-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrumbl.min.js
8 lines (8 loc) · 10.2 KB
/
crumbl.min.js
1
2
3
4
5
6
7
8
/*!
* @preserve Crumbl - A lightweight javascript framework
* Version 1.0.2
* http://crumbljs.com/
* copyright Glenn Naessens 2013
* MIT License
*/
!function(e,n,t){"use strict";function r(e,n){for(var t=0,r=e.length;r>t;t++)n(e[t])}function i(e){for(var n=[],t=0,r=e.length;r>t;++t)u(e[t])?n=n.concat(e[t]):n[n.length]=e[t];return n}function o(e){for(var n=0,t=e.length,r=[];t>n;n++)r[n]=e[n];return r}function s(e){for(;(e=e.previousSibling)&&1!=e[nodeType];);return e}function u(e){return"object"==typeof e&&isFinite(e.length)}function c(){var e;for(y=!0,e=0;e<v.length;e+=1)v[e]();v=[]}function a(){var e;for(b=!0,y||c(),e=0;e<w.length;e+=1)w[e]();w=[]}function f(e){return 1===e.length&&(e=e[0]),e}function h(e,t,i,o){r(o,function(r){n.addEventListener?i?r.removeEventListener(e,r[e],!1):r.addEventListener(e,t,!1):n.attachEvent&&(i?r.detachEvent("on"+e,r[e]):r.attachEvent("on"+e,t)),r[e]=i?null:t})}function l(e,n,t){var i,o,s,u,c,a,h,l=[];return e&&(i=e.split(/\s+/),o=i.length,r(t,function(t){if(s=t.className,"add"===n)t.className=s+" "+e;else{for(c=!0,a=0;o>a;a+=1)h=i[a],u=new RegExp("\\b"+h+"\\b","g"),"has"===n?s.match(u)||(c=!1):t.className="toggle"===n?t.className.match(u)?t.className.replace(u,""):t.className+" "+h:t.className.replace(u,"");"has"===n&&l.push(c)}t.className=t.className.replace(/^\s+|\s+$/g,"")}),l.length>0)?f(l):void 0}function d(e,n,t,i){var o=[];return r(i,function(r){e&&(e=e.toLowerCase(),t?r.removeAttribute(e):n?r.setAttribute(e,n):o.push(r.getAttribute(e)?r.getAttribute(e):null))}),o.length>0?f(o):void 0}function p(e,n,t){var i,o=[];n.nodes&&0!==n.nodes?o=n.nodes:n.nodeType&&1===n.nodeType&&o.push(n),i=o.length,"append"===e?r(t,function(e){for(var n=0;i>n;n++)e.appendChild(o[n])}):r(t,function(e){for(var n=0;i>n;n++)e.insertBefore(o[n],e.firstChild)})}function g(e,n){if(e){var t,r=[],i=n.length;switch(e){case"children":case"siblings":for(t=0;i>t;t++){var o="siblings"===e?n[t].parentNode.firstChild:n[t].firstChild,s=n[t];do o&&1===o.nodeType&&o!==s&&r.push(o),o=o.nextSibling;while(o)}break;case"parent":for(t=0;i>t;t++)r.push(n[t].parentNode);break;case"next":for(t=0;i>t;t++){var u=n[t];do u=u.nextSibling;while(u&&1!==u.nodeType);r.push(u)}break;case"previous":for(t=0;i>t;t++){var c=n[t];do c=c.previousSibling;while(c&&1!==c.nodeType);r.push(c)}}n=r}return n}function m(e,n){return new m.methods.init(e,n)}window.qwery=function(){function e(){this.c={}}function n(e){return V.g(e)||V.s(e,"(^|\\s+)"+e+"(\\s+|$)",1)}function c(e){return e.match(K)}function a(e,t,r,i,o,s,u,c,a,f,h){var d,p,g,m,v;if(1!==this[S])return!1;if(t&&"*"!==t&&this[L]&&this[L].toLowerCase()!==t)return!1;if(r&&(p=r.match(q))&&p[1]!==this.id)return!1;if(r&&(v=r.match(D)))for(d=v.length;d--;)if(!n(v[d].slice(1)).test(this.className))return!1;if(a&&y.pseudos[a]&&!y.pseudos[a](this,h))return!1;if(i&&!u){m=this.attributes;for(g in m)if(Object.prototype.hasOwnProperty.call(m,g)&&(m[g].name||g)==o)return this}return i&&!l(s,en(this,o)||"",u)?!1:this}function f(e,n){return e&&"object"==typeof e&&(n=e[S])&&(1==n||9==n)}function h(e){return W.g(e)||W.s(e,e.replace(z,"\\$1"))}function l(e,n,t){switch(e){case"=":return n==t;case"^=":return n.match(X.g("^="+t)||X.s("^="+t,"^"+h(t),1));case"$=":return n.match(X.g("$="+t)||X.s("$="+t,h(t)+"$",1));case"*=":return n.match(X.g(t)||X.s(t,h(t),1));case"~=":return n.match(X.g("~="+t)||X.s("~="+t,"(?:^|\\s+)"+h(t)+"(?:\\s+|$)",1));case"|=":return n.match(X.g("|="+t)||X.s("|="+t,"^"+h(t)+"(-|$)",1))}return 0}function d(e,n){var t,i,o,s,u,f,h,l=[],d=[],p=n,m=Y.g(e)||Y.s(e,e.split(J)),v=e.match(G);if(!m.length)return l;if(s=(m=m.slice(0)).pop(),m.length&&(o=m[m.length-1].match(R))&&(p=w(n,o[1])),!p)return l;for(f=c(s),u=p!==n&&9!==p[S]&&v&&/^[+~]$/.test(v[v.length-1])?function(e){for(;p=p.nextSibling;)1==p[S]&&(f[1]?f[1]==p[L].toLowerCase():1)&&(e[e.length]=p);return e}([]):p[A](f[1]||"*"),t=0,i=u.length;i>t;t++)(h=a.apply(u[t],f))&&(l[l.length]=h);return m.length?(r(l,function(e){g(e,m,v)&&(d[d.length]=e)}),d):l}function p(e,n,t){if(f(n))return e==n;if(u(n))return!!~i(n).indexOf(e);for(var r,o,s=n.split(",");n=s.pop();)if(r=Y.g(n)||Y.s(n,n.split(J)),o=n.match(G),r=r.slice(0),a.apply(e,c(r.pop()))&&(!r.length||g(e,r,o,t)))return!0;return!1}function g(e,n,t,r){function i(e,r,s){for(;s=U[t[r]](s,e);)if(f(s)&&a.apply(s,c(n[r]))){if(!r)return s;if(o=i(s,r-1,s))return o}}var o;return(o=i(e,n.length-1,e))&&(!r||Z(o,r))}function m(e){var n,t,r=[];e:for(n=0;n<e.length;++n){for(t=0;t<r.length;++t)if(r[t]==e[n])continue e;r[r.length]=e[n]}return r}function v(e){return e?"string"==typeof e?y(e)[0]:!e[S]&&u(e)?e[0]:e:E}function w(e,n,t){return 9===e[S]?e.getElementById(n):e.ownerDocument&&((t=e.ownerDocument.getElementById(n))&&Z(t,e)&&t||!Z(e,e.ownerDocument)&&N('[id="'+n+'"]',e)[0])}function y(e,n){var t,r,s=v(n);if(!s||!e)return[];if(e===window||f(e))return!n||e!==window&&f(s)&&Z(e,s)?[e]:[];if(e&&u(e))return i(e);if(t=e.match(F)){if(t[1])return(r=w(s,t[1]))?[r]:[];if(t[2])return o(s[A](t[2]));if(nn&&t[3])return o(s[C](t[3]))}return N(e,s)}function b(e,n){return function(t){var r,i;return O.test(t)?void(9!==e[S]&&((i=r=e.getAttribute("id"))||e.setAttribute("id",i="__qwerymeupscotty"),t='[id="'+i+'"]'+t,n(e.parentNode||e,t,!0),r||e.removeAttribute("id"))):void(t.length&&n(e,t,!1))}}var N,E=document,$=E.documentElement,C="getElementsByClassName",A="getElementsByTagName",T="querySelectorAll",x="useNativeQSA",L="tagName",S="nodeType",q=/#([\w\-]+)/,D=/\.[\w\-]+/g,R=/^#([\w\-]+)$/,B=/^\.([\w\-]+)$/,M=/^([\w\-]+)$/,H=/^([\w]+)?\.([\w\-]+)$/,O=/(^|,)\s*[>~+]/,j=/^\s+|\s*([,\s\+\~>]|$)\s*/g,k=/[\s\>\+\~]/,P=/(?![\s\w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^'"]*\]|[\s\w\+\-]*\))/,z=/([.*+?\^=!:${}()|\[\]\/\\])/g,I=/^(\*|[a-z0-9]+)?(?:([\.\#]+[\w\-\.#]+)?)/,Q=/\[([\w\-]+)(?:([\|\^\$\*\~]?\=)['"]?([ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+)["']?)?\]/,_=/:([\w\-]+)(\(['"]?([^()]+)['"]?\))?/,F=new RegExp(R.source+"|"+M.source+"|"+B.source),G=new RegExp("("+k.source+")"+P.source,"g"),J=new RegExp(k.source+P.source),K=new RegExp(I.source+"("+Q.source+")?("+_.source+")?"),U={" ":function(e){return e&&e!==$&&e.parentNode},">":function(e,n){return e&&e.parentNode==n.parentNode&&e.parentNode},"~":function(e){return e&&e.previousSibling},"+":function(e,n,t,r){return e?(t=s(e))&&(r=s(n))&&t==r&&t:!1}};e.prototype={g:function(e){return this.c[e]||t},s:function(e,n,t){return n=t?new RegExp(n):n,this.c[e]=n}};var V=new e,W=new e,X=new e,Y=new e,Z="compareDocumentPosition"in $?function(e,n){return 16==(16&n.compareDocumentPosition(e))}:"contains"in $?function(e,n){return n=9===n[S]||n==window?$:n,n!==e&&n.contains(e)}:function(e,n){for(;e=e.parentNode;)if(e===n)return 1;return 0},en=function(){var e=E.createElement("p");return(e.innerHTML='<a href="#x">x</a>')&&"#x"!=e.firstChild.getAttribute("href")?function(e,n){return"class"===n?e.className:"href"===n||"src"===n?e.getAttribute(n,2):e.getAttribute(n)}:function(e,n){return e.getAttribute(n)}}(),nn=!!E[C],tn=E.querySelector&&E[T],rn=function(e,n){var t,i,s=[];try{return 9!==n[S]&&O.test(e)?(r(t=e.split(","),b(n,function(e,n){i=e[T](n),1==i.length?s[s.length]=i.item(0):i.length&&(s=s.concat(o(i)))})),t.length>1&&s.length>1?m(s):s):o(n[T](e))}catch(u){}return on(e,n)},on=function(e,t){var i,o,s,u,c,a,f=[];if(e=e.replace(j,"$1"),o=e.match(H)){for(c=n(o[2]),i=t[A](o[1]||"*"),s=0,u=i.length;u>s;s++)c.test(i[s].className)&&(f[f.length]=i[s]);return f}return r(a=e.split(","),b(t,function(e,n,r){for(c=d(n,e),s=0,u=c.length;u>s;s++)(9===e[S]||r||Z(c[s],t))&&(f[f.length]=c[s])})),a.length>1&&f.length>1?m(f):f},sn=function(e){e[x]!==t&&(N=e[x]?tn?rn:on:on)};return sn({useNativeQSA:!0}),y.configure=sn,y.uniq=m,y.is=p,y.pseudos={},y}();var v=[],w=[],y=!1,b=!1;n.addEventListener?(n.addEventListener("DOMContentLoaded",c,!1),e.addEventListener("load",a,!1)):n.attachEvent?(n.attachEvent("onreadystatechange",c),e.attachEvent("onload",a)):e.onload=a,m.methods=m.prototype={init:function(t,r){var i,o=[],r=r||n,s=null,u=0,c=!1;if(t)if(t.nodeType&&1===t.nodeType)o=[t],u=1;else{if(t.constructor&&t.call&&t.apply)return v.push(t),u=!1,null;if(t===e)o=[e],u=1;else if(t instanceof Array)o=t,u=o.length;else if("string"==typeof t)if(t.match(/<\/*[a-z][^>]+?>/gi)){var a=document.createElement("div");a.innerHTML=t,o.push(a.firstChild),u=1}else{if(r===n)s=qwery(t),u=s.length,c=!0;else if("string"==typeof r)s=qwery(t),u=s.length,c=!0;else if(r.nodeType&&1===r.nodeType||r instanceof Array&&1===r.length)s=qwery(t,r[0]||r),u=s.length,c=!0;else if(r instanceof Array){var f,h=r.length,l=0;for(f=0;h>f;f++){for(s=qwery(t,r[f]),u=s.length,l+=u,i=0;u>i;i++)o.push(s[i]);u=l}}if(c)for(i=0;u>i;i++)o.push(s[i])}}return this.nodes=o,this.count=u,this},ready:function(e){e&&(y?e():v.push(e))},loaded:function(e){e&&(b?e():w.push(e))},each:function(e){return"function"==typeof e&&r(this.nodes,function(n){return e.apply(n,arguments)}),this},find:function(e){return new m.methods.init(e,this.nodes)},children:function(){return new m.methods.init(g("children",this.nodes))},siblings:function(){return new m.methods.init(g("siblings",this.nodes))},parent:function(){return new m.methods.init(g("parent",this.nodes))},next:function(){return new m.methods.init(g("next",this.nodes))},prev:function(){return new m.methods.init(g("previous",this.nodes))},only:function(){var e=this.nodes[0];return e?e:void 0},append:function(e){p("append",e,this.nodes)},prepend:function(e){p("prepend",e,this.nodes)},empty:function(){return r(this.nodes,function(e){for(;e.hasChildNodes();)e.removeChild(e.lastChild)}),this},remove:function(){return r(this.nodes,function(e){try{e.parentNode.removeChild(e)}catch(n){}}),this.nodes=[],this},clone:function(e){e=e===!0||e===t?!0:!1;var n=[];return r(this.nodes,function(t){(t.nodeType||1===t.nodeType)&&n.push(t.cloneNode(e))}),new m.methods.init(n)},hasClass:function(e){return l(e,"has",this.nodes)},addClass:function(e){return l(e,"add",this.nodes),this},removeClass:function(e){return l(e,"remove",this.nodes),this},toggleClass:function(e){return l(e,"toggle",this.nodes),this},html:function(e){var n=[];return r(this.nodes,function(t){e?t.innerHTML=e:n.push(t.innerHTML)}),n.length>0?f(n):this},attr:function(e,n){return e?n?(d(e,n,!1,this.nodes),this):d(e,!1,!1,this.nodes):void 0},removeAttr:function(e){return d(e,!1,!0,this.nodes),this},on:function(e,n){return h(e,n,!1,this.nodes),this},off:function(e){return h(e,null,!0,this.nodes),this}},m.methods.init.prototype=m.methods,e.$=m}(window,document);