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

Create GroupTree class.

This generalizes exampes/guides/videos trees.
parent 0e5249f8
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ Ext.define('Docs.controller.Examples', {
    refs: [
        {
            ref: 'tree',
            selector: 'exampletree'
            selector: '#exampletree'
        }
    ],

@@ -22,7 +22,7 @@ Ext.define('Docs.controller.Examples', {
        );

        this.control({
            'exampletree': {
            '#exampletree': {
                urlclick: function(url, event) {
                    this.loadExample(url);
                }
+2 −2
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ Ext.define('Docs.controller.Guides', {
        },
        {
            ref: 'tree',
            selector: 'guidetree'
            selector: '#guidetree'
        }
    ],

@@ -28,7 +28,7 @@ Ext.define('Docs.controller.Guides', {
        );

        this.control({
            'guidetree': {
            '#guidetree': {
                urlclick: function(url, event) {
                    this.handleUrlClick(url, event, this.getTree());
                }
+3 −3
Original line number Diff line number Diff line
@@ -11,15 +11,15 @@ Ext.define('Docs.controller.Tabs', {
        },
        {
            ref: 'guideTree',
            selector: 'guidetree'
            selector: '#guidetree'
        },
        {
            ref: 'exampleTree',
            selector: 'exampletree'
            selector: '#exampletree'
        },
        {
            ref: 'videoTree',
            selector: 'videotree'
            selector: '#videotree'
        }
    ],

+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ Ext.define('Docs.controller.Videos', {
        );

        this.control({
            'videotree': {
            '#videotree': {
                urlclick: function(url) {
                    this.loadVideo(url);
                }
+42 −0
Original line number Diff line number Diff line
/**
 * A tree for guides/videos/examples.
 *
 * Each of these has similar dataset that consists of groups.
 * Only the actual items (that are grouped) differ.
 * This class applies a conversion function for each item.
 */
Ext.define('Docs.view.GroupTree', {
    extend: 'Docs.view.DocTree',
    alias: 'widget.grouptree',

    /**
     * @cfg {Object[]} data (required)
     * An array of guoups. Each group is object with properties:
     * @cfg {String} title
     * @cfg {Object[]} items
     */

    /**
     * @cfg {Function} convert (required)
     * A function that converts items to tree nodes
     * @cfg {Object} convert.item The item to convert
     * @cfg {Object} convert.return The treenode config
     */

    initComponent: function() {
        this.root = {
            children: [],
            text: 'Root'
        };

        Ext.Array.each(this.data, function(group) {
            this.root.children.push({
                text: group.title,
                children: Ext.Array.map(group.items, this.convert),
                iconCls: 'icon-pkg'
            });
        }, this);

        this.callParent();
    }
});
Loading