Commit bd876027 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Make history navigation work with guides.

parent 4acbce4a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ Ext.define("Docs.App", {
        Ext.Array.forEach(Ext.query("#api-overview .guides a"), function(el) {
            Ext.get(el).addListener('click', function() {
                this.setGuideMode();
                Docs.Guides.load(el.href);
                Docs.Guides.load(el.className);
            }, this, {preventDefault: true});
        }, this);

+6 −3
Original line number Diff line number Diff line
@@ -7,11 +7,14 @@ Ext.define("Docs.Guides", {
    /**
     * Loads guide from given URL.
     *
     * @param {String} url
     * @param {String} name  name of the guide
     * @param {Boolean} noHistory  true to not add browser history entry
     */
    load: function(url) {
    load: function(name, noHistory) {
        noHistory || Docs.History.push("/guide/" + name);

        Ext.Ajax.request({
            url: url,
            url: Docs.App.getBaseUrl() + "/guides/" + name + "/index.html",
            success: function(response) {
                var html = response.responseText;
                this.render(html);
+10 −6
Original line number Diff line number Diff line
@@ -25,17 +25,21 @@ Ext.define("Docs.History", {

    // Parses current URL and navigates to the page
    navigate: function() {
        var className = this.parseUrl();
        if (className) {
            Docs.ClassLoader.load(className, true);
            Ext.getCmp('treePanelCmp').selectClass(className);
        var url = this.parseUrl();
        if (url.type === "api") {
            Docs.ClassLoader.load(url.key, true);
            Ext.getCmp('treePanelCmp').selectClass(url.key);
        }
        else if (url.type === "guide") {
            Docs.App.setGuideMode();
            Docs.Guides.load(url.key, true);
        }
    },

    // Parses current browser location
    parseUrl: function() {
        var matches = document.location.hash.match(/#\/api\/(.*)/);
        return matches ? matches[1] : undefined;
        var matches = document.location.hash.match(/#\/(api|guide)\/(.*)/);
        return matches ? {type: matches[1], key: matches[2]} : {};
    },

    /**