From 59478e06c25303a790a0840ab2ac30662c4ef781 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Tue, 5 Aug 2014 16:46:22 +0200 Subject: c'est la merde.. --- plugins/message_highlight/message_highlight.js | 58 ++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 plugins/message_highlight/message_highlight.js (limited to 'plugins/message_highlight/message_highlight.js') diff --git a/plugins/message_highlight/message_highlight.js b/plugins/message_highlight/message_highlight.js new file mode 100644 index 000000000..f6b0c58ec --- /dev/null +++ b/plugins/message_highlight/message_highlight.js @@ -0,0 +1,58 @@ +var mh_cur_row; + +$(document).ready(function() { + if(window.rcmail) { + + rcmail.addEventListener('plugin.mh_receive_row', mh_receive_row); + + rcmail.addEventListener('insertrow', function(evt) { + 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.color = message.flags.plugin_mh_color; + } + }); + + + $('.mh_delete').live('click', function() { + mh_delete(this); + }); + + $('.mh_add').live('click', 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(''+row+''); + //$('.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' + }); +} -- cgit v1.2.3