silverstripe-framework/javascript/dist/router.js

51 lines
1.3 KiB
JavaScript
Raw Normal View History

(function (global, factory) {
2016-04-05 07:07:52 +02:00
if (typeof define === "function" && define.amd) {
define('ss.router', ['exports', 'page.js'], factory);
} else if (typeof exports !== "undefined") {
factory(exports, require('page.js'));
} else {
var mod = {
exports: {}
};
factory(mod.exports, global.page);
global.ssRouter = mod.exports;
}
})(this, function (exports, _page) {
2016-04-05 07:07:52 +02:00
'use strict';
2016-04-05 07:07:52 +02:00
Object.defineProperty(exports, "__esModule", {
value: true
});
2016-04-05 07:07:52 +02:00
var _page2 = _interopRequireDefault(_page);
2016-04-05 07:07:52 +02:00
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
2016-04-05 07:07:52 +02:00
function show(pageShow) {
return function (path, state, dispatch, push) {
var el = document.createElement('a');
2016-04-07 13:43:43 +02:00
var pathWithSearch = void 0;
2016-04-05 07:07:52 +02:00
el.href = path;
2016-04-07 13:43:43 +02:00
pathWithSearch = el.pathname;
2016-04-05 07:07:52 +02:00
if (el.search) {
2016-04-07 13:43:43 +02:00
pathWithSearch += el.search;
2016-04-05 07:07:52 +02:00
}
2016-04-07 13:43:43 +02:00
return pageShow(pathWithSearch, state, dispatch, push);
2016-04-05 07:07:52 +02:00
};
}
2016-04-12 00:25:02 +02:00
function routeAppliesToCurrentLocation(route) {
var r = new _page2.default.Route(route);
return r.match(_page2.default.current, {});
}
2016-04-05 07:07:52 +02:00
_page2.default.show = show(_page2.default.show);
2016-04-12 00:25:02 +02:00
_page2.default.routeAppliesToCurrentLocation = routeAppliesToCurrentLocation;
2016-04-05 07:07:52 +02:00
exports.default = _page2.default;
});