diff --git a/colorpicker.jquery.json b/colorpicker.jquery.json index 0bc7364..013f4d5 100644 --- a/colorpicker.jquery.json +++ b/colorpicker.jquery.json @@ -1,7 +1,7 @@ { "name": "colorpicker", "title": "Evol ColorPicker", - "version": "2.2.4", + "version": "3.0.0", "description": "A jQuery UI widget for color picking (similar to the one in Microsoft Office 2010).", "keywords": [ "colorpicker", diff --git a/js/evol.colorpicker.js b/js/evol.colorpicker.js index bd6df2d..788b4eb 100755 --- a/js/evol.colorpicker.js +++ b/js/evol.colorpicker.js @@ -1,5 +1,5 @@ /* - evol.colorpicker 2.2.4 + evol.colorpicker 3.0.0 ColorPicker widget for jQuery UI https://github.com/evoluteur/colorpicker @@ -68,7 +68,7 @@ var _idx=0, $.widget( "evol.colorpicker", { - version: '2.2.4', + version: '3.0.0', options: { color: null, // example:'#31859B' diff --git a/js/evol.colorpicker.min.js b/js/evol.colorpicker.min.js index 17676cd..c9efb98 100755 --- a/js/evol.colorpicker.min.js +++ b/js/evol.colorpicker.min.js @@ -1,6 +1,6 @@ /* - evol.colorpicker 2.2.4 + evol.colorpicker 3.0.0 (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="#0000ffff",m=function(a){var b=a.toString(16);return 1==b.length&&(b="0"+b),b},n=function(a){return m(Number(a))},o=function(a){var b=m(a);return b+b+b},p=function(a){if(a.length>10){var b=1+a.indexOf("("),c=a.indexOf(")"),d=a.substring(b,c).split(",");return["#",n(d[0]),n(d[1]),n(d[2])].join("")}return a};a.widget("evol.colorpicker",{version:"2.2.4",options:{color:null,showOn:"both",displayIndicator:!0,transparentColor:!1,history:!0,strings:"Theme Colors,Standard Colors,More Colors,Less Colors,Back to Palette,History,No history yet."},_create:function(){var c=this;switch(this._paletteIdx=1,this._id="evo-cp"+b++,this._enabled=!0,this.element.get(0).tagName){case"INPUT":var g=this.options.color,h=this.element,i=("focus"===this.options.showOn?"":"evo-pointer ")+"evo-colorind"+(f?"-ff":e),j="";if(this._isPopup=!0,this._palette=null,null!==g)h.val(g);else{var k=h.val();""!==k&&(g=this.options.color=k)}g===l?i+=" evo-transparent":j=null!==g?"background-color:"+g:"",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 m=this.options.showOn;("both"===m||"focus"===m)&&h.on("focus",function(){c.showPalette()}),("both"===m||"button"===m)&&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()}g&&this.options.history&&this._add2History(g)},_paletteHTML:function(){var a=this._paletteIdx=Math.abs(this._paletteIdx),b=this.options,c=b.strings.split(","),d='
"+this["_paletteHTML"+a]()+'
'+c[1+a]+"";return b.history&&(d+=''+c[5]+""),d+="
",b.displayIndicator&&(d+=this._colorIndHTML(this.options.color)+this._colorIndHTML("")),d+="
"},_colorIndHTML:function(a){var b=d?"evo-colorbox-ie ":"",c="";return a?a===l?b+="evo-transparent":c="background-color:"+a:c="display:none",'
'+(a?a:"")+"
"},_paletteHTML1:function(){for(var a=this.options,b=a.strings.split(","),c='
':'">',g='',k=''+g+b[0]+"",l=0;10>l;l++)k+=c+h[l]+f;for(k+="",d||(k+=''),k+='',l=0;10>l;l++)k+=c+i[l]+f;for(var m=1;4>m;m++)for(k+='',l=0;10>l;l++)k+=c+i[10*m+l]+f;for(k+='',l=40;50>l;l++)k+=c+i[l]+f;for(k+=""+g,a.transparentColor&&(k+='
'),k+=b[1]+"",l=0;10>l;l++)k+=c+j[l]+f;return k+="
"},_paletteHTML2:function(){for(var a,b,c='
':'">',g='',h="
",i='
',j=0,l=k.length;l>j;j++){i+=g;var m=k[j];for(a=0,b=m.length;b>a;a++)i+=c+m[a]+f;i+=h}i+='
';var n="";for(i+=g,a=255;a>10;a-=10)i+=c+o(a)+f,a-=10,n+=c+o(a)+f;return i+=h+g+n+h+"
"},_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--)9===g[i].length?h.push('
'):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").not("."+this._id).colorpicker("hidePalette"),null===this._palette)){this._palette=this.element.next().after(this._paletteHTML()).next().on("click",function(a){a.stopPropagation()}),this._bindColors();var b=this;a(document.body).on("click."+this._id,function(a){a.target!=b.element.get(0)&&b.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,.evo-transparent").fadeOut(function(){b._palette.remove(),b._palette=b._cTxt=null}).find(".evo-more a").off("click")}return this},_bindColors:function(){var b=this,c=this.options,d=this._palette.find("div.evo-color"),e=c.history?"td,.evo-cHist>div":"td";c.transparentColor&&(e+=",.evo-transparent"),this._cTxt1=d.eq(0).children().eq(0),this._cTxt2=d.eq(1).children().eq(0),this._palette.on("click",e,function(){if(b._enabled){var c=a(this);b._setValue(c.hasClass("evo-transparent")?l:p(c.attr("style").substring(17)))}}).on("mouseover",e,function(){if(b._enabled){var c=a(this),d=c.hasClass("evo-transparent")?l:p(c.attr("style").substring(17));b.options.displayIndicator&&b._setColorInd(d,2),b.element.trigger("mouseover.color",d)}}).find(".evo-more a").on("click",function(){b._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._setBoxColor(this.element.val(a).next(),a)):this._setColorInd(a,1),this.options.history&&this._paletteIdx>0&&this._add2History(a),this.element.trigger("change.color",a)},_setColorInd:function(a,b){var c=this["_cTxt"+b];this._setBoxColor(c,a),c.next().html(a)},_setBoxColor:function(a,b){b===l?a.addClass("evo-transparent").removeAttr("style"):a.removeClass("evo-transparent").attr("style","background-color:"+b)},_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,.evo-transparent").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); \ No newline at end of file +!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="#0000ffff",m=function(a){var b=a.toString(16);return 1==b.length&&(b="0"+b),b},n=function(a){return m(Number(a))},o=function(a){var b=m(a);return b+b+b},p=function(a){if(a.length>10){var b=1+a.indexOf("("),c=a.indexOf(")"),d=a.substring(b,c).split(",");return["#",n(d[0]),n(d[1]),n(d[2])].join("")}return a};a.widget("evol.colorpicker",{version:"3.0.0",options:{color:null,showOn:"both",displayIndicator:!0,transparentColor:!1,history:!0,strings:"Theme Colors,Standard Colors,More Colors,Less Colors,Back to Palette,History,No history yet."},_create:function(){var c=this;switch(this._paletteIdx=1,this._id="evo-cp"+b++,this._enabled=!0,this.element.get(0).tagName){case"INPUT":var g=this.options.color,h=this.element,i=("focus"===this.options.showOn?"":"evo-pointer ")+"evo-colorind"+(f?"-ff":e),j="";if(this._isPopup=!0,this._palette=null,null!==g)h.val(g);else{var k=h.val();""!==k&&(g=this.options.color=k)}g===l?i+=" evo-transparent":j=null!==g?"background-color:"+g:"",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 m=this.options.showOn;("both"===m||"focus"===m)&&h.on("focus",function(){c.showPalette()}),("both"===m||"button"===m)&&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()}g&&this.options.history&&this._add2History(g)},_paletteHTML:function(){var a=this._paletteIdx=Math.abs(this._paletteIdx),b=this.options,c=b.strings.split(","),d='
"+this["_paletteHTML"+a]()+'
'+c[1+a]+"";return b.history&&(d+=''+c[5]+""),d+="
",b.displayIndicator&&(d+=this._colorIndHTML(this.options.color)+this._colorIndHTML("")),d+="
"},_colorIndHTML:function(a){var b=d?"evo-colorbox-ie ":"",c="";return a?a===l?b+="evo-transparent":c="background-color:"+a:c="display:none",'
'+(a?a:"")+"
"},_paletteHTML1:function(){for(var a=this.options,b=a.strings.split(","),c='
':'">',g='',k=''+g+b[0]+"",l=0;10>l;l++)k+=c+h[l]+f;for(k+="",d||(k+=''),k+='',l=0;10>l;l++)k+=c+i[l]+f;for(var m=1;4>m;m++)for(k+='',l=0;10>l;l++)k+=c+i[10*m+l]+f;for(k+='',l=40;50>l;l++)k+=c+i[l]+f;for(k+=""+g,a.transparentColor&&(k+='
'),k+=b[1]+"",l=0;10>l;l++)k+=c+j[l]+f;return k+="
"},_paletteHTML2:function(){for(var a,b,c='
':'">',g='',h="
",i='
',j=0,l=k.length;l>j;j++){i+=g;var m=k[j];for(a=0,b=m.length;b>a;a++)i+=c+m[a]+f;i+=h}i+='
';var n="";for(i+=g,a=255;a>10;a-=10)i+=c+o(a)+f,a-=10,n+=c+o(a)+f;return i+=h+g+n+h+"
"},_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--)9===g[i].length?h.push('
'):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").not("."+this._id).colorpicker("hidePalette"),null===this._palette)){this._palette=this.element.next().after(this._paletteHTML()).next().on("click",function(a){a.stopPropagation()}),this._bindColors();var b=this;a(document.body).on("click."+this._id,function(a){a.target!=b.element.get(0)&&b.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,.evo-transparent").fadeOut(function(){b._palette.remove(),b._palette=b._cTxt=null}).find(".evo-more a").off("click")}return this},_bindColors:function(){var b=this,c=this.options,d=this._palette.find("div.evo-color"),e=c.history?"td,.evo-cHist>div":"td";c.transparentColor&&(e+=",.evo-transparent"),this._cTxt1=d.eq(0).children().eq(0),this._cTxt2=d.eq(1).children().eq(0),this._palette.on("click",e,function(){if(b._enabled){var c=a(this);b._setValue(c.hasClass("evo-transparent")?l:p(c.attr("style").substring(17)))}}).on("mouseover",e,function(){if(b._enabled){var c=a(this),d=c.hasClass("evo-transparent")?l:p(c.attr("style").substring(17));b.options.displayIndicator&&b._setColorInd(d,2),b.element.trigger("mouseover.color",d)}}).find(".evo-more a").on("click",function(){b._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._setBoxColor(this.element.val(a).next(),a)):this._setColorInd(a,1),this.options.history&&this._paletteIdx>0&&this._add2History(a),this.element.trigger("change.color",a)},_setColorInd:function(a,b){var c=this["_cTxt"+b];this._setBoxColor(c,a),c.next().html(a)},_setBoxColor:function(a,b){b===l?a.addClass("evo-transparent").removeAttr("style"):a.removeClass("evo-transparent").attr("style","background-color:"+b)},_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,.evo-transparent").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); \ No newline at end of file diff --git a/package.json b/package.json index 691afd5..6a21bc5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "evol.colorpicker", - "version": "2.2.4", + "version": "3.0.0", "description": "jQuery UI widget for web color picking which looks like the one in Microsoft Office 2010.", "copyright": "(c) 2014 Olivier Giulieri", "homepage": "https://github.com/evoluteur/colorpicker",