aboutsummaryrefslogtreecommitdiffstats
path: root/js/yui/colorpicker
diff options
context:
space:
mode:
authorDavid Lawrence <dlawrence@mozilla.com>2011-04-23 08:03:15 -0400
committerDavid Lawrence <dlawrence@mozilla.com>2011-04-23 08:03:15 -0400
commit4c08043332e39576eed0868c22e6089eafa6aabf (patch)
tree5a8ad25f26a345feadedfe82782a763da051564e /js/yui/colorpicker
parent8bb0ca1f5c922f8ea2fe64a59b1e1811dfaca65a (diff)
downloadbugs-4c08043332e39576eed0868c22e6089eafa6aabf.tar
bugs-4c08043332e39576eed0868c22e6089eafa6aabf.tar.gz
bugs-4c08043332e39576eed0868c22e6089eafa6aabf.tar.bz2
bugs-4c08043332e39576eed0868c22e6089eafa6aabf.tar.xz
bugs-4c08043332e39576eed0868c22e6089eafa6aabf.zip
Bug 649879 - Update to YUI 2.9.0
r/a=mkanat
Diffstat (limited to 'js/yui/colorpicker')
-rw-r--r--js/yui/colorpicker/colorpicker-min.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/js/yui/colorpicker/colorpicker-min.js b/js/yui/colorpicker/colorpicker-min.js
index 461e422bf..dadac2a5c 100644
--- a/js/yui/colorpicker/colorpicker-min.js
+++ b/js/yui/colorpicker/colorpicker-min.js
@@ -1,9 +1,9 @@
/*
-Copyright (c) 2010, Yahoo! Inc. All rights reserved.
+Copyright (c) 2011, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
-version: 2.8.2r1
+version: 2.9.0
*/
-YAHOO.util.Color=function(){var A="0",B=YAHOO.lang.isArray,C=YAHOO.lang.isNumber;return{real2dec:function(D){return Math.min(255,Math.round(D*256));},hsv2rgb:function(H,O,M){if(B(H)){return this.hsv2rgb.call(this,H[0],H[1],H[2]);}var D,I,L,G=Math.floor((H/60)%6),J=(H/60)-G,F=M*(1-O),E=M*(1-J*O),N=M*(1-(1-J)*O),K;switch(G){case 0:D=M;I=N;L=F;break;case 1:D=E;I=M;L=F;break;case 2:D=F;I=M;L=N;break;case 3:D=F;I=E;L=M;break;case 4:D=N;I=F;L=M;break;case 5:D=M;I=F;L=E;break;}K=this.real2dec;return[K(D),K(I),K(L)];},rgb2hsv:function(D,H,I){if(B(D)){return this.rgb2hsv.apply(this,D);}D/=255;H/=255;I/=255;var G,L,E=Math.min(Math.min(D,H),I),J=Math.max(Math.max(D,H),I),K=J-E,F;switch(J){case E:G=0;break;case D:G=60*(H-I)/K;if(H<I){G+=360;}break;case H:G=(60*(I-D)/K)+120;break;case I:G=(60*(D-H)/K)+240;break;}L=(J===0)?0:1-(E/J);F=[Math.round(G),L,J];return F;},rgb2hex:function(F,E,D){if(B(F)){return this.rgb2hex.apply(this,F);}var G=this.dec2hex;return G(F)+G(E)+G(D);},dec2hex:function(D){D=parseInt(D,10)|0;D=(D>255||D<0)?0:D;return(A+D.toString(16)).slice(-2).toUpperCase();},hex2dec:function(D){return parseInt(D,16);},hex2rgb:function(D){var E=this.hex2dec;return[E(D.slice(0,2)),E(D.slice(2,4)),E(D.slice(4,6))];},websafe:function(F,E,D){if(B(F)){return this.websafe.apply(this,F);}var G=function(H){if(C(H)){H=Math.min(Math.max(0,H),255);var I,J;for(I=0;I<256;I=I+51){J=I+51;if(H>=I&&H<=J){return(H-I>25)?J:I;}}}return H;};return[G(F),G(E),G(D)];}};}();(function(){var J=0,F=YAHOO.util,C=YAHOO.lang,D=YAHOO.widget.Slider,B=F.Color,E=F.Dom,I=F.Event,A=C.substitute,H="yui-picker";function G(L,K){J=J+1;K=K||{};if(arguments.length===1&&!YAHOO.lang.isString(L)&&!L.nodeName){K=L;L=K.element||null;}if(!L&&!K.element){L=this._createHostElement(K);}G.superclass.constructor.call(this,L,K);this.initPicker();}YAHOO.extend(G,YAHOO.util.Element,{ID:{R:H+"-r",R_HEX:H+"-rhex",G:H+"-g",G_HEX:H+"-ghex",B:H+"-b",B_HEX:H+"-bhex",H:H+"-h",S:H+"-s",V:H+"-v",PICKER_BG:H+"-bg",PICKER_THUMB:H+"-thumb",HUE_BG:H+"-hue-bg",HUE_THUMB:H+"-hue-thumb",HEX:H+"-hex",SWATCH:H+"-swatch",WEBSAFE_SWATCH:H+"-websafe-swatch",CONTROLS:H+"-controls",RGB_CONTROLS:H+"-rgb-controls",HSV_CONTROLS:H+"-hsv-controls",HEX_CONTROLS:H+"-hex-controls",HEX_SUMMARY:H+"-hex-summary",CONTROLS_LABEL:H+"-controls-label"},TXT:{ILLEGAL_HEX:"Illegal hex value entered",SHOW_CONTROLS:"Show color details",HIDE_CONTROLS:"Hide color details",CURRENT_COLOR:"Currently selected color: {rgb}",CLOSEST_WEBSAFE:"Closest websafe color: {rgb}. Click to select.",R:"R",G:"G",B:"B",H:"H",S:"S",V:"V",HEX:"#",DEG:"\u00B0",PERCENT:"%"},IMAGE:{PICKER_THUMB:"../../build/colorpicker/assets/picker_thumb.png",HUE_THUMB:"../../build/colorpicker/assets/hue_thumb.png"},DEFAULT:{PICKER_SIZE:180},OPT:{HUE:"hue",SATURATION:"saturation",VALUE:"value",RED:"red",GREEN:"green",BLUE:"blue",HSV:"hsv",RGB:"rgb",WEBSAFE:"websafe",HEX:"hex",PICKER_SIZE:"pickersize",SHOW_CONTROLS:"showcontrols",SHOW_RGB_CONTROLS:"showrgbcontrols",SHOW_HSV_CONTROLS:"showhsvcontrols",SHOW_HEX_CONTROLS:"showhexcontrols",SHOW_HEX_SUMMARY:"showhexsummary",SHOW_WEBSAFE:"showwebsafe",CONTAINER:"container",IDS:"ids",ELEMENTS:"elements",TXT:"txt",IMAGES:"images",ANIMATE:"animate"},skipAnim:true,_createHostElement:function(){var K=document.createElement("div");if(this.CSS.BASE){K.className=this.CSS.BASE;}return K;},_updateHueSlider:function(){var K=this.get(this.OPT.PICKER_SIZE),L=this.get(this.OPT.HUE);L=K-Math.round(L/360*K);if(L===K){L=0;}this.hueSlider.setValue(L,this.skipAnim);},_updatePickerSlider:function(){var L=this.get(this.OPT.PICKER_SIZE),M=this.get(this.OPT.SATURATION),K=this.get(this.OPT.VALUE);M=Math.round(M*L/100);K=Math.round(L-(K*L/100));this.pickerSlider.setRegionValue(M,K,this.skipAnim);},_updateSliders:function(){this._updateHueSlider();this._updatePickerSlider();},setValue:function(L,K){K=(K)||false;this.set(this.OPT.RGB,L,K);this._updateSliders();},hueSlider:null,pickerSlider:null,_getH:function(){var K=this.get(this.OPT.PICKER_SIZE),L=(K-this.hueSlider.getValue())/K;L=Math.round(L*360);return(L===360)?0:L;},_getS:function(){return this.pickerSlider.getXValue()/this.get(this.OPT.PICKER_SIZE);},_getV:function(){var K=this.get(this.OPT.PICKER_SIZE);return(K-this.pickerSlider.getYValue())/K;},_updateSwatch:function(){var M=this.get(this.OPT.RGB),O=this.get(this.OPT.WEBSAFE),N=this.getElement(this.ID.SWATCH),L=M.join(","),K=this.get(this.OPT.TXT);E.setStyle(N,"background-color","rgb("+L+")");N.title=A(K.CURRENT_COLOR,{"rgb":"#"+this.get(this.OPT.HEX)});N=this.getElement(this.ID.WEBSAFE_SWATCH);L=O.join(",");E.setStyle(N,"background-color","rgb("+L+")");N.title=A(K.CLOSEST_WEBSAFE,{"rgb":"#"+B.rgb2hex(O)});},_getValuesFromSliders:function(){this.set(this.OPT.RGB,B.hsv2rgb(this._getH(),this._getS(),this._getV()));},_updateFormFields:function(){this.getElement(this.ID.H).value=this.get(this.OPT.HUE);this.getElement(this.ID.S).value=this.get(this.OPT.SATURATION);this.getElement(this.ID.V).value=this.get(this.OPT.VALUE);this.getElement(this.ID.R).value=this.get(this.OPT.RED);this.getElement(this.ID.R_HEX).innerHTML=B.dec2hex(this.get(this.OPT.RED));this.getElement(this.ID.G).value=this.get(this.OPT.GREEN);this.getElement(this.ID.G_HEX).innerHTML=B.dec2hex(this.get(this.OPT.GREEN));this.getElement(this.ID.B).value=this.get(this.OPT.BLUE);this.getElement(this.ID.B_HEX).innerHTML=B.dec2hex(this.get(this.OPT.BLUE));this.getElement(this.ID.HEX).value=this.get(this.OPT.HEX);},_onHueSliderChange:function(N){var L=this._getH(),K=B.hsv2rgb(L,1,1),M="rgb("+K.join(",")+")";this.set(this.OPT.HUE,L,true);E.setStyle(this.getElement(this.ID.PICKER_BG),"background-color",M);if(this.hueSlider.valueChangeSource!==D.SOURCE_SET_VALUE){this._getValuesFromSliders();}this._updateFormFields();this._updateSwatch();},_onPickerSliderChange:function(M){var L=this._getS(),K=this._getV();this.set(this.OPT.SATURATION,Math.round(L*100),true);this.set(this.OPT.VALUE,Math.round(K*100),true);if(this.pickerSlider.valueChangeSource!==D.SOURCE_SET_VALUE){this._getValuesFromSliders();
-}this._updateFormFields();this._updateSwatch();},_getCommand:function(K){var L=I.getCharCode(K);if(L===38){return 3;}else{if(L===13){return 6;}else{if(L===40){return 4;}else{if(L>=48&&L<=57){return 1;}else{if(L>=97&&L<=102){return 2;}else{if(L>=65&&L<=70){return 2;}else{if("8, 9, 13, 27, 37, 39".indexOf(L)>-1||K.ctrlKey||K.metaKey){return 5;}else{return 0;}}}}}}}},_useFieldValue:function(L,K,N){var M=K.value;if(N!==this.OPT.HEX){M=parseInt(M,10);}if(M!==this.get(N)){this.set(N,M);}},_rgbFieldKeypress:function(M,K,O){var N=this._getCommand(M),L=(M.shiftKey)?10:1;switch(N){case 6:this._useFieldValue.apply(this,arguments);break;case 3:this.set(O,Math.min(this.get(O)+L,255));this._updateFormFields();break;case 4:this.set(O,Math.max(this.get(O)-L,0));this._updateFormFields();break;default:}},_hexFieldKeypress:function(L,K,N){var M=this._getCommand(L);if(M===6){this._useFieldValue.apply(this,arguments);}},_hexOnly:function(L,K){var M=this._getCommand(L);switch(M){case 6:case 5:case 1:break;case 2:if(K!==true){break;}default:I.stopEvent(L);return false;}},_numbersOnly:function(K){return this._hexOnly(K,true);},getElement:function(K){return this.get(this.OPT.ELEMENTS)[this.get(this.OPT.IDS)[K]];},_createElements:function(){var N,M,P,O,L,K=this.get(this.OPT.IDS),Q=this.get(this.OPT.TXT),S=this.get(this.OPT.IMAGES),R=function(U,V){var W=document.createElement(U);if(V){C.augmentObject(W,V,true);}return W;},T=function(U,V){var W=C.merge({autocomplete:"off",value:"0",size:3,maxlength:3},V);W.name=W.id;return new R(U,W);};L=this.get("element");N=new R("div",{id:K[this.ID.PICKER_BG],className:"yui-picker-bg",tabIndex:-1,hideFocus:true});M=new R("div",{id:K[this.ID.PICKER_THUMB],className:"yui-picker-thumb"});P=new R("img",{src:S.PICKER_THUMB});M.appendChild(P);N.appendChild(M);L.appendChild(N);N=new R("div",{id:K[this.ID.HUE_BG],className:"yui-picker-hue-bg",tabIndex:-1,hideFocus:true});M=new R("div",{id:K[this.ID.HUE_THUMB],className:"yui-picker-hue-thumb"});P=new R("img",{src:S.HUE_THUMB});M.appendChild(P);N.appendChild(M);L.appendChild(N);N=new R("div",{id:K[this.ID.CONTROLS],className:"yui-picker-controls"});L.appendChild(N);L=N;N=new R("div",{className:"hd"});M=new R("a",{id:K[this.ID.CONTROLS_LABEL],href:"#"});N.appendChild(M);L.appendChild(N);N=new R("div",{className:"bd"});L.appendChild(N);L=N;N=new R("ul",{id:K[this.ID.RGB_CONTROLS],className:"yui-picker-rgb-controls"});M=new R("li");M.appendChild(document.createTextNode(Q.R+" "));O=new T("input",{id:K[this.ID.R],className:"yui-picker-r"});M.appendChild(O);N.appendChild(M);M=new R("li");M.appendChild(document.createTextNode(Q.G+" "));O=new T("input",{id:K[this.ID.G],className:"yui-picker-g"});M.appendChild(O);N.appendChild(M);M=new R("li");M.appendChild(document.createTextNode(Q.B+" "));O=new T("input",{id:K[this.ID.B],className:"yui-picker-b"});M.appendChild(O);N.appendChild(M);L.appendChild(N);N=new R("ul",{id:K[this.ID.HSV_CONTROLS],className:"yui-picker-hsv-controls"});M=new R("li");M.appendChild(document.createTextNode(Q.H+" "));O=new T("input",{id:K[this.ID.H],className:"yui-picker-h"});M.appendChild(O);M.appendChild(document.createTextNode(" "+Q.DEG));N.appendChild(M);M=new R("li");M.appendChild(document.createTextNode(Q.S+" "));O=new T("input",{id:K[this.ID.S],className:"yui-picker-s"});M.appendChild(O);M.appendChild(document.createTextNode(" "+Q.PERCENT));N.appendChild(M);M=new R("li");M.appendChild(document.createTextNode(Q.V+" "));O=new T("input",{id:K[this.ID.V],className:"yui-picker-v"});M.appendChild(O);M.appendChild(document.createTextNode(" "+Q.PERCENT));N.appendChild(M);L.appendChild(N);N=new R("ul",{id:K[this.ID.HEX_SUMMARY],className:"yui-picker-hex_summary"});M=new R("li",{id:K[this.ID.R_HEX]});N.appendChild(M);M=new R("li",{id:K[this.ID.G_HEX]});N.appendChild(M);M=new R("li",{id:K[this.ID.B_HEX]});N.appendChild(M);L.appendChild(N);N=new R("div",{id:K[this.ID.HEX_CONTROLS],className:"yui-picker-hex-controls"});N.appendChild(document.createTextNode(Q.HEX+" "));M=new T("input",{id:K[this.ID.HEX],className:"yui-picker-hex",size:6,maxlength:6});N.appendChild(M);L.appendChild(N);L=this.get("element");N=new R("div",{id:K[this.ID.SWATCH],className:"yui-picker-swatch"});L.appendChild(N);N=new R("div",{id:K[this.ID.WEBSAFE_SWATCH],className:"yui-picker-websafe-swatch"});L.appendChild(N);},_attachRGBHSV:function(L,K){I.on(this.getElement(L),"keydown",function(N,M){M._rgbFieldKeypress(N,this,K);},this);I.on(this.getElement(L),"keypress",this._numbersOnly,this,true);I.on(this.getElement(L),"blur",function(N,M){M._useFieldValue(N,this,K);},this);},_updateRGB:function(){var K=[this.get(this.OPT.RED),this.get(this.OPT.GREEN),this.get(this.OPT.BLUE)];this.set(this.OPT.RGB,K);this._updateSliders();},_initElements:function(){var O=this.OPT,N=this.get(O.IDS),L=this.get(O.ELEMENTS),K,M,P;for(K in this.ID){if(C.hasOwnProperty(this.ID,K)){N[this.ID[K]]=N[K];}}M=E.get(N[this.ID.PICKER_BG]);if(!M){this._createElements();}else{}for(K in N){if(C.hasOwnProperty(N,K)){M=E.get(N[K]);P=E.generateId(M);N[K]=P;N[N[K]]=P;L[P]=M;}}},initPicker:function(){this._initSliders();this._bindUI();this.syncUI(true);},_initSliders:function(){var K=this.ID,L=this.get(this.OPT.PICKER_SIZE);this.hueSlider=D.getVertSlider(this.getElement(K.HUE_BG),this.getElement(K.HUE_THUMB),0,L);this.pickerSlider=D.getSliderRegion(this.getElement(K.PICKER_BG),this.getElement(K.PICKER_THUMB),0,L,0,L);this.set(this.OPT.ANIMATE,this.get(this.OPT.ANIMATE));},_bindUI:function(){var K=this.ID,L=this.OPT;this.hueSlider.subscribe("change",this._onHueSliderChange,this,true);this.pickerSlider.subscribe("change",this._onPickerSliderChange,this,true);I.on(this.getElement(K.WEBSAFE_SWATCH),"click",function(M){this.setValue(this.get(L.WEBSAFE));},this,true);I.on(this.getElement(K.CONTROLS_LABEL),"click",function(M){this.set(L.SHOW_CONTROLS,!this.get(L.SHOW_CONTROLS));I.preventDefault(M);},this,true);this._attachRGBHSV(K.R,L.RED);this._attachRGBHSV(K.G,L.GREEN);this._attachRGBHSV(K.B,L.BLUE);this._attachRGBHSV(K.H,L.HUE);
-this._attachRGBHSV(K.S,L.SATURATION);this._attachRGBHSV(K.V,L.VALUE);I.on(this.getElement(K.HEX),"keydown",function(N,M){M._hexFieldKeypress(N,this,L.HEX);},this);I.on(this.getElement(this.ID.HEX),"keypress",this._hexOnly,this,true);I.on(this.getElement(this.ID.HEX),"blur",function(N,M){M._useFieldValue(N,this,L.HEX);},this);},syncUI:function(K){this.skipAnim=K;this._updateRGB();this.skipAnim=false;},_updateRGBFromHSV:function(){var L=[this.get(this.OPT.HUE),this.get(this.OPT.SATURATION)/100,this.get(this.OPT.VALUE)/100],K=B.hsv2rgb(L);this.set(this.OPT.RGB,K);this._updateSliders();},_updateHex:function(){var N=this.get(this.OPT.HEX),K=N.length,O,M,L;if(K===3){O=N.split("");for(M=0;M<K;M=M+1){O[M]=O[M]+O[M];}N=O.join("");}if(N.length!==6){return false;}L=B.hex2rgb(N);this.setValue(L);},_hideShowEl:function(M,K){var L=(C.isString(M)?this.getElement(M):M);E.setStyle(L,"display",(K)?"":"none");},initAttributes:function(K){K=K||{};G.superclass.initAttributes.call(this,K);this.setAttributeConfig(this.OPT.PICKER_SIZE,{value:K.size||this.DEFAULT.PICKER_SIZE});this.setAttributeConfig(this.OPT.HUE,{value:K.hue||0,validator:C.isNumber});this.setAttributeConfig(this.OPT.SATURATION,{value:K.saturation||0,validator:C.isNumber});this.setAttributeConfig(this.OPT.VALUE,{value:C.isNumber(K.value)?K.value:100,validator:C.isNumber});this.setAttributeConfig(this.OPT.RED,{value:C.isNumber(K.red)?K.red:255,validator:C.isNumber});this.setAttributeConfig(this.OPT.GREEN,{value:C.isNumber(K.green)?K.green:255,validator:C.isNumber});this.setAttributeConfig(this.OPT.BLUE,{value:C.isNumber(K.blue)?K.blue:255,validator:C.isNumber});this.setAttributeConfig(this.OPT.HEX,{value:K.hex||"FFFFFF",validator:C.isString});this.setAttributeConfig(this.OPT.RGB,{value:K.rgb||[255,255,255],method:function(O){this.set(this.OPT.RED,O[0],true);this.set(this.OPT.GREEN,O[1],true);this.set(this.OPT.BLUE,O[2],true);var Q=B.websafe(O),P=B.rgb2hex(O),N=B.rgb2hsv(O);this.set(this.OPT.WEBSAFE,Q,true);this.set(this.OPT.HEX,P,true);if(N[1]){this.set(this.OPT.HUE,N[0],true);}this.set(this.OPT.SATURATION,Math.round(N[1]*100),true);this.set(this.OPT.VALUE,Math.round(N[2]*100),true);},readonly:true});this.setAttributeConfig(this.OPT.CONTAINER,{value:null,method:function(N){if(N){N.showEvent.subscribe(function(){this.pickerSlider.focus();},this,true);}}});this.setAttributeConfig(this.OPT.WEBSAFE,{value:K.websafe||[255,255,255]});var M=K.ids||C.merge({},this.ID),L;if(!K.ids&&J>1){for(L in M){if(C.hasOwnProperty(M,L)){M[L]=M[L]+J;}}}this.setAttributeConfig(this.OPT.IDS,{value:M,writeonce:true});this.setAttributeConfig(this.OPT.TXT,{value:K.txt||this.TXT,writeonce:true});this.setAttributeConfig(this.OPT.IMAGES,{value:K.images||this.IMAGE,writeonce:true});this.setAttributeConfig(this.OPT.ELEMENTS,{value:{},readonly:true});this.setAttributeConfig(this.OPT.SHOW_CONTROLS,{value:C.isBoolean(K.showcontrols)?K.showcontrols:true,method:function(N){var O=E.getElementsByClassName("bd","div",this.getElement(this.ID.CONTROLS))[0];this._hideShowEl(O,N);this.getElement(this.ID.CONTROLS_LABEL).innerHTML=(N)?this.get(this.OPT.TXT).HIDE_CONTROLS:this.get(this.OPT.TXT).SHOW_CONTROLS;}});this.setAttributeConfig(this.OPT.SHOW_RGB_CONTROLS,{value:C.isBoolean(K.showrgbcontrols)?K.showrgbcontrols:true,method:function(N){this._hideShowEl(this.ID.RGB_CONTROLS,N);}});this.setAttributeConfig(this.OPT.SHOW_HSV_CONTROLS,{value:C.isBoolean(K.showhsvcontrols)?K.showhsvcontrols:false,method:function(N){this._hideShowEl(this.ID.HSV_CONTROLS,N);if(N&&this.get(this.OPT.SHOW_HEX_SUMMARY)){this.set(this.OPT.SHOW_HEX_SUMMARY,false);}}});this.setAttributeConfig(this.OPT.SHOW_HEX_CONTROLS,{value:C.isBoolean(K.showhexcontrols)?K.showhexcontrols:false,method:function(N){this._hideShowEl(this.ID.HEX_CONTROLS,N);}});this.setAttributeConfig(this.OPT.SHOW_WEBSAFE,{value:C.isBoolean(K.showwebsafe)?K.showwebsafe:true,method:function(N){this._hideShowEl(this.ID.WEBSAFE_SWATCH,N);}});this.setAttributeConfig(this.OPT.SHOW_HEX_SUMMARY,{value:C.isBoolean(K.showhexsummary)?K.showhexsummary:true,method:function(N){this._hideShowEl(this.ID.HEX_SUMMARY,N);if(N&&this.get(this.OPT.SHOW_HSV_CONTROLS)){this.set(this.OPT.SHOW_HSV_CONTROLS,false);}}});this.setAttributeConfig(this.OPT.ANIMATE,{value:C.isBoolean(K.animate)?K.animate:true,method:function(N){if(this.pickerSlider){this.pickerSlider.animate=N;this.hueSlider.animate=N;}}});this.on(this.OPT.HUE+"Change",this._updateRGBFromHSV,this,true);this.on(this.OPT.SATURATION+"Change",this._updateRGBFromHSV,this,true);this.on(this.OPT.VALUE+"Change",this._updateRGBFromHSV,this,true);this.on(this.OPT.RED+"Change",this._updateRGB,this,true);this.on(this.OPT.GREEN+"Change",this._updateRGB,this,true);this.on(this.OPT.BLUE+"Change",this._updateRGB,this,true);this.on(this.OPT.HEX+"Change",this._updateHex,this,true);this._initElements();}});YAHOO.widget.ColorPicker=G;})();YAHOO.register("colorpicker",YAHOO.widget.ColorPicker,{version:"2.8.2r1",build:"7"}); \ No newline at end of file
+YAHOO.util.Color=function(){var a="0",b=YAHOO.lang.isArray,c=YAHOO.lang.isNumber;return{real2dec:function(d){return Math.min(255,Math.round(d*256));},hsv2rgb:function(l,y,w){if(b(l)){return this.hsv2rgb.call(this,l[0],l[1],l[2]);}var d,m,u,k=Math.floor((l/60)%6),n=(l/60)-k,j=w*(1-y),e=w*(1-n*y),x=w*(1-(1-n)*y),o;switch(k){case 0:d=w;m=x;u=j;break;case 1:d=e;m=w;u=j;break;case 2:d=j;m=w;u=x;break;case 3:d=j;m=e;u=w;break;case 4:d=x;m=j;u=w;break;case 5:d=w;m=j;u=e;break;}o=this.real2dec;return[o(d),o(m),o(u)];},rgb2hsv:function(d,j,k){if(b(d)){return this.rgb2hsv.apply(this,d);}d/=255;j/=255;k/=255;var i,n,e=Math.min(Math.min(d,j),k),l=Math.max(Math.max(d,j),k),m=l-e,f;switch(l){case e:i=0;break;case d:i=60*(j-k)/m;if(j<k){i+=360;}break;case j:i=(60*(k-d)/m)+120;break;case k:i=(60*(d-j)/m)+240;break;}n=(l===0)?0:1-(e/l);f=[Math.round(i),n,l];return f;},rgb2hex:function(h,e,d){if(b(h)){return this.rgb2hex.apply(this,h);}var i=this.dec2hex;return i(h)+i(e)+i(d);},dec2hex:function(d){d=parseInt(d,10)|0;d=(d>255||d<0)?0:d;return(a+d.toString(16)).slice(-2).toUpperCase();},hex2dec:function(d){return parseInt(d,16);},hex2rgb:function(d){var e=this.hex2dec;return[e(d.slice(0,2)),e(d.slice(2,4)),e(d.slice(4,6))];},websafe:function(h,e,d){if(b(h)){return this.websafe.apply(this,h);}var i=function(f){if(c(f)){f=Math.min(Math.max(0,f),255);var g,j;for(g=0;g<256;g=g+51){j=g+51;if(f>=g&&f<=j){return(f-g>25)?j:g;}}}return f;};return[i(h),i(e),i(d)];}};}();(function(){var k=0,g=YAHOO.util,d=YAHOO.lang,e=YAHOO.widget.Slider,c=g.Color,f=g.Dom,j=g.Event,a=d.substitute,i="yui-picker";function h(l,b){k=k+1;b=b||{};if(arguments.length===1&&!YAHOO.lang.isString(l)&&!l.nodeName){b=l;l=b.element||null;}if(!l&&!b.element){l=this._createHostElement(b);}h.superclass.constructor.call(this,l,b);this.initPicker();}YAHOO.extend(h,YAHOO.util.Element,{ID:{R:i+"-r",R_HEX:i+"-rhex",G:i+"-g",G_HEX:i+"-ghex",B:i+"-b",B_HEX:i+"-bhex",H:i+"-h",S:i+"-s",V:i+"-v",PICKER_BG:i+"-bg",PICKER_THUMB:i+"-thumb",HUE_BG:i+"-hue-bg",HUE_THUMB:i+"-hue-thumb",HEX:i+"-hex",SWATCH:i+"-swatch",WEBSAFE_SWATCH:i+"-websafe-swatch",CONTROLS:i+"-controls",RGB_CONTROLS:i+"-rgb-controls",HSV_CONTROLS:i+"-hsv-controls",HEX_CONTROLS:i+"-hex-controls",HEX_SUMMARY:i+"-hex-summary",CONTROLS_LABEL:i+"-controls-label"},TXT:{ILLEGAL_HEX:"Illegal hex value entered",SHOW_CONTROLS:"Show color details",HIDE_CONTROLS:"Hide color details",CURRENT_COLOR:"Currently selected color: {rgb}",CLOSEST_WEBSAFE:"Closest websafe color: {rgb}. Click to select.",R:"R",G:"G",B:"B",H:"H",S:"S",V:"V",HEX:"#",DEG:"\u00B0",PERCENT:"%"},IMAGE:{PICKER_THUMB:"../../build/colorpicker/assets/picker_thumb.png",HUE_THUMB:"../../build/colorpicker/assets/hue_thumb.png"},DEFAULT:{PICKER_SIZE:180},OPT:{HUE:"hue",SATURATION:"saturation",VALUE:"value",RED:"red",GREEN:"green",BLUE:"blue",HSV:"hsv",RGB:"rgb",WEBSAFE:"websafe",HEX:"hex",PICKER_SIZE:"pickersize",SHOW_CONTROLS:"showcontrols",SHOW_RGB_CONTROLS:"showrgbcontrols",SHOW_HSV_CONTROLS:"showhsvcontrols",SHOW_HEX_CONTROLS:"showhexcontrols",SHOW_HEX_SUMMARY:"showhexsummary",SHOW_WEBSAFE:"showwebsafe",CONTAINER:"container",IDS:"ids",ELEMENTS:"elements",TXT:"txt",IMAGES:"images",ANIMATE:"animate"},skipAnim:true,_createHostElement:function(){var b=document.createElement("div");if(this.CSS.BASE){b.className=this.CSS.BASE;}return b;},_updateHueSlider:function(){var b=this.get(this.OPT.PICKER_SIZE),l=this.get(this.OPT.HUE);l=b-Math.round(l/360*b);if(l===b){l=0;}this.hueSlider.setValue(l,this.skipAnim);},_updatePickerSlider:function(){var l=this.get(this.OPT.PICKER_SIZE),m=this.get(this.OPT.SATURATION),b=this.get(this.OPT.VALUE);m=Math.round(m*l/100);b=Math.round(l-(b*l/100));this.pickerSlider.setRegionValue(m,b,this.skipAnim);},_updateSliders:function(){this._updateHueSlider();this._updatePickerSlider();},setValue:function(l,b){b=(b)||false;this.set(this.OPT.RGB,l,b);this._updateSliders();},hueSlider:null,pickerSlider:null,_getH:function(){var b=this.get(this.OPT.PICKER_SIZE),l=(b-this.hueSlider.getValue())/b;l=Math.round(l*360);return(l===360)?0:l;},_getS:function(){return this.pickerSlider.getXValue()/this.get(this.OPT.PICKER_SIZE);},_getV:function(){var b=this.get(this.OPT.PICKER_SIZE);return(b-this.pickerSlider.getYValue())/b;},_updateSwatch:function(){var m=this.get(this.OPT.RGB),o=this.get(this.OPT.WEBSAFE),n=this.getElement(this.ID.SWATCH),l=m.join(","),b=this.get(this.OPT.TXT);f.setStyle(n,"background-color","rgb("+l+")");n.title=a(b.CURRENT_COLOR,{"rgb":"#"+this.get(this.OPT.HEX)});n=this.getElement(this.ID.WEBSAFE_SWATCH);l=o.join(",");f.setStyle(n,"background-color","rgb("+l+")");n.title=a(b.CLOSEST_WEBSAFE,{"rgb":"#"+c.rgb2hex(o)});},_getValuesFromSliders:function(){this.set(this.OPT.RGB,c.hsv2rgb(this._getH(),this._getS(),this._getV()));},_updateFormFields:function(){this.getElement(this.ID.H).value=this.get(this.OPT.HUE);this.getElement(this.ID.S).value=this.get(this.OPT.SATURATION);this.getElement(this.ID.V).value=this.get(this.OPT.VALUE);this.getElement(this.ID.R).value=this.get(this.OPT.RED);this.getElement(this.ID.R_HEX).innerHTML=c.dec2hex(this.get(this.OPT.RED));this.getElement(this.ID.G).value=this.get(this.OPT.GREEN);this.getElement(this.ID.G_HEX).innerHTML=c.dec2hex(this.get(this.OPT.GREEN));this.getElement(this.ID.B).value=this.get(this.OPT.BLUE);this.getElement(this.ID.B_HEX).innerHTML=c.dec2hex(this.get(this.OPT.BLUE));this.getElement(this.ID.HEX).value=this.get(this.OPT.HEX);},_onHueSliderChange:function(n){var l=this._getH(),b=c.hsv2rgb(l,1,1),m="rgb("+b.join(",")+")";this.set(this.OPT.HUE,l,true);f.setStyle(this.getElement(this.ID.PICKER_BG),"background-color",m);if(this.hueSlider.valueChangeSource!==e.SOURCE_SET_VALUE){this._getValuesFromSliders();}this._updateFormFields();this._updateSwatch();},_onPickerSliderChange:function(m){var l=this._getS(),b=this._getV();this.set(this.OPT.SATURATION,Math.round(l*100),true);this.set(this.OPT.VALUE,Math.round(b*100),true);if(this.pickerSlider.valueChangeSource!==e.SOURCE_SET_VALUE){this._getValuesFromSliders();
+}this._updateFormFields();this._updateSwatch();},_getCommand:function(b){var l=j.getCharCode(b);if(l===38){return 3;}else{if(l===13){return 6;}else{if(l===40){return 4;}else{if(l>=48&&l<=57){return 1;}else{if(l>=97&&l<=102){return 2;}else{if(l>=65&&l<=70){return 2;}else{if("8, 9, 13, 27, 37, 39".indexOf(l)>-1||b.ctrlKey||b.metaKey){return 5;}else{return 0;}}}}}}}},_useFieldValue:function(l,b,n){var m=b.value;if(n!==this.OPT.HEX){m=parseInt(m,10);}if(m!==this.get(n)){this.set(n,m);}},_rgbFieldKeypress:function(m,b,o){var n=this._getCommand(m),l=(m.shiftKey)?10:1;switch(n){case 6:this._useFieldValue.apply(this,arguments);break;case 3:this.set(o,Math.min(this.get(o)+l,255));this._updateFormFields();break;case 4:this.set(o,Math.max(this.get(o)-l,0));this._updateFormFields();break;default:}},_hexFieldKeypress:function(l,b,n){var m=this._getCommand(l);if(m===6){this._useFieldValue.apply(this,arguments);}},_hexOnly:function(l,b){var m=this._getCommand(l);switch(m){case 6:case 5:case 1:break;case 2:if(b!==true){break;}default:j.stopEvent(l);return false;}},_numbersOnly:function(b){return this._hexOnly(b,true);},getElement:function(b){return this.get(this.OPT.ELEMENTS)[this.get(this.OPT.IDS)[b]];},_createElements:function(){var n,m,q,o,l,b=this.get(this.OPT.IDS),r=this.get(this.OPT.TXT),t=this.get(this.OPT.IMAGES),s=function(p,v){var w=document.createElement(p);if(v){d.augmentObject(w,v,true);}return w;},u=function(p,v){var w=d.merge({autocomplete:"off",value:"0",size:3,maxlength:3},v);w.name=w.id;return new s(p,w);};l=this.get("element");n=new s("div",{id:b[this.ID.PICKER_BG],className:"yui-picker-bg",tabIndex:-1,hideFocus:true});m=new s("div",{id:b[this.ID.PICKER_THUMB],className:"yui-picker-thumb"});q=new s("img",{src:t.PICKER_THUMB});m.appendChild(q);n.appendChild(m);l.appendChild(n);n=new s("div",{id:b[this.ID.HUE_BG],className:"yui-picker-hue-bg",tabIndex:-1,hideFocus:true});m=new s("div",{id:b[this.ID.HUE_THUMB],className:"yui-picker-hue-thumb"});q=new s("img",{src:t.HUE_THUMB});m.appendChild(q);n.appendChild(m);l.appendChild(n);n=new s("div",{id:b[this.ID.CONTROLS],className:"yui-picker-controls"});l.appendChild(n);l=n;n=new s("div",{className:"hd"});m=new s("a",{id:b[this.ID.CONTROLS_LABEL],href:"#"});n.appendChild(m);l.appendChild(n);n=new s("div",{className:"bd"});l.appendChild(n);l=n;n=new s("ul",{id:b[this.ID.RGB_CONTROLS],className:"yui-picker-rgb-controls"});m=new s("li");m.appendChild(document.createTextNode(r.R+" "));o=new u("input",{id:b[this.ID.R],className:"yui-picker-r"});m.appendChild(o);n.appendChild(m);m=new s("li");m.appendChild(document.createTextNode(r.G+" "));o=new u("input",{id:b[this.ID.G],className:"yui-picker-g"});m.appendChild(o);n.appendChild(m);m=new s("li");m.appendChild(document.createTextNode(r.B+" "));o=new u("input",{id:b[this.ID.B],className:"yui-picker-b"});m.appendChild(o);n.appendChild(m);l.appendChild(n);n=new s("ul",{id:b[this.ID.HSV_CONTROLS],className:"yui-picker-hsv-controls"});m=new s("li");m.appendChild(document.createTextNode(r.H+" "));o=new u("input",{id:b[this.ID.H],className:"yui-picker-h"});m.appendChild(o);m.appendChild(document.createTextNode(" "+r.DEG));n.appendChild(m);m=new s("li");m.appendChild(document.createTextNode(r.S+" "));o=new u("input",{id:b[this.ID.S],className:"yui-picker-s"});m.appendChild(o);m.appendChild(document.createTextNode(" "+r.PERCENT));n.appendChild(m);m=new s("li");m.appendChild(document.createTextNode(r.V+" "));o=new u("input",{id:b[this.ID.V],className:"yui-picker-v"});m.appendChild(o);m.appendChild(document.createTextNode(" "+r.PERCENT));n.appendChild(m);l.appendChild(n);n=new s("ul",{id:b[this.ID.HEX_SUMMARY],className:"yui-picker-hex_summary"});m=new s("li",{id:b[this.ID.R_HEX]});n.appendChild(m);m=new s("li",{id:b[this.ID.G_HEX]});n.appendChild(m);m=new s("li",{id:b[this.ID.B_HEX]});n.appendChild(m);l.appendChild(n);n=new s("div",{id:b[this.ID.HEX_CONTROLS],className:"yui-picker-hex-controls"});n.appendChild(document.createTextNode(r.HEX+" "));m=new u("input",{id:b[this.ID.HEX],className:"yui-picker-hex",size:6,maxlength:6});n.appendChild(m);l.appendChild(n);l=this.get("element");n=new s("div",{id:b[this.ID.SWATCH],className:"yui-picker-swatch"});l.appendChild(n);n=new s("div",{id:b[this.ID.WEBSAFE_SWATCH],className:"yui-picker-websafe-swatch"});l.appendChild(n);},_attachRGBHSV:function(l,b){j.on(this.getElement(l),"keydown",function(n,m){m._rgbFieldKeypress(n,this,b);},this);j.on(this.getElement(l),"keypress",this._numbersOnly,this,true);j.on(this.getElement(l),"blur",function(n,m){m._useFieldValue(n,this,b);},this);},_updateRGB:function(){var b=[this.get(this.OPT.RED),this.get(this.OPT.GREEN),this.get(this.OPT.BLUE)];this.set(this.OPT.RGB,b);this._updateSliders();},_initElements:function(){var p=this.OPT,n=this.get(p.IDS),l=this.get(p.ELEMENTS),b,m,q;for(b in this.ID){if(d.hasOwnProperty(this.ID,b)){n[this.ID[b]]=n[b];}}m=f.get(n[this.ID.PICKER_BG]);if(!m){this._createElements();}else{}for(b in n){if(d.hasOwnProperty(n,b)){m=f.get(n[b]);q=f.generateId(m);n[b]=q;n[n[b]]=q;l[q]=m;}}},initPicker:function(){this._initSliders();this._bindUI();this.syncUI(true);},_initSliders:function(){var b=this.ID,l=this.get(this.OPT.PICKER_SIZE);this.hueSlider=e.getVertSlider(this.getElement(b.HUE_BG),this.getElement(b.HUE_THUMB),0,l);this.pickerSlider=e.getSliderRegion(this.getElement(b.PICKER_BG),this.getElement(b.PICKER_THUMB),0,l,0,l);this.set(this.OPT.ANIMATE,this.get(this.OPT.ANIMATE));},_bindUI:function(){var b=this.ID,l=this.OPT;this.hueSlider.subscribe("change",this._onHueSliderChange,this,true);this.pickerSlider.subscribe("change",this._onPickerSliderChange,this,true);j.on(this.getElement(b.WEBSAFE_SWATCH),"click",function(m){this.setValue(this.get(l.WEBSAFE));},this,true);j.on(this.getElement(b.CONTROLS_LABEL),"click",function(m){this.set(l.SHOW_CONTROLS,!this.get(l.SHOW_CONTROLS));j.preventDefault(m);},this,true);this._attachRGBHSV(b.R,l.RED);this._attachRGBHSV(b.G,l.GREEN);this._attachRGBHSV(b.B,l.BLUE);this._attachRGBHSV(b.H,l.HUE);
+this._attachRGBHSV(b.S,l.SATURATION);this._attachRGBHSV(b.V,l.VALUE);j.on(this.getElement(b.HEX),"keydown",function(n,m){m._hexFieldKeypress(n,this,l.HEX);},this);j.on(this.getElement(this.ID.HEX),"keypress",this._hexOnly,this,true);j.on(this.getElement(this.ID.HEX),"blur",function(n,m){m._useFieldValue(n,this,l.HEX);},this);},syncUI:function(b){this.skipAnim=b;this._updateRGB();this.skipAnim=false;},_updateRGBFromHSV:function(){var l=[this.get(this.OPT.HUE),this.get(this.OPT.SATURATION)/100,this.get(this.OPT.VALUE)/100],b=c.hsv2rgb(l);this.set(this.OPT.RGB,b);this._updateSliders();},_updateHex:function(){var o=this.get(this.OPT.HEX),b=o.length,p,n,m;if(b===3){p=o.split("");for(n=0;n<b;n=n+1){p[n]=p[n]+p[n];}o=p.join("");}if(o.length!==6){return false;}m=c.hex2rgb(o);this.setValue(m);},_hideShowEl:function(m,b){var l=(d.isString(m)?this.getElement(m):m);f.setStyle(l,"display",(b)?"":"none");},initAttributes:function(b){b=b||{};h.superclass.initAttributes.call(this,b);this.setAttributeConfig(this.OPT.PICKER_SIZE,{value:b.size||this.DEFAULT.PICKER_SIZE});this.setAttributeConfig(this.OPT.HUE,{value:b.hue||0,validator:d.isNumber});this.setAttributeConfig(this.OPT.SATURATION,{value:b.saturation||0,validator:d.isNumber});this.setAttributeConfig(this.OPT.VALUE,{value:d.isNumber(b.value)?b.value:100,validator:d.isNumber});this.setAttributeConfig(this.OPT.RED,{value:d.isNumber(b.red)?b.red:255,validator:d.isNumber});this.setAttributeConfig(this.OPT.GREEN,{value:d.isNumber(b.green)?b.green:255,validator:d.isNumber});this.setAttributeConfig(this.OPT.BLUE,{value:d.isNumber(b.blue)?b.blue:255,validator:d.isNumber});this.setAttributeConfig(this.OPT.HEX,{value:b.hex||"FFFFFF",validator:d.isString});this.setAttributeConfig(this.OPT.RGB,{value:b.rgb||[255,255,255],method:function(o){this.set(this.OPT.RED,o[0],true);this.set(this.OPT.GREEN,o[1],true);this.set(this.OPT.BLUE,o[2],true);var q=c.websafe(o),p=c.rgb2hex(o),n=c.rgb2hsv(o);this.set(this.OPT.WEBSAFE,q,true);this.set(this.OPT.HEX,p,true);if(n[1]){this.set(this.OPT.HUE,n[0],true);}this.set(this.OPT.SATURATION,Math.round(n[1]*100),true);this.set(this.OPT.VALUE,Math.round(n[2]*100),true);},readonly:true});this.setAttributeConfig(this.OPT.CONTAINER,{value:null,method:function(n){if(n){n.showEvent.subscribe(function(){this.pickerSlider.focus();},this,true);}}});this.setAttributeConfig(this.OPT.WEBSAFE,{value:b.websafe||[255,255,255]});var m=b.ids||d.merge({},this.ID),l;if(!b.ids&&k>1){for(l in m){if(d.hasOwnProperty(m,l)){m[l]=m[l]+k;}}}this.setAttributeConfig(this.OPT.IDS,{value:m,writeonce:true});this.setAttributeConfig(this.OPT.TXT,{value:b.txt||this.TXT,writeonce:true});this.setAttributeConfig(this.OPT.IMAGES,{value:b.images||this.IMAGE,writeonce:true});this.setAttributeConfig(this.OPT.ELEMENTS,{value:{},readonly:true});this.setAttributeConfig(this.OPT.SHOW_CONTROLS,{value:d.isBoolean(b.showcontrols)?b.showcontrols:true,method:function(n){var o=f.getElementsByClassName("bd","div",this.getElement(this.ID.CONTROLS))[0];this._hideShowEl(o,n);this.getElement(this.ID.CONTROLS_LABEL).innerHTML=(n)?this.get(this.OPT.TXT).HIDE_CONTROLS:this.get(this.OPT.TXT).SHOW_CONTROLS;}});this.setAttributeConfig(this.OPT.SHOW_RGB_CONTROLS,{value:d.isBoolean(b.showrgbcontrols)?b.showrgbcontrols:true,method:function(n){this._hideShowEl(this.ID.RGB_CONTROLS,n);}});this.setAttributeConfig(this.OPT.SHOW_HSV_CONTROLS,{value:d.isBoolean(b.showhsvcontrols)?b.showhsvcontrols:false,method:function(n){this._hideShowEl(this.ID.HSV_CONTROLS,n);if(n&&this.get(this.OPT.SHOW_HEX_SUMMARY)){this.set(this.OPT.SHOW_HEX_SUMMARY,false);}}});this.setAttributeConfig(this.OPT.SHOW_HEX_CONTROLS,{value:d.isBoolean(b.showhexcontrols)?b.showhexcontrols:false,method:function(n){this._hideShowEl(this.ID.HEX_CONTROLS,n);}});this.setAttributeConfig(this.OPT.SHOW_WEBSAFE,{value:d.isBoolean(b.showwebsafe)?b.showwebsafe:true,method:function(n){this._hideShowEl(this.ID.WEBSAFE_SWATCH,n);}});this.setAttributeConfig(this.OPT.SHOW_HEX_SUMMARY,{value:d.isBoolean(b.showhexsummary)?b.showhexsummary:true,method:function(n){this._hideShowEl(this.ID.HEX_SUMMARY,n);if(n&&this.get(this.OPT.SHOW_HSV_CONTROLS)){this.set(this.OPT.SHOW_HSV_CONTROLS,false);}}});this.setAttributeConfig(this.OPT.ANIMATE,{value:d.isBoolean(b.animate)?b.animate:true,method:function(n){if(this.pickerSlider){this.pickerSlider.animate=n;this.hueSlider.animate=n;}}});this.on(this.OPT.HUE+"Change",this._updateRGBFromHSV,this,true);this.on(this.OPT.SATURATION+"Change",this._updateRGBFromHSV,this,true);this.on(this.OPT.VALUE+"Change",this._updateRGBFromHSV,this,true);this.on(this.OPT.RED+"Change",this._updateRGB,this,true);this.on(this.OPT.GREEN+"Change",this._updateRGB,this,true);this.on(this.OPT.BLUE+"Change",this._updateRGB,this,true);this.on(this.OPT.HEX+"Change",this._updateHex,this,true);this._initElements();}});YAHOO.widget.ColorPicker=h;})();YAHOO.register("colorpicker",YAHOO.widget.ColorPicker,{version:"2.9.0",build:"2800"}); \ No newline at end of file