Files
spyda/internal/static/js/spyda.min.js
2021-01-30 14:07:19 +10:00

1 line
12 KiB
JavaScript

var u=function(a,b){if(!(this instanceof u))return new u(a,b);if(a instanceof u)return a;typeof a=='string'&&(a=this.select(a,b)),a&&a.nodeName&&(a=[a]),this.nodes=this.slice(a)},Twix,dropCookie,cookieDuration,cookieName,cookieValue;u.prototype={get length(){return this.nodes.length}},u.prototype.nodes=[],u.prototype.addClass=function(){return this.eacharg(arguments,function(a,b){a.classList.add(b)})},u.prototype.adjacent=function(b,a,c){return typeof a=='number'&&(a===0?a=[]:a=new Array(a).join().split(',').map(Number.call,Number)),this.each(function(e,f){var d=document.createDocumentFragment();u(a||{}).map(function(c,d){var a=typeof b=='function'?b.call(this,c,d,e,f):b;return typeof a=='string'?this.generate(a):u(a)}).each(function(a){this.isInPage(a)?d.appendChild(u(a).clone().first()):d.appendChild(a)}),c.call(this,e,d)})},u.prototype.after=function(a,b){return this.adjacent(a,b,function(a,b){a.parentNode.insertBefore(b,a.nextSibling)})},u.prototype.append=function(a,b){return this.adjacent(a,b,function(a,b){a.appendChild(b)})},u.prototype.args=function(a,b,c){return typeof a=='function'&&(a=a(b,c)),typeof a!='string'&&(a=this.slice(a).map(this.str(b,c))),a.toString().split(/[\s,]+/).filter(function(a){return a.length})},u.prototype.array=function(a){a=a;var b=this;return this.nodes.reduce(function(e,d,f){var c;return a?(c=a.call(b,d,f),c||(c=!1),typeof c=='string'&&(c=u(c)),c instanceof u&&(c=c.nodes)):c=d.innerHTML,e.concat(c!==!1?c:[])},[])},u.prototype.attr=function(b,c,a){return a=a?'data-':'',this.pairs(b,c,function(b,c){return b.getAttribute(a+c)},function(b,c,d){b.setAttribute(a+c,d)})},u.prototype.before=function(a,b){return this.adjacent(a,b,function(a,b){a.parentNode.insertBefore(b,a)})},u.prototype.children=function(a){return this.map(function(a){return this.slice(a.children)}).filter(a)},u.prototype.clone=function(){return this.map(function(a,d){var b=a.cloneNode(!0),c=this.getAll(b);return this.getAll(a).each(function(b,d){for(var a in this.mirror)this.mirror[a]&&this.mirror[a](b,c.nodes[d])}),b})},u.prototype.getAll=function(a){return u([a].concat(u('*',a).nodes))},u.prototype.mirror={},u.prototype.mirror.events=function(a,c){if(!a._e)return;for(var b in a._e)a._e[b].forEach(function(a){u(c).on(b,a.callback)})},u.prototype.mirror.select=function(a,b){u(a).is('select')&&(b.value=a.value)},u.prototype.mirror.textarea=function(a,b){u(a).is('textarea')&&(b.value=a.value)},u.prototype.closest=function(a){return this.map(function(b){do if(u(b).is(a))return b;while((b=b.parentNode)&&b!==document)})},u.prototype.data=function(a,b){return this.attr(a,b,!0)},u.prototype.each=function(a){return this.nodes.forEach(a.bind(this)),this},u.prototype.eacharg=function(a,b){return this.each(function(c,d){this.args(a,c,d).forEach(function(a){b.call(this,c,a)},this)})},u.prototype.empty=function(){return this.each(function(a){while(a.firstChild)a.removeChild(a.firstChild)})},u.prototype.filter=function(a){var b=function(b){return b.matches=b.matches||b.msMatchesSelector||b.webkitMatchesSelector,b.matches(a||'*')};return typeof a=='function'&&(b=a),a instanceof u&&(b=function(b){return a.nodes.indexOf(b)!==-1}),u(this.nodes.filter(b))},u.prototype.find=function(a){return this.map(function(b){return u(a||'*',b)})},u.prototype.first=function(){return this.nodes[0]||!1},u.prototype.generate=function(a){return/^\s*<tr[> ]/.test(a)?u(document.createElement('table')).html(a).children().children().nodes:/^\s*<t(h|d)[> ]/.test(a)?u(document.createElement('table')).html(a).children().children().children().nodes:/^\s*</.test(a)?u(document.createElement('div')).html(a).children().nodes:document.createTextNode(a)},u.prototype.handle=function(){var a=this.slice(arguments).map(function(a){return typeof a=='function'?function(b){b.preventDefault(),a.apply(this,arguments)}:a},this);return this.on.apply(this,a)},u.prototype.hasClass=function(){return this.is('.'+this.args(arguments).join('.'))},u.prototype.html=function(a){return a===void 0?this.first().innerHTML||'':this.each(function(b){b.innerHTML=a})},u.prototype.is=function(a){return this.filter(a).length>0},u.prototype.isInPage=function(a){return!(a===document.body)&&document.body.contains(a)},u.prototype.last=function(){return this.nodes[this.length-1]||!1},u.prototype.map=function(a){return a?u(this.array(a)).unique():this},u.prototype.not=function(a){return this.filter(function(b){return!u(b).is(a||!0)})},u.prototype.off=function(e,a,d){var f=a==null&&d==null,b=null,c=a;return typeof a=='string'&&(b=a,c=d),this.eacharg(e,function(a,d){u(a._e?a._e[d]:[]).each(function(e){(f||e.orig_callback===c&&e.selector===b)&&a.removeEventListener(d,e.callback)})})},u.prototype.on=function(f,a,b){var c=null,d=a,e;return typeof a=='string'&&(c=a,d=b,a=function(a){var e=arguments,d=!1;u(a.currentTarget).find(c).each(function(c){if(c===a.target||c.contains(a.target)){d=!0;try{Object.defineProperty(a,'currentTarget',{get:function(){return c}})}catch(a){}b.apply(c,e)}}),!d&&a.currentTarget===a.target&&b.apply(a.target,e)}),e=function(b){return a.apply(this,[b].concat(b.detail||[]))},this.eacharg(f,function(a,b){a.addEventListener(b,e),a._e=a._e||{},a._e[b]=a._e[b]||[],a._e[b].push({callback:e,orig_callback:d,selector:c})})},u.prototype.pairs=function(a,b,c,d){if(typeof b!='undefined'){var e=a;a={},a[e]=b}return typeof a=='object'?this.each(function(c){for(var b in a)d(c,b,a[b])}):this.length?c(this.first(),a):''},u.prototype.param=function(a){return Object.keys(a).map(function(b){return this.uri(b)+'='+this.uri(a[b])}.bind(this)).join('&')},u.prototype.parent=function(a){return this.map(function(a){return a.parentNode}).filter(a)},u.prototype.prepend=function(a,b){return this.adjacent(a,b,function(a,b){a.insertBefore(b,a.firstChild)})},u.prototype.remove=function(){return this.each(function(a){a.parentNode&&a.parentNode.removeChild(a)})},u.prototype.removeClass=function(){return this.eacharg(arguments,function(a,b){a.classList.remove(b)})},u.prototype.replace=function(b,c){var a=[];return this.adjacent(b,c,function(b,c){a=a.concat(this.slice(c.children)),b.parentNode.replaceChild(c,b)}),u(a)},u.prototype.scroll=function(){return this.first().scrollIntoView({behavior:'smooth'}),this},u.prototype.select=function(a,b){return(a=a.replace(/^\s*/,'').replace(/\s*$/,''),/^</.test(a))?u().generate(a):(b||document).querySelectorAll(a)},u.prototype.serialize=function(){var a=this;return this.slice(this.first().elements).reduce(function(c,b){return!b.name||b.disabled||b.type==='file'?c:/(checkbox|radio)/.test(b.type)&&!b.checked?c:b.type==='select-multiple'?(u(b.options).each(function(d){d.selected&&(c+='&'+a.uri(b.name)+'='+a.uri(d.value))}),c):c+'&'+a.uri(b.name)+'='+a.uri(b.value)},'').slice(1)},u.prototype.siblings=function(a){return this.parent().children(a).not(this)},u.prototype.size=function(){return this.first().getBoundingClientRect()},u.prototype.slice=function(a){return!a||a.length===0||typeof a=='string'||a.toString()==='[object Function]'?[]:a.length?[].slice.call(a.nodes||a):[a]},u.prototype.str=function(a,b){return function(c){return typeof c=='function'?c.call(this,a,b):c.toString()}},u.prototype.text=function(a){return a===void 0?this.first().textContent||'':this.each(function(b){b.textContent=a})},u.prototype.toggleClass=function(b,a){return!!a===a?this[a?'addClass':'removeClass'](b):this.eacharg(b,function(a,b){a.classList.toggle(b)})},u.prototype.trigger=function(b){var a=this.slice(arguments).slice(1);return this.eacharg(b,function(e,c){var d={bubbles:!0,cancelable:!0,detail:a},b;try{b=new window.CustomEvent(c,d)}catch(d){b=document.createEvent('CustomEvent'),b.initCustomEvent(c,!0,!0,a)}e.dispatchEvent(b)})},u.prototype.unique=function(){return u(this.nodes.reduce(function(b,a){var c=a!==null&&a!==void 0&&a!==!1;return c&&b.indexOf(a)===-1?b.concat(a):b},[]))},u.prototype.uri=function(a){return encodeURIComponent(a).replace(/!/g,'%21').replace(/'/g,'%27').replace(/\(/g,'%28').replace(/\)/g,'%29').replace(/\*/g,'%2A').replace(/%20/g,'+')},u.prototype.wrap=function(a){function b(a){while(a.firstElementChild)a=a.firstElementChild;return u(a)}return this.map(function(c){return u(a).each(function(a){b(a).append(c.cloneNode(!0)),c.parentNode.replaceChild(a,c)})})},typeof module=='object'&&module.exports&&(module.exports=u,module.exports.u=u),function(){if(typeof window.Element=="undefined"||"classList"in document.documentElement)return;var a=Array.prototype,c=a.push,d=a.splice,e=a.join;function b(d){var b,a;this.el=d,b=d.className.replace(/^\s+|\s+$/g,'').split(/\s+/);for(a=0;a<b.length;a++)c.call(this,b[a])}b.prototype={add:function(a){if(this.contains(a))return;c.call(this,a),this.el.className=this.toString()},contains:function(a){return this.el.className.indexOf(a)!=-1},item:function(a){return this[a]||null},remove:function(b){if(!this.contains(b))return;for(var a=0;a<this.length;a++)if(this[a]==b)break;d.call(this,a,1),this.el.className=this.toString()},toString:function(){return e.call(this,' ')},toggle:function(a){return this.contains(a)?this.remove(a):this.add(a),this.contains(a)}},window.DOMTokenList=b;function f(a,b,c){Object.defineProperty?Object.defineProperty(a,b,{get:c}):a.__defineGetter__(b,c)}f(Element.prototype,'classList',function(){return new b(this)})}(),Twix=function(){function a(){}a.ajax=function(a){var b,c;a=a||{url:""},a.type=a.type.toUpperCase()||'GET',a.headers=a.headers||{},a.timeout=parseInt(a.timeout)||0,a.success=a.success||function(){},a.error=a.error||function(){},a.async=typeof a.async=='undefined'||a.async,b=new XMLHttpRequest,a.timeout>0&&(b.timeout=a.timeout,b.ontimeout=function(){a.error('timeout','timeout',b)}),b.open(a.type,a.url,a.async);for(c in a.headers)a.headers.hasOwnProperty(c)&&b.setRequestHeader(c,a.headers[c]);return b.send(a.data),b.onreadystatechange=function(){var b,c;this.readyState==4&&(this.status>=200&&this.status<300||this.status==304)?(b=this.responseText,c=this.getResponseHeader('Content-Type'),c&&c.match(/json/)&&(b=JSON.parse(this.responseText)),a.success(b,this.statusText,this)):this.readyState==4&&a.error(this.status,this.statusText,this)},a.async==!1&&(b.readyState==4&&(b.status>=200&&b.status<300||b.status==304)?a.success(b.responseText,b):b.readyState==4&&a.error(b.status,b.statusText,b)),b};var b=function(d,e,b,c){return typeof b=="function"&&(c=b,b=void 0),a.ajax({url:e,data:b,type:d,success:c})};return a.get=function(a,c,d){return b("GET",a,c,d)},a.head=function(a,c,d){return b("HEAD",a,c,d)},a.post=function(a,c,d){return b("POST",a,c,d)},a.patch=function(a,c,d){return b("PATCH",a,c,d)},a.put=function(a,c,d){return b("PUT",a,c,d)},a.delete=function(a,c,d){return b("DELETE",a,c,d)},a.options=function(a,c,d){return b("OPTIONS",a,c,d)},a}(),__=Twix,dropCookie=!0,cookieDuration=14,cookieName="complianceCookie",cookieValue="on";function createDiv(){u("body").prepend('<div id="cookie-law" class="container-fluid"><p>This website uses cookies. By continuing we assume your permission to deploy cookies, as detailed in our <a href="/privacy" rel="nofollow" title="Privacy Policy">privacy policy</a>. <a role="button" href="javascript:void(0);" onclick="removeMe();">Close</a></p></div>'),createCookie(window.cookieName,window.cookieValue,window.cookieDuration)}function createCookie(d,e,c){var a,b;c?(a=new Date,a.setTime(a.getTime()+c*24*60*60*1e3),b="; expires="+a.toGMTString()):(b=""),window.dropCookie&&(document.cookie=d+"="+e+b+"; path=/")}function checkCookie(e){for(var d=e+"=",c=document.cookie.split(";"),b=0,a;b<c.length;b++){for(a=c[b];a.charAt(0)==" ";)a=a.substring(1,a.length);if(a.indexOf(d)==0)return a.substring(d.length,a.length)}return null}function eraseCookie(a){createCookie(a,"",-1)}window.onload=function(){checkCookie(window.cookieName)!=window.cookieValue&&createDiv()};function removeMe(){var a=document.getElementById("cookie-law");a.parentNode.removeChild(a)}u("#burgerMenu").on("click",function(a){a.preventDefault(),u("#mainNav").hasClass("responsive")?u("#mainNav").removeClass("responsive"):u("#mainNav").addClass("responsive")})