forked from umount/rcplugin_chbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchbox.js
93 lines (84 loc) · 3.12 KB
/
chbox.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* Check box plugin
* @version 0.2.1
* @author Denis Sobolev
*/
rcube_mail_ui.prototype.selectmenu = function() {
add = {
selectmenu: {id:'selectmenu'}
};
this.popups = $.extend(this.popups, add);
var obj = $('#'+this.popups.selectmenu.id);
if (obj.length)
this.popups.selectmenu.obj = obj;
else {
delete this.popups.selectmenu;
}
}
function rcmail_selectmenu() {
if (!rcmail_ui.popups.selectmenu)
rcmail_ui.selectmenu();
var obj = rcmail_ui.popups['selectmenu'].obj
show = obj.is(':visible') ? false : true;
if(show) {
$('#selectmenu').mouseleave(function() { return rcmail.command('plugin.chbox.selectmenu')});
}else {
$('#selectmenu').unbind('mouseleave');
}
rcmail_ui.show_popupmenu('selectmenu');
return false;
}
function chbox_menu(){
var link_html = '<a href="#" onclick="return rcmail.command(\'plugin.chbox.selectmenu\')">'+rcmail.env.chboxicon;
$('#rcmchbox').html(link_html);
}
if (window.rcmail) {
rcmail.addEventListener('init', function(evt) {
rcmail.register_command('plugin.chbox.selectmenu', rcmail_selectmenu, true);
// add event-listener to message list
if (rcmail.message_list) {
rcmail.message_list.addEventListener('select', function(list){
$('#messagelist input:checked').removeAttr('checked');
var selection = rcmail.message_list ? $.merge([], rcmail.message_list.get_selection()) : [];
// exit if no mailbox specified or if selection is empty
if (!rcmail.env.uid && !selection.length)
return;
// also select childs of collapsed rows
/*
for (var uid, i=0, len=selection.length; i<len; i++) {
uid = selection[i];
if (rcmail.message_list.rows[uid].has_children && !rcmail.message_list.rows[uid].expanded)
rcmail.message_list.select_childs(uid);
}
var selection = rcmail.message_list ? $.merge([], rcmail.message_list.get_selection()) : [];
*/
for (var uid, i=0, len=selection.length; i<len; i++) {
uid = selection[i];
var select = document.getElementById('rcmselect'+uid);
if (select) select.checked = true;
}
});
}
});
rcmail.addEventListener('listupdate','chbox_menu');
rcmail.addEventListener('insertrow', function(evt) {
var row = evt.row
if ((found = $.inArray('chbox', rcmail.env.coltypes)) >= 0) {
rcmail.set_env('chbox_col', found);
}
// set eventhandler to checkbox selection
if (rcmail.env.chbox_col != null && (row.select = document.getElementById('rcmselect'+row.uid))) {
row.select._row = row.obj;
row.select.onclick = function(e) {
// don't include the non-selected checkbox in this
rcmail.message_list.select_row(row.uid, CONTROL_KEY, false);
$("#selectcount").html(rcmail.message_list.selection.length);
};
}
});
}
$(document).ready(function(){
chbox_menu();
var li = '<li><input type="checkbox" name="list_col[]" value="chbox" id="cols_chbox" /><label for="cols_chbox">'+rcmail.get_label('chbox.chbox')+'</label></li>';
$("#listmenu fieldset ul input#cols_threads").parent().after(li);
});