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

Make docs app work without extra static tabs.

The number of static tabs now depends on if --welcome, --guides,
--videos and/or --examples options were specified.  Only the classes
tab is always on.
parent e96e4139
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -9,6 +9,26 @@ Ext.define('Docs.controller.Tabs', {
    ],

    refs: [
        {
            ref: 'welcomeIndex',
            selector: '#welcomeindex'
        },
        {
            ref: 'classIndex',
            selector: '#classindex'
        },
        {
            ref: 'guideIndex',
            selector: '#guideindex'
        },
        {
            ref: 'videoIndex',
            selector: '#videoindex'
        },
        {
            ref: 'exampleIndex',
            selector: '#exampleindex'
        },
        {
            ref: 'classTree',
            selector: '#classtree'
@@ -90,6 +110,14 @@ Ext.define('Docs.controller.Tabs', {

    // Open all tabs from previous session
    onLaunch: function() {
        this.getDoctabs().setStaticTabs(Ext.Array.filter([
            this.getWelcomeIndex().getTab(),
            this.getClassIndex().getTab(),
            this.getGuideIndex().getTab(),
            this.getVideoIndex().getTab(),
            this.getExampleIndex().getTab()
        ], function(x){return x;}));

        var tabs = Docs.Settings.get('tabs');
        if (tabs) {
            Ext.Array.forEach(tabs, function(url) {
+3 −1
Original line number Diff line number Diff line
@@ -25,7 +25,9 @@ Ext.define('Docs.view.DocTree', {

        // Expand the main tree
        this.root.expanded = true;
        if (this.root.children[0]) {
            this.root.children[0].expanded = true;
        }

        this.on("itemclick", this.onItemClick, this);

+14 −8
Original line number Diff line number Diff line
@@ -16,14 +16,7 @@ Ext.define('Docs.view.Tabs', {
    tabs: [],
    tabsInBar: [],
    tabCache: {},

    staticTabs: [
        { cls: 'index',    href: '#',          tooltip: 'Home' },
        { cls: 'classes',  href: '#!/api',     tooltip: 'API documentation' },
        { cls: 'guides',   href: '#!/guide',   tooltip: 'Guides' },
        { cls: 'videos',   href: '#!/video',   tooltip: 'Videos' },
        { cls: 'examples', href: '#!/example', tooltip: 'Examples' }
    ],
    staticTabs: [],

    initComponent: function() {
        this.tpl = Ext.create('Ext.XTemplate',
@@ -64,6 +57,19 @@ Ext.define('Docs.view.Tabs', {
        }
    },

    /**
     * Sets the static tabs to display.
     *
     * @param {Object[]} tabs Array of tab configs with the following structure:
     * @param {String} tabs.cls CSS classname for tab
     * @param {String} tabs.href URL to activate when clicking tab
     * @param {String} tabs.tooltip Tooltip to show when hovering the tab
     */
    setStaticTabs: function(tabs) {
        this.staticTabs = tabs;
        this.refresh();
    },

    /**
     * Adds a new tab
     *
+8 −0
Original line number Diff line number Diff line
@@ -26,5 +26,13 @@ Ext.define('Docs.view.cls.Index', {
        };

        this.callParent(arguments);
    },

    /**
     * Returns tab config for classes page.
     * @return {Object}
     */
    getTab: function() {
        return {cls: 'classes', href: '#!/api', tooltip: 'API Documentation'};
    }
});
+8 −0
Original line number Diff line number Diff line
@@ -36,5 +36,13 @@ Ext.define('Docs.view.examples.Index', {
        ];

        this.callParent(arguments);
    },

    /**
     * Returns tab config for examples page.
     * @return {Object}
     */
    getTab: function() {
        return Docs.data.examples.length > 0 ? {cls: 'examples', href: '#!/example', tooltip: 'Examples'} : false;
    }
});
Loading