UNPKG

graft-react

Version:

react admin and helper components for graft-db

42 lines (41 loc) 1.32 kB
"use strict"; function prependSlash(url) { return (url && url.substring(0, 1) !== '/') ? '/' + url : url; } var PreviewHistoryManager = (function () { function PreviewHistoryManager(navigator) { this.navigator = navigator; } PreviewHistoryManager.prototype.init = function (navigateHistory) { this.navigateHistory = navigateHistory; if (this.disabled) { return; } }; PreviewHistoryManager.prototype.addHistory = function (url, _replace) { if (this.disabled) { return; } this.navigator.update({ purl: url }); }; PreviewHistoryManager.prototype.getCurrentUrl = function () { var purl = this.navigator.data().purl; return purl || ''; }; PreviewHistoryManager.prototype.getHref = function (url) { if (url == null) { throw new Error('The Url is null'); } return prependSlash(url); }; PreviewHistoryManager.prototype.getUrl = function (hrefElement) { return hrefElement.pathname.substring(0) + hrefElement.search; }; PreviewHistoryManager.prototype.stop = function () { if (this.disabled) { return; } }; return PreviewHistoryManager; }()); exports.PreviewHistoryManager = PreviewHistoryManager;