Commit 4ba760a1 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

New logic for expaning Ext namespace in class tree.

Now the expansion happens only when there's just one expandable
item at root level.  Basically this means that when we have two
namespaces like Ext and Blah, then neither gets expanded by default,
but if there's just Blah, it will be expanded.
parent 79eedc52
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -23,11 +23,8 @@ Ext.define('Docs.view.DocTree', {
            "urlclick"
        );

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

        this.on("itemclick", this.onItemClick, this);
        this.on("beforeitemcollapse", this.handleBeforeExpandCollapse, this);
+13 −2
Original line number Diff line number Diff line
@@ -37,15 +37,26 @@ Ext.define('Docs.view.cls.Tree', {
            var selected = this.getSelectionModel().getLastSelected();
            // create new treestructure
            var root = tree.create();
            this.expandLonelyNode(root);
            this.setRootNode(root);
            this.initNodeLinks();
            // expand first child
            this.getRootNode().getChildAt(0).expand();

            // re-establish the previous selection
            selected && this.selectUrl(selected.raw.url);
        }
        else {
            this.root = tree.create();
            this.expandLonelyNode(this.root);
        }
    },

    // When only one expandable node at root level, expand it
    expandLonelyNode: function(root) {
        var expandableNodes = Ext.Array.filter(root.children, function(node) {
            return node.children.length > 0;
        });
        if (expandableNodes.length == 1) {
            expandableNodes[0].expanded = true;
        }
    }
});