2009-06-16 18:28:41 +00:00
|
|
|
|
(function(d){var c=function(g,p){var m=this,k=d("#"+g),o=d("#"+g+"_Arrow"),n=function(q){j(q);d(document).bind("mousemove",h).bind("mouseup",l);q.stopPropagation();q.preventDefault();return false;},h=function(q){j(q);q.stopPropagation();q.preventDefault();return false;},l=function(q){d(document).unbind("mouseup",l).unbind("mousemove",h);q.stopPropagation();q.preventDefault();return false;},j=function(u){var w=k.offset(),q=u.pageX-w.left-parseInt(k.css("border-left-width")),z=u.pageY-w.top-parseInt(k.css("border-top-width")),t=k.w,r=k.h,v,s;if(q<0){q=0;}else{if(q>t){q=t;}}if(z<0){z=0;}else{if(z>r){z=r;}}v=Math.floor(q/t*m.mxX);s=Math.floor(z/r*m.mxY);m.x=v;m.y=s;if(m.mxX==m.mnX){q=0;}if(m.mxY==m.mnY){z=0;}m.setArrowPosition(q,z);d.isFunction(m.valuesChanged)&&m.valuesChanged(m);};d.extend(true,m,{settings:p,x:0,y:0,mnX:0,mxX:0,mnY:100,mxY:100,valuesChanged:d.isFunction(arguments[2])&&arguments[2]||null,setPositioningVariables:function(r){var q=m.settings.map;k.w=q&&q.width||k.width();k.h=q&&q.height||k.height();m.MinX=0;m.MinY=0;m.MaxX=k.w;m.MaxY=k.h;},setArrowPositionFromValues:function(t){m.setPositioningVariables();var w=0,v=0,u=m.mnX,r=m.mxX,s=m.mnY,q=m.mxY,A=m.x,z=m.y;if(u!=r){if(A==u){w=0;}else{if(A==r){w=k.w;}else{if(u<1){r+=Math.abs(u)+1;}if(A<1){A+=1;}w=A/r*k.w;if(parseInt(w)==(r-1)){w=r;}else{w=parseInt(w);}if(u<1){w-=Math.abs(u)-1;}}}}if(s!=q){if(z==s){v=0;}else{if(z==q){v=k.h;}else{if(s<1){q+=Math.abs(s)+1;}if(z<1){z+=1;}v=z/q*k.h;if(parseInt(v)==(q-1)){v=q;}else{v=parseInt(v);}if(s<1){v-=Math.abs(s)-1;}}}}m.setArrowPosition(w,v);},setArrowPosition:function(q,v){var u=k.w,s=k.h,t=o.w,r=o.h;if(q<0){q=0;}else{if(q>u){q=u;}}if(v<0){v=0;}else{if(v>s){v=s;}}if(t>u){q=(u>>1)-(t>>1);}else{q-=t>>1;}if(r>s){v=(s>>1)-(r>>1);}else{v-=r>>1;}o.css({left:q+"px",top:v+"px"});},destroy:function(){d(document).unbind("mouseup",l).unbind("mousemove",h);k.unbind("mousedown",n);k=null;o=null;m.valuesChanged=null;}});o.src=m.settings.arrow&&m.settings.arrow.image;o.w=m.settings.arrow&&m.settings.arrow.width||o.width();o.h=m.settings.arrow&&m.settings.arrow.height||o.height();m.setPositioningVariables();k.bind("mousedown",n);m.setArrowPositionFromValues();d.isFunction(m.valuesChanged)&&m.valuesChanged(m);},a=function(h){var r=this,u=function(w){if(w.target.value==""){return;}v(w);r.setValuesFromHsv();d.isFunction(r.valuesChanged)&&r.valuesChanged(r);},n=function(w){if(w.target.value==""){return;}j(w);r.setValuesFromRgb();d.isFunction(r.valuesChanged)&&r.valuesChanged(r);},g=function(w){if(w.target.value==""){r.setValuesFromRgb();}},p=function(w){if(w.target.value==""){r.setValuesFromHsv();}},t=function(w){if(w.target.value==""){return;}s(w);r.setValuesFromHex();d.isFunction(r.valuesChanged)&&r.valuesChanged(r);},q=function(w){if(w.target.value==""){r.setValuesFromHsv();}},j=function(w){if(!l(w)){return w;}o.red.val(m(o.red.val(),0,255));o.green.val(m(o.green.val(),0,255));o.blue.val(m(o.blue.val(),0,255));},v=function(w){if(!l(w)){return w;}o.hue.val(m(o.hue.val(),0,360));o.saturation.val(m(o.saturation.val(),0,100));o.value.val(m(o.value.val(),0,100));},s=function(w){if(!l(w)){return w;}o.hex.val(o.hex.val().replace(/[^a-fA-F0-9]/g,"0").toLowerCase().substring(0,6));},l=function(w){switch(w.keyCode){case 9:case 16:case 29:case 37:case 38:case 40:return false;case"c".charCodeAt():case"v".charCodeAt():if(w.ctrlKey){return false;}}return true;},m=function(y,x,w){if(y==""||isNaN(y)){return x;}y=parseInt(y);if(y>w){return w;}if(y<x){return x;}return y;};d.extend(true,r,{color:new e(),fields:{hue:d("#"+h+"_jPicker_Hue"),saturation:d("#"+h+"_jPicker_Saturation"),value:d("#"+h+"_jPicker_Brightness"),red:d("#"+h+"_jPicker_Red"),green:d("#"+h+"_jPicker_Green"),blue:d("#"+h+"_jPicker_Blue"),hex:d("#"+h+"_jPicker_Hex")},valuesChanged:d.isFunction(arguments[1])&&arguments[1]||null,bindedHexKeyUp:function(w){t(w);},setValuesFromRgb:function(){k.fromRgb(o.red.val(),o.green.val(),o.blue.val());o.hex.val(k.hex);o.hue.val(k.h);o.saturation.val(k.s);o.value.val(k.v);},setValuesFromHsv:function(){k.fromHsv(o.hue.val(),o.saturation.val(),o.value.va
|