Commit 08b01674 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Refactor all trees to fire 'urlclick' event.

- most of tree functionality is now in classtree.
  only the tree data creation is done by subclasses.
parent 764243ce
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ Ext.define('Docs.controller.Examples', {

        this.control({
            'exampletree': {
                exampleclick: function(url, event) {
                urlclick: function(url, event) {
                    this.loadExample(url);
                }
            },
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ Ext.define('Docs.controller.Guides', {

        this.control({
            'guidetree': {
                guideclick: function(url, event) {
                urlclick: function(url, event) {
                    this.handleUrlClick(url, event, this.getTree());
                }
            },
+3 −3
Original line number Diff line number Diff line
@@ -15,13 +15,13 @@ Ext.define('Docs.controller.Videos', {
        );

        this.control({
            'videoindex > thumblist': {
            'videotree': {
                urlclick: function(url) {
                    this.loadVideo(url);
                }
            },
            'videotree': {
                videoclick: function(url) {
            'videoindex > thumblist': {
                urlclick: function(url) {
                    this.loadVideo(url);
                }
            }
+0 −34
Original line number Diff line number Diff line
@@ -5,23 +5,7 @@ Ext.define('Docs.view.examples.Tree', {
    extend: 'Docs.view.cls.Tree',
    alias: 'widget.exampletree',

    useArrows: true,
    rootVisible: false,

    border: false,
    bodyBorder: false,

    initComponent: function() {
        this.addEvents(
            /**
             * @event
             * Fired when link in tree was clicked on and needs to be loaded.
             * @param {String} url  URL of the example to load
             * @param {Ext.EventObject} e
             */
            "exampleclick"
        );

        this.root = {
            allowDrag: false,
            children: [],
@@ -44,24 +28,6 @@ Ext.define('Docs.view.examples.Tree', {
            });
        }, this);

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

        this.callParent();
    },

    onItemClick: function(view, node, item, index, e) {
        var url = node.raw.url;

        if (url) {
            this.fireEvent('exampleclick', url, e);
        }
        else if (!node.isLeaf()) {
            if (node.isExpanded()) {
                node.collapse(false);
            }
            else {
                node.expand(false);
            }
        }
    }
});
+0 −34
Original line number Diff line number Diff line
@@ -5,23 +5,7 @@ Ext.define('Docs.view.guides.Tree', {
    extend: 'Docs.view.cls.Tree',
    alias: 'widget.guidetree',

    useArrows: true,
    rootVisible: false,

    border: false,
    bodyBorder: false,

    initComponent: function() {
        this.addEvents(
            /**
             * @event
             * Fired when link in tree was clicked on and needs to be loaded.
             * @param {String} url  URL of the guide to load
             * @param {Ext.EventObject} e
             */
            "guideclick"
        );

        this.root = {
            allowDrag: false,
            children: [],
@@ -45,24 +29,6 @@ Ext.define('Docs.view.guides.Tree', {
            });
        }, this);

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

        this.callParent();
    },

    onItemClick: function(view, node, item, index, e) {
        var url = node.raw.url;

        if (url) {
            this.fireEvent('guideclick', url, e);
        }
        else if (!node.isLeaf()) {
            if (node.isExpanded()) {
                node.collapse(false);
            }
            else {
                node.expand(false);
            }
        }
    }
});
Loading