/* * Sprint JavaScript Library v0.9.3 * * Copyright (c) 2014, 2015 Benjamin De Cock * Released under the MIT license */ (function(){"use strict";var t,e,n,i,r=function(t,e){for(var n=B(e),i=Object.keys(t),r=i.length,o=0;o1)){(f=a(t))&&r(f,e);for(var n,i=L("*",t),o=i.length,s=0;s1&&9!=i.nodeType)return;var r=e[0].toUpperCase()+e.substring(1);return i==document?Math.max(i.body["scroll"+r]||0,i.body["offset"+r]||0,w["scroll"+r]||0,w["offset"+r]||0):i==window?window["inner"+r]:i.getBoundingClientRect()[e]}var s="function"==typeof n,f=s?"":o(e,n);return t.each(function(t){this==document||this==window||this.nodeType>1||(s&&(f=o(e,n.call(this,t,B(this)[e]()))),this.style[e]=f)})},d=function(t,e){var n=e.length,i=e;if(n>1&&t.indexOf("after")>-1){i=[];for(var r=n;r--;)i.push(e[r])}for(r=0;r1)){if(!i){var h=e.call(f,s,f.className);if(!h)return;r=h.trim().split(" "),o=r.length}for(var u=0;ur?w:document.body}if(null==i){var s=t.get(0);if(!s)return;return s!=window&&s!=document||(s=n),s[e]}return t.each(function(){var t=this;t!=window&&t!=document||(t=n),t[e]=i})},x=function(t,e,n,i){var r=[],o=e+"ElementSibling";return t.each(function(){for(var e=this;(e=e[o])&&(!i||!t.is(i,e));)n&&!t.is(n,e)||r.push(e)}),B(b(r))},A=function(t,e,n){var i=e+"ElementSibling";return t.map(function(){var e=this[i];if(e&&(!n||t.is(n,e)))return e},!1)},L=function(t,e){if(e=e||document,/^[\#.]?[\w-]+$/.test(t)){var n=t[0];if("."===n)return k(e.getElementsByClassName(t.slice(1)));if("#"===n){var i=void 0!==e.getElementById?e.getElementById(t.slice(1)):e.querySelector(t);return i?[i]:[]}return"body"===t?[document.body]:"head"===t?[document.head]:k(e.getElementsByTagName(t))}return k(e.querySelectorAll(t))},j=function(t){return C(t.split("."))},k=function(t){for(var e=[],n=t.length;n--;)e[n]=t[n];return e},S=(i=function(t,e){var n=B(t).clone(!0).get(0),i=n;if(n&&!(this.nodeType>1)){for(;i.firstChild;)i=i.firstChild;if("inner"==e){for(;this.firstChild;)i.appendChild(this.firstChild);this.appendChild(n)}else{var r="all"==e?this.get(0):this,o=r.parentNode,s=r.nextSibling;"all"==e?this.each(function(){i.appendChild(this)}):i.appendChild(r),o.insertBefore(n,s)}}},function(t,e){return"function"==typeof t?this.each(function(n){B(this)["inner"==e?"wrapInner":"wrap"](t.call(this,n))}):"all"==e?i.call(this,t,e):this.each(function(){i.call(this,t,e)}),this}),M={legend:{intro:"
",outro:"
"},area:{intro:"",outro:""},param:{intro:"",outro:""},thead:{intro:"",outro:"
"},tr:{intro:"",outro:"
"},col:{intro:"",outro:"
"},td:{intro:"",outro:"
"}};["tbody","tfoot","colgroup","caption"].forEach(function(t){M[t]=M.thead}),M.th=M.td;var O=function(t,e){if("string"==typeof t)"<"==t[0]?this.dom=[function(t){var e=document.createElement("div"),n=/[\w:-]+/.exec(t)[0],i=M[n],r=t.trim();i&&(r=i.intro+r+i.outro),e.insertAdjacentHTML("afterbegin",r);var o=e.lastChild;if(i)for(var s=i.outro.match(/1||this.setAttribute(t,n?e.call(this,i,this.getAttribute(t)):e)});if("object"==typeof t){var i=Object.keys(t),r=i.length;return this.each(function(){if(!(this.nodeType>1))for(var e=0;e1)){var s=o.getAttribute(t);if(null!=s)return s||t}},before:function(){return d.call(this,"beforebegin",arguments),this},children:function(t){var e=[],n=this;return this.each(function(){if(!(this.nodeType>1))for(var i=this.children,r=i.length,o=0;o1)){if(r)var n=parseInt(getComputedStyle(this).getPropertyValue(t))+s;this.style[t]=o(t,r?n:e)}})}if("function"==n)return this.each(function(n){if(!(this.nodeType>1)){var i=getComputedStyle(this).getPropertyValue(t);this.style[t]=e.call(this,n,i)}});if("string"==typeof t){if(!(f=this.get(0))||f.nodeType>1)return;return getComputedStyle(f).getPropertyValue(t)}if(Array.isArray(t)){var f;if(!(f=this.get(0))||f.nodeType>1)return;for(var h={},u=getComputedStyle(f),c=t.length,a=0;a1))for(var e=0;e1||!e&&!n.is(t,this)||e&&!t.call(this,i,this)))return this},!1)},find:function(t){if("string"==typeof t){var e=[];return this.each(function(){if(!(this.nodeType>1))for(var n=L(t,this),i=n.length,r=0;r1))for(var h=0;h1)&&L(t,this)[0])return this},!1);for(var e=[],n=this.length;n--;){var i=this.get(n);if(i.contains(t)){e.push(i);break}}return B(e)},hasClass:function(t){for(var e=this.length;e--;){var n=this.get(e);if(n.nodeType>1)return;if(n.classList.contains(t))return!0}return!1},height:function(t){return p(this,"height",t)},html:function(t){if(null==t){var e=this.get(0);if(!e)return;return e.innerHTML}return"function"==typeof t?this.each(function(e){var n=t.call(this,e,this.innerHTML);B(this).html(n)}):this.each(function(){this.innerHTML=t})},index:function(t){if(this.length){var e,n;t?"string"==typeof t?(e=this.get(0),n=B(t)):(e=t instanceof O?t.get(0):t,n=this):(e=this.get(0),n=this.first().parent().children());for(var i=n.get(),r=i.length;r--;)if(i[r]==e)return r;return-1}},insertAfter:function(t){return B(t).after(this),this},insertBefore:function(t){return B(t).before(this),this},is:function(t,e){var n=e?[e]:this.get(),i=n.length;if("string"==typeof t){for(var r=0;r1)&&o[m](t))return!0}return!1}if("object"==typeof t){var s,f=(s=t instanceof O?t.get():t.length?t:[t]).length;for(r=0;r1)return;var n=e.getBoundingClientRect();return{top:n.top+window.pageYOffset,left:n.left+window.pageXOffset}}return"object"==typeof t?this.each(function(){if(!(this.nodeType>1)){var e=B(this);"static"==e.css("position")?e.css("position","relative"):e.css({top:0,left:0});var n=e.offset();e.css({top:t.top-n.top+"px",left:t.left-n.left+"px"})}}):"function"==typeof t?this.each(function(e){var n=B(this),i=t.call(this,e,n.offset());n.offset(i)}):void 0},offsetParent:function(){var t=[];return this.each(function(){if(!(this.nodeType>1)){for(var e=this;e!=w;){e=e.parentNode;var n=getComputedStyle(e).getPropertyValue("position");if(!n)break;if("static"!=n)return void t.push(e)}t.push(w)}}),B(t)},on:function(t,e,n){if("string"!=typeof e&&(n=e,e=null),n){e&&(n=s(n,e));var i=t.trim().split(" ");return this.each(function(){e&&(n=s(n,e,this)),a(this)||(this.sprintEventListeners={}),i.forEach(function(t){a(this)[t]||(a(this)[t]=[]),a(this)[t].push(n),this.addEventListener(t,n),g(t)&&this.addEventListener(c(t),n)},this)})}return Object.keys(t).forEach(function(e){this.on(e,t[e])},this),this},parent:function(t){return u.call(this,!0,!0,!1,t)},parents:function(t){return u.call(this,!0,!1,!1,t)},position:function(){var t=this.offset(),e=this.parent().offset();if(t)return{top:t.top-e.top,left:t.left-e.left}},prop:function(t,e){if("object"==typeof t){var n=Object.keys(t),i=n.length;return this.each(function(){for(var e=0;e1))for(var t=0;t=0?t:t+this.length,o=this.length;for(e<0?o+=e:e>=0&&(o=e>this.length?this.length:e);r