/*! kimbo v1.1.0 | http://kimbojs.com | https://github.com/dciccale/kimbo.js/blob/master/LICENSE.txt */
!function(e,t){"use strict";function n(e,i){var r,a,s;return this instanceof n?e?"string"==typeof e?(r=/^#([\w\-]+)$/.exec(e),r&&r[1]?(r=t.getElementById(r[1]),r&&(this[0]=r,this.length=1),this):"<"===e.charAt(0)?(a=t.createElement("div"),a.innerHTML=e,this.add(a.childNodes),s=new n(t.createDocumentFragment()),s.append(this),this):(i=i?o.kimbo(i):o.rootContext,i.find(e))):e.nodeType?(this[0]=e,this.length=1,this):n.isFunction(e)?o.rootContext.ready(e):n.makeArray(e,this):this:new n(e,i)}var i={},o={push:Array.prototype.push,slice:Array.prototype.slice,rootContext:t,kimbo:function(e,t){return new n(e,t)}};n.require=function(e){return i[e]},n.define=function(e,t){i[e]=t(o)},n.fn=n.prototype={constructor:n,length:0,ready:function(e){function n(){t.removeEventListener("DOMContentLoaded",n,!1),e.call(t)}return/t/.test(t.readyState)?e.call(t):t.addEventListener("DOMContentLoaded",n,!1),o.rootContext},get:function(e){return this.length?arguments.length?0>e?this[this.length+e]:this[e]:o.slice.call(this):void 0},splice:Array.prototype.splice},n.forEach=function(t,i){var o,r=t.length,a=Array.isArray(t)||t instanceof n||t instanceof e.NodeList||!(void 0!==r||!r);if(a)for(o=0;r>o&&i.call(t[o],t[o],o,t)!==!1;o++);else for(o in t)if(t.hasOwnProperty(o)&&i.call(t[o],o,t[o],t)===!1)break;return t},n.extend=n.fn.extend=function(){var e=arguments,t=e[0]||{},i=t===!0,r=1;return i?(t=e[1]||{},r=2):1===e.length&&(t=this,r=0),e=o.slice.call(e,r),n.forEach(e,function(e){n.forEach(e,function(e,o){var r;i&&(n.isObject(o)||n.isArray(o))?(r=t[e],t[e]=n.extend(i,r,o)):void 0!==o&&(t[e]=o)})}),t},n.ref="kimbo"+("1"+Math.random()).replace(/\D/g,""),"function"==typeof e.define&&e.define.amd&&e.define("kimbo",[],function(){return n}),e.Kimbo=e.$=n}(window,window.document),Kimbo.define("query",function(e){"use strict";var t=/^#([\w\-]+)$/,n=/^\.([\w\-]+)$/,i=/^[\w\-]+$/,o=/^\[name=["']?([\w\-]+)["']?\]$/,r=function(r,a){var s,c=[];return c=r===document&&(s=t.exec(a))?[r.getElementById(s[1])]:(s=n.exec(a))?r.getElementsByClassName(s[1]):i.test(a)?r.getElementsByTagName(a):(s=o.exec(a))?r.getElementsByName(s[1]):r.querySelectorAll(a),e.slice.call(c)},a=function(e,t){return e===window&&t&&(t===window||t.nodeType)||e&&e.nodeType&&t&&t.nodeType?e.contains?e.contains(t):!0:!1};return{find:r,contains:a}}),Kimbo.define("data",function(){"use strict";var e={},t=1,n={get:function(t,n){var i,o=e[t._dataId];return o?i=o[n]:(i=t.dataset[n],i&&this.set(t,n,i)),i},set:function(n,i,o){var r=n._dataId||(n._dataId=t++),a=e[r];a||(a=e[r]={}),a[i]=o},remove:function(t,n){var i=e[t._dataId];if(i){if(n)return n=Kimbo.camelCase(n),void delete e[t._dataId][n];delete e[t._dataId]}}};return Kimbo.fn.extend({data:function(e,t){return this.length&&Kimbo.isString(e)?(e=Kimbo.camelCase(e),void 0===t?n.get(this[0],e):this.each(function(i){n.set(i,e,t)})):this},removeData:function(e){return this.length?this.each(function(t){n.remove(t,e)}):this}}),n}),Kimbo.define("css",function(){"use strict";function e(e,t){return t=t.replace(/([A-Z])/g,"-$1").toLowerCase(),window.getComputedStyle(e,null).getPropertyValue(t)}function t(){return o=document.createElement("iframe"),document.documentElement.appendChild(o),o}function n(t,n){n=n||document;var i,o;return i=n.createElement(t),n.body.appendChild(i),o=e(i,"display"),i.parentNode.removeChild(i),o}var i={fontWeight:!0,lineHeight:!0,opacity:!0,zIndex:!0},o=null,r={};Kimbo.fn.extend({show:function(){return this.each(function(e){var i,a=e.nodeName,s=r[a];s||(s=n(a),"none"!==s&&s||(o=o||t(),i=(o.contentWindow||o.contentDocument).document,i.write("
"),i.close(),s=n(a,i),o.parentNode.removeChild(o)),r[a]=s),e.style.display=s||"block"})},hide:function(){return this.each(function(t){var n=t.nodeName,i=r[n];i?i=t.style.display:(i=e(t,"display"),r[n]=i),"none"!==i&&(t.style.display="none")})},css:function(t,n){function o(e,t){Kimbo.isNumeric(t)&&!i[Kimbo.camelCase(e)]&&(t+="px"),r.each(function(n){n.style[e]=t})}var r=this;if(!this.length||!Kimbo.isString(t)&&!Kimbo.isObject(t))return this;if(Kimbo.isString(t)){if(void 0===n)return e(this[0],t);o(t,n)}else Kimbo.isObject(t)&&Kimbo.forEach(t,o);return this}})}),Kimbo.define("manipulation",function(e){"use strict";function t(e,t){return 1===e.nodeType&&e.classList.contains(t)}var n=/\s+/,i={};Kimbo.forEach(["multiple","selected","checked","async","autofocus","autoplay","controls","defer","disabled","hidden","readOnly","required","open","required"],function(e){i[e.toLowerCase()]=e}),Kimbo.forEach({text:"textContent",html:"innerHTML",val:"value"},function(e,t){Kimbo.fn[e]=function(e){return this.length?void 0===e?this[0][t]:this.each(function(n){n[t]=e}):void 0}}),Kimbo.forEach(["add","remove"],function(e){var t="remove"===e;Kimbo.fn[e+"Class"]=function(i){var o;return i&&Kimbo.isString(i)?(o=i.split(n),this.each(function(t){1===t.nodeType&&Kimbo.forEach(o,function(n){t.classList[e](n)})})):!i&&t&&this.removeAttr("class"),this}}),Kimbo.forEach(["append","prepend"],function(t){var n="prepend"===t;Kimbo.fn[t]=function(t){var i;return this.length&&t?(Kimbo.isString(t)&&(i=document.createElement("div"),i.innerHTML=t.trim(),t=i.firstChild),t.nodeType||t instanceof Kimbo?this.each(function(i){(1===i.nodeType||11===i.nodeType)&&e.kimbo(t).each(function(e){i.insertBefore(e,n?i.firstChild:null)})}):void 0):this}}),Kimbo.fn.extend({empty:function(){return this.each(function(e){for(;e.hasChildNodes();)e.removeChild(e.childNodes[0])})},remove:function(){return this.each(function(e){e.parentNode&&e.parentNode.removeChild(e)})},attr:function(e,t){var n=e.toLowerCase(),o=this[0];return this.length?Kimbo.isString(e)&&void 0===t?i[n]?o[e]||(o.attributes.getNamedItem(e)||{}).specified?n:void 0:o.getAttribute(e):this.each(function(o){i[n]?t?(o[e]=!0,o.setAttribute(e,n)):(o[e]=!1,o.removeAttribute(e)):o.setAttribute(e,t)}):this},removeAttr:function(e){return this.each(function(t){t.removeAttribute(e)})},toggleClass:function(i,o){var r;return this.length&&i&&Kimbo.isString(i)&&(r=i.split(n),this.each(function(n){Kimbo.forEach(r,function(i){o=Kimbo.isBoolean(o)?o:!t(n,i),e.kimbo(n)[o?"addClass":"removeClass"](i)})})),this},hasClass:function(e){var i,o=!1;return this.length&&e&&Kimbo.isString(e)&&(i=e.trim().split(n),this.each(function(e){Kimbo.forEach(i,function(n){return o=t(e,n),o?void 0:!1})})),o},clone:function(){return this.each(function(e){return e.cloneNode(!0)})}})}),Kimbo.define("traversing",function(e){"use strict";function t(e,t){return e&&1===e.nodeType?c.call(e,t):!1}function n(e){return e.filter(function(t,n){return e.indexOf(t)===n})}function i(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}function o(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}var r=Kimbo.require("query"),a=Array.prototype.filter,s={children:!0,contents:!0,next:!0,prev:!0},c=document.documentElement.matchesSelector||document.documentElement.webkitMatchesSelector||document.documentElement.mozMatchesSelector||document.documentElement.oMatchesSelector;Kimbo.fn.extend({filter:function(n){var i=a.call(this,function(e,i){var o;return Kimbo.isFunction(n)?o=!!n.call(e,e,i):Kimbo.isString(n)?o=t(e,n):n.nodeType?o=e===n:n instanceof Kimbo&&(o=e===n[0]),o});return e.kimbo(i)},eq:function(e){return this.length&&-1===e?this.slice(e):this.slice(e,e+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.length&&e.kimbo(e.slice.apply(this,arguments))},each:function(e){return Kimbo.forEach(this,e)},map:function(t){return e.kimbo(Kimbo.map(this,function(e,n){return t.call(e,e,n)}))},find:function(t){var n,i,o,a,s,c=e.kimbo(),u=this.length;for(n=0;u>n;n++)if(i=c.length,s=r.find(this[n],t),e.push.apply(c,s),n)for(o=i;oa;a++)if(c[a]===c[o]){c.splice(o--,1);break}return c},closest:function(i,o){function r(e){for(;e&&!t(e,i);)e=e!==o&&e!==document&&e.parentNode;return e}var a=this.length,s=[];return a?(1===a?s=r(this[0]):(Kimbo.forEach(this,function(e){e=r(e),e&&s.push(e)}),s=s.length>1?n(s):s),e.kimbo(s)):this},contains:function(e){return Kimbo.isString(e)?e=this.find(e)[0]:e instanceof Kimbo&&(e=e[0]),r.contains(this[0],e)},add:function(t,n){var i,o;return t?(i=Kimbo.isString(t)?e.kimbo(t,n):t.nodeType?[t]:t,o=Kimbo.merge(this,i),e.kimbo(o)):this},is:function(e){return!(!this.length||!this.filter(e).length)}}),Kimbo.forEach({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},next:function(e){return o(e,"nextSibling")},prev:function(e){return o(e,"previousSibling")},siblings:function(e){return i((e.parentNode||{}).firstChild,e)},children:function(e){return i(e.firstChild)},contents:function(e){return"iframe"===e.nodeName.toLowerCase()?e.contentDocument||e.contentWindow[document]:Kimbo.makeArray(e.childNodes)}},function(t,i){Kimbo.fn[t]=function(o){var r,a=this.length;return a?(r=Kimbo.map(this,i),r=a>1&&!s[t]?n(r):r,Kimbo.isString(o)&&(r=e.kimbo(r).filter(o)),e.kimbo(r)):this}})}),Kimbo.define("utilities",function(e){"use strict";var t="(Android)\\s+([\\d.]+)",n="(BlackBerry|BB10|Playbook).*Version/([\\d.]+)",i="(Mozilla).*Mobile[^/]*/([\\d.]*)",o="(iPad).*OS\\s([\\d_]+)",r="(iPhone\\sOS)\\s([\\d_]+)",a="(web|hpw)OS[\\s/]([\\d.]+)",s=new RegExp(t+"|"+n+"|"+i+"|"+r+"|"+o+"|"+a),c=null,u={},l=Object.prototype.toString;Kimbo.forEach(["Array","Boolean","Date","Error","Function","Number","Object","RegExp","String"],function(e){u["[object "+e+"]"]=e.toLowerCase()}),Kimbo.extend({typeOf:function(e){var t;return t=null===e||void 0===e?String(e):u[l.call(e)],t||"object"},isArray:Array.isArray,isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},isWindow:function(e){return e&&e===e.window},isEmptyObject:function(e){var t;for(t in e)if(e.hasOwnProperty(t))return!1;return!0},isMobile:function(){return null===c&&(c=s.test(navigator.userAgent)),c},parseJSON:function(e){return e&&Kimbo.isString(e)?window.JSON.parse(e):void 0},parseXML:function(e){var t,n;if(e&&Kimbo.isString(e)){if(t=new window.DOMParser,n=t.parseFromString(e,"text/xml"),n.getElementsByTagName("parsererror").length)throw new Error("Invalid XML: "+e);return n}},map:function(e,t){var n=[];return e&&Kimbo.forEach(e,function(e,i){var o=t(e,i);null!==o&&void 0!==o&&n.push(o)}),n.concat.apply([],n)},makeArray:function(t,n){return n=n||[],t&&(Kimbo.isArray(t)||t instanceof Kimbo||t instanceof window.NodeList?n=Kimbo.merge(n,t):e.push.call(n,t)),n},merge:function(t,n){return Kimbo.isArray(t)?t=t.concat(n):e.push.apply(t,e.slice.call(n)),t},camelCase:function(e){return e.replace(/-+(.)?/g,function(e,t){return t.toUpperCase()})},isFunction:function(e){return"function"===Kimbo.typeOf(e)},isObject:function(e){return"object"===Kimbo.typeOf(e)},isString:function(e){return"string"===Kimbo.typeOf(e)},isBoolean:function(e){return"boolean"===Kimbo.typeOf(e)}}),e.rootContext=e.kimbo(e.rootContext)}),Kimbo.define("events",function(e){"use strict";function t(e){var t,n,i;return e[Kimbo.ref]?e:(t=e,n=v[e.type]||[],i=h.concat(n),e=new Kimbo.Event(t),Kimbo.forEach(i,function(n){e[n]=t[n]}),e)}function n(e){return e._guid||(e._guid=d++)}function i(e,t){var n=(y[e]||{}).events||{};return(t?n[t]:n)||[]}function o(e,t,i,o,r){var a,c,u,l,d,f,m;(!e||3!==e.nodeType&&8!==e.nodeType)&&Kimbo.isString(t)&&(a=n(e),c=y[a],u=t,t=K[t]?K[t].origType:t,c||(y[a]=c={}),l=c.events,l||(c.events=l={}),m=c.handler,m||(c.handler=m=function(){return s.apply(e,arguments)}),f={type:t,origType:u,data:o,callback:i,selector:r},d=l[t],d||(d=l[t]=[],d.delegateCount=0,e.addEventListener&&e.addEventListener(t,m,!1)),r?d.splice(d.delegateCount++,0,f):d.push(f))}function r(e,t,o,a){var s,c,u,l,d=n(e);if(c=i(d,t),!t||c.length)if(t){for(l=0;ld;d++)u=m[d],l=u.selector,s[l]||(s[l]=e.kimbo(r).is(l)),s[l]&&c.push(u);c.length&&b.push({element:r,matches:c})}m.length>h&&b.push({element:this,matches:m.slice(h)}),Kimbo.forEach(b,function(e){o.isPropagationStopped()||(o.currentTarget=e.element,Kimbo.forEach(e.matches,function(t){o.isImmediatePropagationStopped()||(o.data=t.data,o.handleObj=t,a=((K[t.origType]||{}).handle||t.callback).apply(e.element,p),a===!1&&(o.preventDefault(),o.stopPropagation()))}))})}function c(){return!1}function u(){return!0}var l=Kimbo.require("query"),d=1,f=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,m=/^key/,h=["altKey","bubbles","cancelable","ctrlKey","currentTarget","eventPhase","metaKey","relatedTarget","shiftKey","target","timeStamp","view","which"],p=["button","buttons","clientX","clientY","fromElement","offsetX","offsetY","screenX","screenY","toElement"],b=["char","charCode","key","keyCode"],g=Kimbo.isMobile()?{}:{touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",touch:"click",doubletap:"dblclick",orientationchange:"resize"},y={},v={},K={};Kimbo.Event=function(e){e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented?u:c):this.type=e,this.timeStamp=e&&e.timeStamp||Date.now(),this[Kimbo.ref]=!0},Kimbo.Event.prototype={isDefaultPrevented:c,isPropagationStopped:c,isImmediatePropagationStopped:c,preventDefault:function(){this.isDefaultPrevented=u,this.isTrigger||this.originalEvent.preventDefault()},stopPropagation:function(){this.isPropagationStopped=u,this.isTrigger||this.originalEvent.stopPropagation()},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=u,this.isTrigger||this.originalEvent.stopImmediatePropagation()}},Kimbo.fn.extend({on:function(e,t,n,i){return n||i?i||(Kimbo.isString(t)?(i=n,n=void 0):(i=n,n=t,t=void 0)):(i=t,n=t=void 0),i?(e=g[e]||e,this.each(function(r){o(r,e,i,n,t)})):this},off:function(e,t,n){return Kimbo.isFunction(t)&&(n=t,t=void 0),this.each(function(i){r(i,e,n,t)})},trigger:function(e,t){return this.each(function(n){a(n,e,t)})}}),Kimbo.forEach(["blur","change","click","contextmenu","dblclick","error","focus","keydown","keypress","keyup","load","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseup","mouseover","resize","scroll","select","submit","unload"],function(e){Kimbo.fn[e]=function(t,n){return arguments.length>0?this.on(e,null,t,n):this.trigger(e)},v[e]=m.test(e)?b:f.test(e)?p:null}),Kimbo.forEach({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){K[e]={origType:t,handle:function(e){var n,i=this,o=e.relatedTarget,r=e.handleObj;return(!o||o!==i&&!l.contains(i,o))&&(e.type=r.origType,n=r.callback.apply(this,arguments),e.type=t),n}}})}),Kimbo.define("ajax",function(){"use strict";function e(e,t){return u[t]?u[t](e):e}function t(t,i){var o,r;i.dataType||(r=t.getResponseHeader("Content-Type"),Kimbo.forEach(c,function(e,t){return t.match(r)?(i.dataType=e,!1):void 0}),n(i));try{o=e(t.responseText,i.dataType)}catch(a){o=!1,l.error("parseerror",a,t,i)}return o}function n(e){e.crossDomain||e.headers["X-Requested-With"]||(e.headers["X-Requested-With"]="XMLHttpRequest"),e.contentType&&(e.headers["Content-Type"]=e.contentType),e.headers.Accept=c[e.dataType]||"*/*"}function i(e,t){e.onreadystatechange=null,e.abort(),l.error("error","timeout",e,t)}function o(e,t){return window.setTimeout(function(){i(e,t)},t.timeout)}function r(e){var t,i=Kimbo.ref+"_"+Date.now(),r=document.createElement("script"),a=document.head,c={abort:function(){window.clearTimeout(t),a.removeChild(r),delete window[i]}};return e.timeout>0&&(t=o(c,e)),r.src=e.url.replace(s,"$1"+i),window[i]=function(t){c.abort(),Kimbo.extend(c,{statusText:"OK",status:200,response:t,headers:e.headers}),l.success(t,c,e)},n(e),a.appendChild(r),c}var a=/^(?:GET|HEAD)$/,s=/(\=)\?(?=&|$)|\?\?/i,c={html:"text/html",json:"application/json",script:"text/javascript, application/javascript",text:"text/plain",xml:"application/xml, text/xml"},u={json:Kimbo.parseJSON,xml:Kimbo.parseXML},l={};Kimbo.forEach(["success","error"],function(e){l[e]=function(t,n,i,o){o=o||i,Kimbo.isFunction(o[e])&&o[e].apply(o.context,arguments)}}),Kimbo.ajaxSettings={type:"GET",async:!0,success:null,error:null,context:null,headers:{},data:null,crossDomain:!1,timeout:0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",xhr:function(){return new window.XMLHttpRequest}},Kimbo.ajax=function(e){var i,c,u,d=Kimbo.extend({},Kimbo.ajaxSettings,e),f=!a.test(d.type);return d.data&&"string"!=typeof d.data&&(d.data=Kimbo.param(d.data)),d.data&&!f&&(d.url+=(/\?/.test(d.url)?"&":"?")+d.data,delete d.data),d.context||(d.context=d),s.test(d.url)?r(d):(i=d.xhr(),d.timeout>0&&(c=o(i,d)),d.type=d.type.toUpperCase(),u=function(){var e,n=i.status;window.clearTimeout(c),n>=200&&300>n||304===n?(e=t(i,d),e!==!1&&l.success(e,i,d)):l.error("error",i.statusText,i,d)},i.onload=u,i.open(d.type,d.url,d.async),n(d),Kimbo.forEach(d.headers,function(e,t){i.setRequestHeader(e,t)}),i.send(d.data),i)},Kimbo.forEach(["get","post"],function(e){Kimbo[e]=function(t,n,i,o){return Kimbo.isFunction(n)&&(o=o||i,i=n,n=null),Kimbo.ajax({type:e.toUpperCase(),url:t,data:n,success:i,dataType:o})}}),Kimbo.extend({getScript:function(e,t){return Kimbo.get(e,t,"script")},getJSON:function(e,t,n){return Kimbo.get(e,t,n,"json")}}),Kimbo.param=function(e){var t="";return Kimbo.isObject(e)?Kimbo.forEach(e,function(e,n){t+=e+"="+n+"&"}):t=e,window.encodeURIComponent(t).replace(/%20/g,"+").replace(/%\d[D6F]/g,window.unescape).replace(/^\?|&$/g,"")}});
//# sourceMappingURL=../dist/kimbo.min.js.map