selector-min.js revision 7bd6c48178788dd4f19fa028e0294192ee2c7278
YUI.add("selector",function(C){C.namespace("Selector");var L="parentNode",D="length",I={_reLead:/^\s*([>+~]|:self)/,_reUnSupported:/!./,_foundCache:[],_supportsNative:function(){return((C.UA.ie>=8||C.UA.webkit>525)&&document.querySelectorAll);},_toArray:function(O){var P=O;if(!O.slice){try{P=Array.prototype.slice.call(O);}catch(R){P=[];for(var Q=0,N=O[D];Q<N;++Q){P[Q]=O[Q];}}}return P;},_clearFoundCache:function(){var Q=I._foundCache;for(var O=0,N=Q[D];O<N;++O){try{delete Q[O]._found;}catch(P){Q[O].removeAttribute("_found");}}Q=[];},_sort:function(N){if(N){N=I._toArray(N);if(N.sort){N.sort(function(P,O){return C.DOM.srcIndex(P)-C.DOM.srcIndex(O);});}}return N;},_deDupe:function(O){var P=[],N=I._foundCache;for(var Q=0,R;R=O[Q++];){if(!R._found){P[P[D]]=N[N[D]]=R;R._found=true;}}I._clearFoundCache();return P;},_prepQuery:function(V,R){var P=R.split(","),T=[],N=(V&&V.nodeType===9),Q=false,O,W,X;if(V){if(!N){V.id=V.id||C.guid();for(var S=0,U=P[D];S<U;++S){if(I._reLead.test(P[S])){O=RegExp.$1;Q=true;W=V;X="#"+V.id+" "+P[S];if(O==="~"||O==="+"){if(V[L]){W=V[L];}else{}}}else{W=V;X=P[S];}T.push({root:W,selector:X});}}if(!Q){T=[{root:V,selector:R}];}}return T;},_query:function(N,U,V){if(I._reUnSupported.test(N)){return I._brute.query(N,U,V);}var R=V?null:[],S=V?"querySelector":"querySelectorAll",W,P;U=U||C.config.doc;if(N){P=I._prepQuery(U,N);R=[];for(var O=0,T;T=P[O++];){try{W=T.root[S](T.selector);if(W&&W.item){W=I._toArray(W);}R=R.concat(W);}catch(Q){}}if(P[D]>1){R=I._sort(I._deDupe(R));}R=(!V)?R:R[0]||null;}return R;},_filter:function(O,N){var P=[];if(O&&N){for(var Q=0,R;(R=O[Q++]);){if(C.Selector._test(R,N)){P[P[D]]=R;}}}else{}return P;},_test:function(Q,N){var O=false,P;if(Q&&Q[L]){Q.id=Q.id||C.guid();N+="#"+Q.id;P=C.Selector.query(N,Q[L],true);O=(P===Q);}return O;}};if(C.UA.ie&&C.UA.ie<=8){I._reUnSupported=/:(?:nth|not|root|only|checked|first|last|empty)/;}C.mix(C.Selector,I,true);if(I._supportsNative()){C.Selector.query=I._query;}C.Selector.test=I._test;C.Selector.filter=I._filter;var L="parentNode",K="tagName",F="attributes",G="combinator",E="pseudos",H="previous",J="previousSibling",D="length",B=[],A=C.Selector,M={SORT_RESULTS:false,_children:function(P){var N=P.children;if(!N){N=[];for(var O=0,Q;Q=P.childNodes[O++];){if(Q.tagName){N[N.length]=Q;}}B[B.length]=P;P.children=N;}return N;},_regexCache:{},_re:{attr:/(\[.*\])/g,urls:/^(?:href|src)/},shorthand:{"\\#(-?[_a-z]+[-\\w]*)":"[id=$1]","\\.(-?[_a-z]+[-\\w]*)":"[className~=$1]"},operators:{"":function(O,N){return C.DOM.getAttribute(O,N[0])!=="";},"=":"^{val}$","~=":"(?:^|\\s+){val}(?:\\s+|$)","|=":"^{val}-?"},pseudos:{"first-child":function(N){return C.Selector._children(N[L])[0]===N;}},_brute:{query:function(N,O,Q){var P=[];if(N){P=A._query(N,O,Q);}A._cleanup();return(Q)?(P[0]||null):P;}},some:function(){return(Array.prototype.some)?function(N,P,O){return Array.prototype.some.call(N,P,O);}:function(N,Q,P){for(var O=0,R;R=N[O++];){if(Q.call(P,R,O,N)){return true;}}return false;};}(),_cleanup:function(){for(var N=0,O;O=B[N++];){delete O.children;}B=[];},_query:function(R,W,X,P){var U=[],O=R.split(","),N=[],V,Q;if(O[D]>1){for(var S=0,T=O[D];S<T;++S){U=U.concat(arguments.callee(O[S],W,X,true));}U=A.SORT_RESULT?A._sort(U):U;A._clearFoundCache();}else{W=W||C.config.doc;if(W.nodeType!==9){R="#"+W.id+" selector";W=W.ownerDocument;}V=A._tokenize(R);Q=V.pop();if(Q){if(V[0]&&V[0].id){W=W.getElementById(V[0].id);}if(W&&!N[D]&&Q.prefilter){N=Q.prefilter(W,Q);}if(N[D]){if(X){A.some(N,A._testToken,Q);}else{C.Array.each(N,A._testToken,Q);}}U=Q.result;}}return U;},_testToken:function(O,S,N,P){var P=P||this,U=P.tag,R=P[H],V=P.result,Q=0,T=R&&R[G]?A.combinators[R[G]]:null;if((U==="*"||U===O[K])&&!(O._found)){while((attr=P.tests[Q])){Q++;test=attr.test;if(test.test){if(!test.test(O[attr.name])){return false;}}else{if(!test(O,attr.match)){return false;}}}if(T&&!T(O,P)){return false;}V[V.length]=O;return true;}return false;},_getRegExp:function(P,N){var O=A._regexCache;N=N||"";if(!O[P+N]){O[P+N]=new RegExp(P,N);}return O[P+N];},combinators:{" ":function(P,N){var Q=A._testToken,O=N[H];while((P=P[L])){if(Q(P,null,null,O)){return true;}}return false;},">":function(O,N){return A._testToken(O[L],null,null,N[H]);},"+":function(P,O){var N=P[J];while(N&&N.nodeType!==1){N=N[J];}if(N&&C.Selector._testToken(N,null,null,O[H])){return true;}return false;}},_parsers:[{name:K,re:/^((?:-?[_a-z]+[\w-]*)|\*)/i,fn:function(O,N){O.tag=N[1].toUpperCase();O.prefilter=function(P){return P.getElementsByTagName(O.tag);};return true;}},{name:F,re:/^\[([a-z]+\w*)+([~\|\^\$\*!=]=?)?['"]?([^\]]*?)['"]?\]/i,fn:function(P,O){var Q=O[3],N=!(O[2]&&Q)?"":O[2],R=A.operators[N];if(typeof R==="string"){R=A._getRegExp(R.replace("{val}",Q));}if(O[1]==="id"&&Q){P.id=Q;P.prefilter=function(S){var U=S.nodeType===9?S:S.ownerDocument,T=U.getElementById(Q);return T?[T]:[];};}else{if(document.documentElement.getElementsByClassName&&O[1].indexOf("class")===0){R=true;P.prefilter=function(S){return S.getElementsByClassName(Q);};}}return R;}},{name:G,re:/^\s*([>+~]|\s)\s*/,fn:function(O,N){O[G]=N[1];return !!A.combinators[O[G]];}},{name:E,re:/^:([\-\w]+)(?:\(['"]?(.+)['"]?\))*/i,fn:function(O,N){return A[E][N[1]];}}],_getToken:function(N){return{previous:N,combinator:" ",tag:"*",prefilter:function(O){return O.getElementsByTagName("*");},tests:[],result:[]};},_tokenize:function(N){N=N||"";N=A._replaceShorthand(C.Lang.trim(N));var Q=A._getToken(),S=[],R=false,U,O;outer:do{R=false;for(var P=0,T;T=A._parsers[P++];){if((O=T.re.exec(N))){U=T.fn(Q,O);if(U){if(U!==true){Q.tests.push({name:O[1],test:U,match:O.slice(1)});}R=true;N=N.replace(O[0],"");if(!N[D]||T.name===G){S.push(Q);Q=A._getToken(Q);}}else{R=false;break outer;}}}}while(R&&N.length);if(!R||N.length){S=[];}return S;},_replaceShorthand:function(O){var P=A.shorthand,Q=O.match(A._re.attr);if(Q){O=O.replace(A._re.attr,"REPLACED_ATTRIBUTE");}for(var S in P){if(P.hasOwnProperty(S)){O=O.replace(A._getRegExp(S,"gi"),P[S]);}}if(Q){for(var R=0,N=Q[D];R<N;++R){O=O.replace("REPLACED_ATTRIBUTE",Q[R]);
}}return O;}};C.mix(C.Selector,M,true);if(!C.Selector._supportsNative()){C.Selector.query=A._brute.query;}C.Selector._reNth=/^(?:([-]?\d*)(n){1}|(odd|even)$)*([-+]?\d*)$/;C.Selector._getNth=function(O,X,Z,S){C.Selector._reNth.test(X);var W=parseInt(RegExp.$1,10),N=RegExp.$2,T=RegExp.$3,U=parseInt(RegExp.$4,10)||0,Y=[],Q;var V=O.parentNode.children||A._children(O.parentNode);if(T){W=2;Q="+";N="n";U=(T==="odd")?1:0;}else{if(isNaN(W)){W=(N)?1:0;}}if(W===0){if(S){U=V.length-U+1;}if(V[U-1]===O){return true;}else{return false;}}else{if(W<0){S=!!S;W=Math.abs(W);}}if(!S){for(var P=U-1,R=V.length;P<R;P+=W){if(P>=0&&V[P]===O){return true;}}}else{for(var P=V.length-U,R=V.length;P>=0;P-=W){if(P<R&&V[P]===O){return true;}}}return false;};C.mix(C.Selector.pseudos,{"root":function(N){return N===N.ownerDocument.documentElement;},"nth-child":function(O,N){return C.Selector._getNth(O,N[1]);},"nth-last-child":function(O,N){return C.Selector._getNth(O,N[1],null,true);},"nth-of-type":function(O,N){return C.Selector._getNth(O,N[1],O.tagName);},"nth-last-of-type":function(O,N){return C.Selector._getNth(O,N[1],O.tagName,true);},"last-child":function(O){var N=O.children||C.Selector._children(O.parentNode);return N[N.length-1]===O;},"first-of-type":function(N){return C.DOM._childrenByTag(N.parentNode,N.tagName)[0];},"last-of-type":function(O){var N=C.DOM._childrenByTag(O.parentNode,O.tagName);return N[N.length-1];},"only-child":function(O){var N=O.children||C.Selector._children(O.parentNode);return N.length===1&&N[0]===O;},"only-of-type":function(N){return C.DOM._childrenByTag(N.parentNode,N.tagName).length===1;},"empty":function(N){return N.childNodes.length===0;},"not":function(O,N){return !C.Selector.test(O,N[1]);},"contains":function(O,N){var P=O.innerText||O.textContent||"";return P.indexOf(N[1])>-1;},"checked":function(N){return N.checked===true;}});C.mix(C.Selector.operators,{"^=":"^{val}","$=":"{val}$","*=":"{val}"});C.Selector.combinators["~"]=function(P,O){var N=P.previousSibling;while(N){if(N.nodeType===1&&C.Selector._testToken(N,null,null,O.previous)){return true;}N=N.previousSibling;}return false;};},"@VERSION@",{requires:["dom-base"],skinnable:false});