node-base-min.js revision 5d01873cf9caef83e00b14d55d8f3045b8e7b497
YUI.add("node-base",function(C){var G=".",E="nodeName",J="nodeType",B="ownerDocument",I="tagName",D="_yuid",L=Array.prototype.slice,F=C.DOM,H=function(N){var M=(N.nodeType!==9)?N.uniqueID:N[D];if(M&&H._instances[M]&&H._instances[M]._node!==N){N[D]=null;}M=M||C.stamp(N);if(!M){M=C.guid();}this[D]=M;this._node=N;H._instances[M]=this;this._stateProxy=N;C.EventTarget.call(this,{emitFacade:true});if(this._initPlugins){this._initPlugins();}this.SHOW_TRANSITION=H.SHOW_TRANSITION;this.HIDE_TRANSITION=H.HIDE_TRANSITION;},K=function(N){var M=null;if(N){M=(typeof N=="string")?function(O){return C.Selector.test(O,N);}:function(O){return N(C.one(O));};}return M;};H.NAME="node";H.re_aria=/^(?:role$|aria-)/;H.SHOW_TRANSITION="fadeIn";H.HIDE_TRANSITION="fadeOut";H.DOM_EVENTS={abort:1,beforeunload:1,blur:1,change:1,click:1,close:1,command:1,contextmenu:1,dblclick:1,DOMMouseScroll:1,drag:1,dragstart:1,dragenter:1,dragover:1,dragleave:1,dragend:1,drop:1,error:1,focus:1,key:1,keydown:1,keypress:1,keyup:1,load:1,message:1,mousedown:1,mouseenter:1,mouseleave:1,mousemove:1,mousemultiwheel:1,mouseout:1,mouseover:1,mouseup:1,mousewheel:1,reset:1,resize:1,select:1,selectstart:1,submit:1,scroll:1,textInput:1,unload:1};C.mix(H.DOM_EVENTS,C.Env.evt.plugins);H._instances={};H.getDOMNode=function(M){if(M){return(M.nodeType)?M:M._node||null;}return null;};H.scrubVal=function(N,M){if(M&&N){if(typeof N=="object"||typeof N=="function"){if(J in N||F.isWindow(N)){N=C.one(N);}else{if((N.item&&!N._nodes)||(N[0]&&N[0][J])){N=C.all(N);}}}}else{if(typeof N==="undefined"){N=M;}else{if(N===null){N=null;}}}return N;};H.addMethod=function(M,O,N){if(M&&O&&typeof O=="function"){H.prototype[M]=function(){N=N||this;var Q=L.call(arguments),P;if(Q[0]&&C.instanceOf(Q[0],H)){Q[0]=Q[0]._node;}if(Q[1]&&C.instanceOf(Q[1],H)){Q[1]=Q[1]._node;}Q.unshift(this._node);P=O.apply(N,Q);if(P){P=H.scrubVal(P,this);}(typeof P!="undefined")||(P=this);return P;};}else{}};H.importMethod=function(O,M,N){if(typeof M=="string"){N=N||M;H.addMethod(N,O[M],O);}else{C.Array.each(M,function(P){H.importMethod(O,P);});}};H.one=function(P){var M=null,O,N;if(P){if(typeof P=="string"){if(P.indexOf("doc")===0){P=C.config.doc;}else{if(P.indexOf("win")===0){P=C.config.win;}else{P=C.Selector.query(P,null,true);}}if(!P){return null;}}else{if(C.instanceOf(P,H)){return P;}}if(P.nodeType||C.DOM.isWindow(P)){N=(P.uniqueID&&P.nodeType!==9)?P.uniqueID:P._yuid;M=H._instances[N];O=M?M._node:null;if(!M||(O&&P!==O)){M=new H(P);}}}return M;};H.get=function(){return H.one.apply(H,arguments);};H.create=function(){return C.one(F.create.apply(F,arguments));};H.ATTRS={text:{getter:function(){return F.getText(this._node);},setter:function(M){F.setText(this._node,M);return M;}},"options":{getter:function(){return this._node.getElementsByTagName("option");}},"children":{getter:function(){var P=this._node,O=P.children,Q,N,M;if(!O){Q=P.childNodes;O=[];for(N=0,M=Q.length;N<M;++N){if(Q[N][I]){O[O.length]=Q[N];}}}return C.all(O);}},value:{getter:function(){return F.getValue(this._node);},setter:function(M){F.setValue(this._node,M);return M;}},data:{getter:function(){return this._dataVal;},setter:function(M){this._dataVal=M;return M;},value:null}};H.DEFAULT_SETTER=function(M,O){var N=this._stateProxy,P;if(M.indexOf(G)>-1){P=M;M=M.split(G);C.Object.setValue(N,M,O);}else{if(typeof N[M]!="undefined"){N[M]=O;}}return O;};H.DEFAULT_GETTER=function(M){var N=this._stateProxy,O;if(M.indexOf&&M.indexOf(G)>-1){O=C.Object.getValue(N,M.split(G));}else{if(typeof N[M]!="undefined"){O=N[M];}}return O;};C.mix(H,C.EventTarget,false,null,1);C.mix(H.prototype,{toString:function(){var P=this[D]+": not bound to a node",O=this._node,M,Q,N;if(O){M=O.attributes;Q=(M&&M.id)?O.getAttribute("id"):null;N=(M&&M.className)?O.getAttribute("className"):null;P=O[E];if(Q){P+="#"+Q;}if(N){P+="."+N.replace(" ",".");}P+=" "+this[D];}return P;},get:function(M){var N;if(this._getAttr){N=this._getAttr(M);}else{N=this._get(M);}if(N){N=H.scrubVal(N,this);}else{if(N===null){N=null;}}return N;},_get:function(M){var N=H.ATTRS[M],O;if(N&&N.getter){O=N.getter.call(this);}else{if(H.re_aria.test(M)){O=this._node.getAttribute(M,2);}else{O=H.DEFAULT_GETTER.apply(this,arguments);}}return O;},set:function(M,O){var N=H.ATTRS[M];if(this._setAttr){this._setAttr.apply(this,arguments);}else{if(N&&N.setter){N.setter.call(this,O);}else{if(H.re_aria.test(M)){this._node.setAttribute(M,O);}else{H.DEFAULT_SETTER.apply(this,arguments);}}}return this;},setAttrs:function(M){if(this._setAttrs){this._setAttrs(M);}else{C.Object.each(M,function(N,O){this.set(O,N);},this);}return this;},getAttrs:function(N){var M={};if(this._getAttrs){this._getAttrs(N);}else{C.Array.each(N,function(O,P){M[O]=this.get(O);},this);}return M;},create:H.create,compareTo:function(M){var N=this._node;if(C.instanceOf(M,H)){M=M._node;}return N===M;},inDoc:function(N){var M=this._node;N=(N)?N._node||N:M[B];if(N.documentElement){return F.contains(N.documentElement,M);}},getById:function(O){var N=this._node,M=F.byId(O,N[B]);if(M&&F.contains(N,M)){M=C.one(M);}else{M=null;}return M;},ancestor:function(M,N){return C.one(F.ancestor(this._node,K(M),N));},ancestors:function(M,N){return C.all(F.ancestors(this._node,K(M),N));},previous:function(N,M){return C.one(F.elementByAxis(this._node,"previousSibling",K(N),M));},next:function(N,M){return C.one(F.elementByAxis(this._node,"nextSibling",K(N),M));},siblings:function(M){return C.all(F.siblings(this._node,K(M)));},one:function(M){return C.one(C.Selector.query(M,this._node,true));},query:function(M){return this.one(M);},all:function(M){var N=C.all(C.Selector.query(M,this._node));N._query=M;N._queryRoot=this._node;return N;},queryAll:function(M){return this.all(M);},test:function(M){return C.Selector.test(this._node,M);},remove:function(N){var O=this._node,M=O.parentNode;if(M){M.removeChild(O);}if(N){this.destroy(true);}return this;},replace:function(M){var N=this._node;if(typeof M=="string"){M=H.create(M);}N.parentNode.replaceChild(H.getDOMNode(M),N);return this;
},replaceChild:function(N,M){if(typeof N=="string"){N=F.create(N);}return C.one(this._node.replaceChild(H.getDOMNode(N),H.getDOMNode(M)));},appendChild:function(M){if(typeof M=="string"){M=F.create(M);}return C.one(this._node.appendChild(H.getDOMNode(M)));},insertBefore:function(N,M){var O=this._node;if(typeof N=="string"){N=F.create(N);}M=H.getDOMNode(M);N=H.getDOMNode(N);if(M){O.insertBefore(N,M);}else{O.appendChild(N);}return C.one(N);},purge:function(N,M){C.Event.purgeElement(this._node,N,M);return this;},destroy:function(M){delete H._instances[this[D]];this.purge(M);if(this.unplug){this.unplug();}this._node._yuid=null;this._node=null;this._stateProxy=null;this.clearData();},invoke:function(T,N,M,S,R,Q){var P=this._node,O;if(N&&C.instanceOf(N,H)){N=N._node;}if(M&&C.instanceOf(M,H)){M=M._node;}O=P[T](N,M,S,R,Q);return H.scrubVal(O,this);},each:function(N,M){M=M||this;return N.call(M,this);},item:function(M){return this;},size:function(){return this._node?1:0;},insert:function(O,M){var N=this._node;if(O){if(typeof M=="number"){M=this._node.childNodes[M];}else{if(M&&M._node){M=M._node;}}if(typeof O!="string"){if(O._node){O=O._node;}else{if(O._nodes||(!O.nodeType&&O.length)){O=C.all(O);C.each(O._nodes,function(P){F.addHTML(N,P,M);});return this;}}}F.addHTML(N,O,M);}else{}return this;},prepend:function(M){return this.insert(M,0);},append:function(M){return this.insert(M,null);},appendTo:function(M){C.one(M).append(this);},setContent:function(M){if(M){if(M._node){M=M._node;}else{if(M._nodes){M=F._nl2frag(M._nodes);}}}F.addHTML(this._node,M,"replace");return this;},swap:C.config.doc.documentElement.swapNode?function(M){this._node.swapNode(H.getDOMNode(M));}:function(M){M=H.getDOMNode(M);var O=this._node,N=M.parentNode,P=M.nextSibling;if(P===O){N.insertBefore(O,M);}else{if(M===O.nextSibling){N.insertBefore(M,O);}else{O.parentNode.replaceChild(M,O);F.addHTML(N,O,P);}}return this;},getData:function(N){var M;this._data=this._data||{};if(arguments.length){M=this._data[N];}else{M=this._data;}return M;},setData:function(M,N){this._data=this._data||{};if(arguments.length>1){this._data[M]=N;}else{this._data=M;}return this;},clearData:function(M){if("_data" in this){if(M){delete this._data[M];}else{delete this._data;}}return this;},hasMethod:function(N){var M=this._node;return !!(M&&N in M&&typeof M[N]!="unknown"&&(typeof M[N]=="function"||String(M[N]).indexOf("function")===1));},SHOW_TRANSITION:null,HIDE_TRANSITION:null,show:function(N,M,O){this._show();return this;},_show:function(){this.setStyle("display","");},hide:function(N,M,O){this._hide();return this;},_hide:function(){this.setStyle("display","none");},isFragment:function(){return(this.get("nodeType")===11);}},true);C.Node=H;C.get=C.Node.get;C.one=C.Node.one;var A=function(M){var N=[];if(typeof M==="string"){this._query=M;M=C.Selector.query(M);}else{if(M.nodeType||F.isWindow(M)){M=[M];}else{if(C.instanceOf(M,C.Node)){M=[M._node];}else{if(C.instanceOf(M[0],C.Node)){C.Array.each(M,function(O){if(O._node){N.push(O._node);}});M=N;}else{M=C.Array(M,0,true);}}}}this._nodes=M;};A.NAME="NodeList";A.getDOMNodes=function(M){return M._nodes;};A.each=function(M,P,O){var N=M._nodes;if(N&&N.length){C.Array.each(N,P,O||M);}else{}};A.addMethod=function(M,O,N){if(M&&O){A.prototype[M]=function(){var Q=[],P=arguments;C.Array.each(this._nodes,function(V){var U=(V.uniqueID&&V.nodeType!==9)?"uniqueID":"_yuid",S=C.Node._instances[V[U]],T,R;if(!S){S=A._getTempNode(V);}T=N||S;R=O.apply(T,P);if(R!==undefined&&R!==S){Q[Q.length]=R;}});return Q.length?Q:this;};}else{}};A.importMethod=function(O,M,N){if(typeof M==="string"){N=N||M;A.addMethod(M,O[M]);}else{C.Array.each(M,function(P){A.importMethod(O,P);});}};A._getTempNode=function(N){var M=A._tempNode;if(!M){M=C.Node.create("<div></div>");A._tempNode=M;}M._node=N;M._stateProxy=N;return M;};C.mix(A.prototype,{item:function(M){return C.one((this._nodes||[])[M]);},each:function(O,N){var M=this;C.Array.each(this._nodes,function(Q,P){Q=C.one(Q);return O.call(N||Q,Q,P,M);});return M;},batch:function(N,M){var O=this;C.Array.each(this._nodes,function(R,Q){var P=C.Node._instances[R[D]];if(!P){P=A._getTempNode(R);}return N.call(M||P,P,Q,O);});return O;},some:function(O,N){var M=this;return C.Array.some(this._nodes,function(Q,P){Q=C.one(Q);N=N||Q;return O.call(N,Q,P,M);});},toFrag:function(){return C.one(C.DOM._nl2frag(this._nodes));},indexOf:function(M){return C.Array.indexOf(this._nodes,C.Node.getDOMNode(M));},filter:function(M){return C.all(C.Selector.filter(this._nodes,M));},modulus:function(O,N){N=N||0;var M=[];A.each(this,function(Q,P){if(P%O===N){M.push(Q);}});return C.all(M);},odd:function(){return this.modulus(2,1);},even:function(){return this.modulus(2);},destructor:function(){},refresh:function(){var P,N=this._nodes,O=this._query,M=this._queryRoot;if(O){if(!M){if(N&&N[0]&&N[0].ownerDocument){M=N[0].ownerDocument;}}this._nodes=C.Selector.query(O,M);}return this;},_prepEvtArgs:function(P,O,N){var M=C.Array(arguments,0,true);if(M.length<2){M[2]=this._nodes;}else{M.splice(2,0,this._nodes);}M[3]=N||this;return M;},on:function(O,N,M){return C.on.apply(C,this._prepEvtArgs.apply(this,arguments));},once:function(O,N,M){return C.once.apply(C,this._prepEvtArgs.apply(this,arguments));},after:function(O,N,M){return C.after.apply(C,this._prepEvtArgs.apply(this,arguments));},size:function(){return this._nodes.length;},isEmpty:function(){return this._nodes.length<1;},toString:function(){var P="",O=this[D]+": not bound to any nodes",M=this._nodes,N;if(M&&M[0]){N=M[0];P+=N[E];if(N.id){P+="#"+N.id;}if(N.className){P+="."+N.className.replace(" ",".");}if(M.length>1){P+="...["+M.length+" items]";}}return P||O;}},true);A.importMethod(C.Node.prototype,["append","detach","detachAll","insert","prepend","remove","set","setContent"]);A.prototype.get=function(N){var Q=[],P=this._nodes,O=false,R=A._getTempNode,M,S;if(P[0]){M=C.Node._instances[P[0]._yuid]||R(P[0]);S=M._get(N);if(S&&S.nodeType){O=true;}}C.Array.each(P,function(T){M=C.Node._instances[T._yuid];
if(!M){M=R(T);}S=M._get(N);if(!O){S=C.Node.scrubVal(S,M);}Q.push(S);});return(O)?C.all(Q):Q;};C.NodeList=A;C.all=function(M){return new A(M);};C.Node.all=C.all;C.Array.each(["removeChild","hasChildNodes","cloneNode","hasAttribute","removeAttribute","scrollIntoView","getElementsByTagName","focus","blur","submit","reset","select","createCaption",],function(M){C.Node.prototype[M]=function(Q,O,N){var P=this.invoke(M,Q,O,N);return P;};});C.Node.importMethod(C.DOM,["contains","setAttribute","getAttribute","wrap","unwrap"]);C.NodeList.importMethod(C.Node.prototype,["getAttribute","setAttribute","removeAttribute"]);(function(N){var M=["hasClass","addClass","removeClass","replaceClass","toggleClass"];N.Node.importMethod(N.DOM,M);N.NodeList.importMethod(N.Node.prototype,M);})(C);if(!C.config.doc.documentElement.hasAttribute){C.Node.prototype.hasAttribute=function(M){if(M==="value"){if(this.get("value")!==""){return true;}}return !!(this._node.attributes[M]&&this._node.attributes[M].specified);};}C.Node.prototype.focus=function(){try{this._node.focus();}catch(M){}};C.Node.ATTRS.type={setter:function(N){if(N==="hidden"){try{this._node.type="hidden";}catch(M){this.setStyle("display","none");this._inputType="hidden";}}else{try{this._node.type=N;}catch(M){}}return N;},getter:function(){return this._inputType||this._node.type;},_bypassProxy:true};if(C.config.doc.createElement("form").elements.nodeType){C.Node.ATTRS.elements={getter:function(){return this.all("input, textarea, button, select");}};}C.mix(C.Node.ATTRS,{offsetHeight:{setter:function(M){C.DOM.setHeight(this._node,M);return M;},getter:function(){return this._node.offsetHeight;}},offsetWidth:{setter:function(M){C.DOM.setWidth(this._node,M);return M;},getter:function(){return this._node.offsetWidth;}}});C.mix(C.Node.prototype,{sizeTo:function(M,N){var O;if(arguments.length<2){O=C.one(M);M=O.get("offsetWidth");N=O.get("offsetHeight");}this.setAttrs({offsetWidth:M,offsetHeight:N});}});},"@VERSION@",{requires:["dom-base","selector-css2","event-base"]});