8 lines
7.1 KiB
JavaScript
8 lines
7.1 KiB
JavaScript
|
/*
|
||
|
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
|
||
|
Code licensed under the BSD License:
|
||
|
http://developer.yahoo.net/yui/license.txt
|
||
|
version: 2.6.0
|
||
|
*/
|
||
|
(function(){var T=function(){};var E=YAHOO.util;var U=/^(?:([-]?\d*)(n){1}|(odd|even)$)*([-+]?\d*)$/;T.prototype={document:window.document,attrAliases:{},shorthand:{"\\#(-?[_a-z]+[-\\w]*)":"[id=$1]","\\.(-?[_a-z]+[-\\w]*)":"[class~=$1]"},operators:{"=":function(W,X){return W===X;},"!=":function(W,X){return W!==X;},"~=":function(W,Y){var X=" ";return(X+W+X).indexOf((X+Y+X))>-1;},"|=":function(W,X){return G("^"+X+"[-]?").test(W);},"^=":function(W,X){return W.indexOf(X)===0;},"$=":function(W,X){return W.lastIndexOf(X)===W.length-X.length;},"*=":function(W,X){return W.indexOf(X)>-1;},"":function(W,X){return W;}},pseudos:{"root":function(W){return W===W.ownerDocument.documentElement;},"nth-child":function(W,X){return R(W,X);},"nth-last-child":function(W,X){return R(W,X,null,true);},"nth-of-type":function(W,X){return R(W,X,W.tagName);},"nth-last-of-type":function(W,X){return R(W,X,W.tagName,true);},"first-child":function(W){return F(W.parentNode)[0]===W;},"last-child":function(X){var W=F(X.parentNode);return W[W.length-1]===X;},"first-of-type":function(W,X){return F(W.parentNode,W.tagName.toLowerCase())[0];},"last-of-type":function(X,Y){var W=F(X.parentNode,X.tagName.toLowerCase());return W[W.length-1];},"only-child":function(X){var W=F(X.parentNode);return W.length===1&&W[0]===X;},"only-of-type":function(W){return F(W.parentNode,W.tagName.toLowerCase()).length===1;},"empty":function(W){return W.childNodes.length===0;},"not":function(W,X){return !T.test(W,X);},"contains":function(W,Y){var X=W.innerText||W.textContent||"";return X.indexOf(Y)>-1;},"checked":function(W){return W.checked===true;}},test:function(a,Y){a=T.document.getElementById(a)||a;if(!a){return false;}var X=Y?Y.split(","):[];if(X.length){for(var Z=0,W=X.length;Z<W;++Z){if(V(a,X[Z])){return true;}}return false;}return V(a,Y);},filter:function(Z,Y){Z=Z||[];var b,X=[],c=C(Y);if(!Z.item){for(var a=0,W=Z.length;a<W;++a){if(!Z[a].tagName){b=T.document.getElementById(Z[a]);if(b){Z[a]=b;}else{}}}}X=Q(Z,C(Y)[0]);B();return X;},query:function(X,Y,Z){var W=H(X,Y,Z);return W;}};var H=function(c,h,j,a){var l=(j)?null:[];if(!c){return l;}var Y=c.split(",");if(Y.length>1){var k;for(var d=0,e=Y.length;d<e;++d){k=arguments.callee(Y[d],h,j,true);l=j?k:l.concat(k);}I();return l;}if(h&&!h.nodeName){h=T.document.getElementById(h);if(!h){return l;}}h=h||T.document;var g=C(c);var f=g[N(g)],W=[],Z,X,b=g.pop()||{};if(f){X=P(f.attributes);}if(X){Z=T.document.getElementById(X);if(Z&&(h.nodeName=="#document"||L(Z,h))){if(V(Z,null,f)){if(f===b){W=[Z];}else{h=Z;}}}else{return l;}}if(h&&!W.length){W=h.getElementsByTagName(b.tag);}if(W.length){l=Q(W,b,j,a);}B();return l;};var L=function(){if(document.documentElement.contains&&!YAHOO.env.ua.webkit<422){return function(X,W){return W.contains(X);};}else{if(document.documentElement.compareDocumentPosition){return function(X,W){return !!(W.compareDocumentPosition(X)&16);};}else{return function(Y,X){var W=Y.parentNode;while(W){if(Y===W){return true;}W=W.parentNode;}return false;};}}}();var Q=function(Z,b,c,Y){var X=c?null:[];for(var a=0,W=Z.length;a<W;a++){if(!V(Z[a],"",b,Y)){continue;}if(c){return Z[a];}if(Y){if(Z[a]._found){continue;}Z[a]._found=true;M[M.length]=Z[a];}X[X.length]=Z[a];}return X;};var V=function(c,X,a,Y){a=a||C(X).pop()||{};if(!c.tagName||(a.tag!=="*"&&c.tagName.toUpperCase()!==a.tag)||(Y&&c._found)){return false;}if(a.attributes.length){var b;for(var Z=0,W=a.attributes.length;Z<W;++Z){b=c.getAttribute(a.attributes[Z][0],2);if(b===null||b===undefined){return false;}if(T.operators[a.attributes[Z][1]]&&!T.operators[a.attributes[Z][1]](b,a.attributes[Z][2])){return false;}}}if(a.pseudos.length){for(var Z=0,W=a.pseudos.length;Z<W;++Z){if(T.pseudos[a.pseudos[Z][0]]&&!T.pseudos[a.pseudos[Z][0]](c,a.pseudos[Z][1])){return false;}}}return(a.previous&&a.previous.combinator!==",")?O[a.previous.combinator](c,a):true;};var M=[];var K=[];var S={};var I=function(){for(var X=0,W=M.length;X<W;++X){try{delete M[X]._found;}catch(Y){M[X].removeAttribute("_found");}}M=[];};var B=function(){if(!document.documentElement.children){return function(){for(
|
||
|
W=A(W);do{a=false;for(var Z in D){if(!YAHOO.lang.hasOwnProperty(D,Z)){continue;}if(Z!="tag"&&Z!="combinator"){Y[Z]=Y[Z]||[];}if(X=D[Z].exec(W)){a=true;if(Z!="tag"&&Z!="combinator"){if(Z==="attributes"&&X[1]==="id"){Y.id=X[3];}Y[Z].push(X.slice(1));}else{Y[Z]=X[1];}W=W.replace(X[0],"");if(Z==="combinator"||!W.length){Y.attributes=J(Y.attributes);Y.pseudos=Y.pseudos||[];Y.tag=Y.tag?Y.tag.toUpperCase():"*";b.push(Y);Y={previous:Y};}}}}while(a);return b;};var J=function(X){var Y=T.attrAliases;X=X||[];for(var Z=0,W=X.length;Z<W;++Z){if(Y[X[Z][0]]){X[Z][0]=Y[X[Z][0]];}if(!X[Z][1]){X[Z][1]="";}}return X;};var A=function(X){var Y=T.shorthand;var Z=X.match(D.attributes);if(Z){X=X.replace(D.attributes,"REPLACED_ATTRIBUTE");}for(var b in Y){if(!YAHOO.lang.hasOwnProperty(Y,b)){continue;}X=X.replace(G(b,"gi"),Y[b]);}if(Z){for(var a=0,W=Z.length;a<W;++a){X=X.replace("REPLACED_ATTRIBUTE",Z[a]);}}return X;};T=new T();T.patterns=D;E.Selector=T;if(YAHOO.env.ua.ie){E.Selector.attrAliases["class"]="className";E.Selector.attrAliases["for"]="htmlFor";}})();YAHOO.register("selector",YAHOO.util.Selector,{version:"2.6.0",build:"1321"});
|