Permalink
Browse files

Gallery Build Tag: gallery-2011.02.23-19-01

  • Loading branch information...
1 parent ce4b5b8 commit 944498e49ca03236667c49877a8871e22d67fda3 YUI Builder committed Feb 23, 2011
View
41 build/gallery-accordion/gallery-accordion-debug.js
@@ -266,6 +266,19 @@ Y.Accordion = Y.Base.create( AccName, Y.Widget, [], {
},
+ /**
+ * Binds an event to Accordion's contentBox.
+ *
+ * @method _bindItemChosenEvent
+ * @protected
+ */
+ _bindItemChosenEvent: function(itemChosenEvent) {
+ var contentBox;
+
+ contentBox = this.get( CONTENT_BOX );
+ contentBox.delegate( itemChosenEvent, Y.bind( this._onItemChosenEvent, this ), '.yui3-widget-hd' );
+ },
+
/**
* Contains items for collapsing
* @property _forCollapsing
@@ -1340,18 +1353,26 @@ Y.Accordion = Y.Base.create( AccName, Y.Widget, [], {
/**
- * Add listener to <code>itemChosen</code> event in Accordion's content box
+ * Add listener(s) to <code>itemChosen</code> event in Accordion's content box.
+ * If itemChosen is an Array, this function will invoke multiple times _bindItemChosenEvent
*
* @method bindUI
* @protected
*/
bindUI: function(){
- var contentBox, itemChosenEvent;
+ var i, itemChosenEvent, length;
- contentBox = this.get( CONTENT_BOX );
itemChosenEvent = this.get( 'itemChosen' );
- contentBox.delegate( itemChosenEvent, Y.bind( this._onItemChosenEvent, this ), '.yui3-widget-hd' );
+ if( Lang.isArray(itemChosenEvent) ){
+ length = itemChosenEvent.length;
+
+ for( i = 0; i < length; i++ ) {
+ this._bindItemChosenEvent(itemChosenEvent[i]);
+ }
+ } else {
+ this._bindItemChosenEvent(itemChosenEvent);
+ }
},
@@ -1647,16 +1668,18 @@ Y.Accordion = Y.Base.create( AccName, Y.Widget, [], {
ATTRS : {
/**
* @description The event on which Accordion should listen for user interactions.
- * The value can be also mousedown or mouseup. Mousedown event can be used if
- * drag&drop is not enabled
+ * The value can be also 'mousedown', 'mouseup' or ['mouseenter','click'].
+ * Mousedown event can be used if drag&drop is not enabled.
*
* @attribute itemChosen
* @default click
- * @type String
+ * @type String|Array
*/
itemChosen: {
value: "click",
- validator: Lang.isString
+ validator: function( value ) {
+ return Lang.isString(value) || Lang.isArray(value);
+ }
},
/**
@@ -2890,4 +2913,4 @@ Y.AccordionItem = Y.Base.create( AccItemName, Y.Widget, [Y.WidgetStdMod], {
-}, 'gallery-2011.02.18-23-10' ,{optional:['dd-constrain', 'dd-proxy', 'dd-drop'], requires:['event', 'anim-easing', 'widget', 'widget-stdmod', 'json-parse']});
+}, 'gallery-2011.02.23-19-01' ,{optional:['dd-constrain', 'dd-proxy', 'dd-drop'], requires:['event', 'anim-easing', 'widget', 'widget-stdmod', 'json-parse']});
View
8 build/gallery-accordion/gallery-accordion-min.js
@@ -1,4 +1,4 @@
-YUI.add("gallery-accordion",function(a){(function(){var U=a.Lang,v=a.Node,z=a.Anim,h=a.Easing,n="accordion",x=a.WidgetStdMod,S=document.compatMode=="BackCompat",t=S&&a.UA.ie>0,u=t?1:0,j=a.ClassNameManager.getClassName,w="yui3-accordion-item",F=j(n,"proxyel","visible"),H=j(n,"graggroup"),B="beforeItemAdd",E="itemAdded",d="beforeItemRemove",I="itemRemoved",c="beforeItemResized",P="itemResized",D="beforeItemExpand",G="beforeItemCollapse",k="itemExpanded",M="itemCollapsed",J="beforeItemReorder",r="beforeEndItemReorder",s="itemReordered",K="default",o="animation",p="alwaysVisible",e="expanded",C="collapseOthersOnExpand",y="items",T="contentHeight",b="iconClose",f="iconAlwaysVisible",g="stretch",R="px",A="contentBox",N="boundingBox",i="srcNode",L="rendered",O="bodyContent",q="children",l="parentNode",Q="node",m="data";a.Accordion=a.Base.create(n,a.Widget,[],{initializer:function(V){this.after("render",a.bind(this._afterRender,this));},destructor:function(){var V,Y,W,X;V=this.get(y);X=V.length;for(W=X-1;W>=0;W--){Y=V[W];V.splice(W,1);this._removeItemHandles(Y);Y.destroy();}},_forCollapsing:{},_forExpanding:{},_animations:{},_itemsHandles:{},_removeItemHandles:function(X){var W,V;W=this._itemsHandles[X];for(V in W){if(W.hasOwnProperty(V)){V=W[V];V.detach();}}delete this._itemsHandles[X];},_getNodeOffsetHeight:function(X){var V,W;if(X instanceof v){if(X.hasMethod("getBoundingClientRect")){W=X.invoke("getBoundingClientRect");if(W){V=W.bottom-W.top;return V;}}else{V=X.get("offsetHeight");return a.Lang.isValue(V)?V:0;}}else{if(X){V=X.offsetHeight;return a.Lang.isValue(V)?V:0;}}return 0;},_setItemProperties:function(X,Z,W){var V,Y;V=X.get(p);Y=X.get(e);if(Z!=Y){X.set(e,Z,{internalCall:true});}if(W!==V){X.set(p,W,{internalCall:true});}},_setItemUI:function(W,X,V){W.markAsExpanded(X);W.markAsAlwaysVisible(V);},_afterRender:function(W){var V;V=this.get("resizeEvent");this._setUpResizing(V);this.after("resizeEventChange",a.bind(this._afterResizeEventChange,this));},_afterResizeEventChange:function(V){this._setUpResizing(V.newVal);},_onItemChosen:function(aa,ab,V){var Z,X,Y,W;Z={};W=this.get(C);X=aa.get(p);Y=aa.get(e);if(V){this.removeItem(aa);return;}else{if(ab){if(Y){X=!X;Y=X?true:Y;this._setItemProperties(aa,Y,X);this._setItemUI(aa,Y,X);return;}else{this._forExpanding[aa]={"item":aa,alwaysVisible:true};if(W){Z[aa]={"item":aa};this._storeItemsForCollapsing(Z);}}}else{if(Y){this._forCollapsing[aa]={"item":aa};}else{this._forExpanding[aa]={"item":aa,"alwaysVisible":X};if(W){Z[aa]={"item":aa};this._storeItemsForCollapsing(Z);}}}}this._processItems();},_adjustStretchItems:function(){var W=this.get(y),X,V;X=this._getHeightPerStretchItem();V=this._forExpanding;a.Array.each(W,function(ac,ab,aa){var Y,ae,ad,af,Z;af=ac.get(T);Z=ac.get(e);if(!V[ac]&&af.method===g&&Z){ad=this._animations[ac];if(ad){ad.stop();}Y=ac.getStdModNode(x.BODY);ae=this._getNodeOffsetHeight(Y);if(X<ae){this._processCollapsing(ac,X);}else{if(X>ae){this._processExpanding(ac,X);}}}},this);return X;},_getHeightPerStretchItem:function(){var V,X,W=0;X=this.get(y);V=this.get(N).get("clientHeight");a.Array.each(X,function(ac,ab,aa){var ad,Z,af,ae,Y;af=ac.getStdModNode(x.HEADER);ae=ac.get(T);Y=this._getNodeOffsetHeight(af);V-=Y;ad=!ac.get(e);if(ad){V-=u;return;}if(ae.method===g){W++;}else{Z=this._getItemContentHeight(ac);V-=Z;}},this);if(W>0){V/=W;}if(V<0){V=0;}return V;},_getItemContentHeight:function(X){var Z,W=0,V,Y;Z=X.get(T);if(Z.method==="auto"){V=X.getStdModNode(x.BODY);Y=V.get(q).item(0);W=Y?this._getNodeOffsetHeight(Y):0;}else{if(Z.method==="fixed"){W=Z.height;}else{W=this._getHeightPerStretchItem();}}return W;},_storeItemsForCollapsing:function(W){var V;W=W||{};V=this.get(y);a.Array.each(V,function(ab,aa,Z){var Y,X;Y=ab.get(e);X=ab.get(p);if(Y&&!X&&!W[ab]){this._forCollapsing[ab]={"item":ab};}},this);},_expandItem:function(X,V){var W=X.get(p);this._processExpanding(X,V);this._setItemUI(X,true,W);},_processExpanding:function(ac,ab,V){var W,X,Z,ad=false,aa,Y;Y=ac.getStdModNode(x.BODY);this.fire(c,{"item":ac});if(Y.get("clientHeight")<=u){ad=true;this.fire(D,{"item":ac});}if(!V&&this.get("useAnimation")){Z=ac.get(o)||{};W=new z({node:Y,to:{"height":ab}});W.on("end",a.bind(this._onExpandComplete,this,ac,ad));aa=this.get(o);W.set("duration",Z.duration||aa.duration);W.set("easing",Z.easing||aa.easing);X=this._animations[ac];if(X){X.stop();}ac.markAsExpanding(true);this._animations[ac]=W;W.run();}else{Y.setStyle("height",ab+R);this.fire(P,{"item":ac});if(ad){this.fire(k,{"item":ac});}}},_onExpandComplete:function(V,W){delete this._animations[V];V.markAsExpanding(false);this.fire(P,{"item":V});if(W){this.fire(k,{"item":V});}},_collapseItem:function(V){this._processCollapsing(V,u);this._setItemUI(V,false,false);},_processCollapsing:function(ac,ab,V){var W,X,Z,aa,Y,ad=(ab===u);Y=ac.getStdModNode(x.BODY);this.fire(c,{"item":ac});if(ad){this.fire(G,{"item":ac});}if(!V&&this.get("useAnimation")){Z=ac.get(o)||{};W=new z({node:Y,to:{"height":ab}});W.on("end",a.bind(this._onCollapseComplete,this,ac,ad));aa=this.get(o);W.set("duration",Z.duration||aa.duration);W.set("easing",Z.easing||aa.easing);X=this._animations[ac];if(X){X.stop();}ac.markAsCollapsing(true);this._animations[ac]=W;W.run();}else{Y.setStyle("height",ab+R);this.fire(P,{"item":ac});if(ad){this.fire(M,{"item":ac});}}},_onCollapseComplete:function(V,W){delete this._animations[V];V.markAsCollapsing(false);this.fire(P,{item:V});if(W){this.fire(M,{"item":V});}},_initItemDragDrop:function(W){var aa,V,Z,X,Y;aa=W.getStdModNode(x.HEADER);if(aa.dd){return;}Z=this.get(N);X=W.get(N);V=new a.DD.Drag({node:aa,groups:[H]}).plug(a.Plugin.DDProxy,{moveOnEnd:false}).plug(a.Plugin.DDConstrained,{constrain2node:Z});Y=new a.DD.Drop({node:X,groups:[H]});V.on("drag:start",a.bind(this._onDragStart,this,V));V.on("drag:end",a.bind(this._onDragEnd,this,V));V.after("drag:end",a.bind(this._afterDragEnd,this,V));V.on("drag:drophit",a.bind(this._onDropHit,this,V));},_onDragStart:function(V,Y){var X,W;W=this.getItem(V.get(Q).get(l));
-X=V.get("dragNode");X.addClass(F);X.set("innerHTML",W.get("label"));return this.fire(J,{"item":W});},_onDragEnd:function(V,Y){var X,W;X=V.get("dragNode");X.removeClass(F);X.set("innerHTML","");W=this.getItem(V.get(Q).get(l));return this.fire(r,{"item":W});},_afterDragEnd:function(V,Y){var W,X;X=V.get(m);if(X.drophit){W=this.getItem(V.get(Q).get(l));V.set(m,{drophit:false});return this.fire(s,{"item":W});}return true;},_onDropHit:function(ae,aa){var Z,ad,W,ac,Y,V,ab,X,af;af=this.getItem(ae.get(Q).get(l));X=this.getItem(aa.drop.get(Q));if(X===af){return false;}Z=this.getItemIndex(af);ad=this.getItemIndex(X);W=X.get(N);ac=af.get(N);Y=this.get(A);V=false;ab=this.get(y);if(ad<Z){V=true;}Y.removeChild(ac);if(V){Y.insertBefore(ac,W);ab.splice(Z,1);ab.splice(ad,0,af);}else{Y.insertBefore(ac,W.next(w));ab.splice(ad+1,0,af);ab.splice(Z,1);}ae.set(m,{drophit:true});return true;},_processItems:function(){var X,W,Y,aa,V,ab,Z;X=this._forCollapsing;W=this._forExpanding;this._setItemsProperties();for(Z in X){if(X.hasOwnProperty(Z)){Y=X[Z];this._collapseItem(Y.item);}}aa=this._adjustStretchItems();for(Z in W){if(W.hasOwnProperty(Z)){Y=W[Z];Z=Y.item;V=aa;ab=Z.get(T);if(ab.method!==g){V=this._getItemContentHeight(Z);}this._expandItem(Z,V);}}this._forCollapsing={};this._forExpanding={};},_setItemsProperties:function(){var X,W,V;X=this._forCollapsing;W=this._forExpanding;for(V in X){if(X.hasOwnProperty(V)){V=X[V];this._setItemProperties(V.item,false,false);}}for(V in W){if(W.hasOwnProperty(V)){V=W[V];this._setItemProperties(V.item,true,V.alwaysVisible);}}},_afterItemExpand:function(Z){var X,Y,W,V;if(Z.internalCall){return;}X=Z.newVal;Y=Z.currentTarget;W=Y.get(p);V=this.get(C);if(X){this._forExpanding[Y]={"item":Y,"alwaysVisible":W};if(V){this._storeItemsForCollapsing();}}else{this._forCollapsing[Y]={"item":Y};}this._processItems();},_afterItemAlwaysVisible:function(Y){var X,V,W;if(Y.internalCall){return;}V=Y.newVal;X=Y.currentTarget;W=X.get(e);if(V){if(W){this._setItemProperties(X,true,true);this._setItemUI(X,true,true);return;}else{this._forExpanding[X]={"item":X,"alwaysVisible":true};this._storeItemsForCollapsing();}}else{if(W){this._setItemUI(X,true,false);return;}else{return;}}this._processItems();},_afterContentHeight:function(aa){var Y,W,V,Z,X;Y=aa.currentTarget;this._adjustStretchItems();if(aa.newVal.method!==g){X=Y.get(e);W=this._getItemContentHeight(Y);V=Y.getStdModNode(x.BODY);Z=this._getNodeOffsetHeight(V);if(W<Z){this._processCollapsing(Y,W,!X);}else{if(W>Z){this._processExpanding(Y,W,!X);}}}},_afterContentUpdate:function(aa){var X,V,Z,W,ab,Y;X=aa.currentTarget;ab=X.get("contentHeight").method==="auto";W=X.get(e);V=X.getStdModNode(x.BODY);Z=this._getNodeOffsetHeight(V);if(ab&&W&&aa.src!==a.Widget.UI_SRC){a.later(0,this,function(){var ac=this._getItemContentHeight(X);if(ac!==Z){Y=this._animations[X];if(Y){Y.stop();}this._adjustStretchItems();if(ac<Z){this._processCollapsing(X,ac,!W);}else{if(ac>Z){this._processExpanding(X,ac,!W);}}}});}},_setUpResizing:function(V){if(this._resizeEventHandle){this._resizeEventHandle.detach();}if(V===K){this._resizeEventHandle=a.on("windowresize",a.bind(this._adjustStretchItems,this));}else{this._resizeEventHandle=V.sourceObject.on(V.resizeEvent,a.bind(this._adjustStretchItems,this));}},renderUI:function(){var Y,X,W,V;Y=this.get(i);W=this.get(A);V=Y.get("id");W.set("id",V);X=Y.all("> ."+w);X.each(function(ac,Z,ab){var aa;if(!this.getItem(ac)){aa=new a.AccordionItem({srcNode:ac,id:ac.get("id")});this.addItem(aa);}},this);},bindUI:function(){var V,W;V=this.get(A);W=this.get("itemChosen");V.delegate(W,a.bind(this._onItemChosenEvent,this),".yui3-widget-hd");},_onItemChosenEvent:function(aa){var ac,ab,X,Y,W,Z,V;ac=aa.currentTarget;ab=ac.get(l);X=this.getItem(ab);Y=X.get(f);W=X.get(b);Z=(Y===aa.target);V=(W===aa.target);this._onItemChosen(X,Z,V);},addItem:function(ah,X){var ab,af,Z,aa,V,ae,ad,ag,Y,ac,W;ac=this.fire(B,{"item":ah});if(!ac){return false;}ae=this.get(y);ad=this.get(A);Y=ah.get(A);if(!Y.inDoc()){if(X){V=this.getItemIndex(X);if(V<0){return false;}ae.splice(V,0,ah);ad.insertBefore(Y,X.get(N));}else{ae.push(ah);ad.insertBefore(Y,null);}}else{W=ad.get(q);ac=W.some(function(ak,aj,ai){if(ak===Y){ae.splice(aj,0,ah);return true;}else{return false;}},this);if(!ac){return false;}}Z=ah.getStdModNode(x.BODY);aa=ah.get(O);if(!Z&&!aa){ah.set(O,"");}if(!ah.get(L)){ah.render();}ab=ah.get(e);af=ah.get(p);ab=ab||af;if(ab){this._forExpanding[ah]={"item":ah,"alwaysVisible":af};}else{this._forCollapsing[ah]={"item":ah};}this._processItems();if(this.get("reorderItems")){this._initItemDragDrop(ah);}ag=this._itemsHandles[ah];if(!ag){ag={};}ag={"expandedChange":ah.after("expandedChange",a.bind(this._afterItemExpand,this)),"alwaysVisibleChange":ah.after("alwaysVisibleChange",a.bind(this._afterItemAlwaysVisible,this)),"contentHeightChange":ah.after("contentHeightChange",a.bind(this._afterContentHeight,this)),"contentUpdate":ah.after("contentUpdate",a.bind(this._afterContentUpdate,this))};this._itemsHandles[ah]=ag;this.fire(E,{"item":ah});return true;},removeItem:function(W){var V,aa,Y=null,X,Z;V=this.get(y);if(U.isNumber(W)){X=W;}else{if(W instanceof a.AccordionItem){X=this.getItemIndex(W);}else{return null;}}if(X>=0){Z=this.fire(d,{item:W});if(!Z){return null;}Y=V.splice(X,1)[0];this._removeItemHandles(Y);aa=Y.get(N);aa.remove();this._adjustStretchItems();this.fire(I,{item:W});}return Y;},getItem:function(X){var V=this.get(y),W=null;if(U.isNumber(X)){W=V[X];return(W instanceof a.AccordionItem)?W:null;}else{if(X instanceof v){a.Array.some(V,function(ab,aa,Z){var Y=ab.get(A);if(Y===X){W=ab;return true;}else{return false;}},this);}}return W;},getItemIndex:function(X){var W=-1,V;if(X instanceof a.AccordionItem){V=this.get(y);a.Array.some(V,function(aa,Z,Y){if(aa===X){W=Z;return true;}else{return false;}},this);}return W;},_findStdModSection:function(V){return this.get(i).one("> ."+a.WidgetStdMod.SECTION_CLASS_NAMES[V]);},CONTENT_TEMPLATE:null},{NAME:n,ATTRS:{itemChosen:{value:"click",validator:U.isString},items:{value:[],readOnly:true,validator:U.isArray},resizeEvent:{value:K,validator:function(V){if(V===K){return true;
-}else{if(U.isObject(V)){if(U.isValue(V.sourceObject)&&U.isValue(V.resizeEvent)){return true;}}}return false;}},useAnimation:{value:true,validator:U.isBoolean},animation:{value:{duration:1,easing:h.easeOutStrong},validator:function(V){return U.isObject(V)&&U.isNumber(V.duration)&&U.isFunction(V.easing);}},reorderItems:{value:false,validator:function(V){return U.isBoolean(V)&&!U.isUndefined(a.DD);}},collapseOthersOnExpand:{value:true,validator:U.isBoolean}}});}());(function(){var U=a.Lang,B=a.Node,p=a.JSON,C=a.WidgetStdMod,D="accordion-item",n=a.ClassNameManager.getClassName,d=n(D,"iconexpanded","expanding"),S=n(D,"iconexpanded","collapsing"),o=n(D,"icon"),k=n(D,"label"),O=n(D,"iconalwaysvisible"),F=n(D,"icons"),M=n(D,"iconexpanded"),J=n(D,"iconclose"),q=n(D,"iconclose","hidden"),s=n(D,"iconexpanded","on"),l=n(D,"iconexpanded","off"),e=n(D,"iconalwaysvisible","on"),K=n(D,"iconalwaysvisible","off"),y=n(D,"expanded"),v=n(D,"closable"),H=n(D,"alwaysvisible"),I=n(D,"contentheight"),L="title",c="strings",Q="rendered",h="className",E="auto",j="stretch",w="fixed",t=".yui3-widget-hd",z=".",N=".yui3-widget-hd "+z,R="innerHTML",T="iconsContainer",G="icon",r="nodeLabel",g="iconAlwaysVisible",A="iconExpanded",b="iconClose",P="href",u="#",f="yuiConfig",i=/^(?:true|yes|1)$/,m=/^auto\s*/,V=/^stretch\s*/,x=/^fixed-\d+/;a.AccordionItem=a.Base.create(D,a.Widget,[a.WidgetStdMod],{_createHeader:function(){var ae,ac,ad,aa,ab,Z,X,W,Y;ab=this.get(G);Z=this.get(r);X=this.get(A);W=this.get(g);Y=this.get(b);aa=this.get(T);ad=this.get(c);ae=this.get("closable");ac=a.AccordionItem.TEMPLATES;if(!ab){ab=B.create(ac.icon);this.set(G,ab);}if(!Z){Z=B.create(ac.label);this.set(r,Z);}else{if(!Z.hasAttribute(P)){Z.setAttribute(P,u);}}Z.setContent(this.get("label"));if(!aa){aa=B.create(ac.iconsContainer);this.set(T,aa);}if(!W){W=B.create(ac.iconAlwaysVisible);W.setAttribute(L,ad.title_always_visible_off);this.set(g,W);}else{if(!W.hasAttribute(P)){W.setAttribute(P,u);}}if(!X){X=B.create(ac.iconExpanded);X.setAttribute(L,ad.title_iconexpanded_off);this.set(A,X);}else{if(!X.hasAttribute(P)){X.setAttribute(P,u);}}if(!Y){Y=B.create(ac.iconClose);Y.setAttribute(L,ad.title_iconclose);this.set(b,Y);}else{if(!Y.hasAttribute(P)){Y.setAttribute(P,u);}}if(ae){Y.removeClass(q);}else{Y.addClass(q);}this._addHeaderComponents();},_addHeaderComponents:function(){var ac,X,ab,Y,aa,Z,W;X=this.get(G);ab=this.get(r);aa=this.get(A);Z=this.get(g);W=this.get(b);Y=this.get(T);ac=this.getStdModNode(C.HEADER);if(!ac){ac=new B(document.createDocumentFragment());ac.appendChild(X);ac.appendChild(ab);ac.appendChild(Y);Y.appendChild(Z);Y.appendChild(aa);Y.appendChild(W);this.setStdModContent(C.HEADER,ac,C.REPLACE);}else{if(!ac.contains(X)){if(ac.contains(ab)){ac.insertBefore(X,ab);}else{ac.appendChild(X);}}if(!ac.contains(ab)){ac.appendChild(ab);}if(!ac.contains(Y)){ac.appendChild(Y);}if(!Y.contains(Z)){Y.appendChild(Z);}if(!Y.contains(aa)){Y.appendChild(aa);}if(!Y.contains(W)){Y.appendChild(W);}}},_labelChanged:function(X){var W;if(this.get(Q)){W=this.get(r);W.set(R,X.newVal);}},_closableChanged:function(X){var W;if(this.get(Q)){W=this.get(b);if(X.newVal){W.removeClass(q);}else{W.addClass(q);}}},initializer:function(W){this.after("labelChange",a.bind(this._labelChanged,this));this.after("closableChange",a.bind(this._closableChanged,this));},destructor:function(){},renderUI:function(){this._createHeader();},bindUI:function(){var W=this.get("contentBox");W.delegate("click",a.bind(this._onLinkClick,this),t+" a");},_onLinkClick:function(W){W.preventDefault();},markAsAlwaysVisible:function(X){var Y,W;Y=this.get(g);W=this.get(c);if(X){if(!Y.hasClass(e)){Y.replaceClass(K,e);Y.set(L,W.title_always_visible_on);return true;}}else{if(Y.hasClass(e)){Y.replaceClass(e,K);Y.set(L,W.title_always_visible_off);return true;}}return false;},markAsExpanded:function(X){var W,Y;Y=this.get(A);W=this.get(c);if(X){if(!Y.hasClass(s)){Y.replaceClass(l,s);Y.set(L,W.title_iconexpanded_on);return true;}}else{if(Y.hasClass(s)){Y.replaceClass(s,l);Y.set(L,W.title_iconexpanded_off);return true;}}return false;},markAsExpanding:function(X){var W=this.get(A);if(X){if(!W.hasClass(d)){W.addClass(d);return true;}}else{if(W.hasClass(d)){W.removeClass(d);return true;}}return false;},markAsCollapsing:function(W){var X=this.get(A);if(W){if(!X.hasClass(S)){X.addClass(S);return true;}}else{if(X.hasClass(S)){X.removeClass(S);return true;}}return false;},resize:function(){this.fire("contentUpdate");},_extractFixedMethodValue:function(aa){var X,Z,Y,W=null;for(X=6,Z=aa.length;X<Z;X++){Y=aa.charAt(X);Y=parseInt(Y,10);if(U.isNumber(Y)){W=(W*10)+Y;}else{break;}}return W;},_validateIcon:function(W){return !this.get(Q)||W;},_validateNodeLabel:function(W){return !this.get(Q)||W;},_validateIconsContainer:function(W){return !this.get(Q)||W;},_validateIconExpanded:function(W){return !this.get(Q)||W;},_validateIconAlwaysVisible:function(W){return !this.get(Q)||W;},_validateIconClose:function(W){return !this.get(Q)||W;},_setIcon:function(W){return a.one(W)||null;},_setNodeLabel:function(W){return a.one(W)||null;},_setIconsContainer:function(W){return a.one(W)||null;},_setIconExpanded:function(W){return a.one(W)||null;},_setIconAlwaysVisible:function(W){return a.one(W)||null;},_setIconClose:function(W){return a.one(W)||null;},_applyParser:function(W){var X;X=this.get("srcNode");if(X){this._parsedYUIConfig=X.getAttribute(f);if(this._parsedYUIConfig){this._parsedYUIConfig=p.parse(this._parsedYUIConfig);}}a.AccordionItem.superclass._applyParser.apply(this,arguments);delete this._parsedYUIConfig;},_findStdModSection:function(W){return this.get("srcNode").one("> ."+a.WidgetStdMod.SECTION_CLASS_NAMES[W]);},CONTENT_TEMPLATE:null},{NAME:D,ATTRS:{icon:{value:null,validator:function(W){return this._validateIcon(W);},setter:function(W){return this._setIcon(W);}},label:{value:"&#160;",validator:U.isString},nodeLabel:{value:null,validator:function(W){return this._validateNodeLabel(W);},setter:function(W){return this._setNodeLabel(W);
-}},iconsContainer:{value:null,validator:function(W){return this._validateIconsContainer(W);},setter:function(W){return this._setIconsContainer(W);}},iconExpanded:{value:null,validator:function(W){return this._validateIconExpanded(W);},setter:function(W){return this._setIconExpanded(W);}},iconAlwaysVisible:{value:null,validator:function(W){return this._validateIconAlwaysVisible(W);},setter:function(W){return this._setIconAlwaysVisible(W);}},iconClose:{value:null,validator:function(W){return this._validateIconClose(W);},setter:function(W){return this._setIconClose(W);}},expanded:{value:false,validator:U.isBoolean},contentHeight:{value:{method:E},validator:function(W){if(U.isObject(W)){if(W.method===E){return true;}else{if(W.method===j){return true;}else{if(W.method===w&&U.isNumber(W.height)&&W.height>=0){return true;}}}}return false;}},alwaysVisible:{value:false,validator:U.isBoolean},animation:{value:{},validator:U.isObject},strings:{value:{title_always_visible_off:"Click to set always visible on",title_always_visible_on:"Click to set always visible off",title_iconexpanded_off:"Click to expand",title_iconexpanded_on:"Click to collapse",title_iconclose:"Click to close"}},closable:{value:false,validator:U.isBoolean}},HTML_PARSER:{icon:N+o,label:function(Z){var Y,aa,X,W;X=this._parsedYUIConfig;if(X&&U.isValue(X.label)){return X.label;}W=Z.getAttribute("data-label");if(W){return W;}aa=N+k;Y=Z.one(aa);return(Y)?Y.get(R):null;},nodeLabel:N+k,iconsContainer:N+F,iconAlwaysVisible:N+O,iconExpanded:N+M,iconClose:N+J,expanded:function(Y){var X,W;X=this._parsedYUIConfig;if(X&&U.isBoolean(X.expanded)){return X.expanded;}W=Y.getAttribute("data-expanded");if(W){return i.test(W);}return Y.hasClass(y);},alwaysVisible:function(Y){var X,W;X=this._parsedYUIConfig;if(X&&U.isBoolean(X.alwaysVisible)){W=X.alwaysVisible;}else{W=Y.getAttribute("data-alwaysvisible");if(W){W=i.test(W);}else{W=Y.hasClass(H);}}if(W){this.set("expanded",true,{internalCall:true});}return W;},closable:function(Y){var X,W;X=this._parsedYUIConfig;if(X&&U.isBoolean(X.closable)){return X.closable;}W=Y.getAttribute("data-closable");if(W){return i.test(W);}return Y.hasClass(v);},contentHeight:function(ac){var aa,ab,W=0,X,Z,Y;Z=this._parsedYUIConfig;if(Z&&Z.contentHeight){return Z.contentHeight;}Y=ac.getAttribute("data-contentheight");if(m.test(Y)){return{method:E};}else{if(V.test(Y)){return{method:j};}else{if(x.test(Y)){W=this._extractFixedMethodValue(Y);return{method:w,height:W};}}}ab=ac.get(h);aa=I+"-";X=ab.indexOf(aa,0);if(X>=0){X+=aa.length;ab=ab.substring(X);if(m.test(ab)){return{method:E};}else{if(V.test(ab)){return{method:j};}else{if(x.test(ab)){W=this._extractFixedMethodValue(ab);return{method:w,height:W};}}}}return null;}},TEMPLATES:{icon:'<a class="'+o+'"></a>',label:'<a href="#" class="'+k+'"></a>',iconsContainer:'<div class="'+F+'"></div>',iconExpanded:['<a href="#" class="',M," ",l,'"></a>'].join(""),iconAlwaysVisible:['<a href="#" class="',O," ",K,'"></a>'].join(""),iconClose:['<a href="#" class="',J," ",q,'"></a>'].join("")}});}());},"gallery-2011.02.18-23-10",{optional:["dd-constrain","dd-proxy","dd-drop"],requires:["event","anim-easing","widget","widget-stdmod","json-parse"]});
+YUI.add("gallery-accordion",function(a){(function(){var U=a.Lang,v=a.Node,z=a.Anim,h=a.Easing,n="accordion",x=a.WidgetStdMod,S=document.compatMode=="BackCompat",t=S&&a.UA.ie>0,u=t?1:0,j=a.ClassNameManager.getClassName,w="yui3-accordion-item",F=j(n,"proxyel","visible"),H=j(n,"graggroup"),B="beforeItemAdd",E="itemAdded",d="beforeItemRemove",I="itemRemoved",c="beforeItemResized",P="itemResized",D="beforeItemExpand",G="beforeItemCollapse",k="itemExpanded",M="itemCollapsed",J="beforeItemReorder",r="beforeEndItemReorder",s="itemReordered",K="default",o="animation",p="alwaysVisible",e="expanded",C="collapseOthersOnExpand",y="items",T="contentHeight",b="iconClose",f="iconAlwaysVisible",g="stretch",R="px",A="contentBox",N="boundingBox",i="srcNode",L="rendered",O="bodyContent",q="children",l="parentNode",Q="node",m="data";a.Accordion=a.Base.create(n,a.Widget,[],{initializer:function(V){this.after("render",a.bind(this._afterRender,this));},destructor:function(){var V,Y,W,X;V=this.get(y);X=V.length;for(W=X-1;W>=0;W--){Y=V[W];V.splice(W,1);this._removeItemHandles(Y);Y.destroy();}},_bindItemChosenEvent:function(W){var V;V=this.get(A);V.delegate(W,a.bind(this._onItemChosenEvent,this),".yui3-widget-hd");},_forCollapsing:{},_forExpanding:{},_animations:{},_itemsHandles:{},_removeItemHandles:function(X){var W,V;W=this._itemsHandles[X];for(V in W){if(W.hasOwnProperty(V)){V=W[V];V.detach();}}delete this._itemsHandles[X];},_getNodeOffsetHeight:function(X){var V,W;if(X instanceof v){if(X.hasMethod("getBoundingClientRect")){W=X.invoke("getBoundingClientRect");if(W){V=W.bottom-W.top;return V;}}else{V=X.get("offsetHeight");return a.Lang.isValue(V)?V:0;}}else{if(X){V=X.offsetHeight;return a.Lang.isValue(V)?V:0;}}return 0;},_setItemProperties:function(X,Z,W){var V,Y;V=X.get(p);Y=X.get(e);if(Z!=Y){X.set(e,Z,{internalCall:true});}if(W!==V){X.set(p,W,{internalCall:true});}},_setItemUI:function(W,X,V){W.markAsExpanded(X);W.markAsAlwaysVisible(V);},_afterRender:function(W){var V;V=this.get("resizeEvent");this._setUpResizing(V);this.after("resizeEventChange",a.bind(this._afterResizeEventChange,this));},_afterResizeEventChange:function(V){this._setUpResizing(V.newVal);},_onItemChosen:function(aa,ab,V){var Z,X,Y,W;Z={};W=this.get(C);X=aa.get(p);Y=aa.get(e);if(V){this.removeItem(aa);return;}else{if(ab){if(Y){X=!X;Y=X?true:Y;this._setItemProperties(aa,Y,X);this._setItemUI(aa,Y,X);return;}else{this._forExpanding[aa]={"item":aa,alwaysVisible:true};if(W){Z[aa]={"item":aa};this._storeItemsForCollapsing(Z);}}}else{if(Y){this._forCollapsing[aa]={"item":aa};}else{this._forExpanding[aa]={"item":aa,"alwaysVisible":X};if(W){Z[aa]={"item":aa};this._storeItemsForCollapsing(Z);}}}}this._processItems();},_adjustStretchItems:function(){var W=this.get(y),X,V;X=this._getHeightPerStretchItem();V=this._forExpanding;a.Array.each(W,function(ac,ab,aa){var Y,ae,ad,af,Z;af=ac.get(T);Z=ac.get(e);if(!V[ac]&&af.method===g&&Z){ad=this._animations[ac];if(ad){ad.stop();}Y=ac.getStdModNode(x.BODY);ae=this._getNodeOffsetHeight(Y);if(X<ae){this._processCollapsing(ac,X);}else{if(X>ae){this._processExpanding(ac,X);}}}},this);return X;},_getHeightPerStretchItem:function(){var V,X,W=0;X=this.get(y);V=this.get(N).get("clientHeight");a.Array.each(X,function(ac,ab,aa){var ad,Z,af,ae,Y;af=ac.getStdModNode(x.HEADER);ae=ac.get(T);Y=this._getNodeOffsetHeight(af);V-=Y;ad=!ac.get(e);if(ad){V-=u;return;}if(ae.method===g){W++;}else{Z=this._getItemContentHeight(ac);V-=Z;}},this);if(W>0){V/=W;}if(V<0){V=0;}return V;},_getItemContentHeight:function(X){var Z,W=0,V,Y;Z=X.get(T);if(Z.method==="auto"){V=X.getStdModNode(x.BODY);Y=V.get(q).item(0);W=Y?this._getNodeOffsetHeight(Y):0;}else{if(Z.method==="fixed"){W=Z.height;}else{W=this._getHeightPerStretchItem();}}return W;},_storeItemsForCollapsing:function(W){var V;W=W||{};V=this.get(y);a.Array.each(V,function(ab,aa,Z){var Y,X;Y=ab.get(e);X=ab.get(p);if(Y&&!X&&!W[ab]){this._forCollapsing[ab]={"item":ab};}},this);},_expandItem:function(X,V){var W=X.get(p);this._processExpanding(X,V);this._setItemUI(X,true,W);},_processExpanding:function(ac,ab,V){var W,X,Z,ad=false,aa,Y;Y=ac.getStdModNode(x.BODY);this.fire(c,{"item":ac});if(Y.get("clientHeight")<=u){ad=true;this.fire(D,{"item":ac});}if(!V&&this.get("useAnimation")){Z=ac.get(o)||{};W=new z({node:Y,to:{"height":ab}});W.on("end",a.bind(this._onExpandComplete,this,ac,ad));aa=this.get(o);W.set("duration",Z.duration||aa.duration);W.set("easing",Z.easing||aa.easing);X=this._animations[ac];if(X){X.stop();}ac.markAsExpanding(true);this._animations[ac]=W;W.run();}else{Y.setStyle("height",ab+R);this.fire(P,{"item":ac});if(ad){this.fire(k,{"item":ac});}}},_onExpandComplete:function(V,W){delete this._animations[V];V.markAsExpanding(false);this.fire(P,{"item":V});if(W){this.fire(k,{"item":V});}},_collapseItem:function(V){this._processCollapsing(V,u);this._setItemUI(V,false,false);},_processCollapsing:function(ac,ab,V){var W,X,Z,aa,Y,ad=(ab===u);Y=ac.getStdModNode(x.BODY);this.fire(c,{"item":ac});if(ad){this.fire(G,{"item":ac});}if(!V&&this.get("useAnimation")){Z=ac.get(o)||{};W=new z({node:Y,to:{"height":ab}});W.on("end",a.bind(this._onCollapseComplete,this,ac,ad));aa=this.get(o);W.set("duration",Z.duration||aa.duration);W.set("easing",Z.easing||aa.easing);X=this._animations[ac];if(X){X.stop();}ac.markAsCollapsing(true);this._animations[ac]=W;W.run();}else{Y.setStyle("height",ab+R);this.fire(P,{"item":ac});if(ad){this.fire(M,{"item":ac});}}},_onCollapseComplete:function(V,W){delete this._animations[V];V.markAsCollapsing(false);this.fire(P,{item:V});if(W){this.fire(M,{"item":V});}},_initItemDragDrop:function(W){var aa,V,Z,X,Y;aa=W.getStdModNode(x.HEADER);if(aa.dd){return;}Z=this.get(N);X=W.get(N);V=new a.DD.Drag({node:aa,groups:[H]}).plug(a.Plugin.DDProxy,{moveOnEnd:false}).plug(a.Plugin.DDConstrained,{constrain2node:Z});Y=new a.DD.Drop({node:X,groups:[H]});V.on("drag:start",a.bind(this._onDragStart,this,V));V.on("drag:end",a.bind(this._onDragEnd,this,V));V.after("drag:end",a.bind(this._afterDragEnd,this,V));
+V.on("drag:drophit",a.bind(this._onDropHit,this,V));},_onDragStart:function(V,Y){var X,W;W=this.getItem(V.get(Q).get(l));X=V.get("dragNode");X.addClass(F);X.set("innerHTML",W.get("label"));return this.fire(J,{"item":W});},_onDragEnd:function(V,Y){var X,W;X=V.get("dragNode");X.removeClass(F);X.set("innerHTML","");W=this.getItem(V.get(Q).get(l));return this.fire(r,{"item":W});},_afterDragEnd:function(V,Y){var W,X;X=V.get(m);if(X.drophit){W=this.getItem(V.get(Q).get(l));V.set(m,{drophit:false});return this.fire(s,{"item":W});}return true;},_onDropHit:function(ae,aa){var Z,ad,W,ac,Y,V,ab,X,af;af=this.getItem(ae.get(Q).get(l));X=this.getItem(aa.drop.get(Q));if(X===af){return false;}Z=this.getItemIndex(af);ad=this.getItemIndex(X);W=X.get(N);ac=af.get(N);Y=this.get(A);V=false;ab=this.get(y);if(ad<Z){V=true;}Y.removeChild(ac);if(V){Y.insertBefore(ac,W);ab.splice(Z,1);ab.splice(ad,0,af);}else{Y.insertBefore(ac,W.next(w));ab.splice(ad+1,0,af);ab.splice(Z,1);}ae.set(m,{drophit:true});return true;},_processItems:function(){var X,W,Y,aa,V,ab,Z;X=this._forCollapsing;W=this._forExpanding;this._setItemsProperties();for(Z in X){if(X.hasOwnProperty(Z)){Y=X[Z];this._collapseItem(Y.item);}}aa=this._adjustStretchItems();for(Z in W){if(W.hasOwnProperty(Z)){Y=W[Z];Z=Y.item;V=aa;ab=Z.get(T);if(ab.method!==g){V=this._getItemContentHeight(Z);}this._expandItem(Z,V);}}this._forCollapsing={};this._forExpanding={};},_setItemsProperties:function(){var X,W,V;X=this._forCollapsing;W=this._forExpanding;for(V in X){if(X.hasOwnProperty(V)){V=X[V];this._setItemProperties(V.item,false,false);}}for(V in W){if(W.hasOwnProperty(V)){V=W[V];this._setItemProperties(V.item,true,V.alwaysVisible);}}},_afterItemExpand:function(Z){var X,Y,W,V;if(Z.internalCall){return;}X=Z.newVal;Y=Z.currentTarget;W=Y.get(p);V=this.get(C);if(X){this._forExpanding[Y]={"item":Y,"alwaysVisible":W};if(V){this._storeItemsForCollapsing();}}else{this._forCollapsing[Y]={"item":Y};}this._processItems();},_afterItemAlwaysVisible:function(Y){var X,V,W;if(Y.internalCall){return;}V=Y.newVal;X=Y.currentTarget;W=X.get(e);if(V){if(W){this._setItemProperties(X,true,true);this._setItemUI(X,true,true);return;}else{this._forExpanding[X]={"item":X,"alwaysVisible":true};this._storeItemsForCollapsing();}}else{if(W){this._setItemUI(X,true,false);return;}else{return;}}this._processItems();},_afterContentHeight:function(aa){var Y,W,V,Z,X;Y=aa.currentTarget;this._adjustStretchItems();if(aa.newVal.method!==g){X=Y.get(e);W=this._getItemContentHeight(Y);V=Y.getStdModNode(x.BODY);Z=this._getNodeOffsetHeight(V);if(W<Z){this._processCollapsing(Y,W,!X);}else{if(W>Z){this._processExpanding(Y,W,!X);}}}},_afterContentUpdate:function(aa){var X,V,Z,W,ab,Y;X=aa.currentTarget;ab=X.get("contentHeight").method==="auto";W=X.get(e);V=X.getStdModNode(x.BODY);Z=this._getNodeOffsetHeight(V);if(ab&&W&&aa.src!==a.Widget.UI_SRC){a.later(0,this,function(){var ac=this._getItemContentHeight(X);if(ac!==Z){Y=this._animations[X];if(Y){Y.stop();}this._adjustStretchItems();if(ac<Z){this._processCollapsing(X,ac,!W);}else{if(ac>Z){this._processExpanding(X,ac,!W);}}}});}},_setUpResizing:function(V){if(this._resizeEventHandle){this._resizeEventHandle.detach();}if(V===K){this._resizeEventHandle=a.on("windowresize",a.bind(this._adjustStretchItems,this));}else{this._resizeEventHandle=V.sourceObject.on(V.resizeEvent,a.bind(this._adjustStretchItems,this));}},renderUI:function(){var Y,X,W,V;Y=this.get(i);W=this.get(A);V=Y.get("id");W.set("id",V);X=Y.all("> ."+w);X.each(function(ac,Z,ab){var aa;if(!this.getItem(ac)){aa=new a.AccordionItem({srcNode:ac,id:ac.get("id")});this.addItem(aa);}},this);},bindUI:function(){var V,X,W;X=this.get("itemChosen");if(U.isArray(X)){W=X.length;for(V=0;V<W;V++){this._bindItemChosenEvent(X[V]);}}else{this._bindItemChosenEvent(X);}},_onItemChosenEvent:function(aa){var ac,ab,X,Y,W,Z,V;ac=aa.currentTarget;ab=ac.get(l);X=this.getItem(ab);Y=X.get(f);W=X.get(b);Z=(Y===aa.target);V=(W===aa.target);this._onItemChosen(X,Z,V);},addItem:function(ah,X){var ab,af,Z,aa,V,ae,ad,ag,Y,ac,W;ac=this.fire(B,{"item":ah});if(!ac){return false;}ae=this.get(y);ad=this.get(A);Y=ah.get(A);if(!Y.inDoc()){if(X){V=this.getItemIndex(X);if(V<0){return false;}ae.splice(V,0,ah);ad.insertBefore(Y,X.get(N));}else{ae.push(ah);ad.insertBefore(Y,null);}}else{W=ad.get(q);ac=W.some(function(ak,aj,ai){if(ak===Y){ae.splice(aj,0,ah);return true;}else{return false;}},this);if(!ac){return false;}}Z=ah.getStdModNode(x.BODY);aa=ah.get(O);if(!Z&&!aa){ah.set(O,"");}if(!ah.get(L)){ah.render();}ab=ah.get(e);af=ah.get(p);ab=ab||af;if(ab){this._forExpanding[ah]={"item":ah,"alwaysVisible":af};}else{this._forCollapsing[ah]={"item":ah};}this._processItems();if(this.get("reorderItems")){this._initItemDragDrop(ah);}ag=this._itemsHandles[ah];if(!ag){ag={};}ag={"expandedChange":ah.after("expandedChange",a.bind(this._afterItemExpand,this)),"alwaysVisibleChange":ah.after("alwaysVisibleChange",a.bind(this._afterItemAlwaysVisible,this)),"contentHeightChange":ah.after("contentHeightChange",a.bind(this._afterContentHeight,this)),"contentUpdate":ah.after("contentUpdate",a.bind(this._afterContentUpdate,this))};this._itemsHandles[ah]=ag;this.fire(E,{"item":ah});return true;},removeItem:function(W){var V,aa,Y=null,X,Z;V=this.get(y);if(U.isNumber(W)){X=W;}else{if(W instanceof a.AccordionItem){X=this.getItemIndex(W);}else{return null;}}if(X>=0){Z=this.fire(d,{item:W});if(!Z){return null;}Y=V.splice(X,1)[0];this._removeItemHandles(Y);aa=Y.get(N);aa.remove();this._adjustStretchItems();this.fire(I,{item:W});}return Y;},getItem:function(X){var V=this.get(y),W=null;if(U.isNumber(X)){W=V[X];return(W instanceof a.AccordionItem)?W:null;}else{if(X instanceof v){a.Array.some(V,function(ab,aa,Z){var Y=ab.get(A);if(Y===X){W=ab;return true;}else{return false;}},this);}}return W;},getItemIndex:function(X){var W=-1,V;if(X instanceof a.AccordionItem){V=this.get(y);a.Array.some(V,function(aa,Z,Y){if(aa===X){W=Z;return true;}else{return false;}},this);}return W;},_findStdModSection:function(V){return this.get(i).one("> ."+a.WidgetStdMod.SECTION_CLASS_NAMES[V]);
+},CONTENT_TEMPLATE:null},{NAME:n,ATTRS:{itemChosen:{value:"click",validator:function(V){return U.isString(V)||U.isArray(V);}},items:{value:[],readOnly:true,validator:U.isArray},resizeEvent:{value:K,validator:function(V){if(V===K){return true;}else{if(U.isObject(V)){if(U.isValue(V.sourceObject)&&U.isValue(V.resizeEvent)){return true;}}}return false;}},useAnimation:{value:true,validator:U.isBoolean},animation:{value:{duration:1,easing:h.easeOutStrong},validator:function(V){return U.isObject(V)&&U.isNumber(V.duration)&&U.isFunction(V.easing);}},reorderItems:{value:false,validator:function(V){return U.isBoolean(V)&&!U.isUndefined(a.DD);}},collapseOthersOnExpand:{value:true,validator:U.isBoolean}}});}());(function(){var U=a.Lang,B=a.Node,p=a.JSON,C=a.WidgetStdMod,D="accordion-item",n=a.ClassNameManager.getClassName,d=n(D,"iconexpanded","expanding"),S=n(D,"iconexpanded","collapsing"),o=n(D,"icon"),k=n(D,"label"),O=n(D,"iconalwaysvisible"),F=n(D,"icons"),M=n(D,"iconexpanded"),J=n(D,"iconclose"),q=n(D,"iconclose","hidden"),s=n(D,"iconexpanded","on"),l=n(D,"iconexpanded","off"),e=n(D,"iconalwaysvisible","on"),K=n(D,"iconalwaysvisible","off"),y=n(D,"expanded"),v=n(D,"closable"),H=n(D,"alwaysvisible"),I=n(D,"contentheight"),L="title",c="strings",Q="rendered",h="className",E="auto",j="stretch",w="fixed",t=".yui3-widget-hd",z=".",N=".yui3-widget-hd "+z,R="innerHTML",T="iconsContainer",G="icon",r="nodeLabel",g="iconAlwaysVisible",A="iconExpanded",b="iconClose",P="href",u="#",f="yuiConfig",i=/^(?:true|yes|1)$/,m=/^auto\s*/,V=/^stretch\s*/,x=/^fixed-\d+/;a.AccordionItem=a.Base.create(D,a.Widget,[a.WidgetStdMod],{_createHeader:function(){var ae,ac,ad,aa,ab,Z,X,W,Y;ab=this.get(G);Z=this.get(r);X=this.get(A);W=this.get(g);Y=this.get(b);aa=this.get(T);ad=this.get(c);ae=this.get("closable");ac=a.AccordionItem.TEMPLATES;if(!ab){ab=B.create(ac.icon);this.set(G,ab);}if(!Z){Z=B.create(ac.label);this.set(r,Z);}else{if(!Z.hasAttribute(P)){Z.setAttribute(P,u);}}Z.setContent(this.get("label"));if(!aa){aa=B.create(ac.iconsContainer);this.set(T,aa);}if(!W){W=B.create(ac.iconAlwaysVisible);W.setAttribute(L,ad.title_always_visible_off);this.set(g,W);}else{if(!W.hasAttribute(P)){W.setAttribute(P,u);}}if(!X){X=B.create(ac.iconExpanded);X.setAttribute(L,ad.title_iconexpanded_off);this.set(A,X);}else{if(!X.hasAttribute(P)){X.setAttribute(P,u);}}if(!Y){Y=B.create(ac.iconClose);Y.setAttribute(L,ad.title_iconclose);this.set(b,Y);}else{if(!Y.hasAttribute(P)){Y.setAttribute(P,u);}}if(ae){Y.removeClass(q);}else{Y.addClass(q);}this._addHeaderComponents();},_addHeaderComponents:function(){var ac,X,ab,Y,aa,Z,W;X=this.get(G);ab=this.get(r);aa=this.get(A);Z=this.get(g);W=this.get(b);Y=this.get(T);ac=this.getStdModNode(C.HEADER);if(!ac){ac=new B(document.createDocumentFragment());ac.appendChild(X);ac.appendChild(ab);ac.appendChild(Y);Y.appendChild(Z);Y.appendChild(aa);Y.appendChild(W);this.setStdModContent(C.HEADER,ac,C.REPLACE);}else{if(!ac.contains(X)){if(ac.contains(ab)){ac.insertBefore(X,ab);}else{ac.appendChild(X);}}if(!ac.contains(ab)){ac.appendChild(ab);}if(!ac.contains(Y)){ac.appendChild(Y);}if(!Y.contains(Z)){Y.appendChild(Z);}if(!Y.contains(aa)){Y.appendChild(aa);}if(!Y.contains(W)){Y.appendChild(W);}}},_labelChanged:function(X){var W;if(this.get(Q)){W=this.get(r);W.set(R,X.newVal);}},_closableChanged:function(X){var W;if(this.get(Q)){W=this.get(b);if(X.newVal){W.removeClass(q);}else{W.addClass(q);}}},initializer:function(W){this.after("labelChange",a.bind(this._labelChanged,this));this.after("closableChange",a.bind(this._closableChanged,this));},destructor:function(){},renderUI:function(){this._createHeader();},bindUI:function(){var W=this.get("contentBox");W.delegate("click",a.bind(this._onLinkClick,this),t+" a");},_onLinkClick:function(W){W.preventDefault();},markAsAlwaysVisible:function(X){var Y,W;Y=this.get(g);W=this.get(c);if(X){if(!Y.hasClass(e)){Y.replaceClass(K,e);Y.set(L,W.title_always_visible_on);return true;}}else{if(Y.hasClass(e)){Y.replaceClass(e,K);Y.set(L,W.title_always_visible_off);return true;}}return false;},markAsExpanded:function(X){var W,Y;Y=this.get(A);W=this.get(c);if(X){if(!Y.hasClass(s)){Y.replaceClass(l,s);Y.set(L,W.title_iconexpanded_on);return true;}}else{if(Y.hasClass(s)){Y.replaceClass(s,l);Y.set(L,W.title_iconexpanded_off);return true;}}return false;},markAsExpanding:function(X){var W=this.get(A);if(X){if(!W.hasClass(d)){W.addClass(d);return true;}}else{if(W.hasClass(d)){W.removeClass(d);return true;}}return false;},markAsCollapsing:function(W){var X=this.get(A);if(W){if(!X.hasClass(S)){X.addClass(S);return true;}}else{if(X.hasClass(S)){X.removeClass(S);return true;}}return false;},resize:function(){this.fire("contentUpdate");},_extractFixedMethodValue:function(aa){var X,Z,Y,W=null;for(X=6,Z=aa.length;X<Z;X++){Y=aa.charAt(X);Y=parseInt(Y,10);if(U.isNumber(Y)){W=(W*10)+Y;}else{break;}}return W;},_validateIcon:function(W){return !this.get(Q)||W;},_validateNodeLabel:function(W){return !this.get(Q)||W;},_validateIconsContainer:function(W){return !this.get(Q)||W;},_validateIconExpanded:function(W){return !this.get(Q)||W;},_validateIconAlwaysVisible:function(W){return !this.get(Q)||W;},_validateIconClose:function(W){return !this.get(Q)||W;},_setIcon:function(W){return a.one(W)||null;},_setNodeLabel:function(W){return a.one(W)||null;},_setIconsContainer:function(W){return a.one(W)||null;},_setIconExpanded:function(W){return a.one(W)||null;},_setIconAlwaysVisible:function(W){return a.one(W)||null;},_setIconClose:function(W){return a.one(W)||null;},_applyParser:function(W){var X;X=this.get("srcNode");if(X){this._parsedYUIConfig=X.getAttribute(f);if(this._parsedYUIConfig){this._parsedYUIConfig=p.parse(this._parsedYUIConfig);}}a.AccordionItem.superclass._applyParser.apply(this,arguments);delete this._parsedYUIConfig;},_findStdModSection:function(W){return this.get("srcNode").one("> ."+a.WidgetStdMod.SECTION_CLASS_NAMES[W]);},CONTENT_TEMPLATE:null},{NAME:D,ATTRS:{icon:{value:null,validator:function(W){return this._validateIcon(W);
+},setter:function(W){return this._setIcon(W);}},label:{value:"&#160;",validator:U.isString},nodeLabel:{value:null,validator:function(W){return this._validateNodeLabel(W);},setter:function(W){return this._setNodeLabel(W);}},iconsContainer:{value:null,validator:function(W){return this._validateIconsContainer(W);},setter:function(W){return this._setIconsContainer(W);}},iconExpanded:{value:null,validator:function(W){return this._validateIconExpanded(W);},setter:function(W){return this._setIconExpanded(W);}},iconAlwaysVisible:{value:null,validator:function(W){return this._validateIconAlwaysVisible(W);},setter:function(W){return this._setIconAlwaysVisible(W);}},iconClose:{value:null,validator:function(W){return this._validateIconClose(W);},setter:function(W){return this._setIconClose(W);}},expanded:{value:false,validator:U.isBoolean},contentHeight:{value:{method:E},validator:function(W){if(U.isObject(W)){if(W.method===E){return true;}else{if(W.method===j){return true;}else{if(W.method===w&&U.isNumber(W.height)&&W.height>=0){return true;}}}}return false;}},alwaysVisible:{value:false,validator:U.isBoolean},animation:{value:{},validator:U.isObject},strings:{value:{title_always_visible_off:"Click to set always visible on",title_always_visible_on:"Click to set always visible off",title_iconexpanded_off:"Click to expand",title_iconexpanded_on:"Click to collapse",title_iconclose:"Click to close"}},closable:{value:false,validator:U.isBoolean}},HTML_PARSER:{icon:N+o,label:function(Z){var Y,aa,X,W;X=this._parsedYUIConfig;if(X&&U.isValue(X.label)){return X.label;}W=Z.getAttribute("data-label");if(W){return W;}aa=N+k;Y=Z.one(aa);return(Y)?Y.get(R):null;},nodeLabel:N+k,iconsContainer:N+F,iconAlwaysVisible:N+O,iconExpanded:N+M,iconClose:N+J,expanded:function(Y){var X,W;X=this._parsedYUIConfig;if(X&&U.isBoolean(X.expanded)){return X.expanded;}W=Y.getAttribute("data-expanded");if(W){return i.test(W);}return Y.hasClass(y);},alwaysVisible:function(Y){var X,W;X=this._parsedYUIConfig;if(X&&U.isBoolean(X.alwaysVisible)){W=X.alwaysVisible;}else{W=Y.getAttribute("data-alwaysvisible");if(W){W=i.test(W);}else{W=Y.hasClass(H);}}if(W){this.set("expanded",true,{internalCall:true});}return W;},closable:function(Y){var X,W;X=this._parsedYUIConfig;if(X&&U.isBoolean(X.closable)){return X.closable;}W=Y.getAttribute("data-closable");if(W){return i.test(W);}return Y.hasClass(v);},contentHeight:function(ac){var aa,ab,W=0,X,Z,Y;Z=this._parsedYUIConfig;if(Z&&Z.contentHeight){return Z.contentHeight;}Y=ac.getAttribute("data-contentheight");if(m.test(Y)){return{method:E};}else{if(V.test(Y)){return{method:j};}else{if(x.test(Y)){W=this._extractFixedMethodValue(Y);return{method:w,height:W};}}}ab=ac.get(h);aa=I+"-";X=ab.indexOf(aa,0);if(X>=0){X+=aa.length;ab=ab.substring(X);if(m.test(ab)){return{method:E};}else{if(V.test(ab)){return{method:j};}else{if(x.test(ab)){W=this._extractFixedMethodValue(ab);return{method:w,height:W};}}}}return null;}},TEMPLATES:{icon:'<a class="'+o+'"></a>',label:'<a href="#" class="'+k+'"></a>',iconsContainer:'<div class="'+F+'"></div>',iconExpanded:['<a href="#" class="',M," ",l,'"></a>'].join(""),iconAlwaysVisible:['<a href="#" class="',O," ",K,'"></a>'].join(""),iconClose:['<a href="#" class="',J," ",q,'"></a>'].join("")}});}());},"gallery-2011.02.23-19-01",{optional:["dd-constrain","dd-proxy","dd-drop"],requires:["event","anim-easing","widget","widget-stdmod","json-parse"]});
View
41 build/gallery-accordion/gallery-accordion.js
@@ -266,6 +266,19 @@ Y.Accordion = Y.Base.create( AccName, Y.Widget, [], {
},
+ /**
+ * Binds an event to Accordion's contentBox.
+ *
+ * @method _bindItemChosenEvent
+ * @protected
+ */
+ _bindItemChosenEvent: function(itemChosenEvent) {
+ var contentBox;
+
+ contentBox = this.get( CONTENT_BOX );
+ contentBox.delegate( itemChosenEvent, Y.bind( this._onItemChosenEvent, this ), '.yui3-widget-hd' );
+ },
+
/**
* Contains items for collapsing
* @property _forCollapsing
@@ -1340,18 +1353,26 @@ Y.Accordion = Y.Base.create( AccName, Y.Widget, [], {
/**
- * Add listener to <code>itemChosen</code> event in Accordion's content box
+ * Add listener(s) to <code>itemChosen</code> event in Accordion's content box.
+ * If itemChosen is an Array, this function will invoke multiple times _bindItemChosenEvent
*
* @method bindUI
* @protected
*/
bindUI: function(){
- var contentBox, itemChosenEvent;
+ var i, itemChosenEvent, length;
- contentBox = this.get( CONTENT_BOX );
itemChosenEvent = this.get( 'itemChosen' );
- contentBox.delegate( itemChosenEvent, Y.bind( this._onItemChosenEvent, this ), '.yui3-widget-hd' );
+ if( Lang.isArray(itemChosenEvent) ){
+ length = itemChosenEvent.length;
+
+ for( i = 0; i < length; i++ ) {
+ this._bindItemChosenEvent(itemChosenEvent[i]);
+ }
+ } else {
+ this._bindItemChosenEvent(itemChosenEvent);
+ }
},
@@ -1647,16 +1668,18 @@ Y.Accordion = Y.Base.create( AccName, Y.Widget, [], {
ATTRS : {
/**
* @description The event on which Accordion should listen for user interactions.
- * The value can be also mousedown or mouseup. Mousedown event can be used if
- * drag&drop is not enabled
+ * The value can be also 'mousedown', 'mouseup' or ['mouseenter','click'].
+ * Mousedown event can be used if drag&drop is not enabled.
*
* @attribute itemChosen
* @default click
- * @type String
+ * @type String|Array
*/
itemChosen: {
value: "click",
- validator: Lang.isString
+ validator: function( value ) {
+ return Lang.isString(value) || Lang.isArray(value);
+ }
},
/**
@@ -2890,4 +2913,4 @@ Y.AccordionItem = Y.Base.create( AccItemName, Y.Widget, [Y.WidgetStdMod], {
-}, 'gallery-2011.02.18-23-10' ,{optional:['dd-constrain', 'dd-proxy', 'dd-drop'], requires:['event', 'anim-easing', 'widget', 'widget-stdmod', 'json-parse']});
+}, 'gallery-2011.02.23-19-01' ,{optional:['dd-constrain', 'dd-proxy', 'dd-drop'], requires:['event', 'anim-easing', 'widget', 'widget-stdmod', 'json-parse']});
View
296 build/gallery-algorithms/gallery-algorithms-debug.js
@@ -0,0 +1,296 @@
+YUI.add('gallery-algorithms', function(Y) {
+
+"use strict";
+
+/**
+ * <p>Useful algorithms not provided by browsers.</p>
+ *
+ * @module gallery-algorithms
+ * @class Y.Array
+ */
+
+/**********************************************************************
+ * <p>Swaps two elements.</p>
+ *
+ * @method Y.Array.swap
+ * @static
+ * @param list {Array} the list on which to operate
+ * @param i {int} first index
+ * @param j {int} second index
+ */
+Y.Array.swap = function(list,i,j)
+{
+ var tmp = list[i];
+ list[i] = list[j];
+ list[j] = tmp;
+};
+
+/**********************************************************************
+ * <p>A -1,0,+1 comparator for case-sensitive string comparison.</p>
+ *
+ * @method Y.Array.compareStringsCaseSensitive
+ * @static
+ * @param s1 {String} first string
+ * @param s2 {String} second string
+ * @return -1 if s1&lt;s2, 0 if s1==s2, +1 if s1&gt;s2
+ */
+Y.Array.compareStringsCaseSensitive = function(s1, s2)
+{
+ if (s1 == s2)
+ {
+ return 0;
+ }
+ else
+ {
+ return (s1 < s2 ? -1 : +1);
+ }
+};
+
+/**********************************************************************
+ * <p>A -1,0,+1 comparator for case-insensitive string comparison.</p>
+ *
+ * @method Y.Array.compareStringsCaseInsensitive
+ * @static
+ * @param s1 {String} first string
+ * @param s2 {String} second string
+ * @return -1 if s1&lt;s2, 0 if s1==s2, +1 if s1&gt;s2
+ */
+Y.Array.compareStringsCaseInsensitive = function(s1, s2)
+{
+ return Y.Array.compareStringsCaseSensitive(s1.toLowerCase(), s2.toLowerCase());
+};
+
+/**********************************************************************
+ * <p>Converts a -1,0,+1 comparator into a boolean comparator, for use by
+ * Y.Array.find().</p>
+ *
+ * @method Y.Array.compareForFind
+ * @static
+ * @param f {Function} -1,0,+1 comparator function
+ * @return {Function} function that returns true if the arguments are equal
+ */
+Y.Array.compareForFind = function(f)
+{
+ return function(a,b)
+ {
+ return (f(a,b) === 0);
+ };
+};
+
+/*
+quick sort history:
+
+ Copyright (c) 2006 John Lindal
+ Copyright (c) 2003 Scandinavian Digital Systems AB
+
+ Adapted from http://www.digsys.se
+
+ Freeware: The source code and its methods and algorithms may be
+ used as desired without restrictions.
+*/
+
+function qsort1(list,i1,i2,compare)
+{
+ var n, m, ip, im, pivot, s, b=true;
+
+ if (!compare)
+ {
+ compare = Y.Array.compareStringsCaseSensitive;
+ }
+
+ im=Math.floor((i1+i2)/2); // Note, im may be equal to i1 but never to i2
+ n=im;
+ ip=n--;
+ pivot=list[ip];
+ while (n>=i1 && b)
+ {
+ m=n--;
+ b=(compare(pivot, list[m])===0);
+ }
+ n=im+1; // n may be equal to i2 but not i2+1 (at this point)
+ while (n<=i2 && b)
+ {
+ m=n++;
+ b=(compare(pivot, list[m])===0);
+ }
+ if (b) { return -1; }
+ if (compare(list[m], pivot) > 0)
+ {
+ ip=m;
+ pivot=list[ip];
+ }
+ n=i1; // Left
+ m=i2; // Right
+ while (n<=m)
+ {
+ while (compare(pivot, list[n]) > 0)
+ {
+ n++;
+ }
+ while (compare(pivot, list[m]) <= 0)
+ {
+ m--;
+ }
+ if (n<m)
+ {
+ s=list[m];
+ list[m]=list[n];
+ list[n]=s;
+ m--;
+ n++;
+ }
+ }
+ return n;
+}
+
+function qsortRange(list,first,last,compare)
+{
+ var center; // This local var is the only recursive stack space used
+ if (first<last)
+ {
+ center=qsort1(list,first,last,compare);
+ if (center!=-1)
+ {
+ qsortRange(list,first,center-1,compare);
+ qsortRange(list,center,last,compare);
+ }
+ }
+}
+
+/**********************************************************************
+ * <p>Quick sort the given list.</p>
+ *
+ * @method Y.Array.quickSort
+ * @static
+ * @param list {Array} the list to search (sorted on the compare function)
+ * @param compare {Function} the comparison function (default: Y.Array.compareStringsCaseSensitive)
+ */
+Y.Array.quickSort = function(list,compare)
+{
+ qsortRange(list, 0, list.length-1, compare);
+};
+
+/*
+binary search history:
+
+ Dobrica Pavlinusic, dpavlin@rot13.org 2004-09-06
+ Matko Andjelinic, matko.andjelinic@gmail.com 2004-09-09 (contributed OO implementation)
+*/
+
+/**********************************************************************
+ * <p>Binary search.</p>
+ *
+ * @method Y.Array.binarySearch
+ * @static
+ * @param list {Array} the list to search (sorted on the compare function)
+ * @param target {Mixed} the object to search for
+ * @param compare {Function} the comparison function (default: Y.Array.compareStringsCaseSensitive)
+ * @return {int} index of matched item or -1 if no match
+ */
+Y.Array.binarySearch = function(list, target, compare)
+{
+ if (!list || !list.length || Y.Lang.isUndefined(target))
+ {
+ return null;
+ }
+
+ if (!compare)
+ {
+ compare = Y.Array.compareStringsCaseSensitive;
+ }
+
+ var low = 0;
+ var high = list.length - 1;
+
+ var lastTry;
+ while (low <= high)
+ {
+ var mid = (low + high) / 2;
+ var aTry = (mid < 1) ? 0 : parseInt(mid, 10);
+
+ var c = compare(list[aTry], target);
+ if (c < 0)
+ {
+ low = aTry + 1;
+ continue;
+ }
+ if (c > 0)
+ {
+ high = aTry - 1;
+ continue;
+ }
+ if (c === 0)
+ {
+ high = aTry - 1;
+ lastTry = aTry;
+ continue;
+ }
+ return aTry;
+ }
+
+ return (Y.Lang.isUndefined(lastTry) ? -1 : lastTry);
+};
+/**
+ * @module gallery-algorithms
+ */
+
+if (Y.ArrayList)
+{
+ /**********************************************************************
+ * Useful algorithms that are not provided by browsers. Available if
+ * Y.ArrayList (collection) is loaded.
+ *
+ * @class Y.ArrayList
+ */
+
+ Y.mix(Y.ArrayList,
+ {
+ /**
+ * <p>Swap two elements.</p>
+ *
+ * @method Y.ArrayList.swap
+ * @param i {int} first index
+ * @param j {int} second index
+ */
+ swap: function(i,j)
+ {
+ Y.Array.swap(this._items, i,j);
+ },
+
+ /**
+ * <p>Set comparison function.</p>
+ *
+ * @method Y.ArrayList.setComparator
+ * @param compare {Function} the -1,0,+1 comparison function to use when sorting and searching
+ */
+ setComparator: function(compare)
+ {
+ this._compare = compare;
+ },
+
+ /**
+ * <p>Quick sort the given list, using the function passed to setComparator().</p>
+ *
+ * @method Y.ArrayList.quickSort
+ */
+ quickSort: function()
+ {
+ Y.Array.quickSort(this._items, this._compare);
+ },
+
+ /**
+ * <p>Binary search, using the function passed to setComparator().</p>
+ *
+ * @method Y.ArrayList.binarySearch
+ * @param target {Mixed} the object to search for
+ * @return {int} index of matched item or -1 if no match
+ */
+ binarySearch: function(target)
+ {
+ Y.Array.binarySearch(this._items, target, this._compare);
+ }
+ });
+}
+
+
+}, 'gallery-2011.02.23-19-01' ,{optional:['collection']});
View
1 build/gallery-algorithms/gallery-algorithms-min.js
@@ -0,0 +1 @@
+YUI.add("gallery-algorithms",function(c){c.Array.swap=function(g,f,d){var e=g[f];g[f]=g[d];g[d]=e;};c.Array.compareStringsCaseSensitive=function(e,d){if(e==d){return 0;}else{return(e<d?-1:+1);}};c.Array.compareStringsCaseInsensitive=function(e,d){return c.Array.compareStringsCaseSensitive(e.toLowerCase(),d.toLowerCase());};c.Array.compareForFind=function(d){return function(f,e){return(d(f,e)===0);};};function b(j,h,g,d){var e,f,i,l,o,p,k=true;if(!d){d=c.Array.compareStringsCaseSensitive;}l=Math.floor((h+g)/2);e=l;i=e--;o=j[i];while(e>=h&&k){f=e--;k=(d(o,j[f])===0);}e=l+1;while(e<=g&&k){f=e++;k=(d(o,j[f])===0);}if(k){return -1;}if(d(j[f],o)>0){i=f;o=j[i];}e=h;f=g;while(e<=f){while(d(o,j[e])>0){e++;}while(d(o,j[f])<=0){f--;}if(e<f){p=j[f];j[f]=j[e];j[e]=p;f--;e++;}}return e;}function a(g,h,e,f){var d;if(h<e){d=b(g,h,e,f);if(d!=-1){a(g,h,d-1,f);a(g,d,e,f);}}}c.Array.quickSort=function(e,d){a(e,0,e.length-1,d);};c.Array.binarySearch=function(i,h,e){if(!i||!i.length||c.Lang.isUndefined(h)){return null;}if(!e){e=c.Array.compareStringsCaseSensitive;}var k=0;var g=i.length-1;var f;while(k<=g){var l=(k+g)/2;var d=(l<1)?0:parseInt(l,10);var j=e(i[d],h);if(j<0){k=d+1;continue;}if(j>0){g=d-1;continue;}if(j===0){g=d-1;f=d;continue;}return d;}return(c.Lang.isUndefined(f)?-1:f);};if(c.ArrayList){c.mix(c.ArrayList,{swap:function(e,d){c.Array.swap(this._items,e,d);},setComparator:function(d){this._compare=d;},quickSort:function(){c.Array.quickSort(this._items,this._compare);},binarySearch:function(d){c.Array.binarySearch(this._items,d,this._compare);}});}},"gallery-2011.02.23-19-01",{optional:["collection"]});
View
296 build/gallery-algorithms/gallery-algorithms.js
@@ -0,0 +1,296 @@
+YUI.add('gallery-algorithms', function(Y) {
+
+"use strict";
+
+/**
+ * <p>Useful algorithms not provided by browsers.</p>
+ *
+ * @module gallery-algorithms
+ * @class Y.Array
+ */
+
+/**********************************************************************
+ * <p>Swaps two elements.</p>
+ *
+ * @method Y.Array.swap
+ * @static
+ * @param list {Array} the list on which to operate
+ * @param i {int} first index
+ * @param j {int} second index
+ */
+Y.Array.swap = function(list,i,j)
+{
+ var tmp = list[i];
+ list[i] = list[j];
+ list[j] = tmp;
+};
+
+/**********************************************************************
+ * <p>A -1,0,+1 comparator for case-sensitive string comparison.</p>
+ *
+ * @method Y.Array.compareStringsCaseSensitive
+ * @static
+ * @param s1 {String} first string
+ * @param s2 {String} second string
+ * @return -1 if s1&lt;s2, 0 if s1==s2, +1 if s1&gt;s2
+ */
+Y.Array.compareStringsCaseSensitive = function(s1, s2)
+{
+ if (s1 == s2)
+ {
+ return 0;
+ }
+ else
+ {
+ return (s1 < s2 ? -1 : +1);
+ }
+};
+
+/**********************************************************************
+ * <p>A -1,0,+1 comparator for case-insensitive string comparison.</p>
+ *
+ * @method Y.Array.compareStringsCaseInsensitive
+ * @static
+ * @param s1 {String} first string
+ * @param s2 {String} second string
+ * @return -1 if s1&lt;s2, 0 if s1==s2, +1 if s1&gt;s2
+ */
+Y.Array.compareStringsCaseInsensitive = function(s1, s2)
+{
+ return Y.Array.compareStringsCaseSensitive(s1.toLowerCase(), s2.toLowerCase());
+};
+
+/**********************************************************************
+ * <p>Converts a -1,0,+1 comparator into a boolean comparator, for use by
+ * Y.Array.find().</p>
+ *
+ * @method Y.Array.compareForFind
+ * @static
+ * @param f {Function} -1,0,+1 comparator function
+ * @return {Function} function that returns true if the arguments are equal
+ */
+Y.Array.compareForFind = function(f)
+{
+ return function(a,b)
+ {
+ return (f(a,b) === 0);
+ };
+};
+
+/*
+quick sort history:
+
+ Copyright (c) 2006 John Lindal
+ Copyright (c) 2003 Scandinavian Digital Systems AB
+
+ Adapted from http://www.digsys.se
+
+ Freeware: The source code and its methods and algorithms may be
+ used as desired without restrictions.
+*/
+
+function qsort1(list,i1,i2,compare)
+{
+ var n, m, ip, im, pivot, s, b=true;
+
+ if (!compare)
+ {
+ compare = Y.Array.compareStringsCaseSensitive;
+ }
+
+ im=Math.floor((i1+i2)/2); // Note, im may be equal to i1 but never to i2
+ n=im;
+ ip=n--;
+ pivot=list[ip];
+ while (n>=i1 && b)
+ {
+ m=n--;
+ b=(compare(pivot, list[m])===0);
+ }
+ n=im+1; // n may be equal to i2 but not i2+1 (at this point)
+ while (n<=i2 && b)
+ {
+ m=n++;
+ b=(compare(pivot, list[m])===0);
+ }
+ if (b) { return -1; }
+ if (compare(list[m], pivot) > 0)
+ {
+ ip=m;
+ pivot=list[ip];
+ }
+ n=i1; // Left
+ m=i2; // Right
+ while (n<=m)
+ {
+ while (compare(pivot, list[n]) > 0)
+ {
+ n++;
+ }
+ while (compare(pivot, list[m]) <= 0)
+ {
+ m--;
+ }
+ if (n<m)
+ {
+ s=list[m];
+ list[m]=list[n];
+ list[n]=s;
+ m--;
+ n++;
+ }
+ }
+ return n;
+}
+
+function qsortRange(list,first,last,compare)
+{
+ var center; // This local var is the only recursive stack space used
+ if (first<last)
+ {
+ center=qsort1(list,first,last,compare);
+ if (center!=-1)
+ {
+ qsortRange(list,first,center-1,compare);
+ qsortRange(list,center,last,compare);
+ }
+ }
+}
+
+/**********************************************************************
+ * <p>Quick sort the given list.</p>
+ *
+ * @method Y.Array.quickSort
+ * @static
+ * @param list {Array} the list to search (sorted on the compare function)
+ * @param compare {Function} the comparison function (default: Y.Array.compareStringsCaseSensitive)
+ */
+Y.Array.quickSort = function(list,compare)
+{
+ qsortRange(list, 0, list.length-1, compare);
+};
+
+/*
+binary search history:
+
+ Dobrica Pavlinusic, dpavlin@rot13.org 2004-09-06
+ Matko Andjelinic, matko.andjelinic@gmail.com 2004-09-09 (contributed OO implementation)
+*/
+
+/**********************************************************************
+ * <p>Binary search.</p>
+ *
+ * @method Y.Array.binarySearch
+ * @static
+ * @param list {Array} the list to search (sorted on the compare function)
+ * @param target {Mixed} the object to search for
+ * @param compare {Function} the comparison function (default: Y.Array.compareStringsCaseSensitive)
+ * @return {int} index of matched item or -1 if no match
+ */
+Y.Array.binarySearch = function(list, target, compare)
+{
+ if (!list || !list.length || Y.Lang.isUndefined(target))
+ {
+ return null;
+ }
+
+ if (!compare)
+ {
+ compare = Y.Array.compareStringsCaseSensitive;
+ }
+
+ var low = 0;
+ var high = list.length - 1;
+
+ var lastTry;
+ while (low <= high)
+ {
+ var mid = (low + high) / 2;
+ var aTry = (mid < 1) ? 0 : parseInt(mid, 10);
+
+ var c = compare(list[aTry], target);
+ if (c < 0)
+ {
+ low = aTry + 1;
+ continue;
+ }
+ if (c > 0)
+ {
+ high = aTry - 1;
+ continue;
+ }
+ if (c === 0)
+ {
+ high = aTry - 1;
+ lastTry = aTry;
+ continue;
+ }
+ return aTry;
+ }
+
+ return (Y.Lang.isUndefined(lastTry) ? -1 : lastTry);
+};
+/**
+ * @module gallery-algorithms
+ */
+
+if (Y.ArrayList)
+{
+ /**********************************************************************
+ * Useful algorithms that are not provided by browsers. Available if
+ * Y.ArrayList (collection) is loaded.
+ *
+ * @class Y.ArrayList
+ */
+
+ Y.mix(Y.ArrayList,
+ {
+ /**
+ * <p>Swap two elements.</p>
+ *
+ * @method Y.ArrayList.swap
+ * @param i {int} first index
+ * @param j {int} second index
+ */
+ swap: function(i,j)
+ {
+ Y.Array.swap(this._items, i,j);
+ },
+
+ /**
+ * <p>Set comparison function.</p>
+ *
+ * @method Y.ArrayList.setComparator
+ * @param compare {Function} the -1,0,+1 comparison function to use when sorting and searching
+ */
+ setComparator: function(compare)
+ {
+ this._compare = compare;
+ },
+
+ /**
+ * <p>Quick sort the given list, using the function passed to setComparator().</p>
+ *
+ * @method Y.ArrayList.quickSort
+ */
+ quickSort: function()
+ {
+ Y.Array.quickSort(this._items, this._compare);
+ },
+
+ /**
+ * <p>Binary search, using the function passed to setComparator().</p>
+ *
+ * @method Y.ArrayList.binarySearch
+ * @param target {Mixed} the object to search for
+ * @return {int} index of matched item or -1 if no match
+ */
+ binarySearch: function(target)
+ {
+ Y.Array.binarySearch(this._items, target, this._compare);
+ }
+ });
+}
+
+
+}, 'gallery-2011.02.23-19-01' ,{optional:['collection']});
View
396 build/gallery-comet-stream/gallery-comet-stream-debug.js
@@ -0,0 +1,396 @@
+YUI.add('gallery-comet-stream', function(Y) {
+
+/*
+ * Provides Server Streaming client functionality.
+ * Currently, it supports XHR streaming and forever iframe streaming.
+ *
+ * @module gallery-comet-stream
+ */
+
+/*
+ * readyState possible value.
+ * http://www.quirksmode.org/blog/archives/2005/09/xmlhttp_notes_r_2.html
+ */
+var READY_STATE = {
+
+ UNINITIALIZED: 0, // open() has not been called yet.
+
+ LOADING: 1, // send() has not been called yet.
+
+ LOADED: 2, // send() has been called, headers and status are available.
+
+ INTERACTIVE: 3, // Downloading, responseText holds the partial data.
+
+ COMPLETED: 4 // Finished with all operations.
+},
+
+E_START = 'start',
+
+E_FAIL = 'fail',
+
+E_PUSHED = 'pushed',
+
+E_RECONNECT = 'reconnect',
+
+E_INVALID_FORMAT= 'invalidFormat';
+
+/**
+ * @class CometStream
+ * @description CometStream class
+ * @constructor
+ * @extends EventTarget
+ * @param cfg {Object} configuration object
+ */
+function CometStream(cfg) {
+ CometStream.superclass.constructor.apply(this, arguments);
+
+ /**
+ * @event start
+ * @description This event is fired when stream is started.
+ * @type Event Custom
+ */
+ this.publish(E_START, {
+ emitFacade: true
+ });
+
+ /**
+ * @event fail
+ * @description This event is fired when stream fails to be connected.
+ * @type Event Custom
+ */
+ this.publish(E_FAIL, {
+ fireOnce: true,
+ emitFacade: true
+ });
+
+ /**
+ * @event pushed
+ * @description This event is fired when message is pushed in the stream.
+ * @type Event Custom
+ */
+ this.publish(E_PUSHED, {
+ emitFacade: true
+ });
+
+ /**
+ * @event reconnect
+ * @description This event is fired when stream connection is reconnected.
+ * @type Event Custom
+ */
+ this.publish(E_RECONNECT, {
+ emitFacade: true
+ });
+
+ /**
+ * @event invalidFormat
+ * @description This event is fired when server pushed message violate message format.
+ * @type Event Custom
+ */
+ this.publish(E_INVALID_FORMAT, {
+ emitFacade: true
+ });
+}
+
+CometStream.NAME = 'cometStream';
+
+CometStream.ATTRS = {
+ /**
+ * Stream URL
+ *
+ * @attribute url
+ * @type String
+ */
+ url: {
+ },
+
+ /**
+ * Timeout to create stream connection in milliseconds
+ *
+ * @attribute connectTimeout
+ * @default 20000
+ * @type Number
+ */
+ connectTimeout: {
+ value: 20 * 1000
+ },
+
+ /**
+ * Stream connection is reset every given seconds to avoid memory leak.
+ *
+ * @attribute resetTimeout
+ * @default 20000
+ * @type Number
+ */
+ resetTimeout: {
+ value: 300 * 1000
+ },
+
+ /**
+ * Whether to retry on HTTP dis-connected.
+ *
+ * @attribute resetTimeout
+ * @default true
+ * @type Boolean
+ */
+ retryOnDisconnect: {
+ value: true
+ },
+
+ /*
+ * XHR polling internal(milliseconds) for Opera
+ *
+ * @attribute operaXhrPollingInterval
+ * @default 50
+ * @type Number
+ */
+ operaXhrPollingInterval: {
+ value: 50
+ }
+};
+
+CometStream.prototype = {
+
+ /**
+ * @method start
+ * @description start this stream.
+ */
+ start: function() {
+ this._initStream();
+ },
+
+ /**
+ * @method close
+ * @description close this stream.
+ */
+ close: function() {
+ this._endStream();
+ this._closed = true;
+ },
+
+ _initStream: function() {
+ var xhr,
+ that = this;
+
+ /*
+ * Last pushed data index which is to track newly pushed data start point.
+ */
+ this._lastMsgIdx = 0;
+
+ if (Y.UA.ie) {
+ this._createIFrame(this.get('url'), Y.bind(this._onPushedMsgFromIFrame, this));
+ } else {
+ xhr = this.xhr = this._createXHR();
+
+ xhr.onreadystatechange = function() {
+ that._onXhrStreamStateChange();
+ };
+
+ xhr.open('GET', this.get('url'), true);
+
+ xhr.send();
+ }
+
+ this._failTimer = Y.later(this.get('connectTimeout'), this, this._failTimeout, null);
+ this._streamStartTime = new Date();
+
+ Y.later(this.get('resetTimeout'), this, this._reconnect);
+
+ this._fireStartEvent();
+ },
+
+ _failTimeout: function() {
+ this.fire(E_FAIL);
+ this._failTimer = null;
+ this._endStream();
+ },
+
+ _succeedToConnect: function() {
+ if (this._failTimer) {
+ this._failTimer.cancel();
+ }
+ },
+
+ _endStream: function() {
+ if (this.transDoc) {
+ this.iframeDiv.innerHTML = '';
+ this.transDoc = null; // Let it be GC-ed
+ }
+
+ if (this._pollHandler) {
+ this._pollHandler.cancel();
+ }
+
+ if (this.xhr) {
+ var xhr = this.xhr;
+ this.xhr = null;
+ xhr.onreadystatechange = null;
+ xhr.abort();
+ }
+ },
+
+ _pollResponse: function() {
+ this._parseResponse(this.xhr.responseText);
+ },
+
+ _onXhrStreamStateChange: function() {
+ var xhr = this.xhr,
+ status;
+ if (!xhr) {
+ return;
+ }
+
+ if (xhr.readyState < READY_STATE.INTERACTIVE) {
+ //Opera throw exception if we check xhr.status when readyState < INTERACTIVE
+ return;
+ }
+
+ status = xhr.status;
+
+ if (status === 200) {
+ if (xhr.readyState === READY_STATE.INTERACTIVE) {
+ // For Opera, it doesn't trigger INTERACTIVE ready state for each pushed data. So, we have to do polling.
+ //
+ if (Y.UA.opera) {
+ this._pollHandler = Y.later(this.get('operaXhrPollingInterval'), this, this._pollResponse, null, true);
+ } else {
+ this._parseResponse(xhr.responseText);
+ }
+ } else if (xhr.readyState === READY_STATE.COMPLETED) {
+ if (Y.UA.opera) {
+ // poll it for the last time in case something is missing.
+ this._pollResponse();
+ }
+
+ if (this.get('retryOnDisconnect')) {
+ this._reconnect();
+ }
+ }
+ } else {
+ this.fire(E_FAIL);
+ }
+ },
+
+ _fireStartEvent: function() {
+ this.fire(E_START);
+ },
+
+ _reconnect: function() {
+ this._endStream();
+
+ if (!this._closed) {
+ this.fire(E_RECONNECT);
+ this._initStream();
+ }
+ },
+
+ _parseResponse: function(responseText) {
+ this._succeedToConnect();
+
+ // Browser doesn't expose chunked structure to us. So, we have to build chunked data based on HTTP trunked data.
+ while (true) {
+ var msg, msgStartPos, msgEndPos,
+ sizeStartPos, sizeEndPos, sizeLine, size;
+
+ sizeStartPos = this._lastMsgIdx;
+ sizeEndPos = responseText.indexOf('\r\n', sizeStartPos);
+ if (sizeEndPos == -1) {
+ break;
+ }
+ sizeLine = responseText.substring(sizeStartPos, sizeEndPos);
+ size = Number('0x' + Y.Lang.trim(sizeLine));
+
+ if (window.isNaN(size)) {
+ this.fire(E_INVALID_FORMAT);
+ this._endStream();
+ return;
+ }
+
+ msgStartPos = sizeEndPos + 2; //pass '\r\n'
+ msgEndPos = msgStartPos + size;
+
+ if (msgEndPos > responseText.length) {
+ // this chunk doesn't get completed yet.
+ break;
+ }
+
+ this._lastMsgIdx = msgEndPos + 2; // pass '\r\n'
+ msg = responseText.substr(msgStartPos, size);
+
+ this._fireMessageEvent(msg);
+ }
+ },
+
+ _onPushedMsgFromIFrame: function(msg) {
+ // iframe channel should pushed down some message on connection success so that client knows the channel is alive.
+ this._succeedToConnect();
+
+ this._fireMessageEvent(msg);
+ },
+
+ _fireMessageEvent: function(msg) {
+ this.fire(E_PUSHED, {data: msg});
+ },
+
+ _createIFrame: function(url, callback) {
+ var m;
+
+ // Don't let transDoc be GC-ed.
+ this.transDoc = new window.ActiveXObject('htmlfile');
+ this.transDoc.open();
+
+ // Don't assign domain if same. It will break in IE8.
+ //
+ m = url.match(/^http.?:\/\/([^\/]+)\/?/);
+ if (m && (m[1] !== window.document.domain)) {
+ this.transDoc.write('<html><script type="text/javascript">document.domain="' + window.document.domain + '";</script></html>');
+ }
+ this.transDoc.write('<html></html>');
+ this.transDoc.close();
+
+ // TODO:
+ // This makes only one instance of CometStream instance allwoed in in one page. Otherwise multiple iframe channel will conflicts
+ // in callback. Perhaps we can specify callback method or channel id name in iframe URL query string.
+ //
+ this.transDoc.parentWindow.push = callback;
+
+ this.iframeDiv = this.transDoc.createElement('div');
+ this.transDoc.body.appendChild(this.iframeDiv);
+ this.iframeDiv.innerHTML = '<iframe src="' + url + '"></iframe>';
+ },
+
+ _createXHR: function() {
+ var xhrObj = null;
+
+ // most browsers (including IE7) just use below 2 lines
+ if (window.XMLHttpRequest) {
+ xhrObj = new XMLHttpRequest();
+ } else if (window.ActiveXObject) {
+ // IE5/6 falls into this block
+ //
+ // NOTE: Actually, we cannot implement comet with IE XHR since it doesn't trigger readyState===INTERACTIVE state in progress.
+ // I keep below code for Long-Poll(perhaps in the future)
+ /*
+ try {
+ xhrObj = new window.ActiveXObject('Msxml2.XMLHTTP');
+ } catch (e1) {
+ try {
+ xhrObj = new window.ActiveXObject('Microsoft.XMLHTTP');
+ } catch (e2) {
+ xhrObj = null;
+ }
+ }
+ */
+ }
+ if (!xhrObj) {
+ throw new Error('XMLHttpRequest is not supported');
+ }
+ return xhrObj;
+ }
+};
+
+Y.extend(CometStream, Y.Base, CometStream.prototype);
+
+Y.CometStream = CometStream;
+
+
+}, 'gallery-2011.02.23-19-01' ,{requires:['base']});
View
1 build/gallery-comet-stream/gallery-comet-stream-min.js
@@ -0,0 +1 @@
+YUI.add("gallery-comet-stream",function(g){var d={UNINITIALIZED:0,LOADING:1,LOADED:2,INTERACTIVE:3,COMPLETED:4},b="start",a="fail",e="pushed",c="reconnect",h="invalidFormat";function f(i){f.superclass.constructor.apply(this,arguments);this.publish(b,{emitFacade:true});this.publish(a,{fireOnce:true,emitFacade:true});this.publish(e,{emitFacade:true});this.publish(c,{emitFacade:true});this.publish(h,{emitFacade:true});}f.NAME="cometStream";f.ATTRS={url:{},connectTimeout:{value:20*1000},resetTimeout:{value:300*1000},retryOnDisconnect:{value:true},operaXhrPollingInterval:{value:50}};f.prototype={start:function(){this._initStream();},close:function(){this._endStream();this._closed=true;},_initStream:function(){var j,i=this;this._lastMsgIdx=0;if(g.UA.ie){this._createIFrame(this.get("url"),g.bind(this._onPushedMsgFromIFrame,this));}else{j=this.xhr=this._createXHR();j.onreadystatechange=function(){i._onXhrStreamStateChange();};j.open("GET",this.get("url"),true);j.send();}this._failTimer=g.later(this.get("connectTimeout"),this,this._failTimeout,null);this._streamStartTime=new Date();g.later(this.get("resetTimeout"),this,this._reconnect);this._fireStartEvent();},_failTimeout:function(){this.fire(a);this._failTimer=null;this._endStream();},_succeedToConnect:function(){if(this._failTimer){this._failTimer.cancel();}},_endStream:function(){if(this.transDoc){this.iframeDiv.innerHTML="";this.transDoc=null;}if(this._pollHandler){this._pollHandler.cancel();}if(this.xhr){var i=this.xhr;this.xhr=null;i.onreadystatechange=null;i.abort();}},_pollResponse:function(){this._parseResponse(this.xhr.responseText);},_onXhrStreamStateChange:function(){var j=this.xhr,i;if(!j){return;}if(j.readyState<d.INTERACTIVE){return;}i=j.status;if(i===200){if(j.readyState===d.INTERACTIVE){if(g.UA.opera){this._pollHandler=g.later(this.get("operaXhrPollingInterval"),this,this._pollResponse,null,true);}else{this._parseResponse(j.responseText);}}else{if(j.readyState===d.COMPLETED){if(g.UA.opera){this._pollResponse();}if(this.get("retryOnDisconnect")){this._reconnect();}}}}else{this.fire(a);}},_fireStartEvent:function(){this.fire(b);},_reconnect:function(){this._endStream();if(!this._closed){this.fire(c);this._initStream();}},_parseResponse:function(m){this._succeedToConnect();while(true){var o,l,p,i,n,j,k;i=this._lastMsgIdx;n=m.indexOf("\r\n",i);if(n==-1){break;}j=m.substring(i,n);k=Number("0x"+g.Lang.trim(j));if(window.isNaN(k)){this.fire(h);this._endStream();return;}l=n+2;p=l+k;if(p>m.length){break;}this._lastMsgIdx=p+2;o=m.substr(l,k);this._fireMessageEvent(o);}},_onPushedMsgFromIFrame:function(i){this._succeedToConnect();this._fireMessageEvent(i);},_fireMessageEvent:function(i){this.fire(e,{data:i});},_createIFrame:function(j,k){var i;this.transDoc=new window.ActiveXObject("htmlfile");this.transDoc.open();i=j.match(/^http.?:\/\/([^\/]+)\/?/);if(i&&(i[1]!==window.document.domain)){this.transDoc.write('<html><script type="text/javascript">document.domain="'+window.document.domain+'";<\/script></html>');}this.transDoc.write("<html></html>");this.transDoc.close();this.transDoc.parentWindow.push=k;this.iframeDiv=this.transDoc.createElement("div");this.transDoc.body.appendChild(this.iframeDiv);this.iframeDiv.innerHTML='<iframe src="'+j+'"></iframe>';},_createXHR:function(){var i=null;if(window.XMLHttpRequest){i=new XMLHttpRequest();}else{if(window.ActiveXObject){}}if(!i){throw new Error("XMLHttpRequest is not supported");}return i;}};g.extend(f,g.Base,f.prototype);g.CometStream=f;},"gallery-2011.02.23-19-01",{requires:["base"]});
View
396 build/gallery-comet-stream/gallery-comet-stream.js
@@ -0,0 +1,396 @@
+YUI.add('gallery-comet-stream', function(Y) {
+
+/*
+ * Provides Server Streaming client functionality.
+ * Currently, it supports XHR streaming and forever iframe streaming.
+ *
+ * @module gallery-comet-stream
+ */
+
+/*
+ * readyState possible value.
+ * http://www.quirksmode.org/blog/archives/2005/09/xmlhttp_notes_r_2.html
+ */
+var READY_STATE = {
+
+ UNINITIALIZED: 0, // open() has not been called yet.
+
+ LOADING: 1, // send() has not been called yet.
+
+ LOADED: 2, // send() has been called, headers and status are available.
+
+ INTERACTIVE: 3, // Downloading, responseText holds the partial data.
+
+ COMPLETED: 4 // Finished with all operations.
+},
+
+E_START = 'start',
+
+E_FAIL = 'fail',
+
+E_PUSHED = 'pushed',
+
+E_RECONNECT = 'reconnect',
+
+E_INVALID_FORMAT= 'invalidFormat';
+
+/**
+ * @class CometStream
+ * @description CometStream class
+ * @constructor
+ * @extends EventTarget
+ * @param cfg {Object} configuration object
+ */
+function CometStream(cfg) {
+ CometStream.superclass.constructor.apply(this, arguments);
+
+ /**
+ * @event start
+ * @description This event is fired when stream is started.
+ * @type Event Custom
+ */
+ this.publish(E_START, {
+ emitFacade: true
+ });
+
+ /**
+ * @event fail
+ * @description This event is fired when stream fails to be connected.
+ * @type Event Custom
+ */
+ this.publish(E_FAIL, {
+ fireOnce: true,
+ emitFacade: true
+ });
+
+ /**
+ * @event pushed
+ * @description This event is fired when message is pushed in the stream.
+ * @type Event Custom
+ */
+ this.publish(E_PUSHED, {
+ emitFacade: true
+ });
+
+ /**
+ * @event reconnect
+ * @description This event is fired when stream connection is reconnected.
+ * @type Event Custom
+ */
+ this.publish(E_RECONNECT, {
+ emitFacade: true
+ });
+
+ /**
+ * @event invalidFormat
+ * @description This event is fired when server pushed message violate message format.
+ * @type Event Custom
+ */
+ this.publish(E_INVALID_FORMAT, {
+ emitFacade: true
+ });
+}
+
+CometStream.NAME = 'cometStream';
+
+CometStream.ATTRS = {
+ /**
+ * Stream URL
+ *
+ * @attribute url
+ * @type String
+ */
+ url: {
+ },
+
+ /**
+ * Timeout to create stream connection in milliseconds
+ *
+ * @attribute connectTimeout
+ * @default 20000
+ * @type Number
+ */
+ connectTimeout: {
+ value: 20 * 1000
+ },
+
+ /**
+ * Stream connection is reset every given seconds to avoid memory leak.
+ *
+ * @attribute resetTimeout
+ * @default 20000
+ * @type Number
+ */
+ resetTimeout: {
+ value: 300 * 1000
+ },
+
+ /**
+ * Whether to retry on HTTP dis-connected.
+ *
+ * @attribute resetTimeout
+ * @default true
+ * @type Boolean
+ */
+ retryOnDisconnect: {
+ value: true
+ },
+
+ /*
+ * XHR polling internal(milliseconds) for Opera
+ *
+ * @attribute operaXhrPollingInterval
+ * @default 50
+ * @type Number
+ */
+ operaXhrPollingInterval: {
+ value: 50
+ }
+};
+
+CometStream.prototype = {
+
+ /**
+ * @method start
+ * @description start this stream.
+ */
+ start: function() {
+ this._initStream();
+ },
+
+ /**
+ * @method close
+ * @description close this stream.
+ */
+ close: function() {
+ this._endStream();
+ this._closed = true;
+ },
+
+ _initStream: function() {
+ var xhr,
+ that = this;
+
+ /*
+ * Last pushed data index which is to track newly pushed data start point.
+ */
+ this._lastMsgIdx = 0;
+
+ if (Y.UA.ie) {
+ this._createIFrame(this.get('url'), Y.bind(this._onPushedMsgFromIFrame, this));
+ } else {
+ xhr = this.xhr = this._createXHR();
+
+ xhr.onreadystatechange = function() {
+ that._onXhrStreamStateChange();
+ };
+
+ xhr.open('GET', this.get('url'), true);
+
+ xhr.send();
+ }
+
+ this._failTimer = Y.later(this.get('connectTimeout'), this, this._failTimeout, null);
+ this._streamStartTime = new Date();
+
+ Y.later(this.get('resetTimeout'), this, this._reconnect);
+
+ this._fireStartEvent();
+ },
+
+ _failTimeout: function() {
+ this.fire(E_FAIL);
+ this._failTimer = null;
+ this._endStream();
+ },
+
+ _succeedToConnect: function() {
+ if (this._failTimer) {
+ this._failTimer.cancel();
+ }
+ },
+
+ _endStream: function() {
+ if (this.transDoc) {
+ this.iframeDiv.innerHTML = '';
+ this.transDoc = null; // Let it be GC-ed
+ }
+
+ if (this._pollHandler) {
+ this._pollHandler.cancel();
+ }
+
+ if (this.xhr) {
+ var xhr = this.xhr;
+ this.xhr = null;
+ xhr.onreadystatechange = null;
+ xhr.abort();
+ }
+ },
+
+ _pollResponse: function() {
+ this._parseResponse(this.xhr.responseText);
+ },
+
+ _onXhrStreamStateChange: function() {
+ var xhr = this.xhr,
+ status;
+ if (!xhr) {
+ return;
+ }
+
+ if (xhr.readyState < READY_STATE.INTERACTIVE) {
+ //Opera throw exception if we check xhr.status when readyState < INTERACTIVE
+ return;
+ }
+
+ status = xhr.status;
+
+ if (status === 200) {
+ if (xhr.readyState === READY_STATE.INTERACTIVE) {
+ // For Opera, it doesn't trigger INTERACTIVE ready state for each pushed data. So, we have to do polling.
+ //
+ if (Y.UA.opera) {
+ this._pollHandler = Y.later(this.get('operaXhrPollingInterval'), this, this._pollResponse, null, true);
+ } else {
+ this._parseResponse(xhr.responseText);
+ }
+ } else if (xhr.readyState === READY_STATE.COMPLETED) {
+ if (Y.UA.opera) {
+ // poll it for the last time in case something is missing.
+ this._pollResponse();
+ }
+
+ if (this.get('retryOnDisconnect')) {
+ this._reconnect();
+ }
+ }
+ } else {
+ this.fire(E_FAIL);
+ }
+ },
+
+ _fireStartEvent: function() {
+ this.fire(E_START);
+ },
+
+ _reconnect: function() {
+ this._endStream();
+
+ if (!this._closed) {
+ this.fire(E_RECONNECT);
+ this._initStream();
+ }
+ },
+
+ _parseResponse: function(responseText) {
+ this._succeedToConnect();
+
+ // Browser doesn't expose chunked structure to us. So, we have to build chunked data based on HTTP trunked data.
+ while (true) {
+ var msg, msgStartPos, msgEndPos,
+ sizeStartPos, sizeEndPos, sizeLine, size;
+
+ sizeStartPos = this._lastMsgIdx;
+ sizeEndPos = responseText.indexOf('\r\n', sizeStartPos);
+ if (sizeEndPos == -1) {
+ break;
+ }
+ sizeLine = responseText.substring(sizeStartPos, sizeEndPos);
+ size = Number('0x' + Y.Lang.trim(sizeLine));
+
+ if (window.isNaN(size)) {
+ this.fire(E_INVALID_FORMAT);
+ this._endStream();
+ return;
+ }
+
+ msgStartPos = sizeEndPos + 2; //pass '\r\n'
+ msgEndPos = msgStartPos + size;
+
+ if (msgEndPos > responseText.length) {
+ // this chunk doesn't get completed yet.
+ break;
+ }
+
+ this._lastMsgIdx = msgEndPos + 2; // pass '\r\n'
+ msg = responseText.substr(msgStartPos, size);
+
+ this._fireMessageEvent(msg);
+ }
+ },
+
+ _onPushedMsgFromIFrame: function(msg) {
+ // iframe channel should pushed down some message on connection success so that client knows the channel is alive.
+ this._succeedToConnect();
+
+ this._fireMessageEvent(msg);
+ },
+
+ _fireMessageEvent: function(msg) {
+ this.fire(E_PUSHED, {data: msg});
+ },
+
+ _createIFrame: function(url, callback) {
+ var m;
+
+ // Don't let transDoc be GC-ed.
+ this.transDoc = new window.ActiveXObject('htmlfile');
+ this.transDoc.open();
+
+ // Don't assign domain if same. It will break in IE8.
+ //
+ m = url.match(/^http.?:\/\/([^\/]+)\/?/);
+ if (m && (m[1] !== window.document.domain)) {
+ this.transDoc.write('<html><script type="text/javascript">document.domain="' + window.document.domain + '";</script></html>');
+ }
+ this.transDoc.write('<html></html>');
+ this.transDoc.close();
+
+ // TODO:
+ // This makes only one instance of CometStream instance allwoed in in one page. Otherwise multiple iframe channel will conflicts
+ // in callback. Perhaps we can specify callback method or channel id name in iframe URL query string.
+ //
+ this.transDoc.parentWindow.push = callback;
+
+ this.iframeDiv = this.transDoc.createElement('div');
+ this.transDoc.body.appendChild(this.iframeDiv);
+ this.iframeDiv.innerHTML = '<iframe src="' + url + '"></iframe>';
+ },
+
+ _createXHR: function() {
+ var xhrObj = null;
+
+ // most browsers (including IE7) just use below 2 lines
+ if (window.XMLHttpRequest) {
+ xhrObj = new XMLHttpRequest();
+ } else if (window.ActiveXObject) {
+ // IE5/6 falls into this block
+ //
+ // NOTE: Actually, we cannot implement comet with IE XHR since it doesn't trigger readyState===INTERACTIVE state in progress.
+ // I keep below code for Long-Poll(perhaps in the future)
+ /*
+ try {
+ xhrObj = new window.ActiveXObject('Msxml2.XMLHTTP');
+ } catch (e1) {
+ try {
+ xhrObj = new window.ActiveXObject('Microsoft.XMLHTTP');
+ } catch (e2) {
+ xhrObj = null;
+ }
+ }
+ */
+ }
+ if (!xhrObj) {
+ throw new Error('XMLHttpRequest is not supported');
+ }
+ return xhrObj;
+ }
+};
+
+Y.extend(CometStream, Y.Base, CometStream.prototype);
+
+Y.CometStream = CometStream;
+
+
+}, 'gallery-2011.02.23-19-01' ,{requires:['base']});
View
2,831 build/gallery-form/gallery-form-debug.js
1,436 additions, 1,395 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
8 build/gallery-form/gallery-form-min.js
@@ -1,4 +1,4 @@
-YUI.add("gallery-form",function(a){a.Form=a.Base.create("form",a.Widget,[a.WidgetParent],{toString:function(){return this.name;},CONTENT_TEMPLATE:"<form></form>",_ioIds:null,_validateMethod:function(b){if(!a.Lang.isString(b)){return false;}if(b.toLowerCase()!="get"&&b.toLowerCase()!="post"){return false;}return true;},_parseAction:function(b){var c=b.one("form");if(!c){c=b;}if(c){return c.get("action");}},_parseMethod:function(b){var c=b.one("form");if(!c){c=b;}if(c){return c.get("method");}},_parseFields:function(c){var e=c.all("*"),f=c.all("label"),b=[],d={text:a.TextField,hidden:a.HiddenField,file:a.FileField,checkbox:a.CheckboxField,radio:a.RadioField,reset:a.ResetButton,submit:a.SubmitButton,button:(a.Button||a.FormButton)};e.each(function(j,h,g){var n=j.get("nodeName"),l=j.get("id"),i,k,m=[];if(n=="INPUT"){i=j.get("type");k={type:(d[i]?d[i]:a.TextField),name:j.get("name"),value:j.get("value"),checked:j.get("checked")};if(k.type==d.button){k.label=j.get("value");}}else{if(n=="BUTTON"){k={type:d.button,name:j.get("name"),label:j.get("innerHTML")};}else{if(n=="SELECT"){j.all("option").each(function(p,q,o){m.push({label:p.get("innerHTML"),value:p.get("value")});});k={type:a.SelectField,name:j.get("name"),choices:m};}else{if(n=="TEXTAREA"){k={type:a.TextareaField,name:j.get("name"),value:j.get("innerHTML")};}}}}if(k){if(l){k.id=l;f.some(function(p,q,o){if(p.get("htmlFor")==l){k.label=p.get("innerHTML");}});}b.push(k);}j.remove();});return b;},_syncFormAttributes:function(){var b=this.get("contentBox");b.setAttrs({action:this.get("action"),method:this.get("method")});if(this.get("encodingType")===a.Form.MULTIPART_ENCODED){b.setAttribute("enctype","multipart/form-data");}},_runValidation:function(){var b=true;this.each(function(c){c.set("error",null);if(c.validateField()===false){b=false;}});return b;},_enableInlineValidation:function(){this.each(function(b){b.set("validateInline",true);});},_disableInlineValidation:function(){this.each(function(b){b.set("validateInline",false);});},_handleIOEvent:function(d,b,c){if(this._ioIds[b]!==undefined){this.fire(d,{response:c});}},reset:function(){this.each(function(c){c.resetFieldNode();c.set("error",null);});var b=a.Node.getDOMNode(this.get("contentBox"));if(a.Lang.isFunction(b.reset)){b.reset();}},submit:function(){if(this.get("skipValidationBeforeSubmit")===true||this._runValidation()){var c=this.get("action"),e=this.get("method"),d=this.get("submitViaIO"),f,b;if(d===true){b={method:e,form:{id:this.get("contentBox"),upload:(this.get("encodingType")===a.Form.MULTIPART_ENCODED)}};f=a.io(c,b);this._ioIds[f.id]=f;}else{this.get("contentBox").submit();}}},getField:function(b){var c;if(a.Lang.isNumber(b)){c=this.item(b);}else{if(a.Lang.isString(b)){this.each(function(d){if(d.get("name")==b){c=d;}});}}return c;},initializer:function(b){this._ioIds={};this.publish("submit");this.publish("reset");this.publish("start");this.publish("success");this.publish("failure");this.publish("complete");this.publish("xdr");},destructor:function(){},renderUI:function(){},bindUI:function(){this.get("contentBox").on("submit",a.bind(function(b){b.halt();},this));this.after("inlineValidationChange",a.bind(function(b){if(b.newVal===true){this._enableInlineValidation();}else{this._disableInlineValidation();}},this));this.after("success",a.bind(function(b){if(this.get("resetAfterSubmit")===true){this.reset();}},this));a.on("io:start",a.bind(this._handleIOEvent,this,"start"));a.on("io:complete",a.bind(this._handleIOEvent,this,"complete"));a.on("io:xdr",a.bind(this._handleIOEvent,this,"xdr"));a.on("io:success",a.bind(this._handleIOEvent,this,"success"));a.on("io:failure",a.bind(this._handleIOEvent,this,"failure"));this.each(a.bind(function(b){if(b.name=="submit-button"){b.on("click",a.bind(this.submit,this));}else{if(b.name=="reset-button"){b.on("click",a.bind(this.reset,this));}}},this));},syncUI:function(){this._syncFormAttributes();if(this.get("inlineValidation")===true){this._enableInlineValidation();}}},{ATTRS:{defaultChildType:{valueFn:function(){return a.TextField;}},method:{value:"post",validator:function(b){return this._validateMethod(b);},setter:function(b){return b.toLowerCase();}},action:{value:".",validator:a.Lang.isString},fields:{setter:function(b){return this.set("children",b);}},inlineValidation:{value:false,validator:a.Lang.isBoolean},resetAfterSubmit:{value:true,validator:a.Lang.isBoolean},encodingType:{value:1,validator:a.Lang.isNumber},skipValidationBeforeSubmit:{value:false,validator:a.Lang.isBoolean},submitViaIO:{value:true,validator:a.Lang.isBoolean}},HTML_PARSER:{action:function(b){return this._parseAction(b);},method:function(b){return this._parseMethod(b);},children:function(b){return this._parseFields(b);}},FORM_TEMPLATE:"<form></form>",URL_ENCODED:1,MULTIPART_ENCODED:2});a.FormField=a.Base.create("form-field",a.Widget,[a.WidgetParent,a.WidgetChild],{toString:function(){return this.name;},_labelNode:null,_fieldNode:null,_errorNode:null,_initialValue:null,_validateError:function(b){if(a.Lang.isString(b)){return true;}if(b===null||typeof b=="undefined"){return true;}return false;},_validateValidator:function(c){if(a.Lang.isString(c)){var b=/^(email|phone|ip|date|time|postal|special)$/;if(b.test(c)===true){return true;}}if(a.Lang.isFunction(c)){return true;}return false;},_setValidator:function(c){var b={email:a.FormField.VALIDATE_EMAIL_ADDRESS,phone:a.FormField.VALIDATE_PHONE_NUMBER,ip:a.FormField.VALIDATE_IP_ADDRESS,date:a.FormField.VALIDATE_DATE,time:a.FormField.VALIDATE_TIME,postal:a.FormField.VALIDATE_POSTAL_CODE,special:a.FormField.VALIDATE_NO_SPECIAL_CHARS};return(b[c]?b[c]:c);},_renderLabelNode:function(){var b=this.get("contentBox"),c=b.one("label");if(!c||c.get("for")!=this.get("id")){c=a.Node.create(a.FormField.LABEL_TEMPLATE);b.appendChild(c);}this._labelNode=c;},_renderFieldNode:function(){var b=this.get("contentBox"),c=b.one("#"+this.get("id"));if(!c){c=a.Node.create(a.FormField.INPUT_TEMPLATE);b.appendChild(c);}this._fieldNode=c;},_syncLabelNode:function(){if(this._labelNode){this._labelNode.setAttrs({innerHTML:this.get("label")});
-this._labelNode.setAttribute("for",this.get("id")+a.FormField.FIELD_ID_SUFFIX);}},_syncFieldNode:function(){var b=this.name.split("-")[0];if(!b){return;}this._fieldNode.setAttrs({name:this.get("name"),type:b,id:this.get("id")+a.FormField.FIELD_ID_SUFFIX,value:this.get("value")});this._fieldNode.setAttribute("tabindex",a.FormField.tabIndex);a.FormField.tabIndex++;},_syncError:function(){var b=this.get("error");if(b){this._showError(b);}},_syncDisabled:function(c){var b=this.get("disabled");if(b===true){this._fieldNode.setAttribute("disabled","disabled");}else{this._fieldNode.removeAttribute("disabled");}},_checkRequired:function(){if(this.get("required")===true&&this.get("value").length===0){return false;}return true;},_showError:function(c){var b=this.get("contentBox"),d=a.Node.create("<span>"+c+"</span>");d.addClass("error");b.insertBefore(d,this._labelNode);this._errorNode=d;},_clearError:function(){if(this._errorNode){var b=this.get("contentBox");b.removeChild(this._errorNode);this._errorNode=null;}},_enableInlineValidation:function(){this.after("valueChange",a.bind(this.validateField,this));},_disableInlineValidation:function(){this.detach("valueChange",this.validateField,this);},validateField:function(d){var c=this.get("value"),b=this.get("validator");this.set("error",null);if(d&&d.src!="ui"){return false;}if(!this._checkRequired()){this.set("error",a.FormField.REQUIRED_ERROR_TEXT);return false;}else{if(!c){return true;}}return b.call(this,c,this);},resetFieldNode:function(){this.set("value",this._initialValue);this._fieldNode.set("value",this._initialValue);this.fire("nodeReset");},clear:function(){this.set("value","");this._fieldNode.set("value","");this._initialValue=null;this.fire("clear");},initializer:function(){this.publish("blur");this.publish("change");this.publish("focus");this.publish("clear");this.publish("nodeReset");this._initialValue=this.get("value");},destructor:function(b){},renderUI:function(){this._renderLabelNode();this._renderFieldNode();},bindUI:function(){this._fieldNode.on("change",a.bind(function(b){this.set("value",this._fieldNode.get("value"),{src:"ui"});this.fire("change",b);},this));this.on("valueChange",a.bind(function(b){if(b.src!="ui"){this._fieldNode.set("value",b.newVal);}},this));this._fieldNode.on("blur",a.bind(function(b){this.set("value",this._fieldNode.get("value"),{src:"ui"});this.fire("blur",b);},this));this._fieldNode.on("focus",a.bind(function(b){this.fire("focus",b);},this));this.on("errorChange",a.bind(function(b){if(b.newVal){this._showError(b.newVal);}else{this._clearError();}},this));this.on("validateInlineChange",a.bind(function(b){if(b.newVal===true){this._enableInlineValidation();}else{this._disableInlineValidation();}},this));this.on("disabledChange",a.bind(function(b){this._syncDisabled();},this));},syncUI:function(){this.get("boundingBox").removeAttribute("tabindex");this._syncLabelNode();this._syncFieldNode();this._syncError();this._syncDisabled();if(this.get("validateInline")===true){this._enableInlineValidation();}}},{ATTRS:{id:{value:a.guid(),validator:a.Lang.isString,writeOnce:true},name:{validator:a.Lang.isString,writeOnce:true},value:{value:"",validator:a.Lang.isString},label:{value:"",validator:a.Lang.isString},validator:{value:function(b){return true;},validator:function(b){return this._validateValidator(b);},setter:function(b){return this._setValidator(b);}},error:{value:false,validator:function(b){return this._validateError(b);}},required:{value:false,validator:a.Lang.isBoolean},validateInline:{value:false,validator:a.Lang.isBoolean},disabled:{value:false,validator:a.Lang.isBoolean}},tabIndex:1,VALIDATE_EMAIL_ADDRESS:function(d,c){var b=/^([\w]+(?:\.[\w]+)*)@((?:[\w]+\.)*\w[\w]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;if(b.test(d)===false){c.set("error",a.FormField.INVALID_EMAIL_MESSAGE);return false;}return true;},INVALID_EMAIL_MESSAGE:"Please enter a valid email address",VALIDATE_PHONE_NUMBER:function(d,c){var b=/^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;if(b.test(d)===false){c.set("error",a.FormField.INVALID_PHONE_NUMBER);return false;}return true;},INVALID_PHONE_NUMBER:"Please enter a valid phone number",VALIDATE_IP_ADDRESS:function(f,e){var c=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,b,d=true;if(c.test(f)===false){d=false;}b=f.split(".");a.Array.each(b,function(h,j,g){var k=parseInt(h,10);if(k<0||k>255){d=false;}});if(d===false){e.set("error",a.FormField.INVALID_IP_MESSAGE);}return d;},INVALID_IP_MESSAGE:"Please enter a valid IP address",VALIDATE_DATE:function(d,c){var b=/^([1-9]|1[0-2])(\-|\/)([0-2][0-9]|3[0-1])(\-|\/)(\d{4}|\d{2})$/;if(b.test(d)===false){c.set("error",a.FormField.INVALID_DATE_MESSAGE);return false;}return true;},INVALID_DATE_MESSAGE:"Please enter a a valid date",VALIDATE_TIME:function(d,c){var b=/^([1-9]|1[0-2]):[0-5]\d(:[0-5]\d(\.\d{1,3})?)?$/;if(b.test(d)===false){c.set("error",a.FormField.INVALID_TIME_MESSAGE);return false;}return true;},INVALID_TIME_MESSAGE:"Please enter a valid time",VALIDATE_POSTAL_CODE:function(e,d){var b,c=true;if(e.length==6||e.length==7){b=/^[a-zA-Z]\d[a-zA-Z](-|\s)?\d[a-zA-Z]\d$/;}else{if(e.length==5||e.length==10){b=/^\d{5}((-|\s)\d{4})?$/;}else{if(e.length>0){c=false;}}}if(c===false||(b&&b.test(e)===false)){d.set("error",a.FormField.INVALID_POSTAL_CODE_MESSAGE);return false;}return true;},INVALID_POSTAL_CODE_MESSAGE:"Please enter a valid postal code",VALIDATE_NO_SPECIAL_CHARS:function(d,c){var b=/^[a-zA-Z0-9]*$/;if(b.test(d)===false){c.set("error",a.FormField.INVALID_SPECIAL_CHARS);return false;}return true;},INVALID_SPECIAL_CHARS:"Please use only letters and numbers",INPUT_TEMPLATE:"<input />",LABEL_TEMPLATE:"<label></label>",REQUIRED_ERROR_TEXT:"This field is required",FIELD_ID_SUFFIX:"-field"});a.TextField=a.Base.create("text-field",a.FormField,[a.WidgetChild]);a.PasswordField=a.Base.create("password-field",a.FormField,[a.WidgetChild]);a.CheckboxField=a.Base.create("checkbox-field",a.FormField,[a.WidgetChild],{_syncChecked:function(){this._fieldNode.set("checked",this.get("checked"));
-},initializer:function(){a.CheckboxField.superclass.initializer.apply(this,arguments);},syncUI:function(){a.CheckboxField.superclass.syncUI.apply(this,arguments);this._syncChecked();},bindUI:function(){a.CheckboxField.superclass.bindUI.apply(this,arguments);this.after("checkedChange",a.bind(function(b){if(b.src!="ui"){this._fieldNode.set("checked",b.newVal);}},this));this._fieldNode.after("change",a.bind(function(b){this.set("checked",b.currentTarget.get("checked"),{src:"ui"});},this));}},{ATTRS:{"checked":{value:false,validator:a.Lang.isBoolean}}});a.RadioField=a.Base.create("radio-field",a.FormField,[a.WidgetChild]);a.HiddenField=a.Base.create("hidden-field",a.FormField,[a.WidgetChild],{_valueDisplayNode:null,_renderValueDisplayNode:function(){if(this.get("displayValue")===true){var c=a.Node.create("<div></div>"),b=this.get("contentBox");b.appendChild(c);this._valueDisplayNode=c;}},renderUI:function(){a.HiddenField.superclass.renderUI.apply(this,arguments);this._renderValueDisplayNode();},bindUI:function(){a.HiddenField.superclass.bindUI.apply(this,arguments);if(this.get("displayValue")===true){this.after("valueChange",a.bind(function(b,c){this._valueDisplayNode.set("innerHTML",c.newVal);},this,true));}},clear:function(){}},{ATTRS:{displayValue:{value:false,writeOnce:true,validator:a.Lang.isBoolean}}});a.TextareaField=a.Base.create("textarea-field",a.FormField,[a.WidgetChild],{_renderFieldNode:function(){var b=this.get("contentBox"),c=b.one("#"+this.get("id"));if(!c){c=a.Node.create(a.TextareaField.NODE_TEMPLATE);c.setAttrs({name:this.get("name"),innerHTML:this.get("value")});b.appendChild(c);}c.setAttribute("tabindex",a.FormField.tabIndex);a.FormField.tabIndex++;this._fieldNode=c;}},{NODE_TEMPLATE:"<textarea></textarea>"});a.ChoiceField=a.Base.create("choice-field",a.FormField,[a.WidgetParent,a.WidgetChild],{_validateChoices:function(d){if(!a.Lang.isArray(d)){return false;}var c=0,b=d.length;for(;c<b;c++){if(!a.Lang.isObject(d[c])){delete d[c];continue;}if(!d[c].label||!a.Lang.isString(d[c].label)||!d[c].value||!a.Lang.isString(d[c].value)){delete d[c];continue;}}if(d.length===0){return false;}return true;},_renderLabelNode:function(){var b=this.get("contentBox"),c=a.Node.create("<span></span>");c.set("innerHTML",this.get("label"));b.appendChild(c);this._labelNode=c;},_renderFieldNode:function(){var d=this.get("contentBox"),e=this.get("choices"),b=this.get("multi"),c=(b===true?a.CheckboxField:a.RadioField);a.Array.each(e,function(k,h,g){var f={value:k.value,id:(this.get("id")+"_choice"+h),name:this.get("name"),label:k.label},j=new c(f);j.render(d);},this);this._fieldNode=d.all("input");},_syncFieldNode:function(){var b=this.get("value");if(b){this._fieldNode.some(function(d,c,e){if(d.get("value")==b){d.setAttribute("checked",true);return true;}},this);}},clear:function(){this._fieldNode.each(function(c,b,d){c.setAttribute("checked",false);},this);this.set("value","");},bindUI:function(){this._fieldNode.on("change",a.bind(function(b){this._fieldNode.each(function(d,c,e){if(d.get("checked")===true){this.set("value",d.get("value"));}},this);},this));}},{ATTRS:{choices:{validator:function(b){return this._validateChoices(b);}},multi:{validator:a.Lang.isBoolean,value:false}}});a.SelectField=a.Base.create("select-field",a.ChoiceField,[a.WidgetParent,a.WidgetChild],{_renderFieldNode:function(){var b=this.get("contentBox"),c=b.one("#"+this.get("id"));if(!c){c=a.Node.create(a.SelectField.NODE_TEMPLATE);b.appendChild(c);}this._fieldNode=c;this._renderOptionNodes();},_renderOptionNodes:function(){var c=this.get("choices"),b;if(this.get("useDefaultOption")===true){b=a.Node.create(a.SelectField.OPTION_TEMPLATE);this._fieldNode.appendChild(b);}a.Array.each(c,function(f,e,d){b=a.Node.create(a.SelectField.OPTION_TEMPLATE);this._fieldNode.appendChild(b);},this);},_syncFieldNode:function(){a.SelectField.superclass.constructor.superclass._syncFieldNode.apply(this,arguments);this._fieldNode.setAttrs({multiple:(this.get("multi")===true?"multiple":"")});},_syncOptionNodes:function(){var f=this.get("choices"),b=this.get("contentBox"),d=b.all("option"),e=this.get("useDefaultOption"),c=this.get("value");if(e===true){f.unshift({label:a.SelectField.DEFAULT_OPTION_TEXT,value:""});}d.each(function(j,i,h){var g=f[i].label,k=f[i].value;j.setAttrs({innerHTML:g,value:k});if(c==k){j.setAttrs({selected:true,defaultSelected:true});}},this);},clear:function(){this._fieldNode.value="";},bindUI:function(){a.SelectField.superclass.constructor.superclass.bindUI.apply(this,arguments);},syncUI:function(){a.SelectField.superclass.syncUI.apply(this,arguments);this._syncOptionNodes();}},{NODE_TEMPLATE:"<select></select>",OPTION_TEMPLATE:"<option></option>",DEFAULT_OPTION_TEXT:"Choose one",ATTRS:{useDefaultOption:{validator:a.Lang.isBoolean,value:true}}});a.FormButton=a.Base.create("button-field",a.FormField,[a.WidgetChild],{_renderButtonNode:function(){var b=this.get("contentBox"),c;c=a.Node.create(a.FormButton.NODE_TEMPLATE);b.appendChild(c);this._fieldNode=c;},_syncLabelNode:function(){},_syncFieldNode:function(){this._fieldNode.setAttrs({innerHTML:this.get("label"),id:this.get("id")});this.get("contentBox").addClass("first-child");},_setClickHandler:function(){if(!this._fieldNode){return;}var b=this.get("onclick");a.Event.purgeElement(this._fieldNode,true,"click");a.on("click",a.bind(b.fn,b.scope,true),this._fieldNode);},renderUI:function(){this._renderButtonNode();},bindUI:function(){this.after("onclickChange",a.bind(this._setClickHandler,this,true));this._setClickHandler();}},{ATTRS:{onclick:{validator:function(b){if(a.Lang.isObject(b)===false){return false;}if(typeof b.fn=="undefined"||a.Lang.isFunction(b.fn)===false){return false;}return true;},value:{fn:function(b){}},setter:function(b){b.scope=b.scope||this;b.argument=b.argument||{};return b;}}},NODE_TEMPLATE:"<button></button>"});a.FileField=a.Base.create("file-field",a.FormField,[a.WidgetChild],{_renderFieldNode:function(){var b=this.get("contentBox"),c=b.one("#"+this.get("id"));
-if(!c){c=a.Node.create(a.FileField.FILE_INPUT_TEMPLATE);b.appendChild(c);}this._fieldNode=c;}},{FILE_INPUT_TEMPLATE:'<input type="file" />'});a.SubmitButton=a.Base.create("submit-button",a.FormField,[a.WidgetChild],{_renderLabelNode:function(){}});a.ResetButton=a.Base.create("reset-button",a.FormField,[a.WidgetChild],{_renderLabelNode:function(){}});},"gallery-2011.01.26-20-33",{requires:["node","widget-base","widget-htmlparser","io-form","widget-parent","widget-child","base-build","substitute"]});
+YUI.add("gallery-form",function(a){a.Form=a.Base.create("form",a.Widget,[a.WidgetParent],{toString:function(){return this.name;},CONTENT_TEMPLATE:"<form></form>",_ioIds:null,_validateMethod:function(b){if(!a.Lang.isString(b)){return false;}if(b.toLowerCase()!="get"&&b.toLowerCase()!="post"){return false;}return true;},_parseAction:function(b){var c=b.one("form");if(!c){c=b;}if(c){return c.get("action");}},_parseMethod:function(b){var c=b.one("form");if(!c){c=b;}if(c){return c.get("method");}},_parseFields:function(c){var e=c.all("*"),f=c.all("label"),b=[],d={text:a.TextField,hidden:a.HiddenField,file:a.FileField,checkbox:a.CheckboxField,radio:a.RadioField,reset:a.ResetButton,submit:a.SubmitButton,button:(a.Button||a.FormButton)};e.each(function(j,h,g){var n=j.get("nodeName"),l=j.get("id"),i,k,m=[];if(n=="INPUT"){i=j.get("type");k={type:(d[i]?d[i]:a.TextField),name:j.get("name"),value:j.get("value"),checked:j.get("checked")};if(k.type==d.button){k.label=j.get("value");}}else{if(n=="BUTTON"){k={type:d.button,name:j.get("name"),label:j.get("innerHTML")};}else{if(n=="SELECT"){j.all("option").each(function(p,q,o){m.push({label:p.get("innerHTML"),value:p.get("value")});});k={type:a.SelectField,name:j.get("name"),choices:m};}else{if(n=="TEXTAREA"){k={type:a.TextareaField,name:j.get("name"),value:j.get("innerHTML")};}}}}if(k){if(l){k.id=l;f.some(function(p,q,o){if(p.get("htmlFor")==l){k.label=p.get("innerHTML");}});}b.push(k);}j.remove();});return b;},_syncFormAttributes:function(){var b=this.get("contentBox");b.setAttrs({action:this.get("action"),method:this.get("method")});if(this.get("encodingType")===a.Form.MULTIPART_ENCODED){b.setAttribute("enctype","multipart/form-data");}},_runValidation:function(){var b=true;this.each(function(c){if(c.validateField()===false){b=false;}});return b;},_enableInlineValidation:function(){this.each(function(b){b.set("validateInline",true);});},_disableInlineValidation:function(){this.each(function(b){b.set("validateInline",false);});},_handleIOEvent:function(d,b,c){if(this._ioIds[b]!==undefined){this.fire(d,{response:c});}},reset:function(){var b=a.Node.getDOMNode(this.get("contentBox"));if(a.Lang.isFunction(b.reset)){b.reset();}this.each(function(c){c.resetFieldNode();c.set("error",null);});},submit:function(){if(this.get("skipValidationBeforeSubmit")===true||this._runValidation()){var c=this.get("action"),e=this.get("method"),d=this.get("submitViaIO"),f,b;if(d===true){b={method:e,form:{id:this.get("contentBox"),upload:(this.get("encodingType")===a.Form.MULTIPART_ENCODED)}};var g=this.get("io");f=g(c,b);this._ioIds[f.id]=f;}else{this.get("contentBox").submit();}}},getField:function(b){var c;if(a.Lang.isNumber(b)){c=this.item(b);}else{if(a.Lang.isString(b)){this.each(function(d){if(d.get("name")==b){c=d;}});}}return c;},initializer:function(b){this._ioIds={};this.publish("submit");this.publish("reset");this.publish("start");this.publish("success");this.publish("failure");this.publish("complete");this.publish("xdr");},destructor:function(){},renderUI:function(){},bindUI:function(){this.get("contentBox").on("submit",a.bind(function(b){b.halt();},this));this.after("inlineValidationChange",a.bind(function(b){if(b.newVal===true){this._enableInlineValidation();}else{this._disableInlineValidation();}},this));this.after("success",a.bind(function(b){if(this.get("resetAfterSubmit")===true){this.reset();}},this));a.on("io:start",a.bind(this._handleIOEvent,this,"start"));a.on("io:complete",a.bind(this._handleIOEvent,this,"complete"));a.on("io:xdr",a.bind(this._handleIOEvent,this,"xdr"));a.on("io:success",a.bind(this._handleIOEvent,this,"success"));a.on("io:failure",a.bind(this._handleIOEvent,this,"failure"));this.each(a.bind(function(b){if(b.name=="submit-button"){b.on("click",a.bind(this.submit,this));}else{if(b.name=="reset-button"){b.on("click",a.bind(this.reset,this));}}},this));},syncUI:function(){this._syncFormAttributes();if(this.get("inlineValidation")===true){this._enableInlineValidation();}}},{ATTRS:{defaultChildType:{valueFn:function(){return a.TextField;}},method:{value:"post",validator:function(b){return this._validateMethod(b);},setter:function(b){return b.toLowerCase();}},action:{value:".",validator:a.Lang.isString},fields:{setter:function(b){return this.set("children",b);}},inlineValidation:{value:false,validator:a.Lang.isBoolean},resetAfterSubmit:{value:true,validator:a.Lang.isBoolean},encodingType:{value:1,validator:a.Lang.isNumber},skipValidationBeforeSubmit:{value:false,validator:a.Lang.isBoolean},submitViaIO:{value:true,validator:a.Lang.isBoolean},io:{value:a.io}},HTML_PARSER:{action:function(b){return this._parseAction(b);},method:function(b){return this._parseMethod(b);},children:function(b){return this._parseFields(b);}},FORM_TEMPLATE:"<form></form>",URL_ENCODED:1,MULTIPART_ENCODED:2});a.FormField=a.Base.create("form-field",a.Widget,[a.WidgetParent,a.WidgetChild],{toString:function(){return this.name;},_labelNode:null,_fieldNode:null,_errorNode:null,_initialValue:null,_validateError:function(b){if(a.Lang.isString(b)){return true;}if(b===null||typeof b=="undefined"){return true;}return false;},_validateValidator:function(c){if(a.Lang.isString(c)){var b=/^(email|phone|ip|date|time|postal|special)$/;if(b.test(c)===true){return true;}}if(a.Lang.isFunction(c)){return true;}return false;},_setValidator:function(c){var b={email:a.FormField.VALIDATE_EMAIL_ADDRESS,phone:a.FormField.VALIDATE_PHONE_NUMBER,ip:a.FormField.VALIDATE_IP_ADDRESS,date:a.FormField.VALIDATE_DATE,time:a.FormField.VALIDATE_TIME,postal:a.FormField.VALIDATE_POSTAL_CODE,special:a.FormField.VALIDATE_NO_SPECIAL_CHARS};return(b[c]?b[c]:c);},_renderLabelNode:function(){var b=this.get("contentBox"),c=b.one("label");if(!c||c.get("for")!=this.get("id")){c=a.Node.create(a.FormField.LABEL_TEMPLATE);b.appendChild(c);}this._labelNode=c;},_renderFieldNode:function(){var b=this.get("contentBox"),c=b.one("#"+this.get("id"));if(!c){c=a.Node.create(a.FormField.INPUT_TEMPLATE);b.appendChild(c);}this._fieldNode=c;
+},_syncLabelNode:function(){if(this._labelNode){this._labelNode.setAttrs({innerHTML:this.get("label")});this._labelNode.setAttribute("for",this.get("id")+a.FormField.FIELD_ID_SUFFIX);}},_syncFieldNode:function(){var b=this.name.split("-")[0];if(!b){return;}this._fieldNode.setAttrs({name:this.get("name"),type:b,id:this.get("id")+a.FormField.FIELD_ID_SUFFIX,value:this.get("value")});this._fieldNode.setAttribute("tabindex",a.FormField.tabIndex);a.FormField.tabIndex++;},_syncError:function(){var b=this.get("error");if(b){this._showError(b);}},_syncDisabled:function(c){var b=this.get("disabled");if(b===true){this._fieldNode.setAttribute("disabled","disabled");}else{this._fieldNode.removeAttribute("disabled");}},_checkRequired:function(){if(this.get("required")===true&&this.get("value").length===0){return false;}return true;},_showError:function(c){var b=this.get("contentBox"),d=a.Node.create("<span>"+c+"</span>");d.addClass("error");b.insertBefore(d,this._labelNode);this._errorNode=d;},_clearError:function(){if(this._errorNode){var b=this.get("contentBox");b.removeChild(this._errorNode);this._errorNode=null;}},_enableInlineValidation:function(){this.after("valueChange",this.validateField,this);},_disableInlineValidation:function(){this.detach("valueChange",this.validateField,this);},validateField:function(d){var c=this.get("value"),b=this.get("validator");this.set("error",null);if(d&&d.src!="ui"){return false;}if(!this._checkRequired()){this.set("error",a.FormField.REQUIRED_ERROR_TEXT);return false;}else{if(!c){return true;}}return b.call(this,c,this);},resetFieldNode:function(){this.set("value",this._initialValue);this._fieldNode.set("value",this._initialValue);this.fire("nodeReset");},clear:function(){this.set("value","");this._fieldNode.set("value","");this._initialValue=null;this.fire("clear");},initializer:function(){this.publish("blur");this.publish("change");this.publish("focus");this.publish("clear");this.publish("nodeReset");this._initialValue=this.get("value");},destructor:function(b){},renderUI:function(){this._renderLabelNode();this._renderFieldNode();},bindUI:function(){this._fieldNode.on("change",a.bind(function(b){this.set("value",this._fieldNode.get("value"),{src:"ui"});},this));this.on("valueChange",a.bind(function(b){if(b.src!="ui"){this._fieldNode.set("value",b.newVal);}},this));this._fieldNode.on("blur",a.bind(function(b){this.set("value",this._fieldNode.get("value"),{src:"ui"});},this));this._fieldNode.on("focus",a.bind(function(b){this.fire("focus",b);},this));this.on("errorChange",a.bind(function(b){if(b.newVal){this._showError(b.newVal);}else{this._clearError();}},this));this.on("validateInlineChange",a.bind(function(b){if(b.newVal===true){this._enableInlineValidation();}else{this._disableInlineValidation();}},this));this.after("disabledChange",a.bind(function(b){this._syncDisabled();},this));},syncUI:function(){this.get("boundingBox").removeAttribute("tabindex");this._syncLabelNode();this._syncFieldNode();this._syncError();this._syncDisabled();if(this.get("validateInline")===true){this._enableInlineValidation();}}},{ATTRS:{id:{value:a.guid(),validator:a.Lang.isString,writeOnce:true},name:{validator:a.Lang.isString,writeOnce:true},value:{value:"",validator:a.Lang.isString},label:{value:"",validator:a.Lang.isString},validator:{value:function(b){return true;},validator:function(b){return this._validateValidator(b);},setter:function(b){return this._setValidator(b);}},error:{value:false,validator:function(b){return this._validateError(b);}},required:{value:false,validator:a.Lang.isBoolean},validateInline:{value:false,validator:a.Lang.isBoolean}},tabIndex:1,VALIDATE_EMAIL_ADDRESS:function(d,c){var b=/^([\w]+(?:\.[\w]+)*)@((?:[\w]+\.)*\w[\w]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;if(b.test(d)===false){c.set("error",a.FormField.INVALID_EMAIL_MESSAGE);return false;}return true;},INVALID_EMAIL_MESSAGE:"Please enter a valid email address",VALIDATE_PHONE_NUMBER:function(d,c){var b=/^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/;if(b.test(d)===false){c.set("error",a.FormField.INVALID_PHONE_NUMBER);return false;}return true;},INVALID_PHONE_NUMBER:"Please enter a valid phone number",VALIDATE_IP_ADDRESS:function(f,e){var c=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,b,d=true;if(c.test(f)===false){d=false;}b=f.split(".");a.Array.each(b,function(h,j,g){var k=parseInt(h,10);if(k<0||k>255){d=false;}});if(d===false){e.set("error",a.FormField.INVALID_IP_MESSAGE);}return d;},INVALID_IP_MESSAGE:"Please enter a valid IP address",VALIDATE_DATE:function(d,c){var b=/^([1-9]|1[0-2])(\-|\/)([0-2][0-9]|3[0-1])(\-|\/)(\d{4}|\d{2})$/;if(b.test(d)===false){c.set("error",a.FormField.INVALID_DATE_MESSAGE);return false;}return true;},INVALID_DATE_MESSAGE:"Please enter a a valid date",VALIDATE_TIME:function(d,c){var b=/^([1-9]|1[0-2]):[0-5]\d(:[0-5]\d(\.\d{1,3})?)?$/;if(b.test(d)===false){c.set("error",a.FormField.INVALID_TIME_MESSAGE);return false;}return true;},INVALID_TIME_MESSAGE:"Please enter a valid time",VALIDATE_POSTAL_CODE:function(e,d){var b,c=true;if(e.length==6||e.length==7){b=/^[a-zA-Z]\d[a-zA-Z](-|\s)?\d[a-zA-Z]\d$/;}else{if(e.length==5||e.length==10){b=/^\d{5}((-|\s)\d{4})?$/;}else{if(e.length>0){c=false;}}}if(c===false||(b&&b.test(e)===false)){d.set("error",a.FormField.INVALID_POSTAL_CODE_MESSAGE);return false;}return true;},INVALID_POSTAL_CODE_MESSAGE:"Please enter a valid postal code",VALIDATE_NO_SPECIAL_CHARS:function(d,c){var b=/^[a-zA-Z0-9]*$/;if(b.test(d)===false){c.set("error",a.FormField.INVALID_SPECIAL_CHARS);return false;}return true;},INVALID_SPECIAL_CHARS:"Please use only letters and numbers",INPUT_TEMPLATE:"<input />",LABEL_TEMPLATE:"<label></label>",REQUIRED_ERROR_TEXT:"This field is required",FIELD_ID_SUFFIX:"-field"});a.TextField=a.Base.create("text-field",a.FormField,[a.WidgetChild]);a.PasswordField=a.Base.create("password-field",a.FormField,[a.WidgetChild]);a.CheckboxField=a.Base.create("checkbox-field",a.FormField,[a.WidgetChild],{_syncChecked:function(){this._fieldNode.set("checked",this.get("checked"));
+},initializer:function(){a.CheckboxField.superclass.initializer.apply(this,arguments);},syncUI:function(){a.CheckboxField.superclass.syncUI.apply(this,arguments);this._syncChecked();},bindUI:function(){a.CheckboxField.superclass.bindUI.apply(this,arguments);this.after("checkedChange",a.bind(function(b){if(b.src!="ui"){this._fieldNode.set("checked",b.newVal);}},this));this._fieldNode.after("change",a.bind(function(b){this.set("checked",b.currentTarget.get("checked"),{src:"ui"});},this));}},{ATTRS:{"checked":{value:false,validator:a.Lang.isBoolean}}});a.RadioField=a.Base.create("radio-field",a.FormField,[a.WidgetChild]);a.HiddenField=a.Base.create("hidden-field",a.FormField,[a.WidgetChild],{_valueDisplayNode:null,_renderValueDisplayNode:function(){if(this.get("displayValue")===true){var c=a.Node.create("<div></div>"),b=this.get("contentBox");b.appendChild(c);this._valueDisplayNode=c;}},renderUI:function(){a.HiddenField.superclass.renderUI.apply(this,arguments);this._renderValueDisplayNode();},bindUI:function(){a.HiddenField.superclass.bindUI.apply(this,arguments);if(this.get("displayValue")===true){this.after("valueChange",a.bind(function(b,c){this._valueDisplayNode.set("innerHTML",c.newVal);},this,true));}},clear:function(){}},{ATTRS:{displayValue:{value:false,writeOnce:true,validator:a.Lang.isBoolean}}});a.TextareaField=a.Base.create("textarea-field",a.FormField,[a.WidgetChild],{_renderFieldNode:function(){var b=this.get("contentBox"),c=b.one("#"+this.get("id"));if(!c){c=a.Node.create(a.TextareaField.NODE_TEMPLATE);c.setAttrs({name:this.get("name"),innerHTML:this.get("value")});b.appendChild(c);}c.setAttribute("tabindex",a.FormField.tabIndex);a.FormField.tabIndex++;this._fieldNode=c;}},{NODE_TEMPLATE:"<textarea></textarea>"});a.ChoiceField=a.Base.create("choice-field",a.FormField,[a.WidgetParent,a.WidgetChild],{_validateChoices:function(d){if(!a.Lang.isArray(d)){return false;}var c=0,b=d.length;for(;c<b;c++){if(!a.Lang.isObject(d[c])){delete d[c];continue;}if(!d[c].label||!a.Lang.isString(d[c].label)||!d[c].value||!a.Lang.isString(d[c].value)){delete d[c];continue;}}if(d.length===0){return false;}return true;},_renderLabelNode:function(){var b=this.get("contentBox"),c=a.Node.create("<span></span>");c.set("innerHTML",this.get("label"));b.appendChild(c);this._labelNode=c;},_renderFieldNode:function(){var d=this.get("contentBox"),e=this.get("choices"),b=this.get("multi"),c=(b===true?a.CheckboxField:a.RadioField);a.Array.each(e,function(k,h,g){var f={value:k.value,id:(this.get("id")+"_choice"+h),name:this.get("name"),label:k.label},j=new c(f);j.render(d);},this);this._fieldNode=d.all("input");},_syncFieldNode:function(){var b=this.get("value").split(",");if(b&&b.length>0){a.Array.each(b,function(c){this._fieldNode.each(function(e,d,f){if(a.Lang.trim(e.get("value"))==a.Lang.trim(c)){e.set("checked",true);return true;}},this);},this);}},clear:function(){this._fieldNode.each(function(c,b,d){c.set("checked",false);},this);this.set("value","");},bindUI:function(){this._fieldNode.on("change",a.bind(function(c){var b="";this._fieldNode.each(function(e,d,f){if(e.get("checked")===true){if(b.length>0){b+=",";}b+=e.get("value");}},this);this.set("value",b);},this));}},{ATTRS:{choices:{validator:function(b){return this._validateChoices(b);}},multi:{validator:a.Lang.isBoolean,value:false}}});a.SelectField=a.Base.create("select-field",a.ChoiceField,[a.WidgetParent,a.WidgetChild],{_renderFieldNode:function(){var b=this.get("contentBox"),c=b.one("#"+this.get("id"));if(!c){c=a.Node.create(a.SelectField.NODE_TEMPLATE);b.appendChild(c);}this._fieldNode=c;this._renderOptionNodes();},_renderOptionNodes:function(){var c=this.get("choices"),b;if(this.get("useDefaultOption")===true){b=a.Node.create(a.SelectField.OPTION_TEMPLATE);this._fieldNode.appendChild(b);}a.Array.each(c,function(f,e,d){b=a.Node.create(a.SelectField.OPTION_TEMPLATE);this._fieldNode.appendChild(b);},this);},_syncFieldNode:function(){a.SelectField.superclass.constructor.superclass._syncFieldNode.apply(this,arguments);this._fieldNode.setAttrs({multiple:(this.get("multi")===true?"multiple":"")});},_syncOptionNodes:function(){var f=this.get("choices"),b=this.get("contentBox"),d=b.all("option"),e=this.get("useDefaultOption"),c=this.get("value");if(e===true){f.unshift({label:a.SelectField.DEFAULT_OPTION_TEXT,value:""});}d.each(function(j,i,h){var g=f[i].label,k=f[i].value;j.setAttrs({innerHTML:g,value:k});if(c==k){j.setAttrs({selected:true,defaultSelected:true});}},this);},clear:function(){this._fieldNode.value="";},bindUI:function(){a.SelectField.superclass.constructor.superclass.bindUI.apply(this,arguments);},syncUI:function(){a.SelectField.superclass.syncUI.apply(this,arguments);this._syncOptionNodes();}},{NODE_TEMPLATE:"<select></select>",OPTION_TEMPLATE:"<option></option>",DEFAULT_OPTION_TEXT:"Choose one",ATTRS:{useDefaultOption:{validator:a.Lang.isBoolean,value:true}}});a.FormButton=a.Base.create("button-field",a.FormField,[a.WidgetChild],{_renderButtonNode:function(){var b=this.get("contentBox"),c;c=a.Node.create(a.FormButton.NODE_TEMPLATE);b.appendChild(c);this._fieldNode=c;},_syncLabelNode:function(){},_syncFieldNode:function(){this._fieldNode.setAttrs({innerHTML:this.get("label"),id:this.get("id")+a.FormField.FIELD_ID_SUFFIX});this.get("contentBox").addClass("first-child");},_setClickHandler:function(){if(!this._fieldNode){return;}var b=this.get("onclick");a.Event.purgeElement(this._fieldNode,true,"click");a.on("click",a.bind(b.fn,b.scope,true),this._fieldNode);},renderUI:function(){this._renderButtonNode();},bindUI:function(){this.after("onclickChange",a.bind(this._setClickHandler,this,true));this._setClickHandler();}},{ATTRS:{onclick:{validator:function(b){if(a.Lang.isObject(b)===false){return false;}if(typeof b.fn=="undefined"||a.Lang.isFunction(b.fn)===false){return false;}return true;},value:{fn:function(b){}},setter:function(b){b.scope=b.scope||this;b.argument=b.argument||{};return b;}}},NODE_TEMPLATE:"<button></button>"});a.FileField=a.Base.create("file-field",a.FormField,[a.WidgetChild],{_renderFieldNode:function(){var b=this.get("contentBox"),c=b.one("#"+this.get("id"));
+if(!c){c=a.Node.create(a.FileField.FILE_INPUT_TEMPLATE);b.appendChild(c);}this._fieldNode=c;}},{FILE_INPUT_TEMPLATE:'<input type="file" />'});a.SubmitButton=a.Base.create("submit-button",a.FormField,[a.WidgetChild],{_renderLabelNode:function(){}});a.ResetButton=a.Base.create("reset-button",a.FormField,[a.WidgetChild],{_renderLabelNode:function(){}});},"gallery-2011.02.23-19-01",{requires:["node","widget-base","widget-htmlparser","io-form","widget-parent","widget-child","base-build","substitute","io-upload-iframe"]});
View
2,823 build/gallery-form/gallery-form.js
1,432 additions, 1,391 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
7 build/gallery-neon/gallery-neon-debug.js
@@ -126,6 +126,11 @@ function neonOn()
}
this.node.setStyle('display', '');
+
+ if (this.flicker_count === 0)
+ {
+ this.node.fire('neon:finished');
+ }
}
function show()
@@ -157,4 +162,4 @@ Y.namespace("Plugin");
Y.Plugin.Neon = Neon;
-}, 'gallery-2011.02.18-23-10' ,{requires:['node-style','node-pluginhost','anim-easing','plugin']});
+}, 'gallery-2011.02.23-19-01' ,{requires:['node-style','node-pluginhost','anim-easing','plugin']});
View
2 build/gallery-neon/gallery-neon-min.js
@@ -1 +1 @@
-YUI.add("gallery-neon",function(e){function b(f){b.superclass.constructor.call(this,f);}b.NAME="NeonPlugin";b.NS="neon";b.ATTRS={backgroundColor:{validator:e.Lang.isString},textColor:{validator:e.Lang.isString},textShadow:{validator:e.Lang.isString},flickerCount:{value:10,validator:e.Lang.isNumber},easing:{value:e.Easing.easeIn,validator:e.Lang.isFunction}};function c(){e.later(Math.round(Math.random()*1000/(this.flicker_max-this.flicker_count)),this,d);this.node.setStyle("display","none");}function d(){this.flicker_count--;if(this.flicker_count>0){var g=this.get("easing");var f={r:g(this.flicker_count,parseInt(this.end_color[1],10),this.start_color[1]-this.end_color[1],this.flicker_max),g:g(this.flicker_count,parseInt(this.end_color[2],10),this.start_color[2]-this.end_color[2],this.flicker_max),b:g(this.flicker_count,parseInt(this.end_color[3],10),this.start_color[3]-this.end_color[3],this.flicker_max)};e.later(Math.round(Math.random()*1000/this.flicker_count),this,c);}else{var f={r:this.end_color[1],g:this.end_color[2],b:this.end_color[3]};}f="rgb("+Math.round(f.r)+","+Math.round(f.g)+","+Math.round(f.b)+")";this.node.setStyle("color",f);var h=this.get("textShadow");if(h){this.node.setStyle("textShadow",e.Lang.sub(h,{color:e.Color.toHex(f)}));}this.node.setStyle("display","");}function a(){if(!this._isHidden()){return;}var f=this.neon;f.node=this;f.flicker_max=Math.max(0,f.get("flickerCount"));f.flicker_count=f.flicker_max;f.start_color=e.Color.re_RGB.exec(e.Color.toRGB(f.get("backgroundColor")));f.end_color=e.Color.re_RGB.exec(e.Color.toRGB(f.get("textColor")));d.call(f);}e.extend(b,e.Plugin.Base,{initializer:function(f){this.get("host").show=a;}});e.namespace("Plugin");e.Plugin.Neon=b;},"gallery-2011.02.18-23-10",{requires:["node-style","node-pluginhost","anim-easing","plugin"]});
+YUI.add("gallery-neon",function(e){function b(f){b.superclass.constructor.call(this,f);}b.NAME="NeonPlugin";b.NS="neon";b.ATTRS={backgroundColor:{validator:e.Lang.isString},textColor:{validator:e.Lang.isString},textShadow:{validator:e.Lang.isString},flickerCount:{value:10,validator:e.Lang.isNumber},easing:{value:e.Easing.easeIn,validator:e.Lang.isFunction}};function c(){e.later(Math.round(Math.random()*1000/(this.flicker_max-this.flicker_count)),this,d);this.node.setStyle("display","none");}function d(){this.flicker_count--;if(this.flicker_count>0){var g=this.get("easing");var f={r:g(this.flicker_count,parseInt(this.end_color[1],10),this.start_color[1]-this.end_color[1],this.flicker_max),g:g(this.flicker_count,parseInt(this.end_color[2],10),this.start_color[2]-this.end_color[2],this.flicker_max),b:g(this.flicker_count,parseInt(this.end_color[3],10),this.start_color[3]-this.end_color[3],this.flicker_max)};e.later(Math.round(Math.random()*1000/this.flicker_count),this,c);}else{var f={r:this.end_color[1],g:this.end_color[2],b:this.end_color[3]};}f="rgb("+Math.round(f.r)+","+Math.round(f.g)+","+Math.round(f.b)+")";this.node.setStyle("color",f);var h=this.get("textShadow");if(h){this.node.setStyle("textShadow",e.Lang.sub(h,{color:e.Color.toHex(f)}));}this.node.setStyle("display","");if(this.flicker_count===0){this.node.fire("neon:finished");}}function a(){if(!this._isHidden()){return;}var f=this.neon;f.node=this;f.flicker_max=Math.max(0,f.get("flickerCount"));f.flicker_count=f.flicker_max;f.start_color=e.Color.re_RGB.exec(e.Color.toRGB(f.get("backgroundColor")));f.end_color=e.Color.re_RGB.exec(e.Color.toRGB(f.get("textColor")));d.call(f);}e.extend(b,e.Plugin.Base,{initializer:function(f){this.get("host").show=a;}});e.namespace("Plugin");e.Plugin.Neon=b;},"gallery-2011.02.23-19-01",{requires:["node-style","node-pluginhost","anim-easing","plugin"]});
View
7 build/gallery-neon/gallery-neon.js
@@ -126,6 +126,11 @@ function neonOn()
}
this.node.setStyle('display', '');
+
+ if (this.flicker_count === 0)
+ {
+ this.node.fire('neon:finished');
+ }
}
function show()
@@ -157,4 +162,4 @@ Y.namespace("Plugin");
Y.Plugin.Neon = Neon;
-}, 'gallery-2011.02.18-23-10' ,{requires:['node-style','node-pluginhost','anim-easing','plugin']});
+}, 'gallery-2011.02.23-19-01' ,{requires:['node-style','node-pluginhost','anim-easing','plugin']});
View
64 build/gallery-patch-330-event-hover/gallery-patch-330-event-hover-debug.js
@@ -0,0 +1,64 @@
+YUI.add('gallery-patch-330-event-hover', function(Y) {
+
+/**
+ * Adds support for a "hover" event. The event provides a convenience wrapper
+ * for subscribing separately to mouseenter and mouseleave. The signature for
+ * subscribing to the event is</p>
+ *
+ * <pre><code>node.on("hover", overFn, outFn);
+ * node.delegate("hover", overFn, outFn, ".filterSelector");
+ * Y.on("hover", overFn, outFn, ".targetSelector");
+ * Y.delegate("hover", overFn, outFn, "#container", ".filterSelector");
+ * </code></pre>
+ *
+ * <p>Additionally, for compatibility with a more typical subscription
+ * signature, the following are also supported:</p>
+ *
+ * <pre><code>Y.on("hover", overFn, ".targetSelector", outFn);
+ * Y.delegate("hover", overFn, "#container", outFn, ".filterSelector");
+ * </code></pre>
+ *
+ * @module event
+ * @submodule event-hover
+ */
+var isFunction = Y.Lang.isFunction,
+ noop = function () {},
+ conf = {
+ processArgs: function (args) {
+ // Y.delegate('hover', over, out, '#container', '.filter')
+ // comes in as ['hover', over, out, '#container', '.filter'], but
+ // node.delegate('hover', over, out, '.filter')
+ // comes in as ['hover', over, containerEl, out, '.filter']
+ var i = isFunction(args[2]) ? 2 : 3;
+
+ return (isFunction(args[i])) ? args.splice(i,1)[0] : noop;
+ },
+
+ on: function (node, sub, notifier, filter) {
+ sub._detach = node[(filter) ? "delegate" : "on"]({
+ mouseenter: function (e) {
+ e.phase = 'over';
+ notifier.fire(e);
+ },
+ mouseleave: function (e) {
+ var thisObj = sub.context || this;
+
+ e.type = 'hover';
+ e.phase = 'out';
+ sub._extra.apply(thisObj, [e].concat(sub.args));
+ }
+ }, filter);
+ },
+
+ detach: function (node, sub, notifier) {
+ sub._detach.detach();
+ }
+ };
+
+conf.delegate = conf.on;
+conf.detachDelegate = conf.detach;
+
+Y.Event.define("hover", conf, true);
+
+
+}, 'gallery-2011.02.23-19-01' ,{requires:['event-mouseenter'], supersedes:['event-hover']});
View
1 build/gallery-patch-330-event-hover/gallery-patch-330-event-hover-min.js
@@ -0,0 +1 @@
+YUI.add("gallery-patch-330-event-hover",function(d){var c=d.Lang.isFunction,b=function(){},a={processArgs:function(e){var f=c(e[2])?2:3;return(c(e[f]))?e.splice(f,1)[0]:b;},on:function(h,f,g,e){f._detach=h[(e)?"delegate":"on"]({mouseenter:function(i){i.phase="over";g.fire(i);},mouseleave:function(i){var j=f.context||this;i.type="hover";i.phase="out";f._extra.apply(j,[i].concat(f.args));}},e);},detach:function(g,e,f){e._detach.detach();}};a.delegate=a.on;a.detachDelegate=a.detach;d.Event.define("hover",a,true);},"gallery-2011.02.23-19-01",{requires:["event-mouseenter"],supersedes:["event-hover"]});
View
64 build/gallery-patch-330-event-hover/gallery-patch-330-event-hover.js
@@ -0,0 +1,64 @@
+YUI.add('gallery-patch-330-event-hover', function(Y) {
+
+/**
+ * Adds support for a "hover" event. The event provides a convenience wrapper
+ * for subscribing separately to mouseenter and mouseleave. The signature for
+ * subscribing to the event is</p>
+ *
+ * <pre><code>node.on("hover", overFn, outFn);
+ * node.delegate("hover", overFn, outFn, ".filterSelector");
+ * Y.on("hover", overFn, outFn, ".targetSelector");
+ * Y.delegate("hover", overFn, outFn, "#container", ".filterSelector");
+ * </code></pre>
+ *
+ * <p>Additionally, for compatibility with a more typical subscription
+ * signature, the following are also supported:</p>
+ *
+ * <pre><code>Y.on("hover", overFn, ".targetSelector", outFn);
+ * Y.delegate("hover", overFn, "#container", outFn, ".filterSelector");
+ * </code></pre>
+ *
+ * @module event
+ * @submodule event-hover
+ */
+var isFunction = Y.Lang.isFunction,
+ noop = function () {},
+ conf = {
+ processArgs: function (args) {
+ // Y.delegate('hover', over, out, '#container', '.filter')
+ // comes in as ['hover', over, out, '#container', '.filter'], but
+ // node.delegate('hover', over, out, '.filter')
+ // comes in as ['hover', over, containerEl, out, '.filter']
+ var i = isFunction(args[2]) ? 2 : 3;
+
+ return (isFunction(args[i])) ? args.splice(i,1)[0] : noop;
+ },
+
+ on: function (node, sub, notifier, filter) {
+ sub._detach = node[(filter) ? "delegate" : "on"]({
+ mouseenter: function (e) {
+ e.phase = 'over';
+ notifier.fire(e);
+ },
+ mouseleave: function (e) {
+ var thisObj = sub.context || this;
+
+ e.type = 'hover';
+ e.phase = 'out';
+ sub._extra.apply(thisObj, [e].concat(sub.args));
+ }
+ }, filter);
+ },
+
+ detach: function (node, sub, notifier) {
+ sub._detach.detach();
+ }
+ };
+
+conf.delegate = conf.on;
+conf.detachDelegate = conf.detach;
+
+Y.Event.define("hover", conf, true);
+
+
+}, 'gallery-2011.02.23-19-01' ,{requires:['event-mouseenter'], supersedes:['event-hover']});
View
6 build/gallery-resource/gallery-resource-debug.js
@@ -61,7 +61,9 @@ YUI.add('gallery-resource', function(Y) {
contentType : 'application/json; charset=UTF-8',
serialize : Y.JSON.stringify,
deserialize : function(r){
- return Y.JSON.parse(r.responseText);
+ if (r.responseText) {
+ return Y.JSON.parse(r.responseText);
+ }
}
},
@@ -343,4 +345,4 @@ YUI.add('gallery-resource', function(Y) {
Y.Resource = Resource;
-}, 'gallery-2011.01.26-20-33' ,{requires:['base-base', 'io-base', 'querystring-stringify-simple', 'substitute', 'json']});
+}, 'gallery-2011.02.23-19-01' ,{requires:['base-base', 'io-base', 'querystring-stringify-simple', 'substitute', 'json']});
View
2 build/gallery-resource/gallery-resource-min.js
@@ -1 +1 @@
-YUI.add("gallery-resource",function(g){var h,i="resource",k="uri",q="headers",b="timeout",a="entityTranslators",t="request",d="response",e="success",j="failure",p="HEAD",r="OPTIONS",u="GET",f="POST",l="PUT",s="DELETE",n=g.Lang.isString,m=g.Lang.isObject,o=g.Lang.isNumber,c=g.Lang.isFunction;h=function(v){h.superclass.constructor.apply(this,arguments);};g.mix(h,{NAME:i,ATTRS:{uri:{validator:n},headers:{validator:m},timeout:{validator:o},entityTranslators:{validator:m}},ENTITY_TRANSLATORS:{JSON:{contentType:"application/json; charset=UTF-8",serialize:g.JSON.stringify,deserialize:function(v){return g.JSON.parse(v.responseText);}},FORM:{contentType:"application/x-www-form-urlencoded; charset=UTF-8",serialize:g.QueryString.stringify,deserialize:null}},NO_ENTITY_METHODS:[u,p,s],isNoEntityMethod:function(v){return g.Array.indexOf(h.NO_ENTITY_METHODS,v.toUpperCase())>=0;}});g.extend(h,g.Base,{_request:null,initializer:function(v){if(!this.get(k)){g.error("A Resource needs to be configured with: uri");}v=v||{};this.publish(t,{defaultFn:this._defRequestFn});this.publish(d);this.publish(e);this.publish(j);g.each(h.ENTITY_TRANSLATORS,g.bind(this.registerEntityTranslator,this));g.each(v[a],g.bind(this.registerEntityTranslator,this));},destructor:function(){this._request=null;},registerEntityTranslator:function(v){var w={};if(v&&v.contentType){w[v.contentType.split(";")[0]]=v;this.set(a,g.merge(this.get(a),w));}},unregisterEntityTranslator:function(w){var v=this.get(a);if(w){delete v[w.split(";")[0]];this.set(a,v);}},getEntityTranslator:function(v){return(v?this.get(a)[v.split(";")[0]]:null);},sendRequest:function(y){var z=this.get(k),x=this.get(q),v=this.get(b),C,B,A,w;y=y||{};C=y.method?y.method.toUpperCase():u;B=g.merge(x,y.headers);A=y.timeout||v;if(h.isNoEntityMethod(C)){delete B["Content-Type"];}else{w=y.entity;}this._request=null;this.fire(t,{uri:z,headers:B,timeout:A,method:C,params:y.params,entity:w,on:y.on});return this._request;},HEAD:function(v){return this.sendRequest(g.merge(v,{method:p}));},OPTIONS:function(v){return this.sendRequest(g.merge(v,{method:r}));},GET:function(v){return this.sendRequest(g.merge(v,{method:u}));},POST:function(v){return this.sendRequest(g.merge(v,{method:f}));},PUT:function(v){return this.sendRequest(g.merge(v,{method:l}));},DELETE:function(v){return this.sendRequest(g.merge(v,{method:s}));},_defRequestFn:function(w){var v=w.method.toLowerCase()+"Request";this.publish(v,{defaultFn:this._sendRequest});this.fire(v,{uri:w.uri,headers:w.headers,timeout:w.timeout,method:w.method,params:w.params,entity:w.entity,on:w.on});},_sendRequest:function(C){var x=C.uri,v=C.method,w=C.headers,E=C.timeout,D=C.on,z,A,B;if(m(C.params)){z=g.clone(C.params,true);x=g.substitute(x,z,function(G,F){delete z[G];return F;});if(g.Object.size(z)>0){x+=x.indexOf("?")<0?"?":"";x+=x[x.length-1]!=="?"&&x[x.length-1]!=="&"?"&":"";x+=g.QueryString.stringify(z);}}A=C.entity;B=this.getEntityTranslator(w["Content-Type"]);if(A&&B&&B.serialize){try{A=B.serialize(A);}catch(y){}}this._request=g.io(x,{method:v,headers:w,data:A,timeout:E,context:this,on:{complete:this._onComplete,success:this._onSuccess,failure:this._onFailure},"arguments":{resource:this,request:{method:C.method,params:C.params,entity:C.entity},on:D}});},_onComplete:function(z,y,v){var x=v.request.method.toLowerCase()+"Response",w={txId:z,request:v.request,response:y};this.getEvent(d).applyConfig({defaultFn:function(A){this.publish(x,{defaultFn:function(B){if(v.on&&c(v.on.response)){v.on.response(w);}}}).fire(w);}},true);this.fire(d,w);},_onSuccess:function(C,B,x){var A=x.request.method.toLowerCase()+"Success",w=this.getEntityTranslator(B.getResponseHeader("Content-Type")),v,y;if(B&&w&&w.deserialize){try{v=w.deserialize(B);}catch(z){g.error(z);}}y={txId:C,request:x.request,response:B,entity:v};this.getEvent(e).applyConfig({defaultFn:function(D){this.publish(A,{defaultFn:function(E){if(x.on&&c(x.on.success)){x.on.success(y);}}}).fire(y);}},true);this.fire(e,y);},_onFailure:function(z,y,w){var v=w.request.method.toLowerCase()+"Failure",x={txId:z,request:w.request,response:y};this.getEvent(j).applyConfig({defaultFn:function(A){this.publish(v,{defaultFn:function(B){if(w.on&&c(w.on.failure)){w.on.failure(x);}}}).fire(x);}},true);this.fire(j,x);}});g.Resource=h;},"gallery-2011.01.26-20-33",{requires:["base-base","io-base","querystring-stringify-simple","substitute","json"]});
+YUI.add("gallery-resource",function(g){var h,i="resource",k="uri",q="headers",b="timeout",a="entityTranslators",t="request",d="response",e="success",j="failure",p="HEAD",r="OPTIONS",u="GET",f="POST",l="PUT",s="DELETE",n=g.Lang.isString,m=g.Lang.isObject,o=g.Lang.isNumber,c=g.Lang.isFunction;h=function(v){h.superclass.constructor.apply(this,arguments);};g.mix(h,{NAME:i,ATTRS:{uri:{validator:n},headers:{validator:m},timeout:{validator:o},entityTranslators:{validator:m}},ENTITY_TRANSLATORS:{JSON:{contentType:"application/json; charset=UTF-8",serialize:g.JSON.stringify,deserialize:function(v){if(v.responseText){return g.JSON.parse(v.responseText);}}},FORM:{contentType:"application/x-www-form-urlencoded; charset=UTF-8",serialize:g.QueryString.stringify,deserialize:null}},NO_ENTITY_METHODS:[u,p,s],isNoEntityMethod:function(v){return g.Array.indexOf(h.NO_ENTITY_METHODS,v.toUpperCase())>=0;}});g.extend(h,g.Base,{_request:null,initializer:function(v){if(!this.get(k)){g.error("A Resource needs to be configured with: uri");}v=v||{};this.publish(t,{defaultFn:this._defRequestFn});this.publish(d);this.publish(e);this.publish(j);g.each(h.ENTITY_TRANSLATORS,g.bind(this.registerEntityTranslator,this));g.each(v[a],g.bind(this.registerEntityTranslator,this));},destructor:function(){this._request=null;},registerEntityTranslator:function(v){var w={};if(v&&v.contentType){w[v.contentType.split(";")[0]]=v;this.set(a,g.merge(this.get(a),w));}},unregisterEntityTranslator:function(w){var v=this.get(a);if(w){delete v[w.split(";")[0]];this.set(a,v);}},getEntityTranslator:function(v){return(v?this.get(a)[v.split(";")[0]]:null);},sendRequest:function(y){var z=this.get(k),x=this.get(q),v=this.get(b),C,B,A,w;y=y||{};C=y.method?y.method.toUpperCase():u;B=g.merge(x,y.headers);A=y.timeout||v;if(h.isNoEntityMethod(C)){delete B["Content-Type"];}else{w=y.entity;}this._request=null;this.fire(t,{uri:z,headers:B,timeout:A,method:C,params:y.params,entity:w,on:y.on});return this._request;},HEAD:function(v){return this.sendRequest(g.merge(v,{method:p}));},OPTIONS:function(v){return this.sendRequest(g.merge(v,{method:r}));},GET:function(v){return this.sendRequest(g.merge(v,{method:u}));},POST:function(v){return this.sendRequest(g.merge(v,{method:f}));},PUT:function(v){return this.sendRequest(g.merge(v,{method:l}));},DELETE:function(v){return this.sendRequest(g.merge(v,{method:s}));},_defRequestFn:function(w){var v=w.method.toLowerCase()+"Request";this.publish(v,{defaultFn:this._sendRequest});this.fire(v,{uri:w.uri,headers:w.headers,timeout:w.timeout,method:w.method,params:w.params,entity:w.entity,on:w.on});},_sendRequest:function(C){var x=C.uri,v=C.method,w=C.headers,E=C.timeout,D=C.on,z,A,B;if(m(C.params)){z=g.clone(C.params,true);x=g.substitute(x,z,function(G,F){delete z[G];return F;});if(g.Object.size(z)>0){x+=x.indexOf("?")<0?"?":"";x+=x[x.length-1]!=="?"&&x[x.length-1]!=="&"?"&":"";x+=g.QueryString.stringify(z);}}A=C.entity;B=this.getEntityTranslator(w["Content-Type"]);if(A&&B&&B.serialize){try{A=B.serialize(A);}catch(y){}}this._request=g.io(x,{method:v,headers:w,data:A,timeout:E,context:this,on:{complete:this._onComplete,success:this._onSuccess,failure:this._onFailure},"arguments":{resource:this,request:{method:C.method,params:C.params,entity:C.entity},on:D}});},_onComplete:function(z,y,v){var x=v.request.method.toLowerCase()+"Response",w={txId:z,request:v.request,response:y};this.getEvent(d).applyConfig({defaultFn:function(A){this.publish(x,{defaultFn:function(B){if(v.on&&c(v.on.response)){v.on.response(w);}}}).fire(w);}},true);this.fire(d,w);},_onSuccess:function(C,B,x){var A=x.request.method.toLowerCase()+"Success",w=this.getEntityTranslator(B.getResponseHeader("Content-Type")),v,y;if(B&&w&&w.deserialize){try{v=w.deserialize(B);}catch(z){g.error(z);}}y={txId:C,request:x.request,response:B,entity:v};this.getEvent(e).applyConfig({defaultFn:function(D){this.publish(A,{defaultFn:function(E){if(x.on&&c(x.on.success)){x.on.success(y);}}}).fire(y);}},true);this.fire(e,y);},_onFailure:function(z,y,w){var v=w.request.method.toLowerCase()+"Failure",x={txId:z,request:w.request,response:y};this.getEvent(j).applyConfig({defaultFn:function(A){this.publish(v,{defaultFn:function(B){if(w.on&&c(w.on.failure)){w.on.failure(x);}}}).fire(x);}},true);this.fire(j,x);}});g.Resource=h;},"gallery-2011.02.23-19-01",{requires:["base-base","io-base","querystring-stringify-simple","substitute","json"]});
View
6 build/gallery-resource/gallery-resource.js
@@ -61,7 +61,9 @@ YUI.add('gallery-resource', function(Y) {
contentType : 'application/json; charset=UTF-8',
serialize : Y.JSON.stringify,
deserialize : function(r){
- return Y.JSON.parse(r.responseText);
+ if (r.responseText) {
+ return Y.JSON.parse(r.responseText);
+ }
}
},
@@ -343,4 +345,4 @@ YUI.add('gallery-resource', function(Y) {
Y.Resource = Resource;
-}, 'gallery-2011.01.26-20-33' ,{requires:['base-base', 'io-base', 'querystring-stringify-simple', 'substitute', 'json']});
+}, 'gallery-2011.02.23-19-01' ,{requires:['base-base', 'io-base', 'querystring-stringify-simple', 'substitute', 'json']});

0 comments on commit 944498e

Please sign in to comment.