/* evol.colorpicker 2.2.4 (c) 2014 Olivier Giulieri https://github.com/evoluteur/colorpicker */ !function(a){var b=0,c=window.navigator.userAgent,d=c.indexOf("MSIE ")>0,e=d?"-ie":"",f=d?!1:/mozilla/.test(c.toLowerCase())&&!/webkit/.test(c.toLowerCase()),g=[],h=["ffffff","000000","eeece1","1f497d","4f81bd","c0504d","9bbb59","8064a2","4bacc6","f79646"],i=["f2f2f2","7f7f7f","ddd9c3","c6d9f0","dbe5f1","f2dcdb","ebf1dd","e5e0ec","dbeef3","fdeada","d8d8d8","595959","c4bd97","8db3e2","b8cce4","e5b9b7","d7e3bc","ccc1d9","b7dde8","fbd5b5","bfbfbf","3f3f3f","938953","548dd4","95b3d7","d99694","c3d69b","b2a2c7","92cddc","fac08f","a5a5a5","262626","494429","17365d","366092","953734","76923c","5f497a","31859b","e36c09","7f7f7f","0c0c0c","1d1b10","0f243e","244061","632423","4f6128","3f3151","205867","974806"],j=["c00000","ff0000","ffc000","ffff00","92d050","00b050","00b0f0","0070c0","002060","7030a0"],k=[["003366","336699","3366cc","003399","000099","0000cc","000066"],["006666","006699","0099cc","0066cc","0033cc","0000ff","3333ff","333399"],["669999","009999","33cccc","00ccff","0099ff","0066ff","3366ff","3333cc","666699"],["339966","00cc99","00ffcc","00ffff","33ccff","3399ff","6699ff","6666ff","6600ff","6600cc"],["339933","00cc66","00ff99","66ffcc","66ffff","66ccff","99ccff","9999ff","9966ff","9933ff","9900ff"],["006600","00cc00","00ff00","66ff99","99ffcc","ccffff","ccccff","cc99ff","cc66ff","cc33ff","cc00ff","9900cc"],["003300","009933","33cc33","66ff66","99ff99","ccffcc","ffffff","ffccff","ff99ff","ff66ff","ff00ff","cc00cc","660066"],["333300","009900","66ff33","99ff66","ccff99","ffffcc","ffcccc","ff99cc","ff66cc","ff33cc","cc0099","993399"],["336600","669900","99ff33","ccff66","ffff99","ffcc99","ff9999","ff6699","ff3399","cc3399","990099"],["666633","99cc00","ccff33","ffff66","ffcc66","ff9966","ff6666","ff0066","d60094","993366"],["a58800","cccc00","ffff00","ffcc00","ff9933","ff6600","ff0033","cc0066","660033"],["996633","cc9900","ff9900","cc6600","ff3300","ff0000","cc0000","990033"],["663300","996600","cc3300","993300","990000","800000","993333"]],l=function(a){var b=a.toString(16);return 1==b.length&&(b="0"+b),b},m=function(a){return l(Number(a))},n=function(a){var b=l(a);return b+b+b},o=function(a){if(a.length>10){var b=1+a.indexOf("("),c=a.indexOf(")"),d=a.substring(b,c).split(",");return["#",m(d[0]),m(d[1]),m(d[2])].join("")}return a};a.widget("evol.colorpicker",{version:"2.2.4",options:{color:null,showOn:"both",displayIndicator:!0,history:!0,strings:"Theme Colors,Standard Colors,More Colors,Less Colors,Back to Palette,History,No history yet."},_create:function(){this._paletteIdx=1,this._id="evo-cp"+b++,this._enabled=!0;var c=this;switch(this.element.get(0).tagName){case"INPUT":var g=this.options.color,h=this.element;if(this._isPopup=!0,this._palette=null,null!==g)h.val(g);else{var i=h.val();""!==i&&(g=this.options.color=i)}h.addClass("colorPicker "+this._id).wrap('
').after('
").on("keyup onpaste",function(){var b=a(this).val();b!=c.options.color&&c._setValue(b,!0)});var j=this.options.showOn;("both"===j||"focus"===j)&&h.on("focus",function(){c.showPalette()}),("both"===j||"button"===j)&&h.next().on("click",function(a){a.stopPropagation(),c.showPalette()});break;default:this._isPopup=!1,this._palette=this.element.html(this._paletteHTML()).attr("aria-haspopup","true"),this._bindColors()}null!==g&&this.options.history&&this._add2History(g)},_paletteHTML:function(){var a=this._paletteIdx=Math.abs(this._paletteIdx),b=this.options,c=b.strings.split(",");return['
","",this["_paletteHTML"+a](),"",'
',c[1+a],"",b.history?''+c[5]+"":"","
",b.displayIndicator?this._colorIndHTML(this.options.color)+this._colorIndHTML(""):"","
"].join("")},_colorIndHTML:function(a){return['
"+a+"":"/>",""].join("")},_paletteHTML1:function(){var a=[],b=this.options.strings.split(","),c='
':'">',g='';a.push('',g,b[0],"");for(var k=0;10>k;k++)a.push(c,h[k],f);for(a.push(""),d||a.push(''),a.push(''),k=0;10>k;k++)a.push(c,i[k],f);for(var l=1;4>l;l++)for(a.push(''),k=0;10>k;k++)a.push(c,i[10*l+k],f);for(a.push(''),k=40;50>k;k++)a.push(c,i[k],f);for(a.push("",g,b[1],""),k=0;10>k;k++)a.push(c,j[k],f);return a.push("
"),a.join("")},_paletteHTML2:function(){var a,b,c=[],f='
':'">',h='',i="
";c.push('
');for(var j=0,l=k.length;l>j;j++){c.push(h);var m=k[j];for(a=0,b=m.length;b>a;a++)c.push(f,m[a],g);c.push(i)}c.push('
');var o=[];for(c.push(h),a=255;a>10;a-=10)c.push(f,n(a),g),a-=10,o.push(f,n(a),g);return c.push(i,h,o.join(""),i),c.push("
"),c.join("")},_switchPalette:function(b){if(this._enabled){var c,d,e,f=this.options.strings.split(",");if(a(b).hasClass("evo-hist")){var h=['
',f[5],"
",'
'];if(0===g.length)h.push("

 ",f[6],"

");else for(var i=g.length-1;i>-1;i--)h.push('
');h.push("
"),c=-this._paletteIdx,d=h.join(""),e=f[4]}else this._paletteIdx<0?(c=-this._paletteIdx,this._palette.find(".evo-hist").show()):c=2==this._paletteIdx?1:2,d=this["_paletteHTML"+c](),e=f[c+1],this._paletteIdx=c;this._paletteIdx=c;var j=this._palette.find(".evo-more").prev().html(d).end().children().eq(0).html(e);0>c&&j.next().hide()}},showPalette:function(){if(this._enabled&&(a(".colorPicker").colorpicker("hidePalette"),null===this._palette)){var b=this.element.next().after(this._paletteHTML());this._palette=b.next().on("click",function(a){a.stopPropagation()}),b.position({of:this.element,my:"right top",at:"left bottom",collision:"flip"}),this._bindColors();var c=this;a(document.body).on("click."+this._id,function(a){a.target!=c.element.get(0)&&c.hidePalette()})}return this},hidePalette:function(){if(this._isPopup&&this._palette){a(document.body).off("click."+this._id);var b=this;this._palette.off("mouseover click","td").fadeOut(function(){b._palette.remove(),b._palette=b._cTxt=null}).find(".evo-more a").off("click")}return this},_bindColors:function(){var b=this._palette.find("div.evo-color"),c=this.options.history?"td,.evo-cHist>div":"td";this._cTxt1=b.eq(0).children().eq(0),this._cTxt2=b.eq(1).children().eq(0);var d=this;this._palette.on("click",c,function(){if(d._enabled){var b=o(a(this).attr("style").substring(17));d._setValue(b)}}).on("mouseover",c,function(){if(d._enabled){var b=o(a(this).attr("style").substring(17));d.options.displayIndicator&&d._setColorInd(b,2),d.element.trigger("mouseover.color",b)}}).find(".evo-more a").on("click",function(){d._switchPalette(this)})},val:function(a){return"undefined"==typeof a?this.options.color:(this._setValue(a),this)},_setValue:function(a,b){a=a.replace(/ /g,""),this.options.color=a,this._isPopup?(b||this.hidePalette(),this.element.val(a).next().attr("style","background-color:"+a)):this._setColorInd(a,1),this.options.history&&this._paletteIdx>0&&this._add2History(a),this.element.trigger("change.color",a)},_setColorInd:function(a,b){this["_cTxt"+b].attr("style","background-color:"+a).next().html(a)},_setOption:function(a,b){"color"==a?this._setValue(b,!0):this.options[a]=b},_add2History:function(a){for(var b=g.length,c=0;b>c;c++)if(a==g[c])return;b>27&&g.shift(),g.push(a)},enable:function(){var a=this.element;return this._isPopup?a.removeAttr("disabled"):a.css({opacity:"1","pointer-events":"auto"}),"focus"!==this.options.showOn&&this.element.next().addClass("evo-pointer"),a.removeAttr("aria-disabled"),this._enabled=!0,this},disable:function(){var a=this.element;return this._isPopup?a.attr("disabled","disabled"):(this.hidePalette(),a.css({opacity:"0.3","pointer-events":"none"})),"focus"!==this.options.showOn&&this.element.next().removeClass("evo-pointer"),a.attr("aria-disabled","true"),this._enabled=!1,this},isDisabled:function(){return!this._enabled},destroy:function(){a(document.body).off("click."+this._id),this._palette&&(this._palette.off("mouseover click","td,.evo-cHist>div").find(".evo-more a").off("click"),this._isPopup&&this._palette.remove(),this._palette=this._cTxt=null),this._isPopup&&this.element.next().off("click").remove().end().off("focus").unwrap(),this.element.removeClass("colorPicker "+this.id).empty(),a.Widget.prototype.destroy.call(this)}})}(jQuery);