Commit 5a59840e authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Refactor noAnimate and noActivate into options object.

parent 4e2f2077
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -74,14 +74,14 @@ Ext.define('Docs.controller.Tabs', {
     * Adds a tab based on information from the class tree
     * @param {String} url The url of the record in the tree
     */
    addTabFromTree: function(url, tree, noAnimate, noActivate) {
    addTabFromTree: function(url, tree) {
        var treeRecord = tree.findRecordByUrl(url);
        if (treeRecord && treeRecord.raw) {
            Ext.getCmp('doctabs').addTab({
                href: '#' + treeRecord.raw.url,
                text: treeRecord.raw.text,
                iconCls: treeRecord.raw.iconCls
            }, noAnimate, noActivate);
            }, {animate: true, activate: true});
        }
    },

+9 −5
Original line number Diff line number Diff line
@@ -43,8 +43,11 @@ Ext.define('Docs.view.Tabs', {
     * @param {String} tab.href URL of the resource
     * @param {String} tab.text Text to be used on the tab
     * @param {String} tab.iconCls CSS class to be used as the icon
     * @param {Object} opts Options object:
     * @param {Boolean} opts.animate True to animate the addition
     * @param {Boolean} opts.activate True to activate the tab
     */
    addTab: function(tab, noAnimate, noActivate) {
    addTab: function(tab, opts) {
        if (!Ext.Array.contains(this.openTabs, tab.href)) {
            var tpl = Ext.create('Ext.XTemplate',
                '<div class="doctab" style="visibility: hidden">',
@@ -59,9 +62,7 @@ Ext.define('Docs.view.Tabs', {
            );
            var docTab = Ext.get(tpl.append(this.el.dom, tab));

            if (noAnimate) {
                docTab.setStyle({ visibility: 'visible' });
            } else {
            if (opts.animate) {
                // Effect to 'slide' the tab out when it is created.
                var width = docTab.getWidth();
                docTab.setStyle('width', '10px');
@@ -70,12 +71,15 @@ Ext.define('Docs.view.Tabs', {
                    to: { width: width }
                });
            }
            else {
                docTab.setStyle({ visibility: 'visible' });
            }

            this.openTabs.push(tab.href);
            Docs.Settings.set('openTabs', this.openTabs);
        }

        if (!noActivate) {
        if (opts.activate) {
            this.activateTab(tab.href);
        }
    },