0
|
1 /**
|
|
2 * ContextMenu plugin script
|
|
3 *
|
|
4 * @licstart The following is the entire license notice for the
|
|
5 * JavaScript code in this file.
|
|
6 *
|
|
7 * Copyright (C) 2014 Philip Weir
|
|
8 *
|
|
9 * The JavaScript code in this page is free software: you can redistribute it
|
|
10 * and/or modify it under the terms of the GNU General Public License
|
|
11 * as published by the Free Software Foundation, either version 3 of
|
|
12 * the License, or (at your option) any later version.
|
|
13 *
|
|
14 * @licend The above is the entire license notice
|
|
15 * for the JavaScript code in this file.
|
|
16 */
|
|
17
|
|
18 rcube_webmail.prototype.context_menu_popup_pattern = /rcmail_ui\.show_popup\(\'([^\']+)\'/;
|
|
19 rcube_webmail.prototype.context_menu_button_active_class = new Array('active', 'button');
|
|
20 rcube_webmail.prototype.context_menu_button_disabled_class = new Array('disabled', 'buttonPas');
|
|
21
|
|
22 function add_menu_text(p) {
|
|
23 if ($(p.item).children('a').hasClass('vcard')) {
|
|
24 $(p.item).children('a').children('span').text($('#abookactions a.vcard').attr('title'));
|
|
25 }
|
|
26 }
|
|
27
|
|
28 function reorder_contact_menu(p) {
|
|
29 // put export link last
|
|
30 var ul = p.ref.container.find('ul:first');
|
|
31 $(p.ref.container).find('a.export').parent('li').appendTo(ul);
|
|
32 }
|
|
33
|
|
34 function reorder_abook_menu(p) {
|
|
35 // remove the remove from group option from the address book menu
|
|
36 p.ref.container.find('a.cmd_group-remove-selected').remove();
|
|
37 }
|
|
38
|
|
39 $(document).ready(function() {
|
|
40 if (window.rcmail) {
|
|
41 if (rcmail.env.task == 'mail' && rcmail.env.action == '') {
|
|
42 rcmail.addEventListener('insertrow', function(props) { rcm_listmenu_init(props.row.id, {'menu_name': 'messagelist', 'menu_source': '#messagetoolbar'}); } );
|
|
43 rcmail.add_onload("rcm_foldermenu_init('#mailboxlist li', {'menu_source': ['#rcmFolderMenu', '#mailboxoptionsmenu ul']})");
|
|
44 }
|
|
45 else if (rcmail.env.task == 'mail' && rcmail.env.action == 'compose') {
|
|
46 rcmail.addEventListener('insertrow', function(props) { rcm_listmenu_init(props.row.id, {'menu_name': 'composeto', 'menu_source': '#abookactions', 'list_object': rcmail.contact_list}, {'insertitem': function(p) { add_menu_text(p); }}); } );
|
|
47 }
|
|
48 else if (rcmail.env.task == 'addressbook' && rcmail.env.action == '') {
|
|
49 rcmail.addEventListener('contextmenu_init', function(menu) {
|
|
50 if (menu.menu_name == 'contactlist') {
|
|
51 // copy the remove from group option in the contact menu
|
|
52 if (btn = $('#' + rcmail.buttons['group-remove-selected'][0].id).clone()) {
|
|
53 // remove the ID and add override class
|
|
54 btn.removeAttr('id').addClass('rcm_active');
|
|
55 btn = $('<li>').attr('role', 'menuitem').append(btn);
|
|
56 btn.insertAfter($('#rcmAddressBookMenu').find('a.assigngroup').parent('li'));
|
|
57 }
|
|
58 }
|
|
59 });
|
|
60 rcmail.addEventListener('insertrow', function(props) { rcm_listmenu_init(props.row.id, {'menu_name': 'contactlist', 'menu_source': ['#abooktoolbar', '#rcmAddressBookMenu'], 'list_object': rcmail.contact_list}, {
|
|
61 'init': function(p) { reorder_contact_menu(p); },
|
|
62 'afteractivate': function(p) {
|
|
63 p.ref.list_selection(false, rcmail.env.contextmenu_selection);
|
|
64
|
|
65 // count the number of groups in the current addressbook
|
|
66 if (!rcmail.env.group || rcmail.env.readonly)
|
|
67 p.ref.container.find('a.cmd_group-remove-selected').removeClass('active').addClass('disabled');
|
|
68
|
|
69 // count the number of groups in the current addressbook
|
|
70 var groupcount = 0;
|
|
71 if (!rcmail.env.readonly && rcmail.env.address_sources[rcmail.env.source] && rcmail.env.address_sources[rcmail.env.source].groups)
|
|
72 $.each(rcmail.env.contactgroups, function(){ if (this.source === rcmail.env.source) groupcount++ });
|
|
73
|
|
74 if (groupcount > 0)
|
|
75 p.ref.container.find('a.assigngroup').removeClass('disabled').addClass('active');
|
|
76 else
|
|
77 p.ref.container.find('a.assigngroup').removeClass('active').addClass('disabled');
|
|
78 },
|
|
79 'aftercommand': function(p) {
|
|
80 if ($(p.el).hasClass('active') && p.command == 'group-remove-selected')
|
|
81 rcmail.command('listgroup', {'source': rcmail.env.source, 'id': rcmail.env.group}, p.el);
|
|
82 }
|
|
83 }); } );
|
|
84 rcmail.add_onload("rcm_abookmenu_init('#directorylist li, #savedsearchlist li', {'menu_source': ['#directorylist-footer', '#groupoptionsmenu ul']}, {'init': function(p) { reorder_abook_menu(p); }})");
|
|
85 rcmail.addEventListener('group_insert', function(props) { rcm_abookmenu_init(props.li, {'menu_source': ['#directorylist-footer', '#groupoptionsmenu ul']}); } );
|
|
86 rcmail.addEventListener('abook_search_insert', function(props) { rcm_abookmenu_init(rcmail.savedsearchlist.get_item('S' + props.id), {'menu_source': ['#directorylist-footer', '#groupoptionsmenu ul']}); } );
|
|
87 }
|
|
88 }
|
|
89 }); |