forked from corbosman/message_highlight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
message_highlight.js
62 lines (47 loc) · 1.68 KB
/
message_highlight.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
var mh_cur_row;
$(document).ready(function() {
if(window.rcmail) {
rcmail.addEventListener('plugin.mh_receive_row', mh_receive_row);
rcmail.addEventListener('insertrow', function(evt) {
if(!rcmail.env.messages) return;
var message = rcmail.env.messages[evt.row.uid];
// check if our color info is present
if(message.flags && message.flags.plugin_mh_color) {
$(evt.row.obj).addClass('rcmfd_mh_row');
evt.row.obj.style.backgroundColor = message.flags.plugin_mh_color;
}
});
$('#preferences-details').on('click', '.mh_delete', function() {
mh_delete(this);
});
$('#preferences-details').on('click', '.mh_add', function() {
mh_add(this);
});
}
});
function mh_delete(button) {
if(confirm(rcmail.get_label('message_highlight.deleteconfirm'))) {
$(button).closest('tr', '#prefs-details').remove();
}
}
// do an ajax call to get a new row
function mh_add(button) {
mh_cur_row = $(button).closest('tr', '#prefs-details');
lock = rcmail.set_busy(true, 'loading');
rcmail.http_request('plugin.mh_add_row', '', lock);
}
// ajax return call
function mh_receive_row(data) {
var row = data.row;
$(mh_cur_row).after('<tr><td>'+row+'</td></tr>');
//$('.mh_color_input:last').mColorPicker();
$('input[data-mcolorpicker!="true"]').filter(function() {
return ($.fn.mColorPicker.init.replace == '[type=color]')? this.getAttribute("type") == 'color': $(this).is($.fn.mColorPicker.init.replace);
}).mColorPicker({
imageFolder: 'plugins/message_highlight/colorpicker/images/',
allowTransparency: false,
showLogo: false,
liveEvents: false,
checkRedraw: 'ajaxSuccess'
});
}