diff --git a/program/js/app.js b/program/js/app.js index 0c2a82b5f..595918bcd 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -125,21 +125,24 @@ function rcube_webmail() // register a button with popup menu, to set its state according to the state of all commands in the menu this.register_menu_button = function(button, menu_id) { - var commands = []; + if (!this.menu_buttons[menu_id]) { + this.menu_buttons[menu_id] = [[], []]; + var commands = []; - $('#' + menu_id).find('a').each(function() { - var command, link = $(this), onclick = link.attr('onclick'); + $('#' + menu_id).find('a').each(function() { + var command, link = $(this), onclick = link.attr('onclick'); - if (onclick && String(onclick).match(/rcmail\.command\(\'([^']+)/)) - command = RegExp.$1; - else - command = function() { return link.is('.active'); }; + if (onclick && String(onclick).match(/rcmail\.command\(\'([^']+)/)) + command = RegExp.$1; + else + command = function() { return link.is('.active'); }; - commands.push(command); - }); + ref.menu_buttons[menu_id][1].push(command); + }); + } - if (commands.length) - this.menu_buttons[menu_id] = [button, commands]; + if (ref.menu_buttons[menu_id][1].length) + this.menu_buttons[menu_id][0].push(button); this.set_menu_buttons(); };