Created
September 23, 2011 03:22
-
-
Save felquis/1236674 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="pt-br" dir="ltr"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/hmtl; charset=uft8" /> | |
<title>javaScript</title> | |
<script type="text/javascript" src="http://localhost/peppy.js"></script> | |
<script type="text/javascript"> | |
window.onload = function(){ | |
$ = peppy.query; | |
var elem = $('label'); | |
for(var i = 0; i < elem.length; i++){ | |
elem[i].style.color = '#ccc'; | |
} | |
console.log(elem); | |
} | |
</script> | |
</head> | |
<body> | |
<label for="nome">Escreva seu nome</label> | |
<label for="nome">Escreva seu nome</label> | |
<label for="nome">Escreva seu nome</label> | |
<h2 id="cNome"></h2> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
url : http://jamesdonaghue.com/static/peppy/peppy-min.js | |
*/ | |
(function(){var O=document;var F=/(?!.*?opera.*?)msie(?!.*?opera.*?)/i.test(navigator.userAgent);var I=/webkit/i.test(navigator.userAgent);var A={};var J=!F&&!I;var G={};var N=0;var D={trim:/^\s+|\s+$/g,quickTest:/^[^:\[>+~ ,]+$/,typeSelector:/(^[^\[:]+?)(?:\[|\:|$)/,tag:/^(\w+|\*)/,id:/^(\w*|\*)#/,classRE:/^(\w*|\*)\./,attributeName:/(\w+)(?:[!+~*\^$|=])|\w+/,attributeValue:/(?:[!+~*\^$|=]=*)(.+)(?:\])/,pseudoName:/(\:[^\(]+)/,pseudoArgs:/(?:\()(.+)(?:\))/,nthParts:/([+-]?\d)*(n)([+-]\d+)*/i,combinatorTest:/[+>~ ](?![^\(]+\)|[^\[]+\])/,combinator:/\s*[>~]\s*(?![=])|\s*\+\s*(?![0-9)])|\s+/g,recursive:/:(not|has)\((\w+|\*)?([#.](\w|\d)+)*(\:(\w|-)+(\([^\)]+\))?|\[[^\}]+\])*(\s*,\s*(\w+|\*)?([#.](\w|\d)+)*(\:(\w|-)+(\([^\)]+\))?|\[[^\}]+\])*)*\)/gi};var E=function(Q){if(!!(window.attachEvent&&!window.opera)){return function(T){if(T instanceof Array){return T}for(var U=0,S=[],R;R=T[U++];){S[S.length]=R}return S}}else{return function(R){return Array.prototype.slice.call(R)}}}();function B(R,Q){var V=[],U={};if(Q){Q=new RegExp("^"+Q+"$","i")}for(var T=0,S;S=R[T++];){S.uid=S.uid||N++;if(!U[S.uid]&&(!Q||S.nodeName.search(Q)!==-1)){V[V.length]=U[S.uid]=S}}return V}function M(R,Q){if(!R){return null}if(Q==="class"||Q==="className"){return R.className}if(Q==="for"){return R.htmlFor}return R.getAttribute(Q)||R[Q]}function C(R,Y,W,V,U,Z,Q){var c=[];if(!!Q){return Y.test(W.className)?[W]:[]}if(W.getElementsByClassName){c=E(W.getElementsByClassName(R));if(!!V){if(Y.test(W.className)){c[c.length]=W}}if(Z!="*"){c=B(c,Z)}A[U]=c.slice(0);return c}else{if(O.getElementsByClassName){c=E(O.getElementsByClassName(R));if(Z!="*"){c=B(c,Z)}A[U]=c.slice(0);return c}}var X=(Z=="*"&&W.all)?W.all:W.getElementsByTagName(Z);if(!!V){X[X.length]=W}for(var S=0,T;T=X[S++];){if(Y.test(T.className)){c[c.length]=T}}return c}function P(R,X,W,V,Z,Q){var S,c=[];if(!!Q){return M(X,"id")===R?[X]:[]}if(X.getElementById){S=X.getElementById(R)}else{S=O.getElementById(R)}if(S&&M(S,"id")===R){c[c.length]=S;A[V]=c.slice(0);return c}var Y=X.getElementsByTagName(Z);if(!!W){Y[Y.length]=X}for(var T=0,U;U=Y[T++];){if(M(U,"id")===R){c[c.length]=U;break}}return c}function H(T,Z,X,Q){var R,d,c="",e=[],S=[],Y,U,V;D.id.lastIndex=D.typeSelector.lastIndex=D.classRE.lastIndex=0;if(!D.tag.test(T)){T="*"+T}R=D.typeSelector.exec(T)[1];Z=Z instanceof Array?Z.slice(0):[Z];V=Z.length;U=V-1;if(D.id.test(R)){c="id";d=(d=R.match(/^\w+/))?d[0]:"*";R=R.replace(D.id,"")}else{if(D.classRE.test(R)){c="class";d=(d=R.match(D.tag))?d[0]:"*";R=R.replace(D.tag,"");contextRE=G[R+"RegExp"]||(G[R+"RegExp"]=new RegExp("(?:^|\\s)"+R.replace(/\./g,"\\s*")+"(?:\\s|$)"));R=R.replace(/\./g," ")}}while(U>-1){Y=Z[U--];Y.uid=Y.uid||N++;var W=T+Y.uid;if(J&&A[W]){e=e.concat(A[W]);continue}if(c==="id"){S=P(R,Y,X,W,d,Q)}else{if(c==="class"){S=C(R,contextRE,Y,X,W,d,Q)}else{S=E(Y.getElementsByTagName(R));if(!!X&&(Y.nodeName.toUpperCase()===R.toUpperCase()||R==="*")){S[S.length]=Y}}}e=V>1?e.concat(S):S;A[W]=e.slice(0)}return e}peppy={query:function(p,k,S,f,d){var e=[];if(!f){p=p.replace(D.trim,"").replace(/(\[)\s+/g,"$1").replace(/\s+(\])/g,"$1").replace(/(\[[^\] ]+)\s+/g,"$1").replace(/\s+([^ \[]+\])/g,"$1").replace(/(\()\s+/g,"$1").replace(/(\+)([^0-9])/g,"$1 $2").replace(/['"]/g,"").replace(/\(\s*even\s*\)/gi,"(2n)").replace(/\(\s*odd\s*\)/gi,"(2n+1)")}if(typeof k==="string"){k=(k=H(k,O)).length>0?k:undefined}k=k||O;k.uid=k.uid||N++;var V=p+k.uid;if(J&&A[V]){return A[V]}D.quickTest.lastIndex=0;if(D.quickTest.test(p)){e=H(p,k,S,d);return(A[V]=e.slice(0))}var v,s,m,i=[],j;v=p.split(/\s*,\s*/g);s=v.length>1?[""]:v;for(var U=0,X=0,q=0,o;v.length>1&&(o=v[U++])!==undefined;){X+=(((l=o.match(/\(/g))?l.length:0)-((r=o.match(/\)/g))?r.length:0));s[q]=s[q]||"";s[q]+=(s[q]===""?o:","+o);if(X===0){q++}}var T=0;while((m=s[T++])!==undefined){D.quickTest.lastIndex=0;if(D.quickTest.test(m)){Y=H(m,k,S,d);e=s.length>1?e.concat(Y):Y;continue}D.combinatorTest.lastIndex=0;if(D.combinatorTest.test(m)){var i,u,W=0,Z,n,h=0,Y;i=m.split(D.combinator);u=i.length;Z=m.match(D.combinator)||[""];n=Z.length;while(W<u){var t,R,Q;t=Z[h++].replace(D.trim,"");R=Y||peppy.query(i[W++],k,S,true,d);Q=peppy.query(i[W++],t==""||t==">"?R:k,t==""||t==">",true,d);Y=peppy.queryCombinator(R,Q,t)}e=s.length>1?e.concat(Y):Y;Y=undefined}else{Y=peppy.querySelector(m,k,S,d);e=s.length>1?e.concat(Y):Y}}if(s.length>1){e=B(e)}return(A[V]=e.slice(0))},queryCombinator:function(T,R,X){var f=[],V={},W={},Y={},S={},U=peppy.simpleSelector.combinator[X];for(var d=0,Q;Q=T[d++];){Q.uid=Q.uid||N++;V[Q.uid]=Q}for(var Z=0,e;e=R[Z++];){e.uid=e.uid||N++;if(!W[e.uid]&&U(e,V,S,Y)){f[f.length]=e}W[e.uid]=e}return f},querySelector:function(s,q,X,j){var W,m=[],d,u,x,f=true,Z={};W=H(s,q,X,j);d=W.length;u=d-1;var Y,w;if(/:(not|has)/i.test(s)){w=s.match(D.recursive);s=s.replace(D.recursive,"")}if(!(Y=s.match(/:(\w|-)+(\([^\(]+\))*|\[[^\[]+\]/g))){Y=[]}if(w){Y=Y.concat(w)}var AA;while((AA=Y.pop())!==undefined){var R=G[AA],y,k,U,T=[],Q=false,AE=false;m=[];if(R){U=R[0];y=R[1];T=R.slice(2);k=y[U]}else{if(!/^:/.test(AA)){var p=AA.match(D.attributeName);var i=AA.match(D.attributeValue);T[1]=p[1]||p[0];T[2]=i?i[1]:"";U=""+AA.match(/[~!+*\^$|=]/);y=peppy.simpleSelector.attribute;k=y[U];G[AA]=[U,y].concat(T)}else{var V=AA.match(D.pseudoArgs);T[1]=V?V[1]:"";U=AA.match(D.pseudoName)[1];y=peppy.simpleSelector.pseudos;if(/nth-(?!.+only)/i.test(AA)){var AB,z,AD=T[1],g=G[AD];if(g){AB=g[0];z=g[1]}else{var h=AD.match(D.nthParts);if(h){AB=parseInt(h[1],10)||0;z=parseInt(h[3],10)||0;if(/^\+n|^n/i.test(AD)){AB=1}else{if(/^-n/i.test(AD)){AB=-1}}T[2]=AB;T[3]=z;G[AD]=[AB,z]}}}else{if(/^:contains/.test(AA)){var c=T[1];var AC=G[c];if(AC){T[1]=AC}else{T[1]=G[c]=new RegExp(c)}}}k=y[U];G[AA]=[U,y].concat(T)}}Q=/:(\w|-)+type/i.test(AA);AE=/^:(nth[^-]|eq|gt|lt|first|last)/i.test(AA);if(AE){T[3]=u}var t=W.length,o=t-1;while(o>-1){x=W[o--];if(f){x.peppyCount=o+1}var S=true;T[0]=x;if(AE){T[2]=x.peppyCount}if(!k.apply(y,T)){S=false}if(S){m.push(x)}}W=m;f=false}return m},simpleSelector:{attribute:{"null":function(S,Q,R){return !!M(S,Q)},"=":function(S,Q,R){return M(S,Q)==R},"~":function(S,Q,R){return M(S,Q).match(new RegExp("\\b"+R+"\\b"))},"^":function(S,Q,R){return M(S,Q).indexOf(R)===0},"$":function(T,R,S){var Q=M(T,R);return Q.lastIndexOf(S)===Q.length-S.length},"*":function(S,Q,R){return M(S,Q).indexOf(R)!=-1},"|":function(S,Q,R){return M(S,Q).match("^"+R+"-?(("+R+"-)*("+R+"$))*")},"!":function(S,Q,R){return M(S,Q)!==R}},pseudos:{":root":function(Q){return Q===O.getElementsByTagName("html")[0]?true:false},":nth-child":function(U,Q,W,V,Y){if(!U.nodeIndex){var R=U.parentNode.firstChild,T=0,X;for(;R;R=R.nextSibling){if(R.nodeType==1){X=R;R.nodeIndex=++T}}X.IsLastNode=true;if(T==1){X.IsOnlyChild=true}}var S=U.nodeIndex;if(Q=="first"){return S==1}if(Q=="last"){return !!U.IsLastNode}if(Q=="only"){return !!U.IsOnlyChild}return(!W&&!V&&S==Q)||((W==0?S==V:W>0?S>=V&&(S-V)%W==0:S<=V&&(S+V)%W==0))},":nth-last-child":function(Q,R){return this[":nth-child"](Q,R,a,b)},":nth-of-type":function(R,S,Q){return this[":nth-child"](R,S,a,b,Q)},":nth-last-of-type":function(R,S,Q){return this[":nth-child"](R,S,a,b,Q)},":first-child":function(Q){return this[":nth-child"](Q,"first")},":last-child":function(Q){return this[":nth-child"](Q,"last")},":first-of-type":function(R,S,Q){return this[":nth-child"](R,"first",null,null,Q)},":last-of-type":function(R,S,Q){return this[":nth-child"](R,"last",null,null,Q)},":only-child":function(Q){return this[":nth-child"](Q,"only")},":only-of-type":function(R,S,Q){return this[":nth-child"](R,"only",null,null,Q)},":empty":function(S){for(var R=S.firstChild,Q=0;R!==null;R=R.nextSibling){if(R.nodeType===1||R.nodeType===3){return false}}return true},":not":function(R,Q){return peppy.query(Q,R,true,true,true).length===0},":has":function(R,Q){return peppy.query(Q,R,true,true,true).length>0},":selected":function(Q){return Q.selected},":hidden":function(Q){return Q.type==="hidden"||Q.style.display==="none"},":visible":function(Q){return Q.type!=="hidden"&&Q.style.display!=="none"},":input":function(Q){return Q.nodeName.search(/input|select|textarea|button/i)!==-1},":radio":function(Q){return Q.type==="radio"},":checkbox":function(Q){return Q.type==="checkbox"},":text":function(Q){return Q.type==="text"},":header":function(Q){return Q.nodeName.search(/h\d/i)!==-1},":enabled":function(Q){return !Q.disabled&&Q.type!=="hidden"},":disabled":function(Q){return Q.disabled},":checked":function(Q){return Q.checked},":contains":function(R,Q){return Q.test((R.textContent||R.innerText||""))},":parent":function(Q){return !!Q.firstChild},":odd":function(Q){return this[":nth-child"](Q,"2n+2",2,2)},":even":function(Q){return this[":nth-child"](Q,"2n+1",2,1)},":nth":function(S,R,Q){return R==Q},":eq":function(S,R,Q){return R==Q},":gt":function(S,R,Q){return Q>R},":lt":function(S,R,Q){return Q<R},":first":function(S,R,Q){return Q==0},":last":function(T,S,R,Q){return R==Q}},combinator:{"":function(T,R,U,S){var Q=T.uid;while((T=T.parentNode)!==null&&!U[T.uid]){if(!!R[T.uid]||!!S[T.uid]){return(S[Q]=true)}}return(U[Q]=false)},">":function(S,Q,T,R){return S.parentNode&&Q[S.parentNode.uid]},"+":function(S,Q,T,R){while((S=S.previousSibling)!==null&&!T[S.uid]){if(S.nodeType===1){return S.uid in Q}}return false},"~":function(T,R,U,S){var Q=T.uid;while((T=T.previousSibling)!==null&&!U[T.uid]){if(!!R[T.uid]||!!S[T.uid]){return(S[Q]=true)}}return(U[Q]=false)}}}};if(O.querySelectorAll){(function(){var Q=peppy.query;peppy.query=function(S,R){R=R||O;if(R===O){try{return R.querySelectorAll(S)}catch(T){}}return Q.apply(Q,E(arguments))}})()}else{var L=O.addEventListener||O.attachEvent;function K(){A={}}L("DOMAttrModified",K,false);L("DOMNodeInserted",K,false);L("DOMNodeRemoved",K,false)}if(!($=window.$)){$=peppy.query}})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment