2 * Browser history management using Ext.util.History.
4 Ext.define("Docs.History", {
8 * Initializes history management.
11 Ext.util.History.init(function() {
12 this.navigate(Ext.util.History.getToken());
14 Ext.util.History.on("change", this.navigate, this);
17 // Parses current URL and navigates to the page
18 navigate: function(token) {
19 var url = this.parseToken(token);
20 if (url.type === "api") {
21 Docs.ClassLoader.load(url.key, true);
22 Ext.getCmp('treePanelCmp').selectClass(url.key.replace(/-.*$/, ''));
24 else if (url.type === "guide") {
25 Docs.App.setGuideMode();
26 Docs.Guides.load(url.key, true);
29 Docs.App.setIndexMode();
33 // Parses current browser location
34 parseToken: function(token) {
35 var matches = token && token.match(/\/(api|guide)\/(.*)/);
36 return matches ? {type: matches[1], key: matches[2]} : {};
42 * @param {String} token the part of URL after #
44 push: function(token) {
45 Ext.util.History.add(token);