Merge branch 'menu_buttons' of https://github.com/johndoh/roundcubemail into johndoh-menu_buttons

pull/6405/head
Aleksander Machniak 6 years ago
commit daf46075d0

@ -47,7 +47,7 @@ function rcube_webmail()
this.group2expand = {}; this.group2expand = {};
this.http_request_jobs = {}; this.http_request_jobs = {};
this.menu_stack = []; this.menu_stack = [];
this.menu_buttons = []; this.menu_buttons = {};
this.entity_selectors = []; this.entity_selectors = [];
this.image_style = {}; this.image_style = {};
@ -125,21 +125,25 @@ function rcube_webmail()
// register a button with popup menu, to set its state according to the state of all commands in the menu // 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) this.register_menu_button = function(button, menu_id)
{ {
var commands = []; if (this.menu_buttons[menu_id]) {
this.menu_buttons[menu_id][0].push(button);
$('#' + menu_id).find('a').each(function() { }
var command, link = $(this), onclick = link.attr('onclick'); else {
var commands = [];
$('#' + menu_id).find('a').each(function() {
var command, link = $(this), onclick = link.attr('onclick');
if (onclick && String(onclick).match(/rcmail\.command\(\'([^']+)/)) if (onclick && String(onclick).match(/rcmail\.command\(\'([^']+)/))
command = RegExp.$1; command = RegExp.$1;
else else
command = function() { return link.is('.active'); }; command = function() { return link.is('.active'); };
commands.push(command); commands.push(command);
}); });
if (commands.length) if (commands.length)
this.menu_buttons.push([button, commands]); this.menu_buttons[menu_id] = [[button], commands];
}
this.set_menu_buttons(); this.set_menu_buttons();
}; };

Loading…
Cancel
Save