selector-min.js revision 45411eef9a56441369baf37f93779e0eb0a8bf90
YUI.add("selector",function(B){B.namespace("Selector");var K="parentNode",C="length",H={_reLead:/^\s*([>+~]|:self)/,_reUnSupported:/!./,_foundCache:[],_supportsNative:function(){return((B.UA.ie>=8||B.UA.webkit>525)&&document.querySelectorAll);},_toArray:function(N){var O=N;if(!N.slice){try{O=Array.prototype.slice.call(N);}catch(Q){O=[];for(var P=0,M=N[C];P<M;++P){O[P]=N[P];}}}return O;},_clearFoundCache:function(){var P=H._foundCache;for(var N=0,M=P[C];N<M;++N){try{delete P[N]._found;}catch(O){P[N].removeAttribute("_found");}}P=[];},_sort:function(M){if(M){M=H._toArray(M);if(M.sort){M.sort(function(O,N){return B.DOM.srcIndex(O)-B.DOM.srcIndex(N);});}}return M;},_deDupe:function(N){var O=[],M=H._foundCache;for(var P=0,Q;Q=N[P++];){if(!Q._found){O[O[C]]=M[M[C]]=Q;Q._found=true;}}H._clearFoundCache();return O;},_prepQuery:function(U,Q){var O=Q.split(","),S=[],M=(U&&U.nodeType===9),P=false,N,V,W;if(U){if(!M){U.id=U.id||B.guid();for(var R=0,T=O[C];R<T;++R){if(H._reLead.test(O[R])){N=RegExp.$1;P=true;V=U;W="#"+U.id+" "+O[R];if(N==="~"||N==="+"){if(U[K]){V=U[K];}else{}}}else{V=U;W=O[R];}S.push({root:V,selector:W});}}if(!P){S=[{root:U,selector:Q}];}}return S;},_query:function(M,T,U){if(H._reUnSupported.test(M)){return H._brute.query(M,T,U);}var Q=U?null:[],R=U?"querySelector":"querySelectorAll",V,O;T=T||B.config.doc;if(M){O=H._prepQuery(T,M);Q=[];for(var N=0,S;S=O[N++];){try{V=S.root[R](S.selector);if(V&&V.item){V=H._toArray(V);}Q=Q.concat(V);}catch(P){}}if(O[C]>1){Q=H._sort(H._deDupe(Q));}Q=(!U)?Q:Q[0]||null;}return Q;},_filter:function(N,M){if(H._reUnSupported.test(M)){return H._brute.filter(N,M);}var O=[];if(N&&M){for(var P=0,Q;(Q=N[P++]);){if(H._native.test(Q,M)){O[O[C]]=Q;}}}else{}return O;},_test:function(P,M){if(H._reUnSupported.test(M)){return H._brute.test(P,M);}var N=false,O;if(P&&P[K]){P.id=P.id||B.guid();M+="#"+P.id;O=H._native.query(M,P[K],true);N=(O===P);}return N;}};if(B.UA.ie&&B.UA.ie<=8){H._reUnSupported=/:(?:nth|not|root|only|checked|first|last|empty)/;}B.mix(B.Selector,H,true);if(H._supportsNative()){B.Selector.query=H._query;B.Selector.filter=H._filter;B.Selector.test=H._test;}var K="parentNode",J="tagName",E="attributes",F="combinator",D="pseudos",G="previous",I="previousSibling",C="length",A=B.Selector,L={_regexCache:{},_re:{attr:/(\[.*\])/g,urls:/^(?:href|src)/},attrAliases:{},shorthand:{"\\#(-?[_a-z]+[-\\w]*)":"[id=$1]","\\.(-?[_a-z]+[-\\w]*)":"[className~=$1]",},operators:{"":function(N,M){return N[M];},"=":"^{val}$","~=":"(?:^|\\s+){val}(?:\\s+|$)","|=":"^{val}-?"},pseudos:{"first-child":function(M){return B.DOM.children(M[K])[0]===M;}},_brute:{test:function(Q,O){if(!Q){return false;}var N=O?O.split(","):[];if(N[C]>1){for(var P=0,M=N[C];P<M;++P){if(A._test(Q,N[P])){return true;}}return false;}return A._test(Q,O);},filter:function(O,N){var M=A._filter(O,A._tokenize(N)[0]);return M;},query:function(N,O,P){var M=A._query(N,O,P);return M;},},_test:function(R,N,Q,O){Q=Q||A._tokenize(N).pop();if(!Q||!R[J]||(O&&R._found)){return false;}for(var P=0,M;M=Q.tests[P++];){if(M.test){if(typeof M.test==="function"){if(!M.test(R,M.name)){return false;}}else{if(!M.test.test(R[M.name])){return false;}}}}return(Q[G]&&Q[G][F])?A._combinators[Q[G][F]](R,Q):true;},_filter:function(P,R,S,O){var N=S?null:[],T=A._foundCache;if(P){for(var Q=0,M=P[C];Q<M;Q++){if(!A._test(P[Q],"",R,O)){continue;}if(S){return P[Q];}if(O){if(P[Q]._found){continue;}P[Q]._found=true;T[T[C]]=P[Q];}N[N[C]]=P[Q];}}return N;},_query:function(S,W,X,Q){var Z=(X)?null:[],P;if(!S){return Z;}W=W||B.config.doc;var O=S.split(",");if(O[C]>1){var Y;Z=[];for(var T=0,U=O[C];T<U;++T){Y=arguments.callee(O[T],W,X,true);Z=Z.concat(Y);}Z=A._sort(Z);A._clearFoundCache();return(X)?Z[0]:Z;}var V=A._tokenize(S),M=[],R=V.pop()||{},N=R.id;if(N){P=B.DOM.byId(N);M=P&&B.DOM.contains(W,P)?[P]:[];}if(W&&!M[C]){M=W.getElementsByTagName(R.tag);}if(M[C]){Z=A._filter(M,R,X,Q);}return Z;},_getRegExp:function(O,M){var N=A._regexCache;M=M||"";if(!N[O+M]){N[O+M]=new RegExp(O,M);}return N[O+M];},_combinators:{" ":function(N,M){while((N=N[K])){if(A._test(N,"",M[G])){return true;}}return false;},">":function(N,M){return A._test(N[K],null,M[G]);},"+":function(O,N){var M=O[I];while(M&&M.nodeType!==1){M=M[I];}if(M&&B.Selector._test(M,null,N[G])){return true;}return false;}},_parsers:[{name:E,re:/^\[([a-z]+\w*)+([~\|\^\$\*!=]=?)?['"]?([^\]]*?)['"]?\]/i,fn:function(O,N){var M=N[2],P=N[3],Q=A.operators[M]||null;if(typeof Q==="string"){Q=A._getRegExp(Q.replace("{val}",P),"i");}if(Q){O.tests.push({name:N[1],test:Q});}if(N[1]==="id"){O.id=N[1];}}},{name:J,re:/^((?:-?[_a-z]+[\w-]*)|\*)/i,fn:function(N,M){var O=A.operators["="].replace("{val}",M[1]);N.tag=M[1];if(N.tag!=="*"){N.tests.push({name:J,test:A._getRegExp(O,"i")});}}},{name:F,re:/^\s*([>+~]|\s)\s*/,fn:function(N,M){N[F]=M[1];}},{name:D,re:/^:([\-\w]+)(?:\(['"]?(.+)['"]?\))*/i,fn:function(N,M){N.tests.push({name:M[1],test:A[D][M[1]]});}}],_getToken:function(M){return{previous:M,combinator:" ",tag:"*",tests:[]};},_tokenize:function(M){var P=A._getToken(),R=[],Q=false,N;M=A._replaceShorthand(M);do{Q=false;for(var O=0,S;S=A._parsers[O++];){if((N=S.re.exec(M))){Q=true;S.fn(P,N);M=M.replace(N[0],"");if(!M[C]||S.name===F){R.push(P);P=A._getToken(P);}}}}while(Q);return(!M.length)?R:[];},_replaceShorthand:function(N){var O=A.shorthand;var P=N.match(A._re.attr);if(P){N=N.replace(A._re.attr,"REPLACED_ATTRIBUTE");}for(var R in O){if(O.hasOwnProperty(R)){N=N.replace(A._getRegExp(R,"gi"),O[R]);}}if(P){for(var Q=0,M=P[C];Q<M;++Q){N=N.replace("REPLACED_ATTRIBUTE",P[Q]);}}return N;}};if(B.UA.ie&&B.UA.ie<8){L.attrAliases["class"]="className";}B.mix(B.Selector,L,true);if(!B.Selector._supportsNative()){B.Selector.query=A._brute.query;B.Selector.filter=A._brute.filter;B.Selector.test=A._brute.test;}},"@VERSION@",{requires:["dom-base"],skinnable:false});