Example #1
0
!function(b,c){typeof a!="undefined"?a.exports=c():typeof define=="function"&&typeof define.amd=="object"?define(c):this[b]=c()}("qwery",function(){function B(){this.c={}}function G(a){return C.g(a)||C.s(a,new RegExp("(^|\\s+)"+a+"(\\s+|$)"))}function H(a,b){var c=0,d=a.length;for(;c<d;c++)b.call(null,a[c])}function I(a){for(var b=[],c=0,d=a.length;c<d;++c)U(a[c])?b=b.concat(a[c]):b[b.length]=a[c];return b}function J(a){var b=0,c=a.length,d=[];for(;b<c;b++)d[b]=a[b];return d}function K(a){while(a=a.previousSibling)if(a.nodeType==1)break;return a}function L(a){return a.match(y)}function M(a,b,c,d,e,f,g,j,k,l,m){var n,o,p,q,r;if(this.nodeType!==1)return!1;if(b&&b!=="*"&&this.tagName&&this.tagName.toLowerCase()!==b)return!1;if(c&&(o=c.match(h))&&o[1]!==this.id)return!1;if(c&&(r=c.match(i)))for(n=r.length;n--;)if(!G(r[n].slice(1)).test(this.className))return!1;if(k&&X.pseudos[k]&&!X.pseudos[k](this,m))return!1;if(d&&!g){q=this.attributes;for(p in q)if(Object.prototype.hasOwnProperty.call(q,p)&&(q[p].name||p)==e)return this}return d&&!O(f,$(this,e)||"",g)?!1:this}function N(a){return D.g(a)||D.s(a,a.replace(s,"\\$1"))}function O(a,b,c){switch(a){case"=":return b==c;case"^=":return b.match(E.g("^="+c)||E.s("^="+c,new RegExp("^"+N(c))));case"$=":return b.match(E.g("$="+c)||E.s("$="+c,new RegExp(N(c)+"$")));case"*=":return b.match(E.g(c)||E.s(c,new RegExp(N(c))));case"~=":return b.match(E.g("~="+c)||E.s("~="+c,new RegExp("(?:^|\\s+)"+N(c)+"(?:\\s+|$)")));case"|=":return b.match(E.g("|="+c)||E.s("|="+c,new RegExp("^"+N(c)+"(-|$)")))}return 0}function P(a,b){var c=[],d=[],e,g,h,i,k,l,m,n,o=b,p=F.g(a)||F.s(a,a.split(x)),q=a.match(w);if(!p.length)return c;i=(p=p.slice(0)).pop(),p.length&&(h=p[p.length-1].match(j))&&(o=W(b,h[1]));if(!o)return c;m=L(i),l=o!==b&&o.nodeType!==9&&q&&/^[+~]$/.test(q[q.length-1])?function(a){while(o=o.nextSibling)o.nodeType==1&&(m[1]?m[1]==o.tagName.toLowerCase():1)&&(a[a.length]=o);return a}([]):o[f](m[1]||"*");for(e=0,g=l.length;e<g;e++)if(n=M.apply(l[e],m))c[c.length]=n;return p.length?(H(c,function(a){R(a,p,q)&&(d[d.length]=a)}),d):c}function Q(a,b,c){if(S(b))return a==b;if(U(b))return!!~I(b).indexOf(a);var d=b.split(","),e,f;while(b=d.pop()){e=F.g(b)||F.s(b,b.split(x)),f=b.match(w),e=e.slice(0);if(M.apply(a,L(e.pop()))&&(!e.length||R(a,e,f,c)))return!0}return!1}function R(a,b,c,d){function f(a,d,g){while(g=A[c[d]](g,a))if(S(g)&&(found=M.apply(g,L(b[d])))){if(!d)return g;if(e=f(g,d-1,g))return e}}var e;return(e=f(a,b.length-1,a))&&(!d||Z(e,d))}function S(a,b){return a&&typeof a=="object"&&(b=a.nodeType)&&(b==1||b==9)}function T(a){var b=[],c,d;a:for(c=0;c<a.length;++c){for(d=0;d<b.length;++d)if(b[d]==a[c])continue a;b[b.length]=a[c]}return b}function U(a){return typeof a=="object"&&isFinite(a.length)}function V(a){return a?typeof a=="string"?X(a)[0]:!a.nodeType&&U(a)?a[0]:a:b}function W(a,b,c){return a.nodeType===9?a.getElementById(b):a.ownerDocument&&((c=a.ownerDocument.getElementById(b))&&Z(c,a)&&c||!Z(a,a.ownerDocument)&&bd('[id="'+b+'"]',a)[0])}function X(a,b){var c,d,g=V(b);if(!g||!a)return[];if(a===window||S(a))return!b||a!==window&&S(g)&&Z(a,g)?[a]:[];if(a&&U(a))return I(a);if(c=a.match(n)){if(c[1])return(d=W(g,c[1]))?[d]:[];if(c[2])return J(g[f](c[2]));if(_&&c[3])return J(g[e](c[3]))}return bd(a,g)}function Y(a,b){return function(c){var d,e;if(o.test(c)){a.nodeType!==9&&((e=d=a.getAttribute("id"))||a.setAttribute("id",e="__qwerymeupscotty"),c='[id="'+e+'"]'+c,b(a.parentNode||a,c,!0),d||a.removeAttribute("id"));return}c.length&&b(a,c,!1)}}var a=this,b=document,c=a.qwery,d=b.documentElement,e="getElementsByClassName",f="getElementsByTagName",g="querySelectorAll",h=/#([\w\-]+)/,i=/\.[\w\-]+/g,j=/^#([\w\-]+)$/,k=/^\.([\w\-]+)$/,l=/^([\w\-]+)$/,m=/^([\w]+)?\.([\w\-]+)$/,n=new RegExp(j.source+"|"+l.source+"|"+k.source),o=/(^|,)\s*[>~+]/,p=/^\s+|\s*([,\s\+\~>]|$)\s*/g,q=/[\s\>\+\~]/,r=/(?![\s\w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^'"]*\]|[\s\w\+\-]*\))/,s=/([.*+?\^=!:${}()|\[\]\/\\])/g,t=/^(\*|[a-z0-9]+)?(?:([\.\#]+[\w\-\.#]+)?)/,u=/\[([\w\-]+)(?:([\|\^\$\*\~]?\=)['"]?([ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+)["']?)?\]/,v=/:([\w\-]+)(\(['"]?([\s\w\+\-]+)['"]?\))?/,w=new RegExp("("+q.source+")"+r.source,"g"),x=new RegExp(q.source+r.source),y=new RegExp(t.source+"("+u.source+")?"+"("+v.source+")?"),z=/^(([\w\-]*[#\.]?[\w\-]+|\*)?(\[[\w\-]+([\~\|]?=['"][ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+["'])?\])?(\:(link|visited|active|hover))?([\s>+~\.,]|(?:$)))+$/,A={" ":function(a){return a&&a!==d&&a.parentNode},">":function(a,b){return a&&a.parentNode==b.parentNode&&a.parentNode},"~":function(a){return a&&a.previousSibling},"+":function(a,b,c,d){return a?(c=K(a))&&(d=K(b))&&c==d&&c:!1}};B.prototype={g:function(a){return this.c[a]||undefined},s:function(a,b){return this.c[a]=b}};var C=new B,D=new B,E=new B,F=new B,Z="compareDocumentPosition"in d?function(a,b){return(b.compareDocumentPosition(a)&16)==16}:"contains"in d?function(a,b){return b=b.nodeType===9||b==window?d:b,b!==a&&b.contains(a)}:function(a,b){while(a=a.parentNode)if(a===b)return 1;return 0},$=function(){var a=b.createElement("p");return(a.innerHTML='<a href="#x">x</a>')&&a.firstChild.getAttribute("href")!="#x"?function(a,b){return b==="class"?a.className:b==="href"||b==="src"?a.getAttribute(b,2):a.getAttribute(b)}:function(a,b){return a.getAttribute(b)}}(),_=function(){if(b[e]&&b.querySelector&&b[g])try{var a=b.createElement("p");return a.innerHTML="<a/>",a[g](":nth-of-type(1)").length}catch(c){}return!1}(),ba=function(a,b){var c=[],d,e;try{return b.nodeType===9||!o.test(a)?J(b[g](a)):(H(d=a.split(","),Y(b,function(a,b){e=a[g](b),e.length==1?c[c.length]=e.item(0):e.length&&(c=c.concat(J(e)))})),d.length>1&&c.length>1?T(c):c)}catch(f){}return bc(a,b)},bb=function(a,b){var c,d,e,f,h=[];return a=a.replace(p,"$1"),!o.test(a)&&z.test(a)?J(b[g](a)):(H(f=a.split(","),Y(b,function(a,f,i){d=z.test(f)?a[g](f):P(f,a);for(c=0,e=d.length;c<e;c++)if(a.nodeType===9||i||Z(d[c],b))h[h.length]=d[c]})),f.length>1&&h.length>1?T(h):h)},bc=function(a,b){var c=[],d,e,g,h,i,j;a=a.replace(p,"$1");if(e=a.match(m)){i=G(e[2]),d=b[f](e[1]||"*");for(g=0,h=d.length;g<h;g++)i.test(d[g].className)&&(c[c.length]=d[g]);return c}return H(j=a.split(","),Y(b,function(a,d,e){i=P(d,a);for(g=0,h=i.length;g<h;g++)if(a.nodeType===9||e||Z(i[g],b))c[c.length]=i[g]})),j.length>1&&c.length>1?T(c):c},bd=_?ba:b[g]?bb:bc;return X.uniq=T,X.is=Q,X.pseudos={},X.noConflict=function(){return a.qwery=c,this},X}),provide("qwery",a.exports),!function(a,b){var c=require("qwery");b.pseudos=c.pseudos,b._select=function(a,d){return(b._select=function(a){try{return a=require("bonzo"),function(b,d){return/^\s*</.test(b)?a.create(b,d):c(b,d)}}catch(b){}return c}())(a,d)},b.ender({find:function(a){var d=[],e,f,g,h,i;for(e=0,f=this.length;e<f;e++){i=c(a,this[e]);for(g=0,h=i.length;g<h;g++)d.push(i[g])}return b(c.uniq(d))},and:function(a){var c=b(a);for(var d=this.length,e=0,f=this.length+c.length;d<f;d++,e++)this[d]=c[e];return this},is:function(a,b){var d,e;for(d=0,e=this.length;d<e;d++)if(c.is(this[d],a,b))return!0;return!1}},!0)}(document,ender)}(),!function(){var a={exports:{}},b=a.exports;
Example #2
0
(function(t,n,r){typeof e!="undefined"&&e.exports?e.exports=r():typeof define=="function"&&define.amd?define(r):n[t]=r()})("qwery",this,function(){function L(){this.c={}}function D(e){return A.g(e)||A.s(e,"(^|\\s+)"+e+"(\\s+|$)",1)}function P(e,t){var n=0,r=e.length;for(;n<r;n++)t(e[n])}function H(e){for(var t=[],n=0,r=e.length;n<r;++n)$(e[n])?t=t.concat(e[n]):t[t.length]=e[n];return t}function B(e){var t=0,n=e.length,r=[];for(;t<n;t++)r[t]=e[t];return r}function j(e){while(e=e.previousSibling)if(e[u]==1)break;return e}function F(e){return e.match(C)}function I(e,t,n,r,i,s,a,c,h,p,d){var v,m,g,y,b;if(this[u]!==1)return!1;if(t&&t!=="*"&&this[o]&&this[o].toLowerCase()!==t)return!1;if(n&&(m=n.match(f))&&m[1]!==this.id)return!1;if(n&&(b=n.match(l)))for(v=b.length;v--;)if(!D(b[v].slice(1)).test(this.className))return!1;if(h&&Q.pseudos[h]&&!Q.pseudos[h](this,d))return!1;if(r&&!a){y=this.attributes;for(g in y)if(Object.prototype.hasOwnProperty.call(y,g)&&(y[g].name||g)==i)return this}return r&&!R(s,Z(this,i)||"",a)?!1:this}function q(e){return O.g(e)||O.s(e,e.replace(b,"\\$1"))}function R(e,t,n){switch(e){case"=":return t==n;case"^=":return t.match(M.g("^="+n)||M.s("^="+n,"^"+q(n),1));case"$=":return t.match(M.g("$="+n)||M.s("$="+n,q(n)+"$",1));case"*=":return t.match(M.g(n)||M.s(n,q(n),1));case"~=":return t.match(M.g("~="+n)||M.s("~="+n,"(?:^|\\s+)"+q(n)+"(?:\\s+|$)",1));case"|=":return t.match(M.g("|="+n)||M.s("|="+n,"^"+q(n)+"(-|$)",1))}return 0}function U(e,t){var n=[],i=[],s,a,f,l,h,p,d,v,m=t,g=_.g(e)||_.s(e,e.split(N)),y=e.match(T);if(!g.length)return n;l=(g=g.slice(0)).pop(),g.length&&(f=g[g.length-1].match(c))&&(m=K(t,f[1]));if(!m)return n;d=F(l),p=m!==t&&m[u]!==9&&y&&/^[+~]$/.test(y[y.length-1])?function(e){while(m=m.nextSibling)m[u]==1&&(d[1]?d[1]==m[o].toLowerCase():1)&&(e[e.length]=m);return e}([]):m[r](d[1]||"*");for(s=0,a=p.length;s<a;s++)if(v=I.apply(p[s],d))n[n.length]=v;return g.length?(P(n,function(e){W(e,g,y)&&(i[i.length]=e)}),i):n}function z(e,t,n){if(X(t))return e==t;if($(t))return!!~H(t).indexOf(e);var r=t.split(","),i,s;while(t=r.pop()){i=_.g(t)||_.s(t,t.split(N)),s=t.match(T),i=i.slice(0);if(I.apply(e,F(i.pop()))&&(!i.length||W(e,i,s,n)))return!0}return!1}function W(e,t,n,r){function s(e,r,o){while(o=k[n[r]](o,e))if(X(o)&&I.apply(o,F(t[r]))){if(!r)return o;if(i=s(o,r-1,o))return i}}var i;return(i=s(e,t.length-1,e))&&(!r||Y(i,r))}function X(e,t){return e&&typeof e=="object"&&(t=e[u])&&(t==1||t==9)}function V(e){var t=[],n,r;e:for(n=0;n<e.length;++n){for(r=0;r<t.length;++r)if(t[r]==e[n])continue e;t[t.length]=e[n]}return t}function $(e){return typeof e=="object"&&isFinite(e.length)}function J(t){return t?typeof t=="string"?Q(t)[0]:!t[u]&&$(t)?t[0]:t:e}function K(e,t,n){return e[u]===9?e.getElementById(t):e.ownerDocument&&((n=e.ownerDocument.getElementById(t))&&Y(n,e)&&n||!Y(e,e.ownerDocument)&&a('[id="'+t+'"]',e)[0])}function Q(e,t){var i,s,o=J(t);if(!o||!e)return[];if(e===window||X(e))return!t||e!==window&&X(o)&&Y(e,o)?[e]:[];if(e&&$(e))return H(e);if(i=e.match(x)){if(i[1])return(s=K(o,i[1]))?[s]:[];if(i[2])return B(o[r](i[2]));if(et&&i[3])return B(o[n](i[3]))}return a(e,o)}function G(e,t){return function(n){var r,i;if(v.test(n)){e[u]!==9&&((i=r=e.getAttribute("id"))||e.setAttribute("id",i="__qwerymeupscotty"),n='[id="'+i+'"]'+n,t(e.parentNode||e,n,!0),r||e.removeAttribute("id"));return}n.length&&t(e,n,!1)}}var e=document,t=e.documentElement,n="getElementsByClassName",r="getElementsByTagName",i="querySelectorAll",s="useNativeQSA",o="tagName",u="nodeType",a,f=/#([\w\-]+)/,l=/\.[\w\-]+/g,c=/^#([\w\-]+)$/,h=/^\.([\w\-]+)$/,p=/^([\w\-]+)$/,d=/^([\w]+)?\.([\w\-]+)$/,v=/(^|,)\s*[>~+]/,m=/^\s+|\s*([,\s\+\~>]|$)\s*/g,g=/[\s\>\+\~]/,y=/(?![\s\w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^'"]*\]|[\s\w\+\-]*\))/,b=/([.*+?\^=!:${}()|\[\]\/\\])/g,w=/^(\*|[a-z0-9]+)?(?:([\.\#]+[\w\-\.#]+)?)/,E=/\[([\w\-]+)(?:([\|\^\$\*\~]?\=)['"]?([ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+)["']?)?\]/,S=/:([\w\-]+)(\(['"]?([^()]+)['"]?\))?/,x=new RegExp(c.source+"|"+p.source+"|"+h.source),T=new RegExp("("+g.source+")"+y.source,"g"),N=new RegExp(g.source+y.source),C=new RegExp(w.source+"("+E.source+")?"+"("+S.source+")?"),k={" ":function(e){return e&&e!==t&&e.parentNode},">":function(e,t){return e&&e.parentNode==t.parentNode&&e.parentNode},"~":function(e){return e&&e.previousSibling},"+":function(e,t,n,r){return e?(n=j(e))&&(r=j(t))&&n==r&&n:!1}};L.prototype={g:function(e){return this.c[e]||undefined},s:function(e,t,n){return t=n?new RegExp(t):t,this.c[e]=t}};var A=new L,O=new L,M=new L,_=new L,Y="compareDocumentPosition"in t?function(e,t){return(t.compareDocumentPosition(e)&16)==16}:"contains"in t?function(e,n){return n=n[u]===9||n==window?t:n,n!==e&&n.contains(e)}:function(e,t){while(e=e.parentNode)if(e===t)return 1;return 0},Z=function(){var t=e.createElement("p");return(t.innerHTML='<a href="#x">x</a>')&&t.firstChild.getAttribute("href")!="#x"?function(e,t){return t==="class"?e.className:t==="href"||t==="src"?e.getAttribute(t,2):e.getAttribute(t)}:function(e,t){return e.getAttribute(t)}}(),et=!!e[n],tt=e.querySelector&&e[i],nt=function(e,t){var n=[],r,s;try{return t[u]===9||!v.test(e)?B(t[i](e)):(P(r=e.split(","),G(t,function(e,t){s=e[i](t),s.length==1?n[n.length]=s.item(0):s.length&&(n=n.concat(B(s)))})),r.length>1&&n.length>1?V(n):n)}catch(o){}return rt(e,t)},rt=function(e,t){var n=[],i,s,o,a,f,l;e=e.replace(m,"$1");if(s=e.match(d)){f=D(s[2]),i=t[r](s[1]||"*");for(o=0,a=i.length;o<a;o++)f.test(i[o].className)&&(n[n.length]=i[o]);return n}return P(l=e.split(","),G(t,function(e,r,i){f=U(r,e);for(o=0,a=f.length;o<a;o++)if(e[u]===9||i||Y(f[o],t))n[n.length]=f[o]})),l.length>1&&n.length>1?V(n):n},it=function(e){typeof e[s]!="undefined"&&(a=e[s]?tt?nt:rt:rt)};return it({useNativeQSA:!0}),Q.configure=it,Q.uniq=V,Q.is=z,Q.pseudos={},Q}),typeof provide=="function"&&provide("qwery",e.exports),function(e){var t=function(){var e;try{e=require("qwery")}catch(t){e=require("qwery-mobile")}finally{return e}}();e.pseudos=t.pseudos,e._select=function(n,r){return(e._select=function(){var n;if(typeof e.create=="function")return function(n,r){return/^\s*</.test(n)?e.create(n,r):t(n,r)};try{return n=require("bonzo"),function(e,r){return/^\s*</.test(e)?n.create(e,r):t(e,r)}}catch(r){}return t}())(n,r)},e.ender({find:function(n){var r=[],i,s,o,u,a;for(i=0,s=this.length;i<s;i++){a=t(n,this[i]);for(o=0,u=a.length;o<u;o++)r.push(a[o])}return e(t.uniq(r))},and:function(t){var n=e(t);for(var r=this.length,i=0,s=this.length+n.length;r<s;r++,i++)this[r]=n[i];return this.length+=n.length,this},is:function(e,n){var r,i;for(r=0,i=this.length;r<i;r++)if(t.is(this[r],e,n))return!0;return!1}},!0)}(ender)}(),function(){var e={exports:{}},t=e.exports;