diff --git a/build/gallery-colorpicker/gallery-colorpicker-debug.js b/build/gallery-colorpicker/gallery-colorpicker-debug.js index 73af5c2f6f..34568c5a71 100644 --- a/build/gallery-colorpicker/gallery-colorpicker-debug.js +++ b/build/gallery-colorpicker/gallery-colorpicker-debug.js @@ -553,9 +553,11 @@ Y.extend(ColorPicker, Y.Widget, { this.trackBar = args.component; this.trackBarCanvas = ev.target; var offXY = ev.target.getXY(), + scrollX = ev.target.get('docScrollX'), + scrollY = ev.target.get('docScrollY'), // get position within the square - x = ev.clientX - offXY[0], - y = ev.clientY - offXY[1]; + x = ev.clientX + scrollX - offXY[0], + y = ev.clientY + scrollY - offXY[1]; this.barX = x; this.barY = y; @@ -573,13 +575,19 @@ Y.extend(ColorPicker, Y.Widget, { x, y, width, - height; + height, + scrollX, + scrollY, + c; if (this.trackSquare) { - offXY = Y.Node.one(this.squareCanvas).getXY(); + c = Y.Node.one(this.squareCanvas); + offXY = c.getXY(); + scrollX = c.get('docScrollX'); + scrollY = c.get('docScrollY'); // get position within the square - x = ev.clientX - offXY[0]; - y = ev.clientY - offXY[1]; + x = ev.clientX + scrollX - offXY[0]; + y = ev.clientY + scrollY - offXY[1]; width = this.get('squareWidth'); height = this.get('squareHeight'); @@ -592,9 +600,11 @@ Y.extend(ColorPicker, Y.Widget, { } if (this.trackBar) { offXY = this.trackBarCanvas.getXY(); + scrollX = this.trackBarCanvas.get('docScrollX'); + scrollY = this.trackBarCanvas.get('docScrollY'); // get position within the square - x = -this.barPaddingX + ev.clientX - offXY[0]; - y = -this.barPaddingY + ev.clientY - offXY[1]; + x = -this.barPaddingX + ev.clientX + scrollX - offXY[0]; + y = -this.barPaddingY + ev.clientY + scrollY - offXY[1]; width = this.get('barWidth'); height = this.get('barHeight'); @@ -611,9 +621,11 @@ Y.extend(ColorPicker, Y.Widget, { // mousedown inside square, start tracking position this.trackSquare = true; var offXY = ev.target.getXY(), + scrollX = ev.target.get('docScrollX'), + scrollY = ev.target.get('docScrollY'), // get position within the square - x = ev.clientX - offXY[0], - y = ev.clientY - offXY[1]; + x = ev.clientX + scrollX - offXY[0], + y = ev.clientY + scrollY - offXY[1]; this.squareX = x; this.squareY = y; @@ -621,6 +633,9 @@ Y.extend(ColorPicker, Y.Widget, { ev.halt(); }, updateColor: function () { + if (!this.get('showHSLBars')) { + return; + } var barWidth = this.get('barWidth'), barHeight = this.get('barHeight'), cacheBars = this.get('cacheBars'), @@ -757,11 +772,13 @@ Y.extend(ColorPicker, Y.Widget, { } } this.renderSquare(); - this.updateColor(); this.updateValues(); - this.drawThumb(this.hCanvas, 'h', {h: this.color.h, s: 1.0, l: 0.5}, barWidth, barHeight, 1.0, false); - this.drawThumb(this.sCanvas, 's', {h: this.color.h, s: 1.0, l: this.color.l}, barWidth, barHeight, 1.0, true); - this.drawThumb(this.lCanvas, 'l', {h: this.color.h, s: this.color.s, l: 0.5}, barWidth, barHeight, 1.0, true); + if (this.get('showHSLBars')) { + this.updateColor(); + this.drawThumb(this.hCanvas, 'h', {h: this.color.h, s: 1.0, l: 0.5}, barWidth, barHeight, 1.0, false); + this.drawThumb(this.sCanvas, 's', {h: this.color.h, s: 1.0, l: this.color.l}, barWidth, barHeight, 1.0, true); + this.drawThumb(this.lCanvas, 'l', {h: this.color.h, s: this.color.s, l: 0.5}, barWidth, barHeight, 1.0, true); + } }, renderSquare: function () { var width = this.get('squareWidth'), height = this.get('squareHeight'), @@ -864,9 +881,11 @@ Y.extend(ColorPicker, Y.Widget, { }, bindUI: function () { Y.on('mousedown', this.onSquareMouseDown, this.squareCanvas, this); - Y.on('mousedown', this.onBarMouseDown, this.hCanvas, this, {component: 'h'}); - Y.on('mousedown', this.onBarMouseDown, this.sCanvas, this, {component: 's'}); - Y.on('mousedown', this.onBarMouseDown, this.lCanvas, this, {component: 'l'}); + if (this.get('showHSLBars')) { + Y.on('mousedown', this.onBarMouseDown, this.hCanvas, this, {component: 'h'}); + Y.on('mousedown', this.onBarMouseDown, this.sCanvas, this, {component: 's'}); + Y.on('mousedown', this.onBarMouseDown, this.lCanvas, this, {component: 'l'}); + } Y.delegate('keyup', this.onInputKeyUp, this.contentBox, '.' + ColorPicker.CLASSNAME_VALUE, this); Y.delegate('blur', this.onInputBlur, this.contentBox, '.' + ColorPicker.CLASSNAME_VALUE, this); Y.delegate('keydown', this.onInputKeyDown, this.contentBox, '.' + ColorPicker.CLASSNAME_VALUE, this); @@ -976,4 +995,4 @@ Y.extend(ColorPalette, Y.Widget, { Y.ColorPalette = ColorPalette; -}, 'gallery-2011.09.14-20-40' ,{requires:['node', 'event', 'widget', 'classnamemanager']}); +}, 'gallery-2011.09.28-20-06' ,{requires:['node', 'event', 'widget', 'classnamemanager']}); diff --git a/build/gallery-colorpicker/gallery-colorpicker-min.js b/build/gallery-colorpicker/gallery-colorpicker-min.js index de3f742c06..0041d1211b 100644 --- a/build/gallery-colorpicker/gallery-colorpicker-min.js +++ b/build/gallery-colorpicker/gallery-colorpicker-min.js @@ -1,3 +1,3 @@ YUI.add("gallery-colorpicker",function(d){var c={rgbToHSL:function(e,k,n){e/=255;k/=255;n/=255;var o=Math.max(e,k,n),i=Math.min(e,k,n),j,p,f=(o+i)/2,m;if(o===i){j=p=0;}else{m=o-i;p=f>0.5?m/(2-o-i):m/(o+i);switch(o){case e:j=(k-n)/m+(k1){e-=1;}if(e<1/6){return g+(f-g)*6*e;}if(e<1/2){return f;}if(e<2/3){return g+(f-g)*(2/3-e)*6;}return g;},hslToRGB:function(j,i,f){var m,k,e,n,o;if(i===0){m=k=e=f;}else{n=f<0.5?f*(1+i):f+i-f*i;o=2*f-n;m=c._hue2rgb(o,n,j+1/3);k=c._hue2rgb(o,n,j);e=c._hue2rgb(o,n,j-1/3);}return{r:Math.round(m*255),g:Math.round(k*255),b:Math.round(e*255)};}};d.Colors=c;function a(){a.superclass.constructor.apply(this,arguments);}a.NAME="colorpicker";a.CLASSNAME=d.ClassNameManager.getClassName(a.NAME);a.CLASSNAME_SQUARE=d.ClassNameManager.getClassName(a.NAME,"colrsqr");a.CLASSNAME_HBAR=d.ClassNameManager.getClassName(a.NAME,"hbar");a.CLASSNAME_SBAR=d.ClassNameManager.getClassName(a.NAME,"sbar");a.CLASSNAME_LBAR=d.ClassNameManager.getClassName(a.NAME,"lbar");a.CLASSNAME_SWATCH=d.ClassNameManager.getClassName(a.NAME,"swatch");a.CLASSNAME_VALUE=d.ClassNameManager.getClassName(a.NAME,"val");a.CLASSNAME_HVALUE=d.ClassNameManager.getClassName(a.NAME,"hval");a.CLASSNAME_SVALUE=d.ClassNameManager.getClassName(a.NAME,"sval");a.CLASSNAME_LVALUE=d.ClassNameManager.getClassName(a.NAME,"lval");a.CLASSNAME_RVALUE=d.ClassNameManager.getClassName(a.NAME,"rval");a.CLASSNAME_GVALUE=d.ClassNameManager.getClassName(a.NAME,"gval");a.CLASSNAME_BVALUE=d.ClassNameManager.getClassName(a.NAME,"bval");a.CLASSNAME_HEXVALUE=d.ClassNameManager.getClassName(a.NAME,"hexval");a.ATTRS={showHSLBars:{value:true},showHSL:{value:true},showRGB:{value:true},showHEX:{value:true},showSwatch:{value:true},squareWidth:{value:150},squareHeight:{value:150},barWidth:{value:20},barHeight:{value:150},swatchWidth:{value:110},swatchHeight:{value:34},hex:{getter:function(){var f=this.get("rgb"),i=f.r.toString(16),h=f.g.toString(16),e=f.b.toString(16);if(i.length<2){i="0"+i;}if(h.length<2){h="0"+h;}if(e.length<2){e="0"+e;}return i+h+e;},setter:function(l){if(l.length<6){return;}var h=l[0]+l[1],f=l[2]+l[3],i=l[4]+l[5],k=parseInt(h,16),j=parseInt(f,16),e=parseInt(i,16);this.set("rgb",{r:k,g:j,b:e});}},rgb:{getter:function(){return c.hslToRGB(this.color.h,this.color.s,this.color.l);},setter:function(f){f.r=Math.min(f.r,255);f.g=Math.min(f.g,255);f.b=Math.min(f.b,255);f.r=Math.max(f.r,0);f.g=Math.max(f.g,0);f.b=Math.max(f.b,0);var e=c.rgbToHSL(f.r,f.g,f.b);this.color=d.merge(e);this.update();}},hslInt:{getter:function(){var e=d.merge(this.color);e.h=Math.round(e.h*360);e.s=Math.round(e.s*100);e.l=Math.round(e.l*100);return e;},setter:function(f){var e=d.merge(f);e.h=e.h/360;e.s=e.s/100;e.l=e.l/100;e.h=Math.min(e.h,1);e.s=Math.min(e.s,1);e.l=Math.min(e.l,1);e.h=Math.max(e.h,0);e.s=Math.max(e.s,0);e.l=Math.max(e.l,0);this.color=e;this.update();}},hsl:{getter:function(){return this.color;},setter:function(e){e.h=Math.min(e.h,1);e.s=Math.min(e.s,1);e.l=Math.min(e.l,1);e.h=Math.max(e.h,0);e.s=Math.max(e.s,0);e.l=Math.max(e.l,0);this.color=d.merge(e);this.update();}},cacheBars:{value:false},strings:{value:{hValue:"H",sValue:"S",lValue:"L",rValue:"R",gValue:"G",bValue:"B",hexValue:"Hex"}}};d.extend(a,d.Widget,{color:{h:0,s:1,l:0.5},sCachePixels:{},lCachePixels:{},squareCachePixels:{},barPaddingX:5,barPaddingY:5,renderUI:function(){this.contentBox=this.get("contentBox");this.contentBox.addClass(this.name);this.squareCanvas=this.createCanvas(a.CLASSNAME_SQUARE,this.get("squareWidth"),this.get("squareHeight"));this.squareCanvas.id="squareCanvas";this.renderSquare();var f,h,g,e;if(this.get("showHSLBars")){f=this.get("barWidth");h=this.get("barHeight");this.hCanvas=this.createCanvas(a.CLASSNAME_HBAR,f+this.barPaddingX*2,h+this.barPaddingY*2);this.sCanvas=this.createCanvas(a.CLASSNAME_SBAR,f+this.barPaddingX*2,h+this.barPaddingY*2);this.lCanvas=this.createCanvas(a.CLASSNAME_LBAR,f+this.barPaddingX*2,h+this.barPaddingY*2);}if(this.get("showSwatch")){this.swatchCanvas=d.Node.create("
");this.swatchCanvas.addClass(a.CLASSNAME_SWATCH);this.contentBox.appendChild(this.swatchCanvas);}if(this.get("showHSL")){this.hVal=this.createValue(a.CLASSNAME_HVALUE,this.get("strings.hValue"),this.color.h,3,3,"hslInt","h");this.sVal=this.createValue(a.CLASSNAME_SVALUE,this.get("strings.sValue"),this.color.s,3,3,"hslInt","s");this.lVal=this.createValue(a.CLASSNAME_LVALUE,this.get("strings.lValue"),this.color.l,3,3,"hslInt","l");}if(this.get("showRGB")){g=this.get("rgb");this.rVal=this.createValue(a.CLASSNAME_RVALUE,this.get("strings.rValue"),g.r,3,3,"rgb","r");this.gVal=this.createValue(a.CLASSNAME_GVALUE,this.get("strings.gValue"),g.g,3,3,"rgb","g");this.bVal=this.createValue(a.CLASSNAME_BVALUE,this.get("strings.bValue"),g.b,3,3,"rgb","b");}if(this.get("showHEX")){e=this.get("hex");this.hexVal=this.createValue(a.CLASSNAME_HEXVALUE,this.get("strings.hexValue"),e,6,6,"hex",null);}},renderPixels:function(j,s,q,v,u,A,w,h,g,B,z,D,C,m){var t=j.getContext("2d"),r=t.createImageData(s,q),l={h:0,s:0,l:0},f=(D-B)/s,k=(C-z)/q,p=0,i=1,o,n,e;l[A]=w;l[h]=B;l[g]=z;if(m){i=-1;p=r.data.length;}for(n=0;n"),f=d.Node.create("");i.appendChild(f);this.contentBox.appendChild(i);return d.Node.getDOMNode(f);},createValue:function(h,k,l,m,f,g,i){var e=d.Node.create("
"),j=d.Node.create("");k=d.Node.create("");e.appendChild(k);k.appendChild(j);this.contentBox.appendChild(e);j.setData("target",g);j.setData("component",i);return j;},onInputKeyDown:function(h){if(h.charCode===13||h.charCode===8||h.charCode===127||h.charCode===9){return true;}var f=String.fromCharCode(h.charCode),e=h.target,i=e.getData("target"),g;if(i==="hex"){g=/[0-9]|[a-f]|[A-F]/;if(!g.test(f)){h.halt();return false;}}else{g=/[0-9]/;if(!g.test(f)){h.halt();return false;}}},onInputKeyUp:function(h){var f=h.target,j=f.getData("target"),g=f.getData("component"),e=f.get("value"),i;if(e===""){return;}if(j==="hex"){if(e.length<6){return;}this.set(j,e);return;}i=this.get(j);i[g]=parseInt(e,10);this.set(j,i);},onInputBlur:function(){this.update(); -},bindUI:function(){d.on("mousedown",this.onSquareMouseDown,this.squareCanvas,this);d.on("mousedown",this.onBarMouseDown,this.hCanvas,this,{component:"h"});d.on("mousedown",this.onBarMouseDown,this.sCanvas,this,{component:"s"});d.on("mousedown",this.onBarMouseDown,this.lCanvas,this,{component:"l"});d.delegate("keyup",this.onInputKeyUp,this.contentBox,"."+a.CLASSNAME_VALUE,this);d.delegate("blur",this.onInputBlur,this.contentBox,"."+a.CLASSNAME_VALUE,this);d.delegate("keydown",this.onInputKeyDown,this.contentBox,"."+a.CLASSNAME_VALUE,this);},syncUI:function(){var f=this.get("squareWidth"),e=this.get("squareHeight");this.squareX=this.color.h*(f/1);this.squareY=this.color.l*(e/1);this.update();}});d.ColorPicker=a;function b(){b.superclass.constructor.apply(this,arguments);this.publish("palette:selected");}b.NAME="colorPalette";b.CLASSNAME_SWATCH="cp-swatch";b.ATTRS={};d.extend(b,d.Widget,{colors:[],colorExists:function(e){var f,g;for(f=0;f'),g=c.hslToRGB(h.h,h.s,h.l),e=this.get("contentBox");i.setStyle("background","rgb("+g.r+", "+g.g+", "+g.b+")");i.setData("hsl",h);e.appendChild(i);this.colors.push(h);},renderUI:function(){},bindUI:function(){d.delegate("click",this.onSwatchClick,this.get("contentBox"),"."+b.CLASSNAME_SWATCH,this);},onSwatchClick:function(h){var g=h.target,e=g.getData("hsl"),f=c.hslToRGB(e.h,e.s,e.l);this.fire("palette:selected",{hsl:e,rgb:f});},syncUI:function(){}});d.ColorPalette=b;},"gallery-2011.09.14-20-40",{requires:["node","event","widget","classnamemanager"]}); \ No newline at end of file +var g=h.target.getXY(),j=h.target.get("docScrollX"),i=h.target.get("docScrollY"),e=h.clientX+j-g[0],k=h.clientY+i-g[1];this.barX=e;this.barY=k;this.startUpdating();h.halt();},onMouseUp:function(e){this.trackBar=false;this.trackSquare=false;this.stopUpdating();e.halt();},onMouseMove:function(i){var f,j,h,e,m,l,k,g;if(this.trackSquare){g=d.Node.one(this.squareCanvas);f=g.getXY();l=g.get("docScrollX");k=g.get("docScrollY");j=i.clientX+l-f[0];h=i.clientY+k-f[1];e=this.get("squareWidth");m=this.get("squareHeight");j=Math.min(e,j);h=Math.min(m,h);h=Math.max(0,h);j=Math.max(0,j);this.squareX=j;this.squareY=h;}if(this.trackBar){f=this.trackBarCanvas.getXY();l=this.trackBarCanvas.get("docScrollX");k=this.trackBarCanvas.get("docScrollY");j=-this.barPaddingX+i.clientX+l-f[0];h=-this.barPaddingY+i.clientY+k-f[1];e=this.get("barWidth");m=this.get("barHeight");j=Math.min(e,j);h=Math.min(m,h);h=Math.max(0,h);j=Math.max(0,j);this.barX=j;this.barY=h;}i.halt();},onSquareMouseDown:function(g){this.trackSquare=true;var f=g.target.getXY(),i=g.target.get("docScrollX"),h=g.target.get("docScrollY"),e=g.clientX+i-f[0],j=g.clientY+h-f[1];this.squareX=e;this.squareY=j;this.startUpdating();g.halt();},updateColor:function(){if(!this.get("showHSLBars")){return;}var f=this.get("barWidth"),h=this.get("barHeight"),g=this.get("cacheBars"),e=this.hCanvas.getContext("2d");e.clearRect(0,0,f+this.barPaddingX*2,h+this.barPaddingY*2);e=this.sCanvas.getContext("2d");e.clearRect(0,0,f+this.barPaddingX*2,h+this.barPaddingY*2);e=this.lCanvas.getContext("2d");e.clearRect(0,0,f+this.barPaddingX*2,h+this.barPaddingY*2);if(g){if(!this.sCachePixels[this.color.h]){this.sCachePixels[this.color.h]=this.renderPixels(this.sCanvas,f,h,this.barPaddingX,this.barPaddingY,"h",this.color.h,"l","s",50,100,50,0);}else{e=this.sCanvas.getContext("2d");e.putImageData(this.sCachePixels[this.color.h],this.barPaddingX,this.barPaddingY);}if(!this.lCachePixels[this.color.h]){this.lCachePixels[this.color.h]=this.renderPixels(this.lCanvas,f,h,this.barPaddingX,this.barPaddingY,"h",this.color.h,"s","l",100,100,100,0);}else{e=this.lCanvas.getContext("2d");e.putImageData(this.lCachePixels[this.color.h],this.barPaddingX,this.barPaddingY);}}else{this.renderPixels(this.sCanvas,f,h,this.barPaddingX,this.barPaddingY,"h",this.color.h,"l","s",0.5,1,0.5,0);this.renderPixels(this.lCanvas,f,h,this.barPaddingX,this.barPaddingY,"h",this.color.h,"s","l",1,1,1,0);}if(!this.huePixelCache){this.huePixelCache=this.renderPixels(this.hCanvas,f,h,this.barPaddingX,this.barPaddingY,"s",1,"l","h",0.5,0,0.5,1);}else{e=this.hCanvas.getContext("2d");e.putImageData(this.huePixelCache,this.barPaddingX,this.barPaddingY);}},drawThumb:function(f,l,h,e,o,m,i){var n=this.color[l],p=f.getContext("2d"),k=(o/m)*(n),g=h,j;if(i){k=o-k;}k+=this.barPaddingY;g[l]=n;g.h=g.h-0.5;if(g.h<0){g.h+=1;}g.s=g.s-0.5;if(g.s<0){g.s+=1;}g.l=g.l-0.5;if(g.l<0){g.l+=1;}p.beginPath();p.moveTo(this.barPaddingX,k);p.lineTo(e+this.barPaddingX*2,k);j=c.hslToRGB(g.h,g.s,g.l);p.strokeStyle="rgb("+j.r+", "+j.g+", "+j.b+")";p.lineWidth=0.5;p.stroke();p.beginPath();p.moveTo(this.barPaddingX,k);p.lineTo(0,k-2.5);p.lineTo(0,k+2.5);p.lineTo(this.barPaddingX,k);p.moveTo(e+this.barPaddingX,k);p.lineTo(e+this.barPaddingX*2,k-2.5);p.lineTo(e+this.barPaddingX*2,k+2.5);p.lineTo(e+this.barPaddingX,k);p.strokeStyle="rgb(255, 255, 255)";p.fillStyle="rgb(255, 255, 255)";p.stroke();p.fill();},updateValues:function(){var e=this.get("rgb"),f;if(this.get("showSwatch")){this.swatchCanvas.setStyle("background","rgb("+e.r+", "+e.g+", "+e.b+")");}if(this.get("showHSL")){this.hVal.set("value",Math.round(this.color.h*360));this.sVal.set("value",Math.round(this.color.s*100));this.lVal.set("value",Math.round(this.color.l*100));}if(this.get("showRGB")){this.rVal.set("value",e.r);this.gVal.set("value",e.g);this.bVal.set("value",e.b);}if(this.get("showHEX")){f=this.get("hex");this.hexVal.set("value",f);}},update:function(){var k=this.get("squareWidth"),e=this.get("squareHeight"),j=this.get("barWidth"),m=this.get("barHeight"),i,f,g;if(this.trackSquare){i=(1/k)*this.squareX;f=1-(1/e)*this.squareY;this.color.h=i;this.color.l=f;}if(this.trackBar){if(this.trackBar==="h"){i=(1/m)*this.barY;this.color.h=i;}else{g=1-(1/m)*this.barY;this.color[this.trackBar]=g;}}this.renderSquare();this.updateValues();if(this.get("showHSLBars")){this.updateColor();this.drawThumb(this.hCanvas,"h",{h:this.color.h,s:1,l:0.5},j,m,1,false);this.drawThumb(this.sCanvas,"s",{h:this.color.h,s:1,l:this.color.l},j,m,1,true);this.drawThumb(this.lCanvas,"l",{h:this.color.h,s:this.color.s,l:0.5},j,m,1,true);}},renderSquare:function(){var i=this.get("squareWidth"),g=this.get("squareHeight"),h=this.squareCanvas.getContext("2d"),f,e,j;if(!this.squareCachePixels[this.color.s]){this.squareCachePixels[this.color.s]=this.renderPixels(this.squareCanvas,i,g,0,0,"s",this.color.s,"h","l",0,1,1,0);}else{h.putImageData(this.squareCachePixels[this.color.s],0,0);}h.strokeStyle="rgb(255, 255, 255)";f=5;e=(this.color.h*(i/1));j=((1-this.color.l)*(g/1));h.beginPath();h.arc(e,j,f,0,Math.PI*2,true);h.stroke();h.beginPath();h.strokeStyle="rgb(0, 0, 0)";h.arc(e,j,f+1,0,Math.PI*2,true);h.stroke();},createCanvas:function(h,g,e){var i=d.Node.create("
"),f=d.Node.create("");i.appendChild(f);this.contentBox.appendChild(i);return d.Node.getDOMNode(f);},createValue:function(h,k,l,m,f,g,i){var e=d.Node.create("
"),j=d.Node.create("");k=d.Node.create("");e.appendChild(k);k.appendChild(j);this.contentBox.appendChild(e);j.setData("target",g);j.setData("component",i);return j;},onInputKeyDown:function(h){if(h.charCode===13||h.charCode===8||h.charCode===127||h.charCode===9){return true;}var f=String.fromCharCode(h.charCode),e=h.target,i=e.getData("target"),g;if(i==="hex"){g=/[0-9]|[a-f]|[A-F]/;if(!g.test(f)){h.halt();return false; +}}else{g=/[0-9]/;if(!g.test(f)){h.halt();return false;}}},onInputKeyUp:function(h){var f=h.target,j=f.getData("target"),g=f.getData("component"),e=f.get("value"),i;if(e===""){return;}if(j==="hex"){if(e.length<6){return;}this.set(j,e);return;}i=this.get(j);i[g]=parseInt(e,10);this.set(j,i);},onInputBlur:function(){this.update();},bindUI:function(){d.on("mousedown",this.onSquareMouseDown,this.squareCanvas,this);if(this.get("showHSLBars")){d.on("mousedown",this.onBarMouseDown,this.hCanvas,this,{component:"h"});d.on("mousedown",this.onBarMouseDown,this.sCanvas,this,{component:"s"});d.on("mousedown",this.onBarMouseDown,this.lCanvas,this,{component:"l"});}d.delegate("keyup",this.onInputKeyUp,this.contentBox,"."+a.CLASSNAME_VALUE,this);d.delegate("blur",this.onInputBlur,this.contentBox,"."+a.CLASSNAME_VALUE,this);d.delegate("keydown",this.onInputKeyDown,this.contentBox,"."+a.CLASSNAME_VALUE,this);},syncUI:function(){var f=this.get("squareWidth"),e=this.get("squareHeight");this.squareX=this.color.h*(f/1);this.squareY=this.color.l*(e/1);this.update();}});d.ColorPicker=a;function b(){b.superclass.constructor.apply(this,arguments);this.publish("palette:selected");}b.NAME="colorPalette";b.CLASSNAME_SWATCH="cp-swatch";b.ATTRS={};d.extend(b,d.Widget,{colors:[],colorExists:function(e){var f,g;for(f=0;f'),g=c.hslToRGB(h.h,h.s,h.l),e=this.get("contentBox");i.setStyle("background","rgb("+g.r+", "+g.g+", "+g.b+")");i.setData("hsl",h);e.appendChild(i);this.colors.push(h);},renderUI:function(){},bindUI:function(){d.delegate("click",this.onSwatchClick,this.get("contentBox"),"."+b.CLASSNAME_SWATCH,this);},onSwatchClick:function(h){var g=h.target,e=g.getData("hsl"),f=c.hslToRGB(e.h,e.s,e.l);this.fire("palette:selected",{hsl:e,rgb:f});},syncUI:function(){}});d.ColorPalette=b;},"gallery-2011.09.28-20-06",{requires:["node","event","widget","classnamemanager"]}); \ No newline at end of file diff --git a/build/gallery-colorpicker/gallery-colorpicker.js b/build/gallery-colorpicker/gallery-colorpicker.js index 73af5c2f6f..34568c5a71 100644 --- a/build/gallery-colorpicker/gallery-colorpicker.js +++ b/build/gallery-colorpicker/gallery-colorpicker.js @@ -553,9 +553,11 @@ Y.extend(ColorPicker, Y.Widget, { this.trackBar = args.component; this.trackBarCanvas = ev.target; var offXY = ev.target.getXY(), + scrollX = ev.target.get('docScrollX'), + scrollY = ev.target.get('docScrollY'), // get position within the square - x = ev.clientX - offXY[0], - y = ev.clientY - offXY[1]; + x = ev.clientX + scrollX - offXY[0], + y = ev.clientY + scrollY - offXY[1]; this.barX = x; this.barY = y; @@ -573,13 +575,19 @@ Y.extend(ColorPicker, Y.Widget, { x, y, width, - height; + height, + scrollX, + scrollY, + c; if (this.trackSquare) { - offXY = Y.Node.one(this.squareCanvas).getXY(); + c = Y.Node.one(this.squareCanvas); + offXY = c.getXY(); + scrollX = c.get('docScrollX'); + scrollY = c.get('docScrollY'); // get position within the square - x = ev.clientX - offXY[0]; - y = ev.clientY - offXY[1]; + x = ev.clientX + scrollX - offXY[0]; + y = ev.clientY + scrollY - offXY[1]; width = this.get('squareWidth'); height = this.get('squareHeight'); @@ -592,9 +600,11 @@ Y.extend(ColorPicker, Y.Widget, { } if (this.trackBar) { offXY = this.trackBarCanvas.getXY(); + scrollX = this.trackBarCanvas.get('docScrollX'); + scrollY = this.trackBarCanvas.get('docScrollY'); // get position within the square - x = -this.barPaddingX + ev.clientX - offXY[0]; - y = -this.barPaddingY + ev.clientY - offXY[1]; + x = -this.barPaddingX + ev.clientX + scrollX - offXY[0]; + y = -this.barPaddingY + ev.clientY + scrollY - offXY[1]; width = this.get('barWidth'); height = this.get('barHeight'); @@ -611,9 +621,11 @@ Y.extend(ColorPicker, Y.Widget, { // mousedown inside square, start tracking position this.trackSquare = true; var offXY = ev.target.getXY(), + scrollX = ev.target.get('docScrollX'), + scrollY = ev.target.get('docScrollY'), // get position within the square - x = ev.clientX - offXY[0], - y = ev.clientY - offXY[1]; + x = ev.clientX + scrollX - offXY[0], + y = ev.clientY + scrollY - offXY[1]; this.squareX = x; this.squareY = y; @@ -621,6 +633,9 @@ Y.extend(ColorPicker, Y.Widget, { ev.halt(); }, updateColor: function () { + if (!this.get('showHSLBars')) { + return; + } var barWidth = this.get('barWidth'), barHeight = this.get('barHeight'), cacheBars = this.get('cacheBars'), @@ -757,11 +772,13 @@ Y.extend(ColorPicker, Y.Widget, { } } this.renderSquare(); - this.updateColor(); this.updateValues(); - this.drawThumb(this.hCanvas, 'h', {h: this.color.h, s: 1.0, l: 0.5}, barWidth, barHeight, 1.0, false); - this.drawThumb(this.sCanvas, 's', {h: this.color.h, s: 1.0, l: this.color.l}, barWidth, barHeight, 1.0, true); - this.drawThumb(this.lCanvas, 'l', {h: this.color.h, s: this.color.s, l: 0.5}, barWidth, barHeight, 1.0, true); + if (this.get('showHSLBars')) { + this.updateColor(); + this.drawThumb(this.hCanvas, 'h', {h: this.color.h, s: 1.0, l: 0.5}, barWidth, barHeight, 1.0, false); + this.drawThumb(this.sCanvas, 's', {h: this.color.h, s: 1.0, l: this.color.l}, barWidth, barHeight, 1.0, true); + this.drawThumb(this.lCanvas, 'l', {h: this.color.h, s: this.color.s, l: 0.5}, barWidth, barHeight, 1.0, true); + } }, renderSquare: function () { var width = this.get('squareWidth'), height = this.get('squareHeight'), @@ -864,9 +881,11 @@ Y.extend(ColorPicker, Y.Widget, { }, bindUI: function () { Y.on('mousedown', this.onSquareMouseDown, this.squareCanvas, this); - Y.on('mousedown', this.onBarMouseDown, this.hCanvas, this, {component: 'h'}); - Y.on('mousedown', this.onBarMouseDown, this.sCanvas, this, {component: 's'}); - Y.on('mousedown', this.onBarMouseDown, this.lCanvas, this, {component: 'l'}); + if (this.get('showHSLBars')) { + Y.on('mousedown', this.onBarMouseDown, this.hCanvas, this, {component: 'h'}); + Y.on('mousedown', this.onBarMouseDown, this.sCanvas, this, {component: 's'}); + Y.on('mousedown', this.onBarMouseDown, this.lCanvas, this, {component: 'l'}); + } Y.delegate('keyup', this.onInputKeyUp, this.contentBox, '.' + ColorPicker.CLASSNAME_VALUE, this); Y.delegate('blur', this.onInputBlur, this.contentBox, '.' + ColorPicker.CLASSNAME_VALUE, this); Y.delegate('keydown', this.onInputKeyDown, this.contentBox, '.' + ColorPicker.CLASSNAME_VALUE, this); @@ -976,4 +995,4 @@ Y.extend(ColorPalette, Y.Widget, { Y.ColorPalette = ColorPalette; -}, 'gallery-2011.09.14-20-40' ,{requires:['node', 'event', 'widget', 'classnamemanager']}); +}, 'gallery-2011.09.28-20-06' ,{requires:['node', 'event', 'widget', 'classnamemanager']}); diff --git a/build/gallery-form/gallery-form-debug.js b/build/gallery-form/gallery-form-debug.js index 3a3a0d66fe..bf33d70fcd 100644 --- a/build/gallery-form/gallery-form-debug.js +++ b/build/gallery-form/gallery-form-debug.js @@ -249,17 +249,18 @@ Y.Form = Y.Base.create('form', Y.Widget, [Y.WidgetParent], { formMethod = this.get('method'), submitViaIO = this.get('submitViaIO'), io = this.get("io"), + ioConfig = this.get('ioConfig') || {}, transaction, cfg; if (submitViaIO === true) { - cfg = { + cfg = Y.merge({ method: formMethod, form: { id: this.get('contentBox'), upload: (this.get('encodingType') === Y.Form.MULTIPART_ENCODED) } - }; + }, ioConfig); transaction = io(formAction, cfg); this._ioIds[transaction.id] = transaction; @@ -482,6 +483,9 @@ Y.Form = Y.Base.create('form', Y.Widget, [Y.WidgetParent], { */ io: { value: Y.io + }, + + ioConfig : { } }, @@ -1380,6 +1384,11 @@ Y.CheckboxField = Y.Base.create('checkbox-field', Y.FormField, [Y.WidgetChild], Y.CheckboxField.superclass.initializer.apply(this, arguments); }, + renderUI : function () { + this._renderFieldNode(); + this._renderLabelNode(); + }, + syncUI : function () { Y.CheckboxField.superclass.syncUI.apply(this, arguments); this._syncChecked(); @@ -1536,10 +1545,6 @@ Y.ChoiceField = Y.Base.create('choice-field', Y.FormField, [Y.WidgetParent, Y.Wi } } - if (val.length === 0) { - return false; - } - return true; }, @@ -1629,6 +1634,9 @@ Y.ChoiceField = Y.Base.create('choice-field', Y.FormField, [Y.WidgetParent, Y.Wi * @description The choices to render into this field */ choices: { + valueFn : function () { + return []; + }, validator: function(val) { return this._validateChoices(val); } @@ -1717,7 +1725,7 @@ Y.SelectField = Y.Base.create('select-field', Y.ChoiceField, [Y.WidgetParent, Y. * @description Syncs the option nodes with the choices attribute */ _syncOptionNodes: function() { - var choices = this.get('choices'), + var choices = this.get('choices') || [], contentBox = this.get('contentBox'), options = contentBox.all('option'), useDefaultOption = this.get('useDefaultOption'), @@ -1748,7 +1756,7 @@ Y.SelectField = Y.Base.create('select-field', Y.ChoiceField, [Y.WidgetParent, Y. }, this); - if (!currentVal && !useDefaultOption) { + if (!currentVal && !useDefaultOption && choices[0]) { this.set('value', choices[0].value); } }, @@ -1958,4 +1966,4 @@ Y.ResetButton = Y.Base.create('reset-button', Y.FormField, [Y.WidgetChild], { }); -}, 'gallery-2011.09.07-20-35' ,{requires:['node', 'widget-base', 'widget-htmlparser', 'io-form', 'widget-parent', 'widget-child', 'base-build', 'substitute', 'io-upload-iframe']}); +}, 'gallery-2011.09.28-20-06' ,{requires:['node', 'widget-base', 'widget-htmlparser', 'io-form', 'widget-parent', 'widget-child', 'base-build', 'substitute', 'io-upload-iframe']}); diff --git a/build/gallery-form/gallery-form-min.js b/build/gallery-form/gallery-form-min.js index ec531cdb72..db744f5035 100644 --- a/build/gallery-form/gallery-form-min.js +++ b/build/gallery-form/gallery-form-min.js @@ -1,4 +1,4 @@ -YUI.add("gallery-form",function(a){a.Form=a.Base.create("form",a.Widget,[a.WidgetParent],{toString:function(){return this.name;},CONTENT_TEMPLATE:"
",_ioIds:null,_validateMethod:function(b){if(!a.Lang.isString(b)){return false;}if(b.toLowerCase()!="get"&&b.toLowerCase()!="post"){return false;}return true;},_parseAction:function(b){var c=b.one("form");if(!c){c=b;}if(c){return c.get("action");}},_parseMethod:function(b){var c=b.one("form");if(!c){c=b;}if(c){return c.get("method");}},_parseFields:function(c){var e=c.all("*"),f=c.all("label"),b=[],d={text:a.TextField,hidden:a.HiddenField,file:a.FileField,checkbox:a.CheckboxField,radio:a.RadioField,reset:a.ResetButton,submit:a.SubmitButton,button:(a.Button||a.FormButton)};e.each(function(j,h,g){var n=j.get("nodeName"),l=j.get("id"),i,k,m=[];if(n=="INPUT"){i=j.get("type");k={type:(d[i]?d[i]:a.TextField),name:j.get("name"),value:j.get("value"),checked:j.get("checked")};if(k.type==d.button){k.label=j.get("value");}}else{if(n=="BUTTON"){k={type:d.button,name:j.get("name"),label:j.get("innerHTML")};}else{if(n=="SELECT"){j.all("option").each(function(p,q,o){m.push({label:p.get("innerHTML"),value:p.get("value")});});k={type:a.SelectField,name:j.get("name"),choices:m};}else{if(n=="TEXTAREA"){k={type:a.TextareaField,name:j.get("name"),value:j.get("innerHTML")};}}}}if(k){if(l){k.id=l;f.some(function(p,q,o){if(p.get("htmlFor")==l){k.label=p.get("innerHTML");}});}b.push(k);}j.remove();});return b;},_syncFormAttributes:function(){var b=this.get("contentBox");b.setAttrs({action:this.get("action"),method:this.get("method")});if(this.get("encodingType")===a.Form.MULTIPART_ENCODED){b.setAttribute("enctype","multipart/form-data");}},_runValidation:function(){var b=true;this.each(function(c){if(c.validateField()===false){b=false;}});return b;},_enableInlineValidation:function(){this.each(function(b){b.set("validateInline",true);});},_disableInlineValidation:function(){this.each(function(b){b.set("validateInline",false);});},_handleIOEvent:function(d,b,c){if(this._ioIds[b]!==undefined){this.fire(d,{response:c});}},reset:function(){var b=a.Node.getDOMNode(this.get("contentBox"));if(a.Lang.isFunction(b.reset)){b.reset();}this.each(function(c){c.resetFieldNode();c.set("error",null);});},submit:function(){if(this.get("skipValidationBeforeSubmit")===true||this._runValidation()){var c=this.get("action"),e=this.get("method"),d=this.get("submitViaIO"),g=this.get("io"),f,b;if(d===true){b={method:e,form:{id:this.get("contentBox"),upload:(this.get("encodingType")===a.Form.MULTIPART_ENCODED)}};f=g(c,b);this._ioIds[f.id]=f;}else{this.get("contentBox").submit();}}},getField:function(b){var c;if(a.Lang.isNumber(b)){c=this.item(b);}else{if(a.Lang.isString(b)){this.each(function(d){if(d.get("name")==b){c=d;}});}}return c;},toJSON:function(){var b={};this.each(function(c){b[c.get("name")]=(c instanceof a.CheckboxField)?c.get("checked"):c.get("value");});return b;},initializer:function(b){this._ioIds={};this.publish("submit");this.publish("reset");this.publish("start");this.publish("success");this.publish("failure");this.publish("complete");this.publish("xdr");},destructor:function(){},renderUI:function(){},bindUI:function(){this.get("contentBox").on("submit",a.bind(function(b){b.halt();},this));this.after("inlineValidationChange",a.bind(function(b){if(b.newVal===true){this._enableInlineValidation();}else{this._disableInlineValidation();}},this));this.after("success",a.bind(function(b){if(this.get("resetAfterSubmit")===true){this.reset();}},this));a.on("io:start",a.bind(this._handleIOEvent,this,"start"));a.on("io:complete",a.bind(this._handleIOEvent,this,"complete"));a.on("io:xdr",a.bind(this._handleIOEvent,this,"xdr"));a.on("io:success",a.bind(this._handleIOEvent,this,"success"));a.on("io:failure",a.bind(this._handleIOEvent,this,"failure"));this.each(a.bind(function(b){if(b.name=="submit-button"){b.on("click",a.bind(this.submit,this));}else{if(b.name=="reset-button"){b.on("click",a.bind(this.reset,this));}}},this));},syncUI:function(){this._syncFormAttributes();if(this.get("inlineValidation")===true){this._enableInlineValidation();}}},{ATTRS:{defaultChildType:{valueFn:function(){return a.TextField;}},method:{value:"post",validator:function(b){return this._validateMethod(b);},setter:function(b){return b.toLowerCase();}},action:{value:".",validator:a.Lang.isString},fields:{setter:function(b){return this.set("children",b);}},inlineValidation:{value:false,validator:a.Lang.isBoolean},resetAfterSubmit:{value:true,validator:a.Lang.isBoolean},encodingType:{value:1,validator:a.Lang.isNumber},skipValidationBeforeSubmit:{value:false,validator:a.Lang.isBoolean},submitViaIO:{value:true,validator:a.Lang.isBoolean},io:{value:a.io}},HTML_PARSER:{action:function(b){return this._parseAction(b);},method:function(b){return this._parseMethod(b);},children:function(b){return this._parseFields(b);}},FORM_TEMPLATE:"
",URL_ENCODED:1,MULTIPART_ENCODED:2});a.FormField=a.Base.create("form-field",a.Widget,[a.WidgetParent,a.WidgetChild],{toString:function(){return this.name;},FIELD_TEMPLATE:"",FIELD_CLASS:"field",LABEL_TEMPLATE:"",LABEL_CLASS:"label",HINT_TEMPLATE:"",HINT_CLASS:"hint",ERROR_TEMPLATE:"",ERROR_CLASS:"error",_labelNode:null,_hintNode:null,_fieldNode:null,_errorNode:null,_initialValue:null,_validateError:function(b){if(a.Lang.isString(b)){return true;}if(b===null||typeof b=="undefined"){return true;}return false;},_validateValidator:function(c){if(a.Lang.isString(c)){var b=/^(email|phone|ip|date|time|postal|special)$/;if(b.test(c)===true){return true;}}if(a.Lang.isFunction(c)){return true;}return false;},_setValidator:function(c){var b={email:a.FormField.VALIDATE_EMAIL_ADDRESS,phone:a.FormField.VALIDATE_PHONE_NUMBER,ip:a.FormField.VALIDATE_IP_ADDRESS,date:a.FormField.VALIDATE_DATE,time:a.FormField.VALIDATE_TIME,postal:a.FormField.VALIDATE_POSTAL_CODE,special:a.FormField.VALIDATE_NO_SPECIAL_CHARS};return(b[c]?b[c]:c);},_renderNode:function(e,d,c){if(!e){return null; -}var b=this.get("contentBox"),g=a.Node.create(e),f=b.one("."+d);g.addClass(d);if(f){f.replace(g);}else{if(c){b.insertBefore(g,c);}else{b.appendChild(g);}}return g;},_renderLabelNode:function(){var b=this.get("contentBox"),c=b.one("label");if(!c||c.get("for")!=this.get("id")){c=this._renderNode(this.LABEL_TEMPLATE,this.LABEL_CLASS);}this._labelNode=c;},_renderHintNode:function(){this._hintNode=this._renderNode(this.HINT_TEMPLATE,this.HINT_CLASS);},_renderFieldNode:function(){var b=this.get("contentBox"),c=b.one("#"+this.get("id"));if(!c){c=this._renderNode(this.FIELD_TEMPLATE,this.FIELD_CLASS);}this._fieldNode=c;},_syncLabelNode:function(){var b=this.get("label"),d=this.get("required"),c=this.get("requiredLabel");if(this._labelNode){this._labelNode.set("text","");if(b){this._labelNode.append(""+b+"");}if(d&&c){this._labelNode.append(" ");this._labelNode.append(""+c+"");}this._labelNode.setAttribute("for",this.get("id")+a.FormField.FIELD_ID_SUFFIX);}},_syncHintNode:function(){if(this._hintNode){this._hintNode.set("text",this.get("hint"));}},_syncFieldNode:function(){var b=this.name.split("-")[0];if(!b){return;}this._fieldNode.setAttrs({name:this.get("name"),type:b,id:this.get("id")+a.FormField.FIELD_ID_SUFFIX,value:this.get("value")});this._fieldNode.setAttribute("tabindex",a.FormField.tabIndex);a.FormField.tabIndex++;},_syncError:function(){var b=this.get("error");if(b){this._showError(b);}},_syncDisabled:function(c){var b=this.get("disabled");if(b===true){this._fieldNode.setAttribute("disabled","disabled");}else{this._fieldNode.removeAttribute("disabled");}},_checkRequired:function(){if(this.get("required")===true&&this.get("value").length===0){return false;}return true;},_showError:function(b){var c=this._renderNode(this.ERROR_TEMPLATE,this.ERROR_CLASS,this._labelNode);c.set("text",b);this._errorNode=c;},_clearError:function(){if(this._errorNode){this._errorNode.remove();this._errorNode=null;}},_enableInlineValidation:function(){this.after("valueChange",this.validateField,this);},_disableInlineValidation:function(){this.detach("valueChange",this.validateField,this);},validateField:function(d){var c=this.get("value"),b=this.get("validator");this.set("error",null);if(d&&d.src!="ui"){return false;}if(!this._checkRequired()){this.set("error",a.FormField.REQUIRED_ERROR_TEXT);return false;}else{if(!c){return true;}}return b.call(this,c,this);},resetFieldNode:function(){this.set("value",this._initialValue);this._fieldNode.set("value",this._initialValue);this.fire("nodeReset");},clear:function(){this.set("value","");this._fieldNode.set("value","");this._initialValue=null;this.fire("clear");},initializer:function(){this.publish("blur");this.publish("change");this.publish("focus");this.publish("clear");this.publish("nodeReset");this._initialValue=this.get("value");},destructor:function(b){},renderUI:function(){this._renderLabelNode();this._renderFieldNode();this._renderHintNode();},bindUI:function(){this._fieldNode.on("change",a.bind(function(b){this.set("value",this._fieldNode.get("value"),{src:"ui"});},this));this.on("valueChange",a.bind(function(b){if(b.src!="ui"){this._fieldNode.set("value",b.newVal);}},this));this._fieldNode.on("blur",a.bind(function(b){this.set("value",this._fieldNode.get("value"),{src:"ui"});},this));this._fieldNode.on("focus",a.bind(function(b){this.fire("focus",b);},this));this.on("errorChange",a.bind(function(b){if(b.newVal){this._showError(b.newVal);}else{this._clearError();}},this));this.on("validateInlineChange",a.bind(function(b){if(b.newVal===true){this._enableInlineValidation();}else{this._disableInlineValidation();}},this));this.after("disabledChange",a.bind(function(b){this._syncDisabled();},this));},syncUI:function(){this.get("boundingBox").removeAttribute("tabindex");this._syncLabelNode();this._syncHintNode();this._syncFieldNode();this._syncError();this._syncDisabled();if(this.get("validateInline")===true){this._enableInlineValidation();}}},{ATTRS:{id:{value:a.guid(),validator:a.Lang.isString,writeOnce:true},name:{validator:a.Lang.isString,writeOnce:true},value:{value:"",validator:a.Lang.isString},label:{value:"",validator:a.Lang.isString},hint:{value:"",validator:a.Lang.isString},validator:{value:function(b){return true;},validator:function(b){return this._validateValidator(b);},setter:function(b){return this._setValidator(b);}},error:{value:false,validator:function(b){return this._validateError(b);}},required:{value:false,validator:a.Lang.isBoolean},validateInline:{value:false,validator:a.Lang.isBoolean},requiredLabel:{value:"",validator:a.Lang.isString}},tabIndex:1,VALIDATE_EMAIL_ADDRESS:function(d,c){var b=/^([\w]+(?:\.[\w]+)*)@((?:[\w]+\.)*\w[\w]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;if(b.test(d)===false){c.set("error",a.FormField.INVALID_EMAIL_MESSAGE);return false;}return true;},INVALID_EMAIL_MESSAGE:"Please enter a valid email address",VALIDATE_PHONE_NUMBER:function(d,c){var b=/^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;if(b.test(d)===false){c.set("error",a.FormField.INVALID_PHONE_NUMBER);return false;}return true;},INVALID_PHONE_NUMBER:"Please enter a valid phone number",VALIDATE_IP_ADDRESS:function(f,e){var c=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,b,d=true;if(c.test(f)===false){d=false;}b=f.split(".");a.Array.each(b,function(h,j,g){var k=parseInt(h,10);if(k<0||k>255){d=false;}});if(d===false){e.set("error",a.FormField.INVALID_IP_MESSAGE);}return d;},INVALID_IP_MESSAGE:"Please enter a valid IP address",VALIDATE_DATE:function(d,c){var b=/^([1-9]|1[0-2])(\-|\/)([0-2][0-9]|3[0-1])(\-|\/)(\d{4}|\d{2})$/;if(b.test(d)===false){c.set("error",a.FormField.INVALID_DATE_MESSAGE);return false;}return true;},INVALID_DATE_MESSAGE:"Please enter a a valid date",VALIDATE_TIME:function(d,c){var b=/^([1-9]|1[0-2]):[0-5]\d(:[0-5]\d(\.\d{1,3})?)?$/;if(b.test(d)===false){c.set("error",a.FormField.INVALID_TIME_MESSAGE); -return false;}return true;},INVALID_TIME_MESSAGE:"Please enter a valid time",VALIDATE_POSTAL_CODE:function(e,d){var b,c=true;if(e.length==6||e.length==7){b=/^[a-zA-Z]\d[a-zA-Z](-|\s)?\d[a-zA-Z]\d$/;}else{if(e.length==5||e.length==10){b=/^\d{5}((-|\s)\d{4})?$/;}else{if(e.length>0){c=false;}}}if(c===false||(b&&b.test(e)===false)){d.set("error",a.FormField.INVALID_POSTAL_CODE_MESSAGE);return false;}return true;},INVALID_POSTAL_CODE_MESSAGE:"Please enter a valid postal code",VALIDATE_NO_SPECIAL_CHARS:function(d,c){var b=/^[a-zA-Z0-9]*$/;if(b.test(d)===false){c.set("error",a.FormField.INVALID_SPECIAL_CHARS);return false;}return true;},INVALID_SPECIAL_CHARS:"Please use only letters and numbers",REQUIRED_ERROR_TEXT:"This field is required",FIELD_ID_SUFFIX:"-field"});a.TextField=a.Base.create("text-field",a.FormField,[a.WidgetChild]);a.PasswordField=a.Base.create("password-field",a.FormField,[a.WidgetChild]);a.CheckboxField=a.Base.create("checkbox-field",a.FormField,[a.WidgetChild],{_syncChecked:function(){this._fieldNode.set("checked",this.get("checked"));},initializer:function(){a.CheckboxField.superclass.initializer.apply(this,arguments);},syncUI:function(){a.CheckboxField.superclass.syncUI.apply(this,arguments);this._syncChecked();},bindUI:function(){a.CheckboxField.superclass.bindUI.apply(this,arguments);this.after("checkedChange",a.bind(function(b){if(b.src!="ui"){this._fieldNode.set("checked",b.newVal);}},this));this._fieldNode.after("change",a.bind(function(b){this.set("checked",b.currentTarget.get("checked"),{src:"ui"});},this));}},{ATTRS:{"checked":{value:false,validator:a.Lang.isBoolean}}});a.RadioField=a.Base.create("radio-field",a.FormField,[a.WidgetChild]);a.HiddenField=a.Base.create("hidden-field",a.FormField,[a.WidgetChild],{_valueDisplayNode:null,_renderValueDisplayNode:function(){if(this.get("displayValue")===true){var c=a.Node.create("
"),b=this.get("contentBox");b.appendChild(c);this._valueDisplayNode=c;}},renderUI:function(){a.HiddenField.superclass.renderUI.apply(this,arguments);this._renderValueDisplayNode();},bindUI:function(){a.HiddenField.superclass.bindUI.apply(this,arguments);if(this.get("displayValue")===true){this.after("valueChange",a.bind(function(b,c){this._valueDisplayNode.set("innerHTML",c.newVal);},this,true));}},clear:function(){}},{ATTRS:{displayValue:{value:false,writeOnce:true,validator:a.Lang.isBoolean}}});a.TextareaField=a.Base.create("textarea-field",a.FormField,[a.WidgetChild],{FIELD_TEMPLATE:""});a.ChoiceField=a.Base.create("choice-field",a.FormField,[a.WidgetParent,a.WidgetChild],{LABEL_TEMPLATE:"",SINGLE_CHOICE:a.RadioField,MULTI_CHOICE:a.CheckboxField,_validateChoices:function(d){if(!a.Lang.isArray(d)){return false;}var c=0,b=d.length;for(;c0){a.Array.each(b,function(c){this._fieldNode.each(function(e,d,f){if(a.Lang.trim(e.get("value"))==a.Lang.trim(c)){e.set("checked",true);return true;}},this);},this);}},_afterChoicesChange:function(c){var b=this.get("contentBox");b.all(".yui3-form-field").remove();this._renderFieldNode();},clear:function(){this._fieldNode.each(function(c,b,d){c.set("checked",false);},this);this.set("value","");},bindUI:function(){this._fieldNode.on("change",a.bind(function(c){var b="";this._fieldNode.each(function(e,d,f){if(e.get("checked")===true){if(b.length>0){b+=",";}b+=e.get("value");}},this);this.set("value",b);},this));this.after("choicesChange",this._afterChoicesChange);}},{ATTRS:{choices:{validator:function(b){return this._validateChoices(b);}},multi:{validator:a.Lang.isBoolean,value:false}}});a.SelectField=a.Base.create("select-field",a.ChoiceField,[a.WidgetParent,a.WidgetChild],{FIELD_TEMPLATE:"",DEFAULT_OPTION_TEXT:"Choose one",_renderFieldNode:function(){a.SelectField.superclass.constructor.superclass._renderFieldNode.apply(this,arguments);this._renderOptionNodes();},_renderOptionNodes:function(){var c=this.get("choices"),b;if(this.get("useDefaultOption")===true){b=a.Node.create(a.SelectField.OPTION_TEMPLATE);this._fieldNode.appendChild(b);}a.Array.each(c,function(f,e,d){b=a.Node.create(a.SelectField.OPTION_TEMPLATE);this._fieldNode.appendChild(b);},this);},_syncFieldNode:function(){a.SelectField.superclass.constructor.superclass._syncFieldNode.apply(this,arguments);this._fieldNode.setAttrs({size:this.get("size"),multiple:(this.get("multi")===true?"multiple":"")});},_syncOptionNodes:function(){var f=this.get("choices"),b=this.get("contentBox"),d=b.all("option"),e=this.get("useDefaultOption"),c=this.get("value");if(e===true){f.unshift({label:this.DEFAULT_OPTION_TEXT,value:""});}d.each(function(j,i,h){var g=f[i].label,k=f[i].value;j.setAttrs({innerHTML:g,value:k});if(c==k){j.setAttrs({selected:true,defaultSelected:true});}},this);if(!c&&!e){this.set("value",f[0].value);}},_afterChoicesChange:function(b){var c=this._fieldNode.all("option");c.remove();this._renderOptionNodes();this._syncOptionNodes();},clear:function(){this._fieldNode.value="";},bindUI:function(){a.SelectField.superclass.constructor.superclass.bindUI.apply(this,arguments);this.after("choicesChange",this._afterChoicesChange);},syncUI:function(){a.SelectField.superclass.syncUI.apply(this,arguments);this._syncOptionNodes();}},{OPTION_TEMPLATE:"",ATTRS:{useDefaultOption:{validator:a.Lang.isBoolean,value:true},choices:{validator:function(b){if(this.get("useDefaultOption")&&a.Lang.isArray(b)&&b.length===0){return true; -}else{return this._validateChoices(b);}}},size:{validator:a.Lang.isString,value:"0"}}});a.FormButton=a.Base.create("button-field",a.FormField,[a.WidgetChild],{FIELD_TEMPLATE:"",LABEL_TEMPLATE:"",_syncFieldNode:function(){this._fieldNode.setAttrs({innerHTML:this.get("label"),id:this.get("id")+a.FormField.FIELD_ID_SUFFIX});this.get("contentBox").addClass("first-child");},_setClickHandler:function(){if(!this._fieldNode){return;}a.Event.purgeElement(this._fieldNode,true,"click");a.on("click",a.bind(this._promptConfirm,this),this._fieldNode);},_promptConfirm:function(d){d.preventDefault();var c=this.get("message"),b=this.get("onclick");if(c){if(!this.get("confirm")(c)){return;}}b.fn.apply(b.scope);},bindUI:function(){this.after("onclickChange",a.bind(this._setClickHandler,this,true));this.after("disabledChange",this._syncDisabled,this);this._setClickHandler();}},{ATTRS:{onclick:{validator:function(b){if(a.Lang.isObject(b)===false){return false;}if(typeof b.fn=="undefined"||a.Lang.isFunction(b.fn)===false){return false;}return true;},value:{fn:function(b){}},setter:function(b){b.scope=b.scope||this;b.argument=b.argument||{};return b;}},message:{validator:a.Lang.isString,value:null},confirm:{validator:a.Lang.isFunction,value:null}}});a.FileField=a.Base.create("file-field",a.FormField,[a.WidgetChild]);a.SubmitButton=a.Base.create("submit-button",a.FormField,[a.WidgetChild],{_renderLabelNode:function(){}});a.ResetButton=a.Base.create("reset-button",a.FormField,[a.WidgetChild],{LABEL_TEMPLATE:""});},"gallery-2011.09.07-20-35",{requires:["node","widget-base","widget-htmlparser","io-form","widget-parent","widget-child","base-build","substitute","io-upload-iframe"]}); \ No newline at end of file +YUI.add("gallery-form",function(a){a.Form=a.Base.create("form",a.Widget,[a.WidgetParent],{toString:function(){return this.name;},CONTENT_TEMPLATE:"
",_ioIds:null,_validateMethod:function(b){if(!a.Lang.isString(b)){return false;}if(b.toLowerCase()!="get"&&b.toLowerCase()!="post"){return false;}return true;},_parseAction:function(b){var c=b.one("form");if(!c){c=b;}if(c){return c.get("action");}},_parseMethod:function(b){var c=b.one("form");if(!c){c=b;}if(c){return c.get("method");}},_parseFields:function(c){var e=c.all("*"),f=c.all("label"),b=[],d={text:a.TextField,hidden:a.HiddenField,file:a.FileField,checkbox:a.CheckboxField,radio:a.RadioField,reset:a.ResetButton,submit:a.SubmitButton,button:(a.Button||a.FormButton)};e.each(function(j,h,g){var n=j.get("nodeName"),l=j.get("id"),i,k,m=[];if(n=="INPUT"){i=j.get("type");k={type:(d[i]?d[i]:a.TextField),name:j.get("name"),value:j.get("value"),checked:j.get("checked")};if(k.type==d.button){k.label=j.get("value");}}else{if(n=="BUTTON"){k={type:d.button,name:j.get("name"),label:j.get("innerHTML")};}else{if(n=="SELECT"){j.all("option").each(function(p,q,o){m.push({label:p.get("innerHTML"),value:p.get("value")});});k={type:a.SelectField,name:j.get("name"),choices:m};}else{if(n=="TEXTAREA"){k={type:a.TextareaField,name:j.get("name"),value:j.get("innerHTML")};}}}}if(k){if(l){k.id=l;f.some(function(p,q,o){if(p.get("htmlFor")==l){k.label=p.get("innerHTML");}});}b.push(k);}j.remove();});return b;},_syncFormAttributes:function(){var b=this.get("contentBox");b.setAttrs({action:this.get("action"),method:this.get("method")});if(this.get("encodingType")===a.Form.MULTIPART_ENCODED){b.setAttribute("enctype","multipart/form-data");}},_runValidation:function(){var b=true;this.each(function(c){if(c.validateField()===false){b=false;}});return b;},_enableInlineValidation:function(){this.each(function(b){b.set("validateInline",true);});},_disableInlineValidation:function(){this.each(function(b){b.set("validateInline",false);});},_handleIOEvent:function(d,b,c){if(this._ioIds[b]!==undefined){this.fire(d,{response:c});}},reset:function(){var b=a.Node.getDOMNode(this.get("contentBox"));if(a.Lang.isFunction(b.reset)){b.reset();}this.each(function(c){c.resetFieldNode();c.set("error",null);});},submit:function(){if(this.get("skipValidationBeforeSubmit")===true||this._runValidation()){var d=this.get("action"),f=this.get("method"),e=this.get("submitViaIO"),h=this.get("io"),c=this.get("ioConfig")||{},g,b;if(e===true){b=a.merge({method:f,form:{id:this.get("contentBox"),upload:(this.get("encodingType")===a.Form.MULTIPART_ENCODED)}},c);g=h(d,b);this._ioIds[g.id]=g;}else{this.get("contentBox").submit();}}},getField:function(b){var c;if(a.Lang.isNumber(b)){c=this.item(b);}else{if(a.Lang.isString(b)){this.each(function(d){if(d.get("name")==b){c=d;}});}}return c;},toJSON:function(){var b={};this.each(function(c){b[c.get("name")]=(c instanceof a.CheckboxField)?c.get("checked"):c.get("value");});return b;},initializer:function(b){this._ioIds={};this.publish("submit");this.publish("reset");this.publish("start");this.publish("success");this.publish("failure");this.publish("complete");this.publish("xdr");},destructor:function(){},renderUI:function(){},bindUI:function(){this.get("contentBox").on("submit",a.bind(function(b){b.halt();},this));this.after("inlineValidationChange",a.bind(function(b){if(b.newVal===true){this._enableInlineValidation();}else{this._disableInlineValidation();}},this));this.after("success",a.bind(function(b){if(this.get("resetAfterSubmit")===true){this.reset();}},this));a.on("io:start",a.bind(this._handleIOEvent,this,"start"));a.on("io:complete",a.bind(this._handleIOEvent,this,"complete"));a.on("io:xdr",a.bind(this._handleIOEvent,this,"xdr"));a.on("io:success",a.bind(this._handleIOEvent,this,"success"));a.on("io:failure",a.bind(this._handleIOEvent,this,"failure"));this.each(a.bind(function(b){if(b.name=="submit-button"){b.on("click",a.bind(this.submit,this));}else{if(b.name=="reset-button"){b.on("click",a.bind(this.reset,this));}}},this));},syncUI:function(){this._syncFormAttributes();if(this.get("inlineValidation")===true){this._enableInlineValidation();}}},{ATTRS:{defaultChildType:{valueFn:function(){return a.TextField;}},method:{value:"post",validator:function(b){return this._validateMethod(b);},setter:function(b){return b.toLowerCase();}},action:{value:".",validator:a.Lang.isString},fields:{setter:function(b){return this.set("children",b);}},inlineValidation:{value:false,validator:a.Lang.isBoolean},resetAfterSubmit:{value:true,validator:a.Lang.isBoolean},encodingType:{value:1,validator:a.Lang.isNumber},skipValidationBeforeSubmit:{value:false,validator:a.Lang.isBoolean},submitViaIO:{value:true,validator:a.Lang.isBoolean},io:{value:a.io},ioConfig:{}},HTML_PARSER:{action:function(b){return this._parseAction(b);},method:function(b){return this._parseMethod(b);},children:function(b){return this._parseFields(b);}},FORM_TEMPLATE:"
",URL_ENCODED:1,MULTIPART_ENCODED:2});a.FormField=a.Base.create("form-field",a.Widget,[a.WidgetParent,a.WidgetChild],{toString:function(){return this.name;},FIELD_TEMPLATE:"",FIELD_CLASS:"field",LABEL_TEMPLATE:"",LABEL_CLASS:"label",HINT_TEMPLATE:"",HINT_CLASS:"hint",ERROR_TEMPLATE:"",ERROR_CLASS:"error",_labelNode:null,_hintNode:null,_fieldNode:null,_errorNode:null,_initialValue:null,_validateError:function(b){if(a.Lang.isString(b)){return true;}if(b===null||typeof b=="undefined"){return true;}return false;},_validateValidator:function(c){if(a.Lang.isString(c)){var b=/^(email|phone|ip|date|time|postal|special)$/;if(b.test(c)===true){return true;}}if(a.Lang.isFunction(c)){return true;}return false;},_setValidator:function(c){var b={email:a.FormField.VALIDATE_EMAIL_ADDRESS,phone:a.FormField.VALIDATE_PHONE_NUMBER,ip:a.FormField.VALIDATE_IP_ADDRESS,date:a.FormField.VALIDATE_DATE,time:a.FormField.VALIDATE_TIME,postal:a.FormField.VALIDATE_POSTAL_CODE,special:a.FormField.VALIDATE_NO_SPECIAL_CHARS}; +return(b[c]?b[c]:c);},_renderNode:function(e,d,c){if(!e){return null;}var b=this.get("contentBox"),g=a.Node.create(e),f=b.one("."+d);g.addClass(d);if(f){f.replace(g);}else{if(c){b.insertBefore(g,c);}else{b.appendChild(g);}}return g;},_renderLabelNode:function(){var b=this.get("contentBox"),c=b.one("label");if(!c||c.get("for")!=this.get("id")){c=this._renderNode(this.LABEL_TEMPLATE,this.LABEL_CLASS);}this._labelNode=c;},_renderHintNode:function(){this._hintNode=this._renderNode(this.HINT_TEMPLATE,this.HINT_CLASS);},_renderFieldNode:function(){var b=this.get("contentBox"),c=b.one("#"+this.get("id"));if(!c){c=this._renderNode(this.FIELD_TEMPLATE,this.FIELD_CLASS);}this._fieldNode=c;},_syncLabelNode:function(){var b=this.get("label"),d=this.get("required"),c=this.get("requiredLabel");if(this._labelNode){this._labelNode.set("text","");if(b){this._labelNode.append(""+b+"");}if(d&&c){this._labelNode.append(" ");this._labelNode.append(""+c+"");}this._labelNode.setAttribute("for",this.get("id")+a.FormField.FIELD_ID_SUFFIX);}},_syncHintNode:function(){if(this._hintNode){this._hintNode.set("text",this.get("hint"));}},_syncFieldNode:function(){var b=this.name.split("-")[0];if(!b){return;}this._fieldNode.setAttrs({name:this.get("name"),type:b,id:this.get("id")+a.FormField.FIELD_ID_SUFFIX,value:this.get("value")});this._fieldNode.setAttribute("tabindex",a.FormField.tabIndex);a.FormField.tabIndex++;},_syncError:function(){var b=this.get("error");if(b){this._showError(b);}},_syncDisabled:function(c){var b=this.get("disabled");if(b===true){this._fieldNode.setAttribute("disabled","disabled");}else{this._fieldNode.removeAttribute("disabled");}},_checkRequired:function(){if(this.get("required")===true&&this.get("value").length===0){return false;}return true;},_showError:function(b){var c=this._renderNode(this.ERROR_TEMPLATE,this.ERROR_CLASS,this._labelNode);c.set("text",b);this._errorNode=c;},_clearError:function(){if(this._errorNode){this._errorNode.remove();this._errorNode=null;}},_enableInlineValidation:function(){this.after("valueChange",this.validateField,this);},_disableInlineValidation:function(){this.detach("valueChange",this.validateField,this);},validateField:function(d){var c=this.get("value"),b=this.get("validator");this.set("error",null);if(d&&d.src!="ui"){return false;}if(!this._checkRequired()){this.set("error",a.FormField.REQUIRED_ERROR_TEXT);return false;}else{if(!c){return true;}}return b.call(this,c,this);},resetFieldNode:function(){this.set("value",this._initialValue);this._fieldNode.set("value",this._initialValue);this.fire("nodeReset");},clear:function(){this.set("value","");this._fieldNode.set("value","");this._initialValue=null;this.fire("clear");},initializer:function(){this.publish("blur");this.publish("change");this.publish("focus");this.publish("clear");this.publish("nodeReset");this._initialValue=this.get("value");},destructor:function(b){},renderUI:function(){this._renderLabelNode();this._renderFieldNode();this._renderHintNode();},bindUI:function(){this._fieldNode.on("change",a.bind(function(b){this.set("value",this._fieldNode.get("value"),{src:"ui"});},this));this.on("valueChange",a.bind(function(b){if(b.src!="ui"){this._fieldNode.set("value",b.newVal);}},this));this._fieldNode.on("blur",a.bind(function(b){this.set("value",this._fieldNode.get("value"),{src:"ui"});},this));this._fieldNode.on("focus",a.bind(function(b){this.fire("focus",b);},this));this.on("errorChange",a.bind(function(b){if(b.newVal){this._showError(b.newVal);}else{this._clearError();}},this));this.on("validateInlineChange",a.bind(function(b){if(b.newVal===true){this._enableInlineValidation();}else{this._disableInlineValidation();}},this));this.after("disabledChange",a.bind(function(b){this._syncDisabled();},this));},syncUI:function(){this.get("boundingBox").removeAttribute("tabindex");this._syncLabelNode();this._syncHintNode();this._syncFieldNode();this._syncError();this._syncDisabled();if(this.get("validateInline")===true){this._enableInlineValidation();}}},{ATTRS:{id:{value:a.guid(),validator:a.Lang.isString,writeOnce:true},name:{validator:a.Lang.isString,writeOnce:true},value:{value:"",validator:a.Lang.isString},label:{value:"",validator:a.Lang.isString},hint:{value:"",validator:a.Lang.isString},validator:{value:function(b){return true;},validator:function(b){return this._validateValidator(b);},setter:function(b){return this._setValidator(b);}},error:{value:false,validator:function(b){return this._validateError(b);}},required:{value:false,validator:a.Lang.isBoolean},validateInline:{value:false,validator:a.Lang.isBoolean},requiredLabel:{value:"",validator:a.Lang.isString}},tabIndex:1,VALIDATE_EMAIL_ADDRESS:function(d,c){var b=/^([\w]+(?:\.[\w]+)*)@((?:[\w]+\.)*\w[\w]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;if(b.test(d)===false){c.set("error",a.FormField.INVALID_EMAIL_MESSAGE);return false;}return true;},INVALID_EMAIL_MESSAGE:"Please enter a valid email address",VALIDATE_PHONE_NUMBER:function(d,c){var b=/^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;if(b.test(d)===false){c.set("error",a.FormField.INVALID_PHONE_NUMBER);return false;}return true;},INVALID_PHONE_NUMBER:"Please enter a valid phone number",VALIDATE_IP_ADDRESS:function(f,e){var c=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,b,d=true;if(c.test(f)===false){d=false;}b=f.split(".");a.Array.each(b,function(h,j,g){var k=parseInt(h,10);if(k<0||k>255){d=false;}});if(d===false){e.set("error",a.FormField.INVALID_IP_MESSAGE);}return d;},INVALID_IP_MESSAGE:"Please enter a valid IP address",VALIDATE_DATE:function(d,c){var b=/^([1-9]|1[0-2])(\-|\/)([0-2][0-9]|3[0-1])(\-|\/)(\d{4}|\d{2})$/;if(b.test(d)===false){c.set("error",a.FormField.INVALID_DATE_MESSAGE);return false;}return true;},INVALID_DATE_MESSAGE:"Please enter a a valid date",VALIDATE_TIME:function(d,c){var b=/^([1-9]|1[0-2]):[0-5]\d(:[0-5]\d(\.\d{1,3})?)?$/; +if(b.test(d)===false){c.set("error",a.FormField.INVALID_TIME_MESSAGE);return false;}return true;},INVALID_TIME_MESSAGE:"Please enter a valid time",VALIDATE_POSTAL_CODE:function(e,d){var b,c=true;if(e.length==6||e.length==7){b=/^[a-zA-Z]\d[a-zA-Z](-|\s)?\d[a-zA-Z]\d$/;}else{if(e.length==5||e.length==10){b=/^\d{5}((-|\s)\d{4})?$/;}else{if(e.length>0){c=false;}}}if(c===false||(b&&b.test(e)===false)){d.set("error",a.FormField.INVALID_POSTAL_CODE_MESSAGE);return false;}return true;},INVALID_POSTAL_CODE_MESSAGE:"Please enter a valid postal code",VALIDATE_NO_SPECIAL_CHARS:function(d,c){var b=/^[a-zA-Z0-9]*$/;if(b.test(d)===false){c.set("error",a.FormField.INVALID_SPECIAL_CHARS);return false;}return true;},INVALID_SPECIAL_CHARS:"Please use only letters and numbers",REQUIRED_ERROR_TEXT:"This field is required",FIELD_ID_SUFFIX:"-field"});a.TextField=a.Base.create("text-field",a.FormField,[a.WidgetChild]);a.PasswordField=a.Base.create("password-field",a.FormField,[a.WidgetChild]);a.CheckboxField=a.Base.create("checkbox-field",a.FormField,[a.WidgetChild],{_syncChecked:function(){this._fieldNode.set("checked",this.get("checked"));},initializer:function(){a.CheckboxField.superclass.initializer.apply(this,arguments);},renderUI:function(){this._renderFieldNode();this._renderLabelNode();},syncUI:function(){a.CheckboxField.superclass.syncUI.apply(this,arguments);this._syncChecked();},bindUI:function(){a.CheckboxField.superclass.bindUI.apply(this,arguments);this.after("checkedChange",a.bind(function(b){if(b.src!="ui"){this._fieldNode.set("checked",b.newVal);}},this));this._fieldNode.after("change",a.bind(function(b){this.set("checked",b.currentTarget.get("checked"),{src:"ui"});},this));}},{ATTRS:{"checked":{value:false,validator:a.Lang.isBoolean}}});a.RadioField=a.Base.create("radio-field",a.FormField,[a.WidgetChild]);a.HiddenField=a.Base.create("hidden-field",a.FormField,[a.WidgetChild],{_valueDisplayNode:null,_renderValueDisplayNode:function(){if(this.get("displayValue")===true){var c=a.Node.create("
"),b=this.get("contentBox");b.appendChild(c);this._valueDisplayNode=c;}},renderUI:function(){a.HiddenField.superclass.renderUI.apply(this,arguments);this._renderValueDisplayNode();},bindUI:function(){a.HiddenField.superclass.bindUI.apply(this,arguments);if(this.get("displayValue")===true){this.after("valueChange",a.bind(function(b,c){this._valueDisplayNode.set("innerHTML",c.newVal);},this,true));}},clear:function(){}},{ATTRS:{displayValue:{value:false,writeOnce:true,validator:a.Lang.isBoolean}}});a.TextareaField=a.Base.create("textarea-field",a.FormField,[a.WidgetChild],{FIELD_TEMPLATE:""});a.ChoiceField=a.Base.create("choice-field",a.FormField,[a.WidgetParent,a.WidgetChild],{LABEL_TEMPLATE:"",SINGLE_CHOICE:a.RadioField,MULTI_CHOICE:a.CheckboxField,_validateChoices:function(d){if(!a.Lang.isArray(d)){return false;}var c=0,b=d.length;for(;c0){a.Array.each(b,function(c){this._fieldNode.each(function(e,d,f){if(a.Lang.trim(e.get("value"))==a.Lang.trim(c)){e.set("checked",true);return true;}},this);},this);}},_afterChoicesChange:function(c){var b=this.get("contentBox");b.all(".yui3-form-field").remove();this._renderFieldNode();},clear:function(){this._fieldNode.each(function(c,b,d){c.set("checked",false);},this);this.set("value","");},bindUI:function(){this._fieldNode.on("change",a.bind(function(c){var b="";this._fieldNode.each(function(e,d,f){if(e.get("checked")===true){if(b.length>0){b+=",";}b+=e.get("value");}},this);this.set("value",b);},this));this.after("choicesChange",this._afterChoicesChange);}},{ATTRS:{choices:{valueFn:function(){return[];},validator:function(b){return this._validateChoices(b);}},multi:{validator:a.Lang.isBoolean,value:false}}});a.SelectField=a.Base.create("select-field",a.ChoiceField,[a.WidgetParent,a.WidgetChild],{FIELD_TEMPLATE:"",DEFAULT_OPTION_TEXT:"Choose one",_renderFieldNode:function(){a.SelectField.superclass.constructor.superclass._renderFieldNode.apply(this,arguments);this._renderOptionNodes();},_renderOptionNodes:function(){var c=this.get("choices"),b;if(this.get("useDefaultOption")===true){b=a.Node.create(a.SelectField.OPTION_TEMPLATE);this._fieldNode.appendChild(b);}a.Array.each(c,function(f,e,d){b=a.Node.create(a.SelectField.OPTION_TEMPLATE);this._fieldNode.appendChild(b);},this);},_syncFieldNode:function(){a.SelectField.superclass.constructor.superclass._syncFieldNode.apply(this,arguments);this._fieldNode.setAttrs({size:this.get("size"),multiple:(this.get("multi")===true?"multiple":"")});},_syncOptionNodes:function(){var f=this.get("choices")||[],b=this.get("contentBox"),d=b.all("option"),e=this.get("useDefaultOption"),c=this.get("value");if(e===true){f.unshift({label:this.DEFAULT_OPTION_TEXT,value:""});}d.each(function(j,i,h){var g=f[i].label,k=f[i].value;j.setAttrs({innerHTML:g,value:k});if(c==k){j.setAttrs({selected:true,defaultSelected:true});}},this);if(!c&&!e&&f[0]){this.set("value",f[0].value);}},_afterChoicesChange:function(b){var c=this._fieldNode.all("option");c.remove();this._renderOptionNodes();this._syncOptionNodes();},clear:function(){this._fieldNode.value="";},bindUI:function(){a.SelectField.superclass.constructor.superclass.bindUI.apply(this,arguments);this.after("choicesChange",this._afterChoicesChange);},syncUI:function(){a.SelectField.superclass.syncUI.apply(this,arguments); +this._syncOptionNodes();}},{OPTION_TEMPLATE:"",ATTRS:{useDefaultOption:{validator:a.Lang.isBoolean,value:true},choices:{validator:function(b){if(this.get("useDefaultOption")&&a.Lang.isArray(b)&&b.length===0){return true;}else{return this._validateChoices(b);}}},size:{validator:a.Lang.isString,value:"0"}}});a.FormButton=a.Base.create("button-field",a.FormField,[a.WidgetChild],{FIELD_TEMPLATE:"",LABEL_TEMPLATE:"",_syncFieldNode:function(){this._fieldNode.setAttrs({innerHTML:this.get("label"),id:this.get("id")+a.FormField.FIELD_ID_SUFFIX});this.get("contentBox").addClass("first-child");},_setClickHandler:function(){if(!this._fieldNode){return;}a.Event.purgeElement(this._fieldNode,true,"click");a.on("click",a.bind(this._promptConfirm,this),this._fieldNode);},_promptConfirm:function(d){d.preventDefault();var c=this.get("message"),b=this.get("onclick");if(c){if(!this.get("confirm")(c)){return;}}b.fn.apply(b.scope);},bindUI:function(){this.after("onclickChange",a.bind(this._setClickHandler,this,true));this.after("disabledChange",this._syncDisabled,this);this._setClickHandler();}},{ATTRS:{onclick:{validator:function(b){if(a.Lang.isObject(b)===false){return false;}if(typeof b.fn=="undefined"||a.Lang.isFunction(b.fn)===false){return false;}return true;},value:{fn:function(b){}},setter:function(b){b.scope=b.scope||this;b.argument=b.argument||{};return b;}},message:{validator:a.Lang.isString,value:null},confirm:{validator:a.Lang.isFunction,value:null}}});a.FileField=a.Base.create("file-field",a.FormField,[a.WidgetChild]);a.SubmitButton=a.Base.create("submit-button",a.FormField,[a.WidgetChild],{_renderLabelNode:function(){}});a.ResetButton=a.Base.create("reset-button",a.FormField,[a.WidgetChild],{LABEL_TEMPLATE:""});},"gallery-2011.09.28-20-06",{requires:["node","widget-base","widget-htmlparser","io-form","widget-parent","widget-child","base-build","substitute","io-upload-iframe"]}); \ No newline at end of file diff --git a/build/gallery-form/gallery-form.js b/build/gallery-form/gallery-form.js index c7aa0e0093..468946215e 100644 --- a/build/gallery-form/gallery-form.js +++ b/build/gallery-form/gallery-form.js @@ -249,17 +249,18 @@ Y.Form = Y.Base.create('form', Y.Widget, [Y.WidgetParent], { formMethod = this.get('method'), submitViaIO = this.get('submitViaIO'), io = this.get("io"), + ioConfig = this.get('ioConfig') || {}, transaction, cfg; if (submitViaIO === true) { - cfg = { + cfg = Y.merge({ method: formMethod, form: { id: this.get('contentBox'), upload: (this.get('encodingType') === Y.Form.MULTIPART_ENCODED) } - }; + }, ioConfig); transaction = io(formAction, cfg); this._ioIds[transaction.id] = transaction; @@ -482,6 +483,9 @@ Y.Form = Y.Base.create('form', Y.Widget, [Y.WidgetParent], { */ io: { value: Y.io + }, + + ioConfig : { } }, @@ -1379,6 +1383,11 @@ Y.CheckboxField = Y.Base.create('checkbox-field', Y.FormField, [Y.WidgetChild], Y.CheckboxField.superclass.initializer.apply(this, arguments); }, + renderUI : function () { + this._renderFieldNode(); + this._renderLabelNode(); + }, + syncUI : function () { Y.CheckboxField.superclass.syncUI.apply(this, arguments); this._syncChecked(); @@ -1532,10 +1541,6 @@ Y.ChoiceField = Y.Base.create('choice-field', Y.FormField, [Y.WidgetParent, Y.Wi } } - if (val.length === 0) { - return false; - } - return true; }, @@ -1625,6 +1630,9 @@ Y.ChoiceField = Y.Base.create('choice-field', Y.FormField, [Y.WidgetParent, Y.Wi * @description The choices to render into this field */ choices: { + valueFn : function () { + return []; + }, validator: function(val) { return this._validateChoices(val); } @@ -1713,7 +1721,7 @@ Y.SelectField = Y.Base.create('select-field', Y.ChoiceField, [Y.WidgetParent, Y. * @description Syncs the option nodes with the choices attribute */ _syncOptionNodes: function() { - var choices = this.get('choices'), + var choices = this.get('choices') || [], contentBox = this.get('contentBox'), options = contentBox.all('option'), useDefaultOption = this.get('useDefaultOption'), @@ -1744,7 +1752,7 @@ Y.SelectField = Y.Base.create('select-field', Y.ChoiceField, [Y.WidgetParent, Y. }, this); - if (!currentVal && !useDefaultOption) { + if (!currentVal && !useDefaultOption && choices[0]) { this.set('value', choices[0].value); } }, @@ -1954,4 +1962,4 @@ Y.ResetButton = Y.Base.create('reset-button', Y.FormField, [Y.WidgetChild], { }); -}, 'gallery-2011.09.07-20-35' ,{requires:['node', 'widget-base', 'widget-htmlparser', 'io-form', 'widget-parent', 'widget-child', 'base-build', 'substitute', 'io-upload-iframe']}); +}, 'gallery-2011.09.28-20-06' ,{requires:['node', 'widget-base', 'widget-htmlparser', 'io-form', 'widget-parent', 'widget-child', 'base-build', 'substitute', 'io-upload-iframe']}); diff --git a/build/gallery-makenode/gallery-makenode-debug.js b/build/gallery-makenode/gallery-makenode-debug.js index 646592cdec..73deffb7de 100644 --- a/build/gallery-makenode/gallery-makenode-debug.js +++ b/build/gallery-makenode/gallery-makenode-debug.js @@ -11,10 +11,10 @@ YUI.add('gallery-makenode', function(Y) { * @class MakeNode */ "use strict"; - (function () { + if (Y.version === '3.4.0') { (function () { // See: http://yuilibrary.com/projects/yui3/ticket/2531032 var L = Y.Lang, DUMP = 'dump', SPACE = ' ', LBRACE = '{', RBRACE = '}', - savedRegExp = /(~-(\d+)-~)/g, lBraceRegExp = /\{LBRACE\}/g, rBraceRegExp = /\{RBRACE\}/g; + savedRegExp = /(~-(\d+)-~)/g, lBraceRegExp = /\{LBRACE\}/g, rBraceRegExp = /\{RBRACE\}/g; Y.substitute = function(s, o, f, recurse) { var i, j, k, key, v, meta, saved = [], token, dump, @@ -99,7 +99,7 @@ YUI.add('gallery-makenode', function(Y) { ; }; - })(); + })();} var WS = /\s+/, NODE = 'Node', DOT = '.', @@ -307,27 +307,32 @@ YUI.add('gallery-makenode', function(Y) { * or those specifically requested in its arguments and stores references to them * in properties named after each className key, prefixed with an underscore * and followed by "Node". + * If the className key contains a hyphen followed by a lowercase letter, the hyphen will be dropped and the letter capitalized. + * Any other characters invalid for identifiers will be turned into underscores, + * thus for the no-label-1 className key a _noLabel_1Node property will be created. * @method _locateNodes - * @param arg1,.... {String} (optional) If given, list of className heys of the nodes to be located. + * @param arg1,.... {String} (optional) If given, list of className keys of the nodes to be located. * If missing, all the classNames stored in this._classNames will be located. * @protected */ _locateNodes: function () { - var bbx = this.get(BBX), el; - if (arguments.length) { - Y.each(arguments, function( name) { - el = bbx.one(DOT + this._classNames[name]); + var bbx = this.get(BBX), + self = this, + makeName = function (el, name) { if (el) { - this['_' + name + NODE] = el; + self['_' + name.replace(/\-([a-z])/g,function (str, p1, p2) { + return p1.toUpperCase(); + }).replace(/\W/g,'_') + NODE] = el; } - }, this); + }; + if (arguments.length) { + Y.each(arguments, function (name) { + makeName(bbx.one(DOT + self._classNames[name]),name); + }); } else { - Y.each(this._classNames, function(selector, name) { - el = bbx.one(DOT + selector); - if (el) { - this['_' + name + NODE] = el; - } - }, this); + Y.each(self._classNames, function(selector, name) { + makeName(bbx.one(DOT + selector), name); + }); } }, /** @@ -411,6 +416,7 @@ YUI.add('gallery-makenode', function(Y) { }; self._forAllXinClasses('_EVENTS', function (c, handlers, key) { selector = equivalents[key] || DOT + self._classNames[key]; + if (key === 'THIS') {key = 'This';} Y.each(Y.Array(handlers), function (handler) { fn = null; if (Lang.isString(handler)) { @@ -468,7 +474,7 @@ YUI.add('gallery-makenode', function(Y) { this._forAllXinClasses('_PUBLISH', function (c, options, name) { var opts = {}; Y.each(options || {}, function (value, opt) { - opts[opt] =opt.substr(-2) === 'Fn'?this[value]:value; + opts[opt] = opt.substr(opt.length - 2) === 'Fn'?this[value]:value; },this); this.publish(name,opts); }); @@ -576,7 +582,7 @@ YUI.add('gallery-makenode', function(Y) { * Each entry contains a type of event to be listened to or an array of events. * Each event can be described by its type (i.e.: "key", "mousedown", etc). * MakeNode will associate this event with a method named "_after" followed by the element identifier with the first character capitalized - * and the type of event with the first character capitalized (i.e.: _afterBoundingBoxClick, _afterInputBlur, _afterTHISValueChange, etc.) + * and the type of event with the first character capitalized (i.e.: _afterBoundingBoxClick, _afterInputBlur, _afterThisValueChange, etc.) * Alternatively, the event listener can be described by an object literal containing properties
    *
  • type (mandatory) the type of event being listened to
  • *
  • fn the name of the method to handle the event. @@ -620,4 +626,4 @@ YUI.add('gallery-makenode', function(Y) { -}, 'gallery-2011.09.14-20-40' ,{requires:['substitute', 'classnamemanager'], skinnable:false}); +}, 'gallery-2011.09.28-20-06' ,{requires:['substitute', 'classnamemanager'], skinnable:false}); diff --git a/build/gallery-makenode/gallery-makenode-min.js b/build/gallery-makenode/gallery-makenode-min.js index 4ee165a973..64b4658dba 100644 --- a/build/gallery-makenode/gallery-makenode-min.js +++ b/build/gallery-makenode/gallery-makenode-min.js @@ -1 +1 @@ -YUI.add("gallery-makenode",function(a){(function(){var k=a.Lang,n="dump",q=" ",m="{",p="}",l=/(~-(\d+)-~)/g,o=/\{LBRACE\}/g,r=/\{RBRACE\}/g;a.substitute=function(H,u,B,t){var z,y,x,F,E,G,D=[],w,A,C=H.length;for(;;){z=H.lastIndexOf(m,C);if(z<0){break;}y=H.indexOf(p,z);if(z+1>=y){break;}w=H.substring(z+1,y);F=w;G=null;x=F.indexOf(q);if(x>-1){G=F.substring(x+1);F=F.substring(0,x);}E=u[F];if(B){E=B(F,E,G);}if(k.isObject(E)){if(!a.dump){E=E.toString();}else{if(k.isArray(E)){E=a.dump(E,parseInt(G,10));}else{G=G||"";A=G.indexOf(n);if(A>-1){G=G.substring(4);}if(E.toString===Object.prototype.toString||A>-1){E=a.dump(E,parseInt(G,10));}else{E=E.toString();}}}}else{if(k.isUndefined(E)){E="~-"+D.length+"-~";D.push(w);}}H=H.substring(0,z)+E+H.substring(y+1);if(!t){C=z-1;}}return H.replace(l,function(I,v,s){return m+D[parseInt(s,10)]+p;}).replace(o,m).replace(r,p);};})();var b=/\s+/,c="Node",i=".",h="boundingBox",f=a.Lang,j=' for "{name}" defined in class {recentDef} also defined in class {prevDef}',e=/^(?:([ \t]+)|("[^"\\]*(?:\\.[^"\\]*)*")|(true)|(false)|(null)|([\-+]?[0-9]*(?:\.[0-9]+)?))/,d=/\\"/g,g=function(){var k=this;k._eventHandles=[];k._makeClassNames();k._concatUIAttrs();k._publishEvents();k.after("render",k._attachEvents,k);k.after("destroy",k._detachEvents,k);};g.prototype={_eventHandles:null,_classNames:null,_templateHandlers:{"@":function(k){return this.get(k);},"p":function(k){return this[k];},"m":function(k){var l=k.split(b)[0];k=k.substr(l.length);k=this._parseMakeNodeArgs(k);return this[l].apply(this,k);},"c":function(k){return this._classNames[k];},"s":function(k,l){return this._substitute(this.get("strings")[k],l);},"?":function(k){k=this._parseMakeNodeArgs(k);return(!!k[0])?k[1]:k[2];},"1":function(k){k=this._parseMakeNodeArgs(k);return parseInt(k[0],10)===1?k[1]:k[2];}},_parseMakeNodeArgs:function(k){var l=[],m=function(n,o){if(n!==undefined&&o){switch(o){case 1:break;case 2:l.push(n.substr(1,n.length-2).replace(d,'"'));break;case 3:l.push(true);break;case 4:l.push(false);break;case 5:l.push(null);break;case 6:if(n){l.push(parseFloat(n));}else{k=k.substr(1);}break;}k=k.substr(n.length);return true;}};while(k.length){a.some(e.exec(k),m);}return l;},_forAllXinClasses:function(k,r){var n=this,q=this._getClasses(),m=q.length,p,s,o=function(t,l){r.call(n,s,t,l);};for(p=m-1;p>=0;p--){s=q[p];if(s[k]){a.each(s[k],o);}}},_makeNode:function(l,k){if(!l){a.some(this._getClasses(),function(m){l=m._TEMPLATE;if(l){return true;}});}return a.Node.create(this._substitute(l,k));},_substitute:function(m,l){var k;return a.substitute(m,l||{},a.bind(function(o,p,n){if(n){k=this._templateHandlers[o.toLowerCase()];if(k){return k.call(this,n,l);}}return p;},this),true);},_locateNodes:function(){var k=this.get(h),l;if(arguments.length){a.each(arguments,function(m){l=k.one(i+this._classNames[m]);if(l){this["_"+m+c]=l;}},this);}else{a.each(this._classNames,function(m,n){l=k.one(i+m);if(l){this["_"+n+c]=l;}},this);}},_makeClassNames:function(){var l=a.ClassNameManager.getClassName,m={},k=this._classNames={};this._forAllXinClasses("_CLASS_NAMES",function(o,n){if(m[n]){}else{k[n]=l(o.NAME.toLowerCase(),n);m[n]=o.NAME;}});k.content=(k[h]=l(this.constructor.NAME.toLowerCase()))+"-content";if(this.getStdModNode){k.HEADER="yui3-widget-hd";k.BODY="yui3-widget-bd";k.FOOTER="yui3-widget-ft";}},_concatUIAttrs:function(){var m,l,k={};a.each(["BIND","SYNC"],function(n){m={};a.each(this._UI_ATTRS[n],function(o){m[o]="Widget";});a.each(this._getClasses(),function(o){l=o._ATTRS_2_UI;if(l){a.each(a.Array(l[n]),function(p){if(m[p]){}else{m[p]=o.NAME;}});}});k[n]=a.Object.keys(m);},this);this._UI_ATTRS=k;},_attachEvents:function(){var r=this,s=r.get(h),l,m=[],o,p,n,q=function(t){return t.charAt(0).toUpperCase()+t.substr(1);},k={boundingBox:s,document:s.get("ownerDocument"),THIS:r,Y:a};r._forAllXinClasses("_EVENTS",function(v,t,u){l=k[u]||i+r._classNames[u];a.each(a.Array(t),function(w){p=null;if(f.isString(w)){o=w;n=null;}else{if(f.isObject(w)){o=w.type;p=w.fn;n=w.args;}else{}}if(o){p=p||"_after"+q(u)+q(o);if(!r[p]){}else{p=r[p];}if(f.isString(l)){if(o==="key"){m.push(s.delegate(o,p,n,l,r));}else{m.push(s.delegate(o,p,l,r,n));}}else{if(l===r||l===a){m.push(l.after(o,p,r,n));}else{if(o==="key"){m.push(a.after(o,p,l,n,r));}else{m.push(a.after(o,p,l,r,n));}}}}else{}});});this._eventHandles=this._eventHandles.concat(m);},_publishEvents:function(){this._forAllXinClasses("_PUBLISH",function(n,l,k){var m={};a.each(l||{},function(p,o){m[o]=o.substr(-2)==="Fn"?this[p]:p;},this);this.publish(k,m);});},_detachEvents:function(){a.each(this._eventHandles,function(k){k.detach();});}};a.MakeNode=g;},"gallery-2011.09.14-20-40",{requires:["substitute","classnamemanager"],skinnable:false}); \ No newline at end of file +YUI.add("gallery-makenode",function(a){if(a.version==="3.4.0"){(function(){var k=a.Lang,n="dump",q=" ",m="{",p="}",l=/(~-(\d+)-~)/g,o=/\{LBRACE\}/g,r=/\{RBRACE\}/g;a.substitute=function(H,u,B,t){var z,y,x,F,E,G,D=[],w,A,C=H.length;for(;;){z=H.lastIndexOf(m,C);if(z<0){break;}y=H.indexOf(p,z);if(z+1>=y){break;}w=H.substring(z+1,y);F=w;G=null;x=F.indexOf(q);if(x>-1){G=F.substring(x+1);F=F.substring(0,x);}E=u[F];if(B){E=B(F,E,G);}if(k.isObject(E)){if(!a.dump){E=E.toString();}else{if(k.isArray(E)){E=a.dump(E,parseInt(G,10));}else{G=G||"";A=G.indexOf(n);if(A>-1){G=G.substring(4);}if(E.toString===Object.prototype.toString||A>-1){E=a.dump(E,parseInt(G,10));}else{E=E.toString();}}}}else{if(k.isUndefined(E)){E="~-"+D.length+"-~";D.push(w);}}H=H.substring(0,z)+E+H.substring(y+1);if(!t){C=z-1;}}return H.replace(l,function(I,v,s){return m+D[parseInt(s,10)]+p;}).replace(o,m).replace(r,p);};})();}var b=/\s+/,c="Node",i=".",h="boundingBox",f=a.Lang,j=' for "{name}" defined in class {recentDef} also defined in class {prevDef}',e=/^(?:([ \t]+)|("[^"\\]*(?:\\.[^"\\]*)*")|(true)|(false)|(null)|([\-+]?[0-9]*(?:\.[0-9]+)?))/,d=/\\"/g,g=function(){var k=this;k._eventHandles=[];k._makeClassNames();k._concatUIAttrs();k._publishEvents();k.after("render",k._attachEvents,k);k.after("destroy",k._detachEvents,k);};g.prototype={_eventHandles:null,_classNames:null,_templateHandlers:{"@":function(k){return this.get(k);},"p":function(k){return this[k];},"m":function(k){var l=k.split(b)[0];k=k.substr(l.length);k=this._parseMakeNodeArgs(k);return this[l].apply(this,k);},"c":function(k){return this._classNames[k];},"s":function(k,l){return this._substitute(this.get("strings")[k],l);},"?":function(k){k=this._parseMakeNodeArgs(k);return(!!k[0])?k[1]:k[2];},"1":function(k){k=this._parseMakeNodeArgs(k);return parseInt(k[0],10)===1?k[1]:k[2];}},_parseMakeNodeArgs:function(k){var l=[],m=function(n,o){if(n!==undefined&&o){switch(o){case 1:break;case 2:l.push(n.substr(1,n.length-2).replace(d,'"'));break;case 3:l.push(true);break;case 4:l.push(false);break;case 5:l.push(null);break;case 6:if(n){l.push(parseFloat(n));}else{k=k.substr(1);}break;}k=k.substr(n.length);return true;}};while(k.length){a.some(e.exec(k),m);}return l;},_forAllXinClasses:function(k,r){var n=this,q=this._getClasses(),m=q.length,p,s,o=function(t,l){r.call(n,s,t,l);};for(p=m-1;p>=0;p--){s=q[p];if(s[k]){a.each(s[k],o);}}},_makeNode:function(l,k){if(!l){a.some(this._getClasses(),function(m){l=m._TEMPLATE;if(l){return true;}});}return a.Node.create(this._substitute(l,k));},_substitute:function(m,l){var k;return a.substitute(m,l||{},a.bind(function(o,p,n){if(n){k=this._templateHandlers[o.toLowerCase()];if(k){return k.call(this,n,l);}}return p;},this),true);},_locateNodes:function(){var l=this.get(h),k=this,m=function(o,n){if(o){k["_"+n.replace(/\-([a-z])/g,function(r,q,p){return q.toUpperCase();}).replace(/\W/g,"_")+c]=o;}};if(arguments.length){a.each(arguments,function(n){m(l.one(i+k._classNames[n]),n);});}else{a.each(k._classNames,function(n,o){m(l.one(i+n),o);});}},_makeClassNames:function(){var l=a.ClassNameManager.getClassName,m={},k=this._classNames={};this._forAllXinClasses("_CLASS_NAMES",function(o,n){if(m[n]){}else{k[n]=l(o.NAME.toLowerCase(),n);m[n]=o.NAME;}});k.content=(k[h]=l(this.constructor.NAME.toLowerCase()))+"-content";if(this.getStdModNode){k.HEADER="yui3-widget-hd";k.BODY="yui3-widget-bd";k.FOOTER="yui3-widget-ft";}},_concatUIAttrs:function(){var m,l,k={};a.each(["BIND","SYNC"],function(n){m={};a.each(this._UI_ATTRS[n],function(o){m[o]="Widget";});a.each(this._getClasses(),function(o){l=o._ATTRS_2_UI;if(l){a.each(a.Array(l[n]),function(p){if(m[p]){}else{m[p]=o.NAME;}});}});k[n]=a.Object.keys(m);},this);this._UI_ATTRS=k;},_attachEvents:function(){var r=this,s=r.get(h),l,m=[],o,p,n,q=function(t){return t.charAt(0).toUpperCase()+t.substr(1);},k={boundingBox:s,document:s.get("ownerDocument"),THIS:r,Y:a};r._forAllXinClasses("_EVENTS",function(v,t,u){l=k[u]||i+r._classNames[u];if(u==="THIS"){u="This";}a.each(a.Array(t),function(w){p=null;if(f.isString(w)){o=w;n=null;}else{if(f.isObject(w)){o=w.type;p=w.fn;n=w.args;}else{}}if(o){p=p||"_after"+q(u)+q(o);if(!r[p]){}else{p=r[p];}if(f.isString(l)){if(o==="key"){m.push(s.delegate(o,p,n,l,r));}else{m.push(s.delegate(o,p,l,r,n));}}else{if(l===r||l===a){m.push(l.after(o,p,r,n));}else{if(o==="key"){m.push(a.after(o,p,l,n,r));}else{m.push(a.after(o,p,l,r,n));}}}}else{}});});this._eventHandles=this._eventHandles.concat(m);},_publishEvents:function(){this._forAllXinClasses("_PUBLISH",function(n,l,k){var m={};a.each(l||{},function(p,o){m[o]=o.substr(o.length-2)==="Fn"?this[p]:p;},this);this.publish(k,m);});},_detachEvents:function(){a.each(this._eventHandles,function(k){k.detach();});}};a.MakeNode=g;},"gallery-2011.09.28-20-06",{requires:["substitute","classnamemanager"],skinnable:false}); \ No newline at end of file diff --git a/build/gallery-makenode/gallery-makenode.js b/build/gallery-makenode/gallery-makenode.js index 71b8af7209..f65643dd46 100644 --- a/build/gallery-makenode/gallery-makenode.js +++ b/build/gallery-makenode/gallery-makenode.js @@ -11,10 +11,10 @@ YUI.add('gallery-makenode', function(Y) { * @class MakeNode */ "use strict"; - (function () { + if (Y.version === '3.4.0') { (function () { // See: http://yuilibrary.com/projects/yui3/ticket/2531032 var L = Y.Lang, DUMP = 'dump', SPACE = ' ', LBRACE = '{', RBRACE = '}', - savedRegExp = /(~-(\d+)-~)/g, lBraceRegExp = /\{LBRACE\}/g, rBraceRegExp = /\{RBRACE\}/g; + savedRegExp = /(~-(\d+)-~)/g, lBraceRegExp = /\{LBRACE\}/g, rBraceRegExp = /\{RBRACE\}/g; Y.substitute = function(s, o, f, recurse) { var i, j, k, key, v, meta, saved = [], token, dump, @@ -99,7 +99,7 @@ YUI.add('gallery-makenode', function(Y) { ; }; - })(); + })();} var WS = /\s+/, NODE = 'Node', DOT = '.', @@ -307,27 +307,32 @@ YUI.add('gallery-makenode', function(Y) { * or those specifically requested in its arguments and stores references to them * in properties named after each className key, prefixed with an underscore * and followed by "Node". + * If the className key contains a hyphen followed by a lowercase letter, the hyphen will be dropped and the letter capitalized. + * Any other characters invalid for identifiers will be turned into underscores, + * thus for the no-label-1 className key a _noLabel_1Node property will be created. * @method _locateNodes - * @param arg1,.... {String} (optional) If given, list of className heys of the nodes to be located. + * @param arg1,.... {String} (optional) If given, list of className keys of the nodes to be located. * If missing, all the classNames stored in this._classNames will be located. * @protected */ _locateNodes: function () { - var bbx = this.get(BBX), el; - if (arguments.length) { - Y.each(arguments, function( name) { - el = bbx.one(DOT + this._classNames[name]); + var bbx = this.get(BBX), + self = this, + makeName = function (el, name) { if (el) { - this['_' + name + NODE] = el; + self['_' + name.replace(/\-([a-z])/g,function (str, p1, p2) { + return p1.toUpperCase(); + }).replace(/\W/g,'_') + NODE] = el; } - }, this); + }; + if (arguments.length) { + Y.each(arguments, function (name) { + makeName(bbx.one(DOT + self._classNames[name]),name); + }); } else { - Y.each(this._classNames, function(selector, name) { - el = bbx.one(DOT + selector); - if (el) { - this['_' + name + NODE] = el; - } - }, this); + Y.each(self._classNames, function(selector, name) { + makeName(bbx.one(DOT + selector), name); + }); } }, /** @@ -409,6 +414,7 @@ YUI.add('gallery-makenode', function(Y) { }; self._forAllXinClasses('_EVENTS', function (c, handlers, key) { selector = equivalents[key] || DOT + self._classNames[key]; + if (key === 'THIS') {key = 'This';} Y.each(Y.Array(handlers), function (handler) { fn = null; if (Lang.isString(handler)) { @@ -463,7 +469,7 @@ YUI.add('gallery-makenode', function(Y) { this._forAllXinClasses('_PUBLISH', function (c, options, name) { var opts = {}; Y.each(options || {}, function (value, opt) { - opts[opt] =opt.substr(-2) === 'Fn'?this[value]:value; + opts[opt] = opt.substr(opt.length - 2) === 'Fn'?this[value]:value; },this); this.publish(name,opts); }); @@ -571,7 +577,7 @@ YUI.add('gallery-makenode', function(Y) { * Each entry contains a type of event to be listened to or an array of events. * Each event can be described by its type (i.e.: "key", "mousedown", etc). * MakeNode will associate this event with a method named "_after" followed by the element identifier with the first character capitalized - * and the type of event with the first character capitalized (i.e.: _afterBoundingBoxClick, _afterInputBlur, _afterTHISValueChange, etc.) + * and the type of event with the first character capitalized (i.e.: _afterBoundingBoxClick, _afterInputBlur, _afterThisValueChange, etc.) * Alternatively, the event listener can be described by an object literal containing properties
      *
    • type (mandatory) the type of event being listened to
    • *
    • fn the name of the method to handle the event. @@ -615,4 +621,4 @@ YUI.add('gallery-makenode', function(Y) { -}, 'gallery-2011.09.14-20-40' ,{requires:['substitute', 'classnamemanager'], skinnable:false}); +}, 'gallery-2011.09.28-20-06' ,{requires:['substitute', 'classnamemanager'], skinnable:false}); diff --git a/build/gallery-md-accordion/gallery-md-accordion-debug.js b/build/gallery-md-accordion/gallery-md-accordion-debug.js index 0c53ddfa87..19ee1d4230 100644 --- a/build/gallery-md-accordion/gallery-md-accordion-debug.js +++ b/build/gallery-md-accordion/gallery-md-accordion-debug.js @@ -314,11 +314,11 @@ Y.Accordion = Y.Base.create( /** * Event listener for child expansion/collapse, ensures that only one is expanded * at a time if multiExpand is not set. - * @method _afterTHISAccordionPanel:expandedChange + * @method _afterThisAccordionPanel:expandedChange * @param ev {EventFacade} * @private */ - '_afterTHISAccordionPanel:expandedChange': function (ev) { + '_afterThisAccordionPanel:expandedChange': function (ev) { var child = ev.target; if (ev.newVal && !this.get(MULTI_EXPAND)) { this.each(function (panel) { @@ -331,12 +331,12 @@ Y.Accordion = Y.Base.create( /** * Listens to the panelClose and destroys the panel * and removes it from the collection of panels. - * @method _afterTHISAccordionPanel:panelClose + * @method _afterThisAccordionPanel:panelClose * @param ev {EventFacade} uses ev.target to locate the panel requesting the close * @private */ - '_afterTHISAccordionPanel:panelClose': function (ev) { + '_afterThisAccordionPanel:panelClose': function (ev) { var panel = ev.target; if (this.indexOf(panel) >= 0) { this.remove(panel); @@ -445,4 +445,4 @@ Y.Accordion = Y.Base.create( -}, 'gallery-2011.08.31-20-57' ,{optional:['resize-plugin', 'transition'], requires:['widget', 'widget-parent', 'widget-child', 'widget-stdmod', 'gallery-makenode'], skinnable:true}); +}, 'gallery-2011.09.28-20-06' ,{optional:['resize-plugin', 'transition'], requires:['widget', 'widget-parent', 'widget-child', 'widget-stdmod', 'gallery-makenode'], skinnable:true}); diff --git a/build/gallery-md-accordion/gallery-md-accordion-min.js b/build/gallery-md-accordion/gallery-md-accordion-min.js index ac29077c60..a739ca992c 100644 --- a/build/gallery-md-accordion/gallery-md-accordion-min.js +++ b/build/gallery-md-accordion/gallery-md-accordion-min.js @@ -1 +1 @@ -YUI.add("gallery-md-accordion",function(b){var f=b.Lang,a="boundingBox",n=b.WidgetStdMod.BODY,o=b.WidgetStdMod.HEADER,h="expanded",q="expanding",j="collapsed",p="collapsing",r="label",g="content",d="icon",e="status",c="close",s="panelClose",l="multiExpand",k="resizeable",m="closeable",i="ui";b.AccordionPanel=b.Base.create("accordionPanel",b.Widget,[b.WidgetChild,b.WidgetStdMod,b.MakeNode],{CONTENT_TEMPLATE:null,_syncUIStdMod:function(){},renderUI:function(){this.setStdModContent(n,this._makeNode());this.setStdModContent(o,this._makeNode(b.AccordionPanel._HEADER_TEMPLATE));this._locateNodes();},_uiSetExpanded:function(t,u){if(u===i){return;}if(t){this.expand();}else{this.collapse();}},_uiSetLabel:function(t){this._labelNode.setContent(t);},_uiSetContent:function(t){this._bodyNode.setContent(t);},_uiSetResizeable:function(u){var t=this.getStdModNode(n);if(b.Plugin.Resize){if(u){t.plug(b.Plugin.Resize,{handles:["b"]});}else{t.unplug(b.Plugin.Resize);}}},_uiSetCloseable:function(t){if(t){this._closeNode.show();}else{this._closeNode.hide();}},expand:function(){var t=this.get(a),u=this._classNames;t.replaceClass(u[j],u[q]);this.getStdModNode(n).show(true,{},function(){t.replaceClass(u[q],u[h]);});this.set(h,true,{src:i});},collapse:function(){var t=this.get(a),u=this._classNames;t.replaceClass(u[h],u[q]);this.getStdModNode(n).hide(true,{},function(){t.replaceClass(u[q],u[j]);});this.set(h,false,{src:i});},toggle:function(){this.set(h,!this.get(h));},_afterHEADERClick:function(t){if(t.target===this.getStdModNode(o)){this.toggle();}},close:function(){this.fire(s);}},{_CLASS_NAMES:[h,j,n,d,r,e,c,q,p],_TEMPLATE:'
      ',_HEADER_TEMPLATE:'
      ',_EVENTS:{HEADER:"click",close:{type:"click",fn:"close"}},_ATTRS_2_UI:{BIND:[r,g,h,k,m],SYNC:[r,g,h,k,m]},ATTRS:{expanded:{value:false,validator:f.isBoolean},label:{value:"",validator:f.isString},content:{value:""},resizeable:{value:true,validator:f.isBoolean},closeable:{value:true,validator:f.isBoolean}}});b.Accordion=b.Base.create("accordion",b.Widget,[b.WidgetParent,b.MakeNode],{"_afterTHISAccordionPanel:expandedChange":function(t){var u=t.target;if(t.newVal&&!this.get(l)){this.each(function(v){if(v!==u&&v.get(h)){v.collapse();}});}},"_afterTHISAccordionPanel:panelClose":function(u){var t=u.target;if(this.indexOf(t)>=0){this.remove(t);t.destroy();}},_uiSetResizeable:function(t){this.each(function(u){u.set(k,t);});},_uiSetCloseable:function(t){this.each(function(u){u.set(m,t);});}},{_ATTRS_2_UI:{BIND:[k,m],SYNC:[k,m]},_EVENTS:{THIS:["accordionPanel:expandedChange","accordionPanel:panelClose"]},ATTRS:{defaultChildType:{value:"AccordionPanel"},multiExpand:{value:true,validator:f.isBoolean},resizeable:{value:true,validator:f.isBoolean},closeable:{value:true,validator:f.isBoolean}}});},"gallery-2011.08.31-20-57",{optional:["resize-plugin","transition"],requires:["widget","widget-parent","widget-child","widget-stdmod","gallery-makenode"],skinnable:true}); \ No newline at end of file +YUI.add("gallery-md-accordion",function(b){var f=b.Lang,a="boundingBox",n=b.WidgetStdMod.BODY,o=b.WidgetStdMod.HEADER,h="expanded",q="expanding",j="collapsed",p="collapsing",r="label",g="content",d="icon",e="status",c="close",s="panelClose",l="multiExpand",k="resizeable",m="closeable",i="ui";b.AccordionPanel=b.Base.create("accordionPanel",b.Widget,[b.WidgetChild,b.WidgetStdMod,b.MakeNode],{CONTENT_TEMPLATE:null,_syncUIStdMod:function(){},renderUI:function(){this.setStdModContent(n,this._makeNode());this.setStdModContent(o,this._makeNode(b.AccordionPanel._HEADER_TEMPLATE));this._locateNodes();},_uiSetExpanded:function(t,u){if(u===i){return;}if(t){this.expand();}else{this.collapse();}},_uiSetLabel:function(t){this._labelNode.setContent(t);},_uiSetContent:function(t){this._bodyNode.setContent(t);},_uiSetResizeable:function(u){var t=this.getStdModNode(n);if(b.Plugin.Resize){if(u){t.plug(b.Plugin.Resize,{handles:["b"]});}else{t.unplug(b.Plugin.Resize);}}},_uiSetCloseable:function(t){if(t){this._closeNode.show();}else{this._closeNode.hide();}},expand:function(){var t=this.get(a),u=this._classNames;t.replaceClass(u[j],u[q]);this.getStdModNode(n).show(true,{},function(){t.replaceClass(u[q],u[h]);});this.set(h,true,{src:i});},collapse:function(){var t=this.get(a),u=this._classNames;t.replaceClass(u[h],u[q]);this.getStdModNode(n).hide(true,{},function(){t.replaceClass(u[q],u[j]);});this.set(h,false,{src:i});},toggle:function(){this.set(h,!this.get(h));},_afterHEADERClick:function(t){if(t.target===this.getStdModNode(o)){this.toggle();}},close:function(){this.fire(s);}},{_CLASS_NAMES:[h,j,n,d,r,e,c,q,p],_TEMPLATE:'
      ',_HEADER_TEMPLATE:'
      ',_EVENTS:{HEADER:"click",close:{type:"click",fn:"close"}},_ATTRS_2_UI:{BIND:[r,g,h,k,m],SYNC:[r,g,h,k,m]},ATTRS:{expanded:{value:false,validator:f.isBoolean},label:{value:"",validator:f.isString},content:{value:""},resizeable:{value:true,validator:f.isBoolean},closeable:{value:true,validator:f.isBoolean}}});b.Accordion=b.Base.create("accordion",b.Widget,[b.WidgetParent,b.MakeNode],{"_afterThisAccordionPanel:expandedChange":function(t){var u=t.target;if(t.newVal&&!this.get(l)){this.each(function(v){if(v!==u&&v.get(h)){v.collapse();}});}},"_afterThisAccordionPanel:panelClose":function(u){var t=u.target;if(this.indexOf(t)>=0){this.remove(t);t.destroy();}},_uiSetResizeable:function(t){this.each(function(u){u.set(k,t);});},_uiSetCloseable:function(t){this.each(function(u){u.set(m,t);});}},{_ATTRS_2_UI:{BIND:[k,m],SYNC:[k,m]},_EVENTS:{THIS:["accordionPanel:expandedChange","accordionPanel:panelClose"]},ATTRS:{defaultChildType:{value:"AccordionPanel"},multiExpand:{value:true,validator:f.isBoolean},resizeable:{value:true,validator:f.isBoolean},closeable:{value:true,validator:f.isBoolean}}});},"gallery-2011.09.28-20-06",{optional:["resize-plugin","transition"],requires:["widget","widget-parent","widget-child","widget-stdmod","gallery-makenode"],skinnable:true}); \ No newline at end of file diff --git a/build/gallery-md-accordion/gallery-md-accordion.js b/build/gallery-md-accordion/gallery-md-accordion.js index 0c53ddfa87..19ee1d4230 100644 --- a/build/gallery-md-accordion/gallery-md-accordion.js +++ b/build/gallery-md-accordion/gallery-md-accordion.js @@ -314,11 +314,11 @@ Y.Accordion = Y.Base.create( /** * Event listener for child expansion/collapse, ensures that only one is expanded * at a time if multiExpand is not set. - * @method _afterTHISAccordionPanel:expandedChange + * @method _afterThisAccordionPanel:expandedChange * @param ev {EventFacade} * @private */ - '_afterTHISAccordionPanel:expandedChange': function (ev) { + '_afterThisAccordionPanel:expandedChange': function (ev) { var child = ev.target; if (ev.newVal && !this.get(MULTI_EXPAND)) { this.each(function (panel) { @@ -331,12 +331,12 @@ Y.Accordion = Y.Base.create( /** * Listens to the panelClose and destroys the panel * and removes it from the collection of panels. - * @method _afterTHISAccordionPanel:panelClose + * @method _afterThisAccordionPanel:panelClose * @param ev {EventFacade} uses ev.target to locate the panel requesting the close * @private */ - '_afterTHISAccordionPanel:panelClose': function (ev) { + '_afterThisAccordionPanel:panelClose': function (ev) { var panel = ev.target; if (this.indexOf(panel) >= 0) { this.remove(panel); @@ -445,4 +445,4 @@ Y.Accordion = Y.Base.create( -}, 'gallery-2011.08.31-20-57' ,{optional:['resize-plugin', 'transition'], requires:['widget', 'widget-parent', 'widget-child', 'widget-stdmod', 'gallery-makenode'], skinnable:true}); +}, 'gallery-2011.09.28-20-06' ,{optional:['resize-plugin', 'transition'], requires:['widget', 'widget-parent', 'widget-child', 'widget-stdmod', 'gallery-makenode'], skinnable:true}); diff --git a/build/gallery-patch-341-charts-alwaysshowzero/gallery-patch-341-charts-alwaysshowzero-debug.js b/build/gallery-patch-341-charts-alwaysshowzero/gallery-patch-341-charts-alwaysshowzero-debug.js new file mode 100644 index 0000000000..d9dbcae266 --- /dev/null +++ b/build/gallery-patch-341-charts-alwaysshowzero/gallery-patch-341-charts-alwaysshowzero-debug.js @@ -0,0 +1,76 @@ +YUI.add('gallery-patch-341-charts-alwaysshowzero', function(Y) { + +Y.NumericAxis.prototype._updateMinAndMax = function() +{ + var data = this.get("data"), + max, + min, + len, + num, + i = 0, + key, + setMax = this.get("setMax"), + setMin = this.get("setMin"); + if(!setMax || !setMin) + { + if(data && data.length && data.length > 0) + { + len = data.length; + for(; i < len; i++) + { + num = data[i]; + if(isNaN(num)) + { + if(Y.Lang.isObject(num)) + { + min = max = 0; + //hloc values + for(key in num) + { + if(num.hasOwnProperty(key)) + { + max = Math.max(num[key], max); + min = Math.min(num[key], min); + } + } + } + max = setMax ? this._setMaximum : max; + min = setMin ? this._setMinimum : min; + continue; + } + + if(setMin) + { + min = this._setMinimum; + } + else if(min === undefined) + { + min = num; + } + else + { + min = Math.min(num, min); + } + if(setMax) + { + max = this._setMaximum; + } + else if(max === undefined) + { + max = num; + } + else + { + max = Math.max(num, max); + } + + this._actualMaximum = max; + this._actualMinimum = min; + } + } + this._roundMinAndMax(min, max, setMin, setMax); + } +}; + + +}, 'gallery-2011.09.28-20-06' ,{requires:['charts']}); diff --git a/build/gallery-patch-341-charts-alwaysshowzero/gallery-patch-341-charts-alwaysshowzero-min.js b/build/gallery-patch-341-charts-alwaysshowzero/gallery-patch-341-charts-alwaysshowzero-min.js new file mode 100644 index 0000000000..45407fd10d --- /dev/null +++ b/build/gallery-patch-341-charts-alwaysshowzero/gallery-patch-341-charts-alwaysshowzero-min.js @@ -0,0 +1 @@ +YUI.add("gallery-patch-341-charts-alwaysshowzero",function(a){a.NumericAxis.prototype._updateMinAndMax=function(){var c=this.get("data"),h,b,f,e,d=0,j,k=this.get("setMax"),g=this.get("setMin");if(!k||!g){if(c&&c.length&&c.length>0){f=c.length;for(;d 0) + { + len = data.length; + for(; i < len; i++) + { + num = data[i]; + if(isNaN(num)) + { + if(Y.Lang.isObject(num)) + { + min = max = 0; + //hloc values + for(key in num) + { + if(num.hasOwnProperty(key)) + { + max = Math.max(num[key], max); + min = Math.min(num[key], min); + } + } + } + max = setMax ? this._setMaximum : max; + min = setMin ? this._setMinimum : min; + continue; + } + + if(setMin) + { + min = this._setMinimum; + } + else if(min === undefined) + { + min = num; + } + else + { + min = Math.min(num, min); + } + if(setMax) + { + max = this._setMaximum; + } + else if(max === undefined) + { + max = num; + } + else + { + max = Math.max(num, max); + } + + this._actualMaximum = max; + this._actualMinimum = min; + } + } + this._roundMinAndMax(min, max, setMin, setMax); + } +}; + + +}, 'gallery-2011.09.28-20-06' ,{requires:['charts']}); diff --git a/build/gallery-yui-tooltip/gallery-yui-tooltip-debug.js b/build/gallery-yui-tooltip/gallery-yui-tooltip-debug.js index 13b0a2c304..caed992d55 100644 --- a/build/gallery-yui-tooltip/gallery-yui-tooltip-debug.js +++ b/build/gallery-yui-tooltip/gallery-yui-tooltip-debug.js @@ -294,6 +294,10 @@ YUI.add('gallery-yui-tooltip', function(Y) { if( $target.get('id') === this.get('_tooltipID') ){ + this.set('visible', true); + + this._setAlignment($target, this.get('_currentAlignment')); + this.show(); } @@ -554,4 +558,4 @@ YUI.add('gallery-yui-tooltip', function(Y) { -}, 'gallery-2011.05.12-13-26' ,{requires:['selector-css3','overlay','transition','event-mouseenter']}); +}, 'gallery-2011.09.28-20-06' ,{requires:['selector-css3','overlay','transition','event-mouseenter']}); diff --git a/build/gallery-yui-tooltip/gallery-yui-tooltip-min.js b/build/gallery-yui-tooltip/gallery-yui-tooltip-min.js index 354f1b5b9b..17c85df6c3 100644 --- a/build/gallery-yui-tooltip/gallery-yui-tooltip-min.js +++ b/build/gallery-yui-tooltip/gallery-yui-tooltip-min.js @@ -1 +1 @@ -YUI.add("gallery-yui-tooltip",function(b){var a=function(c){a.superclass.constructor.apply(this,arguments);};a.NAME="Tooltip";a.ATTRS={hideTimer:{value:0.5},resetOnHover:{value:true},alignment:{value:"top"},distance:{value:10},move:{value:10},duration:{value:0.15},easing:{value:"ease-out"},visible:{value:false},zIndex:{value:30000},_timeoutID:{value:null},_tooltipID:{value:null},_alignmentMap:{value:{"top":[b.WidgetPositionAlign.BC,b.WidgetPositionAlign.TC],"right":[b.WidgetPositionAlign.LC,b.WidgetPositionAlign.RC],"bottom":[b.WidgetPositionAlign.TC,b.WidgetPositionAlign.BC],"left":[b.WidgetPositionAlign.RC,b.WidgetPositionAlign.LC]}},_currentAlignment:{value:null}};b.extend(a,b.Overlay,{hide:function(){this.fire("hide");return this;},reset:function(){this.fire("reset");return this;},show:function(c){this.fire("show",c);return this;},timeout:function(){this.fire("timeout");return this;},tip:function(c){var e=c.getAttribute("tooltip"),g=c.getAttribute("tooltip:alignment")||this.get("alignment"),d=this.get("_currentAlignment"),f=this.get("distance"),h=this.get("move"),i={"top":"auto","right":"auto","bottom":"auto","left":"auto"};i[g]="-"+(f+h)+"px";this.set("_tooltipID",c.get("id"));this.setStdModContent(b.WidgetStdMod.BODY,e);this.get("contentBox").setStyles(i);this.set("visible",true);this._setAlignment(c,g);this.show(true);},_handleMouseEnter:function(g){var c=g.target,h=this.get("contentBox"),f=false,d=this;if(c.ancestor("."+this.getClassName(),true)){this.reset();}else{c=c.ancestor("*[tooltip]",true);if(c.get("id")===this.get("_tooltipID")){this.show();}else{if(h.getStyle("opacity")>0){h.transition({duration:this.get("duration"),easing:this.get("easing"),opacity:0},function(){f=true;d.tip(c);});window.setTimeout(function(){if(!f){d.tip(c);}},(this.get("duration")*1000+50));}else{this.tip(c);}}}},_handleMouseLeave:function(c){this.timeout();},_hide:function(d){var c=this;this.reset();this.get("contentBox").transition({duration:this.get("duration"),easing:this.get("easing"),opacity:0},function(){c.set("visible",false);});},_reset:function(){window.clearTimeout(this.get("_timeoutID"));this.set("_timeoutID",null);},_setAlignment:function(c,d){this.get("contentBox").replaceClass(this.getClassName("align",this.get("_currentAlignment")),this.getClassName("align",d));this.set("_currentAlignment",d);this.set("align",{node:c,points:this.get("_alignmentMap")[d]});},_show:function(m,d){var l=this.get("_currentAlignment"),h=this.get("distance"),c=this.get("move"),j=this.get("contentBox"),f={duration:this.get("duration"),easing:this.get("easing"),opacity:1},k={"top":"auto","right":"auto","bottom":"auto","left":"auto"},g;this.reset();this.set("visible",true);if(d||j.getStyle("opacity")<0.1){k[l]="-"+(h+c)+"px";f[l]="-"+h+"px";j.setStyles(k);}j.transition(f);},_timeout:function(){var c=this;if(b.Lang.isNull(this.get("_timeoutID"))){this.set("_timeoutID",window.setTimeout(function(){c.hide();},parseInt(this.get("hideTimer")*1000,10)));}},renderUI:function(){this.setStdModContent(b.WidgetStdMod.BODY,"");this.setStdModContent(b.WidgetStdMod.FOOTER,"
      ");},bindUI:function(){var e=["hide","show","timeout","reset"],f=b.all("*[tooltip]"),c=this.get("resetOnHover"),d;for(d=0;d0){h.transition({duration:this.get("duration"),easing:this.get("easing"),opacity:0},function(){f=true;d.tip(c);});window.setTimeout(function(){if(!f){d.tip(c);}},(this.get("duration")*1000+50));}else{this.tip(c);}}}},_handleMouseLeave:function(c){this.timeout();},_hide:function(d){var c=this;this.reset();this.get("contentBox").transition({duration:this.get("duration"),easing:this.get("easing"),opacity:0},function(){c.set("visible",false);});},_reset:function(){window.clearTimeout(this.get("_timeoutID"));this.set("_timeoutID",null);},_setAlignment:function(c,d){this.get("contentBox").replaceClass(this.getClassName("align",this.get("_currentAlignment")),this.getClassName("align",d));this.set("_currentAlignment",d);this.set("align",{node:c,points:this.get("_alignmentMap")[d]});},_show:function(m,d){var l=this.get("_currentAlignment"),h=this.get("distance"),c=this.get("move"),j=this.get("contentBox"),f={duration:this.get("duration"),easing:this.get("easing"),opacity:1},k={"top":"auto","right":"auto","bottom":"auto","left":"auto"},g;this.reset();this.set("visible",true);if(d||j.getStyle("opacity")<0.1){k[l]="-"+(h+c)+"px";f[l]="-"+h+"px";j.setStyles(k);}j.transition(f);},_timeout:function(){var c=this;if(b.Lang.isNull(this.get("_timeoutID"))){this.set("_timeoutID",window.setTimeout(function(){c.hide();},parseInt(this.get("hideTimer")*1000,10)));}},renderUI:function(){this.setStdModContent(b.WidgetStdMod.BODY,"");this.setStdModContent(b.WidgetStdMod.FOOTER,"
      ");},bindUI:function(){var e=["hide","show","timeout","reset"],f=b.all("*[tooltip]"),c=this.get("resetOnHover"),d;for(d=0;d