freifunkmanager/webroot/js/navigo.js

2 lines
7.6 KiB
JavaScript
Raw Normal View History

2017-05-09 20:40:18 +02:00
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Navigo",[],e):"object"==typeof exports?exports.Navigo=e():t.Navigo=e()}(this,function(){return function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return t[o].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e){"use strict";function n(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function o(){return!("undefined"==typeof window||!window.history||!window.history.pushState)}function r(t,e,n){this.root=null,this._routes=[],this._useHash=e,this._hash="undefined"==typeof n?"#":n,this._paused=!1,this._destroyed=!1,this._lastRouteResolved=null,this._notFoundHandler=null,this._defaultHandler=null,this._usePushState=!e&&o(),this._onLocationChange=this._onLocationChange.bind(this),t?this.root=e?t.replace(/\/$/,"/"+this._hash):t.replace(/\/$/,""):e&&(this.root=this._cLoc().split(this._hash)[0].replace(/\/$/,"/"+this._hash)),this._listen(),this.updatePageLinks()}function i(t){return t instanceof RegExp?t:t.replace(/\/+$/,"").replace(/^\/+/,"/")}function s(t,e){return 0===e.length?null:t?t.slice(1,t.length).reduce(function(t,n,o){return null===t&&(t={}),t[e[o]]=n,t},null):null}function u(t){var e,n=[];return e=t instanceof RegExp?t:new RegExp(i(t).replace(r.PARAMETER_REGEXP,function(t,e,o){return n.push(o),r.REPLACE_VARIABLE_REGEXP}).replace(r.WILDCARD_REGEXP,r.REPLACE_WILDCARD)+r.FOLLOWED_BY_SLASH_REGEXP,r.MATCH_REGEXP_FLAGS),{regexp:e,paramNames:n}}function a(t){return t.replace(/\/$/,"").split("/").length}function h(t,e){return a(e)-a(t)}function l(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.map(function(e){var n=u(e.route),o=n.regexp,r=n.paramNames,i=t.match(o),a=s(i,r);return!!i&&{match:i,route:e,params:a}}).filter(function(t){return t})}function d(t,e){return l(t,e)[0]||!1}function c(t,e){var n=l(t,e.filter(function(t){var e=i(t.route);return""!==e&&"*"!==e})),o=i(t);return n.length>0?n.map(function(e){return i(t.substr(0,e.match.index))}).reduce(function(t,e){return e.length<t.length?e:t},o):o}function f(){return!!("undefined"!=typeof window&&"onhashchange"in window)}function _(t){return t.split(/\?(.*)?$/).slice(1).join("")}function p(t,e,n){var r=t.split(/\?(.*)?$/)[0];return"undefined"==typeof n&&(n="#"),o()&&!e&&(r=r.split(n)[0]),r}function v(t,e,n){return e&&e.hooks&&"object"===R(e.hooks)?void(e.hooks.before?e.hooks.before(function(){var o=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];o&&(t(),e.hooks.after&&e.hooks.after(n))},n):e.hooks.after&&(t(),e.hooks.after&&e.hooks.after(n))):void t()}function g(t,e,n){if(o()&&!e)return!1;if(!t.match(n))return!1;var r=t.split(n);return r.length<2||""===r[1]}Object.defineProperty(e,"__esModule",{value:!0});var R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};r.prototype={helpers:{match:d,root:c,clean:i},navigate:function(t,e){var n;return t=t||"",this._usePushState?(n=(e?"":this._getRoot()+"/")+t.replace(/^\/+/,"/"),n=n.replace(/([^:])(\/{2,})/g,"$1/"),history[this._paused?"replaceState":"pushState"]({},"",n),this.resolve()):"undefined"!=typeof window&&(t=t.replace(new RegExp("^"+this._hash),""),window.location.href=window.location.href.replace(/#$/,"").replace(new RegExp(this._hash+".*$"),"")+this._hash+t),this},on:function(){for(var t=this,e=arguments.length,n=Array(e),o=0;o<e;o++)n[o]=arguments[o];if("function"==typeof n[0])this._defaultHandler={handler:n[0],hooks:n[1]};else if(n.length>=2)if("/"===n[0]){var r=n[1];"object"===R(n[1])&&(r=n[1].uses),this._defaultHandler={handler:r,hooks:n[2]}}else this._add(n[0],n[1],n[2]);else if("object"===R(n[0])){var i=Object.keys(n[0]).sort(h);i.forEach(function(e){t.on(e,n[0][e])})}return this},off:function(t){return null!==this._defaultHandler&&t===this._defaul
//# sourceMappingURL=navigo.min.js.map