navigator.js (790B)
1 /** 2 * Navigation. 3 */ 4 Openrat.Navigator = new function () { 5 'use strict'; 6 7 /** 8 * Navigiert zu einer Action. 9 */ 10 this.navigateTo = function(state) { 11 Openrat.Workbench.loadNewActionState(state); 12 } 13 14 15 /** 16 * 17 * Navigiert zu einer neue Action und fügt einen neuen History-Eintrag hinzu. 18 */ 19 this.navigateToNew = function(obj) { 20 21 this.navigateTo(obj); 22 23 window.history.pushState(obj,obj.name,this.createShortUrl(obj.action,obj.id) ); 24 } 25 26 /** 27 * Setzt den State für den aktuellen History-Eintrag. 28 * @param obj 29 */ 30 this.toActualHistory = function(obj) { 31 window.history.replaceState(obj,obj.name,this.createShortUrl(obj.action,obj.id) ); 32 } 33 34 35 36 this.createShortUrl = function(action,id) { 37 return './#/'+action+(id?'/'+id:''); 38 } 39 40 41 }