Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Gallery Build Tag: gallery-2011.02.23-19-01

  • Loading branch information...
commit 944498e49ca03236667c49877a8871e22d67fda3 1 parent ce4b5b8
YUI Builder authored
Showing with 4,477 additions and 2,820 deletions.
  1. +32 −9 build/gallery-accordion/gallery-accordion-debug.js
  2. +4 −4 build/gallery-accordion/gallery-accordion-min.js
  3. +32 −9 build/gallery-accordion/gallery-accordion.js
  4. +296 −0 build/gallery-algorithms/gallery-algorithms-debug.js
  5. +1 −0  build/gallery-algorithms/gallery-algorithms-min.js
  6. +296 −0 build/gallery-algorithms/gallery-algorithms.js
  7. +396 −0 build/gallery-comet-stream/gallery-comet-stream-debug.js
  8. +1 −0  build/gallery-comet-stream/gallery-comet-stream-min.js
  9. +396 −0 build/gallery-comet-stream/gallery-comet-stream.js
  10. +1,436 −1,395 build/gallery-form/gallery-form-debug.js
  11. +4 −4 build/gallery-form/gallery-form-min.js
  12. +1,432 −1,391 build/gallery-form/gallery-form.js
  13. +6 −1 build/gallery-neon/gallery-neon-debug.js
  14. +1 −1  build/gallery-neon/gallery-neon-min.js
  15. +6 −1 build/gallery-neon/gallery-neon.js
  16. +64 −0 build/gallery-patch-330-event-hover/gallery-patch-330-event-hover-debug.js
  17. +1 −0  build/gallery-patch-330-event-hover/gallery-patch-330-event-hover-min.js
  18. +64 −0 build/gallery-patch-330-event-hover/gallery-patch-330-event-hover.js
  19. +4 −2 build/gallery-resource/gallery-resource-debug.js
  20. +1 −1  build/gallery-resource/gallery-resource-min.js
  21. +4 −2 build/gallery-resource/gallery-resource.js
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
@@ -18,476 +18,498 @@ YUI.add('gallery-form', function(Y) {
*/
Y.Form = Y.Base.create('form', Y.Widget, [Y.WidgetParent], {
- toString : function () {
+ toString: function() {
return this.name;
},
-
- CONTENT_TEMPLATE : '<form></form>',
-
- /**
- * @property _ioIds
- * @type Object
- * @protected
- * @description An object who's keys represent the IO request ids sent by this Y.Form instance
- */
- _ioIds : null,
-
- /**
- * @method _validateAction
- * @private
- * @param {String} val
- * @description Validates the values of the 'action' attribute
- */
- _validateMethod : function (val) {
- if (!Y.Lang.isString(val)) {
- return false;
- }
- if (val.toLowerCase() != 'get' && val.toLowerCase() != 'post') {
- return false;
- }
- return true;
- },
-
- /**
- * @method _parseAction
- * @private
- * @param {Y.Node} contentBox
- * @description Sets the 'action' attribute based on parsed HTML
- */
- _parseAction : function (contentBox) {
- var form = contentBox.one('form');
+
+ CONTENT_TEMPLATE: '<form></form>',
+
+ /**
+ * @property _ioIds
+ * @type Object
+ * @protected
+ * @description An object who's keys represent the IO request ids sent by this Y.Form instance
+ */
+ _ioIds: null,
+
+ /**
+ * @method _validateAction
+ * @private
+ * @param {String} val
+ * @description Validates the values of the 'action' attribute
+ */
+ _validateMethod: function(val) {
+ if (!Y.Lang.isString(val)) {
+ return false;
+ }
+ if (val.toLowerCase() != 'get' && val.toLowerCase() != 'post') {
+ return false;
+ }
+ return true;
+ },
+
+ /**
+ * @method _parseAction
+ * @private
+ * @param {Y.Node} contentBox
+ * @description Sets the 'action' attribute based on parsed HTML
+ */
+ _parseAction: function(contentBox) {
+ var form = contentBox.one('form');
if (!form) {
form = contentBox;
}
- if (form) {
- return form.get('action');
- }
- },
-
- /**
- * @method _parseMethod
- * @private
- * @param {Y.Node} contentBox
- * @description Sets the 'method' attribute based on parsed HTML
- */
- _parseMethod : function (contentBox) {
- var form = contentBox.one('form');
- if (!form) {
- form = contentBox;
- }
- if (form) {
- return form.get('method');
- }
- },
-
- /**
- * @method _parseFields
- * @private
- * @param {Y.Node} contentBox
- * @description Sets the 'fields' attribute based on parsed HTML
- */
- _parseFields : function (contentBox) {
- var children = contentBox.all('*'),
- labels = contentBox.all('label'),
- fields = [],
- inputMap = {
- text : Y.TextField,
- hidden : Y.HiddenField,
- file : Y.FileField,
- checkbox : Y.CheckboxField,
- radio : Y.RadioField,
- reset : Y.ResetButton,
- submit : Y.SubmitButton,
- button : (Y.Button || Y.FormButton)
- };
-
- children.each(function(node, index, nodeList) {
- var nodeName = node.get('nodeName'),
- nodeId = node.get('id'),
- type,
- o, c = [];
- if (nodeName == 'INPUT') {
- type = node.get('type');
- o = {
- type: (inputMap[type] ? inputMap[type] : Y.TextField),
- name : node.get('name'),
- value : node.get('value'),
- checked : node.get('checked')
- };
-
- if (o.type == inputMap.button) {
- o.label = node.get('value');
- }
- } else if (nodeName == 'BUTTON') {
- o = {
- type : inputMap.button,
- name : node.get('name'),
- label : node.get('innerHTML')
- };
- } else if (nodeName == 'SELECT') {
- node.all('option').each(function (optNode, optNodeIndex, optNodeList) {
- c.push({
- label : optNode.get('innerHTML'),
- value : optNode.get('value')
- });
- });
- o = {
- type : Y.SelectField,
- name : node.get('name'),
- choices : c
- };
- } else if (nodeName == 'TEXTAREA') {
- o = {
- type: Y.TextareaField,
- name : node.get('name'),
- value : node.get('innerHTML')
- };
- }
-
- if (o) {
- if (nodeId) {
- o.id = nodeId;
- labels.some(function(labelNode, labelNodeIndex, labelNodeList) {
- if (labelNode.get('htmlFor') == nodeId) {
- o.label = labelNode.get('innerHTML');
- }
- });
- }
- fields.push(o);
- }
- node.remove();
- });
-
- return fields;
- },
-
- /**
- * @method _syncFormAttributes
- * @protected
- * @description Syncs the form node action and method attributes
- */
- _syncFormAttributes : function () {
- var contentBox = this.get('contentBox');
- contentBox.setAttrs({
- action : this.get('action'),
- method : this.get('method')
- });
-
- if (this.get('encodingType') === Y.Form.MULTIPART_ENCODED) {
- contentBox.setAttribute('enctype', 'multipart/form-data');
- }
- },
-
- /**
- * @method _runValidation
- * @protected
- * @description Validates the form based on each field's validator
- */
- _runValidation : function () {
- var isValid = true;
-
- this.each(function (f) {
- f.set('error',null);
- if (f.validateField() === false) {
- isValid = false;
- }
- });
-
- return isValid;
- },
-
- _enableInlineValidation : function () {
- this.each(function (f) {
- f.set('validateInline', true);
- });
- },
-
- _disableInlineValidation : function () {
- this.each(function (f) {
- f.set('validateInline', false);
- });
- },
-
- /**
- * @method _handleIOEvent
- * @protected
- * @param {String} eventName
- * @param {Number} ioId
- * @param {Object} ioResponse
- * @description Handles the IO events of transactions instantiated by this instance
- */
- _handleIOEvent : function (eventName, ioId, ioResponse) {
- if (this._ioIds[ioId] !== undefined) {
- this.fire(eventName, {response : ioResponse});
- }
- },
-
- /**
- * @method reset
- * @description Resets all form fields to their initial value
- */
- reset : function () {
- this.each(function (field) {
- field.resetFieldNode();
- field.set('error', null);
- });
- var cb = Y.Node.getDOMNode(this.get('contentBox'));
- if (Y.Lang.isFunction(cb.reset)) {
- cb.reset();
- }
- },
-
- /**
- * @method submit
- * @description Submits the form using the defined method to the URL defined in the action
- */
- submit : function () {
- if (this.get('skipValidationBeforeSubmit') === true || this._runValidation()) {
- var formAction = this.get('action'),
- formMethod = this.get('method'),
- submitViaIO = this.get('submitViaIO'),
- transaction, cfg;
-
- if (submitViaIO === true) {
- cfg = {
- method : formMethod,
- form : {
- id : this.get('contentBox'),
- upload : (this.get('encodingType') === Y.Form.MULTIPART_ENCODED)
- }
- };
-
- transaction = Y.io(formAction, cfg);
- this._ioIds[transaction.id] = transaction;
- } else {
- this.get('contentBox').submit();
- }
- }
- },
-
- /**
- * @method getField
- * @param {String|Number} selector
- * @description Get a form field by its name attribute or numerical index
- */
- getField : function (selector) {
- var sel;
-
- if (Y.Lang.isNumber(selector)) {
- sel = this.item(selector);
- } else if (Y.Lang.isString(selector)) {
- this.each(function (f) {
- if (f.get('name') == selector) {
- sel = f;
- }
- });
- }
- return sel;
- },
-
- initializer : function (config) {
- 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', Y.bind(function (e) {
- e.halt();
- }, this));
-
- this.after('inlineValidationChange', Y.bind(function (e) {
- if (e.newVal === true) {
- this._enableInlineValidation();
- } else {
- this._disableInlineValidation();
- }
- }, this));
-
- this.after('success', Y.bind(function(e) {
- if (this.get('resetAfterSubmit') === true) {
- this.reset();
- }
- }, this));
-
- Y.on('io:start', Y.bind(this._handleIOEvent, this, 'start'));
- Y.on('io:complete', Y.bind(this._handleIOEvent, this, 'complete'));
- Y.on('io:xdr', Y.bind(this._handleIOEvent, this, 'xdr'));
- Y.on('io:success', Y.bind(this._handleIOEvent, this, 'success'));
- Y.on('io:failure', Y.bind(this._handleIOEvent, this, 'failure'));
-
- this.each(Y.bind(function(f) {
- if (f.name =='submit-button') {
- f.on('click', Y.bind(this.submit, this));
+ if (form) {
+ return form.get('action');
+ }
+ },
+
+ /**
+ * @method _parseMethod
+ * @private
+ * @param {Y.Node} contentBox
+ * @description Sets the 'method' attribute based on parsed HTML
+ */
+ _parseMethod: function(contentBox) {
+ var form = contentBox.one('form');
+ if (!form) {
+ form = contentBox;
+ }
+ if (form) {
+ return form.get('method');
+ }
+ },
+
+ /**
+ * @method _parseFields
+ * @private
+ * @param {Y.Node} contentBox
+ * @description Sets the 'fields' attribute based on parsed HTML
+ */
+ _parseFields: function(contentBox) {
+ var children = contentBox.all('*'),
+ labels = contentBox.all('label'),
+ fields = [],
+ inputMap = {
+ text: Y.TextField,
+ hidden: Y.HiddenField,
+ file: Y.FileField,
+ checkbox: Y.CheckboxField,
+ radio: Y.RadioField,
+ reset: Y.ResetButton,
+ submit: Y.SubmitButton,
+ button: (Y.Button || Y.FormButton)
+ };
+
+ children.each(function(node, index, nodeList) {
+ var nodeName = node.get('nodeName'),
+ nodeId = node.get('id'),
+ type,
+ o,
+ c = [];
+ if (nodeName == 'INPUT') {
+ type = node.get('type');
+ o = {
+ type: (inputMap[type] ? inputMap[type] : Y.TextField),
+ name: node.get('name'),
+ value: node.get('value'),
+ checked: node.get('checked')
+ };
+
+ if (o.type == inputMap.button) {
+ o.label = node.get('value');
+ }
+ } else if (nodeName == 'BUTTON') {
+ o = {
+ type: inputMap.button,
+ name: node.get('name'),
+ label: node.get('innerHTML')
+ };
+ } else if (nodeName == 'SELECT') {
+ node.all('option').each(function(optNode, optNodeIndex, optNodeList) {
+ c.push({
+ label: optNode.get('innerHTML'),
+ value: optNode.get('value')
+ });
+ });
+ o = {
+ type: Y.SelectField,
+ name: node.get('name'),
+ choices: c
+ };
+ } else if (nodeName == 'TEXTAREA') {
+ o = {
+ type: Y.TextareaField,
+ name: node.get('name'),
+ value: node.get('innerHTML')
+ };
+ }
+
+ if (o) {
+ if (nodeId) {
+ o.id = nodeId;
+ labels.some(function(labelNode, labelNodeIndex, labelNodeList) {
+ if (labelNode.get('htmlFor') == nodeId) {
+ o.label = labelNode.get('innerHTML');
+ }
+ });
+ }
+ fields.push(o);
+ }
+ node.remove();
+ });
+
+ return fields;
+ },
+
+ /**
+ * @method _syncFormAttributes
+ * @protected
+ * @description Syncs the form node action and method attributes
+ */
+ _syncFormAttributes: function() {
+ var contentBox = this.get('contentBox');
+ contentBox.setAttrs({
+ action: this.get('action'),
+ method: this.get('method')
+ });
+
+ if (this.get('encodingType') === Y.Form.MULTIPART_ENCODED) {
+ contentBox.setAttribute('enctype', 'multipart/form-data');
+ }
+ },
+
+ /**
+ * @method _runValidation
+ * @protected
+ * @description Validates the form based on each field's validator
+ */
+ _runValidation: function() {
+ var isValid = true;
+
+ this.each(function(f) {
+ if (f.validateField() === false) {
+ isValid = false;
+ }
+ });
+
+ return isValid;
+ },
+
+ _enableInlineValidation: function() {
+ this.each(function(f) {
+ f.set('validateInline', true);
+ });
+ },
+
+ _disableInlineValidation: function() {
+ this.each(function(f) {
+ f.set('validateInline', false);
+ });
+ },
+
+ /**
+ * @method _handleIOEvent
+ * @protected
+ * @param {String} eventName
+ * @param {Number} ioId
+ * @param {Object} ioResponse
+ * @description Handles the IO events of transactions instantiated by this instance
+ */
+ _handleIOEvent: function(eventName, ioId, ioResponse) {
+ if (this._ioIds[ioId] !== undefined) {
+ this.fire(eventName, {
+ response: ioResponse
+ });
+ }
+ },
+
+ /**
+ * @method reset
+ * @description Resets all form fields to their initial value
+ */
+ reset: function() {
+ var cb = Y.Node.getDOMNode(this.get('contentBox'));
+ if (Y.Lang.isFunction(cb.reset)) {
+ cb.reset();
+ }
+ this.each(function(field) {
+ field.resetFieldNode();
+ field.set('error', null);
+ });
+ },
+
+ /**
+ * @method submit
+ * @description Submits the form using the defined method to the URL defined in the action
+ */
+ submit: function() {
+ if (this.get('skipValidationBeforeSubmit') === true || this._runValidation()) {
+ var formAction = this.get('action'),
+ formMethod = this.get('method'),
+ submitViaIO = this.get('submitViaIO'),
+ transaction,
+ cfg;
+
+ if (submitViaIO === true) {
+ cfg = {
+ method: formMethod,
+ form: {
+ id: this.get('contentBox'),
+ upload: (this.get('encodingType') === Y.Form.MULTIPART_ENCODED)
+ }
+ };
+
+ var io = this.get("io");
+ transaction = io(formAction, cfg);
+ this._ioIds[transaction.id] = transaction;
+ } else {
+ this.get('contentBox').submit();
+ }
+ }
+ },
+
+ /**
+ * @method getField
+ * @param {String|Number} selector
+ * @description Get a form field by its name attribute or numerical index
+ */
+ getField: function(selector) {
+ var sel;
+
+ if (Y.Lang.isNumber(selector)) {
+ sel = this.item(selector);
+ } else if (Y.Lang.isString(selector)) {
+ this.each(function(f) {
+ if (f.get('name') == selector) {
+ sel = f;
+ }
+ });
+ }
+ return sel;
+ },
+
+ initializer: function(config) {
+ 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', Y.bind(function(e) {
+ e.halt();
+ },
+ this));
+
+ this.after('inlineValidationChange', Y.bind(function(e) {
+ if (e.newVal === true) {
+ this._enableInlineValidation();
+ } else {
+ this._disableInlineValidation();
+ }
+ },
+ this));
+
+ this.after('success', Y.bind(function(e) {
+ if (this.get('resetAfterSubmit') === true) {
+ this.reset();
+ }
+ },
+ this));
+
+ Y.on('io:start', Y.bind(this._handleIOEvent, this, 'start'));
+ Y.on('io:complete', Y.bind(this._handleIOEvent, this, 'complete'));
+ Y.on('io:xdr', Y.bind(this._handleIOEvent, this, 'xdr'));
+ Y.on('io:success', Y.bind(this._handleIOEvent, this, 'success'));
+ Y.on('io:failure', Y.bind(this._handleIOEvent, this, 'failure'));
+
+ this.each(Y.bind(function(f) {
+ // This should probably be performed also when children
+ // are with Form.add() after the form is rendered.
+ if (f.name == 'submit-button') {
+ f.on('click', Y.bind(this.submit, this));
} else if (f.name == 'reset-button') {
- f.on('click', Y.bind(this.reset, this));
+ f.on('click', Y.bind(this.reset, this));
}
- }, this));
- },
-
- syncUI : function () {
- this._syncFormAttributes();
- if (this.get('inlineValidation') === true) {
- this._enableInlineValidation();
- }
- }
-}, {
-
- /**
- * @property Form.ATTRS
- * @type Object
- * @static
- */
- ATTRS : {
- defaultChildType : {
- valueFn : function () {
- return Y.TextField;
- }
- },
-
- /**
- * @attribute method
- * @type String
- * @default 'post'
- * @description The method by which the form should be transmitted. Valid values are 'get' and 'post'
- */
- method : {
- value : 'post',
- validator : function (val) {
- return this._validateMethod(val);
- },
- setter : function (val) {
- return val.toLowerCase();
- }
- },
-
- /**
- * @attribute action
- * @type String
- * @default '.'
- * @description A url to which the validated form is to be sent
- */
- action : {
- value : '.',
- validator : Y.Lang.isString
- },
-
- /**
- * @attribute fields
- * @type Array
- * @deprecated Use "children" attribet instead
- * @description An array of the fields to be rendered into the Y.Form. Each item in the
- * array can either be a FormField instance or an object literal defining
- * the properties of the field to be generated. Alternatively, this value
- * will be parsed in from HTML
- */
- fields : {
- setter : function (val) {
- return this.set('children', val);
- }
- },
-
- /**
- * @attribute inlineValidation
- * @type Boolean
- * @description Set to true to validate fields "on the fly", where they will
- * validate themselves any time the value attribute is changed
- * @default false
- */
- inlineValidation : {
- value : false,
- validator : Y.Lang.isBoolean
- },
+ },
+ this));
+ },
- /**
- * @attribute resetAfterSubmit
- * @type Boolean
- * @description If true, the form is reset following a successful submit event
- * @default true
- */
- resetAfterSubmit : {
- value : true,
- validator : Y.Lang.isBoolean
- },
-
- /**
- * @attribute encodingType
- * @type Number
- * @description Set to Form.MULTIPART_ENCODED in order to use the FileField for uploads
- * @default Form.URL_ENCODED
- */
- encodingType : {
- value : 1,
- validator : Y.Lang.isNumber
- },
-
- /**
- * @attribute skipValidationBeforeSubmit
- * @type Boolean
- * @description Set to true to skip the validation step when submitting
- * @default false
- */
- skipValidationBeforeSubmit : {
- value : false,
- validator : Y.Lang.isBoolean
- },
-
- submitViaIO : {
- value : true,
- validator : Y.Lang.isBoolean
- }
- },
-
- /**
- * @property Form.HTML_PARSER
- * @type Object
- * @static
- */
- HTML_PARSER : {