tb-vue-hash-router
Version:
A Vue hash-router-plugin
1 lines • 8.98 kB
JavaScript
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("vue")):"function"==typeof define&&define.amd?define("tb19-vue-hash-router",["vue"],n):"object"==typeof exports?exports["tb19-vue-hash-router"]=n(require("vue")):e["tb19-vue-hash-router"]=n(e.vue)}(window,function(e){return function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=5)}([function(e,n,t){var r=t(3);"string"==typeof r&&(r=[[e.i,r,""]]),r.locals&&(e.exports=r.locals);(0,t(6).default)("1ce3f9a7",r,!1,{})},function(n,t){n.exports=e},function(e,n,t){"use strict";var r=t(0);t.n(r).a},function(e,n,t){(e.exports=t(4)(!1)).push([e.i,"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",""])},function(e,n,t){"use strict";e.exports=function(e){var n=[];return n.toString=function(){return this.map(function(n){var t=function(e,n){var t=e[1]||"",r=e[3];if(!r)return t;if(n&&"function"==typeof btoa){var o=(i=r,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */"),a=r.sources.map(function(e){return"/*# sourceURL="+r.sourceRoot+e+" */"});return[t].concat(a).concat([o]).join("\n")}var i;return[t].join("\n")}(n,e);return n[2]?"@media "+n[2]+"{"+t+"}":t}).join("")},n.i=function(e,t){"string"==typeof e&&(e=[[null,e,""]]);for(var r={},o=0;o<this.length;o++){var a=this[o][0];null!=a&&(r[a]=!0)}for(o=0;o<e.length;o++){var i=e[o];null!=i[0]&&r[i[0]]||(t&&!i[2]?i[2]=t:t&&(i[2]="("+i[2]+") and ("+t+")"),n.push(i))}},n}},function(e,n,t){"use strict";t.r(n);var r=t(1),o=t.n(r),a=function(){var e=this.$createElement;return(this._self._c||e)(this.page,{tag:"component"})};a._withStripped=!0;var i={name:"PageRoot",data:function(){return{page:null}},created:function(){var e=this;window&&window.location&&window.location.hash?(this.page=window.location.hash.split("?")[0].substring(1)+"-page",window.location.hash="hash-router-navigation"):(this.page=this.$landingPage,window.location.hash="hash-router-navigation"),window.location.hash=this.page.split("-page")[0],this.$hashRouter.$on("Page selected",function(n){return e.page=n}),window.onhashchange=function(){"#hash-router-navigation"==window.location.hash&&window.history.forward(1)}}};t(2);var s=function(e,n,t,r,o,a,i,s){var u,c="function"==typeof e?e.options:e;if(n&&(c.render=n,c.staticRenderFns=t,c._compiled=!0),r&&(c.functional=!0),a&&(c._scopeId="data-v-"+a),i?(u=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(i)},c._ssrRegister=u):o&&(u=s?function(){o.call(this,this.$root.$options.shadowRoot)}:o),u)if(c.functional){c._injectStyles=u;var d=c.render;c.render=function(e,n){return u.call(n),d(e,n)}}else{var l=c.beforeCreate;c.beforeCreate=l?[].concat(l,u):[u]}return{exports:e,options:c}}(i,a,[],!1,null,null,null);s.options.__file="src/page-root.vue";var u=s.exports;function c(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}t.d(n,"default",function(){return d});var d=function(){function e(){!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e)}var n,t,r;return n=e,r=[{key:"install",value:function(n,t){if(!t||!t.landingPage){throw"\nNo landing page added!\nDefine a globally registered component as a landing page!\nIn main.js upon registering HashRouterPlugin:\n\nimport YourComponent from './components/your-component.js'\n\nVue.use(HashRouterPlugin, { landingPage: 'your-component' })\n\nVue.component('your-component', YourComponent)\n "}n.prototype.$navigate=e.HASH_ROUTER_CONTROLLER.navigate,n.prototype.$getRedirectParams=e.HASH_ROUTER_CONTROLLER.getRedirectParams,n.prototype.$addToQueryParams=e.HASH_ROUTER_CONTROLLER.addToQueryParams,n.prototype.$deleteQueryParam=e.HASH_ROUTER_CONTROLLER.deleteQueryParam,n.prototype.$deleteQueryParams=e.HASH_ROUTER_CONTROLLER.deleteQueryParams,n.prototype.$updateQueryParams=e.HASH_ROUTER_CONTROLLER.updateQueryParams,n.prototype.$hashRouter=e.HASH_ROUTER_CONTROLLER,n.prototype.$landingPage=t.landingPage,n.component("page-root",u)}}],(t=null)&&c(n.prototype,t),r&&c(n,r),e}();d.HASH_ROUTER_CONTROLLER=new o.a({data:{redirectParams:{}},methods:{navigate:function(e,n){this.redirectParams=n||{},window.location.hash="hash-router-navigation",window.location.hash=e.split("-page")[0],this.$emit("Page selected",e)},getRedirectParams:function(){return Object.assign({},this.redirectParams)},addToQueryParams:function(e,n){if(!this.supportsHash())return result;var t=window.location.hash;t+=window.location.hash.includes("?")?"&":"?",t+=e+"="+n,window.location.hash="hash-router-navigation",window.location.hash=t},updateQueryParams:function(e){for(var n in this.deleteQueryParams(),e)this.addToQueryParams(n,e[n])},deleteQueryParams:function(){var e=window.location.hash.split("?")[0].substring(1);window.location.hash="hash-router-navigation",window.location.hash=e},deleteQueryParam:function(e){var n=this.parseQueryParams();delete n[e],this.updateQueryParams(n)},parseQueryParams:function(){var e={};if(!this.supportsHash())return e;var n=window.location.hash.split("?")[1];return n?(n.split("&").forEach(function(n){var t=n.split("=")[0],r=n.split("=")[1];e[t]=r}),e):e},supportsHash:function(){return!(!window||!window.location||null==window.location.hash)}},created:function(){this.redirectParams=this.parseQueryParams()}})},function(e,n,t){"use strict";function r(e,n){for(var t=[],r={},o=0;o<n.length;o++){var a=n[o],i=a[0],s={id:e+":"+o,css:a[1],media:a[2],sourceMap:a[3]};r[i]?r[i].parts.push(s):t.push(r[i]={id:i,parts:[s]})}return t}t.r(n),t.d(n,"default",function(){return h});var o="undefined"!=typeof document;if("undefined"!=typeof DEBUG&&DEBUG&&!o)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var a={},i=o&&(document.head||document.getElementsByTagName("head")[0]),s=null,u=0,c=!1,d=function(){},l=null,p="data-vue-ssr-id",f="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());function h(e,n,t,o){c=t,l=o||{};var i=r(e,n);return v(i),function(n){for(var t=[],o=0;o<i.length;o++){var s=i[o];(u=a[s.id]).refs--,t.push(u)}n?v(i=r(e,n)):i=[];for(o=0;o<t.length;o++){var u;if(0===(u=t[o]).refs){for(var c=0;c<u.parts.length;c++)u.parts[c]();delete a[u.id]}}}}function v(e){for(var n=0;n<e.length;n++){var t=e[n],r=a[t.id];if(r){r.refs++;for(var o=0;o<r.parts.length;o++)r.parts[o](t.parts[o]);for(;o<t.parts.length;o++)r.parts.push(m(t.parts[o]));r.parts.length>t.parts.length&&(r.parts.length=t.parts.length)}else{var i=[];for(o=0;o<t.parts.length;o++)i.push(m(t.parts[o]));a[t.id]={id:t.id,refs:1,parts:i}}}}function g(){var e=document.createElement("style");return e.type="text/css",i.appendChild(e),e}function m(e){var n,t,r=document.querySelector("style["+p+'~="'+e.id+'"]');if(r){if(c)return d;r.parentNode.removeChild(r)}if(f){var o=u++;r=s||(s=g()),n=R.bind(null,r,o,!1),t=R.bind(null,r,o,!0)}else r=g(),n=function(e,n){var t=n.css,r=n.media,o=n.sourceMap;r&&e.setAttribute("media",r);l.ssrId&&e.setAttribute(p,n.id);o&&(t+="\n/*# sourceURL="+o.sources[0]+" */",t+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}.bind(null,r),t=function(){r.parentNode.removeChild(r)};return n(e),function(r){if(r){if(r.css===e.css&&r.media===e.media&&r.sourceMap===e.sourceMap)return;n(e=r)}else t()}}var y,w=(y=[],function(e,n){return y[e]=n,y.filter(Boolean).join("\n")});function R(e,n,t,r){var o=t?"":r.css;if(e.styleSheet)e.styleSheet.cssText=w(n,o);else{var a=document.createTextNode(o),i=e.childNodes;i[n]&&e.removeChild(i[n]),i.length?e.insertBefore(a,i[n]):e.appendChild(a)}}}])});