1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.Ng1LocationServices = void 0;
|
4 |
|
5 | var core_1 = require("@uirouter/core");
|
6 | var core_2 = require("@uirouter/core");
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | var Ng1LocationServices = (function () {
|
12 | function Ng1LocationServices($locationProvider) {
|
13 |
|
14 | this._urlListeners = [];
|
15 | this.$locationProvider = $locationProvider;
|
16 | var _lp = core_2.val($locationProvider);
|
17 | core_2.createProxyFunctions(_lp, this, _lp, ['hashPrefix']);
|
18 | }
|
19 | |
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | Ng1LocationServices.monkeyPatchPathParameterType = function (router) {
|
32 | var pathType = router.urlMatcherFactory.type('path');
|
33 | pathType.encode = function (x) {
|
34 | return x != null ? x.toString().replace(/(~|\/)/g, function (m) { return ({ '~': '~~', '/': '~2F' }[m]); }) : x;
|
35 | };
|
36 | pathType.decode = function (x) {
|
37 | return x != null ? x.toString().replace(/(~~|~2F)/g, function (m) { return ({ '~~': '~', '~2F': '/' }[m]); }) : x;
|
38 | };
|
39 | };
|
40 |
|
41 | Ng1LocationServices.prototype.dispose = function () { };
|
42 | Ng1LocationServices.prototype.onChange = function (callback) {
|
43 | var _this = this;
|
44 | this._urlListeners.push(callback);
|
45 | return function () { return core_2.removeFrom(_this._urlListeners)(callback); };
|
46 | };
|
47 | Ng1LocationServices.prototype.html5Mode = function () {
|
48 | var html5Mode = this.$locationProvider.html5Mode();
|
49 | html5Mode = core_2.isObject(html5Mode) ? html5Mode.enabled : html5Mode;
|
50 | return html5Mode && this.$sniffer.history;
|
51 | };
|
52 | Ng1LocationServices.prototype.baseHref = function () {
|
53 | return this._baseHref || (this._baseHref = this.$browser.baseHref() || this.$window.location.pathname);
|
54 | };
|
55 | Ng1LocationServices.prototype.url = function (newUrl, replace, state) {
|
56 | if (replace === void 0) { replace = false; }
|
57 | if (core_1.isDefined(newUrl))
|
58 | this.$location.url(newUrl);
|
59 | if (replace)
|
60 | this.$location.replace();
|
61 | if (state)
|
62 | this.$location.state(state);
|
63 | return this.$location.url();
|
64 | };
|
65 | Ng1LocationServices.prototype._runtimeServices = function ($rootScope, $location, $sniffer, $browser, $window) {
|
66 | var _this = this;
|
67 | this.$location = $location;
|
68 | this.$sniffer = $sniffer;
|
69 | this.$browser = $browser;
|
70 | this.$window = $window;
|
71 |
|
72 | $rootScope.$on('$locationChangeSuccess', function (evt) { return _this._urlListeners.forEach(function (fn) { return fn(evt); }); });
|
73 | var _loc = core_2.val($location);
|
74 |
|
75 | core_2.createProxyFunctions(_loc, this, _loc, ['replace', 'path', 'search', 'hash']);
|
76 |
|
77 | core_2.createProxyFunctions(_loc, this, _loc, ['port', 'protocol', 'host']);
|
78 | };
|
79 | return Ng1LocationServices;
|
80 | }());
|
81 | exports.Ng1LocationServices = Ng1LocationServices;
|
82 |
|
\ | No newline at end of file |