@htmlguyllc/jpack
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -1,1 +0,1 @@ | ||
!function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=9)}([function(t,e,n){"use strict";n.d(e,"a",function(){return i});const i={getElement:function(t,e,n){if((t=this.getElements(t,e)).length>1&&n)throw"Too many DOM elements found in getElement for "+JSON.stringify(t);return t[0]},getElements:function(t,e){e=void 0!==e&&e;let n=[];if(void 0!==t&&t)if(t instanceof Element||t instanceof HTMLDocument)n.push(t);else if("string"==typeof t)n=(n=document.querySelectorAll(t))?Array.from(n):n;else{if(!(t instanceof jQuery))throw"Invalid value provided to getElements: "+JSON.stringify(t);t.length&&(n=t.toArray())}else;if(!n.length&&e)throw"Failed to get array of DOM elements for "+JSON.stringify(t);return n},remove:function(t){return this.getElements(t).forEach(function(t){t.parentNode.removeChild(t)}),this},replaceElWithHTML:function(t,e){if("string"!=typeof e)throw`${e} is not a string`;t=this.getElement(t);let n=(new DOMParser).parseFromString(e,"text/html");return n=t.parentNode.insertBefore(n.documentElement.querySelector("body").childNodes[0],t),t.remove(),n},exists:function(t){return this.getElements(t).length},multipleExist:function(t){return this.getElements(t).length>1}}},function(t,e,n){"use strict";n.d(e,"a",function(){return r});var i=n(0);const r={onClick:function(t,e){return this.onEventPreventDefault(t,"click",e)},offClick(t,e){return this.offEventPreventDefault(t,"click",e)},onSubmit:function(t,e){return this.onEventPreventDefault(t,"submit",e)},offSubmit:function(t,e){return this.offEventPreventDefault(t,"submit",e)},onChange:function(t,e){return this.on(t,"change",e)},offChange:function(t,e){return this.off(t,"change",e)},onEventPreventDefault:function(t,e,n){const r=i.a.getElements(t);return r.length?(r.forEach(function(t){t.addEventListener(e,function(t){return t.preventDefault(),n.call(this,[t]),!1})}),r):t},offEventPreventDefault:function(t,e,n){const r=i.a.getElements(t);return r.length?(r.forEach(function(t){t.removeEventListener(e,function(t){return t.preventDefault(),n.call(this,[t]),!1})}),r):t},on:function(t,e,n){const r=i.a.getElements(t);return r.length?(r.forEach(function(t){t.addEventListener(e,n)}),r):t},off:function(t,e,n){const r=i.a.getElements(t);return r.length?(r.forEach(function(t){t.removeEventListener(e,n)}),r):t},trigger:function(t,e,n){const r=i.a.getElements(t);return r.length?(n=void 0===n?null:n,e=new CustomEvent(e,{detail:n}),r.forEach(function(t){t.dispatchEvent(e)}),r):t}}},function(t,e,n){"use strict";n.d(e,"a",function(){return i});const i={isDataObject:function(t,e,n,i,r){r=void 0!==r&&r,n=void 0!==n&&n;var o=JSON.stringify(t);const s=`${o} is not an object`;if(void 0===t){if(r)throw s;return!1}if(!("object"==typeof t)||null===t||Array.isArray(t)){if(r)throw s;return!1}if(Array.isArray(e)){let s=!1,a=[];const u=Object.keys(t);if(e.forEach(function(t){u.includes(t)?s=!0:a.push(t)}),!s){if(r)throw`${o} does not contain at least one of the following: `+e.join(", ");return!1}if(n&&a.length){if(r)throw`${o} is missing data: `+a.join(", ");return!1}if(i){let t=[];if(u.forEach(function(n){e.includes(n)||t.push(n)}),t.length){if(r)throw`${o} contains invalid data: `+t.join(", ");return!1}}}return!0}}},function(t,e,n){"use strict";n.d(e,"a",function(){return i}),n(11);const i={query:new URLSearchParams(window.location.search),isHttps:function(){return"https:"===window.location.protocol},getDomain:function(){return window.location.hostname||window.location.host},getDomainWithProtocol:function(){return window.location.origin},getURI:function(){return window.location.pathname},getURIWithQueryString:function(){return window.location.pathname+window.location.search},getFullURL:function(){return window.location.href},appendSlash:function(t){return"/"!==t[t.length-1]?t+"/":t}}},function(t,e,n){"use strict";n.r(e);var i=n(2);const r={getter:function(t){return"get"+this.ucfirst(t)},setter:function(t){return"set"+this.ucfirst(t)},ucfirst:function(t){return t&&t[0].toUpperCase()+t.slice(1)}};var o=n(0),s=n(1);n.d(e,"type_checks",function(){return i.a}),n.d(e,"strings",function(){return r}),n.d(e,"dom",function(){return o.a}),n.d(e,"events",function(){return s.a})},function(t,e,n){"use strict";n.r(e)},function(t,e,n){"use strict";n.r(e);var i=n(3),r=n(4);const o={keys:[],populate:function(t){const e=this;return r.type_checks.isDataObject(t,this.keys,!1,!0,!0),this.keys.forEach(function(n){void 0!==t[n]&&e[r.strings.setter(n)](t[n])}),this}};var s=n(2);let a={id:null,name:null,config:{}};"object"==typeof $site&&(a={...a,...$site});const u={...o,keys:["id","name","config"],getId:function(){return this._id},setId:function(t){return this._id=t,this},getName:function(){return this._name},setName:function(t){return this._name=t,this},getConfig:function(){return this._config},setConfig:function(t){return s.a.isDataObject(t,null,!1,!1,!0),this._config=t,this},getConfigItem:function(t){return void 0===this._config[t]?null:this._config[t]},setConfigItem:function(t,e){return this._config[t]=e,this}}.populate(a);let l={id:null,isGuest:!1,isAdmin:!1,username:null,fname:null,lname:null,email:null,phone:null,permissions:[],additionalData:{}};"object"==typeof $user&&(l={...l,...$user});const c={...o,keys:["id","isGuest","isAdmin","username","fname","lname","email","phone","permissions","additionalData"],setId:function(t){return this._id=t,this},getId:function(){return this._id},setIsGuest:function(t){return this._isGuest=t,this},getIsGuest:function(){return this._isGuest},setIsAdmin:function(t){return this._isAdmin=t,this},getIsAdmin:function(){return this._isAdmin},setUsername:function(t){return this._username=t,this},getUsername:function(){return this._username},getFname:function(){return this._fname},setFname:function(t){return this._fname=t,this},getLname:function(){return this._lname},setLname:function(t){return this._lname=t,this},getName:function(){return`${c.getFname()} ${c.getLname()}`},getEmail:function(){return this._email},setEmail:function(t){return this._email=t,this},getPhone:function(){return this._phone},setPhone:function(t){return this._phone=t,this},getPermissions:function(){return this._permissions},setPermissions:function(t){if(!Array.isArray(t))throw"setPermissions requires an array";return this._permissions=t,this},addPermission:function(t){return this._permissions.push(t),this},removePermission:function(t){return this.setPermissions(this._permissions.filter(function(e){return e!==t})),this},hasPermission:function(t){return this.getPermissions().includes(t)},getAdditionalData:function(){return this._additionalData},setAdditionalData:function(t){return s.a.isDataObject(t,null,!1,!1,!0),this._additionalData=t,this},getDataItem(t){return void 0===this._additionalData[t]?null:this._additionalData[t]},setDataItem(t,e){return this._additionalData[t]=e,this}}.populate(l);n.d(e,"request",function(){return i.a}),n.d(e,"site",function(){return u}),n.d(e,"user",function(){return c})},function(t,e,n){"use strict";n.r(e);var i=n(8),r=n.n(i),o=n(0),s=n(3),a=n(1);const u={_passthroughData:null,setPassthroughData:function(t){return this._passthroughData=t,this},clearPassthroughData:function(){return this.setPassthroughData(null),this},getPassThroughData:function(t){return this._passthroughData},_incomingElementSelector:"body",setIncomingElement:function(t){if("string"!=typeof t)throw`${t} is not a string`;this._incomingElementSelector=t},getIncomingElement:function(){return this._incomingElementSelector},_replaceElementSelector:"body",setReplaceElement:function(t){if("string"!=typeof t)throw`${t} is not a string`;this._replaceElementSelector=t},getReplaceElement:function(){return this._replaceElementSelector},load:function(t,e,n,i,s){if("string"!=typeof t)throw`Provided URL (${t}) is not a string`;if(n=void 0!==n&&n?n:this.getIncomingElement(),i=void 0!==i&&i?i:this.getReplaceElement(),s=void 0===s||s,"string"!=typeof n)throw`Provided incoming_el (${n}) is not a string`;if("string"!=typeof i)throw`Provided replace_el (${i}) is not a string`;u.showLoader(),r.a.get(t).then(function(r){u.hideLoader(),u.replacePageContent(r.data,t,n,i,s),"function"==typeof e&&window.setTimeout(function(){e(o.a.getElement(i),n,u.getPassThroughData())},105)}).catch(function(t){throw u.hideLoader(),u.triggerNavigationFailure(t),t})},loaderEnabled:!0,_loaderDelay:300,setLoaderDelay:function(t){if("number"!=typeof t)throw`${t} is not an integer`;return this._loaderDelay=t,this},getLoaderDelay:function(){return this._loaderDelay},_loaderClasses:"progress page-navigation-loader",_loaderInnerDivClasses:"progress-bar progress-bar-striped progress-bar-animated",getLoaderEl:function(){if(!this.loaderEnabled)return;if(u.navLoaderCached)return u.navLoaderCached;let t=document.createElement("div");t.classList=this._loaderClasses;let e=document.createElement("div");return e.classList=this._loaderInnerDivClasses,t.append(e),document.body.prepend(t),u.navLoaderCached=o.a.getElement(".page-navigation-loader"),u.navLoaderCached},showLoader:function(){if(this.loaderEnabled)return u.loader_timeout=window.setTimeout(function(){u.getLoaderEl().classList.add("active")},this.getLoaderDelay()),this},hideLoader:function(){if(this.loaderEnabled)return window.clearTimeout(u.loader_timeout),u.getLoaderEl().classList.remove("active"),this},parseHTML(t,e){if("string"!=typeof(e=void 0===e?null:e)&&null!==e)throw`Provided parent_el (${e}) is not a string or null`;var n=new DOMParser,i=n.parseFromString(t,"text/html"),r=i.querySelector("title");r=r?r.innerText:null;var o=i.head.getElementsByTagName("meta"),s=i.querySelectorAll('link[rel="canonical"]'),a=i.body.classList,l=t;if(e){var c=i.querySelector(e);if(!c)throw`Could not find parent selector ${e}`;l=c.outerHTML}var f=u.getRouteFromMeta(i);return n=i=null,{title:r,route:f,metas:o,links:s,body_classes:a,html:l}},getRouteFromMeta:function(t){var e=(t=void 0===t?document.head:t).querySelector('[name="current_route"]');return e=e?e.content:null},replacePageContent(t,e,n,i,r){if(r=void 0===r||r,n=void 0!==n&&n?n:this.getIncomingElement(),i=void 0!==i&&i?i:this.getReplaceElement(),"string"!=typeof e)throw`Provided url (${e}) is not a string`;if("string"!=typeof n)throw`Provided incoming_el (${n}) is not a string`;if("string"!=typeof i)throw`Provided replace_el (${i}) is not a string`;return u.triggerUnload(o.a.getElement(i),i),window.setTimeout(function(){var s=u.parseHTML(t,n);if(s.html.length){o.a.remove("meta"),document.head.append(s.metas),o.a.remove('[rel="canonical"]'),Array.from(s.links).forEach(function(t){document.head.append(t)}),document.body.classList=s.body_classes,r&&history.pushState({url:e},s.title,e),u.setTitle(s.title);const t=o.a.replaceElWithHTML(i,s.html);u.triggerOnLoad(t,n,s.route)}},100),this},reload:function(t){return t="function"!=typeof t?null:t,u.load(s.a.getFullURL(),t),this},fullReload:function(){u.showLoader(),window.location.reload()},redirect:function(t){u.showLoader(),window.location.href=t},setTitle:function(t){return document.title=t,this},onLoad:function(t){return a.a.on("body","navigation.complete",t),this},onUnload:function(t){return a.a.on("body","navigation.started",t),this},onNavigationFailure:function(t){return a.a.on("body","navigation.failed",t),this},triggerOnLoad:function(t,e,n){return n=void 0!==n?n:u.getRouteFromMeta(),a.a.trigger("body","navigation.complete",{el:t,el_selector:e,route:n,data:this.getPassThroughData()}),this},triggerUnload:function(t){return a.a.trigger("body","navigation.started",{el:t}),this},triggerNavigationFailure:function(t){return a.a.trigger("body","navigation.failed",{error:t}),this},initHistoryHandlers:function(){return window.onpushstate=function(t){console.log(t),u.load(s.a.getURIWithQueryString())},window.onpopstate=function(t){console.log(t),u.load(s.a.getURIWithQueryString(),null,null,null,!1)},this}};n.d(e,"navigation",function(){return u})},function(t,e){t.exports=axios},function(t,e,n){"use strict";n.r(e),function(t){n.d(e,"jpack",function(){return a});var i=n(7),r=n(6),o=n(5),s=n(4);const a={components:i,objects:r,plugin_wrappers:o,utilities:s,goGlobal:function(t){t="string"==typeof t?t+".":null,[i,r,o,s].forEach(function(e){for(var n in e)e.hasOwnProperty(n)&&(window[t+n]=e[n])})}};t.jpack=a}.call(this,n(10))},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e){t.exports=url-search-params-polyfill}]); | ||
!function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=9)}([function(t,e,n){"use strict";n.d(e,"a",function(){return i});const i={getElement:function(t,e,n){if((t=this.getElements(t,e)).length>1&&n)throw"Too many DOM elements found in getElement for "+JSON.stringify(t);return t[0]},getElements:function(t,e){e=void 0!==e&&e;let n=[];if(void 0!==t&&t)if(t instanceof Element||t instanceof HTMLDocument)n.push(t);else if("string"==typeof t)n=(n=document.querySelectorAll(t))?Array.from(n):n;else{if(!(t instanceof jQuery))throw"Invalid value provided to getElements: "+JSON.stringify(t);t.length&&(n=t.toArray())}else;if(!n.length&&e)throw"Failed to get array of DOM elements for "+JSON.stringify(t);return n},remove:function(t){return this.getElements(t).forEach(function(t){t.parentNode.removeChild(t)}),this},replaceElWithHTML:function(t,e){if("string"!=typeof e)throw`${e} is not a string`;t=this.getElement(t);let n=(new DOMParser).parseFromString(e,"text/html");return n=t.parentNode.insertBefore(n.documentElement.querySelector("body").childNodes[0],t),t.remove(),n},exists:function(t){return this.getElements(t).length},multipleExist:function(t){return this.getElements(t).length>1}}},function(t,e,n){"use strict";n.d(e,"a",function(){return r});var i=n(0);const r={onClick:function(t,e){return this.onEventPreventDefault(t,"click",e)},offClick(t,e){return this.offEventPreventDefault(t,"click",e)},onSubmit:function(t,e){return this.onEventPreventDefault(t,"submit",e)},offSubmit:function(t,e){return this.offEventPreventDefault(t,"submit",e)},onChange:function(t,e){return this.on(t,"change",e)},offChange:function(t,e){return this.off(t,"change",e)},onEventPreventDefault:function(t,e,n){const r=i.a.getElements(t);return r.length?(r.forEach(function(t){t.addEventListener(e,function(t){return t.preventDefault(),n.call(this,[t]),!1})}),r):t},offEventPreventDefault:function(t,e,n){const r=i.a.getElements(t);return r.length?(r.forEach(function(t){t.removeEventListener(e,function(t){return t.preventDefault(),n.call(this,[t]),!1})}),r):t},on:function(t,e,n){const r=i.a.getElements(t);return r.length?(r.forEach(function(t){t.addEventListener(e,n)}),r):t},off:function(t,e,n){const r=i.a.getElements(t);return r.length?(r.forEach(function(t){t.removeEventListener(e,n)}),r):t},trigger:function(t,e,n){const r=i.a.getElements(t);return r.length?(n=void 0===n?null:n,e=new CustomEvent(e,{detail:n}),r.forEach(function(t){t.dispatchEvent(e)}),r):t}}},function(t,e,n){"use strict";n.d(e,"a",function(){return i});const i={isDataObject:function(t,e,n,i,r){r=void 0!==r&&r,n=void 0!==n&&n;var o=JSON.stringify(t);const s=`${o} is not an object`;if(void 0===t){if(r)throw s;return!1}if(!("object"==typeof t)||null===t||Array.isArray(t)){if(r)throw s;return!1}if(Array.isArray(e)){let s=!1,a=[];const u=Object.keys(t);if(e.forEach(function(t){u.includes(t)?s=!0:a.push(t)}),!s){if(r)throw`${o} does not contain at least one of the following: `+e.join(", ");return!1}if(n&&a.length){if(r)throw`${o} is missing data: `+a.join(", ");return!1}if(i){let t=[];if(u.forEach(function(n){e.includes(n)||t.push(n)}),t.length){if(r)throw`${o} contains invalid data: `+t.join(", ");return!1}}}return!0}}},function(t,e,n){"use strict";n.d(e,"a",function(){return i}),n(11);const i={query:new URLSearchParams(window.location.search),isHttps:function(){return"https:"===window.location.protocol},getDomain:function(){return window.location.hostname||window.location.host},getDomainWithProtocol:function(){return window.location.origin},getURI:function(){return window.location.pathname},getURIWithQueryString:function(){return window.location.pathname+window.location.search},getFullURL:function(){return window.location.href},appendSlash:function(t){return"/"!==t[t.length-1]?t+"/":t}}},function(t,e,n){"use strict";n.r(e);var i=n(2);const r={getter:function(t){return"get"+this.ucfirst(t)},setter:function(t){return"set"+this.ucfirst(t)},ucfirst:function(t){return t&&t[0].toUpperCase()+t.slice(1)}};var o=n(0),s=n(1);n.d(e,"type_checks",function(){return i.a}),n.d(e,"strings",function(){return r}),n.d(e,"dom",function(){return o.a}),n.d(e,"events",function(){return s.a})},function(t,e,n){"use strict";n.r(e)},function(t,e,n){"use strict";n.r(e);var i=n(3),r=n(4);const o={keys:[],populate:function(t){const e=this;return r.type_checks.isDataObject(t,this.keys,!1,!0,!0),this.keys.forEach(function(n){void 0!==t[n]&&e[r.strings.setter(n)](t[n])}),this}};var s=n(2);let a={id:null,name:null,config:{}};"object"==typeof $site&&(a={...a,...$site});const u={...o,keys:["id","name","config"],getId:function(){return this._id},setId:function(t){return this._id=t,this},getName:function(){return this._name},setName:function(t){return this._name=t,this},getConfig:function(){return this._config},setConfig:function(t){return s.a.isDataObject(t,null,!1,!1,!0),this._config=t,this},getConfigItem:function(t){return void 0===this._config[t]?null:this._config[t]},setConfigItem:function(t,e){return this._config[t]=e,this}}.populate(a);let l={id:null,isGuest:!1,isAdmin:!1,username:null,fname:null,lname:null,email:null,phone:null,permissions:[],additionalData:{}};"object"==typeof $user&&(l={...l,...$user});const c={...o,keys:["id","isGuest","isAdmin","username","fname","lname","email","phone","permissions","additionalData"],setId:function(t){return this._id=t,this},getId:function(){return this._id},setIsGuest:function(t){return this._isGuest=t,this},getIsGuest:function(){return this._isGuest},setIsAdmin:function(t){return this._isAdmin=t,this},getIsAdmin:function(){return this._isAdmin},setUsername:function(t){return this._username=t,this},getUsername:function(){return this._username},getFname:function(){return this._fname},setFname:function(t){return this._fname=t,this},getLname:function(){return this._lname},setLname:function(t){return this._lname=t,this},getName:function(){return`${c.getFname()} ${c.getLname()}`},getEmail:function(){return this._email},setEmail:function(t){return this._email=t,this},getPhone:function(){return this._phone},setPhone:function(t){return this._phone=t,this},getPermissions:function(){return this._permissions},setPermissions:function(t){if(!Array.isArray(t))throw"setPermissions requires an array";return this._permissions=t,this},addPermission:function(t){return this._permissions.push(t),this},removePermission:function(t){return this.setPermissions(this._permissions.filter(function(e){return e!==t})),this},hasPermission:function(t){return this.getPermissions().includes(t)},getAdditionalData:function(){return this._additionalData},setAdditionalData:function(t){return s.a.isDataObject(t,null,!1,!1,!0),this._additionalData=t,this},getDataItem(t){return void 0===this._additionalData[t]?null:this._additionalData[t]},setDataItem(t,e){return this._additionalData[t]=e,this}}.populate(l);n.d(e,"request",function(){return i.a}),n.d(e,"site",function(){return u}),n.d(e,"user",function(){return c})},function(t,e,n){"use strict";n.r(e);var i=n(8),r=n.n(i),o=n(0),s=n(3),a=n(1);const u={_passthroughData:null,setPassthroughData:function(t){return this._passthroughData=t,this},clearPassthroughData:function(){return this.setPassthroughData(null),this},getPassThroughData:function(t){return this._passthroughData},_incomingElementSelector:"body",setIncomingElement:function(t){if("string"!=typeof t)throw`${t} is not a string`;this._incomingElementSelector=t},getIncomingElement:function(){return this._incomingElementSelector},_replaceElementSelector:"body",setReplaceElement:function(t){if("string"!=typeof t)throw`${t} is not a string`;this._replaceElementSelector=t},getReplaceElement:function(){return this._replaceElementSelector},load:function(t,e,n,i,s){if("string"!=typeof t)throw`Provided URL (${t}) is not a string`;if(n=void 0!==n&&n?n:this.getIncomingElement(),i=void 0!==i&&i?i:this.getReplaceElement(),s=void 0===s||s,"string"!=typeof n)throw`Provided incoming_el (${n}) is not a string`;if("string"!=typeof i)throw`Provided replace_el (${i}) is not a string`;u.showLoader(),r.a.get(t).then(function(r){u.hideLoader(),u.replacePageContent(r.data,t,n,i,s),"function"==typeof e&&window.setTimeout(function(){e(o.a.getElement(i),n,u.getPassThroughData())},105)}).catch(function(t){throw u.hideLoader(),u.triggerNavigationFailure(t),t})},loaderEnabled:!0,_loaderDelay:300,setLoaderDelay:function(t){if("number"!=typeof t)throw`${t} is not an integer`;return this._loaderDelay=t,this},getLoaderDelay:function(){return this._loaderDelay},_loaderClasses:"progress page-navigation-loader",_loaderInnerDivClasses:"progress-bar progress-bar-striped progress-bar-animated",getLoaderEl:function(){if(!this.loaderEnabled)return;if(u.navLoaderCached)return u.navLoaderCached;let t=document.createElement("div");t.classList=this._loaderClasses;let e=document.createElement("div");return e.classList=this._loaderInnerDivClasses,t.append(e),document.body.prepend(t),u.navLoaderCached=o.a.getElement(".page-navigation-loader"),u.navLoaderCached},showLoader:function(){if(this.loaderEnabled)return u.loader_timeout=window.setTimeout(function(){u.getLoaderEl().classList.add("active")},this.getLoaderDelay()),this},hideLoader:function(){if(this.loaderEnabled)return window.clearTimeout(u.loader_timeout),u.getLoaderEl().classList.remove("active"),this},parseHTML(t,e){if("string"!=typeof(e=void 0===e?null:e)&&null!==e)throw`Provided parent_el (${e}) is not a string or null`;var n=new DOMParser,i=n.parseFromString(t,"text/html"),r=i.querySelector("title");r=r?r.innerText:null;var o=i.head.getElementsByTagName("meta"),s=i.querySelectorAll('link[rel="canonical"]'),a=i.body.classList,l=t;if(e){var c=i.querySelector(e);if(!c)throw`Could not find parent selector ${e}`;l=c.outerHTML}var f=u.getRouteFromMeta(i);return n=i=null,{title:r,route:f,metas:o,links:s,body_classes:a,html:l}},getRouteFromMeta:function(t){var e=(t=void 0===t?document.head:t).querySelector('[name="current_route"]');return e=e?e.content:null},replacePageContent(t,e,n,i,r){if(r=void 0===r||r,n=void 0!==n&&n?n:this.getIncomingElement(),i=void 0!==i&&i?i:this.getReplaceElement(),"string"!=typeof e)throw`Provided url (${e}) is not a string`;if("string"!=typeof n)throw`Provided incoming_el (${n}) is not a string`;if("string"!=typeof i)throw`Provided replace_el (${i}) is not a string`;return u.triggerUnload(o.a.getElement(i),i,this.getRouteFromMeta()),window.setTimeout(function(){var s=u.parseHTML(t,n);if(s.html.length){o.a.remove("meta"),document.head.append(s.metas),o.a.remove('[rel="canonical"]'),Array.from(s.links).forEach(function(t){document.head.append(t)}),document.body.classList=s.body_classes,r&&history.pushState({url:e},s.title,e),u.setTitle(s.title);const t=o.a.replaceElWithHTML(i,s.html);u.triggerOnLoad(t,n,s.route)}},100),this},reload:function(t){return t="function"!=typeof t?null:t,u.load(s.a.getFullURL(),t),this},fullReload:function(){u.showLoader(),window.location.reload()},redirect:function(t){u.showLoader(),window.location.href=t},setTitle:function(t){return document.title=t,this},onLoad:function(t){return a.a.on("body","navigation.complete",t),this},onUnload:function(t){return a.a.on("body","navigation.started",t),this},onNavigationFailure:function(t){return a.a.on("body","navigation.failed",t),this},triggerOnLoad:function(t,e,n){return n=void 0!==n?n:u.getRouteFromMeta(),a.a.trigger("body","navigation.complete",{el:t,el_selector:e,route:n,data:this.getPassThroughData()}),this},triggerUnload:function(t,e,n){return a.a.trigger("body","navigation.started",{el:t,el_selector:e,route:n}),this},triggerNavigationFailure:function(t){return a.a.trigger("body","navigation.failed",{error:t}),this},initHistoryHandlers:function(){return window.onpushstate=function(t){console.log(t),u.load(s.a.getURIWithQueryString())},window.onpopstate=function(t){console.log(t),u.load(s.a.getURIWithQueryString(),null,null,null,!1)},this}};n.d(e,"navigation",function(){return u})},function(t,e){t.exports=axios},function(t,e,n){"use strict";n.r(e),function(t){n.d(e,"jpack",function(){return a});var i=n(7),r=n(6),o=n(5),s=n(4);const a={components:i,objects:r,plugin_wrappers:o,utilities:s,goGlobal:function(t){t="string"==typeof t?t+".":null,[i,r,o,s].forEach(function(e){for(var n in e)e.hasOwnProperty(n)&&(window[t+n]=e[n])})}};t.jpack=a}.call(this,n(10))},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e){t.exports=url-search-params-polyfill}]); |
@@ -353,3 +353,3 @@ import axios from 'axios'; | ||
//get replace_el again because it was replaced | ||
navigation.triggerUnload(dom.getElement(replace_el), replace_el); | ||
navigation.triggerUnload(dom.getElement(replace_el), replace_el, this.getRouteFromMeta()); | ||
@@ -506,4 +506,4 @@ //very slight 100ms delay to let the on unload handlers run first | ||
*/ | ||
triggerUnload: function(el){ | ||
events.trigger('body', 'navigation.started', {el:el}); | ||
triggerUnload: function(el, el_selector, route){ | ||
events.trigger('body', 'navigation.started', {el:el, el_selector:el_selector, route:route}); | ||
@@ -510,0 +510,0 @@ return this; |
{ | ||
"name": "@htmlguyllc/jpack", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"description": "Core Javascript Library of Everyday Objects, Events, and Utilities", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
138
README.md
@@ -102,14 +102,14 @@ # jPack | ||
Method/Property | Params | Return | Notes | ||
Method/Property | Params (name:type) | Return | Notes | ||
--- | --- | --- | --- | ||
setPassthroughData|mixed|self|set data you want provided in the onload method for the next page | ||
setPassthroughData|data:mixed|self|set data you want provided in the onload method for the next page | ||
clearPassthroughData| |self|must be called manually or the data will persist infinitely. you can set an onload callback to clear this every time | ||
getPassthroughData| |mixed|returns the data you set | ||
setIncomingElement|string|self|a selector string for the element being retrieved from another page which contains the HTML you want put on the current page | ||
setIncomingElement|el:string|self|a selector string for the element being retrieved from another page which contains the HTML you want put on the current page | ||
getIncomingElement| |string| | ||
setReplaceElement|string|self|a selector string for the element on the current page you want the new HTML to replace | ||
setReplaceElement|el:string|self|a selector string for the element on the current page you want the new HTML to replace | ||
getReplaceElement| |string| | ||
load|string, function/null, string/null, string/null, bool|void|pulls content from the provided URL and puts it on the current page - also swaps out the page title, metas, and much more | ||
load|url:string, callback:function/null, incoming_el:string/null, replace_el:string/null, push_state:bool|void|pulls content from the provided URL and puts it on the current page - also swaps out the page title, metas, and much more | ||
loaderEnabled|n/a|bool|property to toggle the slow request loader on/off | ||
setLoaderDelay|int|self|set how long a request should take in ms before the loader displays | ||
setLoaderDelay|delay:int|self|set how long a request should take in ms before the loader displays | ||
getLoaderDelay| |self| | ||
@@ -119,15 +119,15 @@ getLoaderEl| |Element| | ||
hideLoader| |self|clears the loader timeout and hides it | ||
parseHTML|string, string|object|parses HTML from the request to get key components like metas and the HTML to be displayed | ||
getRouteFromMeta|string|string|retrieves the value of a meta tag named "current_route" to be passed in the onload event to help trigger page-specific JS | ||
replacePageContent|string, string, string, string, bool|self|replaces HTML on the page with the new content, updates metas, runs the unload and load callbacks and more | ||
reload|function|self|reloads the current page using .load() | ||
parseHTML|html:string, parent_el:string|object|parses HTML from the request to get key components like metas and the HTML to be displayed | ||
getRouteFromMeta|html:string|string|retrieves the value of a meta tag named "current_route" to be passed in the onload event to help trigger page-specific JS | ||
replacePageContent|html:string, url:string, incoming_el:string, replace_el:string, push_state:bool | self|replaces HTML on the page with the new content, updates metas, runs the unload and load callbacks and more | ||
reload|callback:function|self|reloads the current page using .load() | ||
fullReload| |void|performs a full browser refresh of the current page | ||
redirect|string|void|redirects the user to a new page (no XHR request) | ||
setTitle|string|self|sets the page title | ||
onLoad|function|self|add an onload callback (runs 100ms after unload) | ||
onUnload|function|self|add an unload callback | ||
onNavigationFailure|function|self|add a callback when the load() request fails - the error message is provided in event.detail.error | ||
triggerOnLoad|mixed, string, string|self|triggers all onload callbacks | ||
triggerUnload|mixed|self|triggers all unload callbacks | ||
triggerNavigationFailure|string|self|triggers the nav failure and provides an error message | ||
redirect|url:string|void|redirects the user to a new page (no XHR request) | ||
setTitle|title:string|self|sets the page title | ||
onLoad|callback:function|self|add an onload callback (runs 100ms after unload) | ||
onUnload|callback:function|self|add an unload callback | ||
onNavigationFailure|callback:function|self|add a callback when the load() request fails - the error message is provided in event.detail.error | ||
triggerOnLoad|el:mixed, el_selector:string, route:string|self|triggers all onload callbacks | ||
triggerUnload|el:mixed, el_selector:string, route:string|self|triggers all unload callbacks | ||
triggerNavigationFailure|error:string|self|triggers the nav failure and provides an error message | ||
initHistoryHandlers| |self|sets event listeners to handle back/forward navigation in the user's browser | ||
@@ -237,5 +237,5 @@ | ||
Method/Property | Params | Return | Notes | ||
Method/Property | Params (name:type) | Return | Notes | ||
--- | --- | --- | --- | ||
fromURL|string, object|self|instantiate a new form.fromURL('/my-form-url', options); to grab a form from another page and insert it into the current | ||
fromURL|url:string, options:object|self|instantiate a new form.fromURL('/my-form-url', options); to grab a form from another page and insert it into the current | ||
@@ -351,3 +351,3 @@ ##### To use: | ||
Method/Property | Params | Return | Notes | ||
Method/Property | Params (name:type) | Return | Notes | ||
--- | --- | --- | --- | ||
@@ -361,3 +361,3 @@ query|n/a|URLSearchParams|see https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams#Methods | ||
getFullURL| |string| | ||
appendSlash|string|string|adds a slash (if there isn't already one) to the end of a string. | ||
appendSlash|string:string|string|adds a slash (if there isn't already one) to the end of a string. | ||
@@ -379,13 +379,13 @@ ##### To use: | ||
Method/Property | Params | Return | Notes | ||
Method/Property | Params (name:type) | Return | Notes | ||
--- | --- | --- | --- | ||
getId| |string/int| | ||
setId|string/int|this| | ||
setId|id:string/int|this| | ||
getName| |string|this | ||
setName|string|this| | ||
setName|name:string|this| | ||
getConfig| |object|this | ||
setConfig|object|this|overwrites all config | ||
setConfig|config:object|this|overwrites all config | ||
getConfigItem| |mixed|returns an individual item from config | ||
setConfigItem|string,mixed|this|sets the value of an individual item in config | ||
populate|object|this|sets provided values all at once (id,name,config) | ||
setConfigItem|key:string,val:mixed|this|sets the value of an individual item in config | ||
populate|data:object|this|sets provided values all at once (id,name,config) | ||
@@ -431,28 +431,28 @@ ##### To populate with data: | ||
getId| |string/int| | ||
setId|string/int|this| | ||
setId|id:string/int|this| | ||
getIsGuest| |bool|if your site has users who don't login but still interact and have a user record (like guest checkout) | ||
setIsGuest|bool|this| | ||
setIsGuest|is_guest:bool|this| | ||
setIsAdmin| |bool|if your site has users who have ultimate permissions and you want to do something based on that | ||
setIsGuest|bool|this| | ||
setIsGuest|is_admin:bool|this| | ||
getUsername| |string| | ||
setUsername|string|this| | ||
setUsername|username:string|this| | ||
getFname| |string| | ||
setFname|string|this| | ||
setFname|fname:string|this| | ||
getLname| |string| | ||
setLname|string|this| | ||
setLname|lname:string|this| | ||
getName| |string|returns fname and lname concatenated with a space | ||
getEmail| |string| | ||
setEmail|string|this| | ||
setEmail|email:string|this| | ||
getPhone| |string| | ||
setPhone|string|this| | ||
setPhone|phone:string|this| | ||
getPermissions| |array| | ||
setPermissions|array|this| | ||
addPermission|string/int|this| | ||
removePermission|string/int|this| | ||
hasPermission|string/int|bool| | ||
setPermissions|permissions:array|this| | ||
addPermission|permission:string/int|this| | ||
removePermission|permission:string/int|this| | ||
hasPermission|permission:string/int|bool| | ||
getAdditionalData| |object|set any additional data about this user that doesn't fit the default getters and setters here (a better idea would be to extend this object with your custom properties/methods) | ||
setAdditionalData|object|this| | ||
getDataItem|string|mixed|returns a single value from the additional data object/array | ||
setDataItem|string, mixed|sets a single value in the additional data array/object | ||
populate|object|this|sets provided values all at once (id, isGuest, isAdmin, etc) | ||
setAdditionalData|data:object|this| | ||
getDataItem|key:string|mixed|returns a single value from the additional data object/array | ||
setDataItem|key:string, val:mixed|sets a single value in the additional data array/object | ||
populate|data:object|this|sets provided values all at once (id, isGuest, isAdmin, etc) | ||
@@ -504,7 +504,7 @@ ##### To populate with data: | ||
Method/Property | Params | Return | Notes | ||
Method/Property | Params (name:type) | Return | Notes | ||
--- | --- | --- | --- | ||
ucfirst|string|string|capitalizes the first letter of a string like ucfirst in PHP | ||
getter|string|string|creates a getter method name from a string | ||
setter|string|string|creates a setter method name from a string | ||
ucfirst|string:string|string|capitalizes the first letter of a string like ucfirst in PHP | ||
getter|string:string|string|creates a getter method name from a string | ||
setter|string:string|string|creates a setter method name from a string | ||
@@ -524,10 +524,10 @@ ##### To Use: | ||
Method/Property | Params | Return | Notes | ||
Method/Property | Params (name:type) | Return | Notes | ||
--- | --- | --- | --- | ||
getElement|mixed, bool, bool|Element/HTMLDocument/null|returns a native DOM element for whatever you provide (selector string, array of elements, single element, jQuery wrapped DOM element, etc) | ||
getElements|mixed, bool|array|same as getElement, except it returns all matches | ||
remove|mixed|this|removes elements from the DOM - uses .getElements() | ||
replaceElWithHTML|mixed,string|Element|replaces an element in the DOM with HTML and returns a reference to the new Element | ||
exists|mixed|bool|checks to see if it exists in the DOM | ||
multipleExist|mixed|bool|checks to see if more than 1 instance exists in the DOM | ||
getElement|el:mixed, error_on_none:bool, error_on_multiple:bool|Element/HTMLDocument/null|returns a native DOM element for whatever you provide (selector string, array of elements, single element, jQuery wrapped DOM element, etc) | ||
getElements|el:mixed, error_on_none:bool|array|same as getElement, except it returns all matches | ||
remove|el:mixed|this|removes elements from the DOM - uses .getElements() | ||
replaceElWithHTML|el:mixed, html:string|Element|replaces an element in the DOM with HTML and returns a reference to the new Element | ||
exists|el:mixed|bool|checks to see if it exists in the DOM | ||
multipleExist|el:mixed|bool|checks to see if more than 1 instance exists in the DOM | ||
@@ -556,5 +556,5 @@ | ||
Method/Property | Params | Return | Notes | ||
Method/Property | Params (name:type) | Return | Notes | ||
--- | --- | --- | --- | ||
isDataObject|object, array, bool, bool, bool|bool|validates that an object contains data and not a dom element, array, null or anything else that would normally return true when you call typeof | ||
isDataObject|value:object, keys:array, require_all_keys:bool, block_other_keys:bool, throw_error:bool|bool|validates that an object contains data and not a dom element, array, null or anything else that would normally return true when you call typeof | ||
@@ -579,15 +579,15 @@ ##### To Use: | ||
Method/Property | Params | Return | Notes | ||
Method/Property | Params (name:type) | Return | Notes | ||
--- | --- | --- | --- | ||
onClick|mixed, function|array|prevents the browser's default so you can handle link clicks and form submissions with less code | ||
offClick|mixed, function|array|removes the handler you added using onClick | ||
onSubmit|mixed, function|array|same as .onClick() but for submit | ||
offSubmit|mixed, function|array|same as .offClick() but for submit | ||
onChange|mixed, function|array|adds an on change handler but does NOT preventDefault - mostly exists for consistency | ||
offChange|mixed, function|array|removes the handler you added using .onChange() | ||
onEventPreventDefault|mixed, string, function|array|attaches an event handler and prevents the default browser action | ||
offEventPreventDefault|mixed, string, function|array|removes the handler you attached with .onEventPreventDefault() | ||
on|mixed, string, function|array|attaches an event listener | ||
off|mixed, string, function|array|removes an event listener | ||
trigger|mixed, string, mixed|array|triggers an event on an element/elements - uses .getElements() | ||
onClick|el:mixed, callback:function|array|prevents the browser's default so you can handle link clicks and form submissions with less code | ||
offClick|el:mixed, callback:function|array|removes the handler you added using onClick | ||
onSubmit|el:mixed, callback:function|array|same as .onClick() but for submit | ||
offSubmit|el:mixed, callback:function|array|same as .offClick() but for submit | ||
onChange|el:mixed, callback:function|array|adds an on change handler but does NOT preventDefault - mostly exists for consistency | ||
offChange|el:mixed, callback:function|array|removes the handler you added using .onChange() | ||
onEventPreventDefault|el:mixed, event:string, callback:function|array|attaches an event handler and prevents the default browser action | ||
offEventPreventDefault|el:mixed, event:string, callback:function|array|removes the handler you attached with .onEventPreventDefault() | ||
on|el:mixed, event:string, callback:function|array|attaches an event listener | ||
off|el:mixed, event:string, callback:function|array|removes an event listener | ||
trigger|el:mixed, event:string, event_options:mixed|array|triggers an event on an element/elements - uses .getElements() | ||
@@ -594,0 +594,0 @@ ##### To Use: |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
242131