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.. --- .../message_highlight/colorpicker/images/color.png | Bin 0 -> 892 bytes .../colorpicker/images/colorpicker.png | Bin 0 -> 4739 bytes .../colorpicker/images/graybar.jpg | Bin 0 -> 5225 bytes .../message_highlight/colorpicker/images/grid.gif | Bin 0 -> 87 bytes .../colorpicker/images/meta100.png | Bin 0 -> 828 bytes .../colorpicker/images/transparentpixel.gif | Bin 0 -> 43 bytes .../message_highlight/colorpicker/mColorPicker.js | 564 +++++++++++++++++++++ plugins/message_highlight/localization/de_DE.inc | 15 + plugins/message_highlight/localization/en_US.inc | 16 + plugins/message_highlight/localization/fr_FR.inc | 16 + plugins/message_highlight/localization/nl_NL.inc | 15 + plugins/message_highlight/localization/ru_RU.inc | 14 + plugins/message_highlight/message_highlight.css | 74 +++ plugins/message_highlight/message_highlight.js | 58 +++ plugins/message_highlight/message_highlight.php | 176 +++++++ plugins/message_highlight/package.xml | 18 + 16 files changed, 966 insertions(+) create mode 100644 plugins/message_highlight/colorpicker/images/color.png create mode 100644 plugins/message_highlight/colorpicker/images/colorpicker.png create mode 100644 plugins/message_highlight/colorpicker/images/graybar.jpg create mode 100644 plugins/message_highlight/colorpicker/images/grid.gif create mode 100644 plugins/message_highlight/colorpicker/images/meta100.png create mode 100644 plugins/message_highlight/colorpicker/images/transparentpixel.gif create mode 100644 plugins/message_highlight/colorpicker/mColorPicker.js create mode 100644 plugins/message_highlight/localization/de_DE.inc create mode 100644 plugins/message_highlight/localization/en_US.inc create mode 100644 plugins/message_highlight/localization/fr_FR.inc create mode 100644 plugins/message_highlight/localization/nl_NL.inc create mode 100644 plugins/message_highlight/localization/ru_RU.inc create mode 100644 plugins/message_highlight/message_highlight.css create mode 100644 plugins/message_highlight/message_highlight.js create mode 100644 plugins/message_highlight/message_highlight.php create mode 100644 plugins/message_highlight/package.xml (limited to 'plugins/message_highlight') diff --git a/plugins/message_highlight/colorpicker/images/color.png b/plugins/message_highlight/colorpicker/images/color.png new file mode 100644 index 000000000..809fb00e5 Binary files /dev/null and b/plugins/message_highlight/colorpicker/images/color.png differ diff --git a/plugins/message_highlight/colorpicker/images/colorpicker.png b/plugins/message_highlight/colorpicker/images/colorpicker.png new file mode 100644 index 000000000..3701eb1c1 Binary files /dev/null and b/plugins/message_highlight/colorpicker/images/colorpicker.png differ diff --git a/plugins/message_highlight/colorpicker/images/graybar.jpg b/plugins/message_highlight/colorpicker/images/graybar.jpg new file mode 100644 index 000000000..f807d24bb Binary files /dev/null and b/plugins/message_highlight/colorpicker/images/graybar.jpg differ diff --git a/plugins/message_highlight/colorpicker/images/grid.gif b/plugins/message_highlight/colorpicker/images/grid.gif new file mode 100644 index 000000000..78b54c0f6 Binary files /dev/null and b/plugins/message_highlight/colorpicker/images/grid.gif differ diff --git a/plugins/message_highlight/colorpicker/images/meta100.png b/plugins/message_highlight/colorpicker/images/meta100.png new file mode 100644 index 000000000..72bea40e8 Binary files /dev/null and b/plugins/message_highlight/colorpicker/images/meta100.png differ diff --git a/plugins/message_highlight/colorpicker/images/transparentpixel.gif b/plugins/message_highlight/colorpicker/images/transparentpixel.gif new file mode 100644 index 000000000..b7406476a Binary files /dev/null and b/plugins/message_highlight/colorpicker/images/transparentpixel.gif differ diff --git a/plugins/message_highlight/colorpicker/mColorPicker.js b/plugins/message_highlight/colorpicker/mColorPicker.js new file mode 100644 index 000000000..6b5d6c381 --- /dev/null +++ b/plugins/message_highlight/colorpicker/mColorPicker.js @@ -0,0 +1,564 @@ +/* + mColorPicker + Version: 1.0 r34 + + Copyright (c) 2010 Meta100 LLC. + http://www.meta100.com/ + + Licensed under the MIT license + http://www.opensource.org/licenses/mit-license.php +*/ + +// After this script loads set: +// $.fn.mColorPicker.init.replace = '.myclass' +// to have this script apply to input.myclass, +// instead of the default input[type=color] +// To turn of automatic operation and run manually set: +// $.fn.mColorPicker.init.replace = false +// To use manually call like any other jQuery plugin +// $('input.foo').mColorPicker({options}) +// options: +// imageFolder - Change to move image location. +// swatches - Initial colors in the swatch, must an array of 10 colors. +// init: +// $.fn.mColorPicker.init.enhancedSwatches - Turn of saving and loading of swatch to cookies. +// $.fn.mColorPicker.init.allowTransparency - Turn off transperancy as a color option. +// $.fn.mColorPicker.init.showLogo - Turn on/off the meta100 logo (You don't really want to turn it off, do you?). + +(function($){ + + var $o; + + $.fn.mColorPicker = function(options) { + + $o = $.extend($.fn.mColorPicker.defaults, options); + + if ($o.swatches.length < 10) $o.swatches = $.fn.mColorPicker.defaults.swatches + if ($("div#mColorPicker").length < 1) $.fn.mColorPicker.drawPicker(); + + if ($('#css_disabled_color_picker').length < 1) $('head').prepend(''); + + $('.mColorPicker').live('keyup', function () { + + try { + + $(this).css({ + 'background-color': $(this).val() + }).css({ + 'color': $.fn.mColorPicker.textColor($(this).css('background-color')) + }).trigger('change'); + } catch (r) {} + }); + + $('.mColorPickerTrigger').live('click', function () { + + $.fn.mColorPicker.colorShow($(this).attr('id').replace('icp_', '')); + }); + + this.each(function () { + + $.fn.mColorPicker.drawPickerTriggers($(this)); + }); + + return this; + }; + + $.fn.mColorPicker.currentColor = false; + $.fn.mColorPicker.currentValue = false; + $.fn.mColorPicker.color = false; + + $.fn.mColorPicker.init = { + replace: '[type=color]', + index: 0, + enhancedSwatches: true, + allowTransparency: true, + checkRedraw: 'DOMUpdated', // Change to 'ajaxSuccess' for ajax only or false if not needed + liveEvents: false, + showLogo: false + }; + + $.fn.mColorPicker.defaults = { + imageFolder: 'images/', + swatches: [ + "#ffffff", + "#ffff00", + "#00ff00", + "#00ffff", + "#0000ff", + "#ff00ff", + "#ff0000", + "#4c2b11", + "#3b3b3b", + "#000000" + ] + }; + + $.fn.mColorPicker.liveEvents = function() { + + $.fn.mColorPicker.init.liveEvents = true; + + if ($.fn.mColorPicker.init.checkRedraw && $.fn.mColorPicker.init.replace) { + + $(document).bind($.fn.mColorPicker.init.checkRedraw + '.mColorPicker', function () { + + $('input[data-mcolorpicker!="true"]').filter(function() { + + return ($.fn.mColorPicker.init.replace == '[type=color]')? this.getAttribute("type") == 'color': $(this).is($.fn.mColorPicker.init.replace); + }).mColorPicker(); + }); + } + }; + + $.fn.mColorPicker.drawPickerTriggers = function ($t) { + + if ($t[0].nodeName.toLowerCase() != 'input') return false; + + var id = $t.attr('id') || 'color_' + $.fn.mColorPicker.init.index++, + hidden = false; + + $t.attr('id', id); + + if ($t.attr('text') == 'hidden' || $t.attr('data-text') == 'hidden') hidden = true; + + var color = $t.val(), + width = ($t.width() > 0)? $t.width(): parseInt($t.css('width'), 10), + height = ($t.height())? $t.height(): parseInt($t.css('height'), 10), + flt = $t.css('float'), + image = (color == 'transparent')? "url('" + $o.imageFolder + "/grid.gif')": '', + colorPicker = ''; + + $('body').append(''); + $('span#color_work_area').append($t.clone(true)); + colorPicker = $('span#color_work_area').html().replace(/type="color"/gi, '').replace(/input /gi, (hidden)? 'input type="hidden"': 'input type="text"'); + $('span#color_work_area').html('').remove(); + $t.after( + (hidden)? ' ': '' + ).after(colorPicker).remove(); + + if (hidden) { + + $('#icp_' + id).css({ + 'background-color': color, + 'background-image': image, + 'display': 'inline-block' + }).attr( + 'class', $('#' + id).attr('class') + ).addClass( + 'mColorPickerTrigger' + ); + } else { + + $('#' + id).css({ + 'background-color': color, + 'background-image': image + }).css({ + 'color': $.fn.mColorPicker.textColor($('#' + id).css('background-color')) + }).after( + '' + ).addClass('mColorPickerInput'); + } + + $('#icp_' + id).attr('data-mcolorpicker', 'true'); + + $('#' + id).addClass('mColorPicker'); + + return $('#' + id); + }; + + $.fn.mColorPicker.drawPicker = function () { + + $(document.createElement("div")).attr( + "id","mColorPicker" + ).css( + 'display','none' + ).html( + '
' + ).appendTo("body"); + + $(document.createElement("div")).attr("id","mColorPickerBg").css({ + 'display': 'none' + }).appendTo("body"); + + for (n = 9; n > -1; n--) { + + $(document.createElement("div")).attr({ + 'id': 'cell' + n, + 'class': "mPastColor" + ((n > 0)? ' mNoLeftBorder': '') + }).html( + ' ' + ).prependTo("#mColorPickerSwatches"); + } + + $('#mColorPicker').css({ + 'border':'1px solid #ccc', + 'color':'#fff', + 'z-index':999998, + 'width':'194px', + 'height':'184px', + 'font-size':'12px', + 'font-family':'times' + }); + + $('.mPastColor').css({ + 'height':'18px', + 'width':'18px', + 'border':'1px solid #000', + 'float':'left' + }); + + $('#colorPreview').css({ + 'height':'50px' + }); + + $('.mNoLeftBorder').css({ + 'border-left':0 + }); + + $('.mClear').css({ + 'clear':'both' + }); + + $('#mColorPickerWrapper').css({ + 'position':'relative', + 'border':'solid 1px gray', + 'z-index':999999 + }); + + $('#mColorPickerImg').css({ + 'height':'128px', + 'width':'192px', + 'border':0, + 'cursor':'crosshair', + 'background-image':"url('" + $o.imageFolder + "colorpicker.png')" + }); + + $('#mColorPickerImgGray').css({ + 'height':'8px', + 'width':'192px', + 'border':0, + 'cursor':'crosshair', + 'background-image':"url('" + $o.imageFolder + "graybar.jpg')" + }); + + $('#mColorPickerInput').css({ + 'border':'solid 1px gray', + 'font-size':'10pt', + 'margin':'3px', + 'width':'80px' + }); + + $('#mColorPickerImgGrid').css({ + 'border':0, + 'height':'20px', + 'width':'20px', + 'vertical-align':'text-bottom' + }); + + $('#mColorPickerSwatches').css({ + 'border-right':'1px solid #000' + }); + + + if ($.fn.mColorPicker.init.allowTransparency) $('#mColorPickerFooter').prepend('transparent'); + if ($.fn.mColorPicker.init.showLogo) $('#mColorPickerFooter').prepend('Meta100 - Designing Fun'); + + $("#mColorPickerBg").click($.fn.mColorPicker.closePicker); + + var swatch = $.fn.mColorPicker.getCookie('swatches'), + i = 0; + + if (typeof swatch == 'string') swatch = swatch.split('||'); + if (swatch == null || $.fn.mColorPicker.init.enhancedSwatches || swatch.length < 10) swatch = $o.swatches; + + $(".mPastColor").each(function() { + + $(this).css('background-color', swatch[i++].toLowerCase()); + }); + }; + + $.fn.mColorPicker.closePicker = function () { + + $(".mColor, .mPastColor, #mColorPickerInput, #mColorPickerWrapper").unbind(); + $("#mColorPickerBg").hide(); + $("#mColorPicker").fadeOut() + }; + + $.fn.mColorPicker.colorShow = function (id) { + + var $e = $("#icp_" + id); + pos = $e.offset(), + $i = $("#" + id); + hex = $i.attr('data-hex') || $i.attr('hex'), + pickerTop = pos.top + $e.outerHeight(), + pickerLeft = pos.left, + $d = $(document), + $m = $("#mColorPicker"); + + if ($i.attr('disabled')) return false; + + // KEEP COLOR PICKER IN VIEWPORT + if (pickerTop + $m.height() > $d.height()) pickerTop = pos.top - $m.height(); + if (pickerLeft + $m.width() > $d.width()) pickerLeft = pos.left - $m.width() + $e.outerWidth(); + + $m.css({ + 'top':(pickerTop) + "px", + 'left':(pickerLeft) + "px", + 'position':'absolute' + }).fadeIn("fast"); + + $("#mColorPickerBg").css({ + 'z-index':999990, + 'background':'black', + 'opacity': .01, + 'position':'absolute', + 'top':0, + 'left':0, + 'width': parseInt($d.width(), 10) + 'px', + 'height': parseInt($d.height(), 10) + 'px' + }).show(); + + var def = $i.val(); + + $('#colorPreview span').text(def); + $('#colorPreview').css('background', def); + $('#color').val(def); + + if ($('#' + id).attr('data-text')) $.fn.mColorPicker.currentColor = $e.css('background-color'); + else $.fn.mColorPicker.currentColor = $i.css('background-color'); + + if (hex == 'true') $.fn.mColorPicker.currentColor = $.fn.mColorPicker.RGBtoHex($.fn.mColorPicker.currentColor); + + $("#mColorPickerInput").val($.fn.mColorPicker.currentColor); + + $('.mColor, .mPastColor').bind('mousemove', function(e) { + + var offset = $(this).offset(); + + $.fn.mColorPicker.color = $(this).css("background-color"); + + if ($(this).hasClass('mPastColor') && hex == 'true') $.fn.mColorPicker.color = $.fn.mColorPicker.RGBtoHex($.fn.mColorPicker.color); + else if ($(this).hasClass('mPastColor') && hex != 'true') $.fn.mColorPicker.color = $.fn.mColorPicker.hexToRGB($.fn.mColorPicker.color); + else if ($(this).attr('id') == 'mColorPickerTransparent') $.fn.mColorPicker.color = 'transparent'; + else if (!$(this).hasClass('mPastColor')) $.fn.mColorPicker.color = $.fn.mColorPicker.whichColor(e.pageX - offset.left, e.pageY - offset.top + (($(this).attr('id') == 'mColorPickerImgGray')? 128: 0), hex); + + $.fn.mColorPicker.setInputColor(id, $.fn.mColorPicker.color); + }).click(function() { + + $.fn.mColorPicker.colorPicked(id); + }); + + $('#mColorPickerInput').bind('keyup', function (e) { + + try { + + $.fn.mColorPicker.color = $('#mColorPickerInput').val(); + $.fn.mColorPicker.setInputColor(id, $.fn.mColorPicker.color); + + if (e.which == 13) $.fn.mColorPicker.colorPicked(id); + } catch (r) {} + + }).bind('blur', function () { + + $.fn.mColorPicker.setInputColor(id, $.fn.mColorPicker.currentColor); + }); + + $('#mColorPickerWrapper').bind('mouseleave', function () { + + $.fn.mColorPicker.setInputColor(id, $.fn.mColorPicker.currentColor); + }); + }; + + $.fn.mColorPicker.setInputColor = function (id, color) { + + var image = (color == 'transparent')? "url('" + $o.imageFolder + "grid.gif')": '', + textColor = $.fn.mColorPicker.textColor(color); + + if ($('#' + id).attr('data-text') || $('#' + id).attr('text')) $("#icp_" + id).css({'background-color': color, 'background-image': image}); + $("#" + id).val(color).css({'background-color': color, 'background-image': image, 'color' : textColor}).trigger('change'); + $("#mColorPickerInput").val(color); + }; + + $.fn.mColorPicker.textColor = function (val) { + + if (typeof val == 'undefined' || val == 'transparent') return "black"; + val = $.fn.mColorPicker.RGBtoHex(val); + return (parseInt(val.substr(1, 2), 16) + parseInt(val.substr(3, 2), 16) + parseInt(val.substr(5, 2), 16) < 400)? 'white': 'black'; + }; + + $.fn.mColorPicker.setCookie = function (name, value, days) { + + var cookie_string = name + "=" + escape(value), + expires = new Date(); + expires.setDate(expires.getDate() + days); + cookie_string += "; expires=" + expires.toGMTString(); + + document.cookie = cookie_string; + }; + + $.fn.mColorPicker.getCookie = function (name) { + + var results = document.cookie.match ( '(^|;) ?' + name + '=([^;]*)(;|$)' ); + + if (results) return (unescape(results[2])); + else return null; + }; + + $.fn.mColorPicker.colorPicked = function (id) { + + $.fn.mColorPicker.closePicker(); + + if ($.fn.mColorPicker.init.enhancedSwatches) $.fn.mColorPicker.addToSwatch(); + + $("#" + id).trigger('colorpicked'); + }; + + $.fn.mColorPicker.addToSwatch = function (color) { + + var swatch = [] + i = 0; + + if (typeof color == 'string') $.fn.mColorPicker.color = color.toLowerCase(); + + $.fn.mColorPicker.currentValue = $.fn.mColorPicker.currentColor = $.fn.mColorPicker.color; + + if ($.fn.mColorPicker.color != 'transparent') swatch[0] = $.fn.mColorPicker.color.toLowerCase(); + + $('.mPastColor').each(function() { + + $.fn.mColorPicker.color = $(this).css('background-color').toLowerCase(); + + if ($.fn.mColorPicker.color != swatch[0] && $.fn.mColorPicker.RGBtoHex($.fn.mColorPicker.color) != swatch[0] && $.fn.mColorPicker.hexToRGB($.fn.mColorPicker.color) != swatch[0] && swatch.length < 10) swatch[swatch.length] = $.fn.mColorPicker.color; + + $(this).css('background-color', swatch[i++]) + }); + + if ($.fn.mColorPicker.init.enhancedSwatches) $.fn.mColorPicker.setCookie('swatches', swatch.join('||'), 365); + }; + + $.fn.mColorPicker.whichColor = function (x, y, hex) { + + var colorR = colorG = colorB = 255; + + if (x < 32) { + + colorG = x * 8; + colorB = 0; + } else if (x < 64) { + + colorR = 256 - (x - 32 ) * 8; + colorB = 0; + } else if (x < 96) { + + colorR = 0; + colorB = (x - 64) * 8; + } else if (x < 128) { + + colorR = 0; + colorG = 256 - (x - 96) * 8; + } else if (x < 160) { + + colorR = (x - 128) * 8; + colorG = 0; + } else { + + colorG = 0; + colorB = 256 - (x - 160) * 8; + } + + if (y < 64) { + + colorR += (256 - colorR) * (64 - y) / 64; + colorG += (256 - colorG) * (64 - y) / 64; + colorB += (256 - colorB) * (64 - y) / 64; + } else if (y <= 128) { + + colorR -= colorR * (y - 64) / 64; + colorG -= colorG * (y - 64) / 64; + colorB -= colorB * (y - 64) / 64; + } else if (y > 128) { + + colorR = colorG = colorB = 256 - ( x / 192 * 256 ); + } + + colorR = Math.round(Math.min(colorR, 255)); + colorG = Math.round(Math.min(colorG, 255)); + colorB = Math.round(Math.min(colorB, 255)); + + if (hex == 'true') { + + colorR = colorR.toString(16); + colorG = colorG.toString(16); + colorB = colorB.toString(16); + + if (colorR.length < 2) colorR = 0 + colorR; + if (colorG.length < 2) colorG = 0 + colorG; + if (colorB.length < 2) colorB = 0 + colorB; + + return "#" + colorR + colorG + colorB; + } + + return "rgb(" + colorR + ', ' + colorG + ', ' + colorB + ')'; + }; + + $.fn.mColorPicker.RGBtoHex = function (color) { + + color = color.toLowerCase(); + + if (typeof color == 'undefined') return ''; + if (color.indexOf('#') > -1 && color.length > 6) return color; + if (color.indexOf('rgb') < 0) return color; + + if (color.indexOf('#') > -1) { + + return '#' + color.substr(1, 1) + color.substr(1, 1) + color.substr(2, 1) + color.substr(2, 1) + color.substr(3, 1) + color.substr(3, 1); + } + + var hexArray = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"], + decToHex = "#", + code1 = 0; + + color = color.replace(/[^0-9,]/g, '').split(","); + + for (var n = 0; n < color.length; n++) { + + code1 = Math.floor(color[n] / 16); + decToHex += hexArray[code1] + hexArray[color[n] - code1 * 16]; + } + + return decToHex; + }; + + $.fn.mColorPicker.hexToRGB = function (color) { + + color = color.toLowerCase(); + + if (typeof color == 'undefined') return ''; + if (color.indexOf('rgb') > -1) return color; + if (color.indexOf('#') < 0) return color; + + var c = color.replace('#', ''); + + if (c.length < 6) c = c.substr(0, 1) + c.substr(0, 1) + c.substr(1, 1) + c.substr(1, 1) + c.substr(2, 1) + c.substr(2, 1); + + return 'rgb(' + parseInt(c.substr(0, 2), 16) + ', ' + parseInt(c.substr(2, 2), 16) + ', ' + parseInt(c.substr(4, 2), 16) + ')'; + }; + + $(document).ready(function () { + + if ($.fn.mColorPicker.init.replace) { + + $('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' + }); + + $.fn.mColorPicker.liveEvents(); + } + }); +})(jQuery); diff --git a/plugins/message_highlight/localization/de_DE.inc b/plugins/message_highlight/localization/de_DE.inc new file mode 100644 index 000000000..a8aecafc9 --- /dev/null +++ b/plugins/message_highlight/localization/de_DE.inc @@ -0,0 +1,15 @@ + diff --git a/plugins/message_highlight/localization/en_US.inc b/plugins/message_highlight/localization/en_US.inc new file mode 100644 index 000000000..4768aba17 --- /dev/null +++ b/plugins/message_highlight/localization/en_US.inc @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/plugins/message_highlight/localization/fr_FR.inc b/plugins/message_highlight/localization/fr_FR.inc new file mode 100644 index 000000000..fc342c22e --- /dev/null +++ b/plugins/message_highlight/localization/fr_FR.inc @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/plugins/message_highlight/localization/nl_NL.inc b/plugins/message_highlight/localization/nl_NL.inc new file mode 100644 index 000000000..b4d29c54a --- /dev/null +++ b/plugins/message_highlight/localization/nl_NL.inc @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/plugins/message_highlight/localization/ru_RU.inc b/plugins/message_highlight/localization/ru_RU.inc new file mode 100644 index 000000000..8f24aa188 --- /dev/null +++ b/plugins/message_highlight/localization/ru_RU.inc @@ -0,0 +1,14 @@ + + diff --git a/plugins/message_highlight/message_highlight.css b/plugins/message_highlight/message_highlight.css new file mode 100644 index 000000000..3d18b3b54 --- /dev/null +++ b/plugins/message_highlight/message_highlight.css @@ -0,0 +1,74 @@ +.rcmfd_mh_row td { + #background-color: transparent !important; +} + +.rcmfd_mh_header { + font-size: 10pt; + margin-right: 10px; +} + +.rcmfd_mh_input { + font-size: 10pt; + margin-left: 10px !important; + margin-right: 10px !important; +} + +.mh_color { + margin-right: 10px; +} + +.mh_color_input_2 { + #background-color:#FF764D; + border:1px solid black; + cursor:pointer; + display:inline-block; + float:none; + height: 20px; + width:100px; + margin-left: 10px; + vertical-align: top; +} + +.mh_color_input { + width: 100px; + height: 20px; + display: none; + padding-top: 4px; + margin-right: 10px; +} + +.mh_button { + margin-left: 10px; +} + +.mh_first { + display: none; +} + +/* icon */ +#sections-table #rcmrowmh_preferences td.section { + background-position: 6px -238px; +} + +#sections-table #rcmrowmh_preferences.selected td.section { + background-position: 6px -262px; +} + +/* remove some colorpicker elements */ +#mColorPickerTransparent, #mColorPickerSwatches, #mColorPickerImgGray { + display: none; +} + +#mColorPickerFooter { + background-color: #ffffff !important; +} + +#mColorPickerImg { + height: 55px !important; +} + +#mColorPicker { + height: 83px !important; + padding: 2px !important; + background-color: #ffffff !important; +} 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' + }); +} diff --git a/plugins/message_highlight/message_highlight.php b/plugins/message_highlight/message_highlight.php new file mode 100644 index 000000000..573257dc0 --- /dev/null +++ b/plugins/message_highlight/message_highlight.php @@ -0,0 +1,176 @@ +add_texts('localization/', array('deleteconfirm')); + $this->add_hook('messages_list', array($this, 'mh_highlight')); + $this->add_hook('preferences_list', array($this, 'mh_preferences')); + $this->add_hook('preferences_save', array($this, 'mh_save')); + $this->add_hook('preferences_sections_list',array($this, 'mh_preferences_section')); + $this->add_hook('storage_init', array($this, 'storage_init')); + + $this->register_action('plugin.mh_add_row', array($this, 'mh_add_row')); + + $this->include_script('message_highlight.js'); + $this->include_script('colorpicker/mColorPicker.js'); + $this->include_stylesheet('message_highlight.css'); + } + + function storage_init($p) + { + $p['fetch_headers'] .= trim($p['fetch_headers']. ' ' . 'CC'); + return($p); + } + + + // add color information for all messages + function mh_highlight($p) + { + $rcmail = rcmail::get_instance(); + $this->prefs = $rcmail->config->get('message_highlight', array()); + + // dont loop over all messages if we dont have any highlights or no msgs + if(!count($this->prefs) or !isset($p['messages']) or !is_array($p['messages'])) return $p; + + // loop over all messages and add highlight color to each message + foreach($p['messages'] as $message) { + if(($color = $this->mh_find_match($message)) !== false ) { + $message->list_flags['extra_flags']['plugin_mh_color'] = $color; + } + } + return($p); + } + + // find a match for this message + function mh_find_match($message) { + foreach($this->prefs as $p) { + if(stristr($message->$p['header'], $p['input'])) { + return($p['color']); + } + } + return false; + } + + // user preferences + function mh_preferences($args) { + if($args['section'] == 'mh_preferences') { + $this->add_texts('localization/', false); + $rcmail = rcmail::get_instance(); + + $args['blocks']['mh_preferences'] = array( + 'options' => array(), + 'name' => Q($this->gettext('mh_title')) + ); + + $i = 1; + $prefs = $rcmail->config->get('message_highlight', array()); + + foreach($prefs as $p) { + $args['blocks']['mh_preferences']['options'][$i++] = array( + 'content' => $this->mh_get_form_row($p['header'], $p['input'], $p['color'], true) + ); + } + + // no rows yet, add 1 empty row + if($i == 1) { + $args['blocks']['mh_preferences']['options'][$i] = array( + 'content' => $this->mh_get_form_row() + ); + } + } + + return($args); + } + + function mh_add_row() { + $rcmail = rcmail::get_instance(); + $rcmail->output->command('plugin.mh_receive_row', array('row' => $this->mh_get_form_row())); + } + + // create a form row + function mh_get_form_row($header = 'from', $input = '', $color = '#ffffff', $delete = false) { + + // header select box + $header_select = new html_select(array('name' => '_mh_header[]', 'class' => 'rcmfd_mh_header')); + $header_select->add(Q($this->gettext('subject')), 'subject'); + $header_select->add(Q($this->gettext('from')), 'from'); + $header_select->add(Q($this->gettext('to')), 'to'); + $header_select->add(Q($this->gettext('cc')), 'cc'); + + // input field + $input = new html_inputfield(array('name' => '_mh_input[]', 'class' => 'rcmfd_mh_input', 'type' => 'text', 'autocomplete' => 'off', 'value' => $input)); + + // color box + $color = html::tag('input', array('id' => uniqid() ,'name' => '_mh_color[]' ,'type' => 'color' ,'text' => 'hidden', 'class' => 'mh_color_input', 'value' => $color, 'data-hex' => 'true')); + + // delete button + $button = html::tag('input', array('class' => 'button mh_delete mh_button', 'type' => 'button', 'value' => $this->gettext('mh_delete'), 'title' => $this->gettext('mh_delete_description'))); + + // add button + $add_button = html::tag('input', array('class' => 'button mh_add mh_button', 'type' => 'button', 'value' => $this->gettext('mh_add'), 'title' => $this->gettext('mh_add_description'))); + + $content = $header_select->show($header) . + html::span('mh_matches', Q($this->gettext('mh_matches'))) . + $input->show() . + html::span('mh_color', Q($this->gettext('mh_color'))) . + $color . $button . $add_button; + + if(rcmail::get_instance()->config->get('request_saver_compress_html', false)){ + $content = request_saver::html_compress($content); + } + + return($content); + } + + // add a section to the preferences tab + function mh_preferences_section($args) { + $this->add_texts('localization/', false); + $args['list']['mh_preferences'] = array( + 'id' => 'mh_preferences', + 'section' => Q($this->gettext('mh_title')) + ); + return($args); + } + + // save preferences + function mh_save($args) { + if($args['section'] != 'mh_preferences') return; + + $rcmail = rcmail::get_instance(); + + $header = get_input_value('_mh_header', RCUBE_INPUT_POST); + $input = get_input_value('_mh_input', RCUBE_INPUT_POST); + $color = get_input_value('_mh_color', RCUBE_INPUT_POST); + + + for($i=0; $i < count($header); $i++) { + if(!in_array($header[$i], array('subject', 'from', 'to', 'cc'))) { + $rcmail->output->show_message('message_highlight.headererror', 'error'); + return; + } + if(!preg_match('/^#[0-9a-fA-F]{2,6}$/', $color[$i])) { + $rcmail->output->show_message('message_highlight.invalidcolor', 'error'); + return; + } + if($input[$i] == '') { + continue; + } + $prefs[] = array('header' => $header[$i], 'input' => $input[$i], 'color' => $color[$i]); + } + + $args['prefs']['message_highlight'] = $prefs; + return($args); + } +} +?> diff --git a/plugins/message_highlight/package.xml b/plugins/message_highlight/package.xml new file mode 100644 index 000000000..8da1c72f5 --- /dev/null +++ b/plugins/message_highlight/package.xml @@ -0,0 +1,18 @@ + + + message_highlight + + Cor Bosman + cor + cor@roundcu.be + yes + + https://github.com/corbosman/message_highlight + + 2.0 + + GNU GPLv2 + -- cgit v1.2.3