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

Change page title according to current page.

Show class name if class selected.
Show guide name if guide.
Otherwise show the normal title, like it used to be.
parent f85f53f4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -32,4 +32,5 @@ Ext.define('Docs.Application', {
            Docs.initEventTracking();
        }
    }

});
+6 −0
Original line number Diff line number Diff line
@@ -23,6 +23,10 @@ Ext.define('Docs.controller.Classes', {
    ],

    refs: [
        {
            ref: 'viewport',
            selector: '#viewport'
        },
        {
            ref: 'header',
            selector: 'classheader'
@@ -161,6 +165,7 @@ Ext.define('Docs.controller.Classes', {
        var classOverview = this.getTabPanel().down('classoverview');

        if (this.currentCls != cls) {
            this.getViewport().setPageTitle(cls.name);
            this.getHeader().load(cls);

            // Init overview tab if not already available
@@ -194,6 +199,7 @@ Ext.define('Docs.controller.Classes', {
            url: this.getBaseUrl() + "/guides/" + name + "/README.js",
            callbackName: name,
            success: function(json) {
                this.getViewport().setPageTitle(json.guide.match(/<h1>(.*)<\/h1>/)[1]);
                Ext.getCmp("guide").update(json.guide);
                Ext.getCmp('container').layout.setActiveItem(2);
                Docs.Syntax.highlight(Ext.get("guide"));
+16 −1
Original line number Diff line number Diff line
@@ -40,9 +40,11 @@ Ext.define('Docs.view.Viewport', {
                        ui: 'hmm',
                        listeners: {
                            click: function() {
                                this.setPageTitle("");
                                Ext.getCmp('container').layout.setActiveItem(0);
                                Docs.History.push("");
                            }
                            },
                            scope: this
                        }
                    },
                    {
@@ -113,5 +115,18 @@ Ext.define('Docs.view.Viewport', {
        ];

        this.callParent(arguments);
    },

    /**
     * Sets the contents of `<title>` tag.
     * @param {String} text
     */
    setPageTitle: function(text) {
        text = Ext.util.Format.stripTags(text);
        var title = Ext.query("title")[0];
        if (!this.origTitle) {
            this.origTitle = title.innerHTML;
        }
        title.innerHTML = text ? (text + " - " + this.origTitle) : this.origTitle;
    }
});