MDL-28554 import YUI 3.4.0
This commit is contained in:
+1
-1
@@ -200,7 +200,7 @@ umask(0000);
|
||||
|
||||
// exact version of currently used yui2 and 3 library
|
||||
$CFG->yui2version = '2.9.0';
|
||||
$CFG->yui3version = '3.2.0';
|
||||
$CFG->yui3version = '3.4.0';
|
||||
|
||||
|
||||
// special support for highly optimised scripts that do not need libraries and DB connection
|
||||
|
||||
@@ -228,7 +228,7 @@
|
||||
<location>yui</location>
|
||||
<name>YUI</name>
|
||||
<license>BSD</license>
|
||||
<version>3.3.2</version>
|
||||
<version>3.4.0</version>
|
||||
<licenseversion></licenseversion>
|
||||
</library>
|
||||
<library>
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("anim-base",function(B){var C="running",N="startTime",L="elapsedTime",J="start",I="tween",M="end",D="node",K="paused",O="reverse",H="iterationCount",A=Number;var F={},E;B.Anim=function(){B.Anim.superclass.constructor.apply(this,arguments);B.Anim._instances[B.stamp(this)]=this;};B.Anim.NAME="anim";B.Anim._instances={};B.Anim.RE_DEFAULT_UNIT=/^width|height|top|right|bottom|left|margin.*|padding.*|border.*$/i;B.Anim.DEFAULT_UNIT="px";B.Anim.DEFAULT_EASING=function(Q,P,S,R){return S*Q/R+P;};B.Anim._intervalTime=20;B.Anim.behaviors={left:{get:function(Q,P){return Q._getOffset(P);}}};B.Anim.behaviors.top=B.Anim.behaviors.left;B.Anim.DEFAULT_SETTER=function(S,T,V,W,Y,R,U,X){var Q=S._node,P=U(Y,A(V),A(W)-A(V),R);if(T in Q._node.style||T in B.DOM.CUSTOM_STYLES){X=X||"";Q.setStyle(T,P+X);}else{if(Q._node.attributes[T]){Q.setAttribute(T,P);}else{Q.set(T,P);}}};B.Anim.DEFAULT_GETTER=function(R,P){var Q=R._node,S="";if(P in Q._node.style||P in B.DOM.CUSTOM_STYLES){S=Q.getComputedStyle(P);}else{if(Q._node.attributes[P]){S=Q.getAttribute(P);}else{S=Q.get(P);}}return S;};B.Anim.ATTRS={node:{setter:function(P){P=B.one(P);this._node=P;if(!P){}return P;}},duration:{value:1},easing:{value:B.Anim.DEFAULT_EASING,setter:function(P){if(typeof P==="string"&&B.Easing){return B.Easing[P];}}},from:{},to:{},startTime:{value:0,readOnly:true},elapsedTime:{value:0,readOnly:true},running:{getter:function(){return !!F[B.stamp(this)];},value:false,readOnly:true},iterations:{value:1},iterationCount:{value:0,readOnly:true},direction:{value:"normal"},paused:{readOnly:true,value:false},reverse:{value:false}};B.Anim.run=function(){var Q=B.Anim._instances;for(var P in Q){if(Q[P].run){Q[P].run();}}};B.Anim.pause=function(){for(var P in F){if(F[P].pause){F[P].pause();}}B.Anim._stopTimer();};B.Anim.stop=function(){for(var P in F){if(F[P].stop){F[P].stop();}}B.Anim._stopTimer();};B.Anim._startTimer=function(){if(!E){E=setInterval(B.Anim._runFrame,B.Anim._intervalTime);}};B.Anim._stopTimer=function(){clearInterval(E);E=0;};B.Anim._runFrame=function(){var P=true;for(var Q in F){if(F[Q]._runFrame){P=false;F[Q]._runFrame();}}if(P){B.Anim._stopTimer();}};B.Anim.RE_UNITS=/^(-?\d*\.?\d*){1}(em|ex|px|in|cm|mm|pt|pc|%)*$/;var G={run:function(){if(this.get(K)){this._resume();}else{if(!this.get(C)){this._start();}}return this;},pause:function(){if(this.get(C)){this._pause();}return this;},stop:function(P){if(this.get(C)||this.get(K)){this._end(P);}return this;},_added:false,_start:function(){this._set(N,new Date()-this.get(L));this._actualFrames=0;if(!this.get(K)){this._initAnimAttr();}F[B.stamp(this)]=this;B.Anim._startTimer();this.fire(J);},_pause:function(){this._set(N,null);this._set(K,true);delete F[B.stamp(this)];this.fire("pause");},_resume:function(){this._set(K,false);F[B.stamp(this)]=this;this._set(N,new Date()-this.get(L));B.Anim._startTimer();this.fire("resume");},_end:function(P){var Q=this.get("duration")*1000;if(P){this._runAttrs(Q,Q,this.get(O));}this._set(N,null);this._set(L,0);this._set(K,false);delete F[B.stamp(this)];this.fire(M,{elapsed:this.get(L)});},_runFrame:function(){var T=this._runtimeAttr.duration,R=new Date()-this.get(N),Q=this.get(O),P=(R>=T),S,U;this._runAttrs(R,T,Q);this._actualFrames+=1;this._set(L,R);this.fire(I);if(P){this._lastFrame();}},_runAttrs:function(Z,Y,V){var W=this._runtimeAttr,R=B.Anim.behaviors,X=W.easing,P=Y,T=false,Q,S,U;if(Z>=Y){T=true;}if(V){Z=Y-Z;P=0;}for(U in W){if(W[U].to){Q=W[U];S=(U in R&&"set" in R[U])?R[U].set:B.Anim.DEFAULT_SETTER;if(!T){S(this,U,Q.from,Q.to,Z,Y,X,Q.unit);}else{S(this,U,Q.from,Q.to,P,Y,X,Q.unit);}}}},_lastFrame:function(){var P=this.get("iterations"),Q=this.get(H);Q+=1;if(P==="infinite"||Q<P){if(this.get("direction")==="alternate"){this.set(O,!this.get(O));}this.fire("iteration");}else{Q=0;this._end();}this._set(N,new Date());this._set(H,Q);},_initAnimAttr:function(){var W=this.get("from")||{},V=this.get("to")||{},P={duration:this.get("duration")*1000,easing:this.get("easing")},R=B.Anim.behaviors,U=this.get(D),T,S,Q;B.each(V,function(a,Y){if(typeof a==="function"){a=a.call(this,U);}S=W[Y];if(S===undefined){S=(Y in R&&"get" in R[Y])?R[Y].get(this,Y):B.Anim.DEFAULT_GETTER(this,Y);}else{if(typeof S==="function"){S=S.call(this,U);}}var X=B.Anim.RE_UNITS.exec(S);var Z=B.Anim.RE_UNITS.exec(a);S=X?X[1]:S;Q=Z?Z[1]:a;T=Z?Z[2]:X?X[2]:"";if(!T&&B.Anim.RE_DEFAULT_UNIT.test(Y)){T=B.Anim.DEFAULT_UNIT;}if(!S||!Q){B.error('invalid "from" or "to" for "'+Y+'"',"Anim");return;}P[Y]={from:S,to:Q,unit:T};},this);this._runtimeAttr=P;},_getOffset:function(Q){var S=this._node,T=S.getComputedStyle(Q),R=(Q==="left")?"getX":"getY",U=(Q==="left")?"setX":"setY";if(T==="auto"){var P=S.getStyle("position");if(P==="absolute"||P==="fixed"){T=S[R]();S[U](T);}else{T=0;}}return T;},destructor:function(){delete B.Anim._instances[B.stamp(this)];}};B.extend(B.Anim,B.Base,G);},"3.2.0",{requires:["base-base","node-style"]});
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("anim-color",function(B){var A=Number;B.Anim.behaviors.color={set:function(F,D,I,H,C,G,E){I=B.Color.re_RGB.exec(B.Color.toRGB(I));H=B.Color.re_RGB.exec(B.Color.toRGB(H));if(!I||I.length<3||!H||H.length<3){B.error("invalid from or to passed to color behavior");}F._node.setStyle(D,"rgb("+[Math.floor(E(C,A(I[1]),A(H[1])-A(I[1]),G)),Math.floor(E(C,A(I[2]),A(H[2])-A(I[2]),G)),Math.floor(E(C,A(I[3]),A(H[3])-A(I[3]),G))].join(", ")+")");},get:function(D,C){var E=D._node.getComputedStyle(C);E=(E==="transparent")?"rgb(255, 255, 255)":E;return E;}};B.each(["backgroundColor","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"],function(C,D){B.Anim.behaviors[C]=B.Anim.behaviors.color;});},"3.2.0",{requires:["anim-base"]});
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("anim-curve",function(A){A.Anim.behaviors.curve={set:function(F,C,I,H,B,G,E){I=I.slice.call(I);H=H.slice.call(H);var D=E(B,0,100,G)/100;H.unshift(I);F._node.setXY(A.Anim.getBezier(H,D));},get:function(C,B){return C._node.getXY();}};A.Anim.getBezier=function(F,E){var G=F.length;var D=[];for(var C=0;C<G;++C){D[C]=[F[C][0],F[C][1]];}for(var B=1;B<G;++B){for(C=0;C<G-B;++C){D[C][0]=(1-E)*D[C][0]+E*D[parseInt(C+1,10)][0];D[C][1]=(1-E)*D[C][1]+E*D[parseInt(C+1,10)][1];}}return[D[0][0],D[0][1]];};},"3.2.0",{requires:["anim-xy"]});
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("anim-easing",function(B){var A={easeNone:function(D,C,F,E){return F*D/E+C;},easeIn:function(D,C,F,E){return F*(D/=E)*D+C;},easeOut:function(D,C,F,E){return -F*(D/=E)*(D-2)+C;},easeBoth:function(D,C,F,E){if((D/=E/2)<1){return F/2*D*D+C;}return -F/2*((--D)*(D-2)-1)+C;},easeInStrong:function(D,C,F,E){return F*(D/=E)*D*D*D+C;},easeOutStrong:function(D,C,F,E){return -F*((D=D/E-1)*D*D*D-1)+C;},easeBothStrong:function(D,C,F,E){if((D/=E/2)<1){return F/2*D*D*D*D+C;}return -F/2*((D-=2)*D*D*D-2)+C;},elasticIn:function(E,C,I,H,D,G){var F;if(E===0){return C;}if((E/=H)===1){return C+I;}if(!G){G=H*0.3;}if(!D||D<Math.abs(I)){D=I;F=G/4;}else{F=G/(2*Math.PI)*Math.asin(I/D);}return -(D*Math.pow(2,10*(E-=1))*Math.sin((E*H-F)*(2*Math.PI)/G))+C;},elasticOut:function(E,C,I,H,D,G){var F;if(E===0){return C;}if((E/=H)===1){return C+I;}if(!G){G=H*0.3;}if(!D||D<Math.abs(I)){D=I;F=G/4;}else{F=G/(2*Math.PI)*Math.asin(I/D);}return D*Math.pow(2,-10*E)*Math.sin((E*H-F)*(2*Math.PI)/G)+I+C;},elasticBoth:function(E,C,I,H,D,G){var F;if(E===0){return C;}if((E/=H/2)===2){return C+I;}if(!G){G=H*(0.3*1.5);}if(!D||D<Math.abs(I)){D=I;F=G/4;}else{F=G/(2*Math.PI)*Math.asin(I/D);}if(E<1){return -0.5*(D*Math.pow(2,10*(E-=1))*Math.sin((E*H-F)*(2*Math.PI)/G))+C;}return D*Math.pow(2,-10*(E-=1))*Math.sin((E*H-F)*(2*Math.PI)/G)*0.5+I+C;},backIn:function(D,C,G,F,E){if(E===undefined){E=1.70158;}if(D===F){D-=0.001;}return G*(D/=F)*D*((E+1)*D-E)+C;},backOut:function(D,C,G,F,E){if(typeof E==="undefined"){E=1.70158;}return G*((D=D/F-1)*D*((E+1)*D+E)+1)+C;},backBoth:function(D,C,G,F,E){if(typeof E==="undefined"){E=1.70158;}if((D/=F/2)<1){return G/2*(D*D*(((E*=(1.525))+1)*D-E))+C;}return G/2*((D-=2)*D*(((E*=(1.525))+1)*D+E)+2)+C;},bounceIn:function(D,C,F,E){return F-B.Easing.bounceOut(E-D,0,F,E)+C;},bounceOut:function(D,C,F,E){if((D/=E)<(1/2.75)){return F*(7.5625*D*D)+C;}else{if(D<(2/2.75)){return F*(7.5625*(D-=(1.5/2.75))*D+0.75)+C;}else{if(D<(2.5/2.75)){return F*(7.5625*(D-=(2.25/2.75))*D+0.9375)+C;}}}return F*(7.5625*(D-=(2.625/2.75))*D+0.984375)+C;},bounceBoth:function(D,C,F,E){if(D<E/2){return B.Easing.bounceIn(D*2,0,F,E)*0.5+C;}return B.Easing.bounceOut(D*2-E,0,F,E)*0.5+F*0.5+C;}};B.Easing=A;},"3.2.0",{requires:["anim-base"]});
|
||||
Vendored
-9
File diff suppressed because one or more lines are too long
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("anim-node-plugin",function(B){var A=function(C){C=(C)?B.merge(C):{};C.node=C.host;A.superclass.constructor.apply(this,arguments);};A.NAME="nodefx";A.NS="fx";B.extend(A,B.Anim);B.namespace("Plugin");B.Plugin.NodeFX=A;},"3.2.0",{requires:["node-pluginhost","anim-base"]});
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("anim-scroll",function(B){var A=Number;B.Anim.behaviors.scroll={set:function(F,G,I,J,K,E,H){var D=F._node,C=([H(K,A(I[0]),A(J[0])-A(I[0]),E),H(K,A(I[1]),A(J[1])-A(I[1]),E)]);if(C[0]){D.set("scrollLeft",C[0]);}if(C[1]){D.set("scrollTop",C[1]);}},get:function(D){var C=D._node;return[C.get("scrollLeft"),C.get("scrollTop")];}};},"3.2.0",{requires:["anim-base"]});
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("anim-xy",function(B){var A=Number;B.Anim.behaviors.xy={set:function(F,D,I,H,C,G,E){F._node.setXY([E(C,A(I[0]),A(H[0])-A(I[0]),G),E(C,A(I[1]),A(H[1])-A(I[1]),G)]);},get:function(C){return C._node.getXY();}};},"3.2.0",{requires:["anim-base","node-screen"]});
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-skin-sam .yui3-separate-console{position:absolute;right:1em;top:1em;z-index:999;}.yui3-skin-sam .yui3-inline-console{display:-moz-inline-stack;display:inline-block;*display:inline;zoom:1;vertical-align:top;}.yui3-skin-sam .yui3-inline-console .yui3-console-content{position:relative;}.yui3-skin-sam .yui3-console-content{background:#777;_background:#D8D8DA url(bg.png) repeat-x 0 0;font:normal 13px/1.3 Arial,sans-serif;text-align:left;border:1px solid #777;border-radius:10px;-moz-border-radius:10px;-webkit-border-radius:10px;}.yui3-skin-sam .yui3-console-hd,.yui3-skin-sam .yui3-console-bd,.yui3-skin-sam .yui3-console-ft{position:relative;}.yui3-skin-sam .yui3-console-hd,.yui3-skin-sam .yui3-console-ft .yui3-console-controls{text-align:right;}.yui3-skin-sam .yui3-console-hd{background:#D8D8DA url(bg.png) repeat-x 0 0;padding:1ex;border:1px solid transparent;_border:0 none;border-top-right-radius:10px;border-top-left-radius:10px;-moz-border-radius-topright:10px;-moz-border-radius-topleft:10px;-webkit-border-top-right-radius:10px;-webkit-border-top-left-radius:10px;}.yui3-skin-sam .yui3-console-bd{background:#fff;border-top:1px solid #777;border-bottom:1px solid #777;color:#000;font-size:11px;overflow:auto;overflow-x:auto;overflow-y:scroll;_width:100%;}.yui3-skin-sam .yui3-console-ft{background:#D8D8DA url(bg.png) repeat-x 0 0;border:1px solid transparent;_border:0 none;border-bottom-right-radius:10px;border-bottom-left-radius:10px;-moz-border-radius-bottomright:10px;-moz-border-radius-bottomleft:10px;-webkit-border-bottom-right-radius:10px;-webkit-border-bottom-left-radius:10px;}.yui3-skin-sam .yui3-console-controls{padding:4px 1ex;zoom:1;}.yui3-skin-sam .yui3-console-title{color:#000;display:inline;float:left;font-weight:bold;font-size:13px;height:24px;line-height:24px;margin:0;padding-left:1ex;}.yui3-skin-sam .yui3-console-pause-label{float:left;}.yui3-skin-sam .yui3-console-button{line-height:1.3;}.yui3-skin-sam .yui3-console-collapsed .yui3-console-bd,.yui3-skin-sam .yui3-console-collapsed .yui3-console-ft{display:none;}.yui3-skin-sam .yui3-console-content.yui3-console-collapsed{-webkit-border-radius:0;}.yui3-skin-sam .yui3-console-collapsed .yui3-console-hd{border-radius:10px;-moz-border-radius:10px;-webkit-border-radius:0;}.yui3-skin-sam .yui3-console-entry{border-bottom:1px solid #aaa;min-height:32px;_height:32px;}.yui3-skin-sam .yui3-console-entry-meta{margin:0;overflow:hidden;}.yui3-skin-sam .yui3-console-entry-content{margin:0;padding:0 1ex;white-space:pre-wrap;word-wrap:break-word;}.yui3-skin-sam .yui3-console-entry-meta .yui3-console-entry-src{color:#000;font-style:italic;font-weight:bold;float:right;margin:2px 5px 0 0;}.yui3-skin-sam .yui3-console-entry-meta .yui3-console-entry-time{color:#777;padding-left:1ex;}.yui3-skin-sam .yui3-console-entry-warn .yui3-console-entry-meta .yui3-console-entry-time{color:#555;}.yui3-skin-sam .yui3-console-entry-info .yui3-console-entry-meta .yui3-console-entry-cat,.yui3-skin-sam .yui3-console-entry-warn .yui3-console-entry-meta .yui3-console-entry-cat,.yui3-skin-sam .yui3-console-entry-error .yui3-console-entry-meta .yui3-console-entry-cat{display:none;}.yui3-skin-sam .yui3-console-entry-warn{background:#aee url(warn_error.png) no-repeat -15px 15px;}.yui3-skin-sam .yui3-console-entry-error{background:#ffa url(warn_error.png) no-repeat 5px -24px;color:#900;}.yui3-skin-sam .yui3-console-entry-warn .yui3-console-entry-content,.yui3-skin-sam .yui3-console-entry-error .yui3-console-entry-content{padding-left:24px;}.yui3-skin-sam .yui3-console-entry-cat{text-transform:uppercase;padding:1px 4px;background-color:#ccc;}.yui3-skin-sam .yui3-console-entry-info .yui3-console-entry-cat{background-color:#ac2;}.yui3-skin-sam .yui3-console-entry-warn .yui3-console-entry-cat{background-color:#e81;}.yui3-skin-sam .yui3-console-entry-error .yui3-console-entry-cat{background-color:#b00;color:#fff;}.yui3-skin-sam .yui3-console-hidden{display:none;}
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-flick{position:relative;overflow:hidden;}.yui3-flick-content{position:relative;}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-overlay{position:absolute;}.yui3-overlay-hidden{visibility:hidden;}.yui3-widget-tmp-forcesize .yui3-overlay-content{overflow:hidden!important;}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 92 B |
Binary file not shown.
|
Before Width: | Height: | Size: 90 B |
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-scrollview{position:relative;overflow:hidden;-webkit-user-select:none;-moz-user-select:none;}.yui3-scrollview-hidden{display:none;}.yui3-scrollview-content{position:relative;}.yui3-scrollview .yui3-scrollview-content ul{margin:0;padding:0;}.yui3-scrollview-vert .yui3-scrollview-content ul{*zoom:1;}.yui3-scrollview-content li{padding:0;margin:0;list-style:none;display:-moz-inline-stack;display:inline-block;*display:inline;*zoom:1;width:100%;}.yui-skin-sam .yui3-scrollview{-webkit-tap-highlight-color:rgba(0,0,0,0);}.yui-skin-sam .yui3-scrollview li{background-color:#fff;}
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-scrollview-paginator{width:100%;height:100%;text-align:center;}.yui3-scrollview-paginator-page{display:inline-block;width:6px;height:6px;}.yui-skin-sam .yui3-scrollview-paginator{-webkit-tap-highlight-color:rgba(0,0,0,0);-moz-tap-highlight-color:rgba(0,0,0,0);}.yui-skin-sam .yui3-scrollview-paginator-page{background:#666;margin-right:8px;-webkit-border-radius:2px;-moz-border-radius:2px;}.yui-skin-sam .yui3-scrollview-paginator-page.yui3-scrollview-active{background:#fff;}
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-scrollview-scrollbar{opacity:1;position:absolute;width:6px;height:10px;}.yui3-scrollview-scrollbar{top:0;right:1px;}.yui3-scrollview-scrollbar-horiz{top:auto;height:8px;width:20px;bottom:1px;left:0;}.yui3-scrollview-scrollbar .yui3-scrollview-child{position:absolute;right:0;display:block;width:100%;height:4px;}.yui3-scrollview-scrollbar .yui3-scrollview-first{top:0;}.yui3-scrollview-scrollbar .yui3-scrollview-last{top:0;}.yui3-scrollview-scrollbar .yui3-scrollview-middle{position:absolute;top:4px;height:1px;}.yui3-scrollview-scrollbar-horiz .yui3-scrollview-child{display:-moz-inline-stack;display:inline-block;zoom:1;*display:inline;top:0;left:0;bottom:auto;right:auto;}.yui3-scrollview-scrollbar-horiz .yui3-scrollview-first,.yui3-scrollview-scrollbar-horiz .yui3-scrollview-last{width:4px;height:6px;}.yui3-scrollview-scrollbar-horiz .yui3-scrollview-middle{top:0;left:4px;width:1px;height:6px;}.yui3-scrollview-scrollbar-vert-basic{height:auto;}.yui3-scrollview-scrollbar-vert-basic .yui3-scrollview-child{position:static;_overflow:hidden;_line-height:4px;}.yui3-scrollview-scrollbar-horiz-basic{width:auto;white-space:nowrap;line-height:6px;_overflow:hidden;}.yui3-scrollview-scrollbar-horiz-basic .yui3-scrollview-child{position:static;padding:0;margin:0;top:auto;left:auto;right:auto;bottom:auto;}.yui-skin-sam .yui3-scrollview-scrollbar{-webkit-transform:translate3d(0,0,0);-moz-transform:translate3d(0,0,0);}.yui-skin-sam .yui3-scrollview-scrollbar .yui3-scrollview-first,.yui-skin-sam .yui3-scrollview-scrollbar .yui3-scrollview-middle,.yui-skin-sam .yui3-scrollview-scrollbar .yui3-scrollview-last{-webkit-border-radius:3px;-moz-border-radius:3px;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAABCAYAAAD9yd/wAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABJJREFUeNpiZGBgSGPAAgACDAAIkABoFyloZQAAAABJRU5ErkJggg==);}.yui-skin-sam .yui3-scrollview-scrollbar .yui3-scrollview-first,.yui-skin-sam .yui3-scrollview-scrollbar .yui3-scrollview-last{-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;}.yui-skin-sam .yui3-scrollview-scrollbar .yui3-scrollview-last{-webkit-border-radius:0;-webkit-border-bottom-right-radius:3px;-webkit-border-bottom-left-radius:3px;-webkit-transform:translate3d(0,0,0);-moz-border-radius:0;-moz-border-radius-bottomright:3px;-moz-border-radius-bottomleft:3px;-moz-transform:translate3d(0,0,0);}.yui-skin-sam .yui3-scrollview-scrollbar .yui3-scrollview-middle{-webkit-border-radius:0;-moz-border-radius:0;-webkit-transform:translate3d(0,0,0) scaleY(1);-webkit-transform-origin-y:0;-moz-transform:translate3d(0,0,0) scaleY(1);-moz-transform-origin-y:0;}.yui-skin-sam .yui3-scrollview-scrollbar-horiz .yui3-scrollview-first,.yui-skin-sam .yui3-scrollview-scrollbar-horiz .yui3-scrollview-last{-webkit-border-top-right-radius:0;-webkit-border-bottom-left-radius:3px;-moz-border-radius-topright:0;-moz-border-radius-bottomleft:3px;}.yui-skin-sam .yui3-scrollview-scrollbar-horiz .yui3-scrollview-last{-webkit-border-bottom-left-radius:0;-webkit-border-top-right-radius:3px;-moz-border-radius-bottomleft:0;-moz-border-radius-topright:3px;}.yui-skin-sam .yui3-scrollview-scrollbar-horiz .yui3-scrollview-middle{-webkit-transform:translate3d(0,0,0) scaleX(1);-webkit-transform-origin:0;-moz-transform:translate3d(0,0,0) scaleX(1);-moz-transform-origin:0;}.yui-skin-sam .yui3-scrollview-scrollbar-vert-basic .yui3-scrollview-child,.yui-skin-sam .yui3-scrollview-scrollbar-horiz-basic .yui3-scrollview-child{background-color:#aaa;background-image:none;}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-slider,.yui3-slider-rail{display:-moz-inline-stack;display:inline-block;*display:inline;zoom:1;vertical-align:middle;}.yui3-slider-content{position:relative;display:block;}.yui3-slider-rail{position:relative;}.yui3-slider-rail-cap-top,.yui3-slider-rail-cap-left,.yui3-slider-rail-cap-bottom,.yui3-slider-rail-cap-right,.yui3-slider-thumb,.yui3-slider-thumb-image,.yui3-slider-thumb-shadow{position:absolute;}.yui3-slider-thumb{overflow:hidden;}.yui3-skin-sam .yui3-slider-x .yui3-slider-rail,.yui3-skin-sam .yui3-slider-x .yui3-slider-rail-cap-left,.yui3-skin-sam .yui3-slider-x .yui3-slider-rail-cap-right{background-image:url(rail-x.png);background-repeat:repeat-x;}.yui3-skin-sam .yui3-slider-x .yui3-slider-rail{height:26px;}.yui3-skin-sam .yui3-slider-x .yui3-slider-thumb{height:26px;width:15px;}.yui3-skin-sam .yui3-slider-x .yui3-slider-rail-cap-left{background-position:0 -20px;height:20px;left:-2px;width:5px;}.yui3-skin-sam .yui3-slider-x .yui3-slider-rail-cap-right{background-position:0 -40px;height:20px;right:-2px;width:5px;}.yui3-skin-sam .yui3-slider-x .yui3-slider-thumb-image{left:0;top:-10px;}.yui3-skin-sam .yui3-slider-x .yui3-slider-thumb-shadow{left:0;opacity:.15;filter:alpha(opacity=15);top:-50px;}.yui3-skin-sam .yui3-slider-y .yui3-slider-rail,.yui3-skin-sam .yui3-slider-y .yui3-slider-rail-cap-top,.yui3-skin-sam .yui3-slider-y .yui3-slider-rail-cap-bottom{background-image:url(rail-y.png);background-repeat:repeat-y;}.yui3-skin-sam .yui3-slider-y .yui3-slider-rail{width:26px;}.yui3-skin-sam .yui3-slider-y .yui3-slider-thumb{width:26px;height:15px;}.yui3-skin-sam .yui3-slider-y .yui3-slider-rail-cap-top{background-position:-20px 0;width:20px;top:-2px;height:5px;}.yui3-skin-sam .yui3-slider-y .yui3-slider-rail-cap-bottom{background-position:-40px 0;width:20px;bottom:-2px;height:5px;}.yui3-skin-sam .yui3-slider-y .yui3-slider-thumb-image{left:-10px;top:0;}.yui3-skin-sam .yui3-slider-y .yui3-slider-thumb-shadow{left:-50px;opacity:.15;filter:alpha(opacity=15);top:0;}
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-slider,.yui3-slider-rail{display:-moz-inline-stack;display:inline-block;*display:inline;zoom:1;vertical-align:middle;}.yui3-slider-content{position:relative;display:block;}.yui3-slider-rail{position:relative;}.yui3-slider-rail-cap-top,.yui3-slider-rail-cap-left,.yui3-slider-rail-cap-bottom,.yui3-slider-rail-cap-right,.yui3-slider-thumb,.yui3-slider-thumb-image,.yui3-slider-thumb-shadow{position:absolute;}.yui3-slider-thumb{overflow:hidden;}.yui3-skin-sam .yui3-slider-x .yui3-slider-rail,.yui3-skin-sam .yui3-slider-x .yui3-slider-rail-cap-left,.yui3-skin-sam .yui3-slider-x .yui3-slider-rail-cap-right{background-image:url(rail-x.png);background-repeat:repeat-x;}.yui3-skin-sam .yui3-slider-x .yui3-slider-rail{height:26px;}.yui3-skin-sam .yui3-slider-x .yui3-slider-thumb{height:26px;width:15px;}.yui3-skin-sam .yui3-slider-x .yui3-slider-rail-cap-left{background-position:0 -20px;height:20px;left:-2px;width:5px;}.yui3-skin-sam .yui3-slider-x .yui3-slider-rail-cap-right{background-position:0 -40px;height:20px;right:-2px;width:5px;}.yui3-skin-sam .yui3-slider-x .yui3-slider-thumb-image{left:0;top:-10px;}.yui3-skin-sam .yui3-slider-x .yui3-slider-thumb-shadow{left:0;opacity:.15;filter:alpha(opacity=15);top:-50px;}.yui3-skin-sam .yui3-slider-y .yui3-slider-rail,.yui3-skin-sam .yui3-slider-y .yui3-slider-rail-cap-top,.yui3-skin-sam .yui3-slider-y .yui3-slider-rail-cap-bottom{background-image:url(rail-y.png);background-repeat:repeat-y;}.yui3-skin-sam .yui3-slider-y .yui3-slider-rail{width:26px;}.yui3-skin-sam .yui3-slider-y .yui3-slider-thumb{width:26px;height:15px;}.yui3-skin-sam .yui3-slider-y .yui3-slider-rail-cap-top{background-position:-20px 0;width:20px;top:-2px;height:5px;}.yui3-skin-sam .yui3-slider-y .yui3-slider-rail-cap-bottom{background-position:-40px 0;width:20px;bottom:-2px;height:5px;}.yui3-skin-sam .yui3-slider-y .yui3-slider-thumb-image{left:-10px;top:0;}.yui3-skin-sam .yui3-slider-y .yui3-slider-thumb-shadow{left:-50px;opacity:.15;filter:alpha(opacity=15);top:0;}
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-tab-panel{display:none;}.yui3-tab-panel-selected{display:block;}.yui3-tabview-list,.yui3-tab{margin:0;padding:0;list-style:none;}.yui3-tabview{position:relative;}.yui3-tabview,.yui3-tabview-list,.yui3-tabview-panel,.yui3-tab,.yui3-tab-panel{zoom:1;}.yui3-tab{display:inline-block;*display:inline;vertical-align:bottom;cursor:pointer;}.yui3-tab-label{display:block;display:inline-block;padding:6px 10px;position:relative;text-decoration:none;vertical-align:bottom;}.yui3-skin-sam .yui3-tabview-list{border:solid #2647a0;border-width:0 0 5px;zoom:1;}.yui3-skin-sam .yui3-tab{margin:0 .2em 0 0;padding:1px 0 0;zoom:1;}.yui3-skin-sam .yui3-tab-selected{margin-bottom:-1px;}.yui3-skin-sam .yui3-tab-label{background:#d8d8d8 url(sprite.png) repeat-x;border:solid #a3a3a3;border-width:1px 1px 0 1px;color:#000;cursor:hand;font-size:85%;padding:.3em .75em;text-decoration:none;}.yui3-skin-sam .yui3-tab-label:hover,.yui3-skin-sam .yui3-tab-label:focus{background:#bfdaff url(sprite.png) repeat-x left -1300px;outline:0;}.yui3-skin-sam .yui3-tab-selected .yui3-tab-label,.yui3-skin-sam .yui3-tab-selected .yui3-tab-label:focus,.yui3-skin-sam .yui3-tab-selected .yui3-tab-label:hover{background:#2647a0 url(sprite.png) repeat-x left -1400px;color:#fff;}.yui3-skin-sam .yui3-tab-selected .yui3-tab-label{padding:.4em .75em;}.yui3-skin-sam .yui3-tab-selected .yui3-tab-label{border-color:#243356;}.yui3-skin-sam .yui3-tabview-panel{background:#edf5ff;}.yui3-skin-sam .yui3-tabview-panel{border:1px solid #808080;border-top-color:#243356;padding:.25em .5em;}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 374 B |
Binary file not shown.
|
Before Width: | Height: | Size: 341 B |
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-widget-hidden{display:none;}.yui3-widget-content{overflow:hidden;}.yui3-widget-content-expanded{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;height:100%;}.yui3-widget-tmp-forcesize{overflow:hidden!important;}
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-widget-stacked .yui3-widget-shim{opacity:0;filter:alpha(opacity=0);position:absolute;border:none;top:0;left:0;padding:0;margin:0;z-index:-1;width:100%;height:100%;_width:0;_height:0;}
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-widget-hidden{display:none;}.yui3-widget-content{overflow:hidden;}.yui3-widget-content-expanded{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;height:100%;}.yui3-widget-tmp-forcesize{overflow:hidden!important;}
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("async-queue",function(G){G.AsyncQueue=function(){this._init();this.add.apply(this,arguments);};var E=G.AsyncQueue,C="execute",B="shift",D="promote",H="remove",A=G.Lang.isObject,F=G.Lang.isFunction;E.defaults=G.mix({autoContinue:true,iterations:1,timeout:10,until:function(){this.iterations|=0;return this.iterations<=0;}},G.config.queueDefaults||{});G.extend(E,G.EventTarget,{_running:false,_init:function(){G.EventTarget.call(this,{emitFacade:true});this._q=[];this.defaults={};this._initEvents();},_initEvents:function(){this.publish({"execute":{defaultFn:this._defExecFn,emitFacade:true},"shift":{defaultFn:this._defShiftFn,emitFacade:true},"add":{defaultFn:this._defAddFn,emitFacade:true},"promote":{defaultFn:this._defPromoteFn,emitFacade:true},"remove":{defaultFn:this._defRemoveFn,emitFacade:true}});},next:function(){var I;while(this._q.length){I=this._q[0]=this._prepare(this._q[0]);if(I&&I.until()){this.fire(B,{callback:I});I=null;}else{break;}}return I||null;},_defShiftFn:function(I){if(this.indexOf(I.callback)===0){this._q.shift();}},_prepare:function(K){if(F(K)&&K._prepared){return K;}var I=G.merge(E.defaults,{context:this,args:[],_prepared:true},this.defaults,(F(K)?{fn:K}:K)),J=G.bind(function(){if(!J._running){J.iterations--;}if(F(J.fn)){J.fn.apply(J.context||G,G.Array(J.args));}},this);return G.mix(J,I);},run:function(){var J,I=true;for(J=this.next();I&&J&&!this.isRunning();J=this.next()){I=(J.timeout<0)?this._execute(J):this._schedule(J);}if(!J){this.fire("complete");}return this;},_execute:function(J){this._running=J._running=true;J.iterations--;this.fire(C,{callback:J});var I=this._running&&J.autoContinue;this._running=J._running=false;return I;},_schedule:function(I){this._running=G.later(I.timeout,this,function(){if(this._execute(I)){this.run();}});return false;},isRunning:function(){return !!this._running;},_defExecFn:function(I){I.callback();},add:function(){this.fire("add",{callbacks:G.Array(arguments,0,true)});return this;},_defAddFn:function(J){var K=this._q,I=[];G.Array.each(J.callbacks,function(L){if(A(L)){K.push(L);I.push(L);}});J.added=I;},pause:function(){if(A(this._running)){this._running.cancel();}this._running=false;return this;},stop:function(){this._q=[];return this.pause();},indexOf:function(L){var J=0,I=this._q.length,K;for(;J<I;++J){K=this._q[J];if(K===L||K.id===L){return J;}}return -1;},getCallback:function(J){var I=this.indexOf(J);return(I>-1)?this._q[I]:null;},promote:function(K){var J={callback:K},I;if(this.isRunning()){I=this.after(B,function(){this.fire(D,J);I.detach();},this);}else{this.fire(D,J);}return this;},_defPromoteFn:function(K){var I=this.indexOf(K.callback),J=(I>-1)?this._q.splice(I,1)[0]:null;K.promoted=J;if(J){this._q.unshift(J);}},remove:function(K){var J={callback:K},I;if(this.isRunning()){I=this.after(B,function(){this.fire(H,J);I.detach();},this);}else{this.fire(H,J);}return this;},_defRemoveFn:function(J){var I=this.indexOf(J.callback);J.removed=(I>-1)?this._q.splice(I,1)[0]:null;},size:function(){if(!this.isRunning()){this.next();}return this._q.length;}});},"3.2.0",{requires:["event-custom"]});
|
||||
File diff suppressed because one or more lines are too long
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("attribute-complex",function(B){var A=B.Object,C=".";B.Attribute.Complex=function(){};B.Attribute.Complex.prototype={_normAttrVals:function(G){var I={},H={},J,D,F,E;if(G){for(E in G){if(G.hasOwnProperty(E)){if(E.indexOf(C)!==-1){J=E.split(C);D=J.shift();F=H[D]=H[D]||[];F[F.length]={path:J,value:G[E]};}else{I[E]=G[E];}}}return{simple:I,complex:H};}else{return null;}},_getAttrInitVal:function(K,I,N){var E=I.value,M=I.valueFn,D,F,H,G,O,L,J;if(M){if(!M.call){M=this[M];}if(M){E=M.call(this);}}if(!I.readOnly&&N){D=N.simple;if(D&&D.hasOwnProperty(K)){E=D[K];}F=N.complex;if(F&&F.hasOwnProperty(K)){J=F[K];for(H=0,G=J.length;H<G;++H){O=J[H].path;L=J[H].value;A.setValue(E,O,L);}}}return E;}};B.mix(B.Attribute,B.Attribute.Complex,true,null,1);},"3.2.0",{requires:["attribute-base"]});
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("base-base",function(B){var I=B.Object,K=B.Lang,J=".",G="destroy",R="init",Q="initialized",H="destroyed",D="initializer",N="bubbleTargets",E="_bubbleTargets",C=Object.prototype.constructor,M="deep",S="shallow",P="destructor",A=B.Attribute;function F(){A.call(this);var L=B.Plugin&&B.Plugin.Host;if(this._initPlugins&&L){L.call(this);}if(this._lazyAddAttrs!==false){this._lazyAddAttrs=true;}this.name=this.constructor.NAME;this._eventPrefix=this.constructor.EVENT_PREFIX||this.constructor.NAME;this.init.apply(this,arguments);}F._ATTR_CFG=A._ATTR_CFG.concat("cloneDefaultValue");F.NAME="base";F.ATTRS={initialized:{readOnly:true,value:false},destroyed:{readOnly:true,value:false}};F.prototype={init:function(L){this._yuievt.config.prefix=this._eventPrefix;this.publish(R,{queuable:false,fireOnce:true,defaultTargetOnly:true,defaultFn:this._defInitFn});this._preInitEventCfg(L);this.fire(R,{cfg:L});return this;},_preInitEventCfg:function(O){if(O){if(O.on){this.on(O.on);}if(O.after){this.after(O.after);}}var T,L,V,U=(O&&N in O);if(U||E in this){V=U?(O&&O.bubbleTargets):this._bubbleTargets;if(K.isArray(V)){for(T=0,L=V.length;T<L;T++){this.addTarget(V[T]);}}else{if(V){this.addTarget(V);}}}},destroy:function(){this.publish(G,{queuable:false,fireOnce:true,defaultTargetOnly:true,defaultFn:this._defDestroyFn});this.fire(G);this.detachAll();return this;},_defInitFn:function(L){this._initHierarchy(L.cfg);if(this._initPlugins){this._initPlugins(L.cfg);}this._set(Q,true);},_defDestroyFn:function(L){this._destroyHierarchy();if(this._destroyPlugins){this._destroyPlugins();}this._set(H,true);},_getClasses:function(){if(!this._classes){this._initHierarchyData();}return this._classes;},_getAttrCfgs:function(){if(!this._attrs){this._initHierarchyData();}return this._attrs;},_filterAttrCfgs:function(V,O){var T=null,L,U=V.ATTRS;if(U){for(L in U){if(U.hasOwnProperty(L)&&O[L]){T=T||{};T[L]=O[L];delete O[L];}}}return T;},_initHierarchyData:function(){var T=this.constructor,O=[],L=[];while(T){O[O.length]=T;if(T.ATTRS){L[L.length]=T.ATTRS;}T=T.superclass?T.superclass.constructor:null;}this._classes=O;this._attrs=this._aggregateAttrs(L);},_aggregateAttrs:function(Y){var V,Z,U,L,a,O,X,T=F._ATTR_CFG,W={};if(Y){for(O=Y.length-1;O>=0;--O){Z=Y[O];for(V in Z){if(Z.hasOwnProperty(V)){U=B.mix({},Z[V],true,T);L=U.value;X=U.cloneDefaultValue;if(L){if((X===undefined&&(C===L.constructor||K.isArray(L)))||X===M||X===true){U.value=B.clone(L);}else{if(X===S){U.value=B.merge(L);}}}a=null;if(V.indexOf(J)!==-1){a=V.split(J);V=a.shift();}if(a&&W[V]&&W[V].value){I.setValue(W[V].value,a,L);}else{if(!a){if(!W[V]){W[V]=U;}else{B.mix(W[V],U,true,T);}}}}}}}return W;},_initHierarchy:function(W){var T=this._lazyAddAttrs,X,Y,Z,U,O,V=this._getClasses(),L=this._getAttrCfgs();for(Z=V.length-1;Z>=0;Z--){X=V[Z];Y=X.prototype;if(X._yuibuild&&X._yuibuild.exts){for(U=0,O=X._yuibuild.exts.length;U<O;U++){X._yuibuild.exts[U].apply(this,arguments);}}this.addAttrs(this._filterAttrCfgs(X,L),W,T);if(Y.hasOwnProperty(D)){Y.initializer.apply(this,arguments);}}},_destroyHierarchy:function(){var V,O,U,L,T=this._getClasses();for(U=0,L=T.length;U<L;U++){V=T[U];O=V.prototype;if(O.hasOwnProperty(P)){O.destructor.apply(this,arguments);}}},toString:function(){return this.constructor.NAME+"["+B.stamp(this)+"]";}};B.mix(F,A,false,null,1);F.prototype.constructor=F;B.Base=F;},"3.2.0",{requires:["attribute-base"]});
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("base-build",function(D){var B=D.Base,A=D.Lang,C;B._build=function(F,L,P,T,S,O){var U=B._build,G=U._ctor(L,O),J=U._cfg(L,O),R=U._mixCust,N=J.aggregates,E=J.custom,I=G._yuibuild.dynamic,M,K,H,Q;if(I&&N){for(M=0,K=N.length;M<K;++M){H=N[M];if(L.hasOwnProperty(H)){G[H]=A.isArray(L[H])?[]:{};}}}for(M=0,K=P.length;M<K;M++){Q=P[M];D.mix(G,Q,true,null,1);R(G,Q,N,E);G._yuibuild.exts.push(Q);}if(T){D.mix(G.prototype,T,true);}if(S){D.mix(G,U._clean(S,N,E),true);R(G,S,N,E);}G.prototype.hasImpl=U._impl;if(I){G.NAME=F;G.prototype.constructor=G;}return G;};C=B._build;D.mix(C,{_mixCust:function(G,F,I,H){if(I){D.aggregate(G,F,true,I);}if(H){for(var E in H){if(H.hasOwnProperty(E)){H[E](E,G,F);}}}},_tmpl:function(E){function F(){F.superclass.constructor.apply(this,arguments);}D.extend(F,E);return F;},_impl:function(H){var K=this._getClasses(),J,F,E,I,L,G;for(J=0,F=K.length;J<F;J++){E=K[J];if(E._yuibuild){I=E._yuibuild.exts;L=I.length;for(G=0;G<L;G++){if(I[G]===H){return true;}}}}return false;},_ctor:function(E,F){var G=(F&&false===F.dynamic)?false:true,H=(G)?C._tmpl(E):E;H._yuibuild={id:null,exts:[],dynamic:G};return H;},_cfg:function(E,F){var G=[],J={},I,H=(F&&F.aggregates),L=(F&&F.custom),K=E;while(K&&K.prototype){I=K._buildCfg;if(I){if(I.aggregates){G=G.concat(I.aggregates);}if(I.custom){D.mix(J,I.custom,true);}}K=K.superclass?K.superclass.constructor:null;}if(H){G=G.concat(H);}if(L){D.mix(J,F.cfgBuild,true);}return{aggregates:G,custom:J};},_clean:function(K,J,G){var I,F,E,H=D.merge(K);for(I in G){if(H.hasOwnProperty(I)){delete H[I];}}for(F=0,E=J.length;F<E;F++){I=J[F];if(H.hasOwnProperty(I)){delete H[I];}}return H;}});B.build=function(G,E,H,F){return C(G,E,H,null,null,F);};B.create=function(E,H,G,F,I){return C(E,H,G,F,I);};B.mix=function(E,F){return C(null,E,F,null,null,{dynamic:false});};B._buildCfg={custom:{ATTRS:function(J,H,F){H.ATTRS=H.ATTRS||{};if(F.ATTRS){var G=F.ATTRS,I=H.ATTRS,E;for(E in G){if(G.hasOwnProperty(E)){I[E]=I[E]||{};D.mix(I[E],G[E],true);}}}}},aggregates:["_PLUG","_UNPLUG"]};},"3.2.0",{requires:["base-base"]});
|
||||
@@ -1,930 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('base-base', function(Y) {
|
||||
|
||||
/**
|
||||
* The base module provides the Base class, which objects requiring attribute and custom event support can extend.
|
||||
* The module also provides two ways to reuse code - It augments Base with the Plugin.Host interface which provides
|
||||
* plugin support and also provides the Base.build method which provides a way to build custom classes using extensions.
|
||||
*
|
||||
* @module base
|
||||
*/
|
||||
|
||||
/**
|
||||
* The base-base submodule provides the Base class without the Plugin support, provided by Plugin.Host,
|
||||
* and without the extension support provided by Base.build.
|
||||
*
|
||||
* @module base
|
||||
* @submodule base-base
|
||||
*/
|
||||
var O = Y.Object,
|
||||
L = Y.Lang,
|
||||
DOT = ".",
|
||||
DESTROY = "destroy",
|
||||
INIT = "init",
|
||||
INITIALIZED = "initialized",
|
||||
DESTROYED = "destroyed",
|
||||
INITIALIZER = "initializer",
|
||||
BUBBLETARGETS = "bubbleTargets",
|
||||
_BUBBLETARGETS = "_bubbleTargets",
|
||||
OBJECT_CONSTRUCTOR = Object.prototype.constructor,
|
||||
DEEP = "deep",
|
||||
SHALLOW = "shallow",
|
||||
DESTRUCTOR = "destructor",
|
||||
|
||||
Attribute = Y.Attribute;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* A base class which objects requiring attributes and custom event support can
|
||||
* extend. Base also handles the chaining of initializer and destructor methods across
|
||||
* the hierarchy as part of object construction and destruction. Additionally, attributes configured
|
||||
* through the static <a href="#property_Base.ATTRS">ATTRS</a> property for each class
|
||||
* in the hierarchy will be initialized by Base.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* The static <a href="#property_Base.NAME">NAME</a> property of each class extending
|
||||
* from Base will be used as the identifier for the class, and is used by Base to prefix
|
||||
* all events fired by instances of that class.
|
||||
* </p>
|
||||
*
|
||||
* @class Base
|
||||
* @constructor
|
||||
* @uses Attribute
|
||||
* @uses Plugin.Host
|
||||
*
|
||||
* @param {Object} config Object with configuration property name/value pairs. The object can be
|
||||
* used to provide default values for the objects published attributes.
|
||||
*
|
||||
* <p>
|
||||
* The config object can also contain the following non-attribute properties, providing a convenient
|
||||
* way to configure events listeners and plugins for the instance, as part of the constructor call:
|
||||
* </p>
|
||||
*
|
||||
* <dl>
|
||||
* <dt>on</dt>
|
||||
* <dd>An event name to listener function map, to register event listeners for the "on" moment of the event. A constructor convenience property for the <a href="Base.html#method_on">on</a> method.</dd>
|
||||
* <dt>after</dt>
|
||||
* <dd>An event name to listener function map, to register event listeners for the "after" moment of the event. A constructor convenience property for the <a href="Base.html#method_after">after</a> method.</dd>
|
||||
* <dt>bubbleTargets</dt>
|
||||
* <dd>An object, or array of objects, to register as bubble targets for bubbled events fired by this instance. A constructor convenience property for the <a href="EventTarget.html#method_addTarget">addTarget</a> method.</dd>
|
||||
* <dt>plugins</dt>
|
||||
* <dd>A plugin, or array of plugins to be plugged into the instance (see PluginHost's plug method for signature details). A constructor convenience property for the <a href="Plugin.Host.html#method_plug">plug</a> method.</dd>
|
||||
* </dl>
|
||||
*/
|
||||
function Base() {
|
||||
Y.log('constructor called', 'life', 'base');
|
||||
|
||||
Attribute.call(this);
|
||||
|
||||
// If Plugin.Host has been augmented [ through base-pluginhost ], setup it's
|
||||
// initial state, but don't initialize Plugins yet. That's done after initialization.
|
||||
var PluginHost = Y.Plugin && Y.Plugin.Host;
|
||||
if (this._initPlugins && PluginHost) {
|
||||
PluginHost.call(this);
|
||||
}
|
||||
|
||||
if (this._lazyAddAttrs !== false) { this._lazyAddAttrs = true; }
|
||||
|
||||
/**
|
||||
* The string used to identify the class of this object.
|
||||
*
|
||||
* @deprecated Use this.constructor.NAME
|
||||
* @property name
|
||||
* @type String
|
||||
*/
|
||||
this.name = this.constructor.NAME;
|
||||
this._eventPrefix = this.constructor.EVENT_PREFIX || this.constructor.NAME;
|
||||
|
||||
this.init.apply(this, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* The list of properties which can be configured for
|
||||
* each attribute (e.g. setter, getter, writeOnce, readOnly etc.)
|
||||
*
|
||||
* @property Base._ATTR_CFG
|
||||
* @type Array
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
Base._ATTR_CFG = Attribute._ATTR_CFG.concat("cloneDefaultValue");
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The string to be used to identify instances of
|
||||
* this class, for example in prefixing events.
|
||||
* </p>
|
||||
* <p>
|
||||
* Classes extending Base, should define their own
|
||||
* static NAME property, which should be camelCase by
|
||||
* convention (e.g. MyClass.NAME = "myClass";).
|
||||
* </p>
|
||||
* @property Base.NAME
|
||||
* @type String
|
||||
* @static
|
||||
*/
|
||||
Base.NAME = "base";
|
||||
|
||||
/**
|
||||
* The default set of attributes which will be available for instances of this class, and
|
||||
* their configuration. In addition to the configuration properties listed by
|
||||
* Attribute's <a href="Attribute.html#method_addAttr">addAttr</a> method, the attribute
|
||||
* can also be configured with a "cloneDefaultValue" property, which defines how the statically
|
||||
* defined value field should be protected ("shallow", "deep" and false are supported values).
|
||||
*
|
||||
* By default if the value is an object literal or an array it will be "shallow" cloned, to
|
||||
* protect the default value.
|
||||
*
|
||||
* @property Base.ATTRS
|
||||
* @type Object
|
||||
* @static
|
||||
*/
|
||||
Base.ATTRS = {
|
||||
/**
|
||||
* Flag indicating whether or not this object
|
||||
* has been through the init lifecycle phase.
|
||||
*
|
||||
* @attribute initialized
|
||||
* @readonly
|
||||
* @default false
|
||||
* @type boolean
|
||||
*/
|
||||
initialized: {
|
||||
readOnly:true,
|
||||
value:false
|
||||
},
|
||||
|
||||
/**
|
||||
* Flag indicating whether or not this object
|
||||
* has been through the destroy lifecycle phase.
|
||||
*
|
||||
* @attribute destroyed
|
||||
* @readonly
|
||||
* @default false
|
||||
* @type boolean
|
||||
*/
|
||||
destroyed: {
|
||||
readOnly:true,
|
||||
value:false
|
||||
}
|
||||
};
|
||||
|
||||
Base.prototype = {
|
||||
|
||||
/**
|
||||
* Init lifecycle method, invoked during construction.
|
||||
* Fires the init event prior to setting up attributes and
|
||||
* invoking initializers for the class hierarchy.
|
||||
*
|
||||
* @method init
|
||||
* @final
|
||||
* @chainable
|
||||
* @param {Object} config Object with configuration property name/value pairs
|
||||
* @return {Base} A reference to this object
|
||||
*/
|
||||
init: function(config) {
|
||||
Y.log('init called', 'life', 'base');
|
||||
|
||||
this._yuievt.config.prefix = this._eventPrefix;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Lifecycle event for the init phase, fired prior to initialization.
|
||||
* Invoking the preventDefault() method on the event object provided
|
||||
* to subscribers will prevent initialization from occuring.
|
||||
* </p>
|
||||
* <p>
|
||||
* Subscribers to the "after" momemt of this event, will be notified
|
||||
* after initialization of the object is complete (and therefore
|
||||
* cannot prevent initialization).
|
||||
* </p>
|
||||
*
|
||||
* @event init
|
||||
* @preventable _defInitFn
|
||||
* @param {EventFacade} e Event object, with a cfg property which
|
||||
* refers to the configuration object passed to the constructor.
|
||||
*/
|
||||
this.publish(INIT, {
|
||||
queuable:false,
|
||||
fireOnce:true,
|
||||
defaultTargetOnly:true,
|
||||
defaultFn:this._defInitFn
|
||||
});
|
||||
|
||||
this._preInitEventCfg(config);
|
||||
|
||||
this.fire(INIT, {cfg: config});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles the special on, after and target properties which allow the user to
|
||||
* easily configure on and after listeners as well as bubble targets during
|
||||
* construction, prior to init.
|
||||
*
|
||||
* @private
|
||||
* @method _preInitEventCfg
|
||||
* @param {Object} config The user configuration object
|
||||
*/
|
||||
_preInitEventCfg : function(config) {
|
||||
if (config) {
|
||||
if (config.on) {
|
||||
this.on(config.on);
|
||||
}
|
||||
if (config.after) {
|
||||
this.after(config.after);
|
||||
}
|
||||
}
|
||||
|
||||
var i, l, target,
|
||||
userTargets = (config && BUBBLETARGETS in config);
|
||||
|
||||
if (userTargets || _BUBBLETARGETS in this) {
|
||||
target = userTargets ? (config && config.bubbleTargets) : this._bubbleTargets;
|
||||
if (L.isArray(target)) {
|
||||
for (i = 0, l = target.length; i < l; i++) {
|
||||
this.addTarget(target[i]);
|
||||
}
|
||||
} else if (target) {
|
||||
this.addTarget(target);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Destroy lifecycle method. Fires the destroy
|
||||
* event, prior to invoking destructors for the
|
||||
* class hierarchy.
|
||||
* </p>
|
||||
* <p>
|
||||
* Subscribers to the destroy
|
||||
* event can invoke preventDefault on the event object, to prevent destruction
|
||||
* from proceeding.
|
||||
* </p>
|
||||
* @method destroy
|
||||
* @return {Base} A reference to this object
|
||||
* @final
|
||||
* @chainable
|
||||
*/
|
||||
destroy: function() {
|
||||
Y.log('destroy called', 'life', 'base');
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Lifecycle event for the destroy phase,
|
||||
* fired prior to destruction. Invoking the preventDefault
|
||||
* method on the event object provided to subscribers will
|
||||
* prevent destruction from proceeding.
|
||||
* </p>
|
||||
* <p>
|
||||
* Subscribers to the "after" moment of this event, will be notified
|
||||
* after destruction is complete (and as a result cannot prevent
|
||||
* destruction).
|
||||
* </p>
|
||||
* @event destroy
|
||||
* @preventable _defDestroyFn
|
||||
* @param {EventFacade} e Event object
|
||||
*/
|
||||
this.publish(DESTROY, {
|
||||
queuable:false,
|
||||
fireOnce:true,
|
||||
defaultTargetOnly:true,
|
||||
defaultFn: this._defDestroyFn
|
||||
});
|
||||
this.fire(DESTROY);
|
||||
|
||||
this.detachAll();
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Default init event handler
|
||||
*
|
||||
* @method _defInitFn
|
||||
* @param {EventFacade} e Event object, with a cfg property which
|
||||
* refers to the configuration object passed to the constructor.
|
||||
* @protected
|
||||
*/
|
||||
_defInitFn : function(e) {
|
||||
this._initHierarchy(e.cfg);
|
||||
if (this._initPlugins) {
|
||||
// Need to initPlugins manually, to handle constructor parsing, static Plug parsing
|
||||
this._initPlugins(e.cfg);
|
||||
}
|
||||
this._set(INITIALIZED, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Default destroy event handler
|
||||
*
|
||||
* @method _defDestroyFn
|
||||
* @param {EventFacade} e Event object
|
||||
* @protected
|
||||
*/
|
||||
_defDestroyFn : function(e) {
|
||||
this._destroyHierarchy();
|
||||
if (this._destroyPlugins) {
|
||||
this._destroyPlugins();
|
||||
}
|
||||
this._set(DESTROYED, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the class hierarchy for this object, with Base being the last class in the array.
|
||||
*
|
||||
* @method _getClasses
|
||||
* @protected
|
||||
* @return {Function[]} An array of classes (constructor functions), making up the class hierarchy for this object.
|
||||
* This value is cached the first time the method, or _getAttrCfgs, is invoked. Subsequent invocations return the
|
||||
* cached value.
|
||||
*/
|
||||
_getClasses : function() {
|
||||
if (!this._classes) {
|
||||
this._initHierarchyData();
|
||||
}
|
||||
return this._classes;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an aggregated set of attribute configurations, by traversing the class hierarchy.
|
||||
*
|
||||
* @method _getAttrCfgs
|
||||
* @protected
|
||||
* @return {Object} The hash of attribute configurations, aggregated across classes in the hierarchy
|
||||
* This value is cached the first time the method, or _getClasses, is invoked. Subsequent invocations return
|
||||
* the cached value.
|
||||
*/
|
||||
_getAttrCfgs : function() {
|
||||
if (!this._attrs) {
|
||||
this._initHierarchyData();
|
||||
}
|
||||
return this._attrs;
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper method used when processing ATTRS across the class hierarchy during
|
||||
* initialization. Returns a disposable object with the attributes defined for
|
||||
* the provided class, extracted from the set of all attributes passed in .
|
||||
*
|
||||
* @method _filterAttrCfs
|
||||
* @private
|
||||
*
|
||||
* @param {Function} clazz The class for which the desired attributes are required.
|
||||
* @param {Object} allCfgs The set of all attribute configurations for this instance.
|
||||
* Attributes will be removed from this set, if they belong to the filtered class, so
|
||||
* that by the time all classes are processed, allCfgs will be empty.
|
||||
*
|
||||
* @return {Object} The set of attributes belonging to the class passed in, in the form
|
||||
* of an object with attribute name/configuration pairs.
|
||||
*/
|
||||
_filterAttrCfgs : function(clazz, allCfgs) {
|
||||
var cfgs = null, attr, attrs = clazz.ATTRS;
|
||||
|
||||
if (attrs) {
|
||||
for (attr in attrs) {
|
||||
if (attrs.hasOwnProperty(attr) && allCfgs[attr]) {
|
||||
cfgs = cfgs || {};
|
||||
cfgs[attr] = allCfgs[attr];
|
||||
delete allCfgs[attr];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cfgs;
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper method used by _getClasses and _getAttrCfgs, which determines both
|
||||
* the array of classes and aggregate set of attribute configurations
|
||||
* across the class hierarchy for the instance.
|
||||
*
|
||||
* @method _initHierarchyData
|
||||
* @private
|
||||
*/
|
||||
_initHierarchyData : function() {
|
||||
var c = this.constructor,
|
||||
classes = [],
|
||||
attrs = [];
|
||||
|
||||
while (c) {
|
||||
// Add to classes
|
||||
classes[classes.length] = c;
|
||||
|
||||
// Add to attributes
|
||||
if (c.ATTRS) {
|
||||
attrs[attrs.length] = c.ATTRS;
|
||||
}
|
||||
c = c.superclass ? c.superclass.constructor : null;
|
||||
}
|
||||
|
||||
this._classes = classes;
|
||||
this._attrs = this._aggregateAttrs(attrs);
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper method, used by _initHierarchyData to aggregate
|
||||
* attribute configuration across the instances class hierarchy.
|
||||
*
|
||||
* The method will potect the attribute configuration value to protect the statically defined
|
||||
* default value in ATTRS if required (if the value is an object literal, array or the
|
||||
* attribute configuration has cloneDefaultValue set to shallow or deep).
|
||||
*
|
||||
* @method _aggregateAttrs
|
||||
* @private
|
||||
* @param {Array} allAttrs An array of ATTRS definitions across classes in the hierarchy
|
||||
* (subclass first, Base last)
|
||||
* @return {Object} The aggregate set of ATTRS definitions for the instance
|
||||
*/
|
||||
_aggregateAttrs : function(allAttrs) {
|
||||
var attr,
|
||||
attrs,
|
||||
cfg,
|
||||
val,
|
||||
path,
|
||||
i,
|
||||
clone,
|
||||
cfgProps = Base._ATTR_CFG,
|
||||
aggAttrs = {};
|
||||
|
||||
if (allAttrs) {
|
||||
for (i = allAttrs.length-1; i >= 0; --i) {
|
||||
attrs = allAttrs[i];
|
||||
|
||||
for (attr in attrs) {
|
||||
if (attrs.hasOwnProperty(attr)) {
|
||||
|
||||
// Protect config passed in
|
||||
cfg = Y.mix({}, attrs[attr], true, cfgProps);
|
||||
|
||||
val = cfg.value;
|
||||
clone = cfg.cloneDefaultValue;
|
||||
|
||||
if (val) {
|
||||
if ( (clone === undefined && (OBJECT_CONSTRUCTOR === val.constructor || L.isArray(val))) || clone === DEEP || clone === true) {
|
||||
Y.log('Cloning default value for attribute:' + attr, 'info', 'base');
|
||||
cfg.value = Y.clone(val);
|
||||
} else if (clone === SHALLOW) {
|
||||
Y.log('Merging default value for attribute:' + attr, 'info', 'base');
|
||||
cfg.value = Y.merge(val);
|
||||
}
|
||||
// else if (clone === false), don't clone the static default value.
|
||||
// It's intended to be used by reference.
|
||||
}
|
||||
|
||||
path = null;
|
||||
if (attr.indexOf(DOT) !== -1) {
|
||||
path = attr.split(DOT);
|
||||
attr = path.shift();
|
||||
}
|
||||
|
||||
if (path && aggAttrs[attr] && aggAttrs[attr].value) {
|
||||
O.setValue(aggAttrs[attr].value, path, val);
|
||||
} else if (!path){
|
||||
if (!aggAttrs[attr]) {
|
||||
aggAttrs[attr] = cfg;
|
||||
} else {
|
||||
Y.mix(aggAttrs[attr], cfg, true, cfgProps);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return aggAttrs;
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes the class hierarchy for the instance, which includes
|
||||
* initializing attributes for each class defined in the class's
|
||||
* static <a href="#property_Base.ATTRS">ATTRS</a> property and
|
||||
* invoking the initializer method on the prototype of each class in the hierarchy.
|
||||
*
|
||||
* @method _initHierarchy
|
||||
* @param {Object} userVals Object with configuration property name/value pairs
|
||||
* @private
|
||||
*/
|
||||
_initHierarchy : function(userVals) {
|
||||
var lazy = this._lazyAddAttrs,
|
||||
constr,
|
||||
constrProto,
|
||||
ci,
|
||||
ei,
|
||||
el,
|
||||
classes = this._getClasses(),
|
||||
attrCfgs = this._getAttrCfgs();
|
||||
|
||||
for (ci = classes.length-1; ci >= 0; ci--) {
|
||||
|
||||
constr = classes[ci];
|
||||
constrProto = constr.prototype;
|
||||
|
||||
if (constr._yuibuild && constr._yuibuild.exts) {
|
||||
for (ei = 0, el = constr._yuibuild.exts.length; ei < el; ei++) {
|
||||
constr._yuibuild.exts[ei].apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
this.addAttrs(this._filterAttrCfgs(constr, attrCfgs), userVals, lazy);
|
||||
|
||||
// Using INITIALIZER in hasOwnProperty check, for performance reasons (helps IE6 avoid GC thresholds when
|
||||
// referencing string literals). Not using it in apply, again, for performance "." is faster.
|
||||
if (constrProto.hasOwnProperty(INITIALIZER)) {
|
||||
constrProto.initializer.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys the class hierarchy for this instance by invoking
|
||||
* the descructor method on the prototype of each class in the hierarchy.
|
||||
*
|
||||
* @method _destroyHierarchy
|
||||
* @private
|
||||
*/
|
||||
_destroyHierarchy : function() {
|
||||
var constr,
|
||||
constrProto,
|
||||
ci, cl,
|
||||
classes = this._getClasses();
|
||||
|
||||
for (ci = 0, cl = classes.length; ci < cl; ci++) {
|
||||
constr = classes[ci];
|
||||
constrProto = constr.prototype;
|
||||
if (constrProto.hasOwnProperty(DESTRUCTOR)) {
|
||||
constrProto.destructor.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Default toString implementation. Provides the constructor NAME
|
||||
* and the instance ID.
|
||||
*
|
||||
* @method toString
|
||||
* @return {String} String representation for this object
|
||||
*/
|
||||
toString: function() {
|
||||
return this.constructor.NAME + "[" + Y.stamp(this) + "]";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Straightup augment, no wrapper functions
|
||||
Y.mix(Base, Attribute, false, null, 1);
|
||||
|
||||
// Fix constructor
|
||||
Base.prototype.constructor = Base;
|
||||
|
||||
Y.Base = Base;
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['attribute-base']});
|
||||
YUI.add('base-pluginhost', function(Y) {
|
||||
|
||||
/**
|
||||
* The base-pluginhost submodule adds Plugin support to Base, by augmenting Base with
|
||||
* Plugin.Host and setting up static (class level) Base.plug and Base.unplug methods.
|
||||
*
|
||||
* @module base
|
||||
* @submodule base-pluginhost
|
||||
* @for Base
|
||||
*/
|
||||
|
||||
var Base = Y.Base,
|
||||
PluginHost = Y.Plugin.Host;
|
||||
|
||||
Y.mix(Base, PluginHost, false, null, 1);
|
||||
|
||||
/**
|
||||
* Alias for <a href="Plugin.Host.html#method_Plugin.Host.plug">Plugin.Host.plug</a>. See aliased
|
||||
* method for argument and return value details.
|
||||
*
|
||||
* @method Base.plug
|
||||
* @static
|
||||
*/
|
||||
Base.plug = PluginHost.plug;
|
||||
|
||||
/**
|
||||
* Alias for <a href="Plugin.Host.html#method_Plugin.Host.unplug">Plugin.Host.unplug</a>. See the
|
||||
* aliased method for argument and return value details.
|
||||
*
|
||||
* @method Base.unplug
|
||||
* @static
|
||||
*/
|
||||
Base.unplug = PluginHost.unplug;
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['base-base', 'pluginhost']});
|
||||
YUI.add('base-build', function(Y) {
|
||||
|
||||
/**
|
||||
* The base-build submodule provides Base.build functionality, which
|
||||
* can be used to create custom classes, by aggregating extensions onto
|
||||
* a main class.
|
||||
*
|
||||
* @module base
|
||||
* @submodule base-build
|
||||
* @for Base
|
||||
*/
|
||||
var Base = Y.Base,
|
||||
L = Y.Lang,
|
||||
build;
|
||||
|
||||
Base._build = function(name, main, extensions, px, sx, cfg) {
|
||||
|
||||
var build = Base._build,
|
||||
|
||||
builtClass = build._ctor(main, cfg),
|
||||
buildCfg = build._cfg(main, cfg),
|
||||
|
||||
_mixCust = build._mixCust,
|
||||
|
||||
aggregates = buildCfg.aggregates,
|
||||
custom = buildCfg.custom,
|
||||
|
||||
dynamic = builtClass._yuibuild.dynamic,
|
||||
|
||||
i, l, val, extClass;
|
||||
|
||||
if (dynamic && aggregates) {
|
||||
for (i = 0, l = aggregates.length; i < l; ++i) {
|
||||
val = aggregates[i];
|
||||
if (main.hasOwnProperty(val)) {
|
||||
builtClass[val] = L.isArray(main[val]) ? [] : {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Augment/Aggregate
|
||||
for (i = 0, l = extensions.length; i < l; i++) {
|
||||
extClass = extensions[i];
|
||||
|
||||
// Prototype, old non-displacing augment
|
||||
Y.mix(builtClass, extClass, true, null, 1);
|
||||
// Custom Statics
|
||||
_mixCust(builtClass, extClass, aggregates, custom);
|
||||
|
||||
builtClass._yuibuild.exts.push(extClass);
|
||||
}
|
||||
|
||||
if (px) {
|
||||
Y.mix(builtClass.prototype, px, true);
|
||||
}
|
||||
|
||||
if (sx) {
|
||||
Y.mix(builtClass, build._clean(sx, aggregates, custom), true);
|
||||
_mixCust(builtClass, sx, aggregates, custom);
|
||||
}
|
||||
|
||||
builtClass.prototype.hasImpl = build._impl;
|
||||
|
||||
if (dynamic) {
|
||||
builtClass.NAME = name;
|
||||
builtClass.prototype.constructor = builtClass;
|
||||
}
|
||||
|
||||
return builtClass;
|
||||
};
|
||||
|
||||
build = Base._build;
|
||||
|
||||
Y.mix(build, {
|
||||
|
||||
_mixCust: function(r, s, aggregates, custom) {
|
||||
|
||||
if (aggregates) {
|
||||
Y.aggregate(r, s, true, aggregates);
|
||||
}
|
||||
|
||||
if (custom) {
|
||||
for (var j in custom) {
|
||||
if (custom.hasOwnProperty(j)) {
|
||||
custom[j](j, r, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_tmpl: function(main) {
|
||||
|
||||
function BuiltClass() {
|
||||
BuiltClass.superclass.constructor.apply(this, arguments);
|
||||
}
|
||||
Y.extend(BuiltClass, main);
|
||||
|
||||
return BuiltClass;
|
||||
},
|
||||
|
||||
_impl : function(extClass) {
|
||||
var classes = this._getClasses(), i, l, cls, exts, ll, j;
|
||||
for (i = 0, l = classes.length; i < l; i++) {
|
||||
cls = classes[i];
|
||||
if (cls._yuibuild) {
|
||||
exts = cls._yuibuild.exts;
|
||||
ll = exts.length;
|
||||
|
||||
for (j = 0; j < ll; j++) {
|
||||
if (exts[j] === extClass) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
_ctor : function(main, cfg) {
|
||||
|
||||
var dynamic = (cfg && false === cfg.dynamic) ? false : true,
|
||||
builtClass = (dynamic) ? build._tmpl(main) : main;
|
||||
|
||||
builtClass._yuibuild = {
|
||||
id: null,
|
||||
exts : [],
|
||||
dynamic: dynamic
|
||||
};
|
||||
|
||||
return builtClass;
|
||||
},
|
||||
|
||||
_cfg : function(main, cfg) {
|
||||
var aggr = [],
|
||||
cust = {},
|
||||
buildCfg,
|
||||
cfgAggr = (cfg && cfg.aggregates),
|
||||
cfgCustBuild = (cfg && cfg.custom),
|
||||
c = main;
|
||||
|
||||
while (c && c.prototype) {
|
||||
buildCfg = c._buildCfg;
|
||||
if (buildCfg) {
|
||||
if (buildCfg.aggregates) {
|
||||
aggr = aggr.concat(buildCfg.aggregates);
|
||||
}
|
||||
if (buildCfg.custom) {
|
||||
Y.mix(cust, buildCfg.custom, true);
|
||||
}
|
||||
}
|
||||
c = c.superclass ? c.superclass.constructor : null;
|
||||
}
|
||||
|
||||
if (cfgAggr) {
|
||||
aggr = aggr.concat(cfgAggr);
|
||||
}
|
||||
if (cfgCustBuild) {
|
||||
Y.mix(cust, cfg.cfgBuild, true);
|
||||
}
|
||||
|
||||
return {
|
||||
aggregates: aggr,
|
||||
custom: cust
|
||||
};
|
||||
},
|
||||
|
||||
_clean : function(sx, aggregates, custom) {
|
||||
var prop, i, l, sxclone = Y.merge(sx);
|
||||
|
||||
for (prop in custom) {
|
||||
if (sxclone.hasOwnProperty(prop)) {
|
||||
delete sxclone[prop];
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0, l = aggregates.length; i < l; i++) {
|
||||
prop = aggregates[i];
|
||||
if (sxclone.hasOwnProperty(prop)) {
|
||||
delete sxclone[prop];
|
||||
}
|
||||
}
|
||||
|
||||
return sxclone;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Builds a custom constructor function (class) from the
|
||||
* main function, and array of extension functions (classes)
|
||||
* provided. The NAME field for the constructor function is
|
||||
* defined by the first argument passed in.
|
||||
* </p>
|
||||
* <p>
|
||||
* The cfg object supports the following properties
|
||||
* </p>
|
||||
* <dl>
|
||||
* <dt>dynamic <boolean></dt>
|
||||
* <dd>
|
||||
* <p>If true (default), a completely new class
|
||||
* is created which extends the main class, and acts as the
|
||||
* host on which the extension classes are augmented.</p>
|
||||
* <p>If false, the extensions classes are augmented directly to
|
||||
* the main class, modifying the main class' prototype.</p>
|
||||
* </dd>
|
||||
* <dt>aggregates <String[]></dt>
|
||||
* <dd>An array of static property names, which will get aggregated
|
||||
* on to the built class, in addition to the default properties build
|
||||
* will always aggregate as defined by the main class' static _buildCfg
|
||||
* property.
|
||||
* </dd>
|
||||
* </dl>
|
||||
*
|
||||
* @method Base.build
|
||||
* @deprecated Use the more convenient Base.create and Base.mix methods instead
|
||||
* @static
|
||||
* @param {Function} name The name of the new class. Used to defined the NAME property for the new class.
|
||||
* @param {Function} main The main class on which to base the built class
|
||||
* @param {Function[]} extensions The set of extension classes which will be
|
||||
* augmented/aggregated to the built class.
|
||||
* @param {Object} cfg Optional. Build configuration for the class (see description).
|
||||
* @return {Function} A custom class, created from the provided main and extension classes
|
||||
*/
|
||||
Base.build = function(name, main, extensions, cfg) {
|
||||
return build(name, main, extensions, null, null, cfg);
|
||||
};
|
||||
|
||||
/**
|
||||
* <p>Creates a new class (constructor function) which extends the base class passed in as the second argument,
|
||||
* and mixes in the array of extensions provided.</p>
|
||||
* <p>Prototype properties or methods can be added to the new class, using the px argument (similar to Y.extend).</p>
|
||||
* <p>Static properties or methods can be added to the new class, using the sx argument (similar to Y.extend).</p>
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
* @method Base.create
|
||||
* @static
|
||||
* @param {Function} name The name of the newly created class. Used to defined the NAME property for the new class.
|
||||
* @param {Function} main The base class which the new class should extend. This class needs to be Base or a class derived from base (e.g. Widget).
|
||||
* @param {Function[]} extensions The list of extensions which will be mixed into the built class.
|
||||
* @param {Object} px The set of prototype properties/methods to add to the built class.
|
||||
* @param {Object} sx The set of static properties/methods to add to the built class.
|
||||
* @return {Function} The newly created class.
|
||||
*/
|
||||
Base.create = function(name, base, extensions, px, sx) {
|
||||
return build(name, base, extensions, px, sx);
|
||||
};
|
||||
|
||||
/**
|
||||
* <p>Mixes in a list of extensions to an existing class.</p>
|
||||
* @method Base.mix
|
||||
* @static
|
||||
* @param {Function} main The existing class into which the extensions should be mixed. The class needs to be Base or class derived from base (e.g. Widget)
|
||||
* @param {Function[]} extensions The set of extension classes which will mixed into the existing main class.
|
||||
* @return {Function} The modified main class, with extensions mixed in.
|
||||
*/
|
||||
Base.mix = function(main, extensions) {
|
||||
return build(null, main, extensions, null, null, {dynamic:false});
|
||||
};
|
||||
|
||||
/**
|
||||
* The build configuration for the Base class.
|
||||
*
|
||||
* Defines the static fields which need to be aggregated
|
||||
* when the Base class is used as the main class passed to
|
||||
* the <a href="#method_Base.build">Base.build</a> method.
|
||||
*
|
||||
* @property Base._buildCfg
|
||||
* @type Object
|
||||
* @static
|
||||
* @final
|
||||
* @private
|
||||
*/
|
||||
Base._buildCfg = {
|
||||
custom : {
|
||||
ATTRS : function(prop, r, s) {
|
||||
|
||||
r.ATTRS = r.ATTRS || {};
|
||||
|
||||
if (s.ATTRS) {
|
||||
|
||||
var sAttrs = s.ATTRS,
|
||||
rAttrs = r.ATTRS,
|
||||
a;
|
||||
|
||||
for (a in sAttrs) {
|
||||
if (sAttrs.hasOwnProperty(a)) {
|
||||
rAttrs[a] = rAttrs[a] || {};
|
||||
Y.mix(rAttrs[a], sAttrs[a], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
aggregates : ["_PLUG", "_UNPLUG"]
|
||||
};
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['base-base']});
|
||||
|
||||
|
||||
YUI.add('base', function(Y){}, '3.2.0' ,{use:['base-base', 'base-pluginhost', 'base-build']});
|
||||
|
||||
Vendored
-8
File diff suppressed because one or more lines are too long
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("base-pluginhost",function(C){var A=C.Base,B=C.Plugin.Host;C.mix(A,B,false,null,1);A.plug=B.plug;A.unplug=B.unplug;},"3.2.0",{requires:["base-base","pluginhost"]});
|
||||
@@ -1,925 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('base-base', function(Y) {
|
||||
|
||||
/**
|
||||
* The base module provides the Base class, which objects requiring attribute and custom event support can extend.
|
||||
* The module also provides two ways to reuse code - It augments Base with the Plugin.Host interface which provides
|
||||
* plugin support and also provides the Base.build method which provides a way to build custom classes using extensions.
|
||||
*
|
||||
* @module base
|
||||
*/
|
||||
|
||||
/**
|
||||
* The base-base submodule provides the Base class without the Plugin support, provided by Plugin.Host,
|
||||
* and without the extension support provided by Base.build.
|
||||
*
|
||||
* @module base
|
||||
* @submodule base-base
|
||||
*/
|
||||
var O = Y.Object,
|
||||
L = Y.Lang,
|
||||
DOT = ".",
|
||||
DESTROY = "destroy",
|
||||
INIT = "init",
|
||||
INITIALIZED = "initialized",
|
||||
DESTROYED = "destroyed",
|
||||
INITIALIZER = "initializer",
|
||||
BUBBLETARGETS = "bubbleTargets",
|
||||
_BUBBLETARGETS = "_bubbleTargets",
|
||||
OBJECT_CONSTRUCTOR = Object.prototype.constructor,
|
||||
DEEP = "deep",
|
||||
SHALLOW = "shallow",
|
||||
DESTRUCTOR = "destructor",
|
||||
|
||||
Attribute = Y.Attribute;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* A base class which objects requiring attributes and custom event support can
|
||||
* extend. Base also handles the chaining of initializer and destructor methods across
|
||||
* the hierarchy as part of object construction and destruction. Additionally, attributes configured
|
||||
* through the static <a href="#property_Base.ATTRS">ATTRS</a> property for each class
|
||||
* in the hierarchy will be initialized by Base.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* The static <a href="#property_Base.NAME">NAME</a> property of each class extending
|
||||
* from Base will be used as the identifier for the class, and is used by Base to prefix
|
||||
* all events fired by instances of that class.
|
||||
* </p>
|
||||
*
|
||||
* @class Base
|
||||
* @constructor
|
||||
* @uses Attribute
|
||||
* @uses Plugin.Host
|
||||
*
|
||||
* @param {Object} config Object with configuration property name/value pairs. The object can be
|
||||
* used to provide default values for the objects published attributes.
|
||||
*
|
||||
* <p>
|
||||
* The config object can also contain the following non-attribute properties, providing a convenient
|
||||
* way to configure events listeners and plugins for the instance, as part of the constructor call:
|
||||
* </p>
|
||||
*
|
||||
* <dl>
|
||||
* <dt>on</dt>
|
||||
* <dd>An event name to listener function map, to register event listeners for the "on" moment of the event. A constructor convenience property for the <a href="Base.html#method_on">on</a> method.</dd>
|
||||
* <dt>after</dt>
|
||||
* <dd>An event name to listener function map, to register event listeners for the "after" moment of the event. A constructor convenience property for the <a href="Base.html#method_after">after</a> method.</dd>
|
||||
* <dt>bubbleTargets</dt>
|
||||
* <dd>An object, or array of objects, to register as bubble targets for bubbled events fired by this instance. A constructor convenience property for the <a href="EventTarget.html#method_addTarget">addTarget</a> method.</dd>
|
||||
* <dt>plugins</dt>
|
||||
* <dd>A plugin, or array of plugins to be plugged into the instance (see PluginHost's plug method for signature details). A constructor convenience property for the <a href="Plugin.Host.html#method_plug">plug</a> method.</dd>
|
||||
* </dl>
|
||||
*/
|
||||
function Base() {
|
||||
|
||||
Attribute.call(this);
|
||||
|
||||
// If Plugin.Host has been augmented [ through base-pluginhost ], setup it's
|
||||
// initial state, but don't initialize Plugins yet. That's done after initialization.
|
||||
var PluginHost = Y.Plugin && Y.Plugin.Host;
|
||||
if (this._initPlugins && PluginHost) {
|
||||
PluginHost.call(this);
|
||||
}
|
||||
|
||||
if (this._lazyAddAttrs !== false) { this._lazyAddAttrs = true; }
|
||||
|
||||
/**
|
||||
* The string used to identify the class of this object.
|
||||
*
|
||||
* @deprecated Use this.constructor.NAME
|
||||
* @property name
|
||||
* @type String
|
||||
*/
|
||||
this.name = this.constructor.NAME;
|
||||
this._eventPrefix = this.constructor.EVENT_PREFIX || this.constructor.NAME;
|
||||
|
||||
this.init.apply(this, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* The list of properties which can be configured for
|
||||
* each attribute (e.g. setter, getter, writeOnce, readOnly etc.)
|
||||
*
|
||||
* @property Base._ATTR_CFG
|
||||
* @type Array
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
Base._ATTR_CFG = Attribute._ATTR_CFG.concat("cloneDefaultValue");
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The string to be used to identify instances of
|
||||
* this class, for example in prefixing events.
|
||||
* </p>
|
||||
* <p>
|
||||
* Classes extending Base, should define their own
|
||||
* static NAME property, which should be camelCase by
|
||||
* convention (e.g. MyClass.NAME = "myClass";).
|
||||
* </p>
|
||||
* @property Base.NAME
|
||||
* @type String
|
||||
* @static
|
||||
*/
|
||||
Base.NAME = "base";
|
||||
|
||||
/**
|
||||
* The default set of attributes which will be available for instances of this class, and
|
||||
* their configuration. In addition to the configuration properties listed by
|
||||
* Attribute's <a href="Attribute.html#method_addAttr">addAttr</a> method, the attribute
|
||||
* can also be configured with a "cloneDefaultValue" property, which defines how the statically
|
||||
* defined value field should be protected ("shallow", "deep" and false are supported values).
|
||||
*
|
||||
* By default if the value is an object literal or an array it will be "shallow" cloned, to
|
||||
* protect the default value.
|
||||
*
|
||||
* @property Base.ATTRS
|
||||
* @type Object
|
||||
* @static
|
||||
*/
|
||||
Base.ATTRS = {
|
||||
/**
|
||||
* Flag indicating whether or not this object
|
||||
* has been through the init lifecycle phase.
|
||||
*
|
||||
* @attribute initialized
|
||||
* @readonly
|
||||
* @default false
|
||||
* @type boolean
|
||||
*/
|
||||
initialized: {
|
||||
readOnly:true,
|
||||
value:false
|
||||
},
|
||||
|
||||
/**
|
||||
* Flag indicating whether or not this object
|
||||
* has been through the destroy lifecycle phase.
|
||||
*
|
||||
* @attribute destroyed
|
||||
* @readonly
|
||||
* @default false
|
||||
* @type boolean
|
||||
*/
|
||||
destroyed: {
|
||||
readOnly:true,
|
||||
value:false
|
||||
}
|
||||
};
|
||||
|
||||
Base.prototype = {
|
||||
|
||||
/**
|
||||
* Init lifecycle method, invoked during construction.
|
||||
* Fires the init event prior to setting up attributes and
|
||||
* invoking initializers for the class hierarchy.
|
||||
*
|
||||
* @method init
|
||||
* @final
|
||||
* @chainable
|
||||
* @param {Object} config Object with configuration property name/value pairs
|
||||
* @return {Base} A reference to this object
|
||||
*/
|
||||
init: function(config) {
|
||||
|
||||
this._yuievt.config.prefix = this._eventPrefix;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Lifecycle event for the init phase, fired prior to initialization.
|
||||
* Invoking the preventDefault() method on the event object provided
|
||||
* to subscribers will prevent initialization from occuring.
|
||||
* </p>
|
||||
* <p>
|
||||
* Subscribers to the "after" momemt of this event, will be notified
|
||||
* after initialization of the object is complete (and therefore
|
||||
* cannot prevent initialization).
|
||||
* </p>
|
||||
*
|
||||
* @event init
|
||||
* @preventable _defInitFn
|
||||
* @param {EventFacade} e Event object, with a cfg property which
|
||||
* refers to the configuration object passed to the constructor.
|
||||
*/
|
||||
this.publish(INIT, {
|
||||
queuable:false,
|
||||
fireOnce:true,
|
||||
defaultTargetOnly:true,
|
||||
defaultFn:this._defInitFn
|
||||
});
|
||||
|
||||
this._preInitEventCfg(config);
|
||||
|
||||
this.fire(INIT, {cfg: config});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles the special on, after and target properties which allow the user to
|
||||
* easily configure on and after listeners as well as bubble targets during
|
||||
* construction, prior to init.
|
||||
*
|
||||
* @private
|
||||
* @method _preInitEventCfg
|
||||
* @param {Object} config The user configuration object
|
||||
*/
|
||||
_preInitEventCfg : function(config) {
|
||||
if (config) {
|
||||
if (config.on) {
|
||||
this.on(config.on);
|
||||
}
|
||||
if (config.after) {
|
||||
this.after(config.after);
|
||||
}
|
||||
}
|
||||
|
||||
var i, l, target,
|
||||
userTargets = (config && BUBBLETARGETS in config);
|
||||
|
||||
if (userTargets || _BUBBLETARGETS in this) {
|
||||
target = userTargets ? (config && config.bubbleTargets) : this._bubbleTargets;
|
||||
if (L.isArray(target)) {
|
||||
for (i = 0, l = target.length; i < l; i++) {
|
||||
this.addTarget(target[i]);
|
||||
}
|
||||
} else if (target) {
|
||||
this.addTarget(target);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Destroy lifecycle method. Fires the destroy
|
||||
* event, prior to invoking destructors for the
|
||||
* class hierarchy.
|
||||
* </p>
|
||||
* <p>
|
||||
* Subscribers to the destroy
|
||||
* event can invoke preventDefault on the event object, to prevent destruction
|
||||
* from proceeding.
|
||||
* </p>
|
||||
* @method destroy
|
||||
* @return {Base} A reference to this object
|
||||
* @final
|
||||
* @chainable
|
||||
*/
|
||||
destroy: function() {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Lifecycle event for the destroy phase,
|
||||
* fired prior to destruction. Invoking the preventDefault
|
||||
* method on the event object provided to subscribers will
|
||||
* prevent destruction from proceeding.
|
||||
* </p>
|
||||
* <p>
|
||||
* Subscribers to the "after" moment of this event, will be notified
|
||||
* after destruction is complete (and as a result cannot prevent
|
||||
* destruction).
|
||||
* </p>
|
||||
* @event destroy
|
||||
* @preventable _defDestroyFn
|
||||
* @param {EventFacade} e Event object
|
||||
*/
|
||||
this.publish(DESTROY, {
|
||||
queuable:false,
|
||||
fireOnce:true,
|
||||
defaultTargetOnly:true,
|
||||
defaultFn: this._defDestroyFn
|
||||
});
|
||||
this.fire(DESTROY);
|
||||
|
||||
this.detachAll();
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Default init event handler
|
||||
*
|
||||
* @method _defInitFn
|
||||
* @param {EventFacade} e Event object, with a cfg property which
|
||||
* refers to the configuration object passed to the constructor.
|
||||
* @protected
|
||||
*/
|
||||
_defInitFn : function(e) {
|
||||
this._initHierarchy(e.cfg);
|
||||
if (this._initPlugins) {
|
||||
// Need to initPlugins manually, to handle constructor parsing, static Plug parsing
|
||||
this._initPlugins(e.cfg);
|
||||
}
|
||||
this._set(INITIALIZED, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Default destroy event handler
|
||||
*
|
||||
* @method _defDestroyFn
|
||||
* @param {EventFacade} e Event object
|
||||
* @protected
|
||||
*/
|
||||
_defDestroyFn : function(e) {
|
||||
this._destroyHierarchy();
|
||||
if (this._destroyPlugins) {
|
||||
this._destroyPlugins();
|
||||
}
|
||||
this._set(DESTROYED, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the class hierarchy for this object, with Base being the last class in the array.
|
||||
*
|
||||
* @method _getClasses
|
||||
* @protected
|
||||
* @return {Function[]} An array of classes (constructor functions), making up the class hierarchy for this object.
|
||||
* This value is cached the first time the method, or _getAttrCfgs, is invoked. Subsequent invocations return the
|
||||
* cached value.
|
||||
*/
|
||||
_getClasses : function() {
|
||||
if (!this._classes) {
|
||||
this._initHierarchyData();
|
||||
}
|
||||
return this._classes;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an aggregated set of attribute configurations, by traversing the class hierarchy.
|
||||
*
|
||||
* @method _getAttrCfgs
|
||||
* @protected
|
||||
* @return {Object} The hash of attribute configurations, aggregated across classes in the hierarchy
|
||||
* This value is cached the first time the method, or _getClasses, is invoked. Subsequent invocations return
|
||||
* the cached value.
|
||||
*/
|
||||
_getAttrCfgs : function() {
|
||||
if (!this._attrs) {
|
||||
this._initHierarchyData();
|
||||
}
|
||||
return this._attrs;
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper method used when processing ATTRS across the class hierarchy during
|
||||
* initialization. Returns a disposable object with the attributes defined for
|
||||
* the provided class, extracted from the set of all attributes passed in .
|
||||
*
|
||||
* @method _filterAttrCfs
|
||||
* @private
|
||||
*
|
||||
* @param {Function} clazz The class for which the desired attributes are required.
|
||||
* @param {Object} allCfgs The set of all attribute configurations for this instance.
|
||||
* Attributes will be removed from this set, if they belong to the filtered class, so
|
||||
* that by the time all classes are processed, allCfgs will be empty.
|
||||
*
|
||||
* @return {Object} The set of attributes belonging to the class passed in, in the form
|
||||
* of an object with attribute name/configuration pairs.
|
||||
*/
|
||||
_filterAttrCfgs : function(clazz, allCfgs) {
|
||||
var cfgs = null, attr, attrs = clazz.ATTRS;
|
||||
|
||||
if (attrs) {
|
||||
for (attr in attrs) {
|
||||
if (attrs.hasOwnProperty(attr) && allCfgs[attr]) {
|
||||
cfgs = cfgs || {};
|
||||
cfgs[attr] = allCfgs[attr];
|
||||
delete allCfgs[attr];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cfgs;
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper method used by _getClasses and _getAttrCfgs, which determines both
|
||||
* the array of classes and aggregate set of attribute configurations
|
||||
* across the class hierarchy for the instance.
|
||||
*
|
||||
* @method _initHierarchyData
|
||||
* @private
|
||||
*/
|
||||
_initHierarchyData : function() {
|
||||
var c = this.constructor,
|
||||
classes = [],
|
||||
attrs = [];
|
||||
|
||||
while (c) {
|
||||
// Add to classes
|
||||
classes[classes.length] = c;
|
||||
|
||||
// Add to attributes
|
||||
if (c.ATTRS) {
|
||||
attrs[attrs.length] = c.ATTRS;
|
||||
}
|
||||
c = c.superclass ? c.superclass.constructor : null;
|
||||
}
|
||||
|
||||
this._classes = classes;
|
||||
this._attrs = this._aggregateAttrs(attrs);
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper method, used by _initHierarchyData to aggregate
|
||||
* attribute configuration across the instances class hierarchy.
|
||||
*
|
||||
* The method will potect the attribute configuration value to protect the statically defined
|
||||
* default value in ATTRS if required (if the value is an object literal, array or the
|
||||
* attribute configuration has cloneDefaultValue set to shallow or deep).
|
||||
*
|
||||
* @method _aggregateAttrs
|
||||
* @private
|
||||
* @param {Array} allAttrs An array of ATTRS definitions across classes in the hierarchy
|
||||
* (subclass first, Base last)
|
||||
* @return {Object} The aggregate set of ATTRS definitions for the instance
|
||||
*/
|
||||
_aggregateAttrs : function(allAttrs) {
|
||||
var attr,
|
||||
attrs,
|
||||
cfg,
|
||||
val,
|
||||
path,
|
||||
i,
|
||||
clone,
|
||||
cfgProps = Base._ATTR_CFG,
|
||||
aggAttrs = {};
|
||||
|
||||
if (allAttrs) {
|
||||
for (i = allAttrs.length-1; i >= 0; --i) {
|
||||
attrs = allAttrs[i];
|
||||
|
||||
for (attr in attrs) {
|
||||
if (attrs.hasOwnProperty(attr)) {
|
||||
|
||||
// Protect config passed in
|
||||
cfg = Y.mix({}, attrs[attr], true, cfgProps);
|
||||
|
||||
val = cfg.value;
|
||||
clone = cfg.cloneDefaultValue;
|
||||
|
||||
if (val) {
|
||||
if ( (clone === undefined && (OBJECT_CONSTRUCTOR === val.constructor || L.isArray(val))) || clone === DEEP || clone === true) {
|
||||
cfg.value = Y.clone(val);
|
||||
} else if (clone === SHALLOW) {
|
||||
cfg.value = Y.merge(val);
|
||||
}
|
||||
// else if (clone === false), don't clone the static default value.
|
||||
// It's intended to be used by reference.
|
||||
}
|
||||
|
||||
path = null;
|
||||
if (attr.indexOf(DOT) !== -1) {
|
||||
path = attr.split(DOT);
|
||||
attr = path.shift();
|
||||
}
|
||||
|
||||
if (path && aggAttrs[attr] && aggAttrs[attr].value) {
|
||||
O.setValue(aggAttrs[attr].value, path, val);
|
||||
} else if (!path){
|
||||
if (!aggAttrs[attr]) {
|
||||
aggAttrs[attr] = cfg;
|
||||
} else {
|
||||
Y.mix(aggAttrs[attr], cfg, true, cfgProps);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return aggAttrs;
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes the class hierarchy for the instance, which includes
|
||||
* initializing attributes for each class defined in the class's
|
||||
* static <a href="#property_Base.ATTRS">ATTRS</a> property and
|
||||
* invoking the initializer method on the prototype of each class in the hierarchy.
|
||||
*
|
||||
* @method _initHierarchy
|
||||
* @param {Object} userVals Object with configuration property name/value pairs
|
||||
* @private
|
||||
*/
|
||||
_initHierarchy : function(userVals) {
|
||||
var lazy = this._lazyAddAttrs,
|
||||
constr,
|
||||
constrProto,
|
||||
ci,
|
||||
ei,
|
||||
el,
|
||||
classes = this._getClasses(),
|
||||
attrCfgs = this._getAttrCfgs();
|
||||
|
||||
for (ci = classes.length-1; ci >= 0; ci--) {
|
||||
|
||||
constr = classes[ci];
|
||||
constrProto = constr.prototype;
|
||||
|
||||
if (constr._yuibuild && constr._yuibuild.exts) {
|
||||
for (ei = 0, el = constr._yuibuild.exts.length; ei < el; ei++) {
|
||||
constr._yuibuild.exts[ei].apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
this.addAttrs(this._filterAttrCfgs(constr, attrCfgs), userVals, lazy);
|
||||
|
||||
// Using INITIALIZER in hasOwnProperty check, for performance reasons (helps IE6 avoid GC thresholds when
|
||||
// referencing string literals). Not using it in apply, again, for performance "." is faster.
|
||||
if (constrProto.hasOwnProperty(INITIALIZER)) {
|
||||
constrProto.initializer.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys the class hierarchy for this instance by invoking
|
||||
* the descructor method on the prototype of each class in the hierarchy.
|
||||
*
|
||||
* @method _destroyHierarchy
|
||||
* @private
|
||||
*/
|
||||
_destroyHierarchy : function() {
|
||||
var constr,
|
||||
constrProto,
|
||||
ci, cl,
|
||||
classes = this._getClasses();
|
||||
|
||||
for (ci = 0, cl = classes.length; ci < cl; ci++) {
|
||||
constr = classes[ci];
|
||||
constrProto = constr.prototype;
|
||||
if (constrProto.hasOwnProperty(DESTRUCTOR)) {
|
||||
constrProto.destructor.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Default toString implementation. Provides the constructor NAME
|
||||
* and the instance ID.
|
||||
*
|
||||
* @method toString
|
||||
* @return {String} String representation for this object
|
||||
*/
|
||||
toString: function() {
|
||||
return this.constructor.NAME + "[" + Y.stamp(this) + "]";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Straightup augment, no wrapper functions
|
||||
Y.mix(Base, Attribute, false, null, 1);
|
||||
|
||||
// Fix constructor
|
||||
Base.prototype.constructor = Base;
|
||||
|
||||
Y.Base = Base;
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['attribute-base']});
|
||||
YUI.add('base-pluginhost', function(Y) {
|
||||
|
||||
/**
|
||||
* The base-pluginhost submodule adds Plugin support to Base, by augmenting Base with
|
||||
* Plugin.Host and setting up static (class level) Base.plug and Base.unplug methods.
|
||||
*
|
||||
* @module base
|
||||
* @submodule base-pluginhost
|
||||
* @for Base
|
||||
*/
|
||||
|
||||
var Base = Y.Base,
|
||||
PluginHost = Y.Plugin.Host;
|
||||
|
||||
Y.mix(Base, PluginHost, false, null, 1);
|
||||
|
||||
/**
|
||||
* Alias for <a href="Plugin.Host.html#method_Plugin.Host.plug">Plugin.Host.plug</a>. See aliased
|
||||
* method for argument and return value details.
|
||||
*
|
||||
* @method Base.plug
|
||||
* @static
|
||||
*/
|
||||
Base.plug = PluginHost.plug;
|
||||
|
||||
/**
|
||||
* Alias for <a href="Plugin.Host.html#method_Plugin.Host.unplug">Plugin.Host.unplug</a>. See the
|
||||
* aliased method for argument and return value details.
|
||||
*
|
||||
* @method Base.unplug
|
||||
* @static
|
||||
*/
|
||||
Base.unplug = PluginHost.unplug;
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['base-base', 'pluginhost']});
|
||||
YUI.add('base-build', function(Y) {
|
||||
|
||||
/**
|
||||
* The base-build submodule provides Base.build functionality, which
|
||||
* can be used to create custom classes, by aggregating extensions onto
|
||||
* a main class.
|
||||
*
|
||||
* @module base
|
||||
* @submodule base-build
|
||||
* @for Base
|
||||
*/
|
||||
var Base = Y.Base,
|
||||
L = Y.Lang,
|
||||
build;
|
||||
|
||||
Base._build = function(name, main, extensions, px, sx, cfg) {
|
||||
|
||||
var build = Base._build,
|
||||
|
||||
builtClass = build._ctor(main, cfg),
|
||||
buildCfg = build._cfg(main, cfg),
|
||||
|
||||
_mixCust = build._mixCust,
|
||||
|
||||
aggregates = buildCfg.aggregates,
|
||||
custom = buildCfg.custom,
|
||||
|
||||
dynamic = builtClass._yuibuild.dynamic,
|
||||
|
||||
i, l, val, extClass;
|
||||
|
||||
if (dynamic && aggregates) {
|
||||
for (i = 0, l = aggregates.length; i < l; ++i) {
|
||||
val = aggregates[i];
|
||||
if (main.hasOwnProperty(val)) {
|
||||
builtClass[val] = L.isArray(main[val]) ? [] : {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Augment/Aggregate
|
||||
for (i = 0, l = extensions.length; i < l; i++) {
|
||||
extClass = extensions[i];
|
||||
|
||||
// Prototype, old non-displacing augment
|
||||
Y.mix(builtClass, extClass, true, null, 1);
|
||||
// Custom Statics
|
||||
_mixCust(builtClass, extClass, aggregates, custom);
|
||||
|
||||
builtClass._yuibuild.exts.push(extClass);
|
||||
}
|
||||
|
||||
if (px) {
|
||||
Y.mix(builtClass.prototype, px, true);
|
||||
}
|
||||
|
||||
if (sx) {
|
||||
Y.mix(builtClass, build._clean(sx, aggregates, custom), true);
|
||||
_mixCust(builtClass, sx, aggregates, custom);
|
||||
}
|
||||
|
||||
builtClass.prototype.hasImpl = build._impl;
|
||||
|
||||
if (dynamic) {
|
||||
builtClass.NAME = name;
|
||||
builtClass.prototype.constructor = builtClass;
|
||||
}
|
||||
|
||||
return builtClass;
|
||||
};
|
||||
|
||||
build = Base._build;
|
||||
|
||||
Y.mix(build, {
|
||||
|
||||
_mixCust: function(r, s, aggregates, custom) {
|
||||
|
||||
if (aggregates) {
|
||||
Y.aggregate(r, s, true, aggregates);
|
||||
}
|
||||
|
||||
if (custom) {
|
||||
for (var j in custom) {
|
||||
if (custom.hasOwnProperty(j)) {
|
||||
custom[j](j, r, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_tmpl: function(main) {
|
||||
|
||||
function BuiltClass() {
|
||||
BuiltClass.superclass.constructor.apply(this, arguments);
|
||||
}
|
||||
Y.extend(BuiltClass, main);
|
||||
|
||||
return BuiltClass;
|
||||
},
|
||||
|
||||
_impl : function(extClass) {
|
||||
var classes = this._getClasses(), i, l, cls, exts, ll, j;
|
||||
for (i = 0, l = classes.length; i < l; i++) {
|
||||
cls = classes[i];
|
||||
if (cls._yuibuild) {
|
||||
exts = cls._yuibuild.exts;
|
||||
ll = exts.length;
|
||||
|
||||
for (j = 0; j < ll; j++) {
|
||||
if (exts[j] === extClass) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
_ctor : function(main, cfg) {
|
||||
|
||||
var dynamic = (cfg && false === cfg.dynamic) ? false : true,
|
||||
builtClass = (dynamic) ? build._tmpl(main) : main;
|
||||
|
||||
builtClass._yuibuild = {
|
||||
id: null,
|
||||
exts : [],
|
||||
dynamic: dynamic
|
||||
};
|
||||
|
||||
return builtClass;
|
||||
},
|
||||
|
||||
_cfg : function(main, cfg) {
|
||||
var aggr = [],
|
||||
cust = {},
|
||||
buildCfg,
|
||||
cfgAggr = (cfg && cfg.aggregates),
|
||||
cfgCustBuild = (cfg && cfg.custom),
|
||||
c = main;
|
||||
|
||||
while (c && c.prototype) {
|
||||
buildCfg = c._buildCfg;
|
||||
if (buildCfg) {
|
||||
if (buildCfg.aggregates) {
|
||||
aggr = aggr.concat(buildCfg.aggregates);
|
||||
}
|
||||
if (buildCfg.custom) {
|
||||
Y.mix(cust, buildCfg.custom, true);
|
||||
}
|
||||
}
|
||||
c = c.superclass ? c.superclass.constructor : null;
|
||||
}
|
||||
|
||||
if (cfgAggr) {
|
||||
aggr = aggr.concat(cfgAggr);
|
||||
}
|
||||
if (cfgCustBuild) {
|
||||
Y.mix(cust, cfg.cfgBuild, true);
|
||||
}
|
||||
|
||||
return {
|
||||
aggregates: aggr,
|
||||
custom: cust
|
||||
};
|
||||
},
|
||||
|
||||
_clean : function(sx, aggregates, custom) {
|
||||
var prop, i, l, sxclone = Y.merge(sx);
|
||||
|
||||
for (prop in custom) {
|
||||
if (sxclone.hasOwnProperty(prop)) {
|
||||
delete sxclone[prop];
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0, l = aggregates.length; i < l; i++) {
|
||||
prop = aggregates[i];
|
||||
if (sxclone.hasOwnProperty(prop)) {
|
||||
delete sxclone[prop];
|
||||
}
|
||||
}
|
||||
|
||||
return sxclone;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Builds a custom constructor function (class) from the
|
||||
* main function, and array of extension functions (classes)
|
||||
* provided. The NAME field for the constructor function is
|
||||
* defined by the first argument passed in.
|
||||
* </p>
|
||||
* <p>
|
||||
* The cfg object supports the following properties
|
||||
* </p>
|
||||
* <dl>
|
||||
* <dt>dynamic <boolean></dt>
|
||||
* <dd>
|
||||
* <p>If true (default), a completely new class
|
||||
* is created which extends the main class, and acts as the
|
||||
* host on which the extension classes are augmented.</p>
|
||||
* <p>If false, the extensions classes are augmented directly to
|
||||
* the main class, modifying the main class' prototype.</p>
|
||||
* </dd>
|
||||
* <dt>aggregates <String[]></dt>
|
||||
* <dd>An array of static property names, which will get aggregated
|
||||
* on to the built class, in addition to the default properties build
|
||||
* will always aggregate as defined by the main class' static _buildCfg
|
||||
* property.
|
||||
* </dd>
|
||||
* </dl>
|
||||
*
|
||||
* @method Base.build
|
||||
* @deprecated Use the more convenient Base.create and Base.mix methods instead
|
||||
* @static
|
||||
* @param {Function} name The name of the new class. Used to defined the NAME property for the new class.
|
||||
* @param {Function} main The main class on which to base the built class
|
||||
* @param {Function[]} extensions The set of extension classes which will be
|
||||
* augmented/aggregated to the built class.
|
||||
* @param {Object} cfg Optional. Build configuration for the class (see description).
|
||||
* @return {Function} A custom class, created from the provided main and extension classes
|
||||
*/
|
||||
Base.build = function(name, main, extensions, cfg) {
|
||||
return build(name, main, extensions, null, null, cfg);
|
||||
};
|
||||
|
||||
/**
|
||||
* <p>Creates a new class (constructor function) which extends the base class passed in as the second argument,
|
||||
* and mixes in the array of extensions provided.</p>
|
||||
* <p>Prototype properties or methods can be added to the new class, using the px argument (similar to Y.extend).</p>
|
||||
* <p>Static properties or methods can be added to the new class, using the sx argument (similar to Y.extend).</p>
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
* @method Base.create
|
||||
* @static
|
||||
* @param {Function} name The name of the newly created class. Used to defined the NAME property for the new class.
|
||||
* @param {Function} main The base class which the new class should extend. This class needs to be Base or a class derived from base (e.g. Widget).
|
||||
* @param {Function[]} extensions The list of extensions which will be mixed into the built class.
|
||||
* @param {Object} px The set of prototype properties/methods to add to the built class.
|
||||
* @param {Object} sx The set of static properties/methods to add to the built class.
|
||||
* @return {Function} The newly created class.
|
||||
*/
|
||||
Base.create = function(name, base, extensions, px, sx) {
|
||||
return build(name, base, extensions, px, sx);
|
||||
};
|
||||
|
||||
/**
|
||||
* <p>Mixes in a list of extensions to an existing class.</p>
|
||||
* @method Base.mix
|
||||
* @static
|
||||
* @param {Function} main The existing class into which the extensions should be mixed. The class needs to be Base or class derived from base (e.g. Widget)
|
||||
* @param {Function[]} extensions The set of extension classes which will mixed into the existing main class.
|
||||
* @return {Function} The modified main class, with extensions mixed in.
|
||||
*/
|
||||
Base.mix = function(main, extensions) {
|
||||
return build(null, main, extensions, null, null, {dynamic:false});
|
||||
};
|
||||
|
||||
/**
|
||||
* The build configuration for the Base class.
|
||||
*
|
||||
* Defines the static fields which need to be aggregated
|
||||
* when the Base class is used as the main class passed to
|
||||
* the <a href="#method_Base.build">Base.build</a> method.
|
||||
*
|
||||
* @property Base._buildCfg
|
||||
* @type Object
|
||||
* @static
|
||||
* @final
|
||||
* @private
|
||||
*/
|
||||
Base._buildCfg = {
|
||||
custom : {
|
||||
ATTRS : function(prop, r, s) {
|
||||
|
||||
r.ATTRS = r.ATTRS || {};
|
||||
|
||||
if (s.ATTRS) {
|
||||
|
||||
var sAttrs = s.ATTRS,
|
||||
rAttrs = r.ATTRS,
|
||||
a;
|
||||
|
||||
for (a in sAttrs) {
|
||||
if (sAttrs.hasOwnProperty(a)) {
|
||||
rAttrs[a] = rAttrs[a] || {};
|
||||
Y.mix(rAttrs[a], sAttrs[a], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
aggregates : ["_PLUG", "_UNPLUG"]
|
||||
};
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['base-base']});
|
||||
|
||||
|
||||
YUI.add('base', function(Y){}, '3.2.0' ,{use:['base-base', 'base-pluginhost', 'base-build']});
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("cache-base",function(D){var A=D.Lang,B=D.Lang.isDate,C=function(){C.superclass.constructor.apply(this,arguments);};D.mix(C,{NAME:"cache",ATTRS:{max:{value:0,setter:"_setMax"},size:{readOnly:true,getter:"_getSize"},uniqueKeys:{value:false},expires:{value:0,validator:function(E){return D.Lang.isDate(E)||(D.Lang.isNumber(E)&&E>=0);}},entries:{readOnly:true,getter:"_getEntries"}}});D.extend(C,D.Base,{_entries:null,initializer:function(E){this.publish("add",{defaultFn:this._defAddFn});this.publish("flush",{defaultFn:this._defFlushFn});this._entries=[];},destructor:function(){this._entries=[];},_setMax:function(F){var E=this._entries;if(F>0){if(E){while(E.length>F){E.shift();}}}else{F=0;this._entries=[];}return F;},_getSize:function(){return this._entries.length;},_getEntries:function(){return this._entries;},_defAddFn:function(H){var F=this._entries,E=this.get("max"),G=H.entry;if(this.get("uniqueKeys")&&(this.retrieve(H.entry.request))){F.shift();}while(E&&F.length>=E){F.shift();}F[F.length]=G;},_defFlushFn:function(E){this._entries=[];},_isMatch:function(F,E){if(!E.expires||new Date()<E.expires){return(F===E.request);}return false;},add:function(G,F){var E=this.get("expires");if(this.get("initialized")&&((this.get("max")===null)||this.get("max")>0)&&(A.isValue(G)||A.isNull(G)||A.isUndefined(G))){this.fire("add",{entry:{request:G,response:F,cached:new Date(),expires:B(E)?E:(E?new Date(new Date().getTime()+this.get("expires")):null)}});}else{}},flush:function(){this.fire("flush");},retrieve:function(I){var E=this._entries,H=E.length,G=null,F=H-1;if((H>0)&&((this.get("max")===null)||(this.get("max")>0))){this.fire("request",{request:I});for(;F>=0;F--){G=E[F];if(this._isMatch(I,G)){this.fire("retrieve",{entry:G});if(F<H-1){E.splice(F,1);E[E.length]=G;}return G;}}}return null;}});D.Cache=C;},"3.2.0",{requires:["base"]});
|
||||
-769
@@ -1,769 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('cache-base', function(Y) {
|
||||
|
||||
/**
|
||||
* The Cache utility provides a common configurable interface for components to
|
||||
* cache and retrieve data from a local JavaScript struct.
|
||||
*
|
||||
* @module cache
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
isDate = Y.Lang.isDate,
|
||||
|
||||
/**
|
||||
* Base class for the YUI Cache utility.
|
||||
* @class Cache
|
||||
* @extends Base
|
||||
* @constructor
|
||||
*/
|
||||
Cache = function() {
|
||||
Cache.superclass.constructor.apply(this, arguments);
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cache static properties
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Y.mix(Cache, {
|
||||
/**
|
||||
* Class name.
|
||||
*
|
||||
* @property NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "cache"
|
||||
*/
|
||||
NAME: "cache",
|
||||
|
||||
|
||||
ATTRS: {
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cache Attributes
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @attribute max
|
||||
* @description Maximum number of entries the Cache can hold.
|
||||
* Set to 0 to turn off caching.
|
||||
* @type Number
|
||||
* @default 0
|
||||
*/
|
||||
max: {
|
||||
value: 0,
|
||||
setter: "_setMax"
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute size
|
||||
* @description Number of entries currently cached.
|
||||
* @type Number
|
||||
*/
|
||||
size: {
|
||||
readOnly: true,
|
||||
getter: "_getSize"
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute uniqueKeys
|
||||
* @description Validate uniqueness of stored keys. Default is false and
|
||||
* is more performant.
|
||||
* @type Boolean
|
||||
*/
|
||||
uniqueKeys: {
|
||||
value: false
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute expires
|
||||
* @description Absolute Date when data expires or
|
||||
* relative number of milliseconds. Zero disables expiration.
|
||||
* @type Date | Number
|
||||
* @default 0
|
||||
*/
|
||||
expires: {
|
||||
value: 0,
|
||||
validator: function(v) {
|
||||
return Y.Lang.isDate(v) || (Y.Lang.isNumber(v) && v >= 0);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute entries
|
||||
* @description Cached entries.
|
||||
* @type Array
|
||||
*/
|
||||
entries: {
|
||||
readOnly: true,
|
||||
getter: "_getEntries"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Y.extend(Cache, Y.Base, {
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cache private properties
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Array of request/response objects indexed chronologically.
|
||||
*
|
||||
* @property _entries
|
||||
* @type Object[]
|
||||
* @private
|
||||
*/
|
||||
_entries: null,
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cache private methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @method initializer
|
||||
* @description Internal init() handler.
|
||||
* @param config {Object} Config object.
|
||||
* @private
|
||||
*/
|
||||
initializer: function(config) {
|
||||
|
||||
/**
|
||||
* @event add
|
||||
* @description Fired when an entry is added.
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>entry (Object)</dt> <dd>The cached entry.</dd>
|
||||
* </dl>
|
||||
* @preventable _defAddFn
|
||||
*/
|
||||
this.publish("add", {defaultFn: this._defAddFn});
|
||||
|
||||
/**
|
||||
* @event flush
|
||||
* @description Fired when the cache is flushed.
|
||||
* @param e {Event.Facade} Event Facade object.
|
||||
* @preventable _defFlushFn
|
||||
*/
|
||||
this.publish("flush", {defaultFn: this._defFlushFn});
|
||||
|
||||
/**
|
||||
* @event request
|
||||
* @description Fired when an entry is requested from the cache.
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>request (Object)</dt> <dd>The request object.</dd>
|
||||
* </dl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @event retrieve
|
||||
* @description Fired when an entry is retrieved from the cache.
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>entry (Object)</dt> <dd>The retrieved entry.</dd>
|
||||
* </dl>
|
||||
*/
|
||||
|
||||
// Initialize internal values
|
||||
this._entries = [];
|
||||
Y.log("Cache initialized", "info", "cache");
|
||||
},
|
||||
|
||||
/**
|
||||
* @method destructor
|
||||
* @description Internal destroy() handler.
|
||||
* @private
|
||||
*/
|
||||
destructor: function() {
|
||||
this._entries = [];
|
||||
Y.log("Cache destroyed", "info", "cache");
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cache protected methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Sets max.
|
||||
*
|
||||
* @method _setMax
|
||||
* @protected
|
||||
*/
|
||||
_setMax: function(value) {
|
||||
// If the cache is full, make room by removing stalest element (index=0)
|
||||
var entries = this._entries;
|
||||
if(value > 0) {
|
||||
if(entries) {
|
||||
while(entries.length > value) {
|
||||
entries.shift();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
value = 0;
|
||||
this._entries = [];
|
||||
}
|
||||
return value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets size.
|
||||
*
|
||||
* @method _getSize
|
||||
* @protected
|
||||
*/
|
||||
_getSize: function() {
|
||||
return this._entries.length;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets all entries.
|
||||
*
|
||||
* @method _getEntries
|
||||
* @protected
|
||||
*/
|
||||
_getEntries: function() {
|
||||
return this._entries;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Adds entry to cache.
|
||||
*
|
||||
* @method _defAddFn
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>entry (Object)</dt> <dd>The cached entry.</dd>
|
||||
* </dl>
|
||||
* @protected
|
||||
*/
|
||||
_defAddFn: function(e) {
|
||||
var entries = this._entries,
|
||||
max = this.get("max"),
|
||||
entry = e.entry;
|
||||
|
||||
if(this.get("uniqueKeys") && (this.retrieve(e.entry.request))) {
|
||||
entries.shift();
|
||||
}
|
||||
|
||||
|
||||
// If the cache at or over capacity, make room by removing stalest element (index=0)
|
||||
while(max && entries.length>=max) {
|
||||
entries.shift();
|
||||
}
|
||||
|
||||
// Add entry to cache in the newest position, at the end of the array
|
||||
entries[entries.length] = entry;
|
||||
Y.log("Cached entry: " + Y.dump(entry), "info", "cache");
|
||||
},
|
||||
|
||||
/**
|
||||
* Flushes cache.
|
||||
*
|
||||
* @method _defFlushFn
|
||||
* @param e {Event.Facade} Event Facade object.
|
||||
* @protected
|
||||
*/
|
||||
_defFlushFn: function(e) {
|
||||
this._entries = [];
|
||||
Y.log("Cache flushed", "info", "cache");
|
||||
},
|
||||
|
||||
/**
|
||||
* Default overridable method compares current request with given cache entry.
|
||||
* Returns true if current request matches the cached request, otherwise
|
||||
* false. Implementers should override this method to customize the
|
||||
* cache-matching algorithm.
|
||||
*
|
||||
* @method _isMatch
|
||||
* @param request {Object} Request object.
|
||||
* @param entry {Object} Cached entry.
|
||||
* @return {Boolean} True if current request matches given cached request, false otherwise.
|
||||
* @protected
|
||||
*/
|
||||
_isMatch: function(request, entry) {
|
||||
if(!entry.expires || new Date() < entry.expires) {
|
||||
return (request === entry.request);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cache public methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Adds a new entry to the cache of the format
|
||||
* {request:request, response:response, cached:cached, expires:expires}.
|
||||
* If cache is full, evicts the stalest entry before adding the new one.
|
||||
*
|
||||
* @method add
|
||||
* @param request {Object} Request value.
|
||||
* @param response {Object} Response value.
|
||||
*/
|
||||
add: function(request, response) {
|
||||
var expires = this.get("expires");
|
||||
if(this.get("initialized") && ((this.get("max") === null) || this.get("max") > 0) &&
|
||||
(LANG.isValue(request) || LANG.isNull(request) || LANG.isUndefined(request))) {
|
||||
this.fire("add", {entry: {
|
||||
request:request,
|
||||
response:response,
|
||||
cached: new Date(),
|
||||
expires: isDate(expires) ? expires :
|
||||
(expires ? new Date(new Date().getTime() + this.get("expires")) : null)
|
||||
}});
|
||||
}
|
||||
else {
|
||||
Y.log("Could not add " + Y.dump(response) + " to cache for " + Y.dump(request), "info", "cache");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Flushes cache.
|
||||
*
|
||||
* @method flush
|
||||
*/
|
||||
flush: function() {
|
||||
this.fire("flush");
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieves cached object for given request, if available, and refreshes
|
||||
* entry in the cache. Returns null if there is no cache match.
|
||||
*
|
||||
* @method retrieve
|
||||
* @param request {Object} Request object.
|
||||
* @return {Object} Cached object with the properties request and response, or null.
|
||||
*/
|
||||
retrieve: function(request) {
|
||||
// If cache is enabled...
|
||||
var entries = this._entries,
|
||||
length = entries.length,
|
||||
entry = null,
|
||||
i = length-1;
|
||||
|
||||
if((length > 0) && ((this.get("max") === null) || (this.get("max") > 0))) {
|
||||
this.fire("request", {request: request});
|
||||
|
||||
// Loop through each cached entry starting from the newest
|
||||
for(; i >= 0; i--) {
|
||||
entry = entries[i];
|
||||
|
||||
// Execute matching function
|
||||
if(this._isMatch(request, entry)) {
|
||||
this.fire("retrieve", {entry: entry});
|
||||
|
||||
// Refresh the position of the cache hit
|
||||
if(i < length-1) {
|
||||
// Remove element from its original location
|
||||
entries.splice(i,1);
|
||||
// Add as newest
|
||||
entries[entries.length] = entry;
|
||||
Y.log("Refreshed cache entry: " + Y.dump(entry) +
|
||||
" for request: " + Y.dump(request), "info", "cache");
|
||||
}
|
||||
|
||||
Y.log("Retrieved cached response: " + Y.dump(entry) +
|
||||
" for request: " + Y.dump(request), "info", "cache");
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
Y.Cache = Cache;
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['base']});
|
||||
|
||||
YUI.add('cache-offline', function(Y) {
|
||||
|
||||
/**
|
||||
* Extends Cache utility with offline functionality.
|
||||
* @class CacheOffline
|
||||
* @extends Cache
|
||||
* @constructor
|
||||
*/
|
||||
function CacheOffline() {
|
||||
CacheOffline.superclass.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
var localStorage = Y.config.win.localStorage,
|
||||
JSON = Y.JSON,
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CacheOffline static properties
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
cacheOfflineStatic = {
|
||||
/**
|
||||
* Class name.
|
||||
*
|
||||
* @property NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "cacheOffline"
|
||||
*/
|
||||
NAME: "cacheOffline",
|
||||
|
||||
ATTRS: {
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CacheOffline Attributes
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @attribute sandbox
|
||||
* @description A string that must be passed in via the constructor.
|
||||
* This identifier is used to sandbox one cache instance's entries
|
||||
* from another. Calling the cache instance's flush and length methods
|
||||
* or get("entries") will apply to only these sandboxed entries.
|
||||
* @type String
|
||||
* @default "default"
|
||||
* @initOnly
|
||||
*/
|
||||
sandbox: {
|
||||
value: "default",
|
||||
writeOnce: "initOnly"
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute expires
|
||||
* @description Absolute Date when data expires or
|
||||
* relative number of milliseconds. Zero disables expiration.
|
||||
* @type Date | Number
|
||||
* @default 86400000 (one day)
|
||||
*/
|
||||
expires: {
|
||||
value: 86400000
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute max
|
||||
* @description Disabled.
|
||||
* @readOnly
|
||||
* @default null
|
||||
*/
|
||||
max: {
|
||||
value: null,
|
||||
readOnly: true
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute uniqueKeys
|
||||
* @description Always true for CacheOffline.
|
||||
* @readOnly
|
||||
* @default true
|
||||
*/
|
||||
uniqueKeys: {
|
||||
value: true,
|
||||
readOnly: true,
|
||||
setter: function() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes all items from all sandboxes. Useful if localStorage has
|
||||
* exceeded quota. Only supported on browsers that implement HTML 5
|
||||
* localStorage.
|
||||
*
|
||||
* @method flushAll
|
||||
* @static
|
||||
*/
|
||||
flushAll: function() {
|
||||
var store = localStorage, key;
|
||||
if(store) {
|
||||
if(store.clear) {
|
||||
store.clear();
|
||||
}
|
||||
// FF2.x and FF3.0.x
|
||||
else {
|
||||
for (key in store) {
|
||||
if (store.hasOwnProperty(key)) {
|
||||
store.removeItem(key);
|
||||
delete store[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
Y.log("All sandboxes of OfflineCache flushed", "info", "cache");
|
||||
}
|
||||
else {
|
||||
Y.log("Could not flush all OfflineCache sandboxes.", "warn", "cache");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CacheOffline events
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @event error
|
||||
* @description Fired when an entry could not be added, most likely due to
|
||||
* exceeded browser quota.
|
||||
* <dl>
|
||||
* <dt>error (Object)</dt> <dd>The error object.</dd>
|
||||
* </dl>
|
||||
*/
|
||||
|
||||
cacheOfflinePrototype = localStorage ? {
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CacheOffline protected methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Always return null.
|
||||
*
|
||||
* @method _setMax
|
||||
* @protected
|
||||
*/
|
||||
_setMax: function(value) {
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets size.
|
||||
*
|
||||
* @method _getSize
|
||||
* @protected
|
||||
*/
|
||||
_getSize: function() {
|
||||
var count = 0,
|
||||
i=0,
|
||||
l=localStorage.length;
|
||||
for(; i<l; ++i) {
|
||||
// Match sandbox id
|
||||
if(localStorage.key(i).indexOf(this.get("sandbox")) === 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets all entries.
|
||||
*
|
||||
* @method _getEntries
|
||||
* @protected
|
||||
*/
|
||||
_getEntries: function() {
|
||||
var entries = [],
|
||||
i=0,
|
||||
l=localStorage.length,
|
||||
sandbox = this.get("sandbox");
|
||||
for(; i<l; ++i) {
|
||||
// Match sandbox id
|
||||
if(localStorage.key(i).indexOf(sandbox) === 0) {
|
||||
entries[i] = JSON.parse(localStorage.key(i).substring(sandbox.length));
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds entry to cache.
|
||||
*
|
||||
* @method _defAddFn
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>entry (Object)</dt> <dd>The cached entry.</dd>
|
||||
* </dl>
|
||||
* @protected
|
||||
*/
|
||||
_defAddFn: function(e) {
|
||||
var entry = e.entry,
|
||||
request = entry.request,
|
||||
cached = entry.cached,
|
||||
expires = entry.expires;
|
||||
|
||||
// Convert Dates to msecs on the way into localStorage
|
||||
entry.cached = cached.getTime();
|
||||
entry.expires = expires ? expires.getTime() : expires;
|
||||
|
||||
try {
|
||||
localStorage.setItem(this.get("sandbox")+JSON.stringify({"request":request}), JSON.stringify(entry));
|
||||
Y.log("Cached offline entry: " + Y.dump(entry), "info", "cache");
|
||||
}
|
||||
catch(error) {
|
||||
this.fire("error", {error:error});
|
||||
Y.log("Could not cache offline entry: " + Y.dump(entry) +
|
||||
" due to error: " + Y.dump(error), "warn", "cache");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Flushes cache.
|
||||
*
|
||||
* @method _defFlushFn
|
||||
* @param e {Event.Facade} Event Facade object.
|
||||
* @protected
|
||||
*/
|
||||
_defFlushFn: function(e) {
|
||||
var key,
|
||||
i=localStorage.length-1;
|
||||
for(; i>-1; --i) {
|
||||
// Match sandbox id
|
||||
key = localStorage.key(i);
|
||||
if(key.indexOf(this.get("sandbox")) === 0) {
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CacheOffline public methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Adds a new entry to the cache of the format
|
||||
* {request:request, response:response, cached:cached, expires: expires}.
|
||||
*
|
||||
* @method add
|
||||
* @param request {Object} Request value must be a String or JSON.
|
||||
* @param response {Object} Response value must be a String or JSON.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Retrieves cached object for given request, if available.
|
||||
* Returns null if there is no cache match.
|
||||
*
|
||||
* @method retrieve
|
||||
* @param request {Object} Request object.
|
||||
* @return {Object} Cached object with the properties request, response,
|
||||
* and expires, or null.
|
||||
*/
|
||||
retrieve: function(request) {
|
||||
this.fire("request", {request: request});
|
||||
|
||||
var entry, expires, sandboxedrequest;
|
||||
|
||||
try {
|
||||
sandboxedrequest = this.get("sandbox")+JSON.stringify({"request":request});
|
||||
try {
|
||||
entry = JSON.parse(localStorage.getItem(sandboxedrequest));
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
}
|
||||
catch(e2) {
|
||||
}
|
||||
|
||||
if(entry) {
|
||||
// Convert msecs to Dates on the way out of localStorage
|
||||
entry.cached = new Date(entry.cached);
|
||||
expires = entry.expires;
|
||||
expires = !expires ? null : new Date(expires);
|
||||
entry.expires = expires;
|
||||
|
||||
if(this._isMatch(request, entry)) {
|
||||
this.fire("retrieve", {entry: entry});
|
||||
Y.log("Retrieved offlinecached response: " + Y.dump(entry) +
|
||||
" for request: " + Y.dump(request), "info", "cache");
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
} : {
|
||||
/**
|
||||
* Always return null.
|
||||
*
|
||||
* @method _setMax
|
||||
* @protected
|
||||
*/
|
||||
_setMax: function(value) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
Y.mix(CacheOffline, cacheOfflineStatic);
|
||||
Y.extend(CacheOffline, Y.Cache, cacheOfflinePrototype);
|
||||
|
||||
|
||||
Y.CacheOffline = CacheOffline;
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['cache-base', 'json']});
|
||||
|
||||
YUI.add('cache-plugin', function(Y) {
|
||||
|
||||
/**
|
||||
* Plugin.Cache adds pluginizability to Cache.
|
||||
* @class Plugin.Cache
|
||||
* @extends Cache
|
||||
* @uses Plugin.Base
|
||||
*/
|
||||
function CachePlugin(config) {
|
||||
var cache = config && config.cache ? config.cache : Y.Cache,
|
||||
tmpclass = Y.Base.create("dataSourceCache", cache, [Y.Plugin.Base]),
|
||||
tmpinstance = new tmpclass(config);
|
||||
tmpclass.NS = "tmpClass";
|
||||
return tmpinstance;
|
||||
}
|
||||
|
||||
Y.mix(CachePlugin, {
|
||||
/**
|
||||
* The namespace for the plugin. This will be the property on the host which
|
||||
* references the plugin instance.
|
||||
*
|
||||
* @property NS
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "cache"
|
||||
*/
|
||||
NS: "cache",
|
||||
|
||||
/**
|
||||
* Class name.
|
||||
*
|
||||
* @property NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "dataSourceCache"
|
||||
*/
|
||||
NAME: "cachePlugin"
|
||||
});
|
||||
|
||||
|
||||
Y.namespace("Plugin").Cache = CachePlugin;
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['cache-base']});
|
||||
|
||||
|
||||
|
||||
YUI.add('cache', function(Y){}, '3.2.0' ,{use:['cache-base','cache-offline','cache-plugin']});
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("cache-base",function(D){var A=D.Lang,B=D.Lang.isDate,C=function(){C.superclass.constructor.apply(this,arguments);};D.mix(C,{NAME:"cache",ATTRS:{max:{value:0,setter:"_setMax"},size:{readOnly:true,getter:"_getSize"},uniqueKeys:{value:false},expires:{value:0,validator:function(E){return D.Lang.isDate(E)||(D.Lang.isNumber(E)&&E>=0);}},entries:{readOnly:true,getter:"_getEntries"}}});D.extend(C,D.Base,{_entries:null,initializer:function(E){this.publish("add",{defaultFn:this._defAddFn});this.publish("flush",{defaultFn:this._defFlushFn});this._entries=[];},destructor:function(){this._entries=[];},_setMax:function(F){var E=this._entries;if(F>0){if(E){while(E.length>F){E.shift();}}}else{F=0;this._entries=[];}return F;},_getSize:function(){return this._entries.length;},_getEntries:function(){return this._entries;},_defAddFn:function(H){var F=this._entries,E=this.get("max"),G=H.entry;if(this.get("uniqueKeys")&&(this.retrieve(H.entry.request))){F.shift();}while(E&&F.length>=E){F.shift();}F[F.length]=G;},_defFlushFn:function(E){this._entries=[];},_isMatch:function(F,E){if(!E.expires||new Date()<E.expires){return(F===E.request);}return false;},add:function(G,F){var E=this.get("expires");if(this.get("initialized")&&((this.get("max")===null)||this.get("max")>0)&&(A.isValue(G)||A.isNull(G)||A.isUndefined(G))){this.fire("add",{entry:{request:G,response:F,cached:new Date(),expires:B(E)?E:(E?new Date(new Date().getTime()+this.get("expires")):null)}});}else{}},flush:function(){this.fire("flush");},retrieve:function(I){var E=this._entries,H=E.length,G=null,F=H-1;if((H>0)&&((this.get("max")===null)||(this.get("max")>0))){this.fire("request",{request:I});for(;F>=0;F--){G=E[F];if(this._isMatch(I,G)){this.fire("retrieve",{entry:G});if(F<H-1){E.splice(F,1);E[E.length]=G;}return G;}}}return null;}});D.Cache=C;},"3.2.0",{requires:["base"]});YUI.add("cache-offline",function(E){function D(){D.superclass.constructor.apply(this,arguments);}var A=E.config.win.localStorage,C=E.JSON,F={NAME:"cacheOffline",ATTRS:{sandbox:{value:"default",writeOnce:"initOnly"},expires:{value:86400000},max:{value:null,readOnly:true},uniqueKeys:{value:true,readOnly:true,setter:function(){return true;}}},flushAll:function(){var G=A,H;if(G){if(G.clear){G.clear();}else{for(H in G){if(G.hasOwnProperty(H)){G.removeItem(H);delete G[H];}}}}else{}}},B=A?{_setMax:function(G){return null;},_getSize:function(){var I=0,H=0,G=A.length;for(;H<G;++H){if(A.key(H).indexOf(this.get("sandbox"))===0){I++;}}return I;},_getEntries:function(){var G=[],J=0,I=A.length,H=this.get("sandbox");for(;J<I;++J){if(A.key(J).indexOf(H)===0){G[J]=C.parse(A.key(J).substring(H.length));}}return G;},_defAddFn:function(L){var K=L.entry,J=K.request,I=K.cached,G=K.expires;K.cached=I.getTime();K.expires=G?G.getTime():G;try{A.setItem(this.get("sandbox")+C.stringify({"request":J}),C.stringify(K));}catch(H){this.fire("error",{error:H});}},_defFlushFn:function(I){var H,G=A.length-1;for(;G>-1;--G){H=A.key(G);if(H.indexOf(this.get("sandbox"))===0){A.removeItem(H);}}},retrieve:function(J){this.fire("request",{request:J});var I,G,H;try{H=this.get("sandbox")+C.stringify({"request":J});try{I=C.parse(A.getItem(H));}catch(L){}}catch(K){}if(I){I.cached=new Date(I.cached);G=I.expires;G=!G?null:new Date(G);I.expires=G;if(this._isMatch(J,I)){this.fire("retrieve",{entry:I});return I;}}return null;}}:{_setMax:function(G){return null;}};E.mix(D,F);E.extend(D,E.Cache,B);E.CacheOffline=D;},"3.2.0",{requires:["cache-base","json"]});YUI.add("cache-plugin",function(B){function A(E){var D=E&&E.cache?E.cache:B.Cache,F=B.Base.create("dataSourceCache",D,[B.Plugin.Base]),C=new F(E);F.NS="tmpClass";return C;}B.mix(A,{NS:"cache",NAME:"cachePlugin"});B.namespace("Plugin").Cache=A;},"3.2.0",{requires:["cache-base"]});YUI.add("cache",function(A){},"3.2.0",{use:["cache-base","cache-offline","cache-plugin"]});
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("cache-offline",function(E){function D(){D.superclass.constructor.apply(this,arguments);}var A=E.config.win.localStorage,C=E.JSON,F={NAME:"cacheOffline",ATTRS:{sandbox:{value:"default",writeOnce:"initOnly"},expires:{value:86400000},max:{value:null,readOnly:true},uniqueKeys:{value:true,readOnly:true,setter:function(){return true;}}},flushAll:function(){var G=A,H;if(G){if(G.clear){G.clear();}else{for(H in G){if(G.hasOwnProperty(H)){G.removeItem(H);delete G[H];}}}}else{}}},B=A?{_setMax:function(G){return null;},_getSize:function(){var I=0,H=0,G=A.length;for(;H<G;++H){if(A.key(H).indexOf(this.get("sandbox"))===0){I++;}}return I;},_getEntries:function(){var G=[],J=0,I=A.length,H=this.get("sandbox");for(;J<I;++J){if(A.key(J).indexOf(H)===0){G[J]=C.parse(A.key(J).substring(H.length));}}return G;},_defAddFn:function(L){var K=L.entry,J=K.request,I=K.cached,G=K.expires;K.cached=I.getTime();K.expires=G?G.getTime():G;try{A.setItem(this.get("sandbox")+C.stringify({"request":J}),C.stringify(K));}catch(H){this.fire("error",{error:H});}},_defFlushFn:function(I){var H,G=A.length-1;for(;G>-1;--G){H=A.key(G);if(H.indexOf(this.get("sandbox"))===0){A.removeItem(H);}}},retrieve:function(J){this.fire("request",{request:J});var I,G,H;try{H=this.get("sandbox")+C.stringify({"request":J});try{I=C.parse(A.getItem(H));}catch(L){}}catch(K){}if(I){I.cached=new Date(I.cached);G=I.expires;G=!G?null:new Date(G);I.expires=G;if(this._isMatch(J,I)){this.fire("retrieve",{entry:I});return I;}}return null;}}:{_setMax:function(G){return null;}};E.mix(D,F);E.extend(D,E.Cache,B);E.CacheOffline=D;},"3.2.0",{requires:["cache-base","json"]});
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("cache-plugin",function(B){function A(E){var D=E&&E.cache?E.cache:B.Cache,F=B.Base.create("dataSourceCache",D,[B.Plugin.Base]),C=new F(E);F.NS="tmpClass";return C;}B.mix(A,{NS:"cache",NAME:"cachePlugin"});B.namespace("Plugin").Cache=A;},"3.2.0",{requires:["cache-base"]});
|
||||
Vendored
-753
@@ -1,753 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('cache-base', function(Y) {
|
||||
|
||||
/**
|
||||
* The Cache utility provides a common configurable interface for components to
|
||||
* cache and retrieve data from a local JavaScript struct.
|
||||
*
|
||||
* @module cache
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
isDate = Y.Lang.isDate,
|
||||
|
||||
/**
|
||||
* Base class for the YUI Cache utility.
|
||||
* @class Cache
|
||||
* @extends Base
|
||||
* @constructor
|
||||
*/
|
||||
Cache = function() {
|
||||
Cache.superclass.constructor.apply(this, arguments);
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cache static properties
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Y.mix(Cache, {
|
||||
/**
|
||||
* Class name.
|
||||
*
|
||||
* @property NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "cache"
|
||||
*/
|
||||
NAME: "cache",
|
||||
|
||||
|
||||
ATTRS: {
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cache Attributes
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @attribute max
|
||||
* @description Maximum number of entries the Cache can hold.
|
||||
* Set to 0 to turn off caching.
|
||||
* @type Number
|
||||
* @default 0
|
||||
*/
|
||||
max: {
|
||||
value: 0,
|
||||
setter: "_setMax"
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute size
|
||||
* @description Number of entries currently cached.
|
||||
* @type Number
|
||||
*/
|
||||
size: {
|
||||
readOnly: true,
|
||||
getter: "_getSize"
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute uniqueKeys
|
||||
* @description Validate uniqueness of stored keys. Default is false and
|
||||
* is more performant.
|
||||
* @type Boolean
|
||||
*/
|
||||
uniqueKeys: {
|
||||
value: false
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute expires
|
||||
* @description Absolute Date when data expires or
|
||||
* relative number of milliseconds. Zero disables expiration.
|
||||
* @type Date | Number
|
||||
* @default 0
|
||||
*/
|
||||
expires: {
|
||||
value: 0,
|
||||
validator: function(v) {
|
||||
return Y.Lang.isDate(v) || (Y.Lang.isNumber(v) && v >= 0);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute entries
|
||||
* @description Cached entries.
|
||||
* @type Array
|
||||
*/
|
||||
entries: {
|
||||
readOnly: true,
|
||||
getter: "_getEntries"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Y.extend(Cache, Y.Base, {
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cache private properties
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Array of request/response objects indexed chronologically.
|
||||
*
|
||||
* @property _entries
|
||||
* @type Object[]
|
||||
* @private
|
||||
*/
|
||||
_entries: null,
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cache private methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @method initializer
|
||||
* @description Internal init() handler.
|
||||
* @param config {Object} Config object.
|
||||
* @private
|
||||
*/
|
||||
initializer: function(config) {
|
||||
|
||||
/**
|
||||
* @event add
|
||||
* @description Fired when an entry is added.
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>entry (Object)</dt> <dd>The cached entry.</dd>
|
||||
* </dl>
|
||||
* @preventable _defAddFn
|
||||
*/
|
||||
this.publish("add", {defaultFn: this._defAddFn});
|
||||
|
||||
/**
|
||||
* @event flush
|
||||
* @description Fired when the cache is flushed.
|
||||
* @param e {Event.Facade} Event Facade object.
|
||||
* @preventable _defFlushFn
|
||||
*/
|
||||
this.publish("flush", {defaultFn: this._defFlushFn});
|
||||
|
||||
/**
|
||||
* @event request
|
||||
* @description Fired when an entry is requested from the cache.
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>request (Object)</dt> <dd>The request object.</dd>
|
||||
* </dl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @event retrieve
|
||||
* @description Fired when an entry is retrieved from the cache.
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>entry (Object)</dt> <dd>The retrieved entry.</dd>
|
||||
* </dl>
|
||||
*/
|
||||
|
||||
// Initialize internal values
|
||||
this._entries = [];
|
||||
},
|
||||
|
||||
/**
|
||||
* @method destructor
|
||||
* @description Internal destroy() handler.
|
||||
* @private
|
||||
*/
|
||||
destructor: function() {
|
||||
this._entries = [];
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cache protected methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Sets max.
|
||||
*
|
||||
* @method _setMax
|
||||
* @protected
|
||||
*/
|
||||
_setMax: function(value) {
|
||||
// If the cache is full, make room by removing stalest element (index=0)
|
||||
var entries = this._entries;
|
||||
if(value > 0) {
|
||||
if(entries) {
|
||||
while(entries.length > value) {
|
||||
entries.shift();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
value = 0;
|
||||
this._entries = [];
|
||||
}
|
||||
return value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets size.
|
||||
*
|
||||
* @method _getSize
|
||||
* @protected
|
||||
*/
|
||||
_getSize: function() {
|
||||
return this._entries.length;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets all entries.
|
||||
*
|
||||
* @method _getEntries
|
||||
* @protected
|
||||
*/
|
||||
_getEntries: function() {
|
||||
return this._entries;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Adds entry to cache.
|
||||
*
|
||||
* @method _defAddFn
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>entry (Object)</dt> <dd>The cached entry.</dd>
|
||||
* </dl>
|
||||
* @protected
|
||||
*/
|
||||
_defAddFn: function(e) {
|
||||
var entries = this._entries,
|
||||
max = this.get("max"),
|
||||
entry = e.entry;
|
||||
|
||||
if(this.get("uniqueKeys") && (this.retrieve(e.entry.request))) {
|
||||
entries.shift();
|
||||
}
|
||||
|
||||
|
||||
// If the cache at or over capacity, make room by removing stalest element (index=0)
|
||||
while(max && entries.length>=max) {
|
||||
entries.shift();
|
||||
}
|
||||
|
||||
// Add entry to cache in the newest position, at the end of the array
|
||||
entries[entries.length] = entry;
|
||||
},
|
||||
|
||||
/**
|
||||
* Flushes cache.
|
||||
*
|
||||
* @method _defFlushFn
|
||||
* @param e {Event.Facade} Event Facade object.
|
||||
* @protected
|
||||
*/
|
||||
_defFlushFn: function(e) {
|
||||
this._entries = [];
|
||||
},
|
||||
|
||||
/**
|
||||
* Default overridable method compares current request with given cache entry.
|
||||
* Returns true if current request matches the cached request, otherwise
|
||||
* false. Implementers should override this method to customize the
|
||||
* cache-matching algorithm.
|
||||
*
|
||||
* @method _isMatch
|
||||
* @param request {Object} Request object.
|
||||
* @param entry {Object} Cached entry.
|
||||
* @return {Boolean} True if current request matches given cached request, false otherwise.
|
||||
* @protected
|
||||
*/
|
||||
_isMatch: function(request, entry) {
|
||||
if(!entry.expires || new Date() < entry.expires) {
|
||||
return (request === entry.request);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Cache public methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Adds a new entry to the cache of the format
|
||||
* {request:request, response:response, cached:cached, expires:expires}.
|
||||
* If cache is full, evicts the stalest entry before adding the new one.
|
||||
*
|
||||
* @method add
|
||||
* @param request {Object} Request value.
|
||||
* @param response {Object} Response value.
|
||||
*/
|
||||
add: function(request, response) {
|
||||
var expires = this.get("expires");
|
||||
if(this.get("initialized") && ((this.get("max") === null) || this.get("max") > 0) &&
|
||||
(LANG.isValue(request) || LANG.isNull(request) || LANG.isUndefined(request))) {
|
||||
this.fire("add", {entry: {
|
||||
request:request,
|
||||
response:response,
|
||||
cached: new Date(),
|
||||
expires: isDate(expires) ? expires :
|
||||
(expires ? new Date(new Date().getTime() + this.get("expires")) : null)
|
||||
}});
|
||||
}
|
||||
else {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Flushes cache.
|
||||
*
|
||||
* @method flush
|
||||
*/
|
||||
flush: function() {
|
||||
this.fire("flush");
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieves cached object for given request, if available, and refreshes
|
||||
* entry in the cache. Returns null if there is no cache match.
|
||||
*
|
||||
* @method retrieve
|
||||
* @param request {Object} Request object.
|
||||
* @return {Object} Cached object with the properties request and response, or null.
|
||||
*/
|
||||
retrieve: function(request) {
|
||||
// If cache is enabled...
|
||||
var entries = this._entries,
|
||||
length = entries.length,
|
||||
entry = null,
|
||||
i = length-1;
|
||||
|
||||
if((length > 0) && ((this.get("max") === null) || (this.get("max") > 0))) {
|
||||
this.fire("request", {request: request});
|
||||
|
||||
// Loop through each cached entry starting from the newest
|
||||
for(; i >= 0; i--) {
|
||||
entry = entries[i];
|
||||
|
||||
// Execute matching function
|
||||
if(this._isMatch(request, entry)) {
|
||||
this.fire("retrieve", {entry: entry});
|
||||
|
||||
// Refresh the position of the cache hit
|
||||
if(i < length-1) {
|
||||
// Remove element from its original location
|
||||
entries.splice(i,1);
|
||||
// Add as newest
|
||||
entries[entries.length] = entry;
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
Y.Cache = Cache;
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['base']});
|
||||
|
||||
YUI.add('cache-offline', function(Y) {
|
||||
|
||||
/**
|
||||
* Extends Cache utility with offline functionality.
|
||||
* @class CacheOffline
|
||||
* @extends Cache
|
||||
* @constructor
|
||||
*/
|
||||
function CacheOffline() {
|
||||
CacheOffline.superclass.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
var localStorage = Y.config.win.localStorage,
|
||||
JSON = Y.JSON,
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CacheOffline static properties
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
cacheOfflineStatic = {
|
||||
/**
|
||||
* Class name.
|
||||
*
|
||||
* @property NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "cacheOffline"
|
||||
*/
|
||||
NAME: "cacheOffline",
|
||||
|
||||
ATTRS: {
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CacheOffline Attributes
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @attribute sandbox
|
||||
* @description A string that must be passed in via the constructor.
|
||||
* This identifier is used to sandbox one cache instance's entries
|
||||
* from another. Calling the cache instance's flush and length methods
|
||||
* or get("entries") will apply to only these sandboxed entries.
|
||||
* @type String
|
||||
* @default "default"
|
||||
* @initOnly
|
||||
*/
|
||||
sandbox: {
|
||||
value: "default",
|
||||
writeOnce: "initOnly"
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute expires
|
||||
* @description Absolute Date when data expires or
|
||||
* relative number of milliseconds. Zero disables expiration.
|
||||
* @type Date | Number
|
||||
* @default 86400000 (one day)
|
||||
*/
|
||||
expires: {
|
||||
value: 86400000
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute max
|
||||
* @description Disabled.
|
||||
* @readOnly
|
||||
* @default null
|
||||
*/
|
||||
max: {
|
||||
value: null,
|
||||
readOnly: true
|
||||
},
|
||||
|
||||
/**
|
||||
* @attribute uniqueKeys
|
||||
* @description Always true for CacheOffline.
|
||||
* @readOnly
|
||||
* @default true
|
||||
*/
|
||||
uniqueKeys: {
|
||||
value: true,
|
||||
readOnly: true,
|
||||
setter: function() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes all items from all sandboxes. Useful if localStorage has
|
||||
* exceeded quota. Only supported on browsers that implement HTML 5
|
||||
* localStorage.
|
||||
*
|
||||
* @method flushAll
|
||||
* @static
|
||||
*/
|
||||
flushAll: function() {
|
||||
var store = localStorage, key;
|
||||
if(store) {
|
||||
if(store.clear) {
|
||||
store.clear();
|
||||
}
|
||||
// FF2.x and FF3.0.x
|
||||
else {
|
||||
for (key in store) {
|
||||
if (store.hasOwnProperty(key)) {
|
||||
store.removeItem(key);
|
||||
delete store[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CacheOffline events
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* @event error
|
||||
* @description Fired when an entry could not be added, most likely due to
|
||||
* exceeded browser quota.
|
||||
* <dl>
|
||||
* <dt>error (Object)</dt> <dd>The error object.</dd>
|
||||
* </dl>
|
||||
*/
|
||||
|
||||
cacheOfflinePrototype = localStorage ? {
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CacheOffline protected methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Always return null.
|
||||
*
|
||||
* @method _setMax
|
||||
* @protected
|
||||
*/
|
||||
_setMax: function(value) {
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets size.
|
||||
*
|
||||
* @method _getSize
|
||||
* @protected
|
||||
*/
|
||||
_getSize: function() {
|
||||
var count = 0,
|
||||
i=0,
|
||||
l=localStorage.length;
|
||||
for(; i<l; ++i) {
|
||||
// Match sandbox id
|
||||
if(localStorage.key(i).indexOf(this.get("sandbox")) === 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets all entries.
|
||||
*
|
||||
* @method _getEntries
|
||||
* @protected
|
||||
*/
|
||||
_getEntries: function() {
|
||||
var entries = [],
|
||||
i=0,
|
||||
l=localStorage.length,
|
||||
sandbox = this.get("sandbox");
|
||||
for(; i<l; ++i) {
|
||||
// Match sandbox id
|
||||
if(localStorage.key(i).indexOf(sandbox) === 0) {
|
||||
entries[i] = JSON.parse(localStorage.key(i).substring(sandbox.length));
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds entry to cache.
|
||||
*
|
||||
* @method _defAddFn
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>entry (Object)</dt> <dd>The cached entry.</dd>
|
||||
* </dl>
|
||||
* @protected
|
||||
*/
|
||||
_defAddFn: function(e) {
|
||||
var entry = e.entry,
|
||||
request = entry.request,
|
||||
cached = entry.cached,
|
||||
expires = entry.expires;
|
||||
|
||||
// Convert Dates to msecs on the way into localStorage
|
||||
entry.cached = cached.getTime();
|
||||
entry.expires = expires ? expires.getTime() : expires;
|
||||
|
||||
try {
|
||||
localStorage.setItem(this.get("sandbox")+JSON.stringify({"request":request}), JSON.stringify(entry));
|
||||
}
|
||||
catch(error) {
|
||||
this.fire("error", {error:error});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Flushes cache.
|
||||
*
|
||||
* @method _defFlushFn
|
||||
* @param e {Event.Facade} Event Facade object.
|
||||
* @protected
|
||||
*/
|
||||
_defFlushFn: function(e) {
|
||||
var key,
|
||||
i=localStorage.length-1;
|
||||
for(; i>-1; --i) {
|
||||
// Match sandbox id
|
||||
key = localStorage.key(i);
|
||||
if(key.indexOf(this.get("sandbox")) === 0) {
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CacheOffline public methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Adds a new entry to the cache of the format
|
||||
* {request:request, response:response, cached:cached, expires: expires}.
|
||||
*
|
||||
* @method add
|
||||
* @param request {Object} Request value must be a String or JSON.
|
||||
* @param response {Object} Response value must be a String or JSON.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Retrieves cached object for given request, if available.
|
||||
* Returns null if there is no cache match.
|
||||
*
|
||||
* @method retrieve
|
||||
* @param request {Object} Request object.
|
||||
* @return {Object} Cached object with the properties request, response,
|
||||
* and expires, or null.
|
||||
*/
|
||||
retrieve: function(request) {
|
||||
this.fire("request", {request: request});
|
||||
|
||||
var entry, expires, sandboxedrequest;
|
||||
|
||||
try {
|
||||
sandboxedrequest = this.get("sandbox")+JSON.stringify({"request":request});
|
||||
try {
|
||||
entry = JSON.parse(localStorage.getItem(sandboxedrequest));
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
}
|
||||
catch(e2) {
|
||||
}
|
||||
|
||||
if(entry) {
|
||||
// Convert msecs to Dates on the way out of localStorage
|
||||
entry.cached = new Date(entry.cached);
|
||||
expires = entry.expires;
|
||||
expires = !expires ? null : new Date(expires);
|
||||
entry.expires = expires;
|
||||
|
||||
if(this._isMatch(request, entry)) {
|
||||
this.fire("retrieve", {entry: entry});
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
} : {
|
||||
/**
|
||||
* Always return null.
|
||||
*
|
||||
* @method _setMax
|
||||
* @protected
|
||||
*/
|
||||
_setMax: function(value) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
Y.mix(CacheOffline, cacheOfflineStatic);
|
||||
Y.extend(CacheOffline, Y.Cache, cacheOfflinePrototype);
|
||||
|
||||
|
||||
Y.CacheOffline = CacheOffline;
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['cache-base', 'json']});
|
||||
|
||||
YUI.add('cache-plugin', function(Y) {
|
||||
|
||||
/**
|
||||
* Plugin.Cache adds pluginizability to Cache.
|
||||
* @class Plugin.Cache
|
||||
* @extends Cache
|
||||
* @uses Plugin.Base
|
||||
*/
|
||||
function CachePlugin(config) {
|
||||
var cache = config && config.cache ? config.cache : Y.Cache,
|
||||
tmpclass = Y.Base.create("dataSourceCache", cache, [Y.Plugin.Base]),
|
||||
tmpinstance = new tmpclass(config);
|
||||
tmpclass.NS = "tmpClass";
|
||||
return tmpinstance;
|
||||
}
|
||||
|
||||
Y.mix(CachePlugin, {
|
||||
/**
|
||||
* The namespace for the plugin. This will be the property on the host which
|
||||
* references the plugin instance.
|
||||
*
|
||||
* @property NS
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "cache"
|
||||
*/
|
||||
NS: "cache",
|
||||
|
||||
/**
|
||||
* Class name.
|
||||
*
|
||||
* @property NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "dataSourceCache"
|
||||
*/
|
||||
NAME: "cachePlugin"
|
||||
});
|
||||
|
||||
|
||||
Y.namespace("Plugin").Cache = CachePlugin;
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['cache-base']});
|
||||
|
||||
|
||||
|
||||
YUI.add('cache', function(Y){}, '3.2.0' ,{use:['cache-base','cache-offline','cache-plugin']});
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("classnamemanager",function(C){var B="classNamePrefix",D="classNameDelimiter",A=C.config;A[B]=A[B]||"yui3";A[D]=A[D]||"-";C.ClassNameManager=function(){var E=A[B],F=A[D];return{getClassName:C.cached(function(){var G=C.Array(arguments);if(G[G.length-1]!==true){G.unshift(E);}else{G.pop();}return G.join(F);})};}();},"3.2.0");
|
||||
@@ -1,306 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('array-extras', function(Y) {
|
||||
|
||||
/**
|
||||
* Collection utilities beyond what is provided in the YUI core
|
||||
* @module collection
|
||||
* @submodule array-extras
|
||||
*/
|
||||
|
||||
var L = Y.Lang, Native = Array.prototype, A = Y.Array;
|
||||
|
||||
/**
|
||||
* Adds the following array utilities to the YUI instance
|
||||
* (Y.Array). This is in addition to the methods provided
|
||||
* in the core.
|
||||
* @class YUI~array~extras
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the index of the last item in the array
|
||||
* that contains the specified value, -1 if the
|
||||
* value isn't found.
|
||||
* @method Array.lastIndexOf
|
||||
* @static
|
||||
* @param a {Array} the array to search
|
||||
* @param val the value to search for
|
||||
* @return {int} the index of hte item that contains the value or -1
|
||||
*/
|
||||
A.lastIndexOf = (Native.lastIndexOf) ?
|
||||
function(a ,val) {
|
||||
return a.lastIndexOf(val);
|
||||
} :
|
||||
function(a, val) {
|
||||
for (var i=a.length-1; i>=0; i=i-1) {
|
||||
if (a[i] === val) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a copy of the array with the duplicate entries removed
|
||||
* @method Array.unique
|
||||
* @static
|
||||
* @param a {Array} the array to find the subset of uniques for
|
||||
* @param sort {bool} flag to denote if the array is sorted or not. Defaults to false, the more general operation
|
||||
* @return {Array} a copy of the array with duplicate entries removed
|
||||
*/
|
||||
A.unique = function(a, sort) {
|
||||
var b = a.slice(), i = 0, n = -1, item = null;
|
||||
|
||||
while (i < b.length) {
|
||||
item = b[i];
|
||||
while ((n = A.lastIndexOf(b, item)) !== i) {
|
||||
b.splice(n, 1);
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
// Note: the sort option doesn't really belong here... I think it was added
|
||||
// because there was a way to fast path the two operations together. That
|
||||
// implementation was not working, so I replaced it with the following.
|
||||
// Leaving it in so that the API doesn't get broken.
|
||||
if (sort) {
|
||||
if (L.isNumber(b[0])) {
|
||||
b.sort(A.numericSort);
|
||||
} else {
|
||||
b.sort();
|
||||
}
|
||||
}
|
||||
|
||||
return b;
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* Returns a new array containing the items that the supplied
|
||||
* function returned true for.
|
||||
* @method Array.filter
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {Array} The items on which the supplied function
|
||||
* returned true. If no items matched an empty array is
|
||||
* returned.
|
||||
*/
|
||||
A.filter = (Native.filter) ?
|
||||
function(a, f, o) {
|
||||
return Native.filter.call(a, f, o);
|
||||
} :
|
||||
function(a, f, o) {
|
||||
var results = [];
|
||||
A.each(a, function(item, i, a) {
|
||||
if (f.call(o, item, i, a)) {
|
||||
results.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
/**
|
||||
* The inverse of filter. Executes the supplied function on each item.
|
||||
* Returns a new array containing the items that the supplied
|
||||
* function returned *false* for.
|
||||
* @method Array.reject
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {Array} The items on which the supplied function
|
||||
* returned false.
|
||||
*/
|
||||
A.reject = function(a, f, o) {
|
||||
return A.filter(a, function(item, i, a) {
|
||||
return !f.call(o, item, i, a);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* Iteration stops if the supplied function does not return
|
||||
* a truthy value.
|
||||
* @method Array.every
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {boolean} true if every item in the array returns true
|
||||
* from the supplied function.
|
||||
*/
|
||||
A.every = (Native.every) ?
|
||||
function(a, f, o) {
|
||||
return Native.every.call(a,f,o);
|
||||
} :
|
||||
function(a, f, o) {
|
||||
for (var i = 0, l = a.length; i < l; i=i+1) {
|
||||
if (!f.call(o, a[i], i, a)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* @method Array.map
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {Array} A new array containing the return value
|
||||
* of the supplied function for each item in the original
|
||||
* array.
|
||||
*/
|
||||
A.map = (Native.map) ?
|
||||
function(a, f, o) {
|
||||
return Native.map.call(a, f, o);
|
||||
} :
|
||||
function(a, f, o) {
|
||||
var results = [];
|
||||
A.each(a, function(item, i, a) {
|
||||
results.push(f.call(o, item, i, a));
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* Reduce "folds" the array into a single value. The callback
|
||||
* function receives four arguments:
|
||||
* the value from the previous callback call (or the initial value),
|
||||
* the value of the current element, the current index, and
|
||||
* the array over which iteration is occurring.
|
||||
* @method Array.reduce
|
||||
* @param a {Array} the array to iterate
|
||||
* @param init The initial value to start from
|
||||
* @param f {Function} the function to execute on each item. It
|
||||
* is responsible for returning the updated value of the
|
||||
* computation.
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return A value that results from iteratively applying the
|
||||
* supplied function to each element in the array.
|
||||
*/
|
||||
A.reduce = (Native.reduce) ?
|
||||
function(a, init, f, o) {
|
||||
//Firefox's Array.reduce does not allow inclusion of a
|
||||
// thisObject, so we need to implement it manually
|
||||
return Native.reduce.call(a, function(init, item, i, a) {
|
||||
return f.call(o, init, item, i, a);
|
||||
}, init);
|
||||
} :
|
||||
function(a, init, f, o) {
|
||||
var r = init;
|
||||
A.each(a, function (item, i, a) {
|
||||
r = f.call(o, r, item, i, a);
|
||||
});
|
||||
return r;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array,
|
||||
* searching for the first item that matches the supplied
|
||||
* function.
|
||||
* @method Array.find
|
||||
* @param a {Array} the array to search
|
||||
* @param f {Function} the function to execute on each item.
|
||||
* Iteration is stopped as soon as this function returns true
|
||||
* on an item.
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {object} the first item that the supplied function
|
||||
* returns true for, or null if it never returns true
|
||||
*/
|
||||
A.find = function(a, f, o) {
|
||||
for(var i=0, l = a.length; i < l; i++) {
|
||||
if (f.call(o, a[i], i, a)) {
|
||||
return a[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Iterates over an array, returning a new array of all the elements
|
||||
* that match the supplied regular expression
|
||||
* @method Array.grep
|
||||
* @param a {Array} a collection to iterate over
|
||||
* @param pattern {RegExp} The regular expression to test against
|
||||
* each item
|
||||
* @static
|
||||
* @return {Array} All the items in the collection that
|
||||
* produce a match against the supplied regular expression.
|
||||
* If no items match, an empty array is returned.
|
||||
*/
|
||||
A.grep = function (a, pattern) {
|
||||
return A.filter(a, function (item, index) {
|
||||
return pattern.test(item);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Partitions an array into two new arrays, one with the items
|
||||
* that match the supplied function, and one with the items that
|
||||
* do not.
|
||||
* @method Array.partition
|
||||
* @param a {Array} a collection to iterate over
|
||||
* @paran f {Function} a function that will receive each item
|
||||
* in the collection and its index.
|
||||
* @param o Optional execution context of f.
|
||||
* @static
|
||||
* @return An object with two members, 'matches' and 'rejects',
|
||||
* that are arrays containing the items that were selected or
|
||||
* rejected by the test function (or an empty array).
|
||||
*/
|
||||
A.partition = function (a, f, o) {
|
||||
var results = {
|
||||
matches: [],
|
||||
rejects: []
|
||||
};
|
||||
|
||||
A.each(a, function (item, index) {
|
||||
var set = f.call(o, item, index, a) ? results.matches : results.rejects;
|
||||
set.push(item);
|
||||
});
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an array of arrays by pairing the corresponding
|
||||
* elements of two arrays together into a new array.
|
||||
* @method Array.zip
|
||||
* @param a {Array} a collection to iterate over
|
||||
* @param a2 {Array} another collection whose members will be
|
||||
* paired with members of the first parameter
|
||||
* @static
|
||||
* @return An array of arrays formed by pairing each element
|
||||
* of the first collection with an item in the second collection
|
||||
* having the corresponding index.
|
||||
*/
|
||||
A.zip = function (a, a2) {
|
||||
var results = [];
|
||||
A.each(a, function (item, index) {
|
||||
results.push([item, a2[index]]);
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
A.forEach = A.each;
|
||||
|
||||
|
||||
}, '3.2.0' );
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("array-extras",function(d){var b=d.Lang,c=Array.prototype,a=d.Array;a.lastIndexOf=(c.lastIndexOf)?function(e,f){return e.lastIndexOf(f);}:function(e,g){for(var f=e.length-1;f>=0;f=f-1){if(e[f]===g){break;}}return f;};a.unique=function(f,h){var e=f.slice(),g=0,k=-1,j=null;while(g<e.length){j=e[g];while((k=a.lastIndexOf(e,j))!==g){e.splice(k,1);}g+=1;}if(h){if(b.isNumber(e[0])){e.sort(a.numericSort);}else{e.sort();}}return e;};a.filter=(c.filter)?function(e,g,h){return c.filter.call(e,g,h);}:function(e,h,i){var g=[];a.each(e,function(k,j,f){if(h.call(i,k,j,f)){g.push(k);}});return g;};a.reject=function(e,g,h){return a.filter(e,function(k,j,f){return !g.call(h,k,j,f);});};a.every=(c.every)?function(e,g,h){return c.every.call(e,g,h);}:function(g,j,k){for(var h=0,e=g.length;h<e;h=h+1){if(!j.call(k,g[h],h,g)){return false;}}return true;};a.map=(c.map)?function(e,g,h){return c.map.call(e,g,h);}:function(e,h,i){var g=[];a.each(e,function(k,j,f){g.push(h.call(i,k,j,f));});return g;};a.reduce=(c.reduce)?function(e,i,g,h){return c.reduce.call(e,function(l,k,j,f){return g.call(h,l,k,j,f);},i);}:function(e,j,h,i){var g=j;a.each(e,function(l,k,f){g=h.call(i,g,l,k,f);});return g;};a.find=function(g,j,k){for(var h=0,e=g.length;h<e;h++){if(j.call(k,g[h],h,g)){return g[h];}}return null;};a.grep=function(e,f){return a.filter(e,function(h,g){return f.test(h);});};a.partition=function(e,h,i){var g={matches:[],rejects:[]};a.each(e,function(j,f){var k=h.call(i,j,f,e)?g.matches:g.rejects;k.push(j);});return g;};a.zip=function(f,e){var g=[];a.each(f,function(i,h){g.push([i,e[h]]);});return g;};a.forEach=a.each;},"3.2.0");
|
||||
@@ -1,306 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('array-extras', function(Y) {
|
||||
|
||||
/**
|
||||
* Collection utilities beyond what is provided in the YUI core
|
||||
* @module collection
|
||||
* @submodule array-extras
|
||||
*/
|
||||
|
||||
var L = Y.Lang, Native = Array.prototype, A = Y.Array;
|
||||
|
||||
/**
|
||||
* Adds the following array utilities to the YUI instance
|
||||
* (Y.Array). This is in addition to the methods provided
|
||||
* in the core.
|
||||
* @class YUI~array~extras
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the index of the last item in the array
|
||||
* that contains the specified value, -1 if the
|
||||
* value isn't found.
|
||||
* @method Array.lastIndexOf
|
||||
* @static
|
||||
* @param a {Array} the array to search
|
||||
* @param val the value to search for
|
||||
* @return {int} the index of hte item that contains the value or -1
|
||||
*/
|
||||
A.lastIndexOf = (Native.lastIndexOf) ?
|
||||
function(a ,val) {
|
||||
return a.lastIndexOf(val);
|
||||
} :
|
||||
function(a, val) {
|
||||
for (var i=a.length-1; i>=0; i=i-1) {
|
||||
if (a[i] === val) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a copy of the array with the duplicate entries removed
|
||||
* @method Array.unique
|
||||
* @static
|
||||
* @param a {Array} the array to find the subset of uniques for
|
||||
* @param sort {bool} flag to denote if the array is sorted or not. Defaults to false, the more general operation
|
||||
* @return {Array} a copy of the array with duplicate entries removed
|
||||
*/
|
||||
A.unique = function(a, sort) {
|
||||
var b = a.slice(), i = 0, n = -1, item = null;
|
||||
|
||||
while (i < b.length) {
|
||||
item = b[i];
|
||||
while ((n = A.lastIndexOf(b, item)) !== i) {
|
||||
b.splice(n, 1);
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
// Note: the sort option doesn't really belong here... I think it was added
|
||||
// because there was a way to fast path the two operations together. That
|
||||
// implementation was not working, so I replaced it with the following.
|
||||
// Leaving it in so that the API doesn't get broken.
|
||||
if (sort) {
|
||||
if (L.isNumber(b[0])) {
|
||||
b.sort(A.numericSort);
|
||||
} else {
|
||||
b.sort();
|
||||
}
|
||||
}
|
||||
|
||||
return b;
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* Returns a new array containing the items that the supplied
|
||||
* function returned true for.
|
||||
* @method Array.filter
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {Array} The items on which the supplied function
|
||||
* returned true. If no items matched an empty array is
|
||||
* returned.
|
||||
*/
|
||||
A.filter = (Native.filter) ?
|
||||
function(a, f, o) {
|
||||
return Native.filter.call(a, f, o);
|
||||
} :
|
||||
function(a, f, o) {
|
||||
var results = [];
|
||||
A.each(a, function(item, i, a) {
|
||||
if (f.call(o, item, i, a)) {
|
||||
results.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
/**
|
||||
* The inverse of filter. Executes the supplied function on each item.
|
||||
* Returns a new array containing the items that the supplied
|
||||
* function returned *false* for.
|
||||
* @method Array.reject
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {Array} The items on which the supplied function
|
||||
* returned false.
|
||||
*/
|
||||
A.reject = function(a, f, o) {
|
||||
return A.filter(a, function(item, i, a) {
|
||||
return !f.call(o, item, i, a);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* Iteration stops if the supplied function does not return
|
||||
* a truthy value.
|
||||
* @method Array.every
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {boolean} true if every item in the array returns true
|
||||
* from the supplied function.
|
||||
*/
|
||||
A.every = (Native.every) ?
|
||||
function(a, f, o) {
|
||||
return Native.every.call(a,f,o);
|
||||
} :
|
||||
function(a, f, o) {
|
||||
for (var i = 0, l = a.length; i < l; i=i+1) {
|
||||
if (!f.call(o, a[i], i, a)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* @method Array.map
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {Array} A new array containing the return value
|
||||
* of the supplied function for each item in the original
|
||||
* array.
|
||||
*/
|
||||
A.map = (Native.map) ?
|
||||
function(a, f, o) {
|
||||
return Native.map.call(a, f, o);
|
||||
} :
|
||||
function(a, f, o) {
|
||||
var results = [];
|
||||
A.each(a, function(item, i, a) {
|
||||
results.push(f.call(o, item, i, a));
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* Reduce "folds" the array into a single value. The callback
|
||||
* function receives four arguments:
|
||||
* the value from the previous callback call (or the initial value),
|
||||
* the value of the current element, the current index, and
|
||||
* the array over which iteration is occurring.
|
||||
* @method Array.reduce
|
||||
* @param a {Array} the array to iterate
|
||||
* @param init The initial value to start from
|
||||
* @param f {Function} the function to execute on each item. It
|
||||
* is responsible for returning the updated value of the
|
||||
* computation.
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return A value that results from iteratively applying the
|
||||
* supplied function to each element in the array.
|
||||
*/
|
||||
A.reduce = (Native.reduce) ?
|
||||
function(a, init, f, o) {
|
||||
//Firefox's Array.reduce does not allow inclusion of a
|
||||
// thisObject, so we need to implement it manually
|
||||
return Native.reduce.call(a, function(init, item, i, a) {
|
||||
return f.call(o, init, item, i, a);
|
||||
}, init);
|
||||
} :
|
||||
function(a, init, f, o) {
|
||||
var r = init;
|
||||
A.each(a, function (item, i, a) {
|
||||
r = f.call(o, r, item, i, a);
|
||||
});
|
||||
return r;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array,
|
||||
* searching for the first item that matches the supplied
|
||||
* function.
|
||||
* @method Array.find
|
||||
* @param a {Array} the array to search
|
||||
* @param f {Function} the function to execute on each item.
|
||||
* Iteration is stopped as soon as this function returns true
|
||||
* on an item.
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {object} the first item that the supplied function
|
||||
* returns true for, or null if it never returns true
|
||||
*/
|
||||
A.find = function(a, f, o) {
|
||||
for(var i=0, l = a.length; i < l; i++) {
|
||||
if (f.call(o, a[i], i, a)) {
|
||||
return a[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Iterates over an array, returning a new array of all the elements
|
||||
* that match the supplied regular expression
|
||||
* @method Array.grep
|
||||
* @param a {Array} a collection to iterate over
|
||||
* @param pattern {RegExp} The regular expression to test against
|
||||
* each item
|
||||
* @static
|
||||
* @return {Array} All the items in the collection that
|
||||
* produce a match against the supplied regular expression.
|
||||
* If no items match, an empty array is returned.
|
||||
*/
|
||||
A.grep = function (a, pattern) {
|
||||
return A.filter(a, function (item, index) {
|
||||
return pattern.test(item);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Partitions an array into two new arrays, one with the items
|
||||
* that match the supplied function, and one with the items that
|
||||
* do not.
|
||||
* @method Array.partition
|
||||
* @param a {Array} a collection to iterate over
|
||||
* @paran f {Function} a function that will receive each item
|
||||
* in the collection and its index.
|
||||
* @param o Optional execution context of f.
|
||||
* @static
|
||||
* @return An object with two members, 'matches' and 'rejects',
|
||||
* that are arrays containing the items that were selected or
|
||||
* rejected by the test function (or an empty array).
|
||||
*/
|
||||
A.partition = function (a, f, o) {
|
||||
var results = {
|
||||
matches: [],
|
||||
rejects: []
|
||||
};
|
||||
|
||||
A.each(a, function (item, index) {
|
||||
var set = f.call(o, item, index, a) ? results.matches : results.rejects;
|
||||
set.push(item);
|
||||
});
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an array of arrays by pairing the corresponding
|
||||
* elements of two arrays together into a new array.
|
||||
* @method Array.zip
|
||||
* @param a {Array} a collection to iterate over
|
||||
* @param a2 {Array} another collection whose members will be
|
||||
* paired with members of the first parameter
|
||||
* @static
|
||||
* @return An array of arrays formed by pairing each element
|
||||
* of the first collection with an item in the second collection
|
||||
* having the corresponding index.
|
||||
*/
|
||||
A.zip = function (a, a2) {
|
||||
var results = [];
|
||||
A.each(a, function (item, index) {
|
||||
results.push([item, a2[index]]);
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
A.forEach = A.each;
|
||||
|
||||
|
||||
}, '3.2.0' );
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('array-invoke', function(Y) {
|
||||
|
||||
/**
|
||||
* Collection utilities beyond what is provided in the YUI core
|
||||
* @module collection
|
||||
* @submodule array-invoke
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds the <code>Y.Array.invoke( items, methodName )</code> utility method.
|
||||
* @class YUI~array~invoke
|
||||
*/
|
||||
|
||||
/**
|
||||
* <p>Execute a named method on an array of objects. Items in the list that do
|
||||
* not have a function by that name will be skipped. For example,
|
||||
* <code>Y.Array.invoke( arrayOfDrags, 'plug', Y.Plugin.DDProxy );</code></p>
|
||||
*
|
||||
* <p>The return values from each call are returned in an array.</p>
|
||||
*
|
||||
* @method invoke
|
||||
* @static
|
||||
* @param items { Array } Array of objects supporting the named method
|
||||
* @param name { String } the name of the method to execute on each item
|
||||
* @param args* { mixed } Any number of additional args are passed as
|
||||
* parameters to the execution of the named method.
|
||||
* @return { Array } All return values, indexed according to item index.
|
||||
*/
|
||||
Y.Array.invoke = function ( items, name ) {
|
||||
var args = Y.Array( arguments, 2, true ),
|
||||
isFunction = Y.Lang.isFunction,
|
||||
ret = [];
|
||||
|
||||
Y.Array.each( Y.Array( items ), function ( item, i ) {
|
||||
if ( isFunction( item[ name ] ) ) {
|
||||
ret[i] = item[ name ].apply( item, args );
|
||||
}
|
||||
});
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
}, '3.2.0' );
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('array-invoke', function(Y) {
|
||||
|
||||
/**
|
||||
* Collection utilities beyond what is provided in the YUI core
|
||||
* @module collection
|
||||
* @submodule array-invoke
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds the <code>Y.Array.invoke( items, methodName )</code> utility method.
|
||||
* @class YUI~array~invoke
|
||||
*/
|
||||
|
||||
/**
|
||||
* <p>Execute a named method on an array of objects. Items in the list that do
|
||||
* not have a function by that name will be skipped. For example,
|
||||
* <code>Y.Array.invoke( arrayOfDrags, 'plug', Y.Plugin.DDProxy );</code></p>
|
||||
*
|
||||
* <p>The return values from each call are returned in an array.</p>
|
||||
*
|
||||
* @method invoke
|
||||
* @static
|
||||
* @param items { Array } Array of objects supporting the named method
|
||||
* @param name { String } the name of the method to execute on each item
|
||||
* @param args* { mixed } Any number of additional args are passed as
|
||||
* parameters to the execution of the named method.
|
||||
* @return { Array } All return values, indexed according to item index.
|
||||
*/
|
||||
Y.Array.invoke = function ( items, name ) {
|
||||
var args = Y.Array( arguments, 2, true ),
|
||||
isFunction = Y.Lang.isFunction,
|
||||
ret = [];
|
||||
|
||||
Y.Array.each( Y.Array( items ), function ( item, i ) {
|
||||
if ( isFunction( item[ name ] ) ) {
|
||||
ret[i] = item[ name ].apply( item, args );
|
||||
}
|
||||
});
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
}, '3.2.0' );
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("arraylist-filter",function(a){a.mix(a.ArrayList.prototype,{filter:function(c){var b=[];a.Array.each(this._items,function(e,d){e=this.item(d);if(c(e)){b.push(e);}},this);return new this.constructor(b);}});},"3.2.0",{requires:["arraylist"]});
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("arraylist",function(e){var d=e.Array,c=d.each,a;function b(f){if(f!==undefined){this._items=e.Lang.isArray(f)?f:d(f);}else{this._items=this._items||[];}}a={item:function(f){return this._items[f];},each:function(g,f){c(this._items,function(j,h){j=this.item(h);g.call(f||j,j,h,this);},this);return this;},some:function(g,f){return d.some(this._items,function(j,h){j=this.item(h);return g.call(f||j,j,h,this);},this);},indexOf:function(f){return d.indexOf(this._items,f);},size:function(){return this._items.length;},isEmpty:function(){return !this.size();}};a._item=a.item;b.prototype=a;e.mix(b,{addMethod:function(f,g){g=d(g);c(g,function(h){f[h]=function(){var j=d(arguments,0,true),i=[];c(this._items,function(m,l){m=this._item(l);var k=m[h].apply(m,j);if(k!==undefined&&k!==m){i.push(k);}},this);return i.length?i:this;};});}});e.ArrayList=b;},"3.2.0");
|
||||
@@ -1,675 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('array-extras', function(Y) {
|
||||
|
||||
/**
|
||||
* Collection utilities beyond what is provided in the YUI core
|
||||
* @module collection
|
||||
* @submodule array-extras
|
||||
*/
|
||||
|
||||
var L = Y.Lang, Native = Array.prototype, A = Y.Array;
|
||||
|
||||
/**
|
||||
* Adds the following array utilities to the YUI instance
|
||||
* (Y.Array). This is in addition to the methods provided
|
||||
* in the core.
|
||||
* @class YUI~array~extras
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the index of the last item in the array
|
||||
* that contains the specified value, -1 if the
|
||||
* value isn't found.
|
||||
* @method Array.lastIndexOf
|
||||
* @static
|
||||
* @param a {Array} the array to search
|
||||
* @param val the value to search for
|
||||
* @return {int} the index of hte item that contains the value or -1
|
||||
*/
|
||||
A.lastIndexOf = (Native.lastIndexOf) ?
|
||||
function(a ,val) {
|
||||
return a.lastIndexOf(val);
|
||||
} :
|
||||
function(a, val) {
|
||||
for (var i=a.length-1; i>=0; i=i-1) {
|
||||
if (a[i] === val) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a copy of the array with the duplicate entries removed
|
||||
* @method Array.unique
|
||||
* @static
|
||||
* @param a {Array} the array to find the subset of uniques for
|
||||
* @param sort {bool} flag to denote if the array is sorted or not. Defaults to false, the more general operation
|
||||
* @return {Array} a copy of the array with duplicate entries removed
|
||||
*/
|
||||
A.unique = function(a, sort) {
|
||||
var b = a.slice(), i = 0, n = -1, item = null;
|
||||
|
||||
while (i < b.length) {
|
||||
item = b[i];
|
||||
while ((n = A.lastIndexOf(b, item)) !== i) {
|
||||
b.splice(n, 1);
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
// Note: the sort option doesn't really belong here... I think it was added
|
||||
// because there was a way to fast path the two operations together. That
|
||||
// implementation was not working, so I replaced it with the following.
|
||||
// Leaving it in so that the API doesn't get broken.
|
||||
if (sort) {
|
||||
if (L.isNumber(b[0])) {
|
||||
b.sort(A.numericSort);
|
||||
} else {
|
||||
b.sort();
|
||||
}
|
||||
}
|
||||
|
||||
return b;
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* Returns a new array containing the items that the supplied
|
||||
* function returned true for.
|
||||
* @method Array.filter
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {Array} The items on which the supplied function
|
||||
* returned true. If no items matched an empty array is
|
||||
* returned.
|
||||
*/
|
||||
A.filter = (Native.filter) ?
|
||||
function(a, f, o) {
|
||||
return Native.filter.call(a, f, o);
|
||||
} :
|
||||
function(a, f, o) {
|
||||
var results = [];
|
||||
A.each(a, function(item, i, a) {
|
||||
if (f.call(o, item, i, a)) {
|
||||
results.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
/**
|
||||
* The inverse of filter. Executes the supplied function on each item.
|
||||
* Returns a new array containing the items that the supplied
|
||||
* function returned *false* for.
|
||||
* @method Array.reject
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {Array} The items on which the supplied function
|
||||
* returned false.
|
||||
*/
|
||||
A.reject = function(a, f, o) {
|
||||
return A.filter(a, function(item, i, a) {
|
||||
return !f.call(o, item, i, a);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* Iteration stops if the supplied function does not return
|
||||
* a truthy value.
|
||||
* @method Array.every
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {boolean} true if every item in the array returns true
|
||||
* from the supplied function.
|
||||
*/
|
||||
A.every = (Native.every) ?
|
||||
function(a, f, o) {
|
||||
return Native.every.call(a,f,o);
|
||||
} :
|
||||
function(a, f, o) {
|
||||
for (var i = 0, l = a.length; i < l; i=i+1) {
|
||||
if (!f.call(o, a[i], i, a)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* @method Array.map
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {Array} A new array containing the return value
|
||||
* of the supplied function for each item in the original
|
||||
* array.
|
||||
*/
|
||||
A.map = (Native.map) ?
|
||||
function(a, f, o) {
|
||||
return Native.map.call(a, f, o);
|
||||
} :
|
||||
function(a, f, o) {
|
||||
var results = [];
|
||||
A.each(a, function(item, i, a) {
|
||||
results.push(f.call(o, item, i, a));
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* Reduce "folds" the array into a single value. The callback
|
||||
* function receives four arguments:
|
||||
* the value from the previous callback call (or the initial value),
|
||||
* the value of the current element, the current index, and
|
||||
* the array over which iteration is occurring.
|
||||
* @method Array.reduce
|
||||
* @param a {Array} the array to iterate
|
||||
* @param init The initial value to start from
|
||||
* @param f {Function} the function to execute on each item. It
|
||||
* is responsible for returning the updated value of the
|
||||
* computation.
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return A value that results from iteratively applying the
|
||||
* supplied function to each element in the array.
|
||||
*/
|
||||
A.reduce = (Native.reduce) ?
|
||||
function(a, init, f, o) {
|
||||
//Firefox's Array.reduce does not allow inclusion of a
|
||||
// thisObject, so we need to implement it manually
|
||||
return Native.reduce.call(a, function(init, item, i, a) {
|
||||
return f.call(o, init, item, i, a);
|
||||
}, init);
|
||||
} :
|
||||
function(a, init, f, o) {
|
||||
var r = init;
|
||||
A.each(a, function (item, i, a) {
|
||||
r = f.call(o, r, item, i, a);
|
||||
});
|
||||
return r;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array,
|
||||
* searching for the first item that matches the supplied
|
||||
* function.
|
||||
* @method Array.find
|
||||
* @param a {Array} the array to search
|
||||
* @param f {Function} the function to execute on each item.
|
||||
* Iteration is stopped as soon as this function returns true
|
||||
* on an item.
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {object} the first item that the supplied function
|
||||
* returns true for, or null if it never returns true
|
||||
*/
|
||||
A.find = function(a, f, o) {
|
||||
for(var i=0, l = a.length; i < l; i++) {
|
||||
if (f.call(o, a[i], i, a)) {
|
||||
return a[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Iterates over an array, returning a new array of all the elements
|
||||
* that match the supplied regular expression
|
||||
* @method Array.grep
|
||||
* @param a {Array} a collection to iterate over
|
||||
* @param pattern {RegExp} The regular expression to test against
|
||||
* each item
|
||||
* @static
|
||||
* @return {Array} All the items in the collection that
|
||||
* produce a match against the supplied regular expression.
|
||||
* If no items match, an empty array is returned.
|
||||
*/
|
||||
A.grep = function (a, pattern) {
|
||||
return A.filter(a, function (item, index) {
|
||||
return pattern.test(item);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Partitions an array into two new arrays, one with the items
|
||||
* that match the supplied function, and one with the items that
|
||||
* do not.
|
||||
* @method Array.partition
|
||||
* @param a {Array} a collection to iterate over
|
||||
* @paran f {Function} a function that will receive each item
|
||||
* in the collection and its index.
|
||||
* @param o Optional execution context of f.
|
||||
* @static
|
||||
* @return An object with two members, 'matches' and 'rejects',
|
||||
* that are arrays containing the items that were selected or
|
||||
* rejected by the test function (or an empty array).
|
||||
*/
|
||||
A.partition = function (a, f, o) {
|
||||
var results = {
|
||||
matches: [],
|
||||
rejects: []
|
||||
};
|
||||
|
||||
A.each(a, function (item, index) {
|
||||
var set = f.call(o, item, index, a) ? results.matches : results.rejects;
|
||||
set.push(item);
|
||||
});
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an array of arrays by pairing the corresponding
|
||||
* elements of two arrays together into a new array.
|
||||
* @method Array.zip
|
||||
* @param a {Array} a collection to iterate over
|
||||
* @param a2 {Array} another collection whose members will be
|
||||
* paired with members of the first parameter
|
||||
* @static
|
||||
* @return An array of arrays formed by pairing each element
|
||||
* of the first collection with an item in the second collection
|
||||
* having the corresponding index.
|
||||
*/
|
||||
A.zip = function (a, a2) {
|
||||
var results = [];
|
||||
A.each(a, function (item, index) {
|
||||
results.push([item, a2[index]]);
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
A.forEach = A.each;
|
||||
|
||||
|
||||
}, '3.2.0' );
|
||||
YUI.add('arraylist', function(Y) {
|
||||
|
||||
/**
|
||||
* Collection utilities beyond what is provided in the YUI core
|
||||
* @module collection
|
||||
* @submodule arraylist
|
||||
*/
|
||||
|
||||
var YArray = Y.Array,
|
||||
YArray_each = YArray.each,
|
||||
ArrayListProto;
|
||||
|
||||
/**
|
||||
* Generic ArrayList class for managing lists of items and iterating operations
|
||||
* over them. The targeted use for this class is for augmentation onto a
|
||||
* class that is responsible for managing multiple instances of another class
|
||||
* (e.g. NodeList for Nodes). The recommended use is to augment your class with
|
||||
* ArrayList, then use ArrayList.addMethod to mirror the API of the constituent
|
||||
* items on the list's API.
|
||||
*
|
||||
* The default implementation creates immutable lists, but mutability can be
|
||||
* provided via the arraylist-add submodule or by implementing mutation methods
|
||||
* directly on the augmented class's prototype.
|
||||
*
|
||||
* @class ArrayList
|
||||
* @constructor
|
||||
* @param items { Array } array of items this list will be responsible for
|
||||
*/
|
||||
function ArrayList( items ) {
|
||||
if ( items !== undefined ) {
|
||||
this._items = Y.Lang.isArray( items ) ? items : YArray( items );
|
||||
} else {
|
||||
// ||= to support lazy initialization from augment
|
||||
this._items = this._items || [];
|
||||
}
|
||||
}
|
||||
|
||||
ArrayListProto = {
|
||||
/**
|
||||
* Get an item by index from the list. Override this method if managing a
|
||||
* list of objects that have a different public representation (e.g. Node
|
||||
* instances vs DOM nodes). The iteration methods that accept a user
|
||||
* function will use this method for access list items for operation.
|
||||
*
|
||||
* @method item
|
||||
* @param i { Integer } index to fetch
|
||||
* @return { mixed } the item at the requested index
|
||||
*/
|
||||
item: function ( i ) {
|
||||
return this._items[i];
|
||||
},
|
||||
|
||||
/**
|
||||
* <p>Execute a function on each item of the list, optionally providing a
|
||||
* custom execution context. Default context is the item.</p>
|
||||
*
|
||||
* <p>The callback signature is <code>callback( item, index )</code>.</p>
|
||||
*
|
||||
* @method each
|
||||
* @param fn { Function } the function to execute
|
||||
* @param context { mixed } optional override 'this' in the function
|
||||
* @return { ArrayList } this instance
|
||||
* @chainable
|
||||
*/
|
||||
each: function ( fn, context ) {
|
||||
YArray_each( this._items, function ( item, i ) {
|
||||
item = this.item( i );
|
||||
|
||||
fn.call( context || item, item, i, this );
|
||||
}, this);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* <p>Execute a function on each item of the list, optionally providing a
|
||||
* custom execution context. Default context is the item.</p>
|
||||
*
|
||||
* <p>The callback signature is <code>callback( item, index )</code>.</p>
|
||||
*
|
||||
* <p>Unlike <code>each</code>, if the callback returns true, the
|
||||
* iteratation will stop.</p>
|
||||
*
|
||||
* @method some
|
||||
* @param fn { Function } the function to execute
|
||||
* @param context { mixed } optional override 'this' in the function
|
||||
* @return { Boolean } True if the function returned true on an item
|
||||
*/
|
||||
some: function ( fn, context ) {
|
||||
return YArray.some( this._items, function ( item, i ) {
|
||||
item = this.item( i );
|
||||
|
||||
return fn.call( context || item, item, i, this );
|
||||
}, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Finds the first index of the needle in the managed array of items.
|
||||
*
|
||||
* @method indexOf
|
||||
* @param needle { mixed } The item to search for
|
||||
* @return { Integer } Array index if found. Otherwise -1
|
||||
*/
|
||||
indexOf: function ( needle ) {
|
||||
return YArray.indexOf( this._items, needle );
|
||||
},
|
||||
|
||||
/**
|
||||
* How many items are in this list?
|
||||
*
|
||||
* @method size
|
||||
* @return { Integer } Number of items in the list
|
||||
*/
|
||||
size: function () {
|
||||
return this._items.length;
|
||||
},
|
||||
|
||||
/**
|
||||
* Is this instance managing any items?
|
||||
*
|
||||
* @method isEmpty
|
||||
* @return { Boolean } true if 1 or more items are being managed
|
||||
*/
|
||||
isEmpty: function () {
|
||||
return !this.size();
|
||||
}
|
||||
};
|
||||
// Default implementation does not distinguish between public and private
|
||||
// item getter
|
||||
/**
|
||||
* Protected method for optimizations that may be appropriate for API
|
||||
* mirroring. Similar in functionality to <code>item</code>, but is used by
|
||||
* methods added with <code>ArrayList.addMethod()</code>.
|
||||
*
|
||||
* @method _item
|
||||
* @protected
|
||||
* @param i { Integer } Index of item to fetch
|
||||
* @return { mixed } The item appropriate for pass through API methods
|
||||
*/
|
||||
ArrayListProto._item = ArrayListProto.item;
|
||||
|
||||
ArrayList.prototype = ArrayListProto;
|
||||
|
||||
Y.mix( ArrayList, {
|
||||
|
||||
/**
|
||||
* <p>Adds a pass through method to dest (typically the prototype of a list
|
||||
* class) that calls the named method on each item in the list with
|
||||
* whatever parameters are passed in. Allows for API indirection via list
|
||||
* instances.</p>
|
||||
*
|
||||
* <p>Accepts a single string name or an array of string names.</p>
|
||||
*
|
||||
* <pre><code>list.each( function ( item ) {
|
||||
* item.methodName( 1, 2, 3 );
|
||||
* } );
|
||||
* // becomes
|
||||
* list.methodName( 1, 2, 3 );</code></pre>
|
||||
*
|
||||
* <p>Additionally, the pass through methods use the item retrieved by the
|
||||
* <code>_item</code> method in case there is any special behavior that is
|
||||
* appropriate for API mirroring.</p>
|
||||
*
|
||||
* @method addMethod
|
||||
* @static
|
||||
* @param dest { Object } Object or prototype to receive the iterator method
|
||||
* @param name { String | Array } Name of method of methods to create
|
||||
*/
|
||||
addMethod: function ( dest, names ) {
|
||||
|
||||
names = YArray( names );
|
||||
|
||||
YArray_each( names, function ( name ) {
|
||||
dest[ name ] = function () {
|
||||
var args = YArray( arguments, 0, true ),
|
||||
ret = [];
|
||||
|
||||
YArray_each( this._items, function ( item, i ) {
|
||||
item = this._item( i );
|
||||
|
||||
var result = item[ name ].apply( item, args );
|
||||
|
||||
if ( result !== undefined && result !== item ) {
|
||||
ret.push( result );
|
||||
}
|
||||
}, this);
|
||||
|
||||
return ret.length ? ret : this;
|
||||
};
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
Y.ArrayList = ArrayList;
|
||||
|
||||
|
||||
}, '3.2.0' );
|
||||
YUI.add('arraylist-add', function(Y) {
|
||||
|
||||
/**
|
||||
* Collection utilities beyond what is provided in the YUI core
|
||||
* @module collection
|
||||
* @submodule arraylist-add
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds methods add and remove to Y.ArrayList
|
||||
* @class ArrayList~add
|
||||
*/
|
||||
Y.mix( Y.ArrayList.prototype, {
|
||||
|
||||
/**
|
||||
* Add a single item to the ArrayList. Does not prevent duplicates.
|
||||
*
|
||||
* @method add
|
||||
* @param item { mixed } Item presumably of the same type as others in the
|
||||
* ArrayList
|
||||
* @param index {Number} (Optional.) Number representing the position at
|
||||
* which the item should be inserted.
|
||||
* @return {ArrayList} the instance
|
||||
* @chainable
|
||||
*/
|
||||
add: function ( item, index ) {
|
||||
var items = this._items;
|
||||
|
||||
if (Y.Lang.isNumber(index)) {
|
||||
items.splice(index, 0, item);
|
||||
}
|
||||
else {
|
||||
items.push(item);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes first or all occurrences of an item to the ArrayList. If a
|
||||
* comparator is not provided, uses itemsAreEqual method to determine
|
||||
* matches.
|
||||
*
|
||||
* @method remove
|
||||
* @param needle { mixed } Item to find and remove from the list
|
||||
* @param all { Boolean } If true, remove all occurrences
|
||||
* @param comparator { Function } optional a/b function to test equivalence
|
||||
* @return {ArrayList} the instance
|
||||
* @chainable
|
||||
*/
|
||||
remove: function ( needle, all, comparator ) {
|
||||
comparator = comparator || this.itemsAreEqual;
|
||||
|
||||
for (var i = this._items.length - 1; i >= 0; --i) {
|
||||
if ( comparator.call( this, needle, this.item( i ) ) ) {
|
||||
this._items.splice( i, 1 );
|
||||
if ( !all ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Default comparator for items stored in this list. Used by remove().
|
||||
*
|
||||
* @method itemsAreEqual
|
||||
* @param a { mixed } item to test equivalence with
|
||||
* @param b { mixed } other item to test equivalance
|
||||
* @return { Boolean } true if items are deemed equivalent
|
||||
*/
|
||||
itemsAreEqual: function ( a, b ) {
|
||||
return a === b;
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['arraylist']});
|
||||
YUI.add('arraylist-filter', function(Y) {
|
||||
|
||||
/**
|
||||
* Collection utilities beyond what is provided in the YUI core
|
||||
* @module collection
|
||||
* @submodule arraylist-filter
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds filter method to ArrayList prototype
|
||||
* @class ArrayList~filter
|
||||
*/
|
||||
Y.mix( Y.ArrayList.prototype, {
|
||||
|
||||
/**
|
||||
* <p>Create a new ArrayList (or augmenting class instance) from a subset
|
||||
* of items as determined by the boolean function passed as the
|
||||
* argument. The original ArrayList is unchanged.</p>
|
||||
*
|
||||
* <p>The validator signature is <code>validator( item )</code>.</p>
|
||||
*
|
||||
* @method filter
|
||||
* @param validator { Function } Boolean function to determine in or out
|
||||
* @return { ArrayList } New instance based on who passed the validator
|
||||
*/
|
||||
filter: function ( validator ) {
|
||||
var items = [];
|
||||
|
||||
Y.Array.each( this._items, function ( item, i ) {
|
||||
item = this.item( i );
|
||||
|
||||
if ( validator( item ) ) {
|
||||
items.push( item );
|
||||
}
|
||||
}, this);
|
||||
|
||||
return new this.constructor( items );
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['arraylist']});
|
||||
YUI.add('array-invoke', function(Y) {
|
||||
|
||||
/**
|
||||
* Collection utilities beyond what is provided in the YUI core
|
||||
* @module collection
|
||||
* @submodule array-invoke
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds the <code>Y.Array.invoke( items, methodName )</code> utility method.
|
||||
* @class YUI~array~invoke
|
||||
*/
|
||||
|
||||
/**
|
||||
* <p>Execute a named method on an array of objects. Items in the list that do
|
||||
* not have a function by that name will be skipped. For example,
|
||||
* <code>Y.Array.invoke( arrayOfDrags, 'plug', Y.Plugin.DDProxy );</code></p>
|
||||
*
|
||||
* <p>The return values from each call are returned in an array.</p>
|
||||
*
|
||||
* @method invoke
|
||||
* @static
|
||||
* @param items { Array } Array of objects supporting the named method
|
||||
* @param name { String } the name of the method to execute on each item
|
||||
* @param args* { mixed } Any number of additional args are passed as
|
||||
* parameters to the execution of the named method.
|
||||
* @return { Array } All return values, indexed according to item index.
|
||||
*/
|
||||
Y.Array.invoke = function ( items, name ) {
|
||||
var args = Y.Array( arguments, 2, true ),
|
||||
isFunction = Y.Lang.isFunction,
|
||||
ret = [];
|
||||
|
||||
Y.Array.each( Y.Array( items ), function ( item, i ) {
|
||||
if ( isFunction( item[ name ] ) ) {
|
||||
ret[i] = item[ name ].apply( item, args );
|
||||
}
|
||||
});
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
}, '3.2.0' );
|
||||
|
||||
|
||||
YUI.add('collection', function(Y){}, '3.2.0' ,{use:['array-extras', 'arraylist', 'arraylist-add', 'arraylist-filter', 'array-invoke']});
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("array-extras",function(d){var b=d.Lang,c=Array.prototype,a=d.Array;a.lastIndexOf=(c.lastIndexOf)?function(e,f){return e.lastIndexOf(f);}:function(e,g){for(var f=e.length-1;f>=0;f=f-1){if(e[f]===g){break;}}return f;};a.unique=function(f,h){var e=f.slice(),g=0,k=-1,j=null;while(g<e.length){j=e[g];while((k=a.lastIndexOf(e,j))!==g){e.splice(k,1);}g+=1;}if(h){if(b.isNumber(e[0])){e.sort(a.numericSort);}else{e.sort();}}return e;};a.filter=(c.filter)?function(e,g,h){return c.filter.call(e,g,h);}:function(e,h,i){var g=[];a.each(e,function(k,j,f){if(h.call(i,k,j,f)){g.push(k);}});return g;};a.reject=function(e,g,h){return a.filter(e,function(k,j,f){return !g.call(h,k,j,f);});};a.every=(c.every)?function(e,g,h){return c.every.call(e,g,h);}:function(g,j,k){for(var h=0,e=g.length;h<e;h=h+1){if(!j.call(k,g[h],h,g)){return false;}}return true;};a.map=(c.map)?function(e,g,h){return c.map.call(e,g,h);}:function(e,h,i){var g=[];a.each(e,function(k,j,f){g.push(h.call(i,k,j,f));});return g;};a.reduce=(c.reduce)?function(e,i,g,h){return c.reduce.call(e,function(l,k,j,f){return g.call(h,l,k,j,f);},i);}:function(e,j,h,i){var g=j;a.each(e,function(l,k,f){g=h.call(i,g,l,k,f);});return g;};a.find=function(g,j,k){for(var h=0,e=g.length;h<e;h++){if(j.call(k,g[h],h,g)){return g[h];}}return null;};a.grep=function(e,f){return a.filter(e,function(h,g){return f.test(h);});};a.partition=function(e,h,i){var g={matches:[],rejects:[]};a.each(e,function(j,f){var k=h.call(i,j,f,e)?g.matches:g.rejects;k.push(j);});return g;};a.zip=function(f,e){var g=[];a.each(f,function(i,h){g.push([i,e[h]]);});return g;};a.forEach=a.each;},"3.2.0");YUI.add("arraylist",function(e){var d=e.Array,c=d.each,a;function b(f){if(f!==undefined){this._items=e.Lang.isArray(f)?f:d(f);}else{this._items=this._items||[];}}a={item:function(f){return this._items[f];},each:function(g,f){c(this._items,function(j,h){j=this.item(h);g.call(f||j,j,h,this);},this);return this;},some:function(g,f){return d.some(this._items,function(j,h){j=this.item(h);return g.call(f||j,j,h,this);},this);},indexOf:function(f){return d.indexOf(this._items,f);},size:function(){return this._items.length;},isEmpty:function(){return !this.size();}};a._item=a.item;b.prototype=a;e.mix(b,{addMethod:function(f,g){g=d(g);c(g,function(h){f[h]=function(){var j=d(arguments,0,true),i=[];c(this._items,function(m,l){m=this._item(l);var k=m[h].apply(m,j);if(k!==undefined&&k!==m){i.push(k);}},this);return i.length?i:this;};});}});e.ArrayList=b;},"3.2.0");YUI.add("arraylist-add",function(a){a.mix(a.ArrayList.prototype,{add:function(d,c){var b=this._items;if(a.Lang.isNumber(c)){b.splice(c,0,d);}else{b.push(d);}return this;},remove:function(e,d,b){b=b||this.itemsAreEqual;for(var c=this._items.length-1;c>=0;--c){if(b.call(this,e,this.item(c))){this._items.splice(c,1);if(!d){break;}}}return this;},itemsAreEqual:function(d,c){return d===c;}});},"3.2.0",{requires:["arraylist"]});YUI.add("arraylist-filter",function(a){a.mix(a.ArrayList.prototype,{filter:function(c){var b=[];a.Array.each(this._items,function(e,d){e=this.item(d);if(c(e)){b.push(e);}},this);return new this.constructor(b);}});},"3.2.0",{requires:["arraylist"]});YUI.add("array-invoke",function(a){a.Array.invoke=function(b,e){var d=a.Array(arguments,2,true),f=a.Lang.isFunction,c=[];a.Array.each(a.Array(b),function(h,g){if(f(h[e])){c[g]=h[e].apply(h,d);}});return c;};},"3.2.0");YUI.add("collection",function(a){},"3.2.0",{use:["array-extras","arraylist","arraylist-add","arraylist-filter","array-invoke"]});
|
||||
@@ -1,675 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('array-extras', function(Y) {
|
||||
|
||||
/**
|
||||
* Collection utilities beyond what is provided in the YUI core
|
||||
* @module collection
|
||||
* @submodule array-extras
|
||||
*/
|
||||
|
||||
var L = Y.Lang, Native = Array.prototype, A = Y.Array;
|
||||
|
||||
/**
|
||||
* Adds the following array utilities to the YUI instance
|
||||
* (Y.Array). This is in addition to the methods provided
|
||||
* in the core.
|
||||
* @class YUI~array~extras
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the index of the last item in the array
|
||||
* that contains the specified value, -1 if the
|
||||
* value isn't found.
|
||||
* @method Array.lastIndexOf
|
||||
* @static
|
||||
* @param a {Array} the array to search
|
||||
* @param val the value to search for
|
||||
* @return {int} the index of hte item that contains the value or -1
|
||||
*/
|
||||
A.lastIndexOf = (Native.lastIndexOf) ?
|
||||
function(a ,val) {
|
||||
return a.lastIndexOf(val);
|
||||
} :
|
||||
function(a, val) {
|
||||
for (var i=a.length-1; i>=0; i=i-1) {
|
||||
if (a[i] === val) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a copy of the array with the duplicate entries removed
|
||||
* @method Array.unique
|
||||
* @static
|
||||
* @param a {Array} the array to find the subset of uniques for
|
||||
* @param sort {bool} flag to denote if the array is sorted or not. Defaults to false, the more general operation
|
||||
* @return {Array} a copy of the array with duplicate entries removed
|
||||
*/
|
||||
A.unique = function(a, sort) {
|
||||
var b = a.slice(), i = 0, n = -1, item = null;
|
||||
|
||||
while (i < b.length) {
|
||||
item = b[i];
|
||||
while ((n = A.lastIndexOf(b, item)) !== i) {
|
||||
b.splice(n, 1);
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
// Note: the sort option doesn't really belong here... I think it was added
|
||||
// because there was a way to fast path the two operations together. That
|
||||
// implementation was not working, so I replaced it with the following.
|
||||
// Leaving it in so that the API doesn't get broken.
|
||||
if (sort) {
|
||||
if (L.isNumber(b[0])) {
|
||||
b.sort(A.numericSort);
|
||||
} else {
|
||||
b.sort();
|
||||
}
|
||||
}
|
||||
|
||||
return b;
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* Returns a new array containing the items that the supplied
|
||||
* function returned true for.
|
||||
* @method Array.filter
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {Array} The items on which the supplied function
|
||||
* returned true. If no items matched an empty array is
|
||||
* returned.
|
||||
*/
|
||||
A.filter = (Native.filter) ?
|
||||
function(a, f, o) {
|
||||
return Native.filter.call(a, f, o);
|
||||
} :
|
||||
function(a, f, o) {
|
||||
var results = [];
|
||||
A.each(a, function(item, i, a) {
|
||||
if (f.call(o, item, i, a)) {
|
||||
results.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
/**
|
||||
* The inverse of filter. Executes the supplied function on each item.
|
||||
* Returns a new array containing the items that the supplied
|
||||
* function returned *false* for.
|
||||
* @method Array.reject
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {Array} The items on which the supplied function
|
||||
* returned false.
|
||||
*/
|
||||
A.reject = function(a, f, o) {
|
||||
return A.filter(a, function(item, i, a) {
|
||||
return !f.call(o, item, i, a);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* Iteration stops if the supplied function does not return
|
||||
* a truthy value.
|
||||
* @method Array.every
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {boolean} true if every item in the array returns true
|
||||
* from the supplied function.
|
||||
*/
|
||||
A.every = (Native.every) ?
|
||||
function(a, f, o) {
|
||||
return Native.every.call(a,f,o);
|
||||
} :
|
||||
function(a, f, o) {
|
||||
for (var i = 0, l = a.length; i < l; i=i+1) {
|
||||
if (!f.call(o, a[i], i, a)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* @method Array.map
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {Array} A new array containing the return value
|
||||
* of the supplied function for each item in the original
|
||||
* array.
|
||||
*/
|
||||
A.map = (Native.map) ?
|
||||
function(a, f, o) {
|
||||
return Native.map.call(a, f, o);
|
||||
} :
|
||||
function(a, f, o) {
|
||||
var results = [];
|
||||
A.each(a, function(item, i, a) {
|
||||
results.push(f.call(o, item, i, a));
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* Reduce "folds" the array into a single value. The callback
|
||||
* function receives four arguments:
|
||||
* the value from the previous callback call (or the initial value),
|
||||
* the value of the current element, the current index, and
|
||||
* the array over which iteration is occurring.
|
||||
* @method Array.reduce
|
||||
* @param a {Array} the array to iterate
|
||||
* @param init The initial value to start from
|
||||
* @param f {Function} the function to execute on each item. It
|
||||
* is responsible for returning the updated value of the
|
||||
* computation.
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return A value that results from iteratively applying the
|
||||
* supplied function to each element in the array.
|
||||
*/
|
||||
A.reduce = (Native.reduce) ?
|
||||
function(a, init, f, o) {
|
||||
//Firefox's Array.reduce does not allow inclusion of a
|
||||
// thisObject, so we need to implement it manually
|
||||
return Native.reduce.call(a, function(init, item, i, a) {
|
||||
return f.call(o, init, item, i, a);
|
||||
}, init);
|
||||
} :
|
||||
function(a, init, f, o) {
|
||||
var r = init;
|
||||
A.each(a, function (item, i, a) {
|
||||
r = f.call(o, r, item, i, a);
|
||||
});
|
||||
return r;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array,
|
||||
* searching for the first item that matches the supplied
|
||||
* function.
|
||||
* @method Array.find
|
||||
* @param a {Array} the array to search
|
||||
* @param f {Function} the function to execute on each item.
|
||||
* Iteration is stopped as soon as this function returns true
|
||||
* on an item.
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {object} the first item that the supplied function
|
||||
* returns true for, or null if it never returns true
|
||||
*/
|
||||
A.find = function(a, f, o) {
|
||||
for(var i=0, l = a.length; i < l; i++) {
|
||||
if (f.call(o, a[i], i, a)) {
|
||||
return a[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Iterates over an array, returning a new array of all the elements
|
||||
* that match the supplied regular expression
|
||||
* @method Array.grep
|
||||
* @param a {Array} a collection to iterate over
|
||||
* @param pattern {RegExp} The regular expression to test against
|
||||
* each item
|
||||
* @static
|
||||
* @return {Array} All the items in the collection that
|
||||
* produce a match against the supplied regular expression.
|
||||
* If no items match, an empty array is returned.
|
||||
*/
|
||||
A.grep = function (a, pattern) {
|
||||
return A.filter(a, function (item, index) {
|
||||
return pattern.test(item);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Partitions an array into two new arrays, one with the items
|
||||
* that match the supplied function, and one with the items that
|
||||
* do not.
|
||||
* @method Array.partition
|
||||
* @param a {Array} a collection to iterate over
|
||||
* @paran f {Function} a function that will receive each item
|
||||
* in the collection and its index.
|
||||
* @param o Optional execution context of f.
|
||||
* @static
|
||||
* @return An object with two members, 'matches' and 'rejects',
|
||||
* that are arrays containing the items that were selected or
|
||||
* rejected by the test function (or an empty array).
|
||||
*/
|
||||
A.partition = function (a, f, o) {
|
||||
var results = {
|
||||
matches: [],
|
||||
rejects: []
|
||||
};
|
||||
|
||||
A.each(a, function (item, index) {
|
||||
var set = f.call(o, item, index, a) ? results.matches : results.rejects;
|
||||
set.push(item);
|
||||
});
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an array of arrays by pairing the corresponding
|
||||
* elements of two arrays together into a new array.
|
||||
* @method Array.zip
|
||||
* @param a {Array} a collection to iterate over
|
||||
* @param a2 {Array} another collection whose members will be
|
||||
* paired with members of the first parameter
|
||||
* @static
|
||||
* @return An array of arrays formed by pairing each element
|
||||
* of the first collection with an item in the second collection
|
||||
* having the corresponding index.
|
||||
*/
|
||||
A.zip = function (a, a2) {
|
||||
var results = [];
|
||||
A.each(a, function (item, index) {
|
||||
results.push([item, a2[index]]);
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
A.forEach = A.each;
|
||||
|
||||
|
||||
}, '3.2.0' );
|
||||
YUI.add('arraylist', function(Y) {
|
||||
|
||||
/**
|
||||
* Collection utilities beyond what is provided in the YUI core
|
||||
* @module collection
|
||||
* @submodule arraylist
|
||||
*/
|
||||
|
||||
var YArray = Y.Array,
|
||||
YArray_each = YArray.each,
|
||||
ArrayListProto;
|
||||
|
||||
/**
|
||||
* Generic ArrayList class for managing lists of items and iterating operations
|
||||
* over them. The targeted use for this class is for augmentation onto a
|
||||
* class that is responsible for managing multiple instances of another class
|
||||
* (e.g. NodeList for Nodes). The recommended use is to augment your class with
|
||||
* ArrayList, then use ArrayList.addMethod to mirror the API of the constituent
|
||||
* items on the list's API.
|
||||
*
|
||||
* The default implementation creates immutable lists, but mutability can be
|
||||
* provided via the arraylist-add submodule or by implementing mutation methods
|
||||
* directly on the augmented class's prototype.
|
||||
*
|
||||
* @class ArrayList
|
||||
* @constructor
|
||||
* @param items { Array } array of items this list will be responsible for
|
||||
*/
|
||||
function ArrayList( items ) {
|
||||
if ( items !== undefined ) {
|
||||
this._items = Y.Lang.isArray( items ) ? items : YArray( items );
|
||||
} else {
|
||||
// ||= to support lazy initialization from augment
|
||||
this._items = this._items || [];
|
||||
}
|
||||
}
|
||||
|
||||
ArrayListProto = {
|
||||
/**
|
||||
* Get an item by index from the list. Override this method if managing a
|
||||
* list of objects that have a different public representation (e.g. Node
|
||||
* instances vs DOM nodes). The iteration methods that accept a user
|
||||
* function will use this method for access list items for operation.
|
||||
*
|
||||
* @method item
|
||||
* @param i { Integer } index to fetch
|
||||
* @return { mixed } the item at the requested index
|
||||
*/
|
||||
item: function ( i ) {
|
||||
return this._items[i];
|
||||
},
|
||||
|
||||
/**
|
||||
* <p>Execute a function on each item of the list, optionally providing a
|
||||
* custom execution context. Default context is the item.</p>
|
||||
*
|
||||
* <p>The callback signature is <code>callback( item, index )</code>.</p>
|
||||
*
|
||||
* @method each
|
||||
* @param fn { Function } the function to execute
|
||||
* @param context { mixed } optional override 'this' in the function
|
||||
* @return { ArrayList } this instance
|
||||
* @chainable
|
||||
*/
|
||||
each: function ( fn, context ) {
|
||||
YArray_each( this._items, function ( item, i ) {
|
||||
item = this.item( i );
|
||||
|
||||
fn.call( context || item, item, i, this );
|
||||
}, this);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* <p>Execute a function on each item of the list, optionally providing a
|
||||
* custom execution context. Default context is the item.</p>
|
||||
*
|
||||
* <p>The callback signature is <code>callback( item, index )</code>.</p>
|
||||
*
|
||||
* <p>Unlike <code>each</code>, if the callback returns true, the
|
||||
* iteratation will stop.</p>
|
||||
*
|
||||
* @method some
|
||||
* @param fn { Function } the function to execute
|
||||
* @param context { mixed } optional override 'this' in the function
|
||||
* @return { Boolean } True if the function returned true on an item
|
||||
*/
|
||||
some: function ( fn, context ) {
|
||||
return YArray.some( this._items, function ( item, i ) {
|
||||
item = this.item( i );
|
||||
|
||||
return fn.call( context || item, item, i, this );
|
||||
}, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Finds the first index of the needle in the managed array of items.
|
||||
*
|
||||
* @method indexOf
|
||||
* @param needle { mixed } The item to search for
|
||||
* @return { Integer } Array index if found. Otherwise -1
|
||||
*/
|
||||
indexOf: function ( needle ) {
|
||||
return YArray.indexOf( this._items, needle );
|
||||
},
|
||||
|
||||
/**
|
||||
* How many items are in this list?
|
||||
*
|
||||
* @method size
|
||||
* @return { Integer } Number of items in the list
|
||||
*/
|
||||
size: function () {
|
||||
return this._items.length;
|
||||
},
|
||||
|
||||
/**
|
||||
* Is this instance managing any items?
|
||||
*
|
||||
* @method isEmpty
|
||||
* @return { Boolean } true if 1 or more items are being managed
|
||||
*/
|
||||
isEmpty: function () {
|
||||
return !this.size();
|
||||
}
|
||||
};
|
||||
// Default implementation does not distinguish between public and private
|
||||
// item getter
|
||||
/**
|
||||
* Protected method for optimizations that may be appropriate for API
|
||||
* mirroring. Similar in functionality to <code>item</code>, but is used by
|
||||
* methods added with <code>ArrayList.addMethod()</code>.
|
||||
*
|
||||
* @method _item
|
||||
* @protected
|
||||
* @param i { Integer } Index of item to fetch
|
||||
* @return { mixed } The item appropriate for pass through API methods
|
||||
*/
|
||||
ArrayListProto._item = ArrayListProto.item;
|
||||
|
||||
ArrayList.prototype = ArrayListProto;
|
||||
|
||||
Y.mix( ArrayList, {
|
||||
|
||||
/**
|
||||
* <p>Adds a pass through method to dest (typically the prototype of a list
|
||||
* class) that calls the named method on each item in the list with
|
||||
* whatever parameters are passed in. Allows for API indirection via list
|
||||
* instances.</p>
|
||||
*
|
||||
* <p>Accepts a single string name or an array of string names.</p>
|
||||
*
|
||||
* <pre><code>list.each( function ( item ) {
|
||||
* item.methodName( 1, 2, 3 );
|
||||
* } );
|
||||
* // becomes
|
||||
* list.methodName( 1, 2, 3 );</code></pre>
|
||||
*
|
||||
* <p>Additionally, the pass through methods use the item retrieved by the
|
||||
* <code>_item</code> method in case there is any special behavior that is
|
||||
* appropriate for API mirroring.</p>
|
||||
*
|
||||
* @method addMethod
|
||||
* @static
|
||||
* @param dest { Object } Object or prototype to receive the iterator method
|
||||
* @param name { String | Array } Name of method of methods to create
|
||||
*/
|
||||
addMethod: function ( dest, names ) {
|
||||
|
||||
names = YArray( names );
|
||||
|
||||
YArray_each( names, function ( name ) {
|
||||
dest[ name ] = function () {
|
||||
var args = YArray( arguments, 0, true ),
|
||||
ret = [];
|
||||
|
||||
YArray_each( this._items, function ( item, i ) {
|
||||
item = this._item( i );
|
||||
|
||||
var result = item[ name ].apply( item, args );
|
||||
|
||||
if ( result !== undefined && result !== item ) {
|
||||
ret.push( result );
|
||||
}
|
||||
}, this);
|
||||
|
||||
return ret.length ? ret : this;
|
||||
};
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
Y.ArrayList = ArrayList;
|
||||
|
||||
|
||||
}, '3.2.0' );
|
||||
YUI.add('arraylist-add', function(Y) {
|
||||
|
||||
/**
|
||||
* Collection utilities beyond what is provided in the YUI core
|
||||
* @module collection
|
||||
* @submodule arraylist-add
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds methods add and remove to Y.ArrayList
|
||||
* @class ArrayList~add
|
||||
*/
|
||||
Y.mix( Y.ArrayList.prototype, {
|
||||
|
||||
/**
|
||||
* Add a single item to the ArrayList. Does not prevent duplicates.
|
||||
*
|
||||
* @method add
|
||||
* @param item { mixed } Item presumably of the same type as others in the
|
||||
* ArrayList
|
||||
* @param index {Number} (Optional.) Number representing the position at
|
||||
* which the item should be inserted.
|
||||
* @return {ArrayList} the instance
|
||||
* @chainable
|
||||
*/
|
||||
add: function ( item, index ) {
|
||||
var items = this._items;
|
||||
|
||||
if (Y.Lang.isNumber(index)) {
|
||||
items.splice(index, 0, item);
|
||||
}
|
||||
else {
|
||||
items.push(item);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes first or all occurrences of an item to the ArrayList. If a
|
||||
* comparator is not provided, uses itemsAreEqual method to determine
|
||||
* matches.
|
||||
*
|
||||
* @method remove
|
||||
* @param needle { mixed } Item to find and remove from the list
|
||||
* @param all { Boolean } If true, remove all occurrences
|
||||
* @param comparator { Function } optional a/b function to test equivalence
|
||||
* @return {ArrayList} the instance
|
||||
* @chainable
|
||||
*/
|
||||
remove: function ( needle, all, comparator ) {
|
||||
comparator = comparator || this.itemsAreEqual;
|
||||
|
||||
for (var i = this._items.length - 1; i >= 0; --i) {
|
||||
if ( comparator.call( this, needle, this.item( i ) ) ) {
|
||||
this._items.splice( i, 1 );
|
||||
if ( !all ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Default comparator for items stored in this list. Used by remove().
|
||||
*
|
||||
* @method itemsAreEqual
|
||||
* @param a { mixed } item to test equivalence with
|
||||
* @param b { mixed } other item to test equivalance
|
||||
* @return { Boolean } true if items are deemed equivalent
|
||||
*/
|
||||
itemsAreEqual: function ( a, b ) {
|
||||
return a === b;
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['arraylist']});
|
||||
YUI.add('arraylist-filter', function(Y) {
|
||||
|
||||
/**
|
||||
* Collection utilities beyond what is provided in the YUI core
|
||||
* @module collection
|
||||
* @submodule arraylist-filter
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds filter method to ArrayList prototype
|
||||
* @class ArrayList~filter
|
||||
*/
|
||||
Y.mix( Y.ArrayList.prototype, {
|
||||
|
||||
/**
|
||||
* <p>Create a new ArrayList (or augmenting class instance) from a subset
|
||||
* of items as determined by the boolean function passed as the
|
||||
* argument. The original ArrayList is unchanged.</p>
|
||||
*
|
||||
* <p>The validator signature is <code>validator( item )</code>.</p>
|
||||
*
|
||||
* @method filter
|
||||
* @param validator { Function } Boolean function to determine in or out
|
||||
* @return { ArrayList } New instance based on who passed the validator
|
||||
*/
|
||||
filter: function ( validator ) {
|
||||
var items = [];
|
||||
|
||||
Y.Array.each( this._items, function ( item, i ) {
|
||||
item = this.item( i );
|
||||
|
||||
if ( validator( item ) ) {
|
||||
items.push( item );
|
||||
}
|
||||
}, this);
|
||||
|
||||
return new this.constructor( items );
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['arraylist']});
|
||||
YUI.add('array-invoke', function(Y) {
|
||||
|
||||
/**
|
||||
* Collection utilities beyond what is provided in the YUI core
|
||||
* @module collection
|
||||
* @submodule array-invoke
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds the <code>Y.Array.invoke( items, methodName )</code> utility method.
|
||||
* @class YUI~array~invoke
|
||||
*/
|
||||
|
||||
/**
|
||||
* <p>Execute a named method on an array of objects. Items in the list that do
|
||||
* not have a function by that name will be skipped. For example,
|
||||
* <code>Y.Array.invoke( arrayOfDrags, 'plug', Y.Plugin.DDProxy );</code></p>
|
||||
*
|
||||
* <p>The return values from each call are returned in an array.</p>
|
||||
*
|
||||
* @method invoke
|
||||
* @static
|
||||
* @param items { Array } Array of objects supporting the named method
|
||||
* @param name { String } the name of the method to execute on each item
|
||||
* @param args* { mixed } Any number of additional args are passed as
|
||||
* parameters to the execution of the named method.
|
||||
* @return { Array } All return values, indexed according to item index.
|
||||
*/
|
||||
Y.Array.invoke = function ( items, name ) {
|
||||
var args = Y.Array( arguments, 2, true ),
|
||||
isFunction = Y.Lang.isFunction,
|
||||
ret = [];
|
||||
|
||||
Y.Array.each( Y.Array( items ), function ( item, i ) {
|
||||
if ( isFunction( item[ name ] ) ) {
|
||||
ret[i] = item[ name ].apply( item, args );
|
||||
}
|
||||
});
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
}, '3.2.0' );
|
||||
|
||||
|
||||
YUI.add('collection', function(Y){}, '3.2.0' ,{use:['array-extras', 'arraylist', 'arraylist-add', 'arraylist-filter', 'array-invoke']});
|
||||
|
||||
@@ -1,916 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('compat', function(Y) {
|
||||
|
||||
|
||||
/*global YAHOO*/
|
||||
/*global YUI*/
|
||||
/*global YUI_config*/
|
||||
|
||||
var COMPAT_ARG = '~yui|2|compat~';
|
||||
|
||||
|
||||
if (window.YAHOO != YUI) {
|
||||
|
||||
// get any existing YAHOO obj props
|
||||
var o = (window.YAHOO) ? YUI.merge(window.YAHOO) : null;
|
||||
|
||||
// Make the YUI global the YAHOO global
|
||||
window.YAHOO = YUI;
|
||||
|
||||
// augment old YAHOO props
|
||||
if (o) {
|
||||
Y.mix(Y, o);
|
||||
}
|
||||
}
|
||||
|
||||
// add old namespaces
|
||||
Y.namespace("util", "widget", "example");
|
||||
|
||||
// case/location change
|
||||
Y.env = (Y.env) ? Y.mix(Y.env, Y.Env) : Y.Env;
|
||||
Y.lang = (Y.lang) ? Y.mix(Y.lang, Y.Lang) : Y.Lang;
|
||||
Y.env.ua = Y.UA;
|
||||
|
||||
// support Y.register
|
||||
Y.mix(Y.env, {
|
||||
modules: [],
|
||||
listeners: [],
|
||||
getVersion: function(name) {
|
||||
return this.Env.modules[name] || null;
|
||||
}
|
||||
});
|
||||
|
||||
var L = Y.lang;
|
||||
|
||||
// add old lang properties
|
||||
Y.mix(L, {
|
||||
|
||||
augmentObject: function(r, s) {
|
||||
var a = arguments, wl = (a.length > 2) ? Y.Array(a, 2, true) : null,
|
||||
ov = (wl), args = [r, s, ov];
|
||||
|
||||
if (wl && wl[0] !== true) {
|
||||
args.push(wl);
|
||||
}
|
||||
|
||||
return Y.mix.apply(Y, args);
|
||||
},
|
||||
|
||||
augmentProto: function(r, s) {
|
||||
var a = arguments, wl = (a.length > 2) ? Y.Array(a, 2, true) : null,
|
||||
ov = (wl), args = [r, s, ov];
|
||||
return Y.augment.apply(Y, args);
|
||||
},
|
||||
|
||||
// extend: Y.bind(Y.extend, Y),
|
||||
extend: Y.extend,
|
||||
// merge: Y.bind(Y.merge, Y)
|
||||
merge: Y.merge
|
||||
}, true);
|
||||
|
||||
L.augment = L.augmentProto;
|
||||
|
||||
L.hasOwnProperty = function(o, k) {
|
||||
return (o.hasOwnProperty(k));
|
||||
};
|
||||
|
||||
Y.augmentProto = L.augmentProto;
|
||||
|
||||
// add register function
|
||||
Y.mix(Y, {
|
||||
register: function(name, mainClass, data) {
|
||||
var mods = Y.Env.modules;
|
||||
if (!mods[name]) {
|
||||
mods[name] = { versions:[], builds:[] };
|
||||
}
|
||||
var m=mods[name],v=data.version,b=data.build,ls=Y.Env.listeners;
|
||||
m.name = name;
|
||||
m.version = v;
|
||||
m.build = b;
|
||||
m.versions.push(v);
|
||||
m.builds.push(b);
|
||||
m.mainClass = mainClass;
|
||||
// fire the module load listeners
|
||||
for (var i=0;i<ls.length;i=i+1) {
|
||||
ls[i](m);
|
||||
}
|
||||
// label the main class
|
||||
if (mainClass) {
|
||||
mainClass.VERSION = v;
|
||||
mainClass.BUILD = b;
|
||||
} else {
|
||||
Y.log("mainClass is undefined for module " + name, "warn");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// add old load listeners
|
||||
if ("undefined" != typeof YAHOO_config) {
|
||||
var l=YAHOO_config.listener,ls=Y.Env.listeners,unique=true,i;
|
||||
if (l) {
|
||||
// if YAHOO is loaded multiple times we need to check to see if
|
||||
// this is a new config object. If it is, add the new component
|
||||
// load listener to the stack
|
||||
for (i=0;i<ls.length;i=i+1) {
|
||||
if (ls[i]==l) {
|
||||
unique=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (unique) {
|
||||
ls.push(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add old registration for yahoo
|
||||
Y.register("yahoo", Y, {version: "3.2.0", build: "2676"});
|
||||
|
||||
if (Y.Event) {
|
||||
|
||||
o = {
|
||||
|
||||
/**
|
||||
* Safari detection
|
||||
* @property isSafari
|
||||
* @private
|
||||
* @static
|
||||
* @deprecated use Y.Env.UA.webkit
|
||||
*/
|
||||
isSafari: Y.UA.webkit,
|
||||
|
||||
/**
|
||||
* webkit version
|
||||
* @property webkit
|
||||
* @type string
|
||||
* @private
|
||||
* @static
|
||||
* @deprecated use Y.Env.UA.webkit
|
||||
*/
|
||||
webkit: Y.UA.webkit,
|
||||
|
||||
/**
|
||||
* Normalized keycodes for webkit/safari
|
||||
* @property webkitKeymap
|
||||
* @type {int: int}
|
||||
* @private
|
||||
* @static
|
||||
* @final
|
||||
*/
|
||||
webkitKeymap: {
|
||||
63232: 38, // up
|
||||
63233: 40, // down
|
||||
63234: 37, // left
|
||||
63235: 39, // right
|
||||
63276: 33, // page up
|
||||
63277: 34, // page down
|
||||
25: 9 // SHIFT-TAB (Safari provides a different key code in
|
||||
// this case, even though the shiftKey modifier is set)
|
||||
},
|
||||
|
||||
/**
|
||||
* IE detection
|
||||
* @property isIE
|
||||
* @private
|
||||
* @static
|
||||
* @deprecated use Y.Env.UA.ie
|
||||
*/
|
||||
isIE: Y.UA.ie,
|
||||
|
||||
/**
|
||||
* Returns scrollLeft
|
||||
* @method _getScrollLeft
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
_getScrollLeft: function() {
|
||||
return this._getScroll()[1];
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns scrollTop
|
||||
* @method _getScrollTop
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
_getScrollTop: function() {
|
||||
return this._getScroll()[0];
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the scrollTop and scrollLeft. Used to calculate the
|
||||
* pageX and pageY in Internet Explorer
|
||||
* @method _getScroll
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
_getScroll: function() {
|
||||
var d = Y.config.doc, dd = d.documentElement, db = d.body;
|
||||
if (dd && (dd.scrollTop || dd.scrollLeft)) {
|
||||
return [dd.scrollTop, dd.scrollLeft];
|
||||
} else if (db) {
|
||||
return [db.scrollTop, db.scrollLeft];
|
||||
} else {
|
||||
return [0, 0];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the event's pageX
|
||||
* @method getPageX
|
||||
* @param {Event} ev the event
|
||||
* @return {int} the event's pageX
|
||||
* @static
|
||||
*/
|
||||
getPageX: function(ev) {
|
||||
var x = ev.pageX;
|
||||
if (!x && 0 !== x) {
|
||||
x = ev.clientX || 0;
|
||||
|
||||
if ( Y.UA.ie ) {
|
||||
x += this._getScrollLeft();
|
||||
}
|
||||
}
|
||||
|
||||
return x;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the charcode for an event
|
||||
* @method getCharCode
|
||||
* @param {Event} ev the event
|
||||
* @return {int} the event's charCode
|
||||
* @static
|
||||
*/
|
||||
getCharCode: function(ev) {
|
||||
var code = ev.keyCode || ev.charCode || 0;
|
||||
|
||||
// webkit normalization
|
||||
if (Y.UA.webkit && (code in Y.Event.webkitKeymap)) {
|
||||
code = Y.Event.webkitKeymap[code];
|
||||
}
|
||||
return code;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the event's pageY
|
||||
* @method getPageY
|
||||
* @param {Event} ev the event
|
||||
* @return {int} the event's pageY
|
||||
* @static
|
||||
*/
|
||||
getPageY: function(ev) {
|
||||
var y = ev.pageY;
|
||||
if (!y && 0 !== y) {
|
||||
y = ev.clientY || 0;
|
||||
|
||||
if ( Y.UA.ie ) {
|
||||
y += this._getScrollTop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return y;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the pageX and pageY properties as an indexed array.
|
||||
* @method getXY
|
||||
* @param {Event} ev the event
|
||||
* @return {[x, y]} the pageX and pageY properties of the event
|
||||
* @static
|
||||
*/
|
||||
getXY: function(ev) {
|
||||
return [this.getPageX(ev), this.getPageY(ev)];
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the event's related target
|
||||
* @method getRelatedTarget
|
||||
* @param {Event} ev the event
|
||||
* @return {HTMLElement} the event's relatedTarget
|
||||
* @static
|
||||
*/
|
||||
getRelatedTarget: function(ev) {
|
||||
var t = ev.relatedTarget;
|
||||
if (!t) {
|
||||
if (ev.type == "mouseout") {
|
||||
t = ev.toElement;
|
||||
} else if (ev.type == "mouseover") {
|
||||
t = ev.fromElement;
|
||||
}
|
||||
}
|
||||
|
||||
return this.resolveTextNode(t);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the time of the event. If the time is not included, the
|
||||
* event is modified using the current time.
|
||||
* @method getTime
|
||||
* @param {Event} ev the event
|
||||
* @return {Date} the time of the event
|
||||
* @static
|
||||
*/
|
||||
getTime: function(ev) {
|
||||
if (!ev.time) {
|
||||
var t = new Date().getTime();
|
||||
try {
|
||||
ev.time = t;
|
||||
} catch(ex) {
|
||||
this.lastError = ex;
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
return ev.time;
|
||||
},
|
||||
|
||||
/**
|
||||
* Convenience method for stopPropagation + preventDefault
|
||||
* @method stopEvent
|
||||
* @param {Event} ev the event
|
||||
* @static
|
||||
*/
|
||||
stopEvent: function(ev) {
|
||||
this.stopPropagation(ev);
|
||||
this.preventDefault(ev);
|
||||
},
|
||||
|
||||
/**
|
||||
* Stops event propagation
|
||||
* @method stopPropagation
|
||||
* @param {Event} ev the event
|
||||
* @static
|
||||
*/
|
||||
stopPropagation: function(ev) {
|
||||
if (ev.stopPropagation) {
|
||||
ev.stopPropagation();
|
||||
} else {
|
||||
ev.cancelBubble = true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Prevents the default behavior of the event
|
||||
* @method preventDefault
|
||||
* @param {Event} ev the event
|
||||
* @static
|
||||
*/
|
||||
preventDefault: function(ev) {
|
||||
if (ev.preventDefault) {
|
||||
ev.preventDefault();
|
||||
} else {
|
||||
ev.returnValue = false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the event's target element. Safari sometimes provides
|
||||
* a text node, and this is automatically resolved to the text
|
||||
* node's parent so that it behaves like other browsers.
|
||||
* @method getTarget
|
||||
* @param {Event} ev the event
|
||||
* @param {boolean} resolveTextNode when set to true the target's
|
||||
* parent will be returned if the target is a
|
||||
* text node. @deprecated, the text node is
|
||||
* now resolved automatically
|
||||
* @return {HTMLElement} the event's target
|
||||
* @static
|
||||
*/
|
||||
getTarget: function(ev, resolveTextNode) {
|
||||
var t = ev.target || ev.srcElement;
|
||||
return this.resolveTextNode(t);
|
||||
},
|
||||
|
||||
/**
|
||||
* In some cases, some browsers will return a text node inside
|
||||
* the actual element that was targeted. This normalizes the
|
||||
* return value for getTarget and getRelatedTarget.
|
||||
* @method resolveTextNode
|
||||
* @param {HTMLElement} node node to resolve
|
||||
* @return {HTMLElement} the normized node
|
||||
* @static
|
||||
*/
|
||||
resolveTextNode: function(node) {
|
||||
if (node && 3 == node.nodeType) {
|
||||
return node.parentNode;
|
||||
} else {
|
||||
return node;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* We cache elements bound by id because when the unload event
|
||||
* fires, we can no longer use document.getElementById
|
||||
* @method getEl
|
||||
* @static
|
||||
* @private
|
||||
* @deprecated Elements are not cached any longer
|
||||
*/
|
||||
getEl: function(id) {
|
||||
return Y.get(id);
|
||||
}
|
||||
};
|
||||
|
||||
Y.mix(Y.Event, o);
|
||||
|
||||
/**
|
||||
* Calls Y.Event.attach with the correct argument order
|
||||
* @method removeListener
|
||||
*/
|
||||
Y.Event.removeListener = function(el, type, fn, data, override) {
|
||||
|
||||
var context, a=[type, fn, el];
|
||||
|
||||
if (data) {
|
||||
|
||||
if (override) {
|
||||
context = (override === true) ? data : override;
|
||||
}
|
||||
|
||||
a.push(context);
|
||||
a.push(data);
|
||||
}
|
||||
|
||||
a.push(COMPAT_ARG);
|
||||
|
||||
return Y.Event.detach.apply(Y.Event, a);
|
||||
};
|
||||
|
||||
/**
|
||||
* Calls Y.Event.detach with the correct argument order
|
||||
* @method addListener
|
||||
*/
|
||||
Y.Event.addListener = function(el, type, fn, data, override) {
|
||||
|
||||
// Y.log('addListener:');
|
||||
// Y.log(Y.Array(arguments, 0, true), 1);
|
||||
|
||||
// var a = Y.Array(arguments, 0, true), el = a.shift();
|
||||
// a.splice(2, 0, el);
|
||||
// return Y.Event.attach.apply(Y.Event, a);
|
||||
var context, a=[type, fn, el];
|
||||
|
||||
if (data) {
|
||||
|
||||
if (override) {
|
||||
context = (override === true) ? data : override;
|
||||
}
|
||||
|
||||
a.push(context);
|
||||
a.push(data);
|
||||
}
|
||||
|
||||
a.push(COMPAT_ARG);
|
||||
|
||||
return Y.Event.attach.apply(Y.Event, a);
|
||||
};
|
||||
|
||||
Y.Event.on = Y.Event.addListener;
|
||||
|
||||
var newOnavail = Y.Event.onAvailable;
|
||||
|
||||
Y.Event.onAvailable = function(id, fn, p_obj, p_override) {
|
||||
return newOnavail(id, fn, p_obj, p_override, false, true);
|
||||
};
|
||||
|
||||
Y.Event.onContentReady = function(id, fn, p_obj, p_override) {
|
||||
return newOnavail(id, fn, p_obj, p_override, true, true);
|
||||
};
|
||||
|
||||
Y.Event.onDOMReady = function() {
|
||||
var a = Y.Array(arguments, 0, true);
|
||||
a.unshift('domready');
|
||||
return Y.on.apply(Y, a);
|
||||
};
|
||||
|
||||
Y.util.Event = Y.Event;
|
||||
|
||||
var CE = function(type, oScope, silent, signature) {
|
||||
//debugger;
|
||||
|
||||
var o = {
|
||||
context: oScope,
|
||||
silent: silent || false
|
||||
// signature: signature || CE.LIST
|
||||
};
|
||||
|
||||
CE.superclass.constructor.call(this, type, o);
|
||||
|
||||
this.signature = signature || CE.LIST;
|
||||
};
|
||||
|
||||
Y.extend(CE, Y.CustomEvent, {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Subscriber listener sigature constant. The LIST type returns three
|
||||
* parameters: the event type, the array of args passed to fire, and
|
||||
* the optional custom object
|
||||
* @property YAHOO.util.CustomEvent.LIST
|
||||
* @static
|
||||
* @type int
|
||||
*/
|
||||
CE.LIST = 0;
|
||||
|
||||
/**
|
||||
* Subscriber listener sigature constant. The FLAT type returns two
|
||||
* parameters: the first argument passed to fire and the optional
|
||||
* custom object
|
||||
* @property YAHOO.util.CustomEvent.FLAT
|
||||
* @static
|
||||
* @type int
|
||||
*/
|
||||
CE.FLAT = 1;
|
||||
|
||||
Y.util.CustomEvent = CE;
|
||||
|
||||
var EP = function() {
|
||||
//console.log('Compat CustomEvent constructor executed: ' + this._yuid);
|
||||
if (!this._yuievt) {
|
||||
var sub = this.subscribe;
|
||||
Y.EventTarget.apply(this, arguments);
|
||||
this.subscribe = sub;
|
||||
this.__yuiepinit = function() {};
|
||||
}
|
||||
};
|
||||
|
||||
Y.extend(EP, Y.EventTarget, {
|
||||
|
||||
createEvent: function(type, o) {
|
||||
// if (!this._yuievt) {
|
||||
// Y.EventTarget.call(this);
|
||||
// }
|
||||
o = o || {};
|
||||
o.signature = o.signature || CE.FLAT;
|
||||
return this.publish(type, o);
|
||||
},
|
||||
|
||||
subscribe: function(type, fn, obj, override) {
|
||||
var ce = this._yuievt.events[type] || this.createEvent(type),
|
||||
a = Y.Array(arguments);
|
||||
|
||||
if (override && true !== override) {
|
||||
// a[2] = override;
|
||||
// a[1] = obj;
|
||||
}
|
||||
|
||||
Y.EventTarget.prototype.on.apply(this, a);
|
||||
},
|
||||
|
||||
fireEvent: function(type) {
|
||||
return this.fire.apply(this, arguments);
|
||||
},
|
||||
|
||||
hasEvent: function(type) {
|
||||
if (!this._yuievt) {
|
||||
Y.EventTarget.call(this);
|
||||
}
|
||||
return this.getEvent(type);
|
||||
}
|
||||
});
|
||||
|
||||
Y.util.EventProvider = EP;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Y.register("event", Y, {version: "3.2.0", build: "2676"});
|
||||
|
||||
|
||||
var propertyCache = {};
|
||||
var patterns = {
|
||||
HYPHEN: /(-[a-z])/i, // to normalize get/setStyle
|
||||
ROOT_TAG: /^body|html$/i, // body for quirks mode, html for standards,
|
||||
OP_SCROLL:/^(?:inline|table-row)$/i
|
||||
};
|
||||
var slice = [].slice;
|
||||
|
||||
var hyphenToCamel = function(property) {
|
||||
if ( !patterns.HYPHEN.test(property) ) {
|
||||
return property; // no hyphens
|
||||
}
|
||||
|
||||
if (propertyCache[property]) { // already converted
|
||||
return propertyCache[property];
|
||||
}
|
||||
|
||||
var converted = property;
|
||||
|
||||
while( patterns.HYPHEN.exec(converted) ) {
|
||||
converted = converted.replace(RegExp.$1,
|
||||
RegExp.$1.substr(1).toUpperCase());
|
||||
}
|
||||
|
||||
propertyCache[property] = converted;
|
||||
return converted;
|
||||
//return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug
|
||||
};
|
||||
|
||||
var Dom = {
|
||||
get: function(el) {
|
||||
if (el) {
|
||||
if (el.nodeType || el.item) { // Node, or NodeList
|
||||
return el;
|
||||
}
|
||||
|
||||
if (typeof el === 'string') { // id
|
||||
return document.getElementById(el);
|
||||
}
|
||||
|
||||
if ('length' in el) { // array-like
|
||||
var c = [];
|
||||
for (var i = 0, len = el.length; i < len; ++i) {
|
||||
c[c.length] = Dom.get(el[i]);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
return el; // some other object, just pass it back
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
isAncestor: function(haystack, needle) {
|
||||
return YUI.DOM.contains(Dom.get(haystack), Dom.get(needle));
|
||||
},
|
||||
|
||||
inDocument: function(el) {
|
||||
return Dom.isAncestor(Y.config.doc.documentElement, el);
|
||||
},
|
||||
|
||||
batch: function(el, method, o, override, args) {
|
||||
el = (el && (el.tagName || el.item)) ? el : Dom.get(el); // skip get() when possible
|
||||
|
||||
if (!el || !method) {
|
||||
return false;
|
||||
}
|
||||
if (args) {
|
||||
args = Y.Array(args);
|
||||
}
|
||||
var scope = (override) ? o : window;
|
||||
|
||||
var apply = function(el) {
|
||||
if (args) {
|
||||
var tmp = slice.call(args);
|
||||
tmp.unshift(el);
|
||||
return method.apply(scope, tmp);
|
||||
} else {
|
||||
return method.call(scope, el, o);
|
||||
}
|
||||
};
|
||||
|
||||
if (el.tagName || el.length === undefined) { // element or not array-like
|
||||
return apply(el);
|
||||
}
|
||||
|
||||
var collection = [];
|
||||
|
||||
for (var i = 0, len = el.length; i < len; ++i) {
|
||||
collection[collection.length] = apply(el[i]);
|
||||
}
|
||||
|
||||
return collection;
|
||||
},
|
||||
|
||||
// 2.x returns false if already present
|
||||
_addClass: function(el, className) {
|
||||
if ( YUI.DOM.hasClass(el, className) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
YUI.DOM.addClass(el, className);
|
||||
return true;
|
||||
},
|
||||
|
||||
// 2.x returns false if not present
|
||||
_removeClass: function(el, className) {
|
||||
if ( !YUI.DOM.hasClass(el, className) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
YUI.DOM.removeClass(el, className);
|
||||
return true;
|
||||
},
|
||||
|
||||
// 2.x returns false if no newClass or same as oldClass
|
||||
_replaceClass: function(el, oldClass, newClass) {
|
||||
if (!newClass || oldClass === newClass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
YUI.DOM.replaceClass(el, oldClass, newClass);
|
||||
return true;
|
||||
},
|
||||
|
||||
getElementsByClassName: function(className, tag, root) {
|
||||
tag = tag || '*';
|
||||
root = (root) ? Dom.get(root) : Y.config.doc;
|
||||
var nodes = [];
|
||||
if (root) {
|
||||
nodes = Y.Selector.query(tag + '.' + className, root);
|
||||
}
|
||||
return nodes;
|
||||
},
|
||||
|
||||
getElementsBy: function(method, tag, root) {
|
||||
tag = tag || '*';
|
||||
root = (root) ? Dom.get(root) : null || document;
|
||||
|
||||
var nodes = [];
|
||||
if (root) {
|
||||
nodes = YUI.DOM.byTag(tag, root, method);
|
||||
}
|
||||
return nodes;
|
||||
},
|
||||
|
||||
getViewportWidth: YUI.DOM.winWidth,
|
||||
getViewportHeight: YUI.DOM.winHeight,
|
||||
getDocumentWidth: YUI.DOM.docWidth,
|
||||
getDocumentHeight: YUI.DOM.docHeight,
|
||||
getDocumentScrollTop: YUI.DOM.docScrollY,
|
||||
getDocumentScrollLeft: YUI.DOM.docScrollX,
|
||||
|
||||
_guid: function(el, prefix) {
|
||||
prefix = prefix || 'yui-gen';
|
||||
Dom._id_counter = Dom._id_counter || 0;
|
||||
|
||||
if (el && el.id) { // do not override existing ID
|
||||
return el.id;
|
||||
}
|
||||
|
||||
var id = prefix + Dom._id_counter++;
|
||||
|
||||
if (el) {
|
||||
el.id = id;
|
||||
}
|
||||
|
||||
return id;
|
||||
},
|
||||
|
||||
_region: function(el) {
|
||||
if ( (el.parentNode === null || el.offsetParent === null ||
|
||||
YUI.DOM.getStyle(el, 'display') == 'none') && el != el.ownerDocument.body) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return YUI.DOM.region(el);
|
||||
|
||||
},
|
||||
|
||||
_ancestorByClass: function(element, className) {
|
||||
return YUI.DOM.ancestor(element, function(el) {
|
||||
return YUI.DOM.hasClass(el, className);
|
||||
});
|
||||
},
|
||||
|
||||
_ancestorByTag: function(element, tag) {
|
||||
tag = tag.toUpperCase();
|
||||
return YUI.DOM.ancestor(element, function(el) {
|
||||
return el.tagName.toUpperCase() === tag;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var wrap = function(fn, name) {
|
||||
Dom[name] = function() {
|
||||
var args = slice.call(arguments);
|
||||
args[0] = Dom.get(args[0]);
|
||||
return fn.apply(Dom, args);
|
||||
};
|
||||
};
|
||||
|
||||
var wrapped = {
|
||||
getAncestorBy: YUI.DOM.ancestor,
|
||||
getAncestorByClassName: Dom._ancestorByClass,
|
||||
getAncestorByTagName: Dom._ancestorByTag,
|
||||
getPreviousSiblingBy: YUI.DOM.previous,
|
||||
getPreviousSibling: YUI.DOM.previous,
|
||||
getNextSiblingBy: YUI.DOM.next,
|
||||
getNextSibling: YUI.DOM.next,
|
||||
getFirstChildBy: YUI.DOM.firstChild,
|
||||
getFirstChild: YUI.DOM.firstChild,
|
||||
getLastChildBy: YUI.DOM.lastChild,
|
||||
getLastChild: YUI.DOM.lastChild,
|
||||
getChildrenBy: YUI.DOM.children,
|
||||
getChildren: YUI.DOM.children,
|
||||
insertBefore: function(newNode, refNode) {
|
||||
YUI.DOM.insertBefore(Dom.get(newNode), Dom.get(refNode));
|
||||
},
|
||||
insertAfter: function(newNode, refNode) {
|
||||
YUI.DOM.insertAfter(Dom.get(newNode), Dom.get(refNode));
|
||||
}
|
||||
};
|
||||
|
||||
Y.each(wrapped, wrap);
|
||||
|
||||
var batched = {
|
||||
getStyle: YUI.DOM.getStyle,
|
||||
setStyle: YUI.DOM.setStyle,
|
||||
getXY: YUI.DOM.getXY,
|
||||
setXY: YUI.DOM.setXY,
|
||||
getX: YUI.DOM.getX,
|
||||
getY: YUI.DOM.getY,
|
||||
setX: YUI.DOM.setX,
|
||||
setY: YUI.DOM.setY,
|
||||
getRegion: Dom._region,
|
||||
hasClass: YUI.DOM.hasClass,
|
||||
addClass: Dom._addClass,
|
||||
removeClass: Dom._removeClass,
|
||||
replaceClass: Dom._replaceClass,
|
||||
generateId: Dom._guid
|
||||
};
|
||||
|
||||
Y.each(batched, function(v, n) {
|
||||
Dom[n] = function(el) {
|
||||
var args = slice.call(arguments, 1);
|
||||
return Dom.batch(el, v, null, null, args);
|
||||
};
|
||||
});
|
||||
|
||||
Y.util.Dom = Dom;
|
||||
|
||||
YAHOO.util.Region = function(t, r, b, l) {
|
||||
this.top = t;
|
||||
this[1] = t;
|
||||
this.right = r;
|
||||
this.bottom = b;
|
||||
this.left = l;
|
||||
this[0] = l;
|
||||
};
|
||||
|
||||
YAHOO.util.Region.prototype.contains = function(region) {
|
||||
return ( region.left >= this.left &&
|
||||
region.right <= this.right &&
|
||||
region.top >= this.top &&
|
||||
region.bottom <= this.bottom );
|
||||
|
||||
// this.logger.debug("does " + this + " contain " + region + " ... " + ret);
|
||||
};
|
||||
|
||||
YAHOO.util.Region.prototype.getArea = function() {
|
||||
return ( (this.bottom - this.top) * (this.right - this.left) );
|
||||
};
|
||||
|
||||
YAHOO.util.Region.prototype.intersect = function(region) {
|
||||
var t = Math.max( this.top, region.top );
|
||||
var r = Math.min( this.right, region.right );
|
||||
var b = Math.min( this.bottom, region.bottom );
|
||||
var l = Math.max( this.left, region.left );
|
||||
|
||||
if (b >= t && r >= l) {
|
||||
return new YAHOO.util.Region(t, r, b, l);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
YAHOO.util.Region.prototype.union = function(region) {
|
||||
var t = Math.min( this.top, region.top );
|
||||
var r = Math.max( this.right, region.right );
|
||||
var b = Math.max( this.bottom, region.bottom );
|
||||
var l = Math.min( this.left, region.left );
|
||||
|
||||
return new YAHOO.util.Region(t, r, b, l);
|
||||
};
|
||||
|
||||
YAHOO.util.Region.prototype.toString = function() {
|
||||
return ( "Region {" +
|
||||
"top: " + this.top +
|
||||
", right: " + this.right +
|
||||
", bottom: " + this.bottom +
|
||||
", left: " + this.left +
|
||||
"}" );
|
||||
};
|
||||
|
||||
YAHOO.util.Region.getRegion = function(el) {
|
||||
return YUI.DOM.region(el);
|
||||
};
|
||||
|
||||
YAHOO.util.Point = function(x, y) {
|
||||
if (YAHOO.lang.isArray(x)) { // accept input from Dom.getXY, Event.getXY, etc.
|
||||
y = x[1]; // dont blow away x yet
|
||||
x = x[0];
|
||||
}
|
||||
|
||||
this.x = this.right = this.left = this[0] = x;
|
||||
this.y = this.top = this.bottom = this[1] = y;
|
||||
};
|
||||
|
||||
YAHOO.util.Point.prototype = new YAHOO.util.Region();
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['dom','event-base','dump','substitute']});
|
||||
YUI._setup(); YUI.use('compat');
|
||||
-9
File diff suppressed because one or more lines are too long
@@ -1,912 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('compat', function(Y) {
|
||||
|
||||
|
||||
/*global YAHOO*/
|
||||
/*global YUI*/
|
||||
/*global YUI_config*/
|
||||
|
||||
var COMPAT_ARG = '~yui|2|compat~';
|
||||
|
||||
|
||||
if (window.YAHOO != YUI) {
|
||||
|
||||
// get any existing YAHOO obj props
|
||||
var o = (window.YAHOO) ? YUI.merge(window.YAHOO) : null;
|
||||
|
||||
// Make the YUI global the YAHOO global
|
||||
window.YAHOO = YUI;
|
||||
|
||||
// augment old YAHOO props
|
||||
if (o) {
|
||||
Y.mix(Y, o);
|
||||
}
|
||||
}
|
||||
|
||||
// add old namespaces
|
||||
Y.namespace("util", "widget", "example");
|
||||
|
||||
// case/location change
|
||||
Y.env = (Y.env) ? Y.mix(Y.env, Y.Env) : Y.Env;
|
||||
Y.lang = (Y.lang) ? Y.mix(Y.lang, Y.Lang) : Y.Lang;
|
||||
Y.env.ua = Y.UA;
|
||||
|
||||
// support Y.register
|
||||
Y.mix(Y.env, {
|
||||
modules: [],
|
||||
listeners: [],
|
||||
getVersion: function(name) {
|
||||
return this.Env.modules[name] || null;
|
||||
}
|
||||
});
|
||||
|
||||
var L = Y.lang;
|
||||
|
||||
// add old lang properties
|
||||
Y.mix(L, {
|
||||
|
||||
augmentObject: function(r, s) {
|
||||
var a = arguments, wl = (a.length > 2) ? Y.Array(a, 2, true) : null,
|
||||
ov = (wl), args = [r, s, ov];
|
||||
|
||||
if (wl && wl[0] !== true) {
|
||||
args.push(wl);
|
||||
}
|
||||
|
||||
return Y.mix.apply(Y, args);
|
||||
},
|
||||
|
||||
augmentProto: function(r, s) {
|
||||
var a = arguments, wl = (a.length > 2) ? Y.Array(a, 2, true) : null,
|
||||
ov = (wl), args = [r, s, ov];
|
||||
return Y.augment.apply(Y, args);
|
||||
},
|
||||
|
||||
// extend: Y.bind(Y.extend, Y),
|
||||
extend: Y.extend,
|
||||
// merge: Y.bind(Y.merge, Y)
|
||||
merge: Y.merge
|
||||
}, true);
|
||||
|
||||
L.augment = L.augmentProto;
|
||||
|
||||
L.hasOwnProperty = function(o, k) {
|
||||
return (o.hasOwnProperty(k));
|
||||
};
|
||||
|
||||
Y.augmentProto = L.augmentProto;
|
||||
|
||||
// add register function
|
||||
Y.mix(Y, {
|
||||
register: function(name, mainClass, data) {
|
||||
var mods = Y.Env.modules;
|
||||
if (!mods[name]) {
|
||||
mods[name] = { versions:[], builds:[] };
|
||||
}
|
||||
var m=mods[name],v=data.version,b=data.build,ls=Y.Env.listeners;
|
||||
m.name = name;
|
||||
m.version = v;
|
||||
m.build = b;
|
||||
m.versions.push(v);
|
||||
m.builds.push(b);
|
||||
m.mainClass = mainClass;
|
||||
// fire the module load listeners
|
||||
for (var i=0;i<ls.length;i=i+1) {
|
||||
ls[i](m);
|
||||
}
|
||||
// label the main class
|
||||
if (mainClass) {
|
||||
mainClass.VERSION = v;
|
||||
mainClass.BUILD = b;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// add old load listeners
|
||||
if ("undefined" != typeof YAHOO_config) {
|
||||
var l=YAHOO_config.listener,ls=Y.Env.listeners,unique=true,i;
|
||||
if (l) {
|
||||
// if YAHOO is loaded multiple times we need to check to see if
|
||||
// this is a new config object. If it is, add the new component
|
||||
// load listener to the stack
|
||||
for (i=0;i<ls.length;i=i+1) {
|
||||
if (ls[i]==l) {
|
||||
unique=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (unique) {
|
||||
ls.push(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add old registration for yahoo
|
||||
Y.register("yahoo", Y, {version: "3.2.0", build: "2676"});
|
||||
|
||||
if (Y.Event) {
|
||||
|
||||
o = {
|
||||
|
||||
/**
|
||||
* Safari detection
|
||||
* @property isSafari
|
||||
* @private
|
||||
* @static
|
||||
* @deprecated use Y.Env.UA.webkit
|
||||
*/
|
||||
isSafari: Y.UA.webkit,
|
||||
|
||||
/**
|
||||
* webkit version
|
||||
* @property webkit
|
||||
* @type string
|
||||
* @private
|
||||
* @static
|
||||
* @deprecated use Y.Env.UA.webkit
|
||||
*/
|
||||
webkit: Y.UA.webkit,
|
||||
|
||||
/**
|
||||
* Normalized keycodes for webkit/safari
|
||||
* @property webkitKeymap
|
||||
* @type {int: int}
|
||||
* @private
|
||||
* @static
|
||||
* @final
|
||||
*/
|
||||
webkitKeymap: {
|
||||
63232: 38, // up
|
||||
63233: 40, // down
|
||||
63234: 37, // left
|
||||
63235: 39, // right
|
||||
63276: 33, // page up
|
||||
63277: 34, // page down
|
||||
25: 9 // SHIFT-TAB (Safari provides a different key code in
|
||||
// this case, even though the shiftKey modifier is set)
|
||||
},
|
||||
|
||||
/**
|
||||
* IE detection
|
||||
* @property isIE
|
||||
* @private
|
||||
* @static
|
||||
* @deprecated use Y.Env.UA.ie
|
||||
*/
|
||||
isIE: Y.UA.ie,
|
||||
|
||||
/**
|
||||
* Returns scrollLeft
|
||||
* @method _getScrollLeft
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
_getScrollLeft: function() {
|
||||
return this._getScroll()[1];
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns scrollTop
|
||||
* @method _getScrollTop
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
_getScrollTop: function() {
|
||||
return this._getScroll()[0];
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the scrollTop and scrollLeft. Used to calculate the
|
||||
* pageX and pageY in Internet Explorer
|
||||
* @method _getScroll
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
_getScroll: function() {
|
||||
var d = Y.config.doc, dd = d.documentElement, db = d.body;
|
||||
if (dd && (dd.scrollTop || dd.scrollLeft)) {
|
||||
return [dd.scrollTop, dd.scrollLeft];
|
||||
} else if (db) {
|
||||
return [db.scrollTop, db.scrollLeft];
|
||||
} else {
|
||||
return [0, 0];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the event's pageX
|
||||
* @method getPageX
|
||||
* @param {Event} ev the event
|
||||
* @return {int} the event's pageX
|
||||
* @static
|
||||
*/
|
||||
getPageX: function(ev) {
|
||||
var x = ev.pageX;
|
||||
if (!x && 0 !== x) {
|
||||
x = ev.clientX || 0;
|
||||
|
||||
if ( Y.UA.ie ) {
|
||||
x += this._getScrollLeft();
|
||||
}
|
||||
}
|
||||
|
||||
return x;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the charcode for an event
|
||||
* @method getCharCode
|
||||
* @param {Event} ev the event
|
||||
* @return {int} the event's charCode
|
||||
* @static
|
||||
*/
|
||||
getCharCode: function(ev) {
|
||||
var code = ev.keyCode || ev.charCode || 0;
|
||||
|
||||
// webkit normalization
|
||||
if (Y.UA.webkit && (code in Y.Event.webkitKeymap)) {
|
||||
code = Y.Event.webkitKeymap[code];
|
||||
}
|
||||
return code;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the event's pageY
|
||||
* @method getPageY
|
||||
* @param {Event} ev the event
|
||||
* @return {int} the event's pageY
|
||||
* @static
|
||||
*/
|
||||
getPageY: function(ev) {
|
||||
var y = ev.pageY;
|
||||
if (!y && 0 !== y) {
|
||||
y = ev.clientY || 0;
|
||||
|
||||
if ( Y.UA.ie ) {
|
||||
y += this._getScrollTop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return y;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the pageX and pageY properties as an indexed array.
|
||||
* @method getXY
|
||||
* @param {Event} ev the event
|
||||
* @return {[x, y]} the pageX and pageY properties of the event
|
||||
* @static
|
||||
*/
|
||||
getXY: function(ev) {
|
||||
return [this.getPageX(ev), this.getPageY(ev)];
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the event's related target
|
||||
* @method getRelatedTarget
|
||||
* @param {Event} ev the event
|
||||
* @return {HTMLElement} the event's relatedTarget
|
||||
* @static
|
||||
*/
|
||||
getRelatedTarget: function(ev) {
|
||||
var t = ev.relatedTarget;
|
||||
if (!t) {
|
||||
if (ev.type == "mouseout") {
|
||||
t = ev.toElement;
|
||||
} else if (ev.type == "mouseover") {
|
||||
t = ev.fromElement;
|
||||
}
|
||||
}
|
||||
|
||||
return this.resolveTextNode(t);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the time of the event. If the time is not included, the
|
||||
* event is modified using the current time.
|
||||
* @method getTime
|
||||
* @param {Event} ev the event
|
||||
* @return {Date} the time of the event
|
||||
* @static
|
||||
*/
|
||||
getTime: function(ev) {
|
||||
if (!ev.time) {
|
||||
var t = new Date().getTime();
|
||||
try {
|
||||
ev.time = t;
|
||||
} catch(ex) {
|
||||
this.lastError = ex;
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
return ev.time;
|
||||
},
|
||||
|
||||
/**
|
||||
* Convenience method for stopPropagation + preventDefault
|
||||
* @method stopEvent
|
||||
* @param {Event} ev the event
|
||||
* @static
|
||||
*/
|
||||
stopEvent: function(ev) {
|
||||
this.stopPropagation(ev);
|
||||
this.preventDefault(ev);
|
||||
},
|
||||
|
||||
/**
|
||||
* Stops event propagation
|
||||
* @method stopPropagation
|
||||
* @param {Event} ev the event
|
||||
* @static
|
||||
*/
|
||||
stopPropagation: function(ev) {
|
||||
if (ev.stopPropagation) {
|
||||
ev.stopPropagation();
|
||||
} else {
|
||||
ev.cancelBubble = true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Prevents the default behavior of the event
|
||||
* @method preventDefault
|
||||
* @param {Event} ev the event
|
||||
* @static
|
||||
*/
|
||||
preventDefault: function(ev) {
|
||||
if (ev.preventDefault) {
|
||||
ev.preventDefault();
|
||||
} else {
|
||||
ev.returnValue = false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the event's target element. Safari sometimes provides
|
||||
* a text node, and this is automatically resolved to the text
|
||||
* node's parent so that it behaves like other browsers.
|
||||
* @method getTarget
|
||||
* @param {Event} ev the event
|
||||
* @param {boolean} resolveTextNode when set to true the target's
|
||||
* parent will be returned if the target is a
|
||||
* text node. @deprecated, the text node is
|
||||
* now resolved automatically
|
||||
* @return {HTMLElement} the event's target
|
||||
* @static
|
||||
*/
|
||||
getTarget: function(ev, resolveTextNode) {
|
||||
var t = ev.target || ev.srcElement;
|
||||
return this.resolveTextNode(t);
|
||||
},
|
||||
|
||||
/**
|
||||
* In some cases, some browsers will return a text node inside
|
||||
* the actual element that was targeted. This normalizes the
|
||||
* return value for getTarget and getRelatedTarget.
|
||||
* @method resolveTextNode
|
||||
* @param {HTMLElement} node node to resolve
|
||||
* @return {HTMLElement} the normized node
|
||||
* @static
|
||||
*/
|
||||
resolveTextNode: function(node) {
|
||||
if (node && 3 == node.nodeType) {
|
||||
return node.parentNode;
|
||||
} else {
|
||||
return node;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* We cache elements bound by id because when the unload event
|
||||
* fires, we can no longer use document.getElementById
|
||||
* @method getEl
|
||||
* @static
|
||||
* @private
|
||||
* @deprecated Elements are not cached any longer
|
||||
*/
|
||||
getEl: function(id) {
|
||||
return Y.get(id);
|
||||
}
|
||||
};
|
||||
|
||||
Y.mix(Y.Event, o);
|
||||
|
||||
/**
|
||||
* Calls Y.Event.attach with the correct argument order
|
||||
* @method removeListener
|
||||
*/
|
||||
Y.Event.removeListener = function(el, type, fn, data, override) {
|
||||
|
||||
var context, a=[type, fn, el];
|
||||
|
||||
if (data) {
|
||||
|
||||
if (override) {
|
||||
context = (override === true) ? data : override;
|
||||
}
|
||||
|
||||
a.push(context);
|
||||
a.push(data);
|
||||
}
|
||||
|
||||
a.push(COMPAT_ARG);
|
||||
|
||||
return Y.Event.detach.apply(Y.Event, a);
|
||||
};
|
||||
|
||||
/**
|
||||
* Calls Y.Event.detach with the correct argument order
|
||||
* @method addListener
|
||||
*/
|
||||
Y.Event.addListener = function(el, type, fn, data, override) {
|
||||
|
||||
|
||||
// var a = Y.Array(arguments, 0, true), el = a.shift();
|
||||
// a.splice(2, 0, el);
|
||||
// return Y.Event.attach.apply(Y.Event, a);
|
||||
var context, a=[type, fn, el];
|
||||
|
||||
if (data) {
|
||||
|
||||
if (override) {
|
||||
context = (override === true) ? data : override;
|
||||
}
|
||||
|
||||
a.push(context);
|
||||
a.push(data);
|
||||
}
|
||||
|
||||
a.push(COMPAT_ARG);
|
||||
|
||||
return Y.Event.attach.apply(Y.Event, a);
|
||||
};
|
||||
|
||||
Y.Event.on = Y.Event.addListener;
|
||||
|
||||
var newOnavail = Y.Event.onAvailable;
|
||||
|
||||
Y.Event.onAvailable = function(id, fn, p_obj, p_override) {
|
||||
return newOnavail(id, fn, p_obj, p_override, false, true);
|
||||
};
|
||||
|
||||
Y.Event.onContentReady = function(id, fn, p_obj, p_override) {
|
||||
return newOnavail(id, fn, p_obj, p_override, true, true);
|
||||
};
|
||||
|
||||
Y.Event.onDOMReady = function() {
|
||||
var a = Y.Array(arguments, 0, true);
|
||||
a.unshift('domready');
|
||||
return Y.on.apply(Y, a);
|
||||
};
|
||||
|
||||
Y.util.Event = Y.Event;
|
||||
|
||||
var CE = function(type, oScope, silent, signature) {
|
||||
//debugger;
|
||||
|
||||
var o = {
|
||||
context: oScope,
|
||||
silent: silent || false
|
||||
// signature: signature || CE.LIST
|
||||
};
|
||||
|
||||
CE.superclass.constructor.call(this, type, o);
|
||||
|
||||
this.signature = signature || CE.LIST;
|
||||
};
|
||||
|
||||
Y.extend(CE, Y.CustomEvent, {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Subscriber listener sigature constant. The LIST type returns three
|
||||
* parameters: the event type, the array of args passed to fire, and
|
||||
* the optional custom object
|
||||
* @property YAHOO.util.CustomEvent.LIST
|
||||
* @static
|
||||
* @type int
|
||||
*/
|
||||
CE.LIST = 0;
|
||||
|
||||
/**
|
||||
* Subscriber listener sigature constant. The FLAT type returns two
|
||||
* parameters: the first argument passed to fire and the optional
|
||||
* custom object
|
||||
* @property YAHOO.util.CustomEvent.FLAT
|
||||
* @static
|
||||
* @type int
|
||||
*/
|
||||
CE.FLAT = 1;
|
||||
|
||||
Y.util.CustomEvent = CE;
|
||||
|
||||
var EP = function() {
|
||||
//console.log('Compat CustomEvent constructor executed: ' + this._yuid);
|
||||
if (!this._yuievt) {
|
||||
var sub = this.subscribe;
|
||||
Y.EventTarget.apply(this, arguments);
|
||||
this.subscribe = sub;
|
||||
this.__yuiepinit = function() {};
|
||||
}
|
||||
};
|
||||
|
||||
Y.extend(EP, Y.EventTarget, {
|
||||
|
||||
createEvent: function(type, o) {
|
||||
// if (!this._yuievt) {
|
||||
// Y.EventTarget.call(this);
|
||||
// }
|
||||
o = o || {};
|
||||
o.signature = o.signature || CE.FLAT;
|
||||
return this.publish(type, o);
|
||||
},
|
||||
|
||||
subscribe: function(type, fn, obj, override) {
|
||||
var ce = this._yuievt.events[type] || this.createEvent(type),
|
||||
a = Y.Array(arguments);
|
||||
|
||||
if (override && true !== override) {
|
||||
// a[2] = override;
|
||||
// a[1] = obj;
|
||||
}
|
||||
|
||||
Y.EventTarget.prototype.on.apply(this, a);
|
||||
},
|
||||
|
||||
fireEvent: function(type) {
|
||||
return this.fire.apply(this, arguments);
|
||||
},
|
||||
|
||||
hasEvent: function(type) {
|
||||
if (!this._yuievt) {
|
||||
Y.EventTarget.call(this);
|
||||
}
|
||||
return this.getEvent(type);
|
||||
}
|
||||
});
|
||||
|
||||
Y.util.EventProvider = EP;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Y.register("event", Y, {version: "3.2.0", build: "2676"});
|
||||
|
||||
|
||||
var propertyCache = {};
|
||||
var patterns = {
|
||||
HYPHEN: /(-[a-z])/i, // to normalize get/setStyle
|
||||
ROOT_TAG: /^body|html$/i, // body for quirks mode, html for standards,
|
||||
OP_SCROLL:/^(?:inline|table-row)$/i
|
||||
};
|
||||
var slice = [].slice;
|
||||
|
||||
var hyphenToCamel = function(property) {
|
||||
if ( !patterns.HYPHEN.test(property) ) {
|
||||
return property; // no hyphens
|
||||
}
|
||||
|
||||
if (propertyCache[property]) { // already converted
|
||||
return propertyCache[property];
|
||||
}
|
||||
|
||||
var converted = property;
|
||||
|
||||
while( patterns.HYPHEN.exec(converted) ) {
|
||||
converted = converted.replace(RegExp.$1,
|
||||
RegExp.$1.substr(1).toUpperCase());
|
||||
}
|
||||
|
||||
propertyCache[property] = converted;
|
||||
return converted;
|
||||
//return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug
|
||||
};
|
||||
|
||||
var Dom = {
|
||||
get: function(el) {
|
||||
if (el) {
|
||||
if (el.nodeType || el.item) { // Node, or NodeList
|
||||
return el;
|
||||
}
|
||||
|
||||
if (typeof el === 'string') { // id
|
||||
return document.getElementById(el);
|
||||
}
|
||||
|
||||
if ('length' in el) { // array-like
|
||||
var c = [];
|
||||
for (var i = 0, len = el.length; i < len; ++i) {
|
||||
c[c.length] = Dom.get(el[i]);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
return el; // some other object, just pass it back
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
isAncestor: function(haystack, needle) {
|
||||
return YUI.DOM.contains(Dom.get(haystack), Dom.get(needle));
|
||||
},
|
||||
|
||||
inDocument: function(el) {
|
||||
return Dom.isAncestor(Y.config.doc.documentElement, el);
|
||||
},
|
||||
|
||||
batch: function(el, method, o, override, args) {
|
||||
el = (el && (el.tagName || el.item)) ? el : Dom.get(el); // skip get() when possible
|
||||
|
||||
if (!el || !method) {
|
||||
return false;
|
||||
}
|
||||
if (args) {
|
||||
args = Y.Array(args);
|
||||
}
|
||||
var scope = (override) ? o : window;
|
||||
|
||||
var apply = function(el) {
|
||||
if (args) {
|
||||
var tmp = slice.call(args);
|
||||
tmp.unshift(el);
|
||||
return method.apply(scope, tmp);
|
||||
} else {
|
||||
return method.call(scope, el, o);
|
||||
}
|
||||
};
|
||||
|
||||
if (el.tagName || el.length === undefined) { // element or not array-like
|
||||
return apply(el);
|
||||
}
|
||||
|
||||
var collection = [];
|
||||
|
||||
for (var i = 0, len = el.length; i < len; ++i) {
|
||||
collection[collection.length] = apply(el[i]);
|
||||
}
|
||||
|
||||
return collection;
|
||||
},
|
||||
|
||||
// 2.x returns false if already present
|
||||
_addClass: function(el, className) {
|
||||
if ( YUI.DOM.hasClass(el, className) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
YUI.DOM.addClass(el, className);
|
||||
return true;
|
||||
},
|
||||
|
||||
// 2.x returns false if not present
|
||||
_removeClass: function(el, className) {
|
||||
if ( !YUI.DOM.hasClass(el, className) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
YUI.DOM.removeClass(el, className);
|
||||
return true;
|
||||
},
|
||||
|
||||
// 2.x returns false if no newClass or same as oldClass
|
||||
_replaceClass: function(el, oldClass, newClass) {
|
||||
if (!newClass || oldClass === newClass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
YUI.DOM.replaceClass(el, oldClass, newClass);
|
||||
return true;
|
||||
},
|
||||
|
||||
getElementsByClassName: function(className, tag, root) {
|
||||
tag = tag || '*';
|
||||
root = (root) ? Dom.get(root) : Y.config.doc;
|
||||
var nodes = [];
|
||||
if (root) {
|
||||
nodes = Y.Selector.query(tag + '.' + className, root);
|
||||
}
|
||||
return nodes;
|
||||
},
|
||||
|
||||
getElementsBy: function(method, tag, root) {
|
||||
tag = tag || '*';
|
||||
root = (root) ? Dom.get(root) : null || document;
|
||||
|
||||
var nodes = [];
|
||||
if (root) {
|
||||
nodes = YUI.DOM.byTag(tag, root, method);
|
||||
}
|
||||
return nodes;
|
||||
},
|
||||
|
||||
getViewportWidth: YUI.DOM.winWidth,
|
||||
getViewportHeight: YUI.DOM.winHeight,
|
||||
getDocumentWidth: YUI.DOM.docWidth,
|
||||
getDocumentHeight: YUI.DOM.docHeight,
|
||||
getDocumentScrollTop: YUI.DOM.docScrollY,
|
||||
getDocumentScrollLeft: YUI.DOM.docScrollX,
|
||||
|
||||
_guid: function(el, prefix) {
|
||||
prefix = prefix || 'yui-gen';
|
||||
Dom._id_counter = Dom._id_counter || 0;
|
||||
|
||||
if (el && el.id) { // do not override existing ID
|
||||
return el.id;
|
||||
}
|
||||
|
||||
var id = prefix + Dom._id_counter++;
|
||||
|
||||
if (el) {
|
||||
el.id = id;
|
||||
}
|
||||
|
||||
return id;
|
||||
},
|
||||
|
||||
_region: function(el) {
|
||||
if ( (el.parentNode === null || el.offsetParent === null ||
|
||||
YUI.DOM.getStyle(el, 'display') == 'none') && el != el.ownerDocument.body) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return YUI.DOM.region(el);
|
||||
|
||||
},
|
||||
|
||||
_ancestorByClass: function(element, className) {
|
||||
return YUI.DOM.ancestor(element, function(el) {
|
||||
return YUI.DOM.hasClass(el, className);
|
||||
});
|
||||
},
|
||||
|
||||
_ancestorByTag: function(element, tag) {
|
||||
tag = tag.toUpperCase();
|
||||
return YUI.DOM.ancestor(element, function(el) {
|
||||
return el.tagName.toUpperCase() === tag;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var wrap = function(fn, name) {
|
||||
Dom[name] = function() {
|
||||
var args = slice.call(arguments);
|
||||
args[0] = Dom.get(args[0]);
|
||||
return fn.apply(Dom, args);
|
||||
};
|
||||
};
|
||||
|
||||
var wrapped = {
|
||||
getAncestorBy: YUI.DOM.ancestor,
|
||||
getAncestorByClassName: Dom._ancestorByClass,
|
||||
getAncestorByTagName: Dom._ancestorByTag,
|
||||
getPreviousSiblingBy: YUI.DOM.previous,
|
||||
getPreviousSibling: YUI.DOM.previous,
|
||||
getNextSiblingBy: YUI.DOM.next,
|
||||
getNextSibling: YUI.DOM.next,
|
||||
getFirstChildBy: YUI.DOM.firstChild,
|
||||
getFirstChild: YUI.DOM.firstChild,
|
||||
getLastChildBy: YUI.DOM.lastChild,
|
||||
getLastChild: YUI.DOM.lastChild,
|
||||
getChildrenBy: YUI.DOM.children,
|
||||
getChildren: YUI.DOM.children,
|
||||
insertBefore: function(newNode, refNode) {
|
||||
YUI.DOM.insertBefore(Dom.get(newNode), Dom.get(refNode));
|
||||
},
|
||||
insertAfter: function(newNode, refNode) {
|
||||
YUI.DOM.insertAfter(Dom.get(newNode), Dom.get(refNode));
|
||||
}
|
||||
};
|
||||
|
||||
Y.each(wrapped, wrap);
|
||||
|
||||
var batched = {
|
||||
getStyle: YUI.DOM.getStyle,
|
||||
setStyle: YUI.DOM.setStyle,
|
||||
getXY: YUI.DOM.getXY,
|
||||
setXY: YUI.DOM.setXY,
|
||||
getX: YUI.DOM.getX,
|
||||
getY: YUI.DOM.getY,
|
||||
setX: YUI.DOM.setX,
|
||||
setY: YUI.DOM.setY,
|
||||
getRegion: Dom._region,
|
||||
hasClass: YUI.DOM.hasClass,
|
||||
addClass: Dom._addClass,
|
||||
removeClass: Dom._removeClass,
|
||||
replaceClass: Dom._replaceClass,
|
||||
generateId: Dom._guid
|
||||
};
|
||||
|
||||
Y.each(batched, function(v, n) {
|
||||
Dom[n] = function(el) {
|
||||
var args = slice.call(arguments, 1);
|
||||
return Dom.batch(el, v, null, null, args);
|
||||
};
|
||||
});
|
||||
|
||||
Y.util.Dom = Dom;
|
||||
|
||||
YAHOO.util.Region = function(t, r, b, l) {
|
||||
this.top = t;
|
||||
this[1] = t;
|
||||
this.right = r;
|
||||
this.bottom = b;
|
||||
this.left = l;
|
||||
this[0] = l;
|
||||
};
|
||||
|
||||
YAHOO.util.Region.prototype.contains = function(region) {
|
||||
return ( region.left >= this.left &&
|
||||
region.right <= this.right &&
|
||||
region.top >= this.top &&
|
||||
region.bottom <= this.bottom );
|
||||
|
||||
};
|
||||
|
||||
YAHOO.util.Region.prototype.getArea = function() {
|
||||
return ( (this.bottom - this.top) * (this.right - this.left) );
|
||||
};
|
||||
|
||||
YAHOO.util.Region.prototype.intersect = function(region) {
|
||||
var t = Math.max( this.top, region.top );
|
||||
var r = Math.min( this.right, region.right );
|
||||
var b = Math.min( this.bottom, region.bottom );
|
||||
var l = Math.max( this.left, region.left );
|
||||
|
||||
if (b >= t && r >= l) {
|
||||
return new YAHOO.util.Region(t, r, b, l);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
YAHOO.util.Region.prototype.union = function(region) {
|
||||
var t = Math.min( this.top, region.top );
|
||||
var r = Math.max( this.right, region.right );
|
||||
var b = Math.max( this.bottom, region.bottom );
|
||||
var l = Math.min( this.left, region.left );
|
||||
|
||||
return new YAHOO.util.Region(t, r, b, l);
|
||||
};
|
||||
|
||||
YAHOO.util.Region.prototype.toString = function() {
|
||||
return ( "Region {" +
|
||||
"top: " + this.top +
|
||||
", right: " + this.right +
|
||||
", bottom: " + this.bottom +
|
||||
", left: " + this.left +
|
||||
"}" );
|
||||
};
|
||||
|
||||
YAHOO.util.Region.getRegion = function(el) {
|
||||
return YUI.DOM.region(el);
|
||||
};
|
||||
|
||||
YAHOO.util.Point = function(x, y) {
|
||||
if (YAHOO.lang.isArray(x)) { // accept input from Dom.getXY, Event.getXY, etc.
|
||||
y = x[1]; // dont blow away x yet
|
||||
x = x[0];
|
||||
}
|
||||
|
||||
this.x = this.right = this.left = this[0] = x;
|
||||
this.y = this.top = this.bottom = this[1] = y;
|
||||
};
|
||||
|
||||
YAHOO.util.Point.prototype = new YAHOO.util.Region();
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['dom','event-base','dump','substitute']});
|
||||
YUI._setup(); YUI.use('compat');
|
||||
@@ -1,7 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
@@ -1,7 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-skin-sam .yui3-console-ft .yui3-console-filters-categories,.yui3-skin-sam .yui3-console-ft .yui3-console-filters-sources{text-align:left;padding:5px 0;border:1px inset;margin:0 2px;}.yui3-skin-sam .yui3-console-ft .yui3-console-filters-categories{background:#fff;border-bottom:2px ridge;}.yui3-skin-sam .yui3-console-ft .yui3-console-filters-sources{background:#fff;margin-bottom:2px;border-top:0 none;border-bottom-right-radius:10px;border-bottom-left-radius:10px;-moz-border-radius-bottomright:10px;-moz-border-radius-bottomleft:10px;-webkit-border-bottom-right-radius:10px;-webkit-border-bottom-left-radius:10px;}.yui3-skin-sam .yui3-console-filter-label{white-space:nowrap;margin-left:1ex;}
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-skin-sam .yui3-separate-console{position:absolute;right:1em;top:1em;z-index:999;}.yui3-skin-sam .yui3-inline-console{display:-moz-inline-stack;display:inline-block;*display:inline;zoom:1;vertical-align:top;}.yui3-skin-sam .yui3-inline-console .yui3-console-content{position:relative;}.yui3-skin-sam .yui3-console-content{background:#777;_background:#D8D8DA url(bg.png) repeat-x 0 0;font:normal 13px/1.3 Arial,sans-serif;text-align:left;border:1px solid #777;border-radius:10px;-moz-border-radius:10px;-webkit-border-radius:10px;}.yui3-skin-sam .yui3-console-hd,.yui3-skin-sam .yui3-console-bd,.yui3-skin-sam .yui3-console-ft{position:relative;}.yui3-skin-sam .yui3-console-hd,.yui3-skin-sam .yui3-console-ft .yui3-console-controls{text-align:right;}.yui3-skin-sam .yui3-console-hd{background:#D8D8DA url(bg.png) repeat-x 0 0;padding:1ex;border:1px solid transparent;_border:0 none;border-top-right-radius:10px;border-top-left-radius:10px;-moz-border-radius-topright:10px;-moz-border-radius-topleft:10px;-webkit-border-top-right-radius:10px;-webkit-border-top-left-radius:10px;}.yui3-skin-sam .yui3-console-bd{background:#fff;border-top:1px solid #777;border-bottom:1px solid #777;color:#000;font-size:11px;overflow:auto;overflow-x:auto;overflow-y:scroll;_width:100%;}.yui3-skin-sam .yui3-console-ft{background:#D8D8DA url(bg.png) repeat-x 0 0;border:1px solid transparent;_border:0 none;border-bottom-right-radius:10px;border-bottom-left-radius:10px;-moz-border-radius-bottomright:10px;-moz-border-radius-bottomleft:10px;-webkit-border-bottom-right-radius:10px;-webkit-border-bottom-left-radius:10px;}.yui3-skin-sam .yui3-console-controls{padding:4px 1ex;zoom:1;}.yui3-skin-sam .yui3-console-title{color:#000;display:inline;float:left;font-weight:bold;font-size:13px;height:24px;line-height:24px;margin:0;padding-left:1ex;}.yui3-skin-sam .yui3-console-pause-label{float:left;}.yui3-skin-sam .yui3-console-button{line-height:1.3;}.yui3-skin-sam .yui3-console-collapsed .yui3-console-bd,.yui3-skin-sam .yui3-console-collapsed .yui3-console-ft{display:none;}.yui3-skin-sam .yui3-console-content.yui3-console-collapsed{-webkit-border-radius:0;}.yui3-skin-sam .yui3-console-collapsed .yui3-console-hd{border-radius:10px;-moz-border-radius:10px;-webkit-border-radius:0;}.yui3-skin-sam .yui3-console-entry{border-bottom:1px solid #aaa;min-height:32px;_height:32px;}.yui3-skin-sam .yui3-console-entry-meta{margin:0;overflow:hidden;}.yui3-skin-sam .yui3-console-entry-content{margin:0;padding:0 1ex;white-space:pre-wrap;word-wrap:break-word;}.yui3-skin-sam .yui3-console-entry-meta .yui3-console-entry-src{color:#000;font-style:italic;font-weight:bold;float:right;margin:2px 5px 0 0;}.yui3-skin-sam .yui3-console-entry-meta .yui3-console-entry-time{color:#777;padding-left:1ex;}.yui3-skin-sam .yui3-console-entry-warn .yui3-console-entry-meta .yui3-console-entry-time{color:#555;}.yui3-skin-sam .yui3-console-entry-info .yui3-console-entry-meta .yui3-console-entry-cat,.yui3-skin-sam .yui3-console-entry-warn .yui3-console-entry-meta .yui3-console-entry-cat,.yui3-skin-sam .yui3-console-entry-error .yui3-console-entry-meta .yui3-console-entry-cat{display:none;}.yui3-skin-sam .yui3-console-entry-warn{background:#aee url(warn_error.png) no-repeat -15px 15px;}.yui3-skin-sam .yui3-console-entry-error{background:#ffa url(warn_error.png) no-repeat 5px -24px;color:#900;}.yui3-skin-sam .yui3-console-entry-warn .yui3-console-entry-content,.yui3-skin-sam .yui3-console-entry-error .yui3-console-entry-content{padding-left:24px;}.yui3-skin-sam .yui3-console-entry-cat{text-transform:uppercase;padding:1px 4px;background-color:#ccc;}.yui3-skin-sam .yui3-console-entry-info .yui3-console-entry-cat{background-color:#ac2;}.yui3-skin-sam .yui3-console-entry-warn .yui3-console-entry-cat{background-color:#e81;}.yui3-skin-sam .yui3-console-entry-error .yui3-console-entry-cat{background-color:#b00;color:#fff;}.yui3-skin-sam .yui3-console-hidden{display:none;}
|
||||
File diff suppressed because one or more lines are too long
-9
File diff suppressed because one or more lines are too long
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("lang/console",function(A){A.Intl.add("console","",{title:"Log Console",pause:"Pause",clear:"Clear",collapse:"Collapse",expand:"Expand"});},"3.2.0");
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("lang/console_en",function(A){A.Intl.add("console","en",{title:"Log Console",pause:"Pause",clear:"Clear",collapse:"Collapse",expand:"Expand"});},"3.2.0");
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("lang/console_es",function(A){A.Intl.add("console","es",{title:"Consola de informacion",pause:"Pausa",clear:"Borrar",collapse:"Colapsar",expand:"Expandir"});},"3.2.0");
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("cookie",function(C){var K=C.Lang,I=C.Object,G=null,D=K.isString,P=K.isObject,F=K.isUndefined,E=K.isFunction,H=encodeURIComponent,B=decodeURIComponent,N=C.config.doc;function J(L){throw new TypeError(L);}function M(L){if(!D(L)||L===""){J("Cookie name must be a non-empty string.");}}function A(L){if(!D(L)||L===""){J("Subcookie name must be a non-empty string.");}}C.Cookie={_createCookieString:function(Q,T,R,O){O=O||{};var V=H(Q)+"="+(R?H(T):T),L=O.expires,U=O.path,S=O.domain;if(P(O)){if(L instanceof Date){V+="; expires="+L.toUTCString();}if(D(U)&&U!==""){V+="; path="+U;}if(D(S)&&S!==""){V+="; domain="+S;}if(O.secure===true){V+="; secure";}}return V;},_createCookieHashString:function(L){if(!P(L)){J("Cookie._createCookieHashString(): Argument must be an object.");}var O=[];I.each(L,function(R,Q){if(!E(R)&&!F(R)){O.push(H(Q)+"="+H(String(R)));}});return O.join("&");},_parseCookieHash:function(S){var R=S.split("&"),T=G,Q={};if(S.length){for(var O=0,L=R.length;O<L;O++){T=R[O].split("=");Q[B(T[0])]=B(T[1]);}}return Q;},_parseCookieString:function(W,Y){var X={};if(D(W)&&W.length>0){var L=(Y===false?function(Z){return Z;}:B),U=W.split(/;\s/g),V=G,O=G,R=G;for(var Q=0,S=U.length;Q<S;Q++){R=U[Q].match(/([^=]+)=/i);if(R instanceof Array){try{V=B(R[1]);O=L(U[Q].substring(R[1].length+1));}catch(T){}}else{V=B(U[Q]);O="";}X[V]=O;}}return X;},_setDoc:function(L){N=L;},exists:function(L){M(L);var O=this._parseCookieString(N.cookie,true);return O.hasOwnProperty(L);},get:function(O,L){M(O);var S,Q,R;if(E(L)){R=L;L={};}else{if(P(L)){R=L.converter;}else{L={};}}S=this._parseCookieString(N.cookie,!L.raw);Q=S[O];if(F(Q)){return G;}if(!E(R)){return Q;}else{return R(Q);}},getSub:function(L,Q,O){var R=this.getSubs(L);if(R!==G){A(Q);if(F(R[Q])){return G;}if(!E(O)){return R[Q];}else{return O(R[Q]);}}else{return G;}},getSubs:function(L){M(L);var O=this._parseCookieString(N.cookie,false);if(D(O[L])){return this._parseCookieHash(O[L]);}return G;},remove:function(O,L){M(O);L=C.merge(L||{},{expires:new Date(0)});return this.set(O,"",L);},removeSub:function(O,S,L){M(O);A(S);L=L||{};var R=this.getSubs(O);if(P(R)&&R.hasOwnProperty(S)){delete R[S];if(!L.removeIfEmpty){return this.setSubs(O,R,L);}else{for(var Q in R){if(R.hasOwnProperty(Q)&&!E(R[Q])&&!F(R[Q])){return this.setSubs(O,R,L);}}return this.remove(O,L);}}else{return"";}},set:function(O,Q,L){M(O);if(F(Q)){J("Cookie.set(): Value cannot be undefined.");}L=L||{};var R=this._createCookieString(O,Q,!L.raw,L);N.cookie=R;return R;},setSub:function(O,R,Q,L){M(O);A(R);if(F(Q)){J("Cookie.setSub(): Subcookie value cannot be undefined.");}var S=this.getSubs(O);if(!P(S)){S={};}S[R]=Q;return this.setSubs(O,S,L);},setSubs:function(O,Q,L){M(O);if(!P(Q)){J("Cookie.setSubs(): Cookie value must be an object.");}var R=this._createCookieString(O,this._createCookieHashString(Q),false,L);N.cookie=R;return R;}};},"3.2.0",{requires:["yui-base"]});
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-cssbase h1{font-size:138.5%;}.yui3-cssbase h2{font-size:123.1%;}.yui3-cssbase h3{font-size:108%;}.yui3-cssbase h1,.yui3-cssbase h2,.yui3-cssbase h3{margin:1em 0;}.yui3-cssbase h1,.yui3-cssbase h2,.yui3-cssbase h3,.yui3-cssbase h4,.yui3-cssbase h5,.yui3-cssbase h6,.yui3-cssbase strong{font-weight:bold;}.yui3-cssbase abbr,.yui3-cssbase acronym{border-bottom:1px dotted #000;cursor:help;}.yui3-cssbase em{font-style:italic;}.yui3-cssbase blockquote,.yui3-cssbase ul,.yui3-cssbase ol,.yui3-cssbase dl{margin:1em;}.yui3-cssbase ol,.yui3-cssbase ul,.yui3-cssbase dl{margin-left:2em;}.yui3-cssbase ol li{list-style:decimal outside;}.yui3-cssbase ul li{list-style:disc outside;}.yui3-cssbase dl dd{margin-left:1em;}.yui3-cssbase th,.yui3-cssbase td{border:1px solid #000;padding:.5em;}.yui3-cssbase th{font-weight:bold;text-align:center;}.yui3-cssbase caption{margin-bottom:.5em;text-align:center;}.yui3-cssbase p,.yui3-cssbase fieldset,.yui3-cssbase table,.yui3-cssbase pre{margin-bottom:1em;}.yui3-cssbase input[type=text],.yui3-cssbase input[type=password],.yui3-cssbase textarea{width:12.25em;*width:11.9em;}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
h1{font-size:138.5%;}h2{font-size:123.1%;}h3{font-size:108%;}h1,h2,h3{margin:1em 0;}h1,h2,h3,h4,h5,h6,strong{font-weight:bold;}abbr,acronym{border-bottom:1px dotted #000;cursor:help;}em{font-style:italic;}blockquote,ul,ol,dl{margin:1em;}ol,ul,dl{margin-left:2em;}ol li{list-style:decimal outside;}ul li{list-style:disc outside;}dl dd{margin-left:1em;}th,td{border:1px solid #000;padding:.5em;}th{font-weight:bold;text-align:center;}caption{margin-bottom:.5em;text-align:center;}p,fieldset,table,pre{margin-bottom:1em;}input[type=text],input[type=password],textarea{width:12.25em;*width:11.9em;}
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-cssfonts body,.yui3-cssfonts{font:13px/1.231 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}.yui3-cssfonts select,.yui3-cssfonts input,.yui3-cssfonts button,.yui3-cssfonts textarea{font:99% arial,helvetica,clean,sans-serif;}.yui3-cssfonts table{font-size:inherit;font:100%;}.yui3-cssfonts pre,.yui3-cssfonts code,.yui3-cssfonts kbd,.yui3-cssfonts samp,.yui3-cssfonts tt{font-family:monospace;*font-size:108%;line-height:100%;}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
body{font:13px/1.231 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}select,input,button,textarea{font:99% arial,helvetica,clean,sans-serif;}table{font-size:inherit;font:100%;}pre,code,kbd,samp,tt{font-family:monospace;*font-size:108%;line-height:100%;}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,481 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* The YUI CSS Foundation uses the *property and _property CSS filter
|
||||
* techniques to shield a value from A-grade browsers [1] other than
|
||||
* IE6 & IE7 (*property) and IE6 (_property)
|
||||
*
|
||||
/
|
||||
Section: General Rules
|
||||
*/
|
||||
body {
|
||||
/* center the page */
|
||||
text-align: center;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
/*
|
||||
Section: Page Width Rules (#doc, #doc2, #doc3, #doc4)
|
||||
*/
|
||||
/*
|
||||
Subsection: General
|
||||
*/
|
||||
.yui3-d0, /* 100% */
|
||||
.yui3-d1, /* 750px */
|
||||
.yui3-d1f, /* 750px fixed */
|
||||
.yui3-d2, /* 950px */
|
||||
.yui3-d2f, /* 950px fixed */
|
||||
.yui3-d3, /* 974px */
|
||||
.yui3-d3f { /* 974px fixed */
|
||||
margin: auto;
|
||||
text-align: left;
|
||||
width: 57.69em;
|
||||
*width: 56.25em; /* doc1*/
|
||||
}
|
||||
|
||||
.yui3-t1,
|
||||
.yui3-t2,
|
||||
.yui3-t3,
|
||||
.yui3-t4,
|
||||
.yui3-t5,
|
||||
.yui3-t6 {
|
||||
margin: auto;
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/*
|
||||
Subsection: 100% (doc)
|
||||
*/
|
||||
.yui3-d0 {
|
||||
/* Left and Right margins are not a structural part of Grids. Without them Grids
|
||||
works fine, but content bleeds to the very edge of the document, which often
|
||||
impairs readability and usability. They are
|
||||
provided because they prevent the content from "bleeding" into the browser's chrome.*/
|
||||
margin: auto 10px;
|
||||
width: auto;
|
||||
}
|
||||
.yui3-d0f {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/*
|
||||
Subsection: 950 Centered (doc2)
|
||||
*/
|
||||
.yui3-d2 {
|
||||
width: 73.076em;
|
||||
*width: 71.25em;
|
||||
}
|
||||
.yui3-d2f {
|
||||
width: 950px;
|
||||
}
|
||||
/*
|
||||
Subsection: 974 Centered (doc3)
|
||||
*/
|
||||
.yui3-d3 {
|
||||
width: 74.923em;
|
||||
*width: 73.05em;
|
||||
}
|
||||
.yui3-d3f {
|
||||
width: 974px;
|
||||
}
|
||||
/*
|
||||
Section: Preset Template Rules (.yui3-t[1-6])
|
||||
*/
|
||||
/*
|
||||
Subsection: General
|
||||
*/
|
||||
|
||||
/* to preserve source-order independence for Gecko without breaking IE */
|
||||
.yui3-b {
|
||||
position: relative;
|
||||
}
|
||||
.yui3-b {
|
||||
_position: static;
|
||||
}
|
||||
.yui3-main .yui3-b {
|
||||
position: static;
|
||||
}
|
||||
.yui3-main {
|
||||
width: 100%;
|
||||
}
|
||||
.yui3-t1 .yui3-main,
|
||||
.yui3-t2 .yui3-main,
|
||||
.yui3-t3 .yui3-main {
|
||||
float: right;
|
||||
/* IE: preserve layout at narrow widths */
|
||||
margin-left: -25em;
|
||||
}
|
||||
.yui3-t4 .yui3-main,
|
||||
.yui3-t5 .yui3-main,
|
||||
.yui3-t6 .yui3-main {
|
||||
float: left;
|
||||
/* IE: preserve layout at narrow widths */
|
||||
margin-right: -25em;
|
||||
}
|
||||
|
||||
/* Subsection: For Specific Template Presets */
|
||||
|
||||
/**
|
||||
* Nudge down to get to 13px equivalent for these form elements
|
||||
*/
|
||||
|
||||
/*
|
||||
TODO Create t1-6's that are based on fixed widths
|
||||
*/
|
||||
/* t1 narrow block = left, equivalent of 160px */
|
||||
.yui3-t1 .yui3-b {
|
||||
float: left;
|
||||
width: 12.30769em;
|
||||
*width: 12.00em;
|
||||
}
|
||||
.yui3-t1 .yui3-main .yui3-b {
|
||||
margin-left: 13.30769em;
|
||||
*margin-left:12.975em;
|
||||
}
|
||||
/* t2 narrow block = left, equivalent of 180px */
|
||||
.yui3-t2 .yui3-b {
|
||||
float: left;
|
||||
width: 13.84615em;
|
||||
*width: 13.50em;
|
||||
}
|
||||
.yui3-t2 .yui3-main .yui3-b {
|
||||
margin-left: 14.84615em;
|
||||
*margin-left: 14.475em;
|
||||
}
|
||||
/* t3 narrow block = left, equivalent of 300px */
|
||||
.yui3-t3 .yui3-b {
|
||||
float: left;
|
||||
width: 23.0769em;
|
||||
*width: 22.50em;
|
||||
}
|
||||
.yui3-t3 .yui3-main .yui3-b {
|
||||
margin-left: 24.0769em;
|
||||
*margin-left: 23.475em;
|
||||
}
|
||||
/* t4 narrow block = right, equivalent of 180px */
|
||||
.yui3-t4 .yui3-b {
|
||||
float: right;
|
||||
width: 13.8456em;
|
||||
*width: 13.50em;
|
||||
}
|
||||
.yui3-t4 .yui3-main .yui3-b {
|
||||
margin-right: 14.8456em;
|
||||
*margin-right: 14.475em;
|
||||
}
|
||||
/* t5 narrow block = right, equivalent of 240px */
|
||||
.yui3-t5 .yui3-b {
|
||||
float: right;
|
||||
width: 18.4615em;
|
||||
*width: 18.00em;
|
||||
}
|
||||
.yui3-t5 .yui3-main .yui3-b {
|
||||
margin-right: 19.4615em;
|
||||
*margin-right: 18.975em;
|
||||
}
|
||||
/* t6 narrow block = equivalent of 300px */
|
||||
.yui3-t6 .yui3-b {
|
||||
float: right;
|
||||
width: 23.0769em;
|
||||
*width: 22.50em;
|
||||
}
|
||||
.yui3-t6 .yui3-main .yui3-b {
|
||||
margin-right: 24.0769em;
|
||||
*margin-right: 23.475em;
|
||||
}
|
||||
|
||||
.yui3-main .yui3-b {
|
||||
float: none;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
/*
|
||||
Section: Grids and Nesting Grids
|
||||
*/
|
||||
|
||||
/*
|
||||
Subsection: Children generally take half the available space
|
||||
*/
|
||||
|
||||
.yui3-gb .yui3-u,
|
||||
.yui3-g .yui3-gb .yui3-u,
|
||||
.yui3-gb .yui3-g,
|
||||
.yui3-gb .yui3-gb,
|
||||
.yui3-gb .yui3-gc,
|
||||
.yui3-gb .yui3-gd,
|
||||
.yui3-gb .yui3-ge,
|
||||
.yui3-gb .yui3-gf,
|
||||
.yui3-gc .yui3-u,
|
||||
.yui3-gc .yui3-g,
|
||||
.yui3-gd .yui3-u {
|
||||
float: left;
|
||||
}
|
||||
|
||||
/*Float units (and sub grids) to the right */
|
||||
.yui3-g .yui3-u,
|
||||
.yui3-g .yui3-g,
|
||||
.yui3-g .yui3-gb,
|
||||
.yui3-g .yui3-gc,
|
||||
.yui3-g .yui3-gd,
|
||||
.yui3-g .yui3-ge,
|
||||
.yui3-g .yui3-gf,
|
||||
.yui3-gc .yui3-u,
|
||||
.yui3-gd .yui3-g,
|
||||
.yui3-g .yui3-gc .yui3-u,
|
||||
.yui3-ge .yui3-u,
|
||||
.yui3-ge .yui3-g,
|
||||
.yui3-gf .yui3-g,
|
||||
.yui3-gf .yui3-u {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/*Float units (and sub grids) to the left */
|
||||
.yui3-g div.first,
|
||||
.yui3-gb div.first,
|
||||
.yui3-gc div.first,
|
||||
.yui3-gd div.first,
|
||||
.yui3-ge div.first,
|
||||
.yui3-gf div.first,
|
||||
.yui3-g .yui3-gc div.first,
|
||||
.yui3-g .yui3-ge div.first,
|
||||
.yui3-gc div.first div.first {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.yui3-g .yui3-u,
|
||||
.yui3-g .yui3-g,
|
||||
.yui3-g .yui3-gb,
|
||||
.yui3-g .yui3-gc,
|
||||
.yui3-g .yui3-gd,
|
||||
.yui3-g .yui3-ge,
|
||||
.yui3-g .yui3-gf {
|
||||
width: 49.1%;
|
||||
}
|
||||
|
||||
.yui3-gb .yui3-u,
|
||||
.yui3-g .yui3-gb .yui3-u,
|
||||
.yui3-gb .yui3-g,
|
||||
.yui3-gb .yui3-gb,
|
||||
.yui3-gb .yui3-gc,
|
||||
.yui3-gb .yui3-gd,
|
||||
.yui3-gb .yui3-ge,
|
||||
.yui3-gb .yui3-gf,
|
||||
.yui3-gc .yui3-u,
|
||||
.yui3-gc .yui3-g,
|
||||
.yui3-gd .yui3-u {
|
||||
width: 32%;
|
||||
margin-left: 2.0%;
|
||||
}
|
||||
|
||||
/* Give IE some extra breathing room for 1/3-based rounding issues */
|
||||
.yui3-gb .yui3-u {
|
||||
*width: 31.8%;
|
||||
*margin-left: 1.9%;
|
||||
}
|
||||
|
||||
.yui3-gc div.first,
|
||||
.yui3-gd .yui3-u {
|
||||
width: 66%;
|
||||
_width: 65.7%;
|
||||
}
|
||||
.yui3-gd div.first {
|
||||
width: 32%;
|
||||
_width: 31.5%;
|
||||
}
|
||||
|
||||
.yui3-ge div.first,
|
||||
.yui3-gf .yui3-u {
|
||||
width: 74.2%;
|
||||
_width: 74%;
|
||||
}
|
||||
|
||||
.yui3-ge .yui3-u,
|
||||
.yui3-gf div.first {
|
||||
width: 24%;
|
||||
_width: 23.8%;
|
||||
}
|
||||
|
||||
.yui3-g .yui3-gb div.first,
|
||||
.yui3-gb div.first,
|
||||
.yui3-gc div.first,
|
||||
.yui3-gd div.first {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Section: Deep Nesting
|
||||
*/
|
||||
.yui3-g .yui3-g .yui3-u,
|
||||
.yui3-gb .yui3-g .yui3-u,
|
||||
.yui3-gc .yui3-g .yui3-u,
|
||||
.yui3-gd .yui3-g .yui3-u,
|
||||
.yui3-ge .yui3-g .yui3-u,
|
||||
.yui3-gf .yui3-g .yui3-u {
|
||||
width: 49%;
|
||||
*width: 48.1%;
|
||||
*margin-left: 0;
|
||||
}
|
||||
|
||||
.yui3-g .yui3-gb div.first,
|
||||
.yui3-gb .yui3-gb div.first {
|
||||
*margin-right: 0;
|
||||
*width: 32%;
|
||||
_width: 31.7%;
|
||||
}
|
||||
|
||||
.yui3-g .yui3-gc div.first,
|
||||
.yui3-gd .yui3-g {
|
||||
width: 66%;
|
||||
}
|
||||
|
||||
.yui3-gb .yui3-g div.first {
|
||||
*margin-right: 4%;
|
||||
_margin-right: 1.3%;
|
||||
}
|
||||
|
||||
.yui3-gb .yui3-gc div.first,
|
||||
.yui3-gb .yui3-gd div.first {
|
||||
*margin-right: 0;
|
||||
}
|
||||
|
||||
.yui3-gb .yui3-gb .yui3-u,
|
||||
.yui3-gb .yui3-gc .yui3-u {
|
||||
*margin-left: 1.8%;
|
||||
_margin-left: 4%;
|
||||
}
|
||||
|
||||
.yui3-g .yui3-gb .yui3-u {
|
||||
_margin-left: 1.0%;
|
||||
}
|
||||
|
||||
.yui3-gb .yui3-gd .yui3-u {
|
||||
*width: 66%;
|
||||
_width: 61.2%;
|
||||
}
|
||||
.yui3-gb .yui3-gd div.first {
|
||||
*width: 31%;
|
||||
_width: 29.5%;
|
||||
}
|
||||
|
||||
.yui3-g .yui3-gc .yui3-u,
|
||||
.yui3-gb .yui3-gc .yui3-u {
|
||||
width: 32%;
|
||||
_float: right;
|
||||
margin-right: 0;
|
||||
_margin-left: 0;
|
||||
}
|
||||
.yui3-gb .yui3-gc div.first {
|
||||
width: 66%;
|
||||
*float: left;
|
||||
*margin-left: 0;
|
||||
}
|
||||
|
||||
.yui3-gb .yui3-ge .yui3-u,
|
||||
.yui3-gb .yui3-gf .yui3-u {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.yui3-gb .yui3-gb .yui3-u {
|
||||
_margin-left: .7%;
|
||||
}
|
||||
|
||||
.yui3-gb .yui3-g div.first,
|
||||
.yui3-gb .yui3-gb div.first {
|
||||
*margin-left:0;
|
||||
}
|
||||
|
||||
.yui3-gc .yui3-g .yui3-u,
|
||||
.yui3-gd .yui3-g .yui3-u {
|
||||
*width: 48.1%;
|
||||
*margin-left: 0;
|
||||
}
|
||||
|
||||
.yui3-gb .yui3-gd div.first {
|
||||
width: 32%;
|
||||
}
|
||||
.yui3-g .yui3-gd div.first {
|
||||
_width: 29.9%;
|
||||
}
|
||||
|
||||
.yui3-ge .yui3-g {
|
||||
width: 24%;
|
||||
}
|
||||
.yui3-gf .yui3-g {
|
||||
width: 74.2%;
|
||||
}
|
||||
|
||||
.yui3-gb .yui3-ge div.yui3-u,
|
||||
.yui3-gb .yui3-gf div.yui3-u {
|
||||
float: right;
|
||||
}
|
||||
.yui3-gb .yui3-ge div.first,
|
||||
.yui3-gb .yui3-gf div.first {
|
||||
float: left;
|
||||
}
|
||||
|
||||
/* Width Accommodation for Nested Contexts */
|
||||
.yui3-gb .yui3-ge .yui3-u,
|
||||
.yui3-gb .yui3-gf div.first {
|
||||
*width: 24%;
|
||||
_width: 20%;
|
||||
}
|
||||
|
||||
/* Width Accommodation for Nested Contexts */
|
||||
.yui3-gb .yui3-ge div.first,
|
||||
.yui3-gb .yui3-gf .yui3-u {
|
||||
*width: 73.5%;
|
||||
_width: 65.5%;
|
||||
}
|
||||
|
||||
/* Patch for GD within GE */
|
||||
.yui3-ge div.first .yui3-gd .yui3-u {
|
||||
width: 65%;
|
||||
}
|
||||
.yui3-ge div.first .yui3-gd div.first {
|
||||
width: 32%;
|
||||
}
|
||||
|
||||
/*
|
||||
Section: Clearing. zoom for IE, :after for others
|
||||
*/
|
||||
|
||||
#bd:after,
|
||||
.yui3-g:after,
|
||||
.yui3-gb:after,
|
||||
.yui3-gc:after,
|
||||
.yui3-gd:after,
|
||||
.yui3-ge:after,
|
||||
.yui3-gf:after,
|
||||
.yui3-t1:after,
|
||||
.yui3-t2:after,
|
||||
.yui3-t3:after,
|
||||
.yui3-t4:after,
|
||||
.yui3-t5:after,
|
||||
.yui3-t6:after {
|
||||
content: ".";
|
||||
display: block;
|
||||
height: 0;
|
||||
clear: both;
|
||||
visibility: hidden;
|
||||
}
|
||||
#bd,
|
||||
.yui3-g,
|
||||
.yui3-gb,
|
||||
.yui3-gc,
|
||||
.yui3-gd,
|
||||
.yui3-ge,
|
||||
.yui3-gf,
|
||||
.yui3-t1,
|
||||
.yui3-t2,
|
||||
.yui3-t3,
|
||||
.yui3-t4,
|
||||
.yui3-t5,
|
||||
.yui3-t6 {
|
||||
zoom: 1;
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-g{letter-spacing:-0.31em;*letter-spacing:normal;word-spacing:-0.43em;}.yui3-u,.yui3-u-1,.yui3-u-1-2,.yui3-u-1-3,.yui3-u-2-3,.yui3-u-1-4,.yui3-u-3-4,.yui3-u-1-5,.yui3-u-2-5,.yui3-u-3-5,.yui3-u-4-5,.yui3-u-1-6,.yui3-u-5-6,.yui3-u-1-8,.yui3-u-3-8,.yui3-u-5-8,.yui3-u-7-8,.yui3-u-1-12,.yui3-u-5-12,.yui3-u-7-12,.yui3-u-11-12,.yui3-u-1-24,.yui3-u-5-24,.yui3-u-7-24,.yui3-u-11-24,.yui3-u-13-24,.yui3-u-17-24,.yui3-u-19-24,.yui3-u-23-24{display:inline-block;zoom:1;*display:inline;letter-spacing:normal;word-spacing:normal;vertical-align:top;}.yui3-u-1{display:block;}.yui3-u-1-2{width:50%;}.yui3-u-1-3{width:33.33333%;}.yui3-u-2-3{width:66.66666%;}.yui3-u-1-4{width:25%;}.yui3-u-3-4{width:75%;}.yui3-u-1-5{width:20%;}.yui3-u-2-5{width:40%;}.yui3-u-3-5{width:60%;}.yui3-u-4-5{width:80%;}.yui3-u-1-6{width:16.656%;}.yui3-u-5-6{width:83.33%;}.yui3-u-1-8{width:12.5%;}.yui3-u-3-8{width:37.5%;}.yui3-u-5-8{width:62.5%;}.yui3-u-7-8{width:87.5%;}.yui3-u-1-12{width:8.3333%;}.yui3-u-5-12{width:41.6666%;}.yui3-u-7-12{width:58.3333%;}.yui3-u-11-12{width:91.6666%;}.yui3-u-1-24{width:4.1666%;}.yui3-u-5-24{width:20.8333%;}.yui3-u-7-24{width:29.1666%;}.yui3-u-11-24{width:45.8333%;}.yui3-u-13-24{width:54.1666%;}.yui3-u-17-24{width:70.8333%;}.yui3-u-19-24{width:79.1666%;}.yui3-u-23-24{width:95.8333%;}
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
.yui3-cssreset html{color:#000;background:#FFF;}.yui3-cssreset body,.yui3-cssreset div,.yui3-cssreset dl,.yui3-cssreset dt,.yui3-cssreset dd,.yui3-cssreset ul,.yui3-cssreset ol,.yui3-cssreset li,.yui3-cssreset h1,.yui3-cssreset h2,.yui3-cssreset h3,.yui3-cssreset h4,.yui3-cssreset h5,.yui3-cssreset h6,.yui3-cssreset pre,.yui3-cssreset code,.yui3-cssreset form,.yui3-cssreset fieldset,.yui3-cssreset legend,.yui3-cssreset input,.yui3-cssreset textarea,.yui3-cssreset p,.yui3-cssreset blockquote,.yui3-cssreset th,.yui3-cssreset td{margin:0;padding:0;}.yui3-cssreset table{border-collapse:collapse;border-spacing:0;}.yui3-cssreset fieldset,.yui3-cssreset img{border:0;}.yui3-cssreset address,.yui3-cssreset caption,.yui3-cssreset cite,.yui3-cssreset code,.yui3-cssreset dfn,.yui3-cssreset em,.yui3-cssreset strong,.yui3-cssreset th,.yui3-cssreset var{font-style:normal;font-weight:normal;}.yui3-cssreset li{list-style:none;}.yui3-cssreset caption,.yui3-cssreset th{text-align:left;}.yui3-cssreset h1,.yui3-cssreset h2,.yui3-cssreset h3,.yui3-cssreset h4,.yui3-cssreset h5,.yui3-cssreset h6{font-size:100%;font-weight:normal;}.yui3-cssreset q:before,.yui3-cssreset q:after{content:'';}.yui3-cssreset abbr,.yui3-cssreset acronym{border:0;font-variant:normal;}.yui3-cssreset sup{vertical-align:text-top;}.yui3-cssreset sub{vertical-align:text-bottom;}.yui3-cssreset input,.yui3-cssreset textarea,.yui3-cssreset select{font-family:inherit;font-size:inherit;font-weight:inherit;}.yui3-cssreset input,.yui3-cssreset textarea,.yui3-cssreset select{*font-size:100%;}.yui3-cssreset legend{color:#000;}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;}
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('dataschema-array', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with data stored in arrays.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-array
|
||||
*/
|
||||
|
||||
/**
|
||||
* Array subclass for the DataSchema Utility.
|
||||
* @class DataSchema.Array
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaArray = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.Array static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given Array data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} Array data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(LANG.isArray(data_in)) {
|
||||
if(LANG.isArray(schema.resultFields)) {
|
||||
// Parse results data
|
||||
data_out = SchemaArray._parseResults.call(this, schema.resultFields, data_in, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.results = data_in;
|
||||
Y.log("Schema resultFields property not found: " + Y.dump(schema), "warn", "dataschema-array");
|
||||
}
|
||||
}
|
||||
else {
|
||||
Y.log("Array data could not be schema-parsed: " + Y.dump(data) + " " + Y.dump(data), "error", "dataschema-array");
|
||||
data_out.error = new Error("Array schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param fields {Array} Schema to parse against.
|
||||
* @param array_in {Array} Array to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(fields, array_in, data_out) {
|
||||
var results = [],
|
||||
result, item, type, field, key, value, i, j;
|
||||
|
||||
for(i=array_in.length-1; i>-1; i--) {
|
||||
result = {};
|
||||
item = array_in[i];
|
||||
type = (LANG.isObject(item) && !LANG.isFunction(item)) ? 2 : (LANG.isArray(item)) ? 1 : (LANG.isString(item)) ? 0 : -1;
|
||||
if(type > 0) {
|
||||
for(j=fields.length-1; j>-1; j--) {
|
||||
field = fields[j];
|
||||
key = (!LANG.isUndefined(field.key)) ? field.key : field;
|
||||
value = (!LANG.isUndefined(item[key])) ? item[key] : item[j];
|
||||
result[key] = Y.DataSchema.Base.parse.call(this, value, field);
|
||||
}
|
||||
}
|
||||
else if(type === 0) {
|
||||
result = item;
|
||||
}
|
||||
else {
|
||||
//TODO: null or {}?
|
||||
result = null;
|
||||
Y.log("Unexpected type while parsing array: " + Y.dump(item), "warn", "dataschema-array");
|
||||
}
|
||||
results[i] = result;
|
||||
}
|
||||
data_out.results = results;
|
||||
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.Array = Y.mix(SchemaArray, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['dataschema-base']});
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("dataschema-array",function(C){var A=C.Lang,B={apply:function(F,G){var D=G,E={results:[],meta:{}};if(A.isArray(D)){if(A.isArray(F.resultFields)){E=B._parseResults.call(this,F.resultFields,D,E);}else{E.results=D;}}else{E.error=new Error("Array schema parse failure");}return E;},_parseResults:function(H,K,D){var G=[],O,N,I,J,M,L,F,E;for(F=K.length-1;F>-1;F--){O={};N=K[F];I=(A.isObject(N)&&!A.isFunction(N))?2:(A.isArray(N))?1:(A.isString(N))?0:-1;if(I>0){for(E=H.length-1;E>-1;E--){J=H[E];M=(!A.isUndefined(J.key))?J.key:J;L=(!A.isUndefined(N[M]))?N[M]:N[E];O[M]=C.DataSchema.Base.parse.call(this,L,J);}}else{if(I===0){O=N;}else{O=null;}}G[F]=O;}D.results=G;return D;}};C.DataSchema.Array=C.mix(B,C.DataSchema.Base);},"3.2.0",{requires:["dataschema-base"]});
|
||||
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('dataschema-array', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with data stored in arrays.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-array
|
||||
*/
|
||||
|
||||
/**
|
||||
* Array subclass for the DataSchema Utility.
|
||||
* @class DataSchema.Array
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaArray = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.Array static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given Array data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} Array data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(LANG.isArray(data_in)) {
|
||||
if(LANG.isArray(schema.resultFields)) {
|
||||
// Parse results data
|
||||
data_out = SchemaArray._parseResults.call(this, schema.resultFields, data_in, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.results = data_in;
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("Array schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param fields {Array} Schema to parse against.
|
||||
* @param array_in {Array} Array to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(fields, array_in, data_out) {
|
||||
var results = [],
|
||||
result, item, type, field, key, value, i, j;
|
||||
|
||||
for(i=array_in.length-1; i>-1; i--) {
|
||||
result = {};
|
||||
item = array_in[i];
|
||||
type = (LANG.isObject(item) && !LANG.isFunction(item)) ? 2 : (LANG.isArray(item)) ? 1 : (LANG.isString(item)) ? 0 : -1;
|
||||
if(type > 0) {
|
||||
for(j=fields.length-1; j>-1; j--) {
|
||||
field = fields[j];
|
||||
key = (!LANG.isUndefined(field.key)) ? field.key : field;
|
||||
value = (!LANG.isUndefined(item[key])) ? item[key] : item[j];
|
||||
result[key] = Y.DataSchema.Base.parse.call(this, value, field);
|
||||
}
|
||||
}
|
||||
else if(type === 0) {
|
||||
result = item;
|
||||
}
|
||||
else {
|
||||
//TODO: null or {}?
|
||||
result = null;
|
||||
}
|
||||
results[i] = result;
|
||||
}
|
||||
data_out.results = results;
|
||||
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.Array = Y.mix(SchemaArray, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['dataschema-base']});
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("dataschema-base",function(B){var A=B.Lang,C={apply:function(D,E){return E;},parse:function(D,E){if(E.parser){var F=(A.isFunction(E.parser))?E.parser:B.Parsers[E.parser+""];if(F){D=F.call(this,D);}else{}}return D;}};B.namespace("DataSchema").Base=C;B.namespace("Parsers");},"3.2.0",{requires:["base"]});
|
||||
@@ -1,887 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('dataschema-base', function(Y) {
|
||||
|
||||
/**
|
||||
* The DataSchema utility provides a common configurable interface for widgets to
|
||||
* apply a given schema to a variety of data.
|
||||
*
|
||||
* @module dataschema
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides the base DataSchema implementation, which can be extended to
|
||||
* create DataSchemas for specific data formats, such XML, JSON, text and
|
||||
* arrays.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-base
|
||||
*/
|
||||
|
||||
var LANG = Y.Lang,
|
||||
/**
|
||||
* Base class for the YUI DataSchema Utility.
|
||||
* @class DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
SchemaBase = {
|
||||
/**
|
||||
* Overridable method returns data as-is.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} Data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies field parser, if defined
|
||||
*
|
||||
* @method parse
|
||||
* @param value {Object} Original value.
|
||||
* @param field {Object} Field.
|
||||
* @return {Object} Type-converted value.
|
||||
*/
|
||||
parse: function(value, field) {
|
||||
if(field.parser) {
|
||||
var parser = (LANG.isFunction(field.parser)) ?
|
||||
field.parser : Y.Parsers[field.parser+''];
|
||||
if(parser) {
|
||||
value = parser.call(this, value);
|
||||
}
|
||||
else {
|
||||
Y.log("Could not find parser for field " + Y.dump(field), "warn", "dataschema-json");
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
Y.namespace("DataSchema").Base = SchemaBase;
|
||||
Y.namespace("Parsers");
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['base']});
|
||||
|
||||
YUI.add('dataschema-json', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with JSON data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-json
|
||||
*/
|
||||
|
||||
/**
|
||||
* JSON subclass for the DataSchema Utility.
|
||||
* @class DataSchema.JSON
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaJSON = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.JSON static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Utility function converts JSON locator strings into walkable paths
|
||||
*
|
||||
* @method DataSchema.JSON.getPath
|
||||
* @param locator {String} JSON value locator.
|
||||
* @return {String[]} Walkable path to data value.
|
||||
* @static
|
||||
*/
|
||||
getPath: function(locator) {
|
||||
var path = null,
|
||||
keys = [],
|
||||
i = 0;
|
||||
|
||||
if (locator) {
|
||||
// Strip the ["string keys"] and [1] array indexes
|
||||
locator = locator.
|
||||
replace(/\[(['"])(.*?)\1\]/g,
|
||||
function (x,$1,$2) {keys[i]=$2;return '.@'+(i++);}).
|
||||
replace(/\[(\d+)\]/g,
|
||||
function (x,$1) {keys[i]=parseInt($1,10)|0;return '.@'+(i++);}).
|
||||
replace(/^\./,''); // remove leading dot
|
||||
|
||||
// Validate against problematic characters.
|
||||
if (!/[^\w\.\$@]/.test(locator)) {
|
||||
path = locator.split('.');
|
||||
for (i=path.length-1; i >= 0; --i) {
|
||||
if (path[i].charAt(0) === '@') {
|
||||
path[i] = keys[parseInt(path[i].substr(1),10)];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Y.log("Invalid locator: " + locator, "error", "dataschema-json");
|
||||
}
|
||||
}
|
||||
return path;
|
||||
},
|
||||
|
||||
/**
|
||||
* Utility function to walk a path and return the value located there.
|
||||
*
|
||||
* @method DataSchema.JSON.getLocationValue
|
||||
* @param path {String[]} Locator path.
|
||||
* @param data {String} Data to traverse.
|
||||
* @return {Object} Data value at location.
|
||||
* @static
|
||||
*/
|
||||
getLocationValue: function (path, data) {
|
||||
var i = 0,
|
||||
len = path.length;
|
||||
for (;i<len;i++) {
|
||||
if(
|
||||
LANG.isObject(data) &&
|
||||
(path[i] in data)
|
||||
) {
|
||||
data = data[path[i]];
|
||||
}
|
||||
else {
|
||||
data = undefined;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies a given schema to given JSON data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} JSON data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
// Convert incoming JSON strings
|
||||
if(!LANG.isObject(data)) {
|
||||
try {
|
||||
data_in = Y.JSON.parse(data);
|
||||
}
|
||||
catch(e) {
|
||||
data_out.error = e;
|
||||
return data_out;
|
||||
}
|
||||
}
|
||||
|
||||
if(LANG.isObject(data_in) && schema) {
|
||||
// Parse results data
|
||||
if(!LANG.isUndefined(schema.resultListLocator)) {
|
||||
data_out = SchemaJSON._parseResults.call(this, schema, data_in, data_out);
|
||||
}
|
||||
|
||||
// Parse meta data
|
||||
if(!LANG.isUndefined(schema.metaFields)) {
|
||||
data_out = SchemaJSON._parseMeta(schema.metaFields, data_in, data_out);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Y.log("JSON data could not be schema-parsed: " + Y.dump(data) + " " + Y.dump(data), "error", "dataschema-json");
|
||||
data_out.error = new Error("JSON schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Object} Schema to parse against.
|
||||
* @param json_in {Object} JSON to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, json_in, data_out) {
|
||||
var results = [],
|
||||
path,
|
||||
error;
|
||||
|
||||
if(schema.resultListLocator) {
|
||||
path = SchemaJSON.getPath(schema.resultListLocator);
|
||||
if(path) {
|
||||
results = SchemaJSON.getLocationValue(path, json_in);
|
||||
if (results === undefined) {
|
||||
data_out.results = [];
|
||||
error = new Error("JSON results retrieval failure");
|
||||
}
|
||||
else {
|
||||
if(LANG.isArray(results)) {
|
||||
// if no result fields are passed in, then just take the results array whole-hog
|
||||
// Sometimes you're getting an array of strings, or want the whole object,
|
||||
// so resultFields don't make sense.
|
||||
if (LANG.isArray(schema.resultFields)) {
|
||||
data_out = SchemaJSON._getFieldValues.call(this, schema.resultFields, results, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.results = results;
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.results = [];
|
||||
error = new Error("JSON Schema fields retrieval failure");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
error = new Error("JSON Schema results locator failure");
|
||||
}
|
||||
|
||||
if (error) {
|
||||
Y.log("JSON data could not be parsed: " + Y.dump(json_in), "error", "dataschema-json");
|
||||
data_out.error = error;
|
||||
}
|
||||
|
||||
}
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get field data values out of list of full results
|
||||
*
|
||||
* @method _getFieldValues
|
||||
* @param fields {Array} Fields to find.
|
||||
* @param array_in {Array} Results to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_getFieldValues: function(fields, array_in, data_out) {
|
||||
var results = [],
|
||||
len = fields.length,
|
||||
i, j,
|
||||
field, key, path, parser,
|
||||
simplePaths = [], complexPaths = [], fieldParsers = [],
|
||||
result, record;
|
||||
|
||||
// First collect hashes of simple paths, complex paths, and parsers
|
||||
for (i=0; i<len; i++) {
|
||||
field = fields[i]; // A field can be a simple string or a hash
|
||||
key = field.key || field; // Find the key
|
||||
|
||||
// Validate and store locators for later
|
||||
path = SchemaJSON.getPath(key);
|
||||
if (path) {
|
||||
if (path.length === 1) {
|
||||
simplePaths[simplePaths.length] = {key:key, path:path[0]};
|
||||
} else {
|
||||
complexPaths[complexPaths.length] = {key:key, path:path};
|
||||
}
|
||||
} else {
|
||||
Y.log("Invalid key syntax: " + key, "warn", "dataschema-json");
|
||||
}
|
||||
|
||||
// Validate and store parsers for later
|
||||
//TODO: use Y.DataSchema.parse?
|
||||
parser = (LANG.isFunction(field.parser)) ? field.parser : Y.Parsers[field.parser+''];
|
||||
if (parser) {
|
||||
fieldParsers[fieldParsers.length] = {key:key, parser:parser};
|
||||
}
|
||||
}
|
||||
|
||||
// Traverse list of array_in, creating records of simple fields,
|
||||
// complex fields, and applying parsers as necessary
|
||||
for (i=array_in.length-1; i>=0; --i) {
|
||||
record = {};
|
||||
result = array_in[i];
|
||||
if(result) {
|
||||
// Cycle through simpleLocators
|
||||
for (j=simplePaths.length-1; j>=0; --j) {
|
||||
// Bug 1777850: The result might be an array instead of object
|
||||
record[simplePaths[j].key] = Y.DataSchema.Base.parse.call(this,
|
||||
(LANG.isUndefined(result[simplePaths[j].path]) ?
|
||||
result[j] : result[simplePaths[j].path]), simplePaths[j]);
|
||||
}
|
||||
|
||||
// Cycle through complexLocators
|
||||
for (j=complexPaths.length - 1; j>=0; --j) {
|
||||
record[complexPaths[j].key] = Y.DataSchema.Base.parse.call(this,
|
||||
(SchemaJSON.getLocationValue(complexPaths[j].path, result)), complexPaths[j] );
|
||||
}
|
||||
|
||||
// Cycle through fieldParsers
|
||||
for (j=fieldParsers.length-1; j>=0; --j) {
|
||||
key = fieldParsers[j].key;
|
||||
record[key] = fieldParsers[j].parser.call(this, record[key]);
|
||||
// Safety net
|
||||
if (LANG.isUndefined(record[key])) {
|
||||
record[key] = null;
|
||||
}
|
||||
}
|
||||
results[i] = record;
|
||||
}
|
||||
}
|
||||
data_out.results = results;
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses results data according to schema
|
||||
*
|
||||
* @method _parseMeta
|
||||
* @param metaFields {Object} Metafields definitions.
|
||||
* @param json_in {Object} JSON to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Schema-parsed meta data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseMeta: function(metaFields, json_in, data_out) {
|
||||
if(LANG.isObject(metaFields)) {
|
||||
var key, path;
|
||||
for(key in metaFields) {
|
||||
if (metaFields.hasOwnProperty(key)) {
|
||||
path = SchemaJSON.getPath(metaFields[key]);
|
||||
if (path && json_in) {
|
||||
data_out.meta[key] = SchemaJSON.getLocationValue(path, json_in);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("JSON meta data retrieval failure");
|
||||
}
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.JSON = Y.mix(SchemaJSON, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['json', 'dataschema-base']});
|
||||
|
||||
YUI.add('dataschema-xml', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with XML data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-xml
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
/**
|
||||
* XML subclass for the DataSchema Utility.
|
||||
* @class DataSchema.XML
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
SchemaXML = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.XML static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given XML data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {XMLDoc} XML document.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var xmldoc = data, // unnecessary variables
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(xmldoc && xmldoc.nodeType && (9 === xmldoc.nodeType || 1 === xmldoc.nodeType || 11 === xmldoc.nodeType) && schema) {
|
||||
// Parse results data
|
||||
data_out = SchemaXML._parseResults.call(this, schema, xmldoc, data_out);
|
||||
|
||||
// Parse meta data
|
||||
data_out = SchemaXML._parseMeta.call(this, schema.metaFields, xmldoc, data_out);
|
||||
}
|
||||
else {
|
||||
Y.log("XML data could not be schema-parsed: " + Y.dump(data) + " " + Y.dump(data), "error", "dataschema-xml");
|
||||
data_out.error = new Error("XML schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get an XPath-specified value for a given field from an XML node or document.
|
||||
*
|
||||
* @method _getLocationValue
|
||||
* @param field {String | Object} Field definition.
|
||||
* @param context {Object} XML node or document to search within.
|
||||
* @return {Object} Data value or null.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_getLocationValue: function(field, context) {
|
||||
var locator = field.locator || field.key || field,
|
||||
xmldoc = context.ownerDocument || context,
|
||||
result, res, value = null;
|
||||
|
||||
try {
|
||||
result = SchemaXML._getXPathResult(locator, context, xmldoc);
|
||||
while(res = result.iterateNext()) {
|
||||
value = res.textContent || res.value || res.text || res.innerHTML || null;
|
||||
}
|
||||
|
||||
return Y.DataSchema.Base.parse.call(this, value, field);
|
||||
}
|
||||
catch(e) {
|
||||
Y.log('SchemaXML._getLocationValue failed: ' + e.message);
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Fetches the XPath-specified result for a given location in an XML node or document.
|
||||
*
|
||||
* @param locator {String} The XPath location.
|
||||
* @param context {Object} XML node or document to search within.
|
||||
* @param xmldoc {Object} XML document to resolve namespace.
|
||||
* @return {Object} Data collection or null.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_getXPathResult: function(locator, context, xmldoc) {
|
||||
// Standards mode
|
||||
if (! LANG.isUndefined(xmldoc.evaluate)) {
|
||||
return xmldoc.evaluate(locator, context, xmldoc.createNSResolver(context.ownerDocument ? context.ownerDocument.documentElement : context.documentElement), 0, null);
|
||||
}
|
||||
// IE mode
|
||||
else {
|
||||
var values=[], locatorArray = locator.split(/\b\/\b/), i=0, l=locatorArray.length, location, subloc, m, isNth;
|
||||
|
||||
// XPath is supported
|
||||
try {
|
||||
// this fixes the IE 5.5+ issue where childnode selectors begin at 0 instead of 1
|
||||
xmldoc.setProperty("SelectionLanguage", "XPath");
|
||||
values = context.selectNodes(locator);
|
||||
}
|
||||
// Fallback for DOM nodes and fragments
|
||||
catch (e) {
|
||||
// Iterate over each locator piece
|
||||
for (; i<l && context; i++) {
|
||||
location = locatorArray[i];
|
||||
|
||||
// grab nth child []
|
||||
if ((location.indexOf("[") > -1) && (location.indexOf("]") > -1)) {
|
||||
subloc = location.slice(location.indexOf("[")+1, location.indexOf("]"));
|
||||
//XPath is 1-based while DOM is 0-based
|
||||
subloc--;
|
||||
context = context.childNodes[subloc];
|
||||
isNth = true;
|
||||
}
|
||||
// grab attribute value @
|
||||
else if (location.indexOf("@") > -1) {
|
||||
subloc = location.substr(location.indexOf("@"));
|
||||
context = subloc ? context.getAttribute(subloc.replace('@', '')) : context;
|
||||
}
|
||||
// grab that last instance of tagName
|
||||
else if (-1 < location.indexOf("//")) {
|
||||
subloc = context.getElementsByTagName(location.substr(2));
|
||||
context = subloc.length ? subloc[subloc.length - 1] : null;
|
||||
}
|
||||
// find the last matching location in children
|
||||
else if (l != i + 1) {
|
||||
for (m=context.childNodes.length-1; 0 <= m; m-=1) {
|
||||
if (location === context.childNodes[m].tagName) {
|
||||
context = context.childNodes[m];
|
||||
m = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (context) {
|
||||
// attribute
|
||||
if (LANG.isString(context)) {
|
||||
values[0] = {value: context};
|
||||
}
|
||||
// nth child
|
||||
else if (isNth) {
|
||||
values[0] = {value: context.innerHTML};
|
||||
}
|
||||
// all children
|
||||
else {
|
||||
values = Y.Array(context.childNodes, 0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// returning a mock-standard object for IE
|
||||
return {
|
||||
index: 0,
|
||||
|
||||
iterateNext: function() {
|
||||
if (this.index >= this.values.length) {return undefined;}
|
||||
var result = this.values[this.index];
|
||||
this.index += 1;
|
||||
return result;
|
||||
},
|
||||
|
||||
values: values
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed result field.
|
||||
*
|
||||
* @method _parseField
|
||||
* @param field {String | Object} Required. Field definition.
|
||||
* @param result {Object} Required. Schema parsed data object.
|
||||
* @param context {Object} Required. XML node or document to search within.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseField: function(field, result, context) {
|
||||
if (field.schema) {
|
||||
result[field.key] = SchemaXML._parseResults.call(this, field.schema, context, {results:[],meta:{}}).results;
|
||||
}
|
||||
else {
|
||||
result[field.key || field] = SchemaXML._getLocationValue.call(this, field, context);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses results data according to schema
|
||||
*
|
||||
* @method _parseMeta
|
||||
* @param xmldoc_in {Object} XML document parse.
|
||||
* @param data_out {Object} In-progress schema-parsed data to update.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseMeta: function(metaFields, xmldoc_in, data_out) {
|
||||
if(LANG.isObject(metaFields)) {
|
||||
var key,
|
||||
xmldoc = xmldoc_in.ownerDocument || xmldoc_in;
|
||||
|
||||
for(key in metaFields) {
|
||||
if (metaFields.hasOwnProperty(key)) {
|
||||
data_out.meta[key] = SchemaXML._getLocationValue.call(this, metaFields[key], xmldoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed result to add to results list.
|
||||
*
|
||||
* @method _parseResult
|
||||
* @param fields {Array} Required. A collection of field definition.
|
||||
* @param context {Object} Required. XML node or document to search within.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResult: function(fields, context) {
|
||||
var result = {}, j;
|
||||
|
||||
// Find each field value
|
||||
for (j=fields.length-1; 0 <= j; j--) {
|
||||
SchemaXML._parseField.call(this, fields[j], result, context);
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Object} Schema to parse against.
|
||||
* @param context {Object} XML node document parse.
|
||||
* @param data_out {Object} In-progress schema-parsed data to update.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, context, data_out) {
|
||||
if (schema.resultListLocator && LANG.isArray(schema.resultFields)) {
|
||||
var xmldoc = context.ownerDocument || context,
|
||||
fields = schema.resultFields,
|
||||
results = [],
|
||||
node, result, nodeList, i=0;
|
||||
|
||||
if (schema.resultListLocator.match(/^[:\-\w]+$/)) {
|
||||
nodeList = context.getElementsByTagName(schema.resultListLocator);
|
||||
|
||||
// loop through each result node
|
||||
for (i=nodeList.length-1; 0 <= i; i--) {
|
||||
results[i] = SchemaXML._parseResult.call(this, fields, nodeList[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
nodeList = SchemaXML._getXPathResult(schema.resultListLocator, context, xmldoc);
|
||||
|
||||
// loop through the nodelist
|
||||
while (node = nodeList.iterateNext()) {
|
||||
results[i] = SchemaXML._parseResult.call(this, fields, node);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (results.length) {
|
||||
data_out.results = results;
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("XML schema result nodes retrieval failure");
|
||||
}
|
||||
}
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.XML = Y.mix(SchemaXML, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['dataschema-base']});
|
||||
|
||||
YUI.add('dataschema-array', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with data stored in arrays.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-array
|
||||
*/
|
||||
|
||||
/**
|
||||
* Array subclass for the DataSchema Utility.
|
||||
* @class DataSchema.Array
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaArray = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.Array static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given Array data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} Array data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(LANG.isArray(data_in)) {
|
||||
if(LANG.isArray(schema.resultFields)) {
|
||||
// Parse results data
|
||||
data_out = SchemaArray._parseResults.call(this, schema.resultFields, data_in, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.results = data_in;
|
||||
Y.log("Schema resultFields property not found: " + Y.dump(schema), "warn", "dataschema-array");
|
||||
}
|
||||
}
|
||||
else {
|
||||
Y.log("Array data could not be schema-parsed: " + Y.dump(data) + " " + Y.dump(data), "error", "dataschema-array");
|
||||
data_out.error = new Error("Array schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param fields {Array} Schema to parse against.
|
||||
* @param array_in {Array} Array to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(fields, array_in, data_out) {
|
||||
var results = [],
|
||||
result, item, type, field, key, value, i, j;
|
||||
|
||||
for(i=array_in.length-1; i>-1; i--) {
|
||||
result = {};
|
||||
item = array_in[i];
|
||||
type = (LANG.isObject(item) && !LANG.isFunction(item)) ? 2 : (LANG.isArray(item)) ? 1 : (LANG.isString(item)) ? 0 : -1;
|
||||
if(type > 0) {
|
||||
for(j=fields.length-1; j>-1; j--) {
|
||||
field = fields[j];
|
||||
key = (!LANG.isUndefined(field.key)) ? field.key : field;
|
||||
value = (!LANG.isUndefined(item[key])) ? item[key] : item[j];
|
||||
result[key] = Y.DataSchema.Base.parse.call(this, value, field);
|
||||
}
|
||||
}
|
||||
else if(type === 0) {
|
||||
result = item;
|
||||
}
|
||||
else {
|
||||
//TODO: null or {}?
|
||||
result = null;
|
||||
Y.log("Unexpected type while parsing array: " + Y.dump(item), "warn", "dataschema-array");
|
||||
}
|
||||
results[i] = result;
|
||||
}
|
||||
data_out.results = results;
|
||||
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.Array = Y.mix(SchemaArray, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['dataschema-base']});
|
||||
|
||||
YUI.add('dataschema-text', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with delimited text data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-text
|
||||
*/
|
||||
|
||||
/**
|
||||
* Text subclass for the DataSchema Utility.
|
||||
* @class DataSchema.Text
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaText = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.Text static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given delimited text data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} Text data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(LANG.isString(data_in) && LANG.isString(schema.resultDelimiter)) {
|
||||
// Parse results data
|
||||
data_out = SchemaText._parseResults.call(this, schema, data_in, data_out);
|
||||
}
|
||||
else {
|
||||
Y.log("Text data could not be schema-parsed: " + Y.dump(data) + " " + Y.dump(data), "error", "dataschema-text");
|
||||
data_out.error = new Error("Text schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Array} Schema to parse against.
|
||||
* @param text_in {String} Text to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, text_in, data_out) {
|
||||
var resultDelim = schema.resultDelimiter,
|
||||
results = [],
|
||||
results_in, fields_in, result, item, fields, field, key, value, i, j,
|
||||
|
||||
// Delete final delimiter at end of string if there
|
||||
tmpLength = text_in.length-resultDelim.length;
|
||||
if(text_in.substr(tmpLength) == resultDelim) {
|
||||
text_in = text_in.substr(0, tmpLength);
|
||||
}
|
||||
|
||||
// Split into results
|
||||
results_in = text_in.split(schema.resultDelimiter);
|
||||
|
||||
for(i=results_in.length-1; i>-1; i--) {
|
||||
result = {};
|
||||
item = results_in[i];
|
||||
|
||||
if(LANG.isString(schema.fieldDelimiter)) {
|
||||
fields_in = item.split(schema.fieldDelimiter);
|
||||
|
||||
if(LANG.isArray(schema.resultFields)) {
|
||||
fields = schema.resultFields;
|
||||
for(j=fields.length-1; j>-1; j--) {
|
||||
field = fields[j];
|
||||
key = (!LANG.isUndefined(field.key)) ? field.key : field;
|
||||
value = (!LANG.isUndefined(fields_in[key])) ? fields_in[key] : fields_in[j];
|
||||
result[key] = Y.DataSchema.Base.parse.call(this, value, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
result = item;
|
||||
}
|
||||
|
||||
results[i] = result;
|
||||
}
|
||||
data_out.results = results;
|
||||
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.Text = Y.mix(SchemaText, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['dataschema-base']});
|
||||
|
||||
|
||||
|
||||
YUI.add('dataschema', function(Y){}, '3.2.0' ,{use:['dataschema-base','dataschema-json','dataschema-xml','dataschema-array','dataschema-text']});
|
||||
|
||||
@@ -1,309 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('dataschema-json', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with JSON data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-json
|
||||
*/
|
||||
|
||||
/**
|
||||
* JSON subclass for the DataSchema Utility.
|
||||
* @class DataSchema.JSON
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaJSON = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.JSON static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Utility function converts JSON locator strings into walkable paths
|
||||
*
|
||||
* @method DataSchema.JSON.getPath
|
||||
* @param locator {String} JSON value locator.
|
||||
* @return {String[]} Walkable path to data value.
|
||||
* @static
|
||||
*/
|
||||
getPath: function(locator) {
|
||||
var path = null,
|
||||
keys = [],
|
||||
i = 0;
|
||||
|
||||
if (locator) {
|
||||
// Strip the ["string keys"] and [1] array indexes
|
||||
locator = locator.
|
||||
replace(/\[(['"])(.*?)\1\]/g,
|
||||
function (x,$1,$2) {keys[i]=$2;return '.@'+(i++);}).
|
||||
replace(/\[(\d+)\]/g,
|
||||
function (x,$1) {keys[i]=parseInt($1,10)|0;return '.@'+(i++);}).
|
||||
replace(/^\./,''); // remove leading dot
|
||||
|
||||
// Validate against problematic characters.
|
||||
if (!/[^\w\.\$@]/.test(locator)) {
|
||||
path = locator.split('.');
|
||||
for (i=path.length-1; i >= 0; --i) {
|
||||
if (path[i].charAt(0) === '@') {
|
||||
path[i] = keys[parseInt(path[i].substr(1),10)];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Y.log("Invalid locator: " + locator, "error", "dataschema-json");
|
||||
}
|
||||
}
|
||||
return path;
|
||||
},
|
||||
|
||||
/**
|
||||
* Utility function to walk a path and return the value located there.
|
||||
*
|
||||
* @method DataSchema.JSON.getLocationValue
|
||||
* @param path {String[]} Locator path.
|
||||
* @param data {String} Data to traverse.
|
||||
* @return {Object} Data value at location.
|
||||
* @static
|
||||
*/
|
||||
getLocationValue: function (path, data) {
|
||||
var i = 0,
|
||||
len = path.length;
|
||||
for (;i<len;i++) {
|
||||
if(
|
||||
LANG.isObject(data) &&
|
||||
(path[i] in data)
|
||||
) {
|
||||
data = data[path[i]];
|
||||
}
|
||||
else {
|
||||
data = undefined;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies a given schema to given JSON data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} JSON data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
// Convert incoming JSON strings
|
||||
if(!LANG.isObject(data)) {
|
||||
try {
|
||||
data_in = Y.JSON.parse(data);
|
||||
}
|
||||
catch(e) {
|
||||
data_out.error = e;
|
||||
return data_out;
|
||||
}
|
||||
}
|
||||
|
||||
if(LANG.isObject(data_in) && schema) {
|
||||
// Parse results data
|
||||
if(!LANG.isUndefined(schema.resultListLocator)) {
|
||||
data_out = SchemaJSON._parseResults.call(this, schema, data_in, data_out);
|
||||
}
|
||||
|
||||
// Parse meta data
|
||||
if(!LANG.isUndefined(schema.metaFields)) {
|
||||
data_out = SchemaJSON._parseMeta(schema.metaFields, data_in, data_out);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Y.log("JSON data could not be schema-parsed: " + Y.dump(data) + " " + Y.dump(data), "error", "dataschema-json");
|
||||
data_out.error = new Error("JSON schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Object} Schema to parse against.
|
||||
* @param json_in {Object} JSON to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, json_in, data_out) {
|
||||
var results = [],
|
||||
path,
|
||||
error;
|
||||
|
||||
if(schema.resultListLocator) {
|
||||
path = SchemaJSON.getPath(schema.resultListLocator);
|
||||
if(path) {
|
||||
results = SchemaJSON.getLocationValue(path, json_in);
|
||||
if (results === undefined) {
|
||||
data_out.results = [];
|
||||
error = new Error("JSON results retrieval failure");
|
||||
}
|
||||
else {
|
||||
if(LANG.isArray(results)) {
|
||||
// if no result fields are passed in, then just take the results array whole-hog
|
||||
// Sometimes you're getting an array of strings, or want the whole object,
|
||||
// so resultFields don't make sense.
|
||||
if (LANG.isArray(schema.resultFields)) {
|
||||
data_out = SchemaJSON._getFieldValues.call(this, schema.resultFields, results, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.results = results;
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.results = [];
|
||||
error = new Error("JSON Schema fields retrieval failure");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
error = new Error("JSON Schema results locator failure");
|
||||
}
|
||||
|
||||
if (error) {
|
||||
Y.log("JSON data could not be parsed: " + Y.dump(json_in), "error", "dataschema-json");
|
||||
data_out.error = error;
|
||||
}
|
||||
|
||||
}
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get field data values out of list of full results
|
||||
*
|
||||
* @method _getFieldValues
|
||||
* @param fields {Array} Fields to find.
|
||||
* @param array_in {Array} Results to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_getFieldValues: function(fields, array_in, data_out) {
|
||||
var results = [],
|
||||
len = fields.length,
|
||||
i, j,
|
||||
field, key, path, parser,
|
||||
simplePaths = [], complexPaths = [], fieldParsers = [],
|
||||
result, record;
|
||||
|
||||
// First collect hashes of simple paths, complex paths, and parsers
|
||||
for (i=0; i<len; i++) {
|
||||
field = fields[i]; // A field can be a simple string or a hash
|
||||
key = field.key || field; // Find the key
|
||||
|
||||
// Validate and store locators for later
|
||||
path = SchemaJSON.getPath(key);
|
||||
if (path) {
|
||||
if (path.length === 1) {
|
||||
simplePaths[simplePaths.length] = {key:key, path:path[0]};
|
||||
} else {
|
||||
complexPaths[complexPaths.length] = {key:key, path:path};
|
||||
}
|
||||
} else {
|
||||
Y.log("Invalid key syntax: " + key, "warn", "dataschema-json");
|
||||
}
|
||||
|
||||
// Validate and store parsers for later
|
||||
//TODO: use Y.DataSchema.parse?
|
||||
parser = (LANG.isFunction(field.parser)) ? field.parser : Y.Parsers[field.parser+''];
|
||||
if (parser) {
|
||||
fieldParsers[fieldParsers.length] = {key:key, parser:parser};
|
||||
}
|
||||
}
|
||||
|
||||
// Traverse list of array_in, creating records of simple fields,
|
||||
// complex fields, and applying parsers as necessary
|
||||
for (i=array_in.length-1; i>=0; --i) {
|
||||
record = {};
|
||||
result = array_in[i];
|
||||
if(result) {
|
||||
// Cycle through simpleLocators
|
||||
for (j=simplePaths.length-1; j>=0; --j) {
|
||||
// Bug 1777850: The result might be an array instead of object
|
||||
record[simplePaths[j].key] = Y.DataSchema.Base.parse.call(this,
|
||||
(LANG.isUndefined(result[simplePaths[j].path]) ?
|
||||
result[j] : result[simplePaths[j].path]), simplePaths[j]);
|
||||
}
|
||||
|
||||
// Cycle through complexLocators
|
||||
for (j=complexPaths.length - 1; j>=0; --j) {
|
||||
record[complexPaths[j].key] = Y.DataSchema.Base.parse.call(this,
|
||||
(SchemaJSON.getLocationValue(complexPaths[j].path, result)), complexPaths[j] );
|
||||
}
|
||||
|
||||
// Cycle through fieldParsers
|
||||
for (j=fieldParsers.length-1; j>=0; --j) {
|
||||
key = fieldParsers[j].key;
|
||||
record[key] = fieldParsers[j].parser.call(this, record[key]);
|
||||
// Safety net
|
||||
if (LANG.isUndefined(record[key])) {
|
||||
record[key] = null;
|
||||
}
|
||||
}
|
||||
results[i] = record;
|
||||
}
|
||||
}
|
||||
data_out.results = results;
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses results data according to schema
|
||||
*
|
||||
* @method _parseMeta
|
||||
* @param metaFields {Object} Metafields definitions.
|
||||
* @param json_in {Object} JSON to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Schema-parsed meta data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseMeta: function(metaFields, json_in, data_out) {
|
||||
if(LANG.isObject(metaFields)) {
|
||||
var key, path;
|
||||
for(key in metaFields) {
|
||||
if (metaFields.hasOwnProperty(key)) {
|
||||
path = SchemaJSON.getPath(metaFields[key]);
|
||||
if (path && json_in) {
|
||||
data_out.meta[key] = SchemaJSON.getLocationValue(path, json_in);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("JSON meta data retrieval failure");
|
||||
}
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.JSON = Y.mix(SchemaJSON, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['json', 'dataschema-base']});
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("dataschema-json",function(C){var A=C.Lang,B={getPath:function(D){var G=null,F=[],E=0;if(D){D=D.replace(/\[(['"])(.*?)\1\]/g,function(I,H,J){F[E]=J;return".@"+(E++);}).replace(/\[(\d+)\]/g,function(I,H){F[E]=parseInt(H,10)|0;return".@"+(E++);}).replace(/^\./,"");if(!/[^\w\.\$@]/.test(D)){G=D.split(".");for(E=G.length-1;E>=0;--E){if(G[E].charAt(0)==="@"){G[E]=F[parseInt(G[E].substr(1),10)];}}}else{}}return G;},getLocationValue:function(G,F){var E=0,D=G.length;for(;E<D;E++){if(A.isObject(F)&&(G[E] in F)){F=F[G[E]];}else{F=undefined;break;}}return F;},apply:function(F,G){var D=G,E={results:[],meta:{}};if(!A.isObject(G)){try{D=C.JSON.parse(G);}catch(H){E.error=H;return E;}}if(A.isObject(D)&&F){if(!A.isUndefined(F.resultListLocator)){E=B._parseResults.call(this,F,D,E);}if(!A.isUndefined(F.metaFields)){E=B._parseMeta(F.metaFields,D,E);}}else{E.error=new Error("JSON schema parse failure");}return E;},_parseResults:function(H,D,G){var F=[],I,E;if(H.resultListLocator){I=B.getPath(H.resultListLocator);if(I){F=B.getLocationValue(I,D);if(F===undefined){G.results=[];E=new Error("JSON results retrieval failure");}else{if(A.isArray(F)){if(A.isArray(H.resultFields)){G=B._getFieldValues.call(this,H.resultFields,F,G);}else{G.results=F;}}else{G.results=[];E=new Error("JSON Schema fields retrieval failure");}}}else{E=new Error("JSON Schema results locator failure");}if(E){G.error=E;}}return G;},_getFieldValues:function(K,P,E){var G=[],M=K.length,H,F,O,Q,S,D,J=[],N=[],L=[],R,I;for(H=0;H<M;H++){O=K[H];Q=O.key||O;S=B.getPath(Q);if(S){if(S.length===1){J[J.length]={key:Q,path:S[0]};}else{N[N.length]={key:Q,path:S};}}else{}D=(A.isFunction(O.parser))?O.parser:C.Parsers[O.parser+""];if(D){L[L.length]={key:Q,parser:D};}}for(H=P.length-1;H>=0;--H){I={};R=P[H];if(R){for(F=J.length-1;F>=0;--F){I[J[F].key]=C.DataSchema.Base.parse.call(this,(A.isUndefined(R[J[F].path])?R[F]:R[J[F].path]),J[F]);}for(F=N.length-1;F>=0;--F){I[N[F].key]=C.DataSchema.Base.parse.call(this,(B.getLocationValue(N[F].path,R)),N[F]);}for(F=L.length-1;F>=0;--F){Q=L[F].key;I[Q]=L[F].parser.call(this,I[Q]);if(A.isUndefined(I[Q])){I[Q]=null;}}G[H]=I;}}E.results=G;return E;},_parseMeta:function(G,D,F){if(A.isObject(G)){var E,H;for(E in G){if(G.hasOwnProperty(E)){H=B.getPath(G[E]);if(H&&D){F.meta[E]=B.getLocationValue(H,D);}}}}else{F.error=new Error("JSON meta data retrieval failure");}return F;}};C.DataSchema.JSON=C.mix(B,C.DataSchema.Base);},"3.2.0",{requires:["json","dataschema-base"]});
|
||||
@@ -1,305 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('dataschema-json', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with JSON data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-json
|
||||
*/
|
||||
|
||||
/**
|
||||
* JSON subclass for the DataSchema Utility.
|
||||
* @class DataSchema.JSON
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaJSON = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.JSON static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Utility function converts JSON locator strings into walkable paths
|
||||
*
|
||||
* @method DataSchema.JSON.getPath
|
||||
* @param locator {String} JSON value locator.
|
||||
* @return {String[]} Walkable path to data value.
|
||||
* @static
|
||||
*/
|
||||
getPath: function(locator) {
|
||||
var path = null,
|
||||
keys = [],
|
||||
i = 0;
|
||||
|
||||
if (locator) {
|
||||
// Strip the ["string keys"] and [1] array indexes
|
||||
locator = locator.
|
||||
replace(/\[(['"])(.*?)\1\]/g,
|
||||
function (x,$1,$2) {keys[i]=$2;return '.@'+(i++);}).
|
||||
replace(/\[(\d+)\]/g,
|
||||
function (x,$1) {keys[i]=parseInt($1,10)|0;return '.@'+(i++);}).
|
||||
replace(/^\./,''); // remove leading dot
|
||||
|
||||
// Validate against problematic characters.
|
||||
if (!/[^\w\.\$@]/.test(locator)) {
|
||||
path = locator.split('.');
|
||||
for (i=path.length-1; i >= 0; --i) {
|
||||
if (path[i].charAt(0) === '@') {
|
||||
path[i] = keys[parseInt(path[i].substr(1),10)];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
return path;
|
||||
},
|
||||
|
||||
/**
|
||||
* Utility function to walk a path and return the value located there.
|
||||
*
|
||||
* @method DataSchema.JSON.getLocationValue
|
||||
* @param path {String[]} Locator path.
|
||||
* @param data {String} Data to traverse.
|
||||
* @return {Object} Data value at location.
|
||||
* @static
|
||||
*/
|
||||
getLocationValue: function (path, data) {
|
||||
var i = 0,
|
||||
len = path.length;
|
||||
for (;i<len;i++) {
|
||||
if(
|
||||
LANG.isObject(data) &&
|
||||
(path[i] in data)
|
||||
) {
|
||||
data = data[path[i]];
|
||||
}
|
||||
else {
|
||||
data = undefined;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies a given schema to given JSON data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} JSON data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
// Convert incoming JSON strings
|
||||
if(!LANG.isObject(data)) {
|
||||
try {
|
||||
data_in = Y.JSON.parse(data);
|
||||
}
|
||||
catch(e) {
|
||||
data_out.error = e;
|
||||
return data_out;
|
||||
}
|
||||
}
|
||||
|
||||
if(LANG.isObject(data_in) && schema) {
|
||||
// Parse results data
|
||||
if(!LANG.isUndefined(schema.resultListLocator)) {
|
||||
data_out = SchemaJSON._parseResults.call(this, schema, data_in, data_out);
|
||||
}
|
||||
|
||||
// Parse meta data
|
||||
if(!LANG.isUndefined(schema.metaFields)) {
|
||||
data_out = SchemaJSON._parseMeta(schema.metaFields, data_in, data_out);
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("JSON schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Object} Schema to parse against.
|
||||
* @param json_in {Object} JSON to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, json_in, data_out) {
|
||||
var results = [],
|
||||
path,
|
||||
error;
|
||||
|
||||
if(schema.resultListLocator) {
|
||||
path = SchemaJSON.getPath(schema.resultListLocator);
|
||||
if(path) {
|
||||
results = SchemaJSON.getLocationValue(path, json_in);
|
||||
if (results === undefined) {
|
||||
data_out.results = [];
|
||||
error = new Error("JSON results retrieval failure");
|
||||
}
|
||||
else {
|
||||
if(LANG.isArray(results)) {
|
||||
// if no result fields are passed in, then just take the results array whole-hog
|
||||
// Sometimes you're getting an array of strings, or want the whole object,
|
||||
// so resultFields don't make sense.
|
||||
if (LANG.isArray(schema.resultFields)) {
|
||||
data_out = SchemaJSON._getFieldValues.call(this, schema.resultFields, results, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.results = results;
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.results = [];
|
||||
error = new Error("JSON Schema fields retrieval failure");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
error = new Error("JSON Schema results locator failure");
|
||||
}
|
||||
|
||||
if (error) {
|
||||
data_out.error = error;
|
||||
}
|
||||
|
||||
}
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get field data values out of list of full results
|
||||
*
|
||||
* @method _getFieldValues
|
||||
* @param fields {Array} Fields to find.
|
||||
* @param array_in {Array} Results to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_getFieldValues: function(fields, array_in, data_out) {
|
||||
var results = [],
|
||||
len = fields.length,
|
||||
i, j,
|
||||
field, key, path, parser,
|
||||
simplePaths = [], complexPaths = [], fieldParsers = [],
|
||||
result, record;
|
||||
|
||||
// First collect hashes of simple paths, complex paths, and parsers
|
||||
for (i=0; i<len; i++) {
|
||||
field = fields[i]; // A field can be a simple string or a hash
|
||||
key = field.key || field; // Find the key
|
||||
|
||||
// Validate and store locators for later
|
||||
path = SchemaJSON.getPath(key);
|
||||
if (path) {
|
||||
if (path.length === 1) {
|
||||
simplePaths[simplePaths.length] = {key:key, path:path[0]};
|
||||
} else {
|
||||
complexPaths[complexPaths.length] = {key:key, path:path};
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
// Validate and store parsers for later
|
||||
//TODO: use Y.DataSchema.parse?
|
||||
parser = (LANG.isFunction(field.parser)) ? field.parser : Y.Parsers[field.parser+''];
|
||||
if (parser) {
|
||||
fieldParsers[fieldParsers.length] = {key:key, parser:parser};
|
||||
}
|
||||
}
|
||||
|
||||
// Traverse list of array_in, creating records of simple fields,
|
||||
// complex fields, and applying parsers as necessary
|
||||
for (i=array_in.length-1; i>=0; --i) {
|
||||
record = {};
|
||||
result = array_in[i];
|
||||
if(result) {
|
||||
// Cycle through simpleLocators
|
||||
for (j=simplePaths.length-1; j>=0; --j) {
|
||||
// Bug 1777850: The result might be an array instead of object
|
||||
record[simplePaths[j].key] = Y.DataSchema.Base.parse.call(this,
|
||||
(LANG.isUndefined(result[simplePaths[j].path]) ?
|
||||
result[j] : result[simplePaths[j].path]), simplePaths[j]);
|
||||
}
|
||||
|
||||
// Cycle through complexLocators
|
||||
for (j=complexPaths.length - 1; j>=0; --j) {
|
||||
record[complexPaths[j].key] = Y.DataSchema.Base.parse.call(this,
|
||||
(SchemaJSON.getLocationValue(complexPaths[j].path, result)), complexPaths[j] );
|
||||
}
|
||||
|
||||
// Cycle through fieldParsers
|
||||
for (j=fieldParsers.length-1; j>=0; --j) {
|
||||
key = fieldParsers[j].key;
|
||||
record[key] = fieldParsers[j].parser.call(this, record[key]);
|
||||
// Safety net
|
||||
if (LANG.isUndefined(record[key])) {
|
||||
record[key] = null;
|
||||
}
|
||||
}
|
||||
results[i] = record;
|
||||
}
|
||||
}
|
||||
data_out.results = results;
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses results data according to schema
|
||||
*
|
||||
* @method _parseMeta
|
||||
* @param metaFields {Object} Metafields definitions.
|
||||
* @param json_in {Object} JSON to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Schema-parsed meta data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseMeta: function(metaFields, json_in, data_out) {
|
||||
if(LANG.isObject(metaFields)) {
|
||||
var key, path;
|
||||
for(key in metaFields) {
|
||||
if (metaFields.hasOwnProperty(key)) {
|
||||
path = SchemaJSON.getPath(metaFields[key]);
|
||||
if (path && json_in) {
|
||||
data_out.meta[key] = SchemaJSON.getLocationValue(path, json_in);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("JSON meta data retrieval failure");
|
||||
}
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.JSON = Y.mix(SchemaJSON, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['json', 'dataschema-base']});
|
||||
File diff suppressed because one or more lines are too long
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('dataschema-text', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with delimited text data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-text
|
||||
*/
|
||||
|
||||
/**
|
||||
* Text subclass for the DataSchema Utility.
|
||||
* @class DataSchema.Text
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaText = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.Text static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given delimited text data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} Text data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(LANG.isString(data_in) && LANG.isString(schema.resultDelimiter)) {
|
||||
// Parse results data
|
||||
data_out = SchemaText._parseResults.call(this, schema, data_in, data_out);
|
||||
}
|
||||
else {
|
||||
Y.log("Text data could not be schema-parsed: " + Y.dump(data) + " " + Y.dump(data), "error", "dataschema-text");
|
||||
data_out.error = new Error("Text schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Array} Schema to parse against.
|
||||
* @param text_in {String} Text to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, text_in, data_out) {
|
||||
var resultDelim = schema.resultDelimiter,
|
||||
results = [],
|
||||
results_in, fields_in, result, item, fields, field, key, value, i, j,
|
||||
|
||||
// Delete final delimiter at end of string if there
|
||||
tmpLength = text_in.length-resultDelim.length;
|
||||
if(text_in.substr(tmpLength) == resultDelim) {
|
||||
text_in = text_in.substr(0, tmpLength);
|
||||
}
|
||||
|
||||
// Split into results
|
||||
results_in = text_in.split(schema.resultDelimiter);
|
||||
|
||||
for(i=results_in.length-1; i>-1; i--) {
|
||||
result = {};
|
||||
item = results_in[i];
|
||||
|
||||
if(LANG.isString(schema.fieldDelimiter)) {
|
||||
fields_in = item.split(schema.fieldDelimiter);
|
||||
|
||||
if(LANG.isArray(schema.resultFields)) {
|
||||
fields = schema.resultFields;
|
||||
for(j=fields.length-1; j>-1; j--) {
|
||||
field = fields[j];
|
||||
key = (!LANG.isUndefined(field.key)) ? field.key : field;
|
||||
value = (!LANG.isUndefined(fields_in[key])) ? fields_in[key] : fields_in[j];
|
||||
result[key] = Y.DataSchema.Base.parse.call(this, value, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
result = item;
|
||||
}
|
||||
|
||||
results[i] = result;
|
||||
}
|
||||
data_out.results = results;
|
||||
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.Text = Y.mix(SchemaText, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['dataschema-base']});
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("dataschema-text",function(C){var B=C.Lang,A={apply:function(F,G){var D=G,E={results:[],meta:{}};if(B.isString(D)&&B.isString(F.resultDelimiter)){E=A._parseResults.call(this,F,D,E);}else{E.error=new Error("Text schema parse failure");}return E;},_parseResults:function(D,K,E){var I=D.resultDelimiter,H=[],L,P,S,R,J,N,Q,O,G,F,M=K.length-I.length;if(K.substr(M)==I){K=K.substr(0,M);}L=K.split(D.resultDelimiter);for(G=L.length-1;G>-1;G--){S={};R=L[G];if(B.isString(D.fieldDelimiter)){P=R.split(D.fieldDelimiter);if(B.isArray(D.resultFields)){J=D.resultFields;for(F=J.length-1;F>-1;F--){N=J[F];Q=(!B.isUndefined(N.key))?N.key:N;O=(!B.isUndefined(P[Q]))?P[Q]:P[F];S[Q]=C.DataSchema.Base.parse.call(this,O,N);}}}else{S=R;}H[G]=S;}E.results=H;return E;}};C.DataSchema.Text=C.mix(A,C.DataSchema.Base);},"3.2.0",{requires:["dataschema-base"]});
|
||||
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('dataschema-text', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with delimited text data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-text
|
||||
*/
|
||||
|
||||
/**
|
||||
* Text subclass for the DataSchema Utility.
|
||||
* @class DataSchema.Text
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaText = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.Text static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given delimited text data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} Text data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(LANG.isString(data_in) && LANG.isString(schema.resultDelimiter)) {
|
||||
// Parse results data
|
||||
data_out = SchemaText._parseResults.call(this, schema, data_in, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("Text schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Array} Schema to parse against.
|
||||
* @param text_in {String} Text to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, text_in, data_out) {
|
||||
var resultDelim = schema.resultDelimiter,
|
||||
results = [],
|
||||
results_in, fields_in, result, item, fields, field, key, value, i, j,
|
||||
|
||||
// Delete final delimiter at end of string if there
|
||||
tmpLength = text_in.length-resultDelim.length;
|
||||
if(text_in.substr(tmpLength) == resultDelim) {
|
||||
text_in = text_in.substr(0, tmpLength);
|
||||
}
|
||||
|
||||
// Split into results
|
||||
results_in = text_in.split(schema.resultDelimiter);
|
||||
|
||||
for(i=results_in.length-1; i>-1; i--) {
|
||||
result = {};
|
||||
item = results_in[i];
|
||||
|
||||
if(LANG.isString(schema.fieldDelimiter)) {
|
||||
fields_in = item.split(schema.fieldDelimiter);
|
||||
|
||||
if(LANG.isArray(schema.resultFields)) {
|
||||
fields = schema.resultFields;
|
||||
for(j=fields.length-1; j>-1; j--) {
|
||||
field = fields[j];
|
||||
key = (!LANG.isUndefined(field.key)) ? field.key : field;
|
||||
value = (!LANG.isUndefined(fields_in[key])) ? fields_in[key] : fields_in[j];
|
||||
result[key] = Y.DataSchema.Base.parse.call(this, value, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
result = item;
|
||||
}
|
||||
|
||||
results[i] = result;
|
||||
}
|
||||
data_out.results = results;
|
||||
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.Text = Y.mix(SchemaText, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['dataschema-base']});
|
||||
@@ -1,296 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('dataschema-xml', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with XML data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-xml
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
/**
|
||||
* XML subclass for the DataSchema Utility.
|
||||
* @class DataSchema.XML
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
SchemaXML = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.XML static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given XML data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {XMLDoc} XML document.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var xmldoc = data, // unnecessary variables
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(xmldoc && xmldoc.nodeType && (9 === xmldoc.nodeType || 1 === xmldoc.nodeType || 11 === xmldoc.nodeType) && schema) {
|
||||
// Parse results data
|
||||
data_out = SchemaXML._parseResults.call(this, schema, xmldoc, data_out);
|
||||
|
||||
// Parse meta data
|
||||
data_out = SchemaXML._parseMeta.call(this, schema.metaFields, xmldoc, data_out);
|
||||
}
|
||||
else {
|
||||
Y.log("XML data could not be schema-parsed: " + Y.dump(data) + " " + Y.dump(data), "error", "dataschema-xml");
|
||||
data_out.error = new Error("XML schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get an XPath-specified value for a given field from an XML node or document.
|
||||
*
|
||||
* @method _getLocationValue
|
||||
* @param field {String | Object} Field definition.
|
||||
* @param context {Object} XML node or document to search within.
|
||||
* @return {Object} Data value or null.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_getLocationValue: function(field, context) {
|
||||
var locator = field.locator || field.key || field,
|
||||
xmldoc = context.ownerDocument || context,
|
||||
result, res, value = null;
|
||||
|
||||
try {
|
||||
result = SchemaXML._getXPathResult(locator, context, xmldoc);
|
||||
while(res = result.iterateNext()) {
|
||||
value = res.textContent || res.value || res.text || res.innerHTML || null;
|
||||
}
|
||||
|
||||
return Y.DataSchema.Base.parse.call(this, value, field);
|
||||
}
|
||||
catch(e) {
|
||||
Y.log('SchemaXML._getLocationValue failed: ' + e.message);
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Fetches the XPath-specified result for a given location in an XML node or document.
|
||||
*
|
||||
* @param locator {String} The XPath location.
|
||||
* @param context {Object} XML node or document to search within.
|
||||
* @param xmldoc {Object} XML document to resolve namespace.
|
||||
* @return {Object} Data collection or null.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_getXPathResult: function(locator, context, xmldoc) {
|
||||
// Standards mode
|
||||
if (! LANG.isUndefined(xmldoc.evaluate)) {
|
||||
return xmldoc.evaluate(locator, context, xmldoc.createNSResolver(context.ownerDocument ? context.ownerDocument.documentElement : context.documentElement), 0, null);
|
||||
}
|
||||
// IE mode
|
||||
else {
|
||||
var values=[], locatorArray = locator.split(/\b\/\b/), i=0, l=locatorArray.length, location, subloc, m, isNth;
|
||||
|
||||
// XPath is supported
|
||||
try {
|
||||
// this fixes the IE 5.5+ issue where childnode selectors begin at 0 instead of 1
|
||||
xmldoc.setProperty("SelectionLanguage", "XPath");
|
||||
values = context.selectNodes(locator);
|
||||
}
|
||||
// Fallback for DOM nodes and fragments
|
||||
catch (e) {
|
||||
// Iterate over each locator piece
|
||||
for (; i<l && context; i++) {
|
||||
location = locatorArray[i];
|
||||
|
||||
// grab nth child []
|
||||
if ((location.indexOf("[") > -1) && (location.indexOf("]") > -1)) {
|
||||
subloc = location.slice(location.indexOf("[")+1, location.indexOf("]"));
|
||||
//XPath is 1-based while DOM is 0-based
|
||||
subloc--;
|
||||
context = context.childNodes[subloc];
|
||||
isNth = true;
|
||||
}
|
||||
// grab attribute value @
|
||||
else if (location.indexOf("@") > -1) {
|
||||
subloc = location.substr(location.indexOf("@"));
|
||||
context = subloc ? context.getAttribute(subloc.replace('@', '')) : context;
|
||||
}
|
||||
// grab that last instance of tagName
|
||||
else if (-1 < location.indexOf("//")) {
|
||||
subloc = context.getElementsByTagName(location.substr(2));
|
||||
context = subloc.length ? subloc[subloc.length - 1] : null;
|
||||
}
|
||||
// find the last matching location in children
|
||||
else if (l != i + 1) {
|
||||
for (m=context.childNodes.length-1; 0 <= m; m-=1) {
|
||||
if (location === context.childNodes[m].tagName) {
|
||||
context = context.childNodes[m];
|
||||
m = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (context) {
|
||||
// attribute
|
||||
if (LANG.isString(context)) {
|
||||
values[0] = {value: context};
|
||||
}
|
||||
// nth child
|
||||
else if (isNth) {
|
||||
values[0] = {value: context.innerHTML};
|
||||
}
|
||||
// all children
|
||||
else {
|
||||
values = Y.Array(context.childNodes, 0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// returning a mock-standard object for IE
|
||||
return {
|
||||
index: 0,
|
||||
|
||||
iterateNext: function() {
|
||||
if (this.index >= this.values.length) {return undefined;}
|
||||
var result = this.values[this.index];
|
||||
this.index += 1;
|
||||
return result;
|
||||
},
|
||||
|
||||
values: values
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed result field.
|
||||
*
|
||||
* @method _parseField
|
||||
* @param field {String | Object} Required. Field definition.
|
||||
* @param result {Object} Required. Schema parsed data object.
|
||||
* @param context {Object} Required. XML node or document to search within.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseField: function(field, result, context) {
|
||||
if (field.schema) {
|
||||
result[field.key] = SchemaXML._parseResults.call(this, field.schema, context, {results:[],meta:{}}).results;
|
||||
}
|
||||
else {
|
||||
result[field.key || field] = SchemaXML._getLocationValue.call(this, field, context);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses results data according to schema
|
||||
*
|
||||
* @method _parseMeta
|
||||
* @param xmldoc_in {Object} XML document parse.
|
||||
* @param data_out {Object} In-progress schema-parsed data to update.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseMeta: function(metaFields, xmldoc_in, data_out) {
|
||||
if(LANG.isObject(metaFields)) {
|
||||
var key,
|
||||
xmldoc = xmldoc_in.ownerDocument || xmldoc_in;
|
||||
|
||||
for(key in metaFields) {
|
||||
if (metaFields.hasOwnProperty(key)) {
|
||||
data_out.meta[key] = SchemaXML._getLocationValue.call(this, metaFields[key], xmldoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed result to add to results list.
|
||||
*
|
||||
* @method _parseResult
|
||||
* @param fields {Array} Required. A collection of field definition.
|
||||
* @param context {Object} Required. XML node or document to search within.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResult: function(fields, context) {
|
||||
var result = {}, j;
|
||||
|
||||
// Find each field value
|
||||
for (j=fields.length-1; 0 <= j; j--) {
|
||||
SchemaXML._parseField.call(this, fields[j], result, context);
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Object} Schema to parse against.
|
||||
* @param context {Object} XML node document parse.
|
||||
* @param data_out {Object} In-progress schema-parsed data to update.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, context, data_out) {
|
||||
if (schema.resultListLocator && LANG.isArray(schema.resultFields)) {
|
||||
var xmldoc = context.ownerDocument || context,
|
||||
fields = schema.resultFields,
|
||||
results = [],
|
||||
node, result, nodeList, i=0;
|
||||
|
||||
if (schema.resultListLocator.match(/^[:\-\w]+$/)) {
|
||||
nodeList = context.getElementsByTagName(schema.resultListLocator);
|
||||
|
||||
// loop through each result node
|
||||
for (i=nodeList.length-1; 0 <= i; i--) {
|
||||
results[i] = SchemaXML._parseResult.call(this, fields, nodeList[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
nodeList = SchemaXML._getXPathResult(schema.resultListLocator, context, xmldoc);
|
||||
|
||||
// loop through the nodelist
|
||||
while (node = nodeList.iterateNext()) {
|
||||
results[i] = SchemaXML._parseResult.call(this, fields, node);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (results.length) {
|
||||
data_out.results = results;
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("XML schema result nodes retrieval failure");
|
||||
}
|
||||
}
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.XML = Y.mix(SchemaXML, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['dataschema-base']});
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("dataschema-xml",function(C){var B=C.Lang,A={apply:function(F,G){var D=G,E={results:[],meta:{}};if(D&&D.nodeType&&(9===D.nodeType||1===D.nodeType||11===D.nodeType)&&F){E=A._parseResults.call(this,F,D,E);E=A._parseMeta.call(this,F.metaFields,D,E);}else{E.error=new Error("XML schema parse failure");}return E;},_getLocationValue:function(K,H){var F=K.locator||K.key||K,E=H.ownerDocument||H,D,G,I=null;try{D=A._getXPathResult(F,H,E);while(G=D.iterateNext()){I=G.textContent||G.value||G.text||G.innerHTML||null;}return C.DataSchema.Base.parse.call(this,I,K);}catch(J){}return null;},_getXPathResult:function(I,E,O){if(!B.isUndefined(O.evaluate)){return O.evaluate(I,E,O.createNSResolver(E.ownerDocument?E.ownerDocument.documentElement:E.documentElement),0,null);}else{var L=[],N=I.split(/\b\/\b/),H=0,G=N.length,K,D,F,M;try{O.setProperty("SelectionLanguage","XPath");L=E.selectNodes(I);}catch(J){for(;H<G&&E;H++){K=N[H];if((K.indexOf("[")>-1)&&(K.indexOf("]")>-1)){D=K.slice(K.indexOf("[")+1,K.indexOf("]"));D--;E=E.childNodes[D];M=true;}else{if(K.indexOf("@")>-1){D=K.substr(K.indexOf("@"));E=D?E.getAttribute(D.replace("@","")):E;}else{if(-1<K.indexOf("//")){D=E.getElementsByTagName(K.substr(2));E=D.length?D[D.length-1]:null;}else{if(G!=H+1){for(F=E.childNodes.length-1;0<=F;F-=1){if(K===E.childNodes[F].tagName){E=E.childNodes[F];F=-1;}}}}}}}if(E){if(B.isString(E)){L[0]={value:E};}else{if(M){L[0]={value:E.innerHTML};}else{L=C.Array(E.childNodes,0,true);}}}}return{index:0,iterateNext:function(){if(this.index>=this.values.length){return undefined;}var P=this.values[this.index];this.index+=1;return P;},values:L};}},_parseField:function(F,D,E){if(F.schema){D[F.key]=A._parseResults.call(this,F.schema,E,{results:[],meta:{}}).results;}else{D[F.key||F]=A._getLocationValue.call(this,F,E);}},_parseMeta:function(H,G,F){if(B.isObject(H)){var E,D=G.ownerDocument||G;for(E in H){if(H.hasOwnProperty(E)){F.meta[E]=A._getLocationValue.call(this,H[E],D);}}}return F;},_parseResult:function(E,G){var D={},F;for(F=E.length-1;0<=F;F--){A._parseField.call(this,E[F],D,G);}return D;},_parseResults:function(G,D,H){if(G.resultListLocator&&B.isArray(G.resultFields)){var L=D.ownerDocument||D,K=G.resultFields,J=[],E,M,F,I=0;if(G.resultListLocator.match(/^[:\-\w]+$/)){F=D.getElementsByTagName(G.resultListLocator);for(I=F.length-1;0<=I;I--){J[I]=A._parseResult.call(this,K,F[I]);}}else{F=A._getXPathResult(G.resultListLocator,D,L);while(E=F.iterateNext()){J[I]=A._parseResult.call(this,K,E);I+=1;}}if(J.length){H.results=J;}else{H.error=new Error("XML schema result nodes retrieval failure");}}return H;}};C.DataSchema.XML=C.mix(A,C.DataSchema.Base);},"3.2.0",{requires:["dataschema-base"]});
|
||||
@@ -1,294 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('dataschema-xml', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with XML data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-xml
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
/**
|
||||
* XML subclass for the DataSchema Utility.
|
||||
* @class DataSchema.XML
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
SchemaXML = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.XML static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given XML data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {XMLDoc} XML document.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var xmldoc = data, // unnecessary variables
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(xmldoc && xmldoc.nodeType && (9 === xmldoc.nodeType || 1 === xmldoc.nodeType || 11 === xmldoc.nodeType) && schema) {
|
||||
// Parse results data
|
||||
data_out = SchemaXML._parseResults.call(this, schema, xmldoc, data_out);
|
||||
|
||||
// Parse meta data
|
||||
data_out = SchemaXML._parseMeta.call(this, schema.metaFields, xmldoc, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("XML schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get an XPath-specified value for a given field from an XML node or document.
|
||||
*
|
||||
* @method _getLocationValue
|
||||
* @param field {String | Object} Field definition.
|
||||
* @param context {Object} XML node or document to search within.
|
||||
* @return {Object} Data value or null.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_getLocationValue: function(field, context) {
|
||||
var locator = field.locator || field.key || field,
|
||||
xmldoc = context.ownerDocument || context,
|
||||
result, res, value = null;
|
||||
|
||||
try {
|
||||
result = SchemaXML._getXPathResult(locator, context, xmldoc);
|
||||
while(res = result.iterateNext()) {
|
||||
value = res.textContent || res.value || res.text || res.innerHTML || null;
|
||||
}
|
||||
|
||||
return Y.DataSchema.Base.parse.call(this, value, field);
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Fetches the XPath-specified result for a given location in an XML node or document.
|
||||
*
|
||||
* @param locator {String} The XPath location.
|
||||
* @param context {Object} XML node or document to search within.
|
||||
* @param xmldoc {Object} XML document to resolve namespace.
|
||||
* @return {Object} Data collection or null.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_getXPathResult: function(locator, context, xmldoc) {
|
||||
// Standards mode
|
||||
if (! LANG.isUndefined(xmldoc.evaluate)) {
|
||||
return xmldoc.evaluate(locator, context, xmldoc.createNSResolver(context.ownerDocument ? context.ownerDocument.documentElement : context.documentElement), 0, null);
|
||||
}
|
||||
// IE mode
|
||||
else {
|
||||
var values=[], locatorArray = locator.split(/\b\/\b/), i=0, l=locatorArray.length, location, subloc, m, isNth;
|
||||
|
||||
// XPath is supported
|
||||
try {
|
||||
// this fixes the IE 5.5+ issue where childnode selectors begin at 0 instead of 1
|
||||
xmldoc.setProperty("SelectionLanguage", "XPath");
|
||||
values = context.selectNodes(locator);
|
||||
}
|
||||
// Fallback for DOM nodes and fragments
|
||||
catch (e) {
|
||||
// Iterate over each locator piece
|
||||
for (; i<l && context; i++) {
|
||||
location = locatorArray[i];
|
||||
|
||||
// grab nth child []
|
||||
if ((location.indexOf("[") > -1) && (location.indexOf("]") > -1)) {
|
||||
subloc = location.slice(location.indexOf("[")+1, location.indexOf("]"));
|
||||
//XPath is 1-based while DOM is 0-based
|
||||
subloc--;
|
||||
context = context.childNodes[subloc];
|
||||
isNth = true;
|
||||
}
|
||||
// grab attribute value @
|
||||
else if (location.indexOf("@") > -1) {
|
||||
subloc = location.substr(location.indexOf("@"));
|
||||
context = subloc ? context.getAttribute(subloc.replace('@', '')) : context;
|
||||
}
|
||||
// grab that last instance of tagName
|
||||
else if (-1 < location.indexOf("//")) {
|
||||
subloc = context.getElementsByTagName(location.substr(2));
|
||||
context = subloc.length ? subloc[subloc.length - 1] : null;
|
||||
}
|
||||
// find the last matching location in children
|
||||
else if (l != i + 1) {
|
||||
for (m=context.childNodes.length-1; 0 <= m; m-=1) {
|
||||
if (location === context.childNodes[m].tagName) {
|
||||
context = context.childNodes[m];
|
||||
m = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (context) {
|
||||
// attribute
|
||||
if (LANG.isString(context)) {
|
||||
values[0] = {value: context};
|
||||
}
|
||||
// nth child
|
||||
else if (isNth) {
|
||||
values[0] = {value: context.innerHTML};
|
||||
}
|
||||
// all children
|
||||
else {
|
||||
values = Y.Array(context.childNodes, 0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// returning a mock-standard object for IE
|
||||
return {
|
||||
index: 0,
|
||||
|
||||
iterateNext: function() {
|
||||
if (this.index >= this.values.length) {return undefined;}
|
||||
var result = this.values[this.index];
|
||||
this.index += 1;
|
||||
return result;
|
||||
},
|
||||
|
||||
values: values
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed result field.
|
||||
*
|
||||
* @method _parseField
|
||||
* @param field {String | Object} Required. Field definition.
|
||||
* @param result {Object} Required. Schema parsed data object.
|
||||
* @param context {Object} Required. XML node or document to search within.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseField: function(field, result, context) {
|
||||
if (field.schema) {
|
||||
result[field.key] = SchemaXML._parseResults.call(this, field.schema, context, {results:[],meta:{}}).results;
|
||||
}
|
||||
else {
|
||||
result[field.key || field] = SchemaXML._getLocationValue.call(this, field, context);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses results data according to schema
|
||||
*
|
||||
* @method _parseMeta
|
||||
* @param xmldoc_in {Object} XML document parse.
|
||||
* @param data_out {Object} In-progress schema-parsed data to update.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseMeta: function(metaFields, xmldoc_in, data_out) {
|
||||
if(LANG.isObject(metaFields)) {
|
||||
var key,
|
||||
xmldoc = xmldoc_in.ownerDocument || xmldoc_in;
|
||||
|
||||
for(key in metaFields) {
|
||||
if (metaFields.hasOwnProperty(key)) {
|
||||
data_out.meta[key] = SchemaXML._getLocationValue.call(this, metaFields[key], xmldoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed result to add to results list.
|
||||
*
|
||||
* @method _parseResult
|
||||
* @param fields {Array} Required. A collection of field definition.
|
||||
* @param context {Object} Required. XML node or document to search within.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResult: function(fields, context) {
|
||||
var result = {}, j;
|
||||
|
||||
// Find each field value
|
||||
for (j=fields.length-1; 0 <= j; j--) {
|
||||
SchemaXML._parseField.call(this, fields[j], result, context);
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Object} Schema to parse against.
|
||||
* @param context {Object} XML node document parse.
|
||||
* @param data_out {Object} In-progress schema-parsed data to update.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, context, data_out) {
|
||||
if (schema.resultListLocator && LANG.isArray(schema.resultFields)) {
|
||||
var xmldoc = context.ownerDocument || context,
|
||||
fields = schema.resultFields,
|
||||
results = [],
|
||||
node, result, nodeList, i=0;
|
||||
|
||||
if (schema.resultListLocator.match(/^[:\-\w]+$/)) {
|
||||
nodeList = context.getElementsByTagName(schema.resultListLocator);
|
||||
|
||||
// loop through each result node
|
||||
for (i=nodeList.length-1; 0 <= i; i--) {
|
||||
results[i] = SchemaXML._parseResult.call(this, fields, nodeList[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
nodeList = SchemaXML._getXPathResult(schema.resultListLocator, context, xmldoc);
|
||||
|
||||
// loop through the nodelist
|
||||
while (node = nodeList.iterateNext()) {
|
||||
results[i] = SchemaXML._parseResult.call(this, fields, node);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (results.length) {
|
||||
data_out.results = results;
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("XML schema result nodes retrieval failure");
|
||||
}
|
||||
}
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.XML = Y.mix(SchemaXML, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['dataschema-base']});
|
||||
@@ -1,876 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add('dataschema-base', function(Y) {
|
||||
|
||||
/**
|
||||
* The DataSchema utility provides a common configurable interface for widgets to
|
||||
* apply a given schema to a variety of data.
|
||||
*
|
||||
* @module dataschema
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides the base DataSchema implementation, which can be extended to
|
||||
* create DataSchemas for specific data formats, such XML, JSON, text and
|
||||
* arrays.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-base
|
||||
*/
|
||||
|
||||
var LANG = Y.Lang,
|
||||
/**
|
||||
* Base class for the YUI DataSchema Utility.
|
||||
* @class DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
SchemaBase = {
|
||||
/**
|
||||
* Overridable method returns data as-is.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} Data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies field parser, if defined
|
||||
*
|
||||
* @method parse
|
||||
* @param value {Object} Original value.
|
||||
* @param field {Object} Field.
|
||||
* @return {Object} Type-converted value.
|
||||
*/
|
||||
parse: function(value, field) {
|
||||
if(field.parser) {
|
||||
var parser = (LANG.isFunction(field.parser)) ?
|
||||
field.parser : Y.Parsers[field.parser+''];
|
||||
if(parser) {
|
||||
value = parser.call(this, value);
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
Y.namespace("DataSchema").Base = SchemaBase;
|
||||
Y.namespace("Parsers");
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['base']});
|
||||
|
||||
YUI.add('dataschema-json', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with JSON data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-json
|
||||
*/
|
||||
|
||||
/**
|
||||
* JSON subclass for the DataSchema Utility.
|
||||
* @class DataSchema.JSON
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaJSON = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.JSON static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Utility function converts JSON locator strings into walkable paths
|
||||
*
|
||||
* @method DataSchema.JSON.getPath
|
||||
* @param locator {String} JSON value locator.
|
||||
* @return {String[]} Walkable path to data value.
|
||||
* @static
|
||||
*/
|
||||
getPath: function(locator) {
|
||||
var path = null,
|
||||
keys = [],
|
||||
i = 0;
|
||||
|
||||
if (locator) {
|
||||
// Strip the ["string keys"] and [1] array indexes
|
||||
locator = locator.
|
||||
replace(/\[(['"])(.*?)\1\]/g,
|
||||
function (x,$1,$2) {keys[i]=$2;return '.@'+(i++);}).
|
||||
replace(/\[(\d+)\]/g,
|
||||
function (x,$1) {keys[i]=parseInt($1,10)|0;return '.@'+(i++);}).
|
||||
replace(/^\./,''); // remove leading dot
|
||||
|
||||
// Validate against problematic characters.
|
||||
if (!/[^\w\.\$@]/.test(locator)) {
|
||||
path = locator.split('.');
|
||||
for (i=path.length-1; i >= 0; --i) {
|
||||
if (path[i].charAt(0) === '@') {
|
||||
path[i] = keys[parseInt(path[i].substr(1),10)];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
return path;
|
||||
},
|
||||
|
||||
/**
|
||||
* Utility function to walk a path and return the value located there.
|
||||
*
|
||||
* @method DataSchema.JSON.getLocationValue
|
||||
* @param path {String[]} Locator path.
|
||||
* @param data {String} Data to traverse.
|
||||
* @return {Object} Data value at location.
|
||||
* @static
|
||||
*/
|
||||
getLocationValue: function (path, data) {
|
||||
var i = 0,
|
||||
len = path.length;
|
||||
for (;i<len;i++) {
|
||||
if(
|
||||
LANG.isObject(data) &&
|
||||
(path[i] in data)
|
||||
) {
|
||||
data = data[path[i]];
|
||||
}
|
||||
else {
|
||||
data = undefined;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies a given schema to given JSON data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} JSON data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
// Convert incoming JSON strings
|
||||
if(!LANG.isObject(data)) {
|
||||
try {
|
||||
data_in = Y.JSON.parse(data);
|
||||
}
|
||||
catch(e) {
|
||||
data_out.error = e;
|
||||
return data_out;
|
||||
}
|
||||
}
|
||||
|
||||
if(LANG.isObject(data_in) && schema) {
|
||||
// Parse results data
|
||||
if(!LANG.isUndefined(schema.resultListLocator)) {
|
||||
data_out = SchemaJSON._parseResults.call(this, schema, data_in, data_out);
|
||||
}
|
||||
|
||||
// Parse meta data
|
||||
if(!LANG.isUndefined(schema.metaFields)) {
|
||||
data_out = SchemaJSON._parseMeta(schema.metaFields, data_in, data_out);
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("JSON schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Object} Schema to parse against.
|
||||
* @param json_in {Object} JSON to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, json_in, data_out) {
|
||||
var results = [],
|
||||
path,
|
||||
error;
|
||||
|
||||
if(schema.resultListLocator) {
|
||||
path = SchemaJSON.getPath(schema.resultListLocator);
|
||||
if(path) {
|
||||
results = SchemaJSON.getLocationValue(path, json_in);
|
||||
if (results === undefined) {
|
||||
data_out.results = [];
|
||||
error = new Error("JSON results retrieval failure");
|
||||
}
|
||||
else {
|
||||
if(LANG.isArray(results)) {
|
||||
// if no result fields are passed in, then just take the results array whole-hog
|
||||
// Sometimes you're getting an array of strings, or want the whole object,
|
||||
// so resultFields don't make sense.
|
||||
if (LANG.isArray(schema.resultFields)) {
|
||||
data_out = SchemaJSON._getFieldValues.call(this, schema.resultFields, results, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.results = results;
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.results = [];
|
||||
error = new Error("JSON Schema fields retrieval failure");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
error = new Error("JSON Schema results locator failure");
|
||||
}
|
||||
|
||||
if (error) {
|
||||
data_out.error = error;
|
||||
}
|
||||
|
||||
}
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get field data values out of list of full results
|
||||
*
|
||||
* @method _getFieldValues
|
||||
* @param fields {Array} Fields to find.
|
||||
* @param array_in {Array} Results to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_getFieldValues: function(fields, array_in, data_out) {
|
||||
var results = [],
|
||||
len = fields.length,
|
||||
i, j,
|
||||
field, key, path, parser,
|
||||
simplePaths = [], complexPaths = [], fieldParsers = [],
|
||||
result, record;
|
||||
|
||||
// First collect hashes of simple paths, complex paths, and parsers
|
||||
for (i=0; i<len; i++) {
|
||||
field = fields[i]; // A field can be a simple string or a hash
|
||||
key = field.key || field; // Find the key
|
||||
|
||||
// Validate and store locators for later
|
||||
path = SchemaJSON.getPath(key);
|
||||
if (path) {
|
||||
if (path.length === 1) {
|
||||
simplePaths[simplePaths.length] = {key:key, path:path[0]};
|
||||
} else {
|
||||
complexPaths[complexPaths.length] = {key:key, path:path};
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
// Validate and store parsers for later
|
||||
//TODO: use Y.DataSchema.parse?
|
||||
parser = (LANG.isFunction(field.parser)) ? field.parser : Y.Parsers[field.parser+''];
|
||||
if (parser) {
|
||||
fieldParsers[fieldParsers.length] = {key:key, parser:parser};
|
||||
}
|
||||
}
|
||||
|
||||
// Traverse list of array_in, creating records of simple fields,
|
||||
// complex fields, and applying parsers as necessary
|
||||
for (i=array_in.length-1; i>=0; --i) {
|
||||
record = {};
|
||||
result = array_in[i];
|
||||
if(result) {
|
||||
// Cycle through simpleLocators
|
||||
for (j=simplePaths.length-1; j>=0; --j) {
|
||||
// Bug 1777850: The result might be an array instead of object
|
||||
record[simplePaths[j].key] = Y.DataSchema.Base.parse.call(this,
|
||||
(LANG.isUndefined(result[simplePaths[j].path]) ?
|
||||
result[j] : result[simplePaths[j].path]), simplePaths[j]);
|
||||
}
|
||||
|
||||
// Cycle through complexLocators
|
||||
for (j=complexPaths.length - 1; j>=0; --j) {
|
||||
record[complexPaths[j].key] = Y.DataSchema.Base.parse.call(this,
|
||||
(SchemaJSON.getLocationValue(complexPaths[j].path, result)), complexPaths[j] );
|
||||
}
|
||||
|
||||
// Cycle through fieldParsers
|
||||
for (j=fieldParsers.length-1; j>=0; --j) {
|
||||
key = fieldParsers[j].key;
|
||||
record[key] = fieldParsers[j].parser.call(this, record[key]);
|
||||
// Safety net
|
||||
if (LANG.isUndefined(record[key])) {
|
||||
record[key] = null;
|
||||
}
|
||||
}
|
||||
results[i] = record;
|
||||
}
|
||||
}
|
||||
data_out.results = results;
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses results data according to schema
|
||||
*
|
||||
* @method _parseMeta
|
||||
* @param metaFields {Object} Metafields definitions.
|
||||
* @param json_in {Object} JSON to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Schema-parsed meta data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseMeta: function(metaFields, json_in, data_out) {
|
||||
if(LANG.isObject(metaFields)) {
|
||||
var key, path;
|
||||
for(key in metaFields) {
|
||||
if (metaFields.hasOwnProperty(key)) {
|
||||
path = SchemaJSON.getPath(metaFields[key]);
|
||||
if (path && json_in) {
|
||||
data_out.meta[key] = SchemaJSON.getLocationValue(path, json_in);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("JSON meta data retrieval failure");
|
||||
}
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.JSON = Y.mix(SchemaJSON, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['json', 'dataschema-base']});
|
||||
|
||||
YUI.add('dataschema-xml', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with XML data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-xml
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
/**
|
||||
* XML subclass for the DataSchema Utility.
|
||||
* @class DataSchema.XML
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
SchemaXML = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.XML static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given XML data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {XMLDoc} XML document.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var xmldoc = data, // unnecessary variables
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(xmldoc && xmldoc.nodeType && (9 === xmldoc.nodeType || 1 === xmldoc.nodeType || 11 === xmldoc.nodeType) && schema) {
|
||||
// Parse results data
|
||||
data_out = SchemaXML._parseResults.call(this, schema, xmldoc, data_out);
|
||||
|
||||
// Parse meta data
|
||||
data_out = SchemaXML._parseMeta.call(this, schema.metaFields, xmldoc, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("XML schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get an XPath-specified value for a given field from an XML node or document.
|
||||
*
|
||||
* @method _getLocationValue
|
||||
* @param field {String | Object} Field definition.
|
||||
* @param context {Object} XML node or document to search within.
|
||||
* @return {Object} Data value or null.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_getLocationValue: function(field, context) {
|
||||
var locator = field.locator || field.key || field,
|
||||
xmldoc = context.ownerDocument || context,
|
||||
result, res, value = null;
|
||||
|
||||
try {
|
||||
result = SchemaXML._getXPathResult(locator, context, xmldoc);
|
||||
while(res = result.iterateNext()) {
|
||||
value = res.textContent || res.value || res.text || res.innerHTML || null;
|
||||
}
|
||||
|
||||
return Y.DataSchema.Base.parse.call(this, value, field);
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Fetches the XPath-specified result for a given location in an XML node or document.
|
||||
*
|
||||
* @param locator {String} The XPath location.
|
||||
* @param context {Object} XML node or document to search within.
|
||||
* @param xmldoc {Object} XML document to resolve namespace.
|
||||
* @return {Object} Data collection or null.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_getXPathResult: function(locator, context, xmldoc) {
|
||||
// Standards mode
|
||||
if (! LANG.isUndefined(xmldoc.evaluate)) {
|
||||
return xmldoc.evaluate(locator, context, xmldoc.createNSResolver(context.ownerDocument ? context.ownerDocument.documentElement : context.documentElement), 0, null);
|
||||
}
|
||||
// IE mode
|
||||
else {
|
||||
var values=[], locatorArray = locator.split(/\b\/\b/), i=0, l=locatorArray.length, location, subloc, m, isNth;
|
||||
|
||||
// XPath is supported
|
||||
try {
|
||||
// this fixes the IE 5.5+ issue where childnode selectors begin at 0 instead of 1
|
||||
xmldoc.setProperty("SelectionLanguage", "XPath");
|
||||
values = context.selectNodes(locator);
|
||||
}
|
||||
// Fallback for DOM nodes and fragments
|
||||
catch (e) {
|
||||
// Iterate over each locator piece
|
||||
for (; i<l && context; i++) {
|
||||
location = locatorArray[i];
|
||||
|
||||
// grab nth child []
|
||||
if ((location.indexOf("[") > -1) && (location.indexOf("]") > -1)) {
|
||||
subloc = location.slice(location.indexOf("[")+1, location.indexOf("]"));
|
||||
//XPath is 1-based while DOM is 0-based
|
||||
subloc--;
|
||||
context = context.childNodes[subloc];
|
||||
isNth = true;
|
||||
}
|
||||
// grab attribute value @
|
||||
else if (location.indexOf("@") > -1) {
|
||||
subloc = location.substr(location.indexOf("@"));
|
||||
context = subloc ? context.getAttribute(subloc.replace('@', '')) : context;
|
||||
}
|
||||
// grab that last instance of tagName
|
||||
else if (-1 < location.indexOf("//")) {
|
||||
subloc = context.getElementsByTagName(location.substr(2));
|
||||
context = subloc.length ? subloc[subloc.length - 1] : null;
|
||||
}
|
||||
// find the last matching location in children
|
||||
else if (l != i + 1) {
|
||||
for (m=context.childNodes.length-1; 0 <= m; m-=1) {
|
||||
if (location === context.childNodes[m].tagName) {
|
||||
context = context.childNodes[m];
|
||||
m = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (context) {
|
||||
// attribute
|
||||
if (LANG.isString(context)) {
|
||||
values[0] = {value: context};
|
||||
}
|
||||
// nth child
|
||||
else if (isNth) {
|
||||
values[0] = {value: context.innerHTML};
|
||||
}
|
||||
// all children
|
||||
else {
|
||||
values = Y.Array(context.childNodes, 0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// returning a mock-standard object for IE
|
||||
return {
|
||||
index: 0,
|
||||
|
||||
iterateNext: function() {
|
||||
if (this.index >= this.values.length) {return undefined;}
|
||||
var result = this.values[this.index];
|
||||
this.index += 1;
|
||||
return result;
|
||||
},
|
||||
|
||||
values: values
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed result field.
|
||||
*
|
||||
* @method _parseField
|
||||
* @param field {String | Object} Required. Field definition.
|
||||
* @param result {Object} Required. Schema parsed data object.
|
||||
* @param context {Object} Required. XML node or document to search within.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseField: function(field, result, context) {
|
||||
if (field.schema) {
|
||||
result[field.key] = SchemaXML._parseResults.call(this, field.schema, context, {results:[],meta:{}}).results;
|
||||
}
|
||||
else {
|
||||
result[field.key || field] = SchemaXML._getLocationValue.call(this, field, context);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses results data according to schema
|
||||
*
|
||||
* @method _parseMeta
|
||||
* @param xmldoc_in {Object} XML document parse.
|
||||
* @param data_out {Object} In-progress schema-parsed data to update.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseMeta: function(metaFields, xmldoc_in, data_out) {
|
||||
if(LANG.isObject(metaFields)) {
|
||||
var key,
|
||||
xmldoc = xmldoc_in.ownerDocument || xmldoc_in;
|
||||
|
||||
for(key in metaFields) {
|
||||
if (metaFields.hasOwnProperty(key)) {
|
||||
data_out.meta[key] = SchemaXML._getLocationValue.call(this, metaFields[key], xmldoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed result to add to results list.
|
||||
*
|
||||
* @method _parseResult
|
||||
* @param fields {Array} Required. A collection of field definition.
|
||||
* @param context {Object} Required. XML node or document to search within.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResult: function(fields, context) {
|
||||
var result = {}, j;
|
||||
|
||||
// Find each field value
|
||||
for (j=fields.length-1; 0 <= j; j--) {
|
||||
SchemaXML._parseField.call(this, fields[j], result, context);
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Object} Schema to parse against.
|
||||
* @param context {Object} XML node document parse.
|
||||
* @param data_out {Object} In-progress schema-parsed data to update.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, context, data_out) {
|
||||
if (schema.resultListLocator && LANG.isArray(schema.resultFields)) {
|
||||
var xmldoc = context.ownerDocument || context,
|
||||
fields = schema.resultFields,
|
||||
results = [],
|
||||
node, result, nodeList, i=0;
|
||||
|
||||
if (schema.resultListLocator.match(/^[:\-\w]+$/)) {
|
||||
nodeList = context.getElementsByTagName(schema.resultListLocator);
|
||||
|
||||
// loop through each result node
|
||||
for (i=nodeList.length-1; 0 <= i; i--) {
|
||||
results[i] = SchemaXML._parseResult.call(this, fields, nodeList[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
nodeList = SchemaXML._getXPathResult(schema.resultListLocator, context, xmldoc);
|
||||
|
||||
// loop through the nodelist
|
||||
while (node = nodeList.iterateNext()) {
|
||||
results[i] = SchemaXML._parseResult.call(this, fields, node);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (results.length) {
|
||||
data_out.results = results;
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("XML schema result nodes retrieval failure");
|
||||
}
|
||||
}
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.XML = Y.mix(SchemaXML, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['dataschema-base']});
|
||||
|
||||
YUI.add('dataschema-array', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with data stored in arrays.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-array
|
||||
*/
|
||||
|
||||
/**
|
||||
* Array subclass for the DataSchema Utility.
|
||||
* @class DataSchema.Array
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaArray = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.Array static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given Array data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} Array data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(LANG.isArray(data_in)) {
|
||||
if(LANG.isArray(schema.resultFields)) {
|
||||
// Parse results data
|
||||
data_out = SchemaArray._parseResults.call(this, schema.resultFields, data_in, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.results = data_in;
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("Array schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param fields {Array} Schema to parse against.
|
||||
* @param array_in {Array} Array to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(fields, array_in, data_out) {
|
||||
var results = [],
|
||||
result, item, type, field, key, value, i, j;
|
||||
|
||||
for(i=array_in.length-1; i>-1; i--) {
|
||||
result = {};
|
||||
item = array_in[i];
|
||||
type = (LANG.isObject(item) && !LANG.isFunction(item)) ? 2 : (LANG.isArray(item)) ? 1 : (LANG.isString(item)) ? 0 : -1;
|
||||
if(type > 0) {
|
||||
for(j=fields.length-1; j>-1; j--) {
|
||||
field = fields[j];
|
||||
key = (!LANG.isUndefined(field.key)) ? field.key : field;
|
||||
value = (!LANG.isUndefined(item[key])) ? item[key] : item[j];
|
||||
result[key] = Y.DataSchema.Base.parse.call(this, value, field);
|
||||
}
|
||||
}
|
||||
else if(type === 0) {
|
||||
result = item;
|
||||
}
|
||||
else {
|
||||
//TODO: null or {}?
|
||||
result = null;
|
||||
}
|
||||
results[i] = result;
|
||||
}
|
||||
data_out.results = results;
|
||||
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.Array = Y.mix(SchemaArray, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['dataschema-base']});
|
||||
|
||||
YUI.add('dataschema-text', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with delimited text data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-text
|
||||
*/
|
||||
|
||||
/**
|
||||
* Text subclass for the DataSchema Utility.
|
||||
* @class DataSchema.Text
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaText = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.Text static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given delimited text data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} Text data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(LANG.isString(data_in) && LANG.isString(schema.resultDelimiter)) {
|
||||
// Parse results data
|
||||
data_out = SchemaText._parseResults.call(this, schema, data_in, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("Text schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Array} Schema to parse against.
|
||||
* @param text_in {String} Text to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, text_in, data_out) {
|
||||
var resultDelim = schema.resultDelimiter,
|
||||
results = [],
|
||||
results_in, fields_in, result, item, fields, field, key, value, i, j,
|
||||
|
||||
// Delete final delimiter at end of string if there
|
||||
tmpLength = text_in.length-resultDelim.length;
|
||||
if(text_in.substr(tmpLength) == resultDelim) {
|
||||
text_in = text_in.substr(0, tmpLength);
|
||||
}
|
||||
|
||||
// Split into results
|
||||
results_in = text_in.split(schema.resultDelimiter);
|
||||
|
||||
for(i=results_in.length-1; i>-1; i--) {
|
||||
result = {};
|
||||
item = results_in[i];
|
||||
|
||||
if(LANG.isString(schema.fieldDelimiter)) {
|
||||
fields_in = item.split(schema.fieldDelimiter);
|
||||
|
||||
if(LANG.isArray(schema.resultFields)) {
|
||||
fields = schema.resultFields;
|
||||
for(j=fields.length-1; j>-1; j--) {
|
||||
field = fields[j];
|
||||
key = (!LANG.isUndefined(field.key)) ? field.key : field;
|
||||
value = (!LANG.isUndefined(fields_in[key])) ? fields_in[key] : fields_in[j];
|
||||
result[key] = Y.DataSchema.Base.parse.call(this, value, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
result = item;
|
||||
}
|
||||
|
||||
results[i] = result;
|
||||
}
|
||||
data_out.results = results;
|
||||
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.Text = Y.mix(SchemaText, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.2.0' ,{requires:['dataschema-base']});
|
||||
|
||||
|
||||
|
||||
YUI.add('dataschema', function(Y){}, '3.2.0' ,{use:['dataschema-base','dataschema-json','dataschema-xml','dataschema-array','dataschema-text']});
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("datasource-arrayschema",function(B){var A=function(){A.superclass.constructor.apply(this,arguments);};B.mix(A,{NS:"schema",NAME:"dataSourceArraySchema",ATTRS:{schema:{}}});B.extend(A,B.Plugin.Base,{initializer:function(C){this.doBefore("_defDataFn",this._beforeDefDataFn);},_beforeDefDataFn:function(E){var D=(B.DataSource.IO&&(this.get("host") instanceof B.DataSource.IO)&&B.Lang.isString(E.data.responseText))?E.data.responseText:E.data,C=B.DataSchema.Array.apply.call(this,this.get("schema"),D);if(!C){C={meta:{},results:D};}this.get("host").fire("response",B.mix({response:C},E));return new B.Do.Halt("DataSourceArraySchema plugin halted _defDataFn");}});B.namespace("Plugin").DataSourceArraySchema=A;},"3.2.0",{requires:["plugin","datasource-local","dataschema-array"]});
|
||||
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("datasource-cache",function(C){var B=function(){};C.mix(B,{NS:"cache",NAME:"dataSourceCacheExtension"});B.prototype={initializer:function(D){this.doBefore("_defRequestFn",this._beforeDefRequestFn);this.doBefore("_defResponseFn",this._beforeDefResponseFn);},_beforeDefRequestFn:function(E){var D=(this.retrieve(E.request))||null;if(D&&D.response){this.get("host").fire("response",C.mix(D,E));return new C.Do.Halt("DataSourceCache extension halted _defRequestFn");}},_beforeDefResponseFn:function(D){if(D.response&&!D.cached){this.add(D.request,D.response);}}};C.namespace("Plugin").DataSourceCacheExtension=B;function A(F){var E=F&&F.cache?F.cache:C.Cache,G=C.Base.create("dataSourceCache",E,[C.Plugin.Base,C.Plugin.DataSourceCacheExtension]),D=new G(F);G.NS="tmpClass";return D;}C.mix(A,{NS:"cache",NAME:"dataSourceCache"});C.namespace("Plugin").DataSourceCache=A;},"3.2.0",{requires:["datasource-local"]});
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.com/yui/license.html
|
||||
version: 3.2.0
|
||||
build: 2676
|
||||
*/
|
||||
YUI.add("datasource-function",function(B){var A=B.Lang,C=function(){C.superclass.constructor.apply(this,arguments);};B.mix(C,{NAME:"dataSourceFunction",ATTRS:{source:{validator:A.isFunction}}});B.extend(C,B.DataSource.Local,{_defRequestFn:function(G){var F=this.get("source"),D;if(F){try{D=F(G.request,this,G);this.fire("data",B.mix({data:D},G));}catch(E){G.error=E;this.fire("data",G);}}else{G.error=new Error("Function data failure");this.fire("data",G);}return G.tId;}});B.DataSource.Function=C;},"3.2.0",{requires:["datasource-local"]});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user