mirror of
https://github.com/penpot/penpot.git
synced 2026-05-19 23:13:39 +00:00
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
/**
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* Copyright (c) KALEIDOS INC
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
goog.provide("app.util.browser_history");
|
|
goog.require("goog.history.Html5History");
|
|
|
|
goog.scope(function() {
|
|
const self = app.util.browser_history;
|
|
const Html5History = goog.history.Html5History;
|
|
|
|
class TokenTransformer {
|
|
retrieveToken(pathPrefix, location) {
|
|
return location.pathname.substr(pathPrefix.length) + location.search;
|
|
}
|
|
|
|
createUrl(token, pathPrefix, location) {
|
|
return pathPrefix + token;
|
|
}
|
|
}
|
|
|
|
self.create = function() {
|
|
const instance = new Html5History(null, new TokenTransformer());
|
|
instance.setUseFragment(true);
|
|
return instance;
|
|
};
|
|
|
|
self.enable_BANG_ = function(instance) {
|
|
instance.setEnabled(true);
|
|
};
|
|
|
|
self.disable_BANG_ = function(instance) {
|
|
instance.setEnabled(false);
|
|
};
|
|
|
|
self.set_token_BANG_ = function(instance, token) {
|
|
instance.setToken(token);
|
|
}
|
|
|
|
self.replace_token_BANG_ = function(instance, token) {
|
|
instance.replaceToken(token);
|
|
}
|
|
});
|