Commit 1816d966 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Refactor scrollstate logic to Content controller.

parent 04bc72b8
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ Ext.define('Docs.Application', {

    controllers: [
        'Welcome',
        'Content',
        'Classes',
        'Search',
        'InlineExamples',
+7 −15
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@
 */
Ext.define('Docs.controller.Classes', {
    extend: 'Docs.controller.Content',
    baseUrl: '#!/api',
    title: 'Classes',

    requires: [
        'Docs.History',
@@ -22,6 +24,10 @@ Ext.define('Docs.controller.Classes', {
            ref: 'viewport',
            selector: '#viewport'
        },
        {
            ref: 'index',
            selector: '#classindex'
        },
        {
            ref: 'header',
            selector: 'classheader'
@@ -85,14 +91,6 @@ Ext.define('Docs.controller.Classes', {
                }
            },

            'classindex': {
                afterrender: function(cmp) {
                    cmp.el.addListener('scroll', function(cmp, el) {
                        this.setScrollState('#!/api', el.scrollTop);
                    }, this);
                }
            },

            'classoverview': {
                afterrender: function(cmp) {
                    // Expand member when clicked
@@ -153,14 +151,8 @@ Ext.define('Docs.controller.Classes', {
     * @param {Boolean} noHistory  true to disable adding entry to browser history
     */
    loadIndex: function(noHistory) {
        if (!noHistory) {
            Docs.History.push("#!/api");
        }
        this.getViewport().setPageTitle("Classes");
        Ext.getCmp('doctabs').activateTab('#!/api');
        Ext.getCmp('treecontainer').showTree('classtree');
        Ext.getCmp('card-panel').layout.setActiveItem('classindex');
        Ext.getCmp('classindex').getEl().scrollTo('top', this.getScrollState("#!/api"));
        this.callParent(arguments);
    },

    /**
+27 −0
Original line number Diff line number Diff line
@@ -7,6 +7,33 @@ Ext.define('Docs.controller.Content', {
    // Code for the middle mouse button
    MIDDLE: 1,

    /**
     * @cfg {String} baseUrl (required)
     * The base URL of pages served by this controller.
     */

    /**
     * @cfg {String} title
     * Title to display while index view active.
     */
    title: "",

    onLaunch: function() {
        this.getIndex().on('afterrender', function() {
            cmp.el.addListener('scroll', function(cmp, el) {
                this.setScrollState(this.baseUrl, el.scrollTop);
            }, this);
        }, this);
    },

    loadIndex: function(noHistory) {
        noHistory || Docs.History.push(this.baseUrl);
        this.getViewport().setPageTitle(this.title);
        Ext.getCmp('doctabs').activateTab(this.baseUrl);
        Ext.getCmp('card-panel').layout.setActiveItem(this.getIndex());
        this.getIndex().getEl().scrollTo('top', this.getScrollState("#"));
    },

    // True when middle mouse button pressed or shift/ctrl key pressed
    // together with mouse button (for Mac)
    opensNewWindow: function(event) {
+7 −12
Original line number Diff line number Diff line
@@ -3,12 +3,18 @@
 */
Ext.define('Docs.controller.Examples', {
    extend: 'Docs.controller.Content',
    baseUrl: '#!/example',
    title: 'Examples',

    refs: [
        {
            ref: 'viewport',
            selector: '#viewport'
        },
        {
            ref: 'index',
            selector: '#exampleindex'
        },
        {
            ref: 'tree',
            selector: '#exampletree'
@@ -31,13 +37,6 @@ Ext.define('Docs.controller.Examples', {
                    this.loadExample(url);
                }
            },
            'exampleindex': {
                afterrender: function(cmp) {
                    cmp.el.addListener('scroll', function(cmp, el) {
                        this.setScrollState('#!/example', el.scrollTop);
                    }, this);
                }
            },
            'exampleindex > thumblist': {
                urlclick: function(url) {
                    this.loadExample(url);
@@ -47,12 +46,8 @@ Ext.define('Docs.controller.Examples', {
    },

    loadIndex: function() {
        Docs.History.push("#!/example");
        this.getViewport().setPageTitle("Examples");
        Ext.getCmp('doctabs').activateTab('#!/example');
        Ext.getCmp('card-panel').layout.setActiveItem('exampleindex');
        Ext.getCmp('treecontainer').showTree('exampletree');
        Ext.getCmp('exampleindex').getEl().scrollTo('top', this.getScrollState("#!/example"));
        this.callParent();
    },

    loadExample: function(url, noHistory) {
+7 −12
Original line number Diff line number Diff line
@@ -3,12 +3,18 @@
 */
Ext.define('Docs.controller.Guides', {
    extend: 'Docs.controller.Content',
    baseUrl: '#!/guide',
    title: 'Guides',

    refs: [
        {
            ref: 'viewport',
            selector: '#viewport'
        },
        {
            ref: 'index',
            selector: '#guideindex'
        },
        {
            ref: 'tree',
            selector: '#guidetree'
@@ -33,13 +39,6 @@ Ext.define('Docs.controller.Guides', {
                    this.handleUrlClick(url, event, this.getTree());
                }
            },
            'guideindex': {
                afterrender: function(cmp) {
                    cmp.el.addListener('scroll', function(cmp, el) {
                        this.setScrollState('#!/guide', el.scrollTop);
                    }, this);
                }
            },
            'guideindex > thumblist': {
                urlclick: function(url) {
                    this.loadGuide(url);
@@ -84,12 +83,8 @@ Ext.define('Docs.controller.Guides', {
     * Loads the guides index
     */
    loadIndex: function() {
        Docs.History.push("#!/guide");
        this.getViewport().setPageTitle("Guides");
        Ext.getCmp('doctabs').activateTab('#!/guide');
        Ext.getCmp('card-panel').layout.setActiveItem('guideindex');
        Ext.getCmp('treecontainer').showTree('guidetree');
        Ext.getCmp('guideindex').getEl().scrollTo('top', this.getScrollState("#!/guide"));
        this.callParent();
    },

    /**
Loading