/** * ContextMenu plugin script */ rcube_webmail.prototype.contextmenu_command_handlers = new Object(); rcube_webmail.prototype.contextmenu_disable_multi = new Array('#reply','#reply-all','#reply-list','#forward-inline','#print','#edit','#viewsource','#download','#open','#edit'); function rcm_contextmenu_update() { //if (!rcmail.env.flag_for_deletion && rcmail.env.trash_mailbox && rcmail.env.mailbox != rcmail.env.trash_mailbox) // $("#rcm_delete").html('' + rcmail.gettext('movemessagetotrash') + ''); //else // $("#rcm_delete").html('' + rcmail.gettext('deletemessage') + ''); } function rcm_contextmenu_init(row) { $("#" + row).contextMenu({ menu: 'rcmContextMenu', submenu_delay: 400 }, function(command, el, pos) { var matches = String($(el).attr('id')).match(/rcmrow([a-z0-9\-_=]+)/i); if ($(el) && matches) { var prev_uid = rcmail.env.uid; if (rcmail.message_list.selection.length <= 1 || !rcmail.message_list.in_selection(matches[1])) rcmail.env.uid = matches[1]; // fix command string in IE if (command.indexOf("#") > 0) command = command.substr(command.indexOf("#") + 1); // enable the required command cmd = (command == 'read' || command == 'unread' || command == 'flagged' || command == 'unflagged') ? 'mark' : command; var prev_command = rcmail.commands[cmd]; rcmail.enable_command(cmd, true); // process external commands if (typeof rcmail.contextmenu_command_handlers[command] == 'function') { rcmail.contextmenu_command_handlers[command](command, el, pos); } else if (typeof rcmail.contextmenu_command_handlers[command] == 'string') { window[rcmail.contextmenu_command_handlers[command]](command, el, pos); } else { switch (command) { case 'read': case 'unread': case 'flagged': case 'unflagged': rcmail.command('mark', command, $(el)); break; case 'reply': case 'reply-all': case 'reply-list': case 'forward-inline': case 'forward-attachment': case 'print': case 'download': case 'viewsource': rcmail.command(command, '', $(el)); break; case 'edit': rcmail.command(command, 'new', $(el)); break; case 'open': rcmail.command(command, '', rcube_find_object('rcm_open')); rcmail.sourcewin = window.open(rcube_find_object('rcm_open').href); if (rcmail.sourcewin) window.setTimeout(function() { rcmail.sourcewin.focus(); }, 20); rcube_find_object('rcm_open').href = '#open'; break; case 'delete': case 'moveto': if (command == 'moveto' && rcmail.env.rcm_destfolder == rcmail.env.mailbox) return; var prev_sel = null; // also select childs of (collapsed) threads if (rcmail.env.uid) { if (!rcmail.message_list.in_selection(rcmail.env.uid)) { prev_sel = rcmail.message_list.get_selection(); rcmail.message_list.select_row(rcmail.env.uid); } if (rcmail.message_list.rows[rcmail.env.uid].has_children && !rcmail.message_list.rows[rcmail.env.uid].expanded) rcmail.message_list.select_childs(rcmail.env.uid); rcmail.env.uid = null; } rcmail.command(command, rcmail.env.rcm_destfolder, $(el)); if (prev_sel) { rcmail.message_list.clear_selection(); for (var i in prev_sel) rcmail.message_list.select_row(prev_sel[i], CONTROL_KEY); } delete rcmail.env.rcm_destfolder; break; } } rcmail.enable_command(cmd, prev_command); rcmail.env.uid = prev_uid; } }); } function rcm_set_dest_folder(folder) { rcmail.env.rcm_destfolder = folder; } function rcm_contextmenu_register_command(command, callback, label, pos, sep, multi, newSub, menu, liclass) { if (!menu) menu = $('#rcmContextMenu'); if (!liclass) liclass = command; if (typeof label != 'string') { var menuItem = label.children('li'); } else { var menuItem = $('