angular2
Version:
Angular 2 - a web framework for modern web apps
64 lines • 3.16 kB
JavaScript
;var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc);
switch (arguments.length) {
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);
case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);
case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);
}
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var dom_adapter_1 = require('angular2/src/platform/dom/dom_adapter');
var core_1 = require('angular2/core');
/**
* `PlatformLocation` encapsulates all of the direct calls to platform APIs.
* This class should not be used directly by an application developer. Instead, use
* {@link Location}.
*/
var PlatformLocation = (function () {
function PlatformLocation() {
this._init();
}
// This is moved to its own method so that `MockPlatformLocationStrategy` can overwrite it
/** @internal */
PlatformLocation.prototype._init = function () {
this._location = dom_adapter_1.DOM.getLocation();
this._history = dom_adapter_1.DOM.getHistory();
};
PlatformLocation.prototype.getBaseHrefFromDOM = function () { return dom_adapter_1.DOM.getBaseHref(); };
PlatformLocation.prototype.onPopState = function (fn) {
dom_adapter_1.DOM.getGlobalEventTarget('window').addEventListener('popstate', fn, false);
};
PlatformLocation.prototype.onHashChange = function (fn) {
dom_adapter_1.DOM.getGlobalEventTarget('window').addEventListener('hashchange', fn, false);
};
Object.defineProperty(PlatformLocation.prototype, "pathname", {
get: function () { return this._location.pathname; },
set: function (newPath) { this._location.pathname = newPath; },
enumerable: true,
configurable: true
});
Object.defineProperty(PlatformLocation.prototype, "search", {
get: function () { return this._location.search; },
enumerable: true,
configurable: true
});
Object.defineProperty(PlatformLocation.prototype, "hash", {
get: function () { return this._location.hash; },
enumerable: true,
configurable: true
});
PlatformLocation.prototype.pushState = function (state, title, url) {
this._history.pushState(state, title, url);
};
PlatformLocation.prototype.forward = function () { this._history.forward(); };
PlatformLocation.prototype.back = function () { this._history.back(); };
PlatformLocation = __decorate([
core_1.Injectable(),
__metadata('design:paramtypes', [])
], PlatformLocation);
return PlatformLocation;
})();
exports.PlatformLocation = PlatformLocation;
//# sourceMappingURL=platform_location.js.map