navigator.js (806B)
1 /** 2 * Navigation. 3 * 4 * Controls the history API. 5 */ 6 export default class WorkbenchNavigator { 7 'use strict'; 8 9 /** 10 * 11 * Creates a new history entry. 12 */ 13 static navigateToNew(obj) { 14 15 window.history.pushState(obj,obj.name,WorkbenchNavigator.createShortUrl(obj.action,obj.id) ); 16 } 17 18 /** 19 * Sets the state for the current history entry. 20 * This will be called once while initializing the workbench. 21 * 22 * @param obj 23 */ 24 static toActualHistory(obj) { 25 window.history.replaceState(obj,obj.name,WorkbenchNavigator.createShortUrl(obj.action,obj.id) ); 26 } 27 28 29 /** 30 * Creates the URL for the browser adress bar. 31 * 32 * @param action action 33 * @param id ID 34 * @return string 35 */ 36 static createShortUrl(action,id) { 37 return './#/'+action+(id?'/'+id:''); 38 } 39 }