Files
OfficialSite/www/assets/scripts/app.js
Deven Caron 43fc62950a Build
2020-10-26 15:28:35 -04:00

1 line
19 KiB
JavaScript

!function(t){"use strict";function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=e(t);function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function o(t,e,n){return e&&s(t.prototype,e),n&&s(t,n),t}function a(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function l(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],i=!0,r=!1,s=void 0;try{for(var o,a=t[Symbol.iterator]();!(i=(o=a.next()).done)&&(n.push(o.value),!e||n.length!==e);i=!0);}catch(t){r=!0,s=t}finally{try{i||null==a.return||a.return()}finally{if(r)throw s}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function u(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var c=function(){function t(e){r(this,t),this.mAttr="data-"+e.dataName,this.mCaptureEvents=["mouseenter","mouseleave"],this.el=e.el}return o(t,[{key:"mInit",value:function(t){var e=this;this.modules=t,this.mCheckEventTarget=this.mCheckEventTarget.bind(this),this.events&&Object.keys(this.events).forEach((function(t){return e.mAddEvent(t)}))}},{key:"mUpdate",value:function(t){this.modules=t}},{key:"mDestroy",value:function(){var t=this;this.events&&Object.keys(this.events).forEach((function(e){return t.mRemoveEvent(e)}))}},{key:"mAddEvent",value:function(t){var e=!!this.mCaptureEvents.includes(t);this.el.addEventListener(t,this.mCheckEventTarget,e)}},{key:"mRemoveEvent",value:function(t){var e=!!this.mCaptureEvents.includes(t);this.el.removeEventListener(t,this.mCheckEventTarget,e)}},{key:"mCheckEventTarget",value:function(t){var e=this.events[t.type];if("string"==typeof e)this[e](t);else{var n="["+this.mAttr+"]",i=t.target;if(this.mCaptureEvents.includes(t.type))i.matches(n)&&this.mCallEventMethod(t,e,i);else for(;i&&i!==document&&(!i.matches(n)||"undefined"==this.mCallEventMethod(t,e,i));)i=i.parentNode}}},{key:"mCallEventMethod",value:function(t,e,n){var i=n.getAttribute(this.mAttr);if(e.hasOwnProperty(i)){var r=e[i];Object.defineProperty(t,"currentTarget",{value:n}),Object.defineProperty(t,"curTarget",{value:n}),this[r](t)}}},{key:"$",value:function(t,e){var n=[t.indexOf("."),t.indexOf("#"),t.indexOf("[")].filter((function(t){return-1!=t})),r=!1,s=t,o="",a=this.el;return n.length&&(r=Math.min.apply(Math,u(n)),s=t.slice(0,r),o=t.slice(r)),"object"==i(e)&&(a=e),a.querySelectorAll("["+this.mAttr+"="+s+"]"+o)}},{key:"parent",value:function(t,e){for(var n="["+this.mAttr+"="+t+"]",i=e;i&&i!==document;){if(i.matches(n))return i;i=i.parentNode}}},{key:"getData",value:function(t,e){return(e||this.el).getAttribute(this.mAttr+"-"+t)}},{key:"setData",value:function(t,e,n){return(n||this.el).setAttribute(this.mAttr+"-"+t,e)}},{key:"call",value:function(t,e,n,i){var r=this;e&&!n&&(n=e,e=!1),this.modules[n]&&(i?this.modules[n][i]&&this.modules[n][i][t](e):Object.keys(this.modules[n]).forEach((function(i){r.modules[n][i][t](e)})))}},{key:"init",value:function(){}},{key:"destroy",value:function(){}}]),t}(),h=function(){function t(e){r(this,t),this.app,this.modules=e.modules,this.currentModules={},this.activeModules={},this.newModules={},this.moduleId=0}return o(t,[{key:"init",value:function(t,e){var n=this,i=(e||document).querySelectorAll("*");t&&!this.app&&(this.app=t),this.activeModules.app={app:this.app},i.forEach((function(t){Array.from(t.attributes).forEach((function(i){if(i.name.startsWith("data-module")){var r=!1,s=i.name.split("-").splice(2),o=n.toCamel(s);if(n.modules[o]?r=!0:n.modules[n.toUpper(o)]&&(o=n.toUpper(o),r=!0),r){var a={el:t,name:o,dataName:s.join("-")},l=new n.modules[o](a),u=i.value;u||(n.moduleId++,u="m"+n.moduleId,t.setAttribute(i.name,u)),n.addActiveModule(o,u,l);var c=o+"-"+u;e?n.newModules[c]=l:n.currentModules[c]=l}}}))})),Object.entries(this.currentModules).forEach((function(t){var i=l(t,2),r=i[0],s=i[1];if(e){var o=r.split("-"),a=o.shift(),u=o.pop();n.addActiveModule(a,u,s)}else n.initModule(s)}))}},{key:"initModule",value:function(t){t.mInit(this.activeModules),t.init()}},{key:"addActiveModule",value:function(t,e,n){this.activeModules[t]?Object.assign(this.activeModules[t],a({},e,n)):this.activeModules[t]=a({},e,n)}},{key:"update",value:function(t){var e=this;this.init(this.app,t),Object.entries(this.currentModules).forEach((function(t){var n=l(t,2);n[0];n[1].mUpdate(e.activeModules)})),Object.entries(this.newModules).forEach((function(t){var n=l(t,2),i=(n[0],n[1]);e.initModule(i)})),Object.assign(this.currentModules,this.newModules)}},{key:"destroy",value:function(t){t?this.destroyScope(t):this.destroyModules()}},{key:"destroyScope",value:function(t){var e=this;t.querySelectorAll("*").forEach((function(t){Array.from(t.attributes).forEach((function(t){if(t.name.startsWith("data-module")){var n=t.value,i=t.name.split("-").splice(2),r=e.toCamel(i)+"-"+n,s=!1;e.currentModules[r]?s=!0:e.currentModules[e.toUpper(r)]&&(r=e.toUpper(r),s=!0),s&&(e.destroyModule(e.currentModules[r]),delete e.currentModules[r])}}))})),this.activeModules={},this.newModules={}}},{key:"destroyModules",value:function(){var t=this;Object.entries(this.currentModules).forEach((function(e){var n=l(e,2),i=(n[0],n[1]);t.destroyModule(i)})),this.currentModules=[]}},{key:"destroyModule",value:function(t){t.mDestroy(),t.destroy()}},{key:"toCamel",value:function(t){var e=this;return t.reduce((function(t,n){return t+e.toUpper(n)}))}},{key:"toUpper",value:function(t){return t.charAt(0).toUpperCase()+t.slice(1)}}]),t}();function d(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function f(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function v(t,e,n){return e&&f(t.prototype,e),n&&f(t,n),t}function y(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&p(t,e)}function m(t){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function b(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function g(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,i=m(t);if(e){var r=m(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return b(this,n)}}function C(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function w(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],i=!0,r=!1,s=void 0;try{for(var o,a=t[Symbol.iterator]();!(i=(o=a.next()).done)&&(n.push(o.value),!e||n.length!==e);i=!0);}catch(t){r=!0,s=t}finally{try{i||null==a.return||a.return()}finally{if(r)throw s}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var k=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.defaults={name:"load",loadingClass:"is-loading",loadedClass:"is-loaded",readyClass:"is-ready",transitionsPrefix:"is-",enterDelay:0,exitDelay:0,loadedDelay:0,isLoaded:!1,isEntered:!1,isUrl:!1,transitionContainer:null},Object.assign(this,this.defaults,e),this.options=e,this.namespace="modular",this.html=document.documentElement,this.href=window.location.href,this.container="data-"+this.name+"-container",this.subContainer=!1,this.prevTransition=null,this.loadAttributes=["src","srcset","style","href"],this.isInserted=!1,this.isLoading=!1,this.enterTimeout=!1,this.controller=new AbortController,this.classContainer=this.html,this.isChrome=-1!=navigator.userAgent.indexOf("Chrome"),this.init()}var e,n,i;return e=t,(n=[{key:"init",value:function(){var t=this;window.addEventListener("popstate",(function(e){return t.checkState(e)}),!1),this.html.addEventListener("click",(function(e){return t.checkClick(e)}),!1),this.loadEls(document)}},{key:"checkClick",value:function(t){if(!t.ctrlKey&&!t.metaKey)for(var e=t.target;e&&e!==document;){if(e.matches("a")){var n=e.getAttribute("href");n.startsWith("#")||n.startsWith("mailto:")||n.startsWith("tel:")||(t.preventDefault(),this.reset(),this.getClickOptions(e));break}e=e.parentNode}}},{key:"checkState",value:function(){this.reset(),this.getStateOptions()}},{key:"reset",value:function(){this.isLoading&&(this.controller.abort(),this.isLoading=!1,this.controller=new AbortController),window.clearTimeout(this.enterTimeout),this.isInserted&&this.removeContainer(),this.classContainer=this.html,Object.assign(this,this.defaults,this.options)}},{key:"getClickOptions",value:function(t){this.transition=t.getAttribute("data-"+this.name),this.isUrl=t.getAttribute("data-"+this.name+"-url");var e=t.getAttribute("href");"_blank"!=t.getAttribute("target")?"false"!=this.transition?this.setOptions(e,!0):window.location=e:window.open(e,"_blank")}},{key:"getStateOptions",value:function(){this.transition=history.state;var t=window.location.href;this.setOptions(t)}},{key:"goTo",value:function(t,e,n){this.reset(),this.transition=e,this.isUrl=n,this.setOptions(t,!0)}},{key:"setOptions",value:function(t,e){var n,i="["+this.container+"]";this.transition&&"true"!=this.transition&&(this.transitionContainer="["+this.container+'="'+this.transition+'"]',this.loadingClass=this.transitions[this.transition].loadingClass||this.loadingClass,this.loadedClass=this.transitions[this.transition].loadedClass||this.loadedClass,this.readyClass=this.transitions[this.transition].readyClass||this.readyClass,this.transitionsPrefix=this.transitions[this.transition].transitionsPrefix||this.transitionsPrefix,this.enterDelay=this.transitions[this.transition].enterDelay||this.enterDelay,this.exitDelay=this.transitions[this.transition].exitDelay||this.exitDelay,this.loadedDelay=this.transitions[this.transition].loadedDelay||this.loadedDelay,n=document.querySelector(this.transitionContainer)),n?(i=this.transitionContainer,this.oldContainer=n,this.classContainer=this.oldContainer.parentNode,this.subContainer||history.replaceState(this.transition,null,this.href),this.subContainer=!0):(this.oldContainer=document.querySelector(i),this.subContainer&&history.replaceState(this.prevTransition,null,this.href),this.subContainer=!1),this.href=t,this.parentContainer=this.oldContainer.parentNode,""===this.isUrl||null!=this.isUrl&&"false"!=this.isUrl&&0!=this.isUrl?history.pushState(this.transition,null,t):(this.oldContainer.classList.add("is-old"),this.setLoading(),this.startEnterDelay(),this.loadHref(t,i,e))}},{key:"setLoading",value:function(){this.classContainer.classList.remove(this.loadedClass,this.readyClass),this.classContainer.classList.add(this.loadingClass),this.classContainer.classList.remove(this.transitionsPrefix+this.prevTransition),this.transition&&this.classContainer.classList.add(this.transitionsPrefix+this.transition),this.subContainer||(this.prevTransition=this.transition);var t=new Event(this.namespace+"loading");window.dispatchEvent(t)}},{key:"startEnterDelay",value:function(){var t=this;this.enterTimeout=window.setTimeout((function(){t.isEntered=!0,t.isLoaded&&t.transitionContainers()}),this.enterDelay)}},{key:"loadHref",value:function(t,e,n){var i=this;this.isLoading=!0;var r=this.controller.signal;fetch(t,{signal:r}).then((function(t){return t.text()})).then((function(t){var n=new DOMParser;i.data=n.parseFromString(t,"text/html"),i.newContainer=i.data.querySelector(e),i.newContainer.classList.add("is-new"),i.parentNewContainer=i.newContainer.parentNode,i.hideContainer(),i.parentContainer.insertBefore(i.newContainer,i.oldContainer),i.isInserted=!0,i.setSvgs(),i.isLoaded=!0,i.isEntered&&i.transitionContainers(),i.loadEls(i.newContainer),i.isLoading=!1})).catch((function(t){console.log(t)})),n&&history.pushState(this.transition,null,t)}},{key:"transitionContainers",value:function(){var t=this;this.setAttributes(),this.showContainer(),this.setLoaded(),setTimeout((function(){t.removeContainer(),t.setReady()}),this.exitDelay)}},{key:"setSvgs",value:function(){if(this.isChrome){var t=this.newContainer.querySelectorAll("use");t.length&&t.forEach((function(t){var e=t.getAttribute("xlink:href");if(e)t.parentNode.innerHTML='<use xlink:href="'+e+'"></use>';else{var n=t.getAttribute("href");n&&(t.parentNode.innerHTML='<use href="'+n+'"></use>')}}))}}},{key:"setAttributes",value:function(){var t,e,n=this,i=this.data.getElementsByTagName("title")[0],r=this.data.head.querySelector('meta[name="description"]'),s=document.head.querySelector('meta[name="description"]');this.subContainer?(e=this.parentNewContainer,t=document.querySelector(this.transitionContainer).parentNode):(e=this.data.querySelector("html"),t=document.querySelector("html"));var o=Object.assign({},e.dataset);i&&(document.title=i.innerHTML),s&&r&&s.setAttribute("content",r.getAttribute("content")),o&&Object.entries(o).forEach((function(e){var i=w(e,2),r=i[0],s=i[1];t.setAttribute("data-"+n.toDash(r),s)}))}},{key:"toDash",value:function(t){return t.split(/(?=[A-Z])/).join("-").toLowerCase()}},{key:"hideContainer",value:function(){this.newContainer.style.visibility="hidden",this.newContainer.style.height=0,this.newContainer.style.overflow="hidden"}},{key:"showContainer",value:function(){this.newContainer.style.visibility="",this.newContainer.style.height="",this.newContainer.style.overflow=""}},{key:"loadEls",value:function(t){var e=this,n=[];this.loadAttributes.forEach((function(i){var r="data-"+e.name+"-"+i,s=t.querySelectorAll("["+r+"]");s.length&&s.forEach((function(t){var e=t.getAttribute(r);if(t.setAttribute(i,e),"src"==i||"srcset"==i){var s=new Promise((function(e){t.onload=function(){return e(t)}}));n.push(s)}}))})),Promise.all(n).then((function(t){var n=new Event(e.namespace+"images");window.dispatchEvent(n)}))}},{key:"setLoaded",value:function(){var t=this;this.classContainer.classList.remove(this.loadingClass),setTimeout((function(){t.classContainer.classList.add(t.loadedClass)}),this.loadedDelay);var e=new Event(this.namespace+"loaded");window.dispatchEvent(e)}},{key:"removeContainer",value:function(){this.parentContainer.removeChild(this.oldContainer),this.newContainer.classList.remove("is-new"),this.isInserted=!1}},{key:"setReady",value:function(){this.classContainer.classList.add(this.readyClass);var t=new Event(this.namespace+"ready");window.dispatchEvent(t)}},{key:"on",value:function(t,e){var n=this;window.addEventListener(this.namespace+t,(function(){switch(t){case"loading":return e(n.transition,n.oldContainer);case"loaded":return e(n.transition,n.oldContainer,n.newContainer);case"ready":return e(n.transition,n.newContainer);default:return e()}}),!1)}}])&&C(e.prototype,n),i&&C(e,i),t}(),E=function(t){y(n,t);var e=g(n);function n(t){return d(this,n),e.call(this,t)}return v(n,[{key:"init",value:function(){var t=this;new k({enterDelay:0,transitions:{customTransition:{}}}).on("loaded",(function(e,n,i){t.call("destroy",n,"app"),t.call("update",i,"app")}))}}]),n}(c),A=function(t){y(i,t);var e=g(i);function i(t){return d(this,i),e.call(this,t)}return v(i,[{key:"init",value:function(){var t=this;this.scroll=new n.default({el:this.el,smooth:!0}),this.scroll.on("call",(function(e,n,i,r){t.call(e[0],{way:n,obj:i},e[1],e[2])})),this.scroll.on("scroll",(function(t){}))}},{key:"toggleLazy",value:function(t){var e=this.getData("lazy",t.obj.el);e.length&&("IMG"==t.obj.el.tagName?t.obj.el.src=e:t.obj.el.style.backgroundImage="url(".concat(e,")"),this.setData("lazy","",t.obj.el))}},{key:"destroy",value:function(){this.scroll.destroy()}}]),i}(c),M=Object.freeze({__proto__:null,Load:E,Scroll:A}),O="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var L=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e,n;e=O,n=function(){function t(t,e,n){if(n){var i=document.createDocumentFragment(),r=!e.hasAttribute("viewBox")&&n.getAttribute("viewBox");r&&e.setAttribute("viewBox",r);for(var s=n.cloneNode(!0);s.childNodes.length;)i.appendChild(s.firstChild);t.appendChild(i)}}function e(e){e.onreadystatechange=function(){if(4===e.readyState){var n=e._cachedDocument;n||((n=e._cachedDocument=document.implementation.createHTMLDocument("")).body.innerHTML=e.responseText,e._cachedTarget={}),e._embeds.splice(0).map((function(i){var r=e._cachedTarget[i.id];r||(r=e._cachedTarget[i.id]=n.getElementById(i.id)),t(i.parent,i.svg,r)}))}},e.onreadystatechange()}function n(t){for(var e=t;"svg"!==e.nodeName.toLowerCase()&&(e=e.parentNode););return e}return function(i){var r,s=Object(i),o=window.top!==window.self;r="polyfill"in s?s.polyfill:/\bTrident\/[567]\b|\bMSIE (?:9|10)\.0\b/.test(navigator.userAgent)||(navigator.userAgent.match(/\bEdge\/12\.(\d+)\b/)||[])[1]<10547||(navigator.userAgent.match(/\bAppleWebKit\/(\d+)\b/)||[])[1]<537||/\bEdge\/.(\d+)\b/.test(navigator.userAgent)&&o;var a={},l=window.requestAnimationFrame||setTimeout,u=document.getElementsByTagName("use"),c=0;r&&function i(){for(var o=0;o<u.length;){var h=u[o],d=h.parentNode,f=n(d),v=h.getAttribute("xlink:href")||h.getAttribute("href");if(!v&&s.attributeName&&(v=h.getAttribute(s.attributeName)),f&&v){if(r)if(!s.validate||s.validate(v,f,h)){d.removeChild(h);var y=v.split("#"),m=y.shift(),p=y.join("#");if(m.length){var b=a[m];b||((b=a[m]=new XMLHttpRequest).open("GET",m),b.send(),b._embeds=[]),b._embeds.push({parent:d,svg:f,id:p}),e(b)}else t(d,f,document.getElementById(p))}else++o,++c}else++o}(!u.length||u.length-c>0)&&l(i,67)}()}},t.exports?t.exports=n():e.svg4everybody=n()}));var T=document.documentElement,j=(T.getAttribute("data-debug"),new h({modules:M}));function S(){L(),j.init(j),T.classList.add("is-loaded"),T.classList.add("is-ready"),T.classList.remove("is-loading")}window.onload=function(t){var e=document.getElementById("stylesheet");e.isLoaded?S():e.addEventListener("load",(function(t){S()}))}}(LocomotiveScroll);