-
Notifications
You must be signed in to change notification settings - Fork 0
/
jcss-min.js
1 lines (1 loc) · 9.2 KB
/
jcss-min.js
1
(function(){var a=function(k,e){if(typeof k=="string"){var A=[/\[(?!.*\])/g,/\((?!.*\))/g,/<|{|}|<.*?>|\(\s*\)/];for(var w=0,h;h=A[w++];){if(h.test(k)){throw"Syntax error. Invalid Query: "+k}}}if(typeof e=="string"){e=a(e)}else{e=e||document}if(e.nodeType&&e.nodeType!=1&&e.nodeType!=9){return[]}k=k.replace(/^\s*|\s*$/g,"");var z=function(j,C){if(j.indexOf){return j.indexOf(C)}else{for(var B=0,D;D=j[B++];){if(D===C){return B-1}}}return -1},n=function(j,i){return j.contains?j!==i&&j.contains(i):!!(j.compareDocumentPosition(i)&16)},g=function(){var j=function(F,D){for(var C=0,B=[],E;E=F[C++];){if(D.call(E)){B.push(E)}}return B};var i=function(C,B){return j(C,function(){return this.type===B})};return{":only-child":function(G){for(var D=0,C=[],B=[],F;F=G[D++];){for(var H=F.parentNode.firstChild,E=true;H;H=H.nextSibling){if(E=(H.nodeType==1&&H!==F)){break}}if(!E){C.push(F)}}return C},":last-child":function(F){for(var C=0,B=[],E;E=F[C++];){for(var G=E.nextSibling,D=G;G;G=G.nextSibling){if(D=(G.nodeType==1)){break}}if(!D){B.push(E)}}return B},":first-child":function(F){for(var C=0,B=[],E;E=F[C++];){for(var G=E.previousSibling,D=G;G;G=G.previousSibling){if(D=(G.nodeType==1)){break}}if(!D){B.push(E)}}return B},":nth-child":function(J,M){var D=function(T,R,O){var P=0,V=[],W=[],Q;while(Q=T[P]){for(var S=0,U=O.length;S<U;S++){if(Q===O[S]){W.push(Q);O.splice(0,S);break}}P+=R}return W};M=M.replace(/\s+/g,"").replace("odd","2n+1").replace("even","2n+2").replace(/^(\d+)n$/,"$1n+$1").replace(/^0n\+(\d+)$/,"$1").replace(/^(\d+)n\-(\1)$/,"$1n+$1").replace(/^(1)?n(\+0)?$/,"n");if(M=="n"){return J}var L=[],F={};for(var H=0,I,N,G;G=J[H++];){if((I=z(L,(N=G.parentNode)))==-1){I=L.push(N)-1}if(!F[I]){F[I]=[]}F[I].push(G)}var B=[],C=0,K=0;if(/(\d+)n(\+|-)(\d+)/.test(M)){C=parseInt(RegExp.$3);K=parseInt(RegExp.$1);if(RegExp.$2=="+"){C=C>0?C-1:K-1}else{if(RegExp.$2=="-"){C=K-C-1}}}if(K>0){for(H in F){for(var G=L[H].firstChild,E=[];G;G=G.nextSibling){if(G.nodeType==1){E.push(G)}}Array.prototype.push.apply(B,D(E.slice(C),K,F[H]))}return B}if(!isNaN(M)){M=parseInt(M)-1;for(H in F){if(F[H][M]){B.push(F[H][M])}}return B}return[]},":nth":function(C,B){return this[":eq"](C,B)},":first":function(B){return B.length?[B[0]]:[]},":last":function(B){return B.length?[B[B.length-1]]:[]},":even":function(E){for(var C=0,B=[],D;D=E[C];C+=2){B.push(D)}return B},":odd":function(E){for(var C=1,B=[],D;D=E[C];C+=2){B.push(D)}return B},":not":function(E,D){var F=D.split(/\s*,\s*/);for(var C=0,B;B=F[C++];){E=p(B.replace(/\.(.+)/,"[class~=$1]").replace(/#(.+)/,"[id=$1]")).not(E)}return E},":selected":function(C,B){return j(C,function(){this.parentNode.selectedIndex;return this.selected==true})},":checked":function(C,B){return j(C,function(){return this.checked===true})},":empty":function(C,B){return j(C,function(){return this.childNodes.length==0})},":disabled":function(C,B){return j(C,function(){return this.disabled==true})},":enabled":function(C,B){return j(C,function(){return this.disabled==false})},":visible":function(C,B){return j(C,function(){return(this.offsetWidth|this.offsetHeight)>0})},":hidden":function(C,B){return j(C,function(){return this.offsetWidth==0||this.offsetHeight==0})},":contains":function(C,B){return j(C,function(){return z((this.innerText||this.textContent||""),B)>-1})},":header":function(C,B){return j(C,function(){return/h[1-6]/i.test(this.nodeName)})},":eq":function(C,B){return !isNaN(B)&&C[B]?[C[B]]:[]},":gt":function(F,E){var B=[];if(!isNaN(E)&&F.length>E){for(var C=parseInt(E)+1,D;D=F[C++];){B.push(D)}}return B},":lt":function(F,E){var B=[];if(!isNaN(E)&&F.length>=E){for(var C=0,D;C<E&&(D=F[C++]);){B.push(D)}}return B},":has":function(C,B){return j(C,function(){return a(B,this).length>0})},":input":function(B){return j(B,function(){return/^input|button|textarea|select$/i.test(this.nodeName)})},":radio":function(B){return i(B,"radio")},":checkbox":function(B){return i(B,"checkbox")},":text":function(B){return i(B,"text")},":image":function(B){return i(B,"image")},":submit":function(B){return i(B,"submit")},":lang":function(C,B){return j(C,function(){return(this.getAttribute("lang")||this.lang)==B})},":root":function(){return[document.documentElement]}}}(),t=function(){var j=function(B){return{"class":"className","for":"htmlFor"}[B]||B},i=function(C,B){return C.getAttribute(B,2)||C[j(B)]||""};return{"=":function(B,C){return function(){return C?i(this,B)==C:!i(this,B)}},"*=":function(B,C){return function(){return z(i(this,B),C)>-1}},"!=":function(B,C){return function(){return C?i(this,B)!=C:!!i(this,B)}},"^=":function(B,C){return function(){return z(i(this,B),C)==0}},"$=":function(B,C){return function(){var D=i(this,B);return D.substr(D.length-C.length)==C}},"~=":function(B,C){return function(){return new RegExp("(^|\\s)"+C+"(\\s|$)").test(i(this,B))}},"|=":function(B,C){return function(){return new RegExp("(^|-)"+C+"(-|$)").test(i(this,B))}},"":function(B,C){return function(){return !!i(this,B)}}}}(),p=function(I){var H=/^(>|~|<|\+|)(\w+|\*)?(?:(#|\.)(.+))?(.*)/,F=/(?:\[\w+(?:(?:(?:!|\*|\^|\$|~|\||)=.*))?\])+$/,D=/(\:[-\w]+)(?:\((.*?)\))?$/,i=H.exec(I);I=(i[4]||"")+(i[5]||"");var G=i[1]||"",R=(i[2]||"*").toUpperCase(),N=i[3]=="#",K=null,O=i[3]==".",B=null,L=[],E=[];while(i=F.exec(I)){I=RegExp.leftContext||"";var C=/\[\s*(\w+)\s*(?:(!|\*|\^|\$|~|\||)(=)\s*(.*?\]?))?\s*\]/,P=i[0];while(i=C.exec(P)){P=RegExp.rightContext;if(i.length==5){var J=(i[2]||"")+(i[3]||"");if(J!==null&&(J=t[J])){L.push(J(i[1],i[4]||""))}}}}var Q=[];while(i=D.exec(I)){I=RegExp.leftContext||"";if(i.length==3){if(!g[i[1]]){Q.push(i[1])}else{E.push(i)}}}if(N){K=I.replace(/\\/g,"")+Q.join("")}if(O){B=I+Q.join("")}if(G==">"){L.push(function(S){return this.parentNode===S})}var M=function(U,T){var S=L.length;if(S>0){while(S--){if(!L[S].call(U,T)){return false}}}return true},j=function(V){var X,T=[];if(N){if(X=document.getElementById(K)){if(document.all&&X.attributes.id.value!=K){for(var U=0,Z=false,Y;Y=document.all[K][U++];){if(Z=(Y.attributes.id.value==K)){X=Y;break}}if(Z){return T}}if((R=="*"||R==X.nodeName)&&M(X,V)&&(V!==document&&V!==X?n(V,X):true)){T.push(X)}}}else{if(!G||G==">"){if(O&&!window.opera&&document.documentElement.getElementsByClassName){B=B.replace(/(\w+)\.(\w+)/g,"$1 $2");for(U=0,S=V.getElementsByClassName(B.replace(/\\/g,"")),Y;Y=S[U++];){if(R=="*"||Y.nodeName==R&&M(Y,V)){T.push(Y)}}}else{if(O){L.push(t["~="]("class",B))}var W=R==="*";for(var U=0,S=V.getElementsByTagName(R),Y;Y=S[U++];){if(W){if(O){if(Y.className&&M(Y,V)){T.push(Y)}}else{if(Y.nodeType==1&&M(Y,V)){T.push(Y)}}}else{if(M(Y,V)){T.push(Y)}}}}}}return T};return{name:R,relation:G,pseudo:function(U){if(E.length){E=E.reverse();Q=[];for(var T=0,S;S=E[T++];){Q.push(S)}for(T=0,S;S=Q[T++];){U=g[""+S[1]](U,""+(S[2]||null))}}return U},not:function(X){for(var V=0,U=[],W;W=X[V++];){if(R=="*"&&(!L.length||!M(W))){U.push(W)}else{if(R!="*"&&L.length&&W.nodeName==R&&!M(W)){U.push(W)}else{if(R!="*"&&!L.length&&W.nodeName!=R){U.push(W)}else{if(R!="*"&&W.nodeName!=R){U.push(W)}}}}}var T=this.pseudo(U);if(E.length){for(var V=0,S;W=T[V++];){if((S=z(U,W))>-1){U.splice(S,1)}}}return U},elements:function(T){var S=[];if(!G||G==">"){S=j(T)}else{if(G=="+"||G=="~"){for(var U=T.nextSibling;U;U=U.nextSibling){if(U.nodeType==1){if(U.nodeName==R&&M(U)){S.push(U)}if(G=="+"){break}}}}}return S}}},u=function(C){C=C.replace(new RegExp(">","g"),">").replace(/[\'\"]/g,"").replace(/((\[)\s*|\s*(\]))/g,"$2$3").replace(/\s*(=|\$|\^|!|\*=)\s*/g,"$1").replace(/table\s+tr\s+td/g,"td").replace(/tr\s+td/g,"td");var D=[];while(C!=(C=C.replace(/\([^\(\)]*\)/g,function(i){return"#__"+(D.push(i.replace(/\s*,\s*/g,","))-1)}))){}C=C.replace(/\s*,\s*/g,":::").replace(/\s+/g,"@@@").replace(/@*(>|~|\+)@*([^\d=])/g,"@@@$1$2");for(var B=D.length-1,j;j=D[B--];){C=C.replace(new RegExp("#__"+(B+1),"g"),j)}return C},f=function(D){for(var C=0,B=u(D).split(":::"),j=[];C<B.length;C++){if(z(j,B[C])==-1){j.push(B[C].replace(/^@+/,""))}}return j},d=false,c=function(j){if(d){for(var B=1;B<j.length;B++){if(j[B]===j[B-1]){j.splice(B--,1)}}d=false}return j},l=function(B,i){if(B===i){d=true;return 0}if(B.compareDocumentPosition){return B.compareDocumentPosition(i)&2?1:-1}if("sourceIndex" in B){return B.sourceIndex-i.sourceIndex}var D=B.ownerDocument,C=D.createRange(),j=D.createRange();C.selectNode(B);C.collapse(true);j.selectNode(i);j.collapse(true);return C.compareBoundaryPoints(Range.START_TO_END,j)},r=function(M){var Q=[],I=f(M);for(var H=0;M=I[H++];){var L,G=e&&e.length?e:[e];L=M.split("@@@");if(L.length==1&&L[0]=="body"){return[document.body]}if(L[1]&&L[0]=="body"){L.shift()}for(var F=0,D;D=L[F++];){var P=[],K=p(D),J;for(var E=0,O;O=G[E++];){Array.prototype.push.apply(P,K.elements(O))}if(P.length>1&&L.length>1&&F<L.length){if(L[F]){if(!(J=p(L[F])).relation){for(E=1;E<P.length;E++){if(n(P[E-1],P[E])){P.splice(E--,1)}}}else{if(J.relation=="~"){var C,B=[],N=[];for(H=0;C=P[H++];){if(z(N,(O=C.parentNode))==-1){N.push(O);B.push(C)}}P=B}}}}G=K.pseudo(P.slice())}Array.prototype.push.apply(Q,G)}if(I.length>1||e.length>1){Q.sort(l);Q=c(Q)}return Q};var o=[];if(document.querySelectorAll&&!/\bparam\b/.test(k)){try{var m=e.length?e:[e];for(var v=0,b;b=m[v++];){var q=b.querySelectorAll(k);try{q=Array.prototype.slice.call(q);Array.prototype.push.apply(o,q)}catch(y){for(var w=0,x=q.length;w<x;){o.push(q[w++])}}}if(m.length>1){o.sort(l);o=c(o)}}catch(s){o=r(k)}}else{o=r(k)}return o};window.jCSS=a})();