@htmlguyllc/jpack
Advanced tools
Comparing version 2.0.9 to 3.0.1
@@ -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,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}]); | ||
!function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},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 r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},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 r});const r={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 i});var r=n(0);const i={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 i=r.a.getElements(t);return i.length?(i.forEach(function(t){t.addEventListener(e,function(t){return t.preventDefault(),n.call(this,[t]),!1})}),i):t},offEventPreventDefault:function(t,e,n){const i=r.a.getElements(t);return i.length?(i.forEach(function(t){t.removeEventListener(e,function(t){return t.preventDefault(),n.call(this,[t]),!1})}),i):t},on:function(t,e,n){const i=r.a.getElements(t);return i.length?(i.forEach(function(t){t.addEventListener(e,n)}),i):t},off:function(t,e,n){const i=r.a.getElements(t);return i.length?(i.forEach(function(t){t.removeEventListener(e,n)}),i):t},trigger:function(t,e,n){const i=r.a.getElements(t);return i.length?(n=void 0===n?null:n,e=new CustomEvent(e,{detail:n}),i.forEach(function(t){t.dispatchEvent(e)}),i):t}}},function(t,e,n){"use strict";n.d(e,"a",function(){return r});const r={isDataObject:function(t,e,n,r,i){i=void 0!==i&&i,n=void 0!==n&&n;var o=JSON.stringify(t);const s=`${o} is not an object`;if(void 0===t){if(i)throw s;return!1}if(!("object"==typeof t)||null===t||Array.isArray(t)){if(i)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(i)throw`${o} does not contain at least one of the following: `+e.join(", ");return!1}if(n&&a.length){if(i)throw`${o} is missing data: `+a.join(", ");return!1}if(r){let t=[];if(u.forEach(function(n){e.includes(n)||t.push(n)}),t.length){if(i)throw`${o} contains invalid data: `+t.join(", ");return!1}}}return!0}}},function(t,e,n){"use strict";n.d(e,"a",function(){return r}),n(11);const r={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 r=n(2);const i={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 r.a}),n.d(e,"strings",function(){return i}),n.d(e,"dom",function(){return o.a}),n.d(e,"events",function(){return s.a})},function(t,e){t.exports=axios},function(t,e,n){"use strict";n.r(e)},function(t,e,n){"use strict";n.r(e);var r=n(3),i=n(2),o=n(4);class s{constructor(){}populate(t){const e=this;if(void 0===this._keys)throw"Cannot populate object if _keys property is not set";return o.type_checks.isDataObject(t,this._keys,!1,!0,!0),this._keys.forEach(function(n){void 0!==t[n]&&e[o.strings.setter(n)](t[n])}),this}}const a={id:null,name:null,config:{}};class u extends s{constructor(t){if(super(),this._keys=["id","name","config"],void 0===t)return this;t={...a,...t},this.populate(t)}getId(){return this._id}setId(t){return this._id=t,this}getName(){return this._name}setName(t){return this._name=t,this}getConfig(){return this._config}setConfig(t){return i.a.isDataObject(t,null,!1,!1,!0),this._config=t,this}getConfigItem(t){return void 0===this._config[t]?null:this._config[t]}setConfigItem(t,e){return this._config[t]=e,this}}const l={id:null,isGuest:!1,isAdmin:!1,username:null,fname:null,lname:null,email:null,phone:null,permissions:[],additionalData:{}};class c extends s{constructor(t){if(super(),this._keys=["id","isGuest","isAdmin","username","fname","lname","email","phone","permissions","additionalData"],void 0===t)return this;t={...l,...t},this.populate(t)}setId(t){return this._id=t,this}getId(){return this._id}setIsGuest(t){return this._isGuest=t,this}getIsGuest(){return this._isGuest}setIsAdmin(t){return this._isAdmin=t,this}getIsAdmin(){return this._isAdmin}setUsername(t){return this._username=t,this}getUsername(){return this._username}getFname(){return this._fname}setFname(t){return this._fname=t,this}getLname(){return this._lname}setLname(t){return this._lname=t,this}getName(){return`${user.getFname()} ${user.getLname()}`}getEmail(){return this._email}setEmail(t){return this._email=t,this}getPhone(){return this._phone}setPhone(t){return this._phone=t,this}getPermissions(){return this._permissions}setPermissions(t){if(!Array.isArray(t))throw"setPermissions requires an array";return this._permissions=t,this}addPermission(t){return this._permissions.push(t),this}removePermission(t){return this.setPermissions(this._permissions.filter(function(e){return e!==t})),this}hasPermission(t){return this.getPermissions().includes(t)}getAdditionalData(){return this._additionalData}setAdditionalData(t){return i.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}}n.d(e,"request",function(){return r.a}),n.d(e,"User",function(){return c}),n.d(e,"Site",function(){return u})},function(t,e,n){"use strict";n.r(e);var r=n(5),i=n.n(r),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,r,s){if("string"!=typeof t)throw`Provided URL (${t}) is not a string`;if(n=void 0!==n&&n?n:this.getIncomingElement(),r=void 0!==r&&r?r:this.getReplaceElement(),s=void 0===s||s,"string"!=typeof n)throw`Provided incoming_el (${n}) is not a string`;if("string"!=typeof r)throw`Provided replace_el (${r}) is not a string`;u.showLoader(),i.a.get(t).then(function(i){u.hideLoader(),u.replacePageContent(i.data,t,n,r,s),"function"==typeof e&&window.setTimeout(function(){e(o.a.getElement(r),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,r=n.parseFromString(t,"text/html"),i=r.querySelector("title");i=i?i.innerText:null;var o=r.head.getElementsByTagName("meta"),s=r.querySelectorAll('link[rel="canonical"]'),a=r.body.classList,l=t;if(e){var c=r.querySelector(e);if(!c)throw`Could not find parent selector ${e}`;l=c.outerHTML}var h=u.getRouteFromMeta(r);return n=r=null,{title:i,route:h,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,r,i){if(i=void 0===i||i,n=void 0!==n&&n?n:this.getIncomingElement(),r=void 0!==r&&r?r: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 r)throw`Provided replace_el (${r}) is not a string`;return u.triggerUnload(o.a.getElement(r),r,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,i&&history.pushState({url:e},s.title,e),u.setTitle(s.title);const t=o.a.replaceElWithHTML(r,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(2);n(12);const l={xhrSubmit:!0,submitURL:null,submitMethod:null,onError:function(t,e,n){},onSuccess:function(t,e){},validateForm:function(t){t.classList.add("was-validated");const e=!t.querySelector(":invalid");return e&&t.classList.remove("was-validated"),e}},c={incomingElementSelector:null,insertIntoElement:null,onload:function(t){return this}};class h{constructor(t,e){if("object"!=typeof(e=void 0===e?{}:e))throw`${e} is not an object`;e={...l,...e},this.setForm(t),this.setValidateCallback(e.validateForm),this.setXHRSubmit(e.xhrSubmit),this.setSubmitMethod(e.submitMethod),this.setSubmitURL(e.submitURL),this.onSuccess(e.onSuccess),this.onError(e.onError)}setValidateCallback(t){if("function"!=typeof t)throw`${t} is not a function`;return this._validateCallback=t,this}validate(t){return void 0===t&&(t=this.getForm()),this._validateCallback(t)}setForm(t){if(!t||void 0===t)throw"Form element is required";if(!(t=o.a.getElement(t,!0,!0)))throw"Invalid form element received";return this._form=t,this}getForm(){return this._form}setXHRSubmit(t){return this._xhrSubmit=!!t,this}setSubmitMethod(t){if("string"!=typeof t&&null!==t)throw`${t} is not a string or null`;return this._submitMethod=t,this}getSubmitMethod(){return this._submitMethod}setSubmitURL(t){if("string"!=typeof t&&"function"!=typeof t&&null!==t)throw`${t} is not a string, function, or null`;return this._submitURL=t,this}getSubmitURL(t){return"function"==typeof this._submitURL?this._submitURL(t):this._submitURL}attachSubmitHandler(t){if(this._xhrSubmit){if(!(t=void 0===t?this.getForm():o.a.getElement(t)))throw"Form element not received, cannot attach submit handler";var e=this;return t.addEventListener("submit",function(n){return!e._xhrSubmit||(n.preventDefault(),e.submitForm(t),!1)}),this}}onSuccess(t){if("function"!=typeof t)throw`${t} is not a function`;return void 0===this._onSuccess&&(this._onSuccess=[]),this._onSuccess.push(t),this}clearOnSuccessCallbacks(){return this._onSuccess=[],this}triggerOnSuccess(t,e){return void 0!==this._onSuccess&&(this._onSuccess.forEach(function(n){n(t,e)}),this)}onError(t){if("function"!=typeof t)throw`${t} is not a function`;return void 0===this._onError&&(this._onError=[]),this._onError.push(t),this}clearOnErrorCallbacks(){return this._onError=[],this}triggerOnError(t,e,n){return void 0!==this._onError&&(this._onError.forEach(function(r){r(t,e,n)}),this)}submitForm(t){var e=this;let n=this.getSubmitURL(t);null===n&&t.attributes.action&&(n=t.action),n=n||this.getURL();let r=this.getSubmitMethod();if(null===r&&void 0!==t.attributes.method&&(r=t.method),r=r?r.toLowerCase():"post",!this.validate(t))return!1;u.showLoader();const o=Array.from(this.getFormValues(t),t=>t.map(encodeURIComponent).join("=")).join("&");return i()({url:n,method:r,data:o}).then(function(n){u.hideLoader();let r=n.data;try{r="string"==typeof r?JSON.parse(r):r}catch(t){}if("string"==typeof r){if("string"==typeof e.getIncomingElementSelector()){const n=u.parseHTML(r,e.getIncomingElementSelector());return n.html.length?e.insertForm(n,r,t):e.triggerOnError(`${e.getIncomingElementSelector()} could not be found in response from the server`,r,t)}return e.insertForm({html:r},r,t)}if("object"==typeof r)return r.html?e.insertForm({html:r.html},r,t):r.error?e.triggerOnError(r.error,r,t):e.triggerOnSuccess(r,t)}).catch(function(t){throw u.hideLoader(),t}),this}getFormValues(t){return new FormData(t)}}class f extends h{constructor(t,e){if(super(null,e),"string"!=typeof t)throw`${t} is not a string`;if("object"!=typeof(e=void 0===e?{}:e))throw`${e} is not an object`;e={...c,...e},this.setURL(t),this.setIncomingElementSelector(e.incomingElementSelector),this.setInsertIntoElement(e.insertIntoElement),this.onload(e.onload)}setForm(t){return this._form=t,this}setURL(t){if("string"!=typeof t)throw`${t} is not a string`;return this._url=t,this}getURL(){return this._url}setIncomingElementSelector(t){if(null!==t&&"string"!=typeof t)throw`${t} is not a string or null value`;return this._incomingElementSelector=t,this}getIncomingElementSelector(){return this._incomingElementSelector}setInsertIntoElement(t){this._insertIntoElement=t}getInsertIntoElement(){return this._insertIntoElement}getForm(){var t=this;u.showLoader(),i.a.get(this.getURL()).then(function(e){u.hideLoader();let n=e.data;try{n="string"==typeof n?JSON.parse(n):n}catch(t){}if("string"==typeof n){if("string"==typeof t.getIncomingElementSelector()){const e=u.parseHTML(n,t.getIncomingElementSelector());return t.insertForm(e,n)}return t.insertForm({html:n})}if("object"==typeof n&&void 0!==n.html)return t.insertForm({html:n.html},n);throw`Unexpected server response ${n}`}).catch(function(t){throw u.hideLoader(),t})}insertForm(t,e,n){let r=this.getInsertIntoElement();if(null===r)throw"Cannot determine where to insert form. Overwrite insertForm() or provide insertIntoElement";return(r=o.a.getElement(r,!0)).innerHTML=t.html,n=r.querySelector("form"),this.attachSubmitHandler(n),this.triggerOnload(n),r}onload(t){if("function"!=typeof t)throw`${t} is not a function`;return void 0===this._onload&&(this._onload=[]),this._onload.push(t),this}clearOnloadCallbacks(){return this._onload=[],this}triggerOnload(t){return void 0!==this._onload&&(this._onload.forEach(function(e){e(t)}),this)}}n.d(e,"navigation",function(){return u}),n.d(e,"XHRForm",function(){return h}),n.d(e,"FormFromURL",function(){return f})},function(t,e,n){"use strict";n.r(e),function(t){n.d(e,"jpack",function(){return a});var r=n(8),i=n(7),o=n(6),s=n(4);const a={components:r,objects:i,plugin_wrappers:o,utilities:s,goGlobal:function(t){t="string"==typeof t?t+".":null,[r,i,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,e){t.exports=formdata-polyfill}]); |
import {navigation} from "./navigation"; | ||
import {XHRForm, FormFromURL} from './form'; | ||
export {navigation}; | ||
export {navigation, XHRForm, FormFromURL}; |
import {request} from "./request"; | ||
import {site} from "./site"; | ||
import {user} from "./user"; | ||
import {Site} from "./Site"; | ||
import {User} from "./User"; | ||
export {request, site, user}; | ||
export {request, User, Site}; |
@@ -1,6 +0,6 @@ | ||
import {abstract_object} from "../abstract_object"; | ||
import {type_checks} from "../../utilities/type_checks"; | ||
import {AbstractObject} from "../AbstractObject"; | ||
//create an object of default values | ||
let site_defaults = { | ||
const site_defaults = { | ||
id: null, | ||
@@ -10,37 +10,50 @@ name:null, | ||
}; | ||
//override defaults from $site (if defined) | ||
if( typeof $site === "object" ) site_defaults = {...site_defaults, ...$site}; | ||
/** | ||
* | ||
* Provides you with easy access to information about the current website (for multi-tenant applications) | ||
* Site (for multi-tenant applications) | ||
* | ||
* @type {{setName: (function(*): site), getConfigItem: (function(*): null), getName: (function(): *), populate: (function(*): site), setConfigItem: (function(*, *): site), name: null, setId: (function(*): site), getId: (function(): *), id: null, config: (site_defaults.config|{}), getConfig: (function(): *), setConfig: (function(*): site)}} | ||
* Class for storing and interacting with the current website's id, name, and config options | ||
* | ||
*/ | ||
export const site = {...abstract_object, ...{ | ||
keys: ['id', 'name', 'config'], | ||
export class Site extends AbstractObject { | ||
constructor(data){ | ||
super(); | ||
getId: function(){ | ||
this._keys = ['id', 'name', 'config']; | ||
if( typeof data === "undefined" ) return this; | ||
//extend user_defaults with incoming data | ||
data = {...site_defaults, ...data}; | ||
this.populate(data); | ||
} | ||
getId() { | ||
return this._id; | ||
}, | ||
setId: function(id){ | ||
} | ||
setId(id) { | ||
this._id = id; | ||
return this; | ||
}, | ||
} | ||
//gets the website's name | ||
getName: function(){ | ||
getName() { | ||
return this._name; | ||
}, | ||
setName: function(name){ | ||
} | ||
setName(name) { | ||
this._name = name; | ||
return this; | ||
}, | ||
} | ||
//returns all config data | ||
getConfig: function(){ | ||
getConfig() { | ||
return this._config; | ||
}, | ||
} | ||
//sets all config data using the provided object | ||
setConfig: function(config){ | ||
setConfig(config) { | ||
//must be a data object, even if it's empty | ||
@@ -51,13 +64,14 @@ type_checks.isDataObject(config, null, false, false, true); | ||
return this; | ||
}, | ||
} | ||
//returns an individual config value or null if it's not defined | ||
getConfigItem: function(key){ | ||
getConfigItem(key) { | ||
return typeof this._config[key] === "undefined" ? null : this._config[key]; | ||
}, | ||
} | ||
//adds or updates a value in the config object | ||
setConfigItem: function(key, val){ | ||
setConfigItem(key, val) { | ||
this._config[key] = val; | ||
return this; | ||
} | ||
}}.populate(site_defaults); | ||
} |
@@ -1,6 +0,6 @@ | ||
import {abstract_object} from "../abstract_object"; | ||
import {type_checks} from "../../utilities/type_checks"; | ||
import {AbstractObject} from "../AbstractObject"; | ||
//create an object of default values | ||
let user_defaults = { | ||
const user_defaults = { | ||
id: null, | ||
@@ -17,90 +17,99 @@ isGuest:false, | ||
}; | ||
//override defaults from $user (if defined) | ||
if( typeof $user === "object" ) user_defaults = {...user_defaults, ...$user}; | ||
/** | ||
* | ||
* Provides you with easy access to user information and allows you to perform permission checks | ||
* User | ||
* | ||
* @type {{getIsGuest: (function(): *), getPhone: (function(): *), getLname: (function(): *), getName: (function(): string), setIsGuest: (function(*): user), keys: string[], addPermission: (function(*=): user), getId: (function(): *), setAdditionalData: (function(*): user), setPermissions: (function(*): user), getUsername: (function(): *), setFname: (function(*): user), getFname: (function(): *), setId: (function(*): user), setUsername: (function(*): user), setLname: (function(*): user), getAdditionalData: (function(): *), getPermissions: (function(): *), setPhone: (function(*): user), removePermission: (function(*): user), getDataItem(*): null, setIsAdmin: (function(*): user), setDataItem(*, *): *, getIsAdmin: (function(): *), setEmail: (function(*): user), hasPermission: (function(*=): (*|boolean)), getEmail: (function(): *)}} | ||
* Class for storing and interacting with a user and their permissions | ||
* | ||
*/ | ||
export const user = {...abstract_object, ...{ | ||
//user object keys | ||
keys: ['id', 'isGuest', 'isAdmin', 'username', 'fname', 'lname', 'email', 'phone', 'permissions', 'additionalData'], | ||
export class User extends AbstractObject{ | ||
constructor(data) { | ||
super(); | ||
this._keys = ['id', 'isGuest', 'isAdmin', 'username', 'fname', 'lname', 'email', 'phone', 'permissions', 'additionalData']; | ||
if( typeof data === "undefined" ) return this; | ||
setId: function(id){ | ||
//extend user_defaults with incoming data | ||
data = {...user_defaults, ...data}; | ||
this.populate(data); | ||
} | ||
setId(id){ | ||
this._id = id; | ||
return this; | ||
}, | ||
getId: function(){ | ||
} | ||
getId(){ | ||
return this._id; | ||
}, | ||
} | ||
setIsGuest: function(is_guest){ | ||
setIsGuest(is_guest){ | ||
this._isGuest = is_guest; | ||
return this; | ||
}, | ||
getIsGuest: function(){ | ||
} | ||
getIsGuest(){ | ||
return this._isGuest; | ||
}, | ||
} | ||
setIsAdmin: function(is_admin){ | ||
setIsAdmin(is_admin){ | ||
this._isAdmin = is_admin; | ||
return this; | ||
}, | ||
getIsAdmin: function(){ | ||
} | ||
getIsAdmin(){ | ||
return this._isAdmin; | ||
}, | ||
} | ||
setUsername: function(username){ | ||
setUsername(username){ | ||
this._username = username; | ||
return this; | ||
}, | ||
getUsername: function(){ | ||
} | ||
getUsername(){ | ||
return this._username; | ||
}, | ||
} | ||
getFname: function(){ | ||
getFname(){ | ||
return this._fname; | ||
}, | ||
setFname: function(first_name){ | ||
} | ||
setFname(first_name){ | ||
this._fname = first_name; | ||
return this; | ||
}, | ||
} | ||
getLname: function(){ | ||
getLname(){ | ||
return this._lname; | ||
}, | ||
setLname: function(last_name){ | ||
} | ||
setLname(last_name){ | ||
this._lname = last_name; | ||
return this; | ||
}, | ||
} | ||
//quick way to get fname and lname | ||
getName: function(){ | ||
getName(){ | ||
return `${user.getFname()} ${user.getLname()}`; | ||
}, | ||
} | ||
getEmail: function(){ | ||
getEmail(){ | ||
return this._email; | ||
}, | ||
setEmail: function(email){ | ||
} | ||
setEmail(email){ | ||
this._email = email; | ||
return this; | ||
}, | ||
} | ||
getPhone: function(){ | ||
getPhone(){ | ||
return this._phone; | ||
}, | ||
setPhone: function(phone){ | ||
} | ||
setPhone(phone){ | ||
this._phone = phone; | ||
return this; | ||
}, | ||
} | ||
//returns all permissions for this user | ||
getPermissions: function(){ | ||
getPermissions(){ | ||
return this._permissions; | ||
}, | ||
} | ||
//sets all permissions for this user | ||
setPermissions: function(permissions){ | ||
setPermissions(permissions){ | ||
if( !Array.isArray(permissions) ) throw "setPermissions requires an array"; | ||
@@ -110,10 +119,10 @@ | ||
return this; | ||
}, | ||
} | ||
//adds a single permission to this user | ||
addPermission: function(permission){ | ||
addPermission(permission){ | ||
this._permissions.push(permission); | ||
return this; | ||
}, | ||
} | ||
//Removes a single permission from this user | ||
removePermission: function(permission){ | ||
removePermission(permission){ | ||
this.setPermissions(this._permissions.filter(function(ele){ | ||
@@ -123,14 +132,14 @@ return ele !== permission; | ||
return this; | ||
}, | ||
} | ||
//returns true if the user has the provided permission | ||
hasPermission: function(permission){ | ||
hasPermission(permission){ | ||
return this.getPermissions().includes(permission); | ||
}, | ||
} | ||
//returns all additional data for this user | ||
getAdditionalData: function(){ | ||
getAdditionalData(){ | ||
return this._additionalData; | ||
}, | ||
} | ||
//sets all additional data for this user | ||
setAdditionalData: function(additional_data){ | ||
setAdditionalData(additional_data){ | ||
//must be a data object, even if it's empty | ||
@@ -141,7 +150,7 @@ type_checks.isDataObject(additional_data, null, false, false, true); | ||
return this; | ||
}, | ||
} | ||
//returns a single additional data value for this user | ||
getDataItem(key){ | ||
return typeof this._additionalData[key] === "undefined" ? null : this._additionalData[key]; | ||
}, | ||
} | ||
//sets a single additional data value for this user | ||
@@ -152,2 +161,2 @@ setDataItem(key, val){ | ||
} | ||
}}.populate(user_defaults); //immediately populate from user_defaults | ||
} |
{ | ||
"name": "@htmlguyllc/jpack", | ||
"version": "2.0.9", | ||
"version": "3.0.1", | ||
"description": "Core Javascript Library of Everyday Objects, Events, and Utilities", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -14,3 +14,3 @@ # jPack | ||
Components | components | navigation, XHRForm, FormFromURL | ||
Objects | objects | request, site, user | ||
Objects | objects | request, Site, User | ||
Plugin Wrappers | plugin_wrappers | None Yet. | ||
@@ -34,3 +34,3 @@ Utilities | utilities | strings, data_types, dom, events | ||
//now you can take advantage of the jpack library | ||
var user_id = jpack.objects.user.getId(); | ||
var fname = jpack.utilities.strings.ucfirst('bob'); //Bob | ||
@@ -40,3 +40,3 @@ //or if you're feeling lazy, you can tie all jpack components to window for shorter use. | ||
var user_id = jp.user.getId(); | ||
jp.strings.ucfirst('bob'); | ||
@@ -47,3 +47,3 @@ //or if you're insanely lazy and want to cross your fingers that nothing conflicts, you can tie | ||
var user_id = user.getId(); | ||
strings.ucfirst('bob'); | ||
}; | ||
@@ -81,3 +81,3 @@ </script> | ||
import {jpack} from '@htmlguyllc/jpack'; | ||
jpack.objects.user.getId(); | ||
jpack.utilities.strings.ucfirst('bob'); | ||
``` | ||
@@ -89,3 +89,4 @@ | ||
jpack.objects.user.getId(); | ||
//now use it | ||
jpack.utilities.strings.ucfirst('bob'); | ||
``` | ||
@@ -393,5 +394,7 @@ | ||
##### To populate with data: | ||
##### Instantiation with current site data: | ||
The easy way: Create an object named $site with values from your server (prior to including jpack) | ||
The easy way: | ||
Create an object named $site with values from your server (prior to including jpack) | ||
```html | ||
@@ -407,6 +410,13 @@ <script> | ||
``` | ||
Then instantiate the Site class in your JS file somewhere | ||
```javascript | ||
const cur_site = new Site($site); | ||
cur_site.getId(); | ||
``` | ||
The harder way: Perform an XHR request to grab site details via a JSON API, then run the populate method on the site object. | ||
The harder way: | ||
Perform an XHR request to grab site details via a JSON API, then run the populate method on the site object. | ||
```javascript | ||
import {site} from '@htmlguyllc/jpack/es/objects'; | ||
import {Site} from '@htmlguyllc/jpack/es/objects'; | ||
@@ -416,19 +426,14 @@ //this example uses jQuery's shorthand AJAX call, you can use axios or any request you want | ||
//don't forget error handling! | ||
site.populate(JSON.parse(data)); | ||
const cur_site = new Site(JSON.parse(data)); | ||
}); | ||
``` | ||
##### To Use: | ||
Of course you can use this class for any site, not just the current one, but this is the intended usage. | ||
```javascript | ||
import {site} from '@htmlguyllc/jpack/es/objects'; | ||
var site_id = site.getId(); | ||
``` | ||
### -User | ||
_Designed for sites with user accounts/guest accounts. This object stores a user's details and allows for front-end permission checks._ | ||
_Designed for sites with user accounts/guest accounts. This class stores a user's details and allows for front-end permission checks._ | ||
Method/Property | Params | Return | Notes | ||
--- | --- | --- | --- | ||
constructor|data:object|self| | ||
getId| |string/int| | ||
@@ -462,5 +467,7 @@ setId|id:string/int|this| | ||
##### To populate with data: | ||
##### Instantiation with current user data: | ||
The easy way: Create an object named $user with values from your server (prior to including jpack) | ||
The easy way: | ||
Create an object named $user with values from your server | ||
```html | ||
@@ -481,21 +488,22 @@ <script> | ||
``` | ||
Then instantiate the User class in your JS file somewhere | ||
```javascript | ||
const cur_user = new User($user); | ||
cur_user.getId(); | ||
``` | ||
The harder way: Perform an XHR request to grab site details via a JSON API, then run the populate method on the site object. | ||
The harder way: | ||
Perform an XHR request to grab site details via a JSON API, then run the populate method on the site object. | ||
```javascript | ||
import {user} from '@htmlguyllc/jpack/es/objects'; | ||
import {User} from '@htmlguyllc/jpack/es/objects'; | ||
$.get('/my-user-info-endpoint.php', function(data){ | ||
//don't forget error handling! | ||
user.populate(JSON.parse(data)); | ||
const cur_user = new User(JSON.parse(data)); | ||
}); | ||
``` | ||
##### To use: | ||
Of course you can use this class for any User not just the current one, but that's the intended usage. | ||
```javascript | ||
import {site} from '@htmlguyllc/jpack/es/objects'; | ||
var site_id = site.getId(); | ||
``` | ||
## - Plugin Wrappers - | ||
@@ -502,0 +510,0 @@ None yet. |
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
308008
4046
607