node-base-min.js revision 45f27cabd6196774234000850bbe9a5f70c64f9b
YUI.add("node-base",function(D){var M={},J={},H=Array.prototype.slice,G=".",E="nodeName",K="nodeType",B="ownerDocument",I="tagName",C="_yuid",F=function(O){var N=O[C];if(N&&M[N]&&M[N]!==O){O[C]=null;}this._initPlugins();N=D.stamp(O);if(!N){N=D.guid();}this[C]=N;this._conf={};M[N]=O;this._stateProxy=O;F._instances[N]=this;},L=function(O){var N=null;if(O){N=(typeof O==="string")?function(P){return D.Selector.test(P,O);}:function(P){return O(F.get(P));};}return N;};F.NAME="Node";F.re_aria=/^(?:role$|aria-)/;F.DOM_EVENTS={abort:true,beforeunload:true,blur:true,change:true,click:true,close:true,command:true,contextmenu:true,drag:true,dragstart:true,dragenter:true,dragover:true,dragleave:true,dragend:true,drop:true,dblclick:true,error:true,focus:true,keydown:true,keypress:true,keyup:true,load:true,mousedown:true,mousemove:true,mouseout:true,mouseover:true,mouseup:true,mousemultiwheel:true,mousewheel:true,submit:true,mouseenter:true,mouseleave:true,scroll:true,reset:true,resize:true,select:true,textInput:true,unload:true};D.mix(F.DOM_EVENTS,D.Env.evt.plugins);F._instances={};F.plug=function(){var N=H.call(arguments,0);N.unshift(F);D.Plugin.Host.plug.apply(D.Base,N);return F;};F.unplug=function(){var N=H.call(arguments,0);N.unshift(F);D.Plugin.Host.unplug.apply(D.Base,N);return F;};F.getDOMNode=function(N){if(N){if(N instanceof F){N=M[N[C]];}else{if(!N[E]||D.DOM.isWindow(N)){N=null;}}}return N||null;};F.scrubVal=function(Q,O,P){if(O&&Q){if(typeof Q==="object"||typeof Q==="function"){if(K in Q||D.DOM.isWindow(Q)){Q=F.get(Q);}else{if(Q.item||(Q[0]&&Q[0][K])){Q=D.all(Q);}else{P=(P===undefined)?4:P;if(P>0){for(var N in Q){if(Q.hasOwnProperty&&Q.hasOwnProperty(N)){Q[N]=F.scrubVal(Q[N],O,--P);}}}}}}}else{if(Q===undefined){Q=O;}}return Q;};F.addMethod=function(N,P,O){if(N&&P&&typeof P==="function"){F.prototype[N]=function(){O=O||this;var R=H.call(arguments),Q;if(R[0]&&R[0] instanceof F){R[0]=F.getDOMNode(R[0]);}if(R[1]&&R[1] instanceof F){R[1]=F.getDOMNode(R[1]);}R.unshift(M[this[C]]);Q=F.scrubVal(P.apply(O,R),this);return Q;};}else{}};F.importMethod=function(P,N,O){if(typeof N==="string"){O=O||N;F.addMethod(O,P[N],P);}else{D.each(N,function(Q){F.importMethod(P,Q);});}};F.get=function(Q,R){var N=null,P,O;if(Q){if(typeof Q==="string"){if(Q.indexOf("doc")===0){Q=D.config.doc;}else{if(Q.indexOf("win")===0){Q=D.config.win;}else{Q=D.Selector.query(Q,R,true);}}if(!Q){return null;}}else{if(Q instanceof F){return Q;}}O=Q._yuid;P=M[O];N=F._instances[O];if(!N||(P&&Q!==P)){N=new F(Q);}}return N;};F.create=function(){return F.get(D.DOM.create.apply(D.DOM,arguments));};F.ATTRS={text:{getter:function(){return D.DOM.getText(M[this[C]]);},setter:function(N){D.DOM.setText(M[this[C]],N);return N;}},"options":{getter:function(){return this.getElementsByTagName("option");}},"children":{getter:function(){var Q=M[this[C]],P=Q.children,R,O,N;if(!P){R=Q.childNodes;P=[];for(O=0,N=R.length;O<N;++O){if(R[O][I]){P[P.length]=R[O];}}}return D.all(P);}},value:{getter:function(){return D.DOM.getValue(M[this[C]]);},setter:function(N){D.DOM.setValue(M[this[C]],N);return N;}},getter:function(){return this._data;},setter:function(N){this._data=N;return N;}};F.DEFAULT_SETTER=function(N,P){var O=this._stateProxy,Q;if(N.indexOf(G)>-1){Q=N;N=N.split(G);D.Object.setValue(O,N,P);}else{if(O[N]!==undefined){O[N]=P;}}return P;};F.DEFAULT_GETTER=function(N){var O=this._stateProxy,P;if(N.indexOf&&N.indexOf(G)>-1){P=D.Object.getValue(O,N.split(G));}else{if(O[N]!==undefined){P=O[N];}}return P?D.Node.scrubVal(P,this):P;};D.augment(F,D.Event.Target);D.augment(F,D.Plugin.Host);D.mix(F.prototype,{toString:function(){var P="",O=this[C]+": not bound to a node",N=M[this[C]];if(N){P+=N[E];if(N.id){P+="#"+N.id;}if(N.className){P+="."+N.className.replace(" ",".");}P+=" "+this[C];}return P||O;},get:function(N){var O=F.ATTRS[N],P;if(O&&O.getter){P=O.getter.call(this);}else{if(F.re_aria.test(N)){P=D.Node.getDOMNode(this).getAttribute(N,2);}else{P=F.DEFAULT_GETTER.apply(this,arguments);}}return P;},set:function(N,P){var O=F.ATTRS[N];if(O&&O.setter){O.setter.call(this,P);}else{if(F.re_aria.test(N)){D.Node.getDOMNode(this).setAttribute(N,P);}else{F.DEFAULT_SETTER.apply(this,arguments);}}return this;},create:F.create,compareTo:function(N){var O=M[this[C]];if(N instanceof D.Node){N=D.Node.getDOMNode(N);}return O===N;},inDoc:function(O){var N=M[this[C]];O=(O)?F.getDOMNode(O):N[B];if(O.documentElement){return D.DOM.contains(O.documentElement,N);}},getById:function(P){var O=M[this[C]],N=D.DOM.byId(P,O[B]);if(N&&D.DOM.contains(O,N)){N=D.get(N);}else{N=null;}return N;},ancestor:function(N){return F.get(D.DOM.elementByAxis(M[this[C]],"parentNode",L(N)));},previous:function(O,N){return F.get(D.DOM.elementByAxis(M[this[C]],"previousSibling",L(O),N));},next:function(P,O,N){return F.get(D.DOM.elementByAxis(M[this[C]],"nextSibling",L(O),N));},query:function(N){return D.get(D.Selector.query(N,M[this[C]],true));},queryAll:function(N){return D.all(D.Selector.query(N,M[this[C]]));},test:function(N){return D.Selector.test(M[this[C]],N);},remove:function(){var N=M[this[C]];N.parentNode.removeChild(N);return this;},invoke:function(U,O,N,T,S,R){var Q=M[this[C]],P;if(O&&O instanceof D.Node){O=F.getDOMNode(O);}if(N&&N instanceof D.Node){N=F.getDOMNode(N);}P=Q[U](O,N,T,S,R);return D.Node.scrubVal(P,this);},destructor:function(){},each:function(O,N){N=N||this;return O.call(N,this);},item:function(N){return this;},size:function(){return M[this[C]]?1:0;},insert:function(O,N){if(O){if(typeof N==="number"){N=M[this[C]].childNodes[N];}if(typeof O!=="string"){O=D.Node.getDOMNode(O);}D.DOM.addHTML(M[this[C]],O,N);}return this;},prepend:function(N){return this.insert(N,0);},append:function(N){return this.insert(N,null);},setContent:function(N){D.DOM.addHTML(M[this[C]],N,"replace");return this;},hasMethod:function(O){var N=M[this[C]];return(N&&(typeof N==="function"));}},true);D.Node=F;D.get=D.Node.get;D.first=D.Node.get;D.Array._diff=function(O,N){var S=[],U=false,Q,P,T,R;outer:for(Q=0,T=O.length;Q<T;
Q++){U=false;for(P=0,R=N.length;P<R;P++){if(O[Q]===N[P]){U=true;continue outer;}}if(!U){S[S.length]=O[Q];}}return S;};D.Array.diff=function(O,N){return{added:D.Array._diff(N,O),removed:D.Array._diff(O,N)};};var A=function(O){var N=O.nodes||[],P=O.doc||D.config.doc;if(typeof N==="string"){this._query=N;N=D.Selector.query(N,P);}D.stamp(this);A._instances[this[C]]=this;J[this[C]]=N;};A.NAME="NodeList";A.getDOMNodes=function(N){return J[N[C]];};A._instances=[];A.each=function(N,Q,P){var O=J[N[C]];if(O&&O.length){D.Array.each(O,Q,P||N);}else{}};A.addMethod=function(N,Q,P){var O=A._getTempNode();if(N&&Q){A.prototype[N]=function(){var S=[],R=arguments;D.Array.each(J[this[C]],function(X){var W="_yuid",U=D.Node._instances[X[W]],V,T;if(!U){M[O[W]]=X;U=O;}V=P||U;T=Q.apply(V,R);if(T!==undefined&&T!==U){S[S.length]=T;}});return S.length?S:this;};}else{}};A.importMethod=function(P,N,O){if(typeof N==="string"){O=O||N;A.addMethod(N,P[N]);}else{D.each(N,function(Q){A.importMethod(P,Q);});}};A._getTempNode=function(){var N=A._tempNode;if(!N){N=D.Node.create("<div></div>");A._tempNode=N;}return N;};D.mix(A.prototype,{item:function(N){return D.get((J[this[C]]||[])[N]);},each:function(P,O){var N=this;D.Array.each(J[this[C]],function(R,Q){R=D.get(R);return P.call(O||R,R,Q,N);});return N;},batch:function(P,O){var Q=this,N=A._getTempNode();D.Array.each(J[this[C]],function(T,S){var R=D.Node._instances[T[C]];if(!R){M[N[C]]=T;R=N;}return P.call(O||R,R,S,Q);});return Q;},some:function(P,O){var N=this;return D.Array.some(J[this[C]],function(R,Q){R=D.get(R);O=O||R;return P.call(O,R,Q,N);});},indexOf:function(N){return D.Array.indexOf(J[this[C]],D.Node.getDOMNode(N));},filter:function(N){return D.all(D.Selector.filter(J[this[C]],N));},modulus:function(P,O){O=O||0;var N=[];A.each(this,function(R,Q){if(Q%P===O){N.push(R);}});return D.all(N);},odd:function(){return this.modulus(2,1);},even:function(){return this.modulus(2);},destructor:function(){delete A._instances[this[C]];},refresh:function(){var O,N,P=J[this[C]];if(this._query){if(J[this[C]]&&J[this[C]][0]&&J[this[C]][0].ownerDocument){O=J[this[C]][0].ownerDocument;}J[this[C]]=D.Selector.query(this._query,O||D.config.doc);N=D.Array.diff(P,J[this[C]]);N.added=N.added?D.all(N.added):null;N.removed=N.removed?D.all(N.removed):null;this.fire("refresh",N);}return this;},on:function(P,O,N){N=N||this;this.batch(function(Q){Q.on.call(Q,P,O,N);});},after:function(P,O,N){N=N||this;this.batch(function(Q){Q.after.call(Q,P,O,N);});},size:function(){return J[this[C]].length;},get:function(O){var N=[],P=A._getTempNode();A.each(this,function(R){var Q=D.Node._instances[R[C]];if(!Q){M[P[C]]=R;Q=P;}N[N.length]=Q.get(O);});return N;},toString:function(){var Q="",P=this[C]+": not bound to any nodes",N=J[this[C]],O;if(N&&N[0]){O=N[0];Q+=O[E];if(O.id){Q+="#"+O.id;}if(O.className){Q+="."+O.className.replace(" ",".");}if(N.length>1){Q+="...["+N.length+" items]";}}return Q||P;}},true);A.importMethod(D.Node.prototype,["append","detach","detachAll","insert","plug","prepend","remove","set","setContent","unplug"]);D.NodeList=A;D.all=function(O,Q,N){var P=new A({nodes:O,doc:Q});return P;};D.Node.all=D.all;D.Array.each(["replaceChild","appendChild","insertBefore","removeChild","hasChildNodes","cloneNode","hasAttribute","removeAttribute","scrollIntoView","getElementsByTagName","focus","blur","submit","reset","select"],function(N){D.Node.prototype[N]=function(R,P,O){var Q=this.invoke(N,R,P,O);return Q;};});F.importMethod(D.DOM,["contains","setAttribute","getAttribute"]);if(!document.documentElement.hasAttribute){D.Node.prototype.hasAttribute=function(N){return D.DOM.getAttribute(D.Node.getDOMNode(this),N)!=="";};}D.NodeList.importMethod(D.Node.prototype,["getAttribute","setAttribute"]);(function(O){var N=["hasClass","addClass","removeClass","replaceClass","toggleClass"];O.Node.importMethod(O.DOM,N);O.NodeList.importMethod(O.Node.prototype,N);})(D);D.Node.prototype.delegate=function(S,R,N,Q){Q=Q||this;var P=Array.prototype.slice.call(arguments,4),O=["delegate",R,D.Node.getDOMNode(this),S,N,Q];O=O.concat(P);return D.on.apply(D,O);};},"@VERSION@",{requires:["dom-base","event-custom","selector-css2","plugin"]});