spectrum-rails 1.3.4 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/spectrum-rails/version.rb +1 -1
- data/vendor/assets/javascripts/spectrum-min.js +1 -0
- data/vendor/assets/javascripts/spectrum.js +271 -82
- data/vendor/assets/stylesheets/spectrum.css +32 -44
- metadata +13 -16
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8efbe4536f89f861b0facd8473aee4bcc1aaca19
|
4
|
+
data.tar.gz: 3a1a9d3545507354ab8c12fa176218253fd9425d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3dc30c1428790ee112a07de77e2d9a14441417b4e78c2e2fe539d48b71d713aae788c364fa9750b0d2d5048af6f86faf6b58b66c1de29cdcb64fbe92d1b6d29b
|
7
|
+
data.tar.gz: 5706f3da0e61181095f5c04ccfb3e5edb87da6fa8a5e2d001c3aea078fc0bf595e3d4d539a2de247f855528d87186b9436f2c3f9ce119330662d266bb112ec2e
|
@@ -0,0 +1 @@
|
|
1
|
+
!function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports&&"object"==typeof module?module.exports=a:a(jQuery)}(function(a,b){"use strict";function c(b,c,d,e){for(var f=[],g=0;g<b.length;g++){var h=b[g];if(h){var i=tinycolor(h),j=i.toHsl().l<.5?"sp-thumb-el sp-thumb-dark":"sp-thumb-el sp-thumb-light";j+=tinycolor.equals(c,h)?" sp-thumb-active":"";var k=i.toString(e.preferredFormat||"rgb"),l=q?"background-color:"+i.toRgbString():"filter:"+i.toFilter();f.push('<span title="'+k+'" data-color="'+i.toRgbString()+'" class="'+j+'"><span class="sp-thumb-inner" style="'+l+';" /></span>')}else{var m="sp-clear-display";f.push(a("<div />").append(a('<span data-color="" style="background-color:transparent;" class="'+m+'"></span>').attr("title",e.noColorSelectedText)).html())}}return"<div class='sp-cf "+d+"'>"+f.join("")+"</div>"}function d(){for(var a=0;a<o.length;a++)o[a]&&o[a].hide()}function e(b,c){var d=a.extend({},n,b);return d.callbacks={move:j(d.move,c),change:j(d.change,c),show:j(d.show,c),hide:j(d.hide,c),beforeShow:j(d.beforeShow,c)},d}function f(f,h){function j(){if(T.showPaletteOnly&&(T.showPalette=!0),Ka.text(T.showPaletteOnly?T.togglePaletteMoreText:T.togglePaletteLessText),T.palette){la=T.palette.slice(0),ma=a.isArray(la[0])?la:[la],na={};for(var b=0;b<ma.length;b++)for(var c=0;c<ma[b].length;c++){var d=tinycolor(ma[b][c]).toRgbString();na[d]=!0}}va.toggleClass("sp-flat",U),va.toggleClass("sp-input-disabled",!T.showInput),va.toggleClass("sp-alpha-enabled",T.showAlpha),va.toggleClass("sp-clear-enabled",Xa),va.toggleClass("sp-buttons-disabled",!T.showButtons),va.toggleClass("sp-palette-buttons-disabled",!T.togglePaletteOnly),va.toggleClass("sp-palette-disabled",!T.showPalette),va.toggleClass("sp-palette-only",T.showPaletteOnly),va.toggleClass("sp-initial-disabled",!T.showInitial),va.addClass(T.className).addClass(T.containerClassName),N()}function n(){function b(b){return b.data&&b.data.ignore?(G(a(b.target).closest(".sp-thumb-el").data("color")),J()):(G(a(b.target).closest(".sp-thumb-el").data("color")),J(),M(!0),T.hideAfterPaletteSelect&&E()),!1}if(p&&va.find("*:not(input)").attr("unselectable","on"),j(),Na&&ta.after(Oa).hide(),Xa||Ia.hide(),U)ta.after(va).hide();else{var c="parent"===T.appendTo?ta.parent():a(T.appendTo);1!==c.length&&(c=a("body")),c.append(va)}t(),Pa.bind("click.spectrum touchstart.spectrum",function(b){ua||B(),b.stopPropagation(),a(b.target).is("input")||b.preventDefault()}),(ta.is(":disabled")||T.disabled===!0)&&R(),va.click(i),Ea.change(A),Ea.bind("paste",function(){setTimeout(A,1)}),Ea.keydown(function(a){13==a.keyCode&&A()}),Ha.text(T.cancelText),Ha.bind("click.spectrum",function(a){a.stopPropagation(),a.preventDefault(),F(),E()}),Ia.attr("title",T.clearText),Ia.bind("click.spectrum",function(a){a.stopPropagation(),a.preventDefault(),Wa=!0,J(),U&&M(!0)}),Ja.text(T.chooseText),Ja.bind("click.spectrum",function(a){a.stopPropagation(),a.preventDefault(),p&&Ea.is(":focus")&&Ea.trigger("change"),I()&&(M(!0),E())}),Ka.text(T.showPaletteOnly?T.togglePaletteMoreText:T.togglePaletteLessText),Ka.bind("click.spectrum",function(a){a.stopPropagation(),a.preventDefault(),T.showPaletteOnly=!T.showPaletteOnly,T.showPaletteOnly||U||va.css("left","-="+(wa.outerWidth(!0)+5)),j()}),k(Ca,function(a,b,c){ka=a/ea,Wa=!1,c.shiftKey&&(ka=Math.round(10*ka)/10),J()},y,z),k(za,function(a,b){ha=parseFloat(b/ca),Wa=!1,T.showAlpha||(ka=1),J()},y,z),k(xa,function(a,b,c){if(c.shiftKey){if(!ra){var d=ia*_,e=aa-ja*aa,f=Math.abs(a-d)>Math.abs(b-e);ra=f?"x":"y"}}else ra=null;var g=!ra||"x"===ra,h=!ra||"y"===ra;g&&(ia=parseFloat(a/_)),h&&(ja=parseFloat((aa-b)/aa)),Wa=!1,T.showAlpha||(ka=1),J()},y,z),Ra?(G(Ra),K(),Ua=Ta||tinycolor(Ra).format,u(Ra)):K(),U&&C();var d=p?"mousedown.spectrum":"click.spectrum touchstart.spectrum";Fa.delegate(".sp-thumb-el",d,b),Ga.delegate(".sp-thumb-el:nth-child(1)",d,{ignore:!0},b)}function t(){if(W&&window.localStorage){try{var b=window.localStorage[W].split(",#");b.length>1&&(delete window.localStorage[W],a.each(b,function(a,b){u(b)}))}catch(c){}try{oa=window.localStorage[W].split(";")}catch(c){}}}function u(b){if(V){var c=tinycolor(b).toRgbString();if(!na[c]&&-1===a.inArray(c,oa))for(oa.push(c);oa.length>pa;)oa.shift();if(W&&window.localStorage)try{window.localStorage[W]=oa.join(";")}catch(d){}}}function v(){var a=[];if(T.showPalette)for(var b=0;b<oa.length;b++){var c=tinycolor(oa[b]).toRgbString();na[c]||a.push(oa[b])}return a.reverse().slice(0,T.maxSelectionSize)}function w(){var b=H(),d=a.map(ma,function(a,d){return c(a,b,"sp-palette-row sp-palette-row-"+d,T)});t(),oa&&d.push(c(v(),b,"sp-palette-row sp-palette-row-selection",T)),Fa.html(d.join(""))}function x(){if(T.showInitial){var a=Sa,b=H();Ga.html(c([a,b],b,"sp-palette-row-initial",T))}}function y(){(0>=aa||0>=_||0>=ca)&&N(),va.addClass(qa),ra=null,ta.trigger("dragstart.spectrum",[H()])}function z(){va.removeClass(qa),ta.trigger("dragstop.spectrum",[H()])}function A(){var a=Ea.val();if(null!==a&&""!==a||!Xa){var b=tinycolor(a);b.isValid()?(G(b),M(!0)):Ea.addClass("sp-validation-error")}else G(null),M(!0)}function B(){$?E():C()}function C(){var b=a.Event("beforeShow.spectrum");return $?void N():(ta.trigger(b,[H()]),void(Y.beforeShow(H())===!1||b.isDefaultPrevented()||(d(),$=!0,a(sa).bind("click.spectrum",D),a(window).bind("resize.spectrum",Z),Oa.addClass("sp-active"),va.removeClass("sp-hidden"),N(),K(),Sa=H(),x(),Y.show(Sa),ta.trigger("show.spectrum",[Sa]))))}function D(a){2!=a.button&&(Va?M(!0):F(),E())}function E(){$&&!U&&($=!1,a(sa).unbind("click.spectrum",D),a(window).unbind("resize.spectrum",Z),Oa.removeClass("sp-active"),va.addClass("sp-hidden"),Y.hide(H()),ta.trigger("hide.spectrum",[H()]))}function F(){G(Sa,!0)}function G(a,b){if(tinycolor.equals(a,H()))return void K();var c,d;!a&&Xa?Wa=!0:(Wa=!1,c=tinycolor(a),d=c.toHsv(),ha=d.h%360/360,ia=d.s,ja=d.v,ka=d.a),K(),c&&c.isValid()&&!b&&(Ua=Ta||c.getFormat())}function H(a){return a=a||{},Xa&&Wa?null:tinycolor.fromRatio({h:ha,s:ia,v:ja,a:Math.round(100*ka)/100},{format:a.format||Ua})}function I(){return!Ea.hasClass("sp-validation-error")}function J(){K(),Y.move(H()),ta.trigger("move.spectrum",[H()])}function K(){Ea.removeClass("sp-validation-error"),L();var a=tinycolor.fromRatio({h:ha,s:1,v:1});xa.css("background-color",a.toHexString());var b=Ua;1>ka&&(0!==ka||"name"!==b)&&("hex"===b||"hex3"===b||"hex6"===b||"name"===b)&&(b="rgb");var c=H({format:b}),d="";if(Qa.removeClass("sp-clear-display"),Qa.css("background-color","transparent"),!c&&Xa)Qa.addClass("sp-clear-display");else{var e=c.toHexString(),f=c.toRgbString();if(q||1===c.alpha?Qa.css("background-color",f):(Qa.css("background-color","transparent"),Qa.css("filter",c.toFilter())),T.showAlpha){var g=c.toRgb();g.a=0;var h=tinycolor(g).toRgbString(),i="linear-gradient(left, "+h+", "+e+")";p?Ba.css("filter",tinycolor(h).toFilter({gradientType:1},e)):(Ba.css("background","-webkit-"+i),Ba.css("background","-moz-"+i),Ba.css("background","-ms-"+i),Ba.css("background","linear-gradient(to right, "+h+", "+e+")"))}d=c.toString(b)}T.showInput&&Ea.val(d),T.showPalette&&w(),x()}function L(){var a=ia,b=ja;if(Xa&&Wa)Da.hide(),Aa.hide(),ya.hide();else{Da.show(),Aa.show(),ya.show();var c=a*_,d=aa-b*aa;c=Math.max(-ba,Math.min(_-ba,c-ba)),d=Math.max(-ba,Math.min(aa-ba,d-ba)),ya.css({top:d+"px",left:c+"px"});var e=ka*ea;Da.css({left:e-fa/2+"px"});var f=ha*ca;Aa.css({top:f-ga+"px"})}}function M(a){var b=H(),c="",d=!tinycolor.equals(b,Sa);b&&(c=b.toString(Ua),u(b)),La&&ta.val(c),a&&d&&(Y.change(b),ta.trigger("change",[b]))}function N(){_=xa.width(),aa=xa.height(),ba=ya.height(),da=za.width(),ca=za.height(),ga=Aa.height(),ea=Ca.width(),fa=Da.width(),U||(va.css("position","absolute"),va.offset(T.offset?T.offset:g(va,Pa))),L(),T.showPalette&&w(),ta.trigger("reflow.spectrum")}function O(){ta.show(),Pa.unbind("click.spectrum touchstart.spectrum"),va.remove(),Oa.remove(),o[Ya.id]=null}function P(c,d){return c===b?a.extend({},T):d===b?T[c]:(T[c]=d,void j())}function Q(){ua=!1,ta.attr("disabled",!1),Pa.removeClass("sp-disabled")}function R(){E(),ua=!0,ta.attr("disabled",!0),Pa.addClass("sp-disabled")}function S(a){T.offset=a,N()}var T=e(h,f),U=T.flat,V=T.showSelectionPalette,W=T.localStorageKey,X=T.theme,Y=T.callbacks,Z=l(N,10),$=!1,_=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=1,la=[],ma=[],na={},oa=T.selectionPalette.slice(0),pa=T.maxSelectionSize,qa="sp-dragging",ra=null,sa=f.ownerDocument,ta=(sa.body,a(f)),ua=!1,va=a(s,sa).addClass(X),wa=va.find(".sp-picker-container"),xa=va.find(".sp-color"),ya=va.find(".sp-dragger"),za=va.find(".sp-hue"),Aa=va.find(".sp-slider"),Ba=va.find(".sp-alpha-inner"),Ca=va.find(".sp-alpha"),Da=va.find(".sp-alpha-handle"),Ea=va.find(".sp-input"),Fa=va.find(".sp-palette"),Ga=va.find(".sp-initial"),Ha=va.find(".sp-cancel"),Ia=va.find(".sp-clear"),Ja=va.find(".sp-choose"),Ka=va.find(".sp-palette-toggle"),La=ta.is("input"),Ma=La&&"color"===ta.attr("type")&&m(),Na=La&&!U,Oa=Na?a(r).addClass(X).addClass(T.className).addClass(T.replacerClassName):a([]),Pa=Na?Oa:ta,Qa=Oa.find(".sp-preview-inner"),Ra=T.color||La&&ta.val(),Sa=!1,Ta=T.preferredFormat,Ua=Ta,Va=!T.showButtons||T.clickoutFiresChange,Wa=!Ra,Xa=T.allowEmpty&&!Ma;n();var Ya={show:C,hide:E,toggle:B,reflow:N,option:P,enable:Q,disable:R,offset:S,set:function(a){G(a),M()},get:H,destroy:O,container:va};return Ya.id=o.push(Ya)-1,Ya}function g(b,c){var d=0,e=b.outerWidth(),f=b.outerHeight(),g=c.outerHeight(),h=b[0].ownerDocument,i=h.documentElement,j=i.clientWidth+a(h).scrollLeft(),k=i.clientHeight+a(h).scrollTop(),l=c.offset();return l.top+=g,l.left-=Math.min(l.left,l.left+e>j&&j>e?Math.abs(l.left+e-j):0),l.top-=Math.min(l.top,l.top+f>k&&k>f?Math.abs(f+g-d):d),l}function h(){}function i(a){a.stopPropagation()}function j(a,b){var c=Array.prototype.slice,d=c.call(arguments,2);return function(){return a.apply(b,d.concat(c.call(arguments)))}}function k(b,c,d,e){function f(a){a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault(),a.returnValue=!1}function g(a){if(k){if(p&&j.documentMode<9&&!a.button)return i();var d=a.originalEvent&&a.originalEvent.touches&&a.originalEvent.touches[0],e=d&&d.pageX||a.pageX,g=d&&d.pageY||a.pageY,h=Math.max(0,Math.min(e-l.left,n)),q=Math.max(0,Math.min(g-l.top,m));o&&f(a),c.apply(b,[h,q,a])}}function h(c){var e=c.which?3==c.which:2==c.button;e||k||d.apply(b,arguments)!==!1&&(k=!0,m=a(b).height(),n=a(b).width(),l=a(b).offset(),a(j).bind(q),a(j.body).addClass("sp-dragging"),o||g(c),f(c))}function i(){k&&(a(j).unbind(q),a(j.body).removeClass("sp-dragging"),e.apply(b,arguments)),k=!1}c=c||function(){},d=d||function(){},e=e||function(){};var j=document,k=!1,l={},m=0,n=0,o="ontouchstart"in window,q={};q.selectstart=f,q.dragstart=f,q["touchmove mousemove"]=g,q["touchend mouseup"]=i,a(b).bind("touchstart mousedown",h)}function l(a,b,c){var d;return function(){var e=this,f=arguments,g=function(){d=null,a.apply(e,f)};c&&clearTimeout(d),(c||!d)&&(d=setTimeout(g,b))}}function m(){return a.fn.spectrum.inputTypeColorSupport()}var n={beforeShow:h,move:h,change:h,show:h,hide:h,color:!1,flat:!1,showInput:!1,allowEmpty:!1,showButtons:!0,clickoutFiresChange:!1,showInitial:!1,showPalette:!1,showPaletteOnly:!1,hideAfterPaletteSelect:!1,togglePaletteOnly:!1,showSelectionPalette:!0,localStorageKey:!1,appendTo:"body",maxSelectionSize:7,cancelText:"cancel",chooseText:"choose",togglePaletteMoreText:"more",togglePaletteLessText:"less",clearText:"Clear Color Selection",noColorSelectedText:"No Color Selected",preferredFormat:!1,className:"",containerClassName:"",replacerClassName:"",showAlpha:!1,theme:"sp-light",palette:[["#ffffff","#000000","#ff0000","#ff8000","#ffff00","#008000","#0000ff","#4b0082","#9400d3"]],selectionPalette:[],disabled:!1,offset:null},o=[],p=!!/msie/i.exec(window.navigator.userAgent),q=function(){function a(a,b){return!!~(""+a).indexOf(b)}var b=document.createElement("div"),c=b.style;return c.cssText="background-color:rgba(0,0,0,.5)",a(c.backgroundColor,"rgba")||a(c.backgroundColor,"hsla")}(),r=["<div class='sp-replacer'>","<div class='sp-preview'><div class='sp-preview-inner'></div></div>","<div class='sp-dd'>▼</div>","</div>"].join(""),s=function(){var a="";if(p)for(var b=1;6>=b;b++)a+="<div class='sp-"+b+"'></div>";return["<div class='sp-container sp-hidden'>","<div class='sp-palette-container'>","<div class='sp-palette sp-thumb sp-cf'></div>","<div class='sp-palette-button-container sp-cf'>","<button type='button' class='sp-palette-toggle'></button>","</div>","</div>","<div class='sp-picker-container'>","<div class='sp-top sp-cf'>","<div class='sp-fill'></div>","<div class='sp-top-inner'>","<div class='sp-color'>","<div class='sp-sat'>","<div class='sp-val'>","<div class='sp-dragger'></div>","</div>","</div>","</div>","<div class='sp-clear sp-clear-display'>","</div>","<div class='sp-hue'>","<div class='sp-slider'></div>",a,"</div>","</div>","<div class='sp-alpha'><div class='sp-alpha-inner'><div class='sp-alpha-handle'></div></div></div>","</div>","<div class='sp-input-container sp-cf'>","<input class='sp-input' type='text' spellcheck='false' />","</div>","<div class='sp-initial sp-thumb sp-cf'></div>","<div class='sp-button-container sp-cf'>","<a class='sp-cancel' href='#'></a>","<button type='button' class='sp-choose'></button>","</div>","</div>","</div>"].join("")}(),t="spectrum.id";a.fn.spectrum=function(b,c){if("string"==typeof b){var d=this,e=Array.prototype.slice.call(arguments,1);return this.each(function(){var c=o[a(this).data(t)];if(c){var f=c[b];if(!f)throw new Error("Spectrum: no such method: '"+b+"'");"get"==b?d=c.get():"container"==b?d=c.container:"option"==b?d=c.option.apply(c,e):"destroy"==b?(c.destroy(),a(this).removeData(t)):f.apply(c,e)}}),d}return this.spectrum("destroy").each(function(){var c=a.extend({},b,a(this).data()),d=f(this,c);a(this).data(t,d.id)})},a.fn.spectrum.load=!0,a.fn.spectrum.loadOpts={},a.fn.spectrum.draggable=k,a.fn.spectrum.defaults=n,a.fn.spectrum.inputTypeColorSupport=function u(){if("undefined"==typeof u._cachedResult){var b=a("<input type='color' value='!' />")[0];u._cachedResult="color"===b.type&&"!"!==b.value}return u._cachedResult},a.spectrum={},a.spectrum.localization={},a.spectrum.palettes={},a.fn.spectrum.processNativeColorInputs=function(){var b=a("input[type=color]");b.length&&!m()&&b.spectrum({preferredFormat:"hex6"})},function(){function a(a){var c={r:0,g:0,b:0},e=1,g=!1,h=!1;return"string"==typeof a&&(a=G(a)),"object"==typeof a&&(a.hasOwnProperty("r")&&a.hasOwnProperty("g")&&a.hasOwnProperty("b")?(c=b(a.r,a.g,a.b),g=!0,h="%"===String(a.r).substr(-1)?"prgb":"rgb"):a.hasOwnProperty("h")&&a.hasOwnProperty("s")&&a.hasOwnProperty("v")?(a.s=D(a.s),a.v=D(a.v),c=f(a.h,a.s,a.v),g=!0,h="hsv"):a.hasOwnProperty("h")&&a.hasOwnProperty("s")&&a.hasOwnProperty("l")&&(a.s=D(a.s),a.l=D(a.l),c=d(a.h,a.s,a.l),g=!0,h="hsl"),a.hasOwnProperty("a")&&(e=a.a)),e=w(e),{ok:g,format:a.format||h,r:M(255,N(c.r,0)),g:M(255,N(c.g,0)),b:M(255,N(c.b,0)),a:e}}function b(a,b,c){return{r:255*x(a,255),g:255*x(b,255),b:255*x(c,255)}}function c(a,b,c){a=x(a,255),b=x(b,255),c=x(c,255);var d,e,f=N(a,b,c),g=M(a,b,c),h=(f+g)/2;if(f==g)d=e=0;else{var i=f-g;switch(e=h>.5?i/(2-f-g):i/(f+g),f){case a:d=(b-c)/i+(c>b?6:0);break;case b:d=(c-a)/i+2;break;case c:d=(a-b)/i+4}d/=6}return{h:d,s:e,l:h}}function d(a,b,c){function d(a,b,c){return 0>c&&(c+=1),c>1&&(c-=1),1/6>c?a+6*(b-a)*c:.5>c?b:2/3>c?a+(b-a)*(2/3-c)*6:a}var e,f,g;if(a=x(a,360),b=x(b,100),c=x(c,100),0===b)e=f=g=c;else{var h=.5>c?c*(1+b):c+b-c*b,i=2*c-h;e=d(i,h,a+1/3),f=d(i,h,a),g=d(i,h,a-1/3)}return{r:255*e,g:255*f,b:255*g}}function e(a,b,c){a=x(a,255),b=x(b,255),c=x(c,255);var d,e,f=N(a,b,c),g=M(a,b,c),h=f,i=f-g;if(e=0===f?0:i/f,f==g)d=0;else{switch(f){case a:d=(b-c)/i+(c>b?6:0);break;case b:d=(c-a)/i+2;break;case c:d=(a-b)/i+4}d/=6}return{h:d,s:e,v:h}}function f(a,b,c){a=6*x(a,360),b=x(b,100),c=x(c,100);var d=K.floor(a),e=a-d,f=c*(1-b),g=c*(1-e*b),h=c*(1-(1-e)*b),i=d%6,j=[c,g,f,f,h,c][i],k=[h,c,c,g,f,f][i],l=[f,f,h,c,c,g][i];return{r:255*j,g:255*k,b:255*l}}function g(a,b,c,d){var e=[C(L(a).toString(16)),C(L(b).toString(16)),C(L(c).toString(16))];return d&&e[0].charAt(0)==e[0].charAt(1)&&e[1].charAt(0)==e[1].charAt(1)&&e[2].charAt(0)==e[2].charAt(1)?e[0].charAt(0)+e[1].charAt(0)+e[2].charAt(0):e.join("")}function h(a,b,c,d){var e=[C(E(d)),C(L(a).toString(16)),C(L(b).toString(16)),C(L(c).toString(16))];return e.join("")}function i(a,b){b=0===b?0:b||10;var c=P(a).toHsl();return c.s-=b/100,c.s=y(c.s),P(c)}function j(a,b){b=0===b?0:b||10;var c=P(a).toHsl();return c.s+=b/100,c.s=y(c.s),P(c)}function k(a){return P(a).desaturate(100)}function l(a,b){b=0===b?0:b||10;var c=P(a).toHsl();return c.l+=b/100,c.l=y(c.l),P(c)}function m(a,b){b=0===b?0:b||10;var c=P(a).toRgb();return c.r=N(0,M(255,c.r-L(255*-(b/100)))),c.g=N(0,M(255,c.g-L(255*-(b/100)))),c.b=N(0,M(255,c.b-L(255*-(b/100)))),P(c)}function n(a,b){b=0===b?0:b||10;var c=P(a).toHsl();return c.l-=b/100,c.l=y(c.l),P(c)}function o(a,b){var c=P(a).toHsl(),d=(L(c.h)+b)%360;return c.h=0>d?360+d:d,P(c)}function p(a){var b=P(a).toHsl();return b.h=(b.h+180)%360,P(b)}function q(a){var b=P(a).toHsl(),c=b.h;return[P(a),P({h:(c+120)%360,s:b.s,l:b.l}),P({h:(c+240)%360,s:b.s,l:b.l})]}function r(a){var b=P(a).toHsl(),c=b.h;return[P(a),P({h:(c+90)%360,s:b.s,l:b.l}),P({h:(c+180)%360,s:b.s,l:b.l}),P({h:(c+270)%360,s:b.s,l:b.l})]}function s(a){var b=P(a).toHsl(),c=b.h;return[P(a),P({h:(c+72)%360,s:b.s,l:b.l}),P({h:(c+216)%360,s:b.s,l:b.l})]}function t(a,b,c){b=b||6,c=c||30;var d=P(a).toHsl(),e=360/c,f=[P(a)];for(d.h=(d.h-(e*b>>1)+720)%360;--b;)d.h=(d.h+e)%360,f.push(P(d));return f}function u(a,b){b=b||6;for(var c=P(a).toHsv(),d=c.h,e=c.s,f=c.v,g=[],h=1/b;b--;)g.push(P({h:d,s:e,v:f})),f=(f+h)%1;return g}function v(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[a[c]]=c);return b}function w(a){return a=parseFloat(a),(isNaN(a)||0>a||a>1)&&(a=1),a}function x(a,b){A(a)&&(a="100%");var c=B(a);return a=M(b,N(0,parseFloat(a))),c&&(a=parseInt(a*b,10)/100),K.abs(a-b)<1e-6?1:a%b/parseFloat(b)}function y(a){return M(1,N(0,a))}function z(a){return parseInt(a,16)}function A(a){return"string"==typeof a&&-1!=a.indexOf(".")&&1===parseFloat(a)}function B(a){return"string"==typeof a&&-1!=a.indexOf("%")}function C(a){return 1==a.length?"0"+a:""+a}function D(a){return 1>=a&&(a=100*a+"%"),a}function E(a){return Math.round(255*parseFloat(a)).toString(16)}function F(a){return z(a)/255}function G(a){a=a.replace(H,"").replace(I,"").toLowerCase();var b=!1;if(Q[a])a=Q[a],b=!0;else if("transparent"==a)return{r:0,g:0,b:0,a:0,format:"name"};var c;return(c=S.rgb.exec(a))?{r:c[1],g:c[2],b:c[3]}:(c=S.rgba.exec(a))?{r:c[1],g:c[2],b:c[3],a:c[4]}:(c=S.hsl.exec(a))?{h:c[1],s:c[2],l:c[3]}:(c=S.hsla.exec(a))?{h:c[1],s:c[2],l:c[3],a:c[4]}:(c=S.hsv.exec(a))?{h:c[1],s:c[2],v:c[3]}:(c=S.hsva.exec(a))?{h:c[1],s:c[2],v:c[3],a:c[4]}:(c=S.hex8.exec(a))?{a:F(c[1]),r:z(c[2]),g:z(c[3]),b:z(c[4]),format:b?"name":"hex8"}:(c=S.hex6.exec(a))?{r:z(c[1]),g:z(c[2]),b:z(c[3]),format:b?"name":"hex"}:(c=S.hex3.exec(a))?{r:z(c[1]+""+c[1]),g:z(c[2]+""+c[2]),b:z(c[3]+""+c[3]),format:b?"name":"hex"}:!1}var H=/^[\s,#]+/,I=/\s+$/,J=0,K=Math,L=K.round,M=K.min,N=K.max,O=K.random,P=function(b,c){if(b=b?b:"",c=c||{},b instanceof P)return b;if(!(this instanceof P))return new P(b,c);var d=a(b);this._originalInput=b,this._r=d.r,this._g=d.g,this._b=d.b,this._a=d.a,this._roundA=L(100*this._a)/100,this._format=c.format||d.format,this._gradientType=c.gradientType,this._r<1&&(this._r=L(this._r)),this._g<1&&(this._g=L(this._g)),this._b<1&&(this._b=L(this._b)),this._ok=d.ok,this._tc_id=J++};P.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var a=this.toRgb();return(299*a.r+587*a.g+114*a.b)/1e3},setAlpha:function(a){return this._a=w(a),this._roundA=L(100*this._a)/100,this},toHsv:function(){var a=e(this._r,this._g,this._b);return{h:360*a.h,s:a.s,v:a.v,a:this._a}},toHsvString:function(){var a=e(this._r,this._g,this._b),b=L(360*a.h),c=L(100*a.s),d=L(100*a.v);return 1==this._a?"hsv("+b+", "+c+"%, "+d+"%)":"hsva("+b+", "+c+"%, "+d+"%, "+this._roundA+")"},toHsl:function(){var a=c(this._r,this._g,this._b);return{h:360*a.h,s:a.s,l:a.l,a:this._a}},toHslString:function(){var a=c(this._r,this._g,this._b),b=L(360*a.h),d=L(100*a.s),e=L(100*a.l);return 1==this._a?"hsl("+b+", "+d+"%, "+e+"%)":"hsla("+b+", "+d+"%, "+e+"%, "+this._roundA+")"},toHex:function(a){return g(this._r,this._g,this._b,a)},toHexString:function(a){return"#"+this.toHex(a)},toHex8:function(){return h(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:L(this._r),g:L(this._g),b:L(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+L(this._r)+", "+L(this._g)+", "+L(this._b)+")":"rgba("+L(this._r)+", "+L(this._g)+", "+L(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:L(100*x(this._r,255))+"%",g:L(100*x(this._g,255))+"%",b:L(100*x(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+L(100*x(this._r,255))+"%, "+L(100*x(this._g,255))+"%, "+L(100*x(this._b,255))+"%)":"rgba("+L(100*x(this._r,255))+"%, "+L(100*x(this._g,255))+"%, "+L(100*x(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":this._a<1?!1:R[g(this._r,this._g,this._b,!0)]||!1},toFilter:function(a){var b="#"+h(this._r,this._g,this._b,this._a),c=b,d=this._gradientType?"GradientType = 1, ":"";if(a){var e=P(a);c=e.toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+d+"startColorstr="+b+",endColorstr="+c+")"},toString:function(a){var b=!!a;a=a||this._format;var c=!1,d=this._a<1&&this._a>=0,e=!b&&d&&("hex"===a||"hex6"===a||"hex3"===a||"name"===a);return e?"name"===a&&0===this._a?this.toName():this.toRgbString():("rgb"===a&&(c=this.toRgbString()),"prgb"===a&&(c=this.toPercentageRgbString()),("hex"===a||"hex6"===a)&&(c=this.toHexString()),"hex3"===a&&(c=this.toHexString(!0)),"hex8"===a&&(c=this.toHex8String()),"name"===a&&(c=this.toName()),"hsl"===a&&(c=this.toHslString()),"hsv"===a&&(c=this.toHsvString()),c||this.toHexString())},_applyModification:function(a,b){var c=a.apply(null,[this].concat([].slice.call(b)));return this._r=c._r,this._g=c._g,this._b=c._b,this.setAlpha(c._a),this},lighten:function(){return this._applyModification(l,arguments)},brighten:function(){return this._applyModification(m,arguments)},darken:function(){return this._applyModification(n,arguments)},desaturate:function(){return this._applyModification(i,arguments)},saturate:function(){return this._applyModification(j,arguments)},greyscale:function(){return this._applyModification(k,arguments)},spin:function(){return this._applyModification(o,arguments)},_applyCombination:function(a,b){return a.apply(null,[this].concat([].slice.call(b)))},analogous:function(){return this._applyCombination(t,arguments)},complement:function(){return this._applyCombination(p,arguments)},monochromatic:function(){return this._applyCombination(u,arguments)},splitcomplement:function(){return this._applyCombination(s,arguments)},triad:function(){return this._applyCombination(q,arguments)},tetrad:function(){return this._applyCombination(r,arguments)}},P.fromRatio=function(a,b){if("object"==typeof a){var c={};for(var d in a)a.hasOwnProperty(d)&&("a"===d?c[d]=a[d]:c[d]=D(a[d]));a=c}return P(a,b)},P.equals=function(a,b){return a&&b?P(a).toRgbString()==P(b).toRgbString():!1},P.random=function(){return P.fromRatio({r:O(),g:O(),b:O()})},P.mix=function(a,b,c){c=0===c?0:c||50;var d,e=P(a).toRgb(),f=P(b).toRgb(),g=c/100,h=2*g-1,i=f.a-e.a;d=h*i==-1?h:(h+i)/(1+h*i),d=(d+1)/2;var j=1-d,k={r:f.r*d+e.r*j,g:f.g*d+e.g*j,b:f.b*d+e.b*j,a:f.a*g+e.a*(1-g)};return P(k)},P.readability=function(a,b){var c=P(a),d=P(b),e=c.toRgb(),f=d.toRgb(),g=c.getBrightness(),h=d.getBrightness(),i=Math.max(e.r,f.r)-Math.min(e.r,f.r)+Math.max(e.g,f.g)-Math.min(e.g,f.g)+Math.max(e.b,f.b)-Math.min(e.b,f.b);return{brightness:Math.abs(g-h),color:i}},P.isReadable=function(a,b){var c=P.readability(a,b);return c.brightness>125&&c.color>500},P.mostReadable=function(a,b){for(var c=null,d=0,e=!1,f=0;f<b.length;f++){var g=P.readability(a,b[f]),h=g.brightness>125&&g.color>500,i=3*(g.brightness/125)+g.color/500;(h&&!e||h&&e&&i>d||!h&&!e&&i>d)&&(e=h,d=i,c=P(b[f]))}return c};var Q=P.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},R=P.hexNames=v(Q),S=function(){var a="[-\\+]?\\d+%?",b="[-\\+]?\\d*\\.\\d+%?",c="(?:"+b+")|(?:"+a+")",d="[\\s|\\(]+("+c+")[,|\\s]+("+c+")[,|\\s]+("+c+")\\s*\\)?",e="[\\s|\\(]+("+c+")[,|\\s]+("+c+")[,|\\s]+("+c+")[,|\\s]+("+c+")\\s*\\)?";return{rgb:new RegExp("rgb"+d),rgba:new RegExp("rgba"+e),hsl:new RegExp("hsl"+d),hsla:new RegExp("hsla"+e),hsv:new RegExp("hsv"+d),hsva:new RegExp("hsva"+e),hex3:/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();window.tinycolor=P}(),a(function(){a.fn.spectrum.load&&a.fn.spectrum.processNativeColorInputs()})});
|
@@ -1,9 +1,21 @@
|
|
1
|
-
// Spectrum Colorpicker v1.
|
1
|
+
// Spectrum Colorpicker v1.6.2
|
2
2
|
// https://github.com/bgrins/spectrum
|
3
3
|
// Author: Brian Grinstead
|
4
4
|
// License: MIT
|
5
5
|
|
6
|
-
(function (
|
6
|
+
(function (factory) {
|
7
|
+
"use strict";
|
8
|
+
|
9
|
+
if (typeof define === 'function' && define.amd) { // AMD
|
10
|
+
define(['jquery'], factory);
|
11
|
+
}
|
12
|
+
else if (typeof exports == "object" && typeof module == "object") { // CommonJS
|
13
|
+
module.exports = factory;
|
14
|
+
}
|
15
|
+
else { // Browser
|
16
|
+
factory(jQuery);
|
17
|
+
}
|
18
|
+
})(function($, undefined) {
|
7
19
|
"use strict";
|
8
20
|
|
9
21
|
var defaultOpts = {
|
@@ -25,12 +37,16 @@
|
|
25
37
|
showInitial: false,
|
26
38
|
showPalette: false,
|
27
39
|
showPaletteOnly: false,
|
40
|
+
hideAfterPaletteSelect: false,
|
41
|
+
togglePaletteOnly: false,
|
28
42
|
showSelectionPalette: true,
|
29
43
|
localStorageKey: false,
|
30
44
|
appendTo: "body",
|
31
45
|
maxSelectionSize: 7,
|
32
46
|
cancelText: "cancel",
|
33
47
|
chooseText: "choose",
|
48
|
+
togglePaletteMoreText: "more",
|
49
|
+
togglePaletteLessText: "less",
|
34
50
|
clearText: "Clear Color Selection",
|
35
51
|
noColorSelectedText: "No Color Selected",
|
36
52
|
preferredFormat: false,
|
@@ -41,7 +57,8 @@
|
|
41
57
|
theme: "sp-light",
|
42
58
|
palette: [["#ffffff", "#000000", "#ff0000", "#ff8000", "#ffff00", "#008000", "#0000ff", "#4b0082", "#9400d3"]],
|
43
59
|
selectionPalette: [],
|
44
|
-
disabled: false
|
60
|
+
disabled: false,
|
61
|
+
offset: null
|
45
62
|
},
|
46
63
|
spectrums = [],
|
47
64
|
IE = !!/msie/i.exec( window.navigator.userAgent ),
|
@@ -55,10 +72,6 @@
|
|
55
72
|
style.cssText = 'background-color:rgba(0,0,0,.5)';
|
56
73
|
return contains(style.backgroundColor, 'rgba') || contains(style.backgroundColor, 'hsla');
|
57
74
|
})(),
|
58
|
-
inputTypeColorSupport = (function() {
|
59
|
-
var colorInput = $("<input type='color' value='!' />")[0];
|
60
|
-
return colorInput.type === "color" && colorInput.value !== "!";
|
61
|
-
})(),
|
62
75
|
replaceInput = [
|
63
76
|
"<div class='sp-replacer'>",
|
64
77
|
"<div class='sp-preview'><div class='sp-preview-inner'></div></div>",
|
@@ -80,6 +93,9 @@
|
|
80
93
|
"<div class='sp-container sp-hidden'>",
|
81
94
|
"<div class='sp-palette-container'>",
|
82
95
|
"<div class='sp-palette sp-thumb sp-cf'></div>",
|
96
|
+
"<div class='sp-palette-button-container sp-cf'>",
|
97
|
+
"<button type='button' class='sp-palette-toggle'></button>",
|
98
|
+
"</div>",
|
83
99
|
"</div>",
|
84
100
|
"<div class='sp-picker-container'>",
|
85
101
|
"<div class='sp-top sp-cf'>",
|
@@ -194,6 +210,7 @@
|
|
194
210
|
boundElement = $(element),
|
195
211
|
disabled = false,
|
196
212
|
container = $(markup, doc).addClass(theme),
|
213
|
+
pickerContainer = container.find(".sp-picker-container"),
|
197
214
|
dragger = container.find(".sp-color"),
|
198
215
|
dragHelper = container.find(".sp-dragger"),
|
199
216
|
slider = container.find(".sp-hue"),
|
@@ -207,8 +224,9 @@
|
|
207
224
|
cancelButton = container.find(".sp-cancel"),
|
208
225
|
clearButton = container.find(".sp-clear"),
|
209
226
|
chooseButton = container.find(".sp-choose"),
|
227
|
+
toggleButton = container.find(".sp-palette-toggle"),
|
210
228
|
isInput = boundElement.is("input"),
|
211
|
-
isInputTypeColor = isInput &&
|
229
|
+
isInputTypeColor = isInput && boundElement.attr("type") === "color" && inputTypeColorSupport(),
|
212
230
|
shouldReplace = isInput && !flat,
|
213
231
|
replacer = (shouldReplace) ? $(replaceInput).addClass(theme).addClass(opts.className).addClass(opts.replacerClassName) : $([]),
|
214
232
|
offsetElement = (shouldReplace) ? replacer : boundElement,
|
@@ -227,6 +245,8 @@
|
|
227
245
|
opts.showPalette = true;
|
228
246
|
}
|
229
247
|
|
248
|
+
toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText);
|
249
|
+
|
230
250
|
if (opts.palette) {
|
231
251
|
palette = opts.palette.slice(0);
|
232
252
|
paletteArray = $.isArray(palette[0]) ? palette : [palette];
|
@@ -244,6 +264,7 @@
|
|
244
264
|
container.toggleClass("sp-alpha-enabled", opts.showAlpha);
|
245
265
|
container.toggleClass("sp-clear-enabled", allowEmpty);
|
246
266
|
container.toggleClass("sp-buttons-disabled", !opts.showButtons);
|
267
|
+
container.toggleClass("sp-palette-buttons-disabled", !opts.togglePaletteOnly);
|
247
268
|
container.toggleClass("sp-palette-disabled", !opts.showPalette);
|
248
269
|
container.toggleClass("sp-palette-only", opts.showPaletteOnly);
|
249
270
|
container.toggleClass("sp-initial-disabled", !opts.showInitial);
|
@@ -313,7 +334,8 @@
|
|
313
334
|
cancelButton.bind("click.spectrum", function (e) {
|
314
335
|
e.stopPropagation();
|
315
336
|
e.preventDefault();
|
316
|
-
|
337
|
+
revert();
|
338
|
+
hide();
|
317
339
|
});
|
318
340
|
|
319
341
|
clearButton.attr("title", opts.clearText);
|
@@ -334,12 +356,34 @@
|
|
334
356
|
e.stopPropagation();
|
335
357
|
e.preventDefault();
|
336
358
|
|
359
|
+
if (IE && textInput.is(":focus")) {
|
360
|
+
textInput.trigger('change');
|
361
|
+
}
|
362
|
+
|
337
363
|
if (isValid()) {
|
338
364
|
updateOriginalInput(true);
|
339
365
|
hide();
|
340
366
|
}
|
341
367
|
});
|
342
368
|
|
369
|
+
toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText);
|
370
|
+
toggleButton.bind("click.spectrum", function (e) {
|
371
|
+
e.stopPropagation();
|
372
|
+
e.preventDefault();
|
373
|
+
|
374
|
+
opts.showPaletteOnly = !opts.showPaletteOnly;
|
375
|
+
|
376
|
+
// To make sure the Picker area is drawn on the right, next to the
|
377
|
+
// Palette area (and not below the palette), first move the Palette
|
378
|
+
// to the left to make space for the picker, plus 5px extra.
|
379
|
+
// The 'applyOptions' function puts the whole container back into place
|
380
|
+
// and takes care of the button-text and the sp-palette-only CSS class.
|
381
|
+
if (!opts.showPaletteOnly && !flat) {
|
382
|
+
container.css('left', '-=' + (pickerContainer.outerWidth(true) + 5));
|
383
|
+
}
|
384
|
+
applyOptions();
|
385
|
+
});
|
386
|
+
|
343
387
|
draggable(alphaSlider, function (dragX, dragY, e) {
|
344
388
|
currentAlpha = (dragX / alphaWidth);
|
345
389
|
isEmpty = false;
|
@@ -410,24 +454,26 @@
|
|
410
454
|
show();
|
411
455
|
}
|
412
456
|
|
413
|
-
function
|
457
|
+
function paletteElementClick(e) {
|
414
458
|
if (e.data && e.data.ignore) {
|
415
|
-
set($(e.target).data("color"));
|
459
|
+
set($(e.target).closest(".sp-thumb-el").data("color"));
|
416
460
|
move();
|
417
461
|
}
|
418
462
|
else {
|
419
|
-
set($(e.target).data("color"));
|
463
|
+
set($(e.target).closest(".sp-thumb-el").data("color"));
|
420
464
|
move();
|
421
465
|
updateOriginalInput(true);
|
422
|
-
|
466
|
+
if (opts.hideAfterPaletteSelect) {
|
467
|
+
hide();
|
468
|
+
}
|
423
469
|
}
|
424
470
|
|
425
471
|
return false;
|
426
472
|
}
|
427
473
|
|
428
474
|
var paletteEvent = IE ? "mousedown.spectrum" : "click.spectrum touchstart.spectrum";
|
429
|
-
paletteContainer.delegate(".sp-thumb-el", paletteEvent,
|
430
|
-
initialColorContainer.delegate(".sp-thumb-el:nth-child(1)", paletteEvent, { ignore: true },
|
475
|
+
paletteContainer.delegate(".sp-thumb-el", paletteEvent, paletteElementClick);
|
476
|
+
initialColorContainer.delegate(".sp-thumb-el:nth-child(1)", paletteEvent, { ignore: true }, paletteElementClick);
|
431
477
|
}
|
432
478
|
|
433
479
|
function updateSelectionPaletteFromStorage() {
|
@@ -572,7 +618,7 @@
|
|
572
618
|
hideAll();
|
573
619
|
visible = true;
|
574
620
|
|
575
|
-
$(doc).bind("click.spectrum",
|
621
|
+
$(doc).bind("click.spectrum", clickout);
|
576
622
|
$(window).bind("resize.spectrum", resize);
|
577
623
|
replacer.addClass("sp-active");
|
578
624
|
container.removeClass("sp-hidden");
|
@@ -587,32 +633,30 @@
|
|
587
633
|
boundElement.trigger('show.spectrum', [ colorOnShow ]);
|
588
634
|
}
|
589
635
|
|
590
|
-
function
|
636
|
+
function clickout(e) {
|
637
|
+
// Return on right click.
|
638
|
+
if (e.button == 2) { return; }
|
591
639
|
|
592
|
-
|
593
|
-
|
640
|
+
if (clickoutFiresChange) {
|
641
|
+
updateOriginalInput(true);
|
642
|
+
}
|
643
|
+
else {
|
644
|
+
revert();
|
645
|
+
}
|
646
|
+
hide();
|
647
|
+
}
|
594
648
|
|
649
|
+
function hide() {
|
595
650
|
// Return if hiding is unnecessary
|
596
651
|
if (!visible || flat) { return; }
|
597
652
|
visible = false;
|
598
653
|
|
599
|
-
$(doc).unbind("click.spectrum",
|
654
|
+
$(doc).unbind("click.spectrum", clickout);
|
600
655
|
$(window).unbind("resize.spectrum", resize);
|
601
656
|
|
602
657
|
replacer.removeClass("sp-active");
|
603
658
|
container.addClass("sp-hidden");
|
604
659
|
|
605
|
-
var colorHasChanged = !tinycolor.equals(get(), colorOnShow);
|
606
|
-
|
607
|
-
if (colorHasChanged) {
|
608
|
-
if (clickoutFiresChange && e !== "cancel") {
|
609
|
-
updateOriginalInput(true);
|
610
|
-
}
|
611
|
-
else {
|
612
|
-
revert();
|
613
|
-
}
|
614
|
-
}
|
615
|
-
|
616
660
|
callbacks.hide(get());
|
617
661
|
boundElement.trigger('hide.spectrum', [ get() ]);
|
618
662
|
}
|
@@ -811,8 +855,6 @@
|
|
811
855
|
boundElement.val(displayColor);
|
812
856
|
}
|
813
857
|
|
814
|
-
colorOnShow = color;
|
815
|
-
|
816
858
|
if (fireCallback && hasChanged) {
|
817
859
|
callbacks.change(color);
|
818
860
|
boundElement.trigger('change', [ color ]);
|
@@ -831,7 +873,11 @@
|
|
831
873
|
|
832
874
|
if (!flat) {
|
833
875
|
container.css("position", "absolute");
|
834
|
-
|
876
|
+
if (opts.offset) {
|
877
|
+
container.offset(opts.offset);
|
878
|
+
} else {
|
879
|
+
container.offset(getOffset(container, offsetElement));
|
880
|
+
}
|
835
881
|
}
|
836
882
|
|
837
883
|
updateHelperLocations();
|
@@ -876,6 +922,11 @@
|
|
876
922
|
offsetElement.addClass("sp-disabled");
|
877
923
|
}
|
878
924
|
|
925
|
+
function setOffset(coord) {
|
926
|
+
opts.offset = coord;
|
927
|
+
reflow();
|
928
|
+
}
|
929
|
+
|
879
930
|
initialize();
|
880
931
|
|
881
932
|
var spect = {
|
@@ -886,6 +937,7 @@
|
|
886
937
|
option: option,
|
887
938
|
enable: enable,
|
888
939
|
disable: disable,
|
940
|
+
offset: setOffset,
|
889
941
|
set: function (c) {
|
890
942
|
set(c);
|
891
943
|
updateOriginalInput();
|
@@ -961,7 +1013,7 @@
|
|
961
1013
|
onmove = onmove || function () { };
|
962
1014
|
onstart = onstart || function () { };
|
963
1015
|
onstop = onstop || function () { };
|
964
|
-
var doc =
|
1016
|
+
var doc = document;
|
965
1017
|
var dragging = false;
|
966
1018
|
var offset = {};
|
967
1019
|
var maxHeight = 0;
|
@@ -987,13 +1039,13 @@
|
|
987
1039
|
function move(e) {
|
988
1040
|
if (dragging) {
|
989
1041
|
// Mouseup happened outside of window
|
990
|
-
if (IE &&
|
1042
|
+
if (IE && doc.documentMode < 9 && !e.button) {
|
991
1043
|
return stop();
|
992
1044
|
}
|
993
1045
|
|
994
|
-
var
|
995
|
-
var pageX =
|
996
|
-
var pageY =
|
1046
|
+
var t0 = e.originalEvent && e.originalEvent.touches && e.originalEvent.touches[0];
|
1047
|
+
var pageX = t0 && t0.pageX || e.pageX;
|
1048
|
+
var pageY = t0 && t0.pageY || e.pageY;
|
997
1049
|
|
998
1050
|
var dragX = Math.max(0, Math.min(pageX - offset.left, maxWidth));
|
999
1051
|
var dragY = Math.max(0, Math.min(pageY - offset.top, maxHeight));
|
@@ -1009,7 +1061,6 @@
|
|
1009
1061
|
|
1010
1062
|
function start(e) {
|
1011
1063
|
var rightclick = (e.which) ? (e.which == 3) : (e.button == 2);
|
1012
|
-
var touches = e.originalEvent.touches;
|
1013
1064
|
|
1014
1065
|
if (!rightclick && !dragging) {
|
1015
1066
|
if (onstart.apply(element, arguments) !== false) {
|
@@ -1055,6 +1106,10 @@
|
|
1055
1106
|
};
|
1056
1107
|
}
|
1057
1108
|
|
1109
|
+
function inputTypeColorSupport() {
|
1110
|
+
return $.fn.spectrum.inputTypeColorSupport();
|
1111
|
+
}
|
1112
|
+
|
1058
1113
|
/**
|
1059
1114
|
* Define a jQuery plugin
|
1060
1115
|
*/
|
@@ -1108,22 +1163,30 @@
|
|
1108
1163
|
$.fn.spectrum.loadOpts = {};
|
1109
1164
|
$.fn.spectrum.draggable = draggable;
|
1110
1165
|
$.fn.spectrum.defaults = defaultOpts;
|
1166
|
+
$.fn.spectrum.inputTypeColorSupport = function inputTypeColorSupport() {
|
1167
|
+
if (typeof inputTypeColorSupport._cachedResult === "undefined") {
|
1168
|
+
var colorInput = $("<input type='color' value='!' />")[0];
|
1169
|
+
inputTypeColorSupport._cachedResult = colorInput.type === "color" && colorInput.value !== "!";
|
1170
|
+
}
|
1171
|
+
return inputTypeColorSupport._cachedResult;
|
1172
|
+
};
|
1111
1173
|
|
1112
1174
|
$.spectrum = { };
|
1113
1175
|
$.spectrum.localization = { };
|
1114
1176
|
$.spectrum.palettes = { };
|
1115
1177
|
|
1116
1178
|
$.fn.spectrum.processNativeColorInputs = function () {
|
1117
|
-
|
1118
|
-
|
1179
|
+
var colorInputs = $("input[type=color]");
|
1180
|
+
if (colorInputs.length && !inputTypeColorSupport()) {
|
1181
|
+
colorInputs.spectrum({
|
1119
1182
|
preferredFormat: "hex6"
|
1120
1183
|
});
|
1121
1184
|
}
|
1122
1185
|
};
|
1123
1186
|
|
1124
|
-
// TinyColor
|
1187
|
+
// TinyColor v1.1.2
|
1125
1188
|
// https://github.com/bgrins/TinyColor
|
1126
|
-
//
|
1189
|
+
// Brian Grinstead, MIT License
|
1127
1190
|
|
1128
1191
|
(function() {
|
1129
1192
|
|
@@ -1136,7 +1199,7 @@
|
|
1136
1199
|
mathMax = math.max,
|
1137
1200
|
mathRandom = math.random;
|
1138
1201
|
|
1139
|
-
var tinycolor = function
|
1202
|
+
var tinycolor = function(color, opts) {
|
1140
1203
|
|
1141
1204
|
color = (color) ? color : '';
|
1142
1205
|
opts = opts || { };
|
@@ -1151,6 +1214,7 @@
|
|
1151
1214
|
}
|
1152
1215
|
|
1153
1216
|
var rgb = inputToRGB(color);
|
1217
|
+
this._originalInput = color,
|
1154
1218
|
this._r = rgb.r,
|
1155
1219
|
this._g = rgb.g,
|
1156
1220
|
this._b = rgb.b,
|
@@ -1172,18 +1236,32 @@
|
|
1172
1236
|
};
|
1173
1237
|
|
1174
1238
|
tinycolor.prototype = {
|
1239
|
+
isDark: function() {
|
1240
|
+
return this.getBrightness() < 128;
|
1241
|
+
},
|
1242
|
+
isLight: function() {
|
1243
|
+
return !this.isDark();
|
1244
|
+
},
|
1175
1245
|
isValid: function() {
|
1176
1246
|
return this._ok;
|
1177
1247
|
},
|
1248
|
+
getOriginalInput: function() {
|
1249
|
+
return this._originalInput;
|
1250
|
+
},
|
1178
1251
|
getFormat: function() {
|
1179
1252
|
return this._format;
|
1180
1253
|
},
|
1181
1254
|
getAlpha: function() {
|
1182
1255
|
return this._a;
|
1183
1256
|
},
|
1257
|
+
getBrightness: function() {
|
1258
|
+
var rgb = this.toRgb();
|
1259
|
+
return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
|
1260
|
+
},
|
1184
1261
|
setAlpha: function(value) {
|
1185
1262
|
this._a = boundAlpha(value);
|
1186
1263
|
this._roundA = mathRound(100*this._a) / 100;
|
1264
|
+
return this;
|
1187
1265
|
},
|
1188
1266
|
toHsv: function() {
|
1189
1267
|
var hsv = rgbToHsv(this._r, this._g, this._b);
|
@@ -1300,6 +1378,58 @@
|
|
1300
1378
|
}
|
1301
1379
|
|
1302
1380
|
return formattedString || this.toHexString();
|
1381
|
+
},
|
1382
|
+
|
1383
|
+
_applyModification: function(fn, args) {
|
1384
|
+
var color = fn.apply(null, [this].concat([].slice.call(args)));
|
1385
|
+
this._r = color._r;
|
1386
|
+
this._g = color._g;
|
1387
|
+
this._b = color._b;
|
1388
|
+
this.setAlpha(color._a);
|
1389
|
+
return this;
|
1390
|
+
},
|
1391
|
+
lighten: function() {
|
1392
|
+
return this._applyModification(lighten, arguments);
|
1393
|
+
},
|
1394
|
+
brighten: function() {
|
1395
|
+
return this._applyModification(brighten, arguments);
|
1396
|
+
},
|
1397
|
+
darken: function() {
|
1398
|
+
return this._applyModification(darken, arguments);
|
1399
|
+
},
|
1400
|
+
desaturate: function() {
|
1401
|
+
return this._applyModification(desaturate, arguments);
|
1402
|
+
},
|
1403
|
+
saturate: function() {
|
1404
|
+
return this._applyModification(saturate, arguments);
|
1405
|
+
},
|
1406
|
+
greyscale: function() {
|
1407
|
+
return this._applyModification(greyscale, arguments);
|
1408
|
+
},
|
1409
|
+
spin: function() {
|
1410
|
+
return this._applyModification(spin, arguments);
|
1411
|
+
},
|
1412
|
+
|
1413
|
+
_applyCombination: function(fn, args) {
|
1414
|
+
return fn.apply(null, [this].concat([].slice.call(args)));
|
1415
|
+
},
|
1416
|
+
analogous: function() {
|
1417
|
+
return this._applyCombination(analogous, arguments);
|
1418
|
+
},
|
1419
|
+
complement: function() {
|
1420
|
+
return this._applyCombination(complement, arguments);
|
1421
|
+
},
|
1422
|
+
monochromatic: function() {
|
1423
|
+
return this._applyCombination(monochromatic, arguments);
|
1424
|
+
},
|
1425
|
+
splitcomplement: function() {
|
1426
|
+
return this._applyCombination(splitcomplement, arguments);
|
1427
|
+
},
|
1428
|
+
triad: function() {
|
1429
|
+
return this._applyCombination(triad, arguments);
|
1430
|
+
},
|
1431
|
+
tetrad: function() {
|
1432
|
+
return this._applyCombination(tetrad, arguments);
|
1303
1433
|
}
|
1304
1434
|
};
|
1305
1435
|
|
@@ -1581,58 +1711,72 @@
|
|
1581
1711
|
// Thanks to less.js for some of the basics here
|
1582
1712
|
// <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
|
1583
1713
|
|
1584
|
-
|
1714
|
+
function desaturate(color, amount) {
|
1585
1715
|
amount = (amount === 0) ? 0 : (amount || 10);
|
1586
1716
|
var hsl = tinycolor(color).toHsl();
|
1587
1717
|
hsl.s -= amount / 100;
|
1588
1718
|
hsl.s = clamp01(hsl.s);
|
1589
1719
|
return tinycolor(hsl);
|
1590
|
-
}
|
1591
|
-
|
1720
|
+
}
|
1721
|
+
|
1722
|
+
function saturate(color, amount) {
|
1592
1723
|
amount = (amount === 0) ? 0 : (amount || 10);
|
1593
1724
|
var hsl = tinycolor(color).toHsl();
|
1594
1725
|
hsl.s += amount / 100;
|
1595
1726
|
hsl.s = clamp01(hsl.s);
|
1596
1727
|
return tinycolor(hsl);
|
1597
|
-
}
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1728
|
+
}
|
1729
|
+
|
1730
|
+
function greyscale(color) {
|
1731
|
+
return tinycolor(color).desaturate(100);
|
1732
|
+
}
|
1733
|
+
|
1734
|
+
function lighten (color, amount) {
|
1602
1735
|
amount = (amount === 0) ? 0 : (amount || 10);
|
1603
1736
|
var hsl = tinycolor(color).toHsl();
|
1604
1737
|
hsl.l += amount / 100;
|
1605
1738
|
hsl.l = clamp01(hsl.l);
|
1606
1739
|
return tinycolor(hsl);
|
1607
|
-
}
|
1608
|
-
|
1740
|
+
}
|
1741
|
+
|
1742
|
+
function brighten(color, amount) {
|
1609
1743
|
amount = (amount === 0) ? 0 : (amount || 10);
|
1610
1744
|
var rgb = tinycolor(color).toRgb();
|
1611
1745
|
rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100))));
|
1612
1746
|
rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100))));
|
1613
1747
|
rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100))));
|
1614
1748
|
return tinycolor(rgb);
|
1615
|
-
}
|
1616
|
-
|
1749
|
+
}
|
1750
|
+
|
1751
|
+
function darken (color, amount) {
|
1617
1752
|
amount = (amount === 0) ? 0 : (amount || 10);
|
1618
1753
|
var hsl = tinycolor(color).toHsl();
|
1619
1754
|
hsl.l -= amount / 100;
|
1620
1755
|
hsl.l = clamp01(hsl.l);
|
1621
1756
|
return tinycolor(hsl);
|
1622
|
-
}
|
1623
|
-
|
1757
|
+
}
|
1758
|
+
|
1759
|
+
// Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
|
1760
|
+
// Values outside of this range will be wrapped into this range.
|
1761
|
+
function spin(color, amount) {
|
1624
1762
|
var hsl = tinycolor(color).toHsl();
|
1625
|
-
|
1763
|
+
var hue = (mathRound(hsl.h) + amount) % 360;
|
1764
|
+
hsl.h = hue < 0 ? 360 + hue : hue;
|
1626
1765
|
return tinycolor(hsl);
|
1627
|
-
}
|
1628
|
-
|
1766
|
+
}
|
1629
1767
|
|
1630
1768
|
// Combination Functions
|
1631
1769
|
// ---------------------
|
1632
1770
|
// Thanks to jQuery xColor for some of the ideas behind these
|
1633
1771
|
// <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
|
1634
1772
|
|
1635
|
-
|
1773
|
+
function complement(color) {
|
1774
|
+
var hsl = tinycolor(color).toHsl();
|
1775
|
+
hsl.h = (hsl.h + 180) % 360;
|
1776
|
+
return tinycolor(hsl);
|
1777
|
+
}
|
1778
|
+
|
1779
|
+
function triad(color) {
|
1636
1780
|
var hsl = tinycolor(color).toHsl();
|
1637
1781
|
var h = hsl.h;
|
1638
1782
|
return [
|
@@ -1640,8 +1784,9 @@
|
|
1640
1784
|
tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),
|
1641
1785
|
tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })
|
1642
1786
|
];
|
1643
|
-
}
|
1644
|
-
|
1787
|
+
}
|
1788
|
+
|
1789
|
+
function tetrad(color) {
|
1645
1790
|
var hsl = tinycolor(color).toHsl();
|
1646
1791
|
var h = hsl.h;
|
1647
1792
|
return [
|
@@ -1650,8 +1795,9 @@
|
|
1650
1795
|
tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),
|
1651
1796
|
tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })
|
1652
1797
|
];
|
1653
|
-
}
|
1654
|
-
|
1798
|
+
}
|
1799
|
+
|
1800
|
+
function splitcomplement(color) {
|
1655
1801
|
var hsl = tinycolor(color).toHsl();
|
1656
1802
|
var h = hsl.h;
|
1657
1803
|
return [
|
@@ -1659,8 +1805,9 @@
|
|
1659
1805
|
tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}),
|
1660
1806
|
tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l})
|
1661
1807
|
];
|
1662
|
-
}
|
1663
|
-
|
1808
|
+
}
|
1809
|
+
|
1810
|
+
function analogous(color, results, slices) {
|
1664
1811
|
results = results || 6;
|
1665
1812
|
slices = slices || 30;
|
1666
1813
|
|
@@ -1673,8 +1820,9 @@
|
|
1673
1820
|
ret.push(tinycolor(hsl));
|
1674
1821
|
}
|
1675
1822
|
return ret;
|
1676
|
-
}
|
1677
|
-
|
1823
|
+
}
|
1824
|
+
|
1825
|
+
function monochromatic(color, results) {
|
1678
1826
|
results = results || 6;
|
1679
1827
|
var hsv = tinycolor(color).toHsv();
|
1680
1828
|
var h = hsv.h, s = hsv.s, v = hsv.v;
|
@@ -1687,6 +1835,41 @@
|
|
1687
1835
|
}
|
1688
1836
|
|
1689
1837
|
return ret;
|
1838
|
+
}
|
1839
|
+
|
1840
|
+
// Utility Functions
|
1841
|
+
// ---------------------
|
1842
|
+
|
1843
|
+
tinycolor.mix = function(color1, color2, amount) {
|
1844
|
+
amount = (amount === 0) ? 0 : (amount || 50);
|
1845
|
+
|
1846
|
+
var rgb1 = tinycolor(color1).toRgb();
|
1847
|
+
var rgb2 = tinycolor(color2).toRgb();
|
1848
|
+
|
1849
|
+
var p = amount / 100;
|
1850
|
+
var w = p * 2 - 1;
|
1851
|
+
var a = rgb2.a - rgb1.a;
|
1852
|
+
|
1853
|
+
var w1;
|
1854
|
+
|
1855
|
+
if (w * a == -1) {
|
1856
|
+
w1 = w;
|
1857
|
+
} else {
|
1858
|
+
w1 = (w + a) / (1 + w * a);
|
1859
|
+
}
|
1860
|
+
|
1861
|
+
w1 = (w1 + 1) / 2;
|
1862
|
+
|
1863
|
+
var w2 = 1 - w1;
|
1864
|
+
|
1865
|
+
var rgba = {
|
1866
|
+
r: rgb2.r * w1 + rgb1.r * w2,
|
1867
|
+
g: rgb2.g * w1 + rgb1.g * w2,
|
1868
|
+
b: rgb2.b * w1 + rgb1.b * w2,
|
1869
|
+
a: rgb2.a * p + rgb1.a * (1 - p)
|
1870
|
+
};
|
1871
|
+
|
1872
|
+
return tinycolor(rgba);
|
1690
1873
|
};
|
1691
1874
|
|
1692
1875
|
|
@@ -1699,14 +1882,16 @@
|
|
1699
1882
|
// `brightness`: difference in brightness between the two colors
|
1700
1883
|
// `color`: difference in color/hue between the two colors
|
1701
1884
|
tinycolor.readability = function(color1, color2) {
|
1702
|
-
var
|
1703
|
-
var
|
1704
|
-
var
|
1705
|
-
var
|
1885
|
+
var c1 = tinycolor(color1);
|
1886
|
+
var c2 = tinycolor(color2);
|
1887
|
+
var rgb1 = c1.toRgb();
|
1888
|
+
var rgb2 = c2.toRgb();
|
1889
|
+
var brightnessA = c1.getBrightness();
|
1890
|
+
var brightnessB = c2.getBrightness();
|
1706
1891
|
var colorDiff = (
|
1707
|
-
Math.max(
|
1708
|
-
Math.max(
|
1709
|
-
Math.max(
|
1892
|
+
Math.max(rgb1.r, rgb2.r) - Math.min(rgb1.r, rgb2.r) +
|
1893
|
+
Math.max(rgb1.g, rgb2.g) - Math.min(rgb1.g, rgb2.g) +
|
1894
|
+
Math.max(rgb1.b, rgb2.b) - Math.min(rgb1.b, rgb2.b)
|
1710
1895
|
);
|
1711
1896
|
|
1712
1897
|
return {
|
@@ -1719,8 +1904,8 @@
|
|
1719
1904
|
// http://www.w3.org/TR/AERT#color-contrast
|
1720
1905
|
// Ensure that foreground and background color combinations provide sufficient contrast.
|
1721
1906
|
// *Example*
|
1722
|
-
// tinycolor.
|
1723
|
-
tinycolor.
|
1907
|
+
// tinycolor.isReadable("#000", "#111") => false
|
1908
|
+
tinycolor.isReadable = function(color1, color2) {
|
1724
1909
|
var readability = tinycolor.readability(color1, color2);
|
1725
1910
|
return readability.brightness > 125 && readability.color > 500;
|
1726
1911
|
};
|
@@ -1879,6 +2064,7 @@
|
|
1879
2064
|
plum: "dda0dd",
|
1880
2065
|
powderblue: "b0e0e6",
|
1881
2066
|
purple: "800080",
|
2067
|
+
rebeccapurple: "663399",
|
1882
2068
|
red: "f00",
|
1883
2069
|
rosybrown: "bc8f8f",
|
1884
2070
|
royalblue: "4169e1",
|
@@ -2026,6 +2212,7 @@
|
|
2026
2212
|
hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
|
2027
2213
|
hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
|
2028
2214
|
hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
|
2215
|
+
hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
|
2029
2216
|
hex3: /^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
2030
2217
|
hex6: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
2031
2218
|
hex8: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
|
@@ -2067,6 +2254,9 @@
|
|
2067
2254
|
if ((match = matchers.hsv.exec(color))) {
|
2068
2255
|
return { h: match[1], s: match[2], v: match[3] };
|
2069
2256
|
}
|
2257
|
+
if ((match = matchers.hsva.exec(color))) {
|
2258
|
+
return { h: match[1], s: match[2], v: match[3], a: match[4] };
|
2259
|
+
}
|
2070
2260
|
if ((match = matchers.hex8.exec(color))) {
|
2071
2261
|
return {
|
2072
2262
|
a: convertHexToDecimal(match[1]),
|
@@ -2099,11 +2289,10 @@
|
|
2099
2289
|
window.tinycolor = tinycolor;
|
2100
2290
|
})();
|
2101
2291
|
|
2102
|
-
|
2103
2292
|
$(function () {
|
2104
2293
|
if ($.fn.spectrum.load) {
|
2105
2294
|
$.fn.spectrum.processNativeColorInputs();
|
2106
2295
|
}
|
2107
2296
|
});
|
2108
2297
|
|
2109
|
-
})
|
2298
|
+
});
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/***
|
2
|
-
Spectrum Colorpicker v1.
|
2
|
+
Spectrum Colorpicker v1.6.2
|
3
3
|
https://github.com/bgrins/spectrum
|
4
4
|
Author: Brian Grinstead
|
5
5
|
License: MIT
|
@@ -134,6 +134,9 @@ License: MIT
|
|
134
134
|
.sp-container.sp-buttons-disabled .sp-button-container {
|
135
135
|
display: none;
|
136
136
|
}
|
137
|
+
.sp-container.sp-palette-buttons-disabled .sp-palette-button-container {
|
138
|
+
display: none;
|
139
|
+
}
|
137
140
|
.sp-palette-only .sp-picker-container {
|
138
141
|
display: none;
|
139
142
|
}
|
@@ -174,6 +177,7 @@ License: MIT
|
|
174
177
|
background: -o-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
|
175
178
|
background: -webkit-gradient(linear, left top, left bottom, from(#ff0000), color-stop(0.17, #ffff00), color-stop(0.33, #00ff00), color-stop(0.5, #00ffff), color-stop(0.67, #0000ff), color-stop(0.83, #ff00ff), to(#ff0000));
|
176
179
|
background: -webkit-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
|
180
|
+
background: linear-gradient(to bottom, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
|
177
181
|
}
|
178
182
|
|
179
183
|
/* IE filters do not support multiple color stops.
|
@@ -255,20 +259,17 @@ See http://bgrins.github.io/spectrum/themes/ for instructions.
|
|
255
259
|
border: solid 1px #f0c49B;
|
256
260
|
padding: 0;
|
257
261
|
}
|
258
|
-
.sp-container, .sp-container button, .sp-container input, .sp-color, .sp-hue, .sp-clear
|
259
|
-
{
|
262
|
+
.sp-container, .sp-container button, .sp-container input, .sp-color, .sp-hue, .sp-clear {
|
260
263
|
font: normal 12px "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
|
261
264
|
-webkit-box-sizing: border-box;
|
262
265
|
-moz-box-sizing: border-box;
|
263
266
|
-ms-box-sizing: border-box;
|
264
267
|
box-sizing: border-box;
|
265
268
|
}
|
266
|
-
.sp-top
|
267
|
-
{
|
269
|
+
.sp-top {
|
268
270
|
margin-bottom: 3px;
|
269
271
|
}
|
270
|
-
.sp-color, .sp-hue, .sp-clear
|
271
|
-
{
|
272
|
+
.sp-color, .sp-hue, .sp-clear {
|
272
273
|
border: solid 1px #666;
|
273
274
|
}
|
274
275
|
|
@@ -294,31 +295,31 @@ See http://bgrins.github.io/spectrum/themes/ for instructions.
|
|
294
295
|
.sp-input:focus {
|
295
296
|
border: 1px solid orange;
|
296
297
|
}
|
297
|
-
.sp-input.sp-validation-error
|
298
|
-
{
|
298
|
+
.sp-input.sp-validation-error {
|
299
299
|
border: 1px solid red;
|
300
300
|
background: #fdd;
|
301
301
|
}
|
302
|
-
.sp-picker-container , .sp-palette-container
|
303
|
-
{
|
302
|
+
.sp-picker-container , .sp-palette-container {
|
304
303
|
float:left;
|
305
304
|
position: relative;
|
306
305
|
padding: 10px;
|
307
306
|
padding-bottom: 300px;
|
308
307
|
margin-bottom: -290px;
|
309
308
|
}
|
310
|
-
.sp-picker-container
|
311
|
-
{
|
309
|
+
.sp-picker-container {
|
312
310
|
width: 172px;
|
313
311
|
border-left: solid 1px #fff;
|
314
312
|
}
|
315
313
|
|
316
314
|
/* Palettes */
|
317
|
-
.sp-palette-container
|
318
|
-
{
|
315
|
+
.sp-palette-container {
|
319
316
|
border-right: solid 1px #ccc;
|
320
317
|
}
|
321
318
|
|
319
|
+
.sp-palette-only .sp-palette-container {
|
320
|
+
border: 0;
|
321
|
+
}
|
322
|
+
|
322
323
|
.sp-palette .sp-thumb-el {
|
323
324
|
display: block;
|
324
325
|
position:relative;
|
@@ -332,14 +333,12 @@ See http://bgrins.github.io/spectrum/themes/ for instructions.
|
|
332
333
|
.sp-palette .sp-thumb-el:hover, .sp-palette .sp-thumb-el.sp-thumb-active {
|
333
334
|
border-color: orange;
|
334
335
|
}
|
335
|
-
.sp-thumb-el
|
336
|
-
{
|
336
|
+
.sp-thumb-el {
|
337
337
|
position:relative;
|
338
338
|
}
|
339
339
|
|
340
340
|
/* Initial */
|
341
|
-
.sp-initial
|
342
|
-
{
|
341
|
+
.sp-initial {
|
343
342
|
float: left;
|
344
343
|
border: solid 1px #333;
|
345
344
|
}
|
@@ -357,6 +356,7 @@ See http://bgrins.github.io/spectrum/themes/ for instructions.
|
|
357
356
|
}
|
358
357
|
|
359
358
|
/* Buttons */
|
359
|
+
.sp-palette-button-container,
|
360
360
|
.sp-button-container {
|
361
361
|
float: right;
|
362
362
|
}
|
@@ -391,8 +391,7 @@ See http://bgrins.github.io/spectrum/themes/ for instructions.
|
|
391
391
|
float:left;
|
392
392
|
font-size:10px;
|
393
393
|
}
|
394
|
-
.sp-preview
|
395
|
-
{
|
394
|
+
.sp-preview {
|
396
395
|
position:relative;
|
397
396
|
width:25px;
|
398
397
|
height: 20px;
|
@@ -402,21 +401,18 @@ See http://bgrins.github.io/spectrum/themes/ for instructions.
|
|
402
401
|
z-index: 0;
|
403
402
|
}
|
404
403
|
|
405
|
-
.sp-palette
|
406
|
-
{
|
404
|
+
.sp-palette {
|
407
405
|
*width: 220px;
|
408
406
|
max-width: 220px;
|
409
407
|
}
|
410
|
-
.sp-palette .sp-thumb-el
|
411
|
-
{
|
408
|
+
.sp-palette .sp-thumb-el {
|
412
409
|
width:16px;
|
413
410
|
height: 16px;
|
414
411
|
margin:2px 1px;
|
415
412
|
border: solid 1px #d0d0d0;
|
416
413
|
}
|
417
414
|
|
418
|
-
.sp-container
|
419
|
-
{
|
415
|
+
.sp-container {
|
420
416
|
padding-bottom:0;
|
421
417
|
}
|
422
418
|
|
@@ -461,8 +457,7 @@ See http://bgrins.github.io/spectrum/themes/ for instructions.
|
|
461
457
|
-o-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
|
462
458
|
box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
|
463
459
|
}
|
464
|
-
.sp-cancel
|
465
|
-
{
|
460
|
+
.sp-cancel {
|
466
461
|
font-size: 11px;
|
467
462
|
color: #d93f3f !important;
|
468
463
|
margin:0;
|
@@ -472,43 +467,36 @@ See http://bgrins.github.io/spectrum/themes/ for instructions.
|
|
472
467
|
text-decoration:none;
|
473
468
|
|
474
469
|
}
|
475
|
-
.sp-cancel:hover
|
476
|
-
{
|
470
|
+
.sp-cancel:hover {
|
477
471
|
color: #d93f3f !important;
|
478
472
|
text-decoration: underline;
|
479
473
|
}
|
480
474
|
|
481
475
|
|
482
|
-
.sp-palette span:hover, .sp-palette span.sp-thumb-active
|
483
|
-
{
|
476
|
+
.sp-palette span:hover, .sp-palette span.sp-thumb-active {
|
484
477
|
border-color: #000;
|
485
478
|
}
|
486
479
|
|
487
|
-
.sp-preview, .sp-alpha, .sp-thumb-el
|
488
|
-
{
|
480
|
+
.sp-preview, .sp-alpha, .sp-thumb-el {
|
489
481
|
position:relative;
|
490
482
|
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg==);
|
491
483
|
}
|
492
|
-
.sp-preview-inner, .sp-alpha-inner, .sp-thumb-inner
|
493
|
-
{
|
484
|
+
.sp-preview-inner, .sp-alpha-inner, .sp-thumb-inner {
|
494
485
|
display:block;
|
495
486
|
position:absolute;
|
496
487
|
top:0;left:0;bottom:0;right:0;
|
497
488
|
}
|
498
489
|
|
499
|
-
.sp-palette .sp-thumb-inner
|
500
|
-
{
|
490
|
+
.sp-palette .sp-thumb-inner {
|
501
491
|
background-position: 50% 50%;
|
502
492
|
background-repeat: no-repeat;
|
503
493
|
}
|
504
494
|
|
505
|
-
.sp-palette .sp-thumb-light.sp-thumb-active .sp-thumb-inner
|
506
|
-
{
|
495
|
+
.sp-palette .sp-thumb-light.sp-thumb-active .sp-thumb-inner {
|
507
496
|
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAIVJREFUeNpiYBhsgJFMffxAXABlN5JruT4Q3wfi/0DsT64h8UD8HmpIPCWG/KemIfOJCUB+Aoacx6EGBZyHBqI+WsDCwuQ9mhxeg2A210Ntfo8klk9sOMijaURm7yc1UP2RNCMbKE9ODK1HM6iegYLkfx8pligC9lCD7KmRof0ZhjQACDAAceovrtpVBRkAAAAASUVORK5CYII=);
|
508
497
|
}
|
509
498
|
|
510
|
-
.sp-palette .sp-thumb-dark.sp-thumb-active .sp-thumb-inner
|
511
|
-
{
|
499
|
+
.sp-palette .sp-thumb-dark.sp-thumb-active .sp-thumb-inner {
|
512
500
|
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjEwMPRyoQAAAMdJREFUOE+tkgsNwzAMRMugEAahEAahEAZhEAqlEAZhEAohEAYh81X2dIm8fKpEspLGvudPOsUYpxE2BIJCroJmEW9qJ+MKaBFhEMNabSy9oIcIPwrB+afvAUFoK4H0tMaQ3XtlrggDhOVVMuT4E5MMG0FBbCEYzjYT7OxLEvIHQLY2zWwQ3D+9luyOQTfKDiFD3iUIfPk8VqrKjgAiSfGFPecrg6HN6m/iBcwiDAo7WiBeawa+Kwh7tZoSCGLMqwlSAzVDhoK+6vH4G0P5wdkAAAAASUVORK5CYII=);
|
513
501
|
}
|
514
502
|
|
@@ -516,4 +504,4 @@ See http://bgrins.github.io/spectrum/themes/ for instructions.
|
|
516
504
|
background-repeat:no-repeat;
|
517
505
|
background-position: center;
|
518
506
|
background-image: url(data:image/gif;base64,R0lGODlhFAAUAPcAAAAAAJmZmZ2dnZ6enqKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq/Hx8fLy8vT09PX19ff39/j4+Pn5+fr6+vv7+wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAP8ALAAAAAAUABQAAAihAP9FoPCvoMGDBy08+EdhQAIJCCMybCDAAYUEARBAlFiQQoMABQhKUJBxY0SPICEYHBnggEmDKAuoPMjS5cGYMxHW3IiT478JJA8M/CjTZ0GgLRekNGpwAsYABHIypcAgQMsITDtWJYBR6NSqMico9cqR6tKfY7GeBCuVwlipDNmefAtTrkSzB1RaIAoXodsABiZAEFB06gIBWC1mLVgBa0AAOw==);
|
519
|
-
}
|
507
|
+
}
|
metadata
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spectrum-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.6.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Kevin Trotter
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-04-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: railties
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '3.1'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '3.1'
|
30
27
|
description: A ruby gem that uses the Rails asset pipeline to include the Spectrum
|
@@ -35,35 +32,35 @@ executables: []
|
|
35
32
|
extensions: []
|
36
33
|
extra_rdoc_files: []
|
37
34
|
files:
|
38
|
-
-
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
39
37
|
- lib/spectrum-rails.rb
|
38
|
+
- lib/spectrum-rails/version.rb
|
39
|
+
- vendor/assets/javascripts/spectrum-min.js
|
40
40
|
- vendor/assets/javascripts/spectrum.js
|
41
41
|
- vendor/assets/stylesheets/spectrum.css
|
42
|
-
- LICENSE
|
43
|
-
- README.md
|
44
42
|
homepage: https://github.com/cskevint/spectrum-rails
|
45
43
|
licenses:
|
46
44
|
- MIT
|
45
|
+
metadata: {}
|
47
46
|
post_install_message:
|
48
47
|
rdoc_options: []
|
49
48
|
require_paths:
|
50
49
|
- lib
|
51
50
|
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
-
none: false
|
53
51
|
requirements:
|
54
|
-
- -
|
52
|
+
- - ">="
|
55
53
|
- !ruby/object:Gem::Version
|
56
54
|
version: '0'
|
57
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
56
|
requirements:
|
60
|
-
- -
|
57
|
+
- - ">="
|
61
58
|
- !ruby/object:Gem::Version
|
62
59
|
version: '0'
|
63
60
|
requirements: []
|
64
61
|
rubyforge_project:
|
65
|
-
rubygems_version:
|
62
|
+
rubygems_version: 2.2.2
|
66
63
|
signing_key:
|
67
|
-
specification_version:
|
64
|
+
specification_version: 4
|
68
65
|
summary: Includes javascript and css files for the Spectrum jQuery plugin.
|
69
66
|
test_files: []
|