1
0
mirror of https://github.com/locomotivemtl/locomotive-boilerplate.git synced 2026-01-15 00:55:08 +08:00
Files
locomotive-boilerplate/www/assets/scripts/app.js

11 lines
55 KiB
JavaScript
Raw Normal View History

(()=>{var Yt=Object.create;var D=Object.defineProperty;var Xt=Object.getOwnPropertyDescriptor;var Zt=Object.getOwnPropertyNames,P=Object.getOwnPropertySymbols,Kt=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty,dt=Object.prototype.propertyIsEnumerable;var ut=(s,e,t)=>e in s?D(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ft=(s,e)=>{for(var t in e||(e={}))Z.call(e,t)&&ut(s,t,e[t]);if(P)for(var t of P(e))dt.call(e,t)&&ut(s,t,e[t]);return s};var mt=(s,e)=>{var t={};for(var i in s)Z.call(s,i)&&e.indexOf(i)<0&&(t[i]=s[i]);if(s!=null&&P)for(var i of P(s))e.indexOf(i)<0&&dt.call(s,i)&&(t[i]=s[i]);return t};var Jt=(s,e)=>()=>(s&&(e=s(s=0)),e);var Qt=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),pt=(s,e)=>{for(var t in e)D(s,t,{get:e[t],enumerable:!0})},te=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Zt(e))!Z.call(s,n)&&n!==t&&D(s,n,{get:()=>e[n],enumerable:!(i=Xt(e,n))||i.enumerable});return s};var ee=(s,e,t)=>(t=s!=null?Yt(Kt(s)):{},te(e||!s||!s.__esModule?D(t,"default",{value:s,enumerable:!0}):t,s));var E=(s,e,t)=>new Promise((i,n)=>{var r=a=>{try{l(t.next(a))}catch(h){n(h)}},o=a=>{try{l(t.throw(a))}catch(h){n(h)}},l=a=>a.done?i(a.value):Promise.resolve(a.value).then(r,o);l((t=t.apply(s,e)).next())});var $t=Qt((Ft,Y)=>{(function(s,e){typeof define=="function"&&define.amd?define([],function(){return s.svg4everybody=e()}):typeof Y=="object"&&Y.exports?Y.exports=e():s.svg4everybody=e()})(Ft,function(){function s(n,r,o){if(o){var l=document.createDocumentFragment(),a=!r.hasAttribute("viewBox")&&o.getAttribute("viewBox");a&&r.setAttribute("viewBox",a);for(var h=o.cloneNode(!0);h.childNodes.length;)l.appendChild(h.firstChild);n.appendChild(l)}}function e(n){n.onreadystatechange=function(){if(n.readyState===4){var r=n._cachedDocument;r||(r=n._cachedDocument=document.implementation.createHTMLDocument(""),r.body.innerHTML=n.responseText,n._cachedTarget={}),n._embeds.splice(0).map(function(o){var l=n._cachedTarget[o.id];l||(l=n._cachedTarget[o.id]=r.getElementById(o.id)),s(o.parent,o.svg,l)})}},n.onreadystatechange()}function t(n){function r(){for(var _=0;_<y.length;){var b=y[_],O=b.parentNode,I=i(O),m=b.getAttribute("xlink:href")||b.getAttribute("href");if(!m&&l.attributeName&&(m=b.getAttribute(l.attributeName)),I&&m){if(o)if(!l.validate||l.validate(m,I,b)){O.removeChild(b);var w=m.split("#"),v=w.shift(),C=w.join("#");if(v.length){var g=f[v];g||(g=f[v]=new XMLHttpRequest,g.open("GET",v),g.send(),g._embeds=[]),g._embeds.push({parent:O,svg:I,id:C}),e(g)}else s(O,I,document.getElementById(C))}else++_,++L}else++_}(!y.length||y.length-L>0)&&p(r,67)}var o,l=Object(n),a=/\bTrident\/[567]\b|\bMSIE (?:9|10)\.0\b/,h=/\bAppleWebKit\/(\d+)\b/,c=/\bEdge\/12\.(\d+)\b/,u=/\bEdge\/.(\d+)\b/,d=window.top!==window.self;o="polyfill"in l?l.polyfill:a.test(navigator.userAgent)||(navigator.userAgent.match(c)||[])[1]<10547||(navigator.userAgent.match(h)||[])[1]<537||u.test(navigator.userAgent)&&d;var f={},p=window.requestAnimationFrame||setTimeout,y=document.getElementsByTagName("use"),L=0;o&&r()}function i(n){for(var r=n;r.nodeName.toLowerCase()!=="svg"&&(r=r.parentNode););return r}return t})});var Nt={};pt(Nt,{gridHelper:()=>Me});function Me({gutterCssVar:s=Ie,marginCssVar:e=Te,rgbaColor:t=Ae}={}){let i=document.createElement("div");document.body.append(i),Ut(i,t),Re(i,s,e),ke(i,t)}function Re(s,e,t){let i=s.style;i.zIndex="10000",i.position="fixed",i.top="0",i.left="0",i.display="flex",i.width="100%",i.height="100%",i.columnGap=`var(${e}, 0)`,i.paddingLeft=`var(${t}, 0)`,i.paddingRight=`var(${t}, 0)`,i.pointerEvents="none",i.visibility="hidden"}function Ut(s,e){s.innerHTML="";let t=Number(window.getComputedStyle(s).getPropertyValue("--grid-columns")),i;for(var n=0;n<t;n++)i=document.createElement("div"),i.style.flex="1 1 0",i.style.backgroundColor=e,s.appendChild(i)}function ke(s,e){window.addEventListener("resize",Ut(s,e));let t=!1,i=!1;document.addEventListener("keydown",n=>{n.key=="Control"?t=!0:t&&n.key=="g"&&(i?s.style.visibility="hidden":s.style.visibility="visible",i=!i)}),document.addE
2024-01-11 11:45:46 +01:00
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ae(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var A=function(){function s(e){yt(this,s),this.mAttr="data-"+e.dataName,this.mCaptureEvents=["mouseenter","mouseleave"],this.el=e.el}return bt(s,[{key:"mInit",value:function(t){var i=this;this.modules=t,this.mCheckEventTarget=this.mCheckEventTarget.bind(this),this.events&&Object.keys(this.events).forEach(function(n){return i.mAddEvent(n)})}},{key:"mUpdate",value:function(t){this.modules=t}},{key:"mDestroy",value:function(){var t=this;this.events&&Object.keys(this.events).forEach(function(i){return t.mRemoveEvent(i)})}},{key:"mAddEvent",value:function(t){var i=!!this.mCaptureEvents.includes(t);this.el.addEventListener(t,this.mCheckEventTarget,i)}},{key:"mRemoveEvent",value:function(t){var i=!!this.mCaptureEvents.includes(t);this.el.removeEventListener(t,this.mCheckEventTarget,i)}},{key:"mCheckEventTarget",value:function(t){var i=this.events[t.type];if(typeof i=="string")this[i](t);else{var n="["+this.mAttr+"]",r=t.target;if(this.mCaptureEvents.includes(t.type))r.matches(n)&&this.mCallEventMethod(t,i,r);else for(;r&&r!==document&&!(r.matches(n)&&this.mCallEventMethod(t,i,r)!="undefined");)r=r.parentNode}}},{key:"mCallEventMethod",value:function(t,i,n){var r=n.getAttribute(this.mAttr);if(i.hasOwnProperty(r)){var o=i[r];t.hasOwnProperty("currentTarget")||Object.defineProperty(t,"currentTarget",{value:n}),t.hasOwnProperty("curTarget")||Object.defineProperty(t,"curTarget",{value:n}),this[o](t)}}},{key:"$",value:function(t,i){var n=t.indexOf("."),r=t.indexOf("#"),o=t.indexOf("["),l=[n,r,o].filter(function(d){return d!=-1}),a=!1,h=t,c="",u=this.el;return l.length&&(a=Math.min.apply(Math,ie(l)),h=t.slice(0,a),c=t.slice(a)),F(i)=="object"&&(u=i),u.querySelectorAll("["+this.mAttr+"="+h+"]"+c)}},{key:"parent",value:function(t,i){for(var n="["+this.mAttr+"="+t+"]",r=i.parentNode;r&&r!==document;){if(r.matches(n))return r;r=r.parentNode}}},{key:"getData",value:function(t,i){var n=i||this.el;return n.getAttribute(this.mAttr+"-"+t)}},{key:"setData",value:function(t,i,n){var r=n||this.el;return r.setAttribute(this.mAttr+"-"+t,i)}},{key:"call",value:function(t,i,n,r){var o=this;i&&!n&&(n=i,i=!1),this.modules[n]&&(r?this.modules[n][r]&&this.modules[n][r][t](i):Object.keys(this.modules[n]).forEach(function(l){o.modules[n][l][t](i)}))}},{key:"on",value:function(t,i,n,r){var o=this;this.modules[i]&&(r?this.modules[i][r].el.addEventListener(t,function(l){return n(l)}):Object.keys(this.modules[i]).forEach(function(l){o.modules[i][l].el.addEventListener(t,function(a){return n(a)})}))}},{key:"init",value:function(){}},{key:"destroy",value:function(){}}]),s}(),he=function(){function s(e){yt(this,s),this.app,this.modules=e.modules,this.currentModules={},this.activeModules={},this.newModules={},this.moduleId=0}return bt(s,[{key:"init",value:function(t,i){var n=this,r=i||document,o=r.querySelectorAll("*");t&&!this.app&&(this.app=t),this.activeModules.app={app:this.app},o.forEach(function(l){Array.from(l.attributes).forEach(function(a){if(a.name.startsWith("data-module")){var h=!1,c=a.name.split("-").splice(2),u=n.toCamel(c);if(n.modules[u]?h=!0:n.modules[n.toUpper(u)]&&(u=n.toUpper(u),h=!0),h){var d={el:l,name:u,dataName:c.join("-")},f=new n.modules[u](d),p=a.value;p||(n.moduleId++,p="m"+n.moduleId,l.setAttribute(a.name,p)),n.addActiveModule(u,p,f);var y=u+"-"+p;i?n.newModules[y]=f:n.currentModules[y]=f}}})}),Object.entries(this.currentModules).forEach(function(l){var a=x(l,2),h=a[0],c=a[1];if(i){var u=h.split("-"),d=u.shift(),f=u.pop();n.addActiveModule(d,f,c)}else n.initModule(c)})}},{key:"initModule",value:function(t){t.mInit(this.activeModules),t.init()}},{key:"addActiveModule",value:function(t,i,n){this.activeModules[t]?Object.assign(this.activeModules[t],gt({},i,n)):this.activeModules[t]=gt({},i,n)}},{key:"update",value:function(t){var i=this;this.init(this.app,t),Object.entries(this.currentModules).forEach(function(n){var r=x(n,2),o=r[0],l=r[1];l.mUpdate(i.activeModules)}),Object.entries(this.newModules).forEach(function(n){var r=x(n,2),o=r[0],l=r[1];i.initMo
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Se=function(){function s(e){pe(this,s),this.defaults={name:"load",loadingClass:"is-loading",loadedClass:"is-loaded",readyClass:"is-ready",transitionsPrefix:"is-",transitionsHistory:!0,enterDelay:0,exitDelay:0,loadedDelay:0,isLoaded:!1,isEntered:!1,isUrl:!1,transitionContainer:null,popstateIgnore:!1},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=navigator.userAgent.indexOf("Chrome")!=-1,this.init()}return ve(s,[{key:"init",value:function(){var t=this;window.addEventListener("popstate",function(i){return t.checkState(i)},!1),this.html.addEventListener("click",function(i){return t.checkClick(i)},!1),this.loadEls(document)}},{key:"checkClick",value:function(t){if(!t.ctrlKey&&!t.metaKey)for(var i=t.target;i&&i!==document;){if(i.matches("a")&&i.getAttribute("download")==null){var n=i.getAttribute("href");!n.startsWith("#")&&!n.startsWith("mailto:")&&!n.startsWith("tel:")&&(t.preventDefault(),this.reset(),this.getClickOptions(i));break}i=i.parentNode}}},{key:"checkState",value:function(){typeof this.popstateIgnore=="string"&&window.location.href.indexOf(this.popstateIgnore)>-1||(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 i=t.getAttribute("href"),n=t.getAttribute("target");if(n=="_blank"){window.open(i,"_blank");return}if(this.transition=="false"){window.location=i;return}this.setOptions(i,!0)}},{key:"getStateOptions",value:function(){this.transitionsHistory?this.transition=history.state:this.transition=!1;var t=window.location.href;this.setOptions(t)}},{key:"goTo",value:function(t,i,n){this.reset(),this.transition=i,this.isUrl=n,this.setOptions(t,!0)}},{key:"setOptions",value:function(t,i){var n="["+this.container+"]",r;this.transition&&this.transition!="true"&&(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,r=document.querySelector(this.transitionContainer)),r?(n=this.transitionContainer,this.oldContainer=r,this.classContainer=this.oldContainer.parentNode,this.subContainer||history.replaceState(this.transition,null,this.href),this.subContainer=!0):(this.oldContainer=document.querySelector(n),this.subContainer&&history.replaceState(this.prevTransition,null,this.href),this.subContainer=!1),this.href=t,this.parentContainer=this.oldContainer.parentNode,this.isUrl===""||this.isUrl!=null&&this.isUrl!="false"&&this.isUrl!=!1?history.pushState(this.transition,null,t):(this.oldContainer.classList.add("is-old"),this.setLoading(),this.startEnterDelay(),this.loadHref(t,n,i))}},{key:"setLoading",value:function(){this.classContainer.classList.remove(this.loadedClass,this.readyClass),this.classContainer.classList.add(this.loadingClass),this.classContainer.classList.remove(this
/*! Bundled license information:
svg4everybody/dist/svg4everybody.js:
(*! svg4everybody v2.1.9 | github.com/jonathantneal/svg4everybody *)
*/
//# sourceMappingURL=app.js.map