Commit 31831436 authored by Nick Poulden's avatar Nick Poulden
Browse files

More refactoring and fixes for redesign

parent e3c3f6fe
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ Ext.define('Docs.Application', {
    ],

    controllers: [
        'Content',
        'Classes',
        'Search',
        'InlineExamples',
@@ -45,9 +46,9 @@ Ext.define('Docs.Application', {
            Docs.initEventTracking();
        }

        setInterval(function(){
            Ext.DomQuery.select('link')[4].href = "resources/css/viewport.css?" + Math.ceil(Math.random() * 100000000)
        }, 1000)
        // setInterval(function(){
        //     Ext.DomQuery.select('link')[4].href = "resources/css/viewport.css?" + Math.ceil(Math.random() * 100000000)
        // }, 1000)
    }

});
+3 −20
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
 * between pages.
 */
Ext.define('Docs.controller.Classes', {
    extend: 'Ext.app.Controller',
    extend: 'Docs.controller.Content',

    requires: [
        'Docs.History',
@@ -39,7 +39,7 @@ Ext.define('Docs.controller.Classes', {
        },
        {
            ref: 'tree',
            selector: 'classtree'
            selector: 'classtree[cmpName=classtree]'
        },
        {
            ref: 'favoritesGrid',
@@ -74,7 +74,7 @@ Ext.define('Docs.controller.Classes', {
        });

        this.control({
            'classtree': {
            'classtree[cmpName=classtree]': {
                urlclick: function(url, event) {
                    this.handleUrlClick(url, event, this.getTree());
                }
@@ -149,15 +149,6 @@ Ext.define('Docs.controller.Classes', {
        }
    },

    // Code for the middle mouse button
    MIDDLE: 1,

    // True when middle mouse button pressed or shift/ctrl key pressed
    // together with mouse button (for Mac)
    opensNewWindow: function(event) {
        return event.button === this.MIDDLE || event.shiftKey || event.ctrlKey;
    },

    /**
     * Loads main page.
     *
@@ -247,14 +238,6 @@ Ext.define('Docs.controller.Classes', {
        }

        this.currentCls = cls;
    },

    /**
     * Returns base URL used for making AJAX requests.
     * @return {String} URL
     */
    getBaseUrl: function() {
        return document.location.href.replace(/#.*/, "").replace(/index.html/, "");
    }

});
+24 −0
Original line number Diff line number Diff line
/**
 * Controller for Welcome page
 */
Ext.define('Docs.controller.Content', {
    extend: 'Ext.app.Controller',

    // Code for the middle mouse button
    MIDDLE: 1,

    // True when middle mouse button pressed or shift/ctrl key pressed
    // together with mouse button (for Mac)
    opensNewWindow: function(event) {
        return event.button === this.MIDDLE || event.shiftKey || event.ctrlKey;
    },

    /**
     * Returns base URL used for making AJAX requests.
     * @return {String} URL
     */
    getBaseUrl: function() {
        return document.location.href.replace(/#.*/, "").replace(/index.html/, "");
    }

});
+2 −2
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ Ext.define('Docs.controller.Favorites', {
            add: function(url) {
                // Show favorites when first favorite added
                if (Docs.Favorites.getCount() > 0) {
                    this.getPanel().show();
                    // this.getPanel().show();
                }
                // Add favorite marking to tree
                this.getTree().setFavorite(url, true);
@@ -59,7 +59,7 @@ Ext.define('Docs.controller.Favorites', {
            remove: function(url) {
                // Hide favorites when favorites list empty
                if (Docs.Favorites.getCount() === 0) {
                    this.getPanel().hide();
                    // this.getPanel().hide();
                }
                // remove favorite marking from tree
                this.getTree().setFavorite(url, false);
+39 −11
Original line number Diff line number Diff line
@@ -2,7 +2,18 @@
 * Controller for Welcome page
 */
Ext.define('Docs.controller.Guides', {
    extend: 'Ext.app.Controller',
    extend: 'Docs.controller.Content',

    refs: [
        {
            ref: 'viewport',
            selector: '#viewport'
        },
        {
            ref: 'tree',
            selector: 'classtree[cmpName=guidetree]'
        }
    ],

    init: function() {
        this.addEvents(
@@ -15,6 +26,11 @@ Ext.define('Docs.controller.Guides', {
        );

        this.control({
            'classtree[cmpName=guidetree]': {
                urlclick: function(url, event) {
                    this.handleUrlClick(url, event, this.getTree());
                }
            },
            'indexcontainer': {
                afterrender: function(cmp) {
                    cmp.el.addListener('click', function(event, el) {
@@ -28,10 +44,26 @@ Ext.define('Docs.controller.Guides', {
        })
    },

    // We don't want to select the class that was opened in another window,
    // so restore the previous selection.
    handleUrlClick: function(url, event, view) {
        // Remove everything up to #
        url = url.replace(/.*#/, "");

        if (this.opensNewWindow(event)) {
            window.open("#"+url);
            view && view.selectUrl(this.activeUrl ? this.activeUrl : "");
        }
        else {
            this.loadGuide(url);
        }
    },

    loadIndex: function() {
        Ext.getCmp('doctabs').activateTab('#/guide');
        Ext.getCmp('card-panel').layout.setActiveItem('guides');
        Ext.getCmp('tree-container').hide();
        Ext.getCmp('tree-container').show();
        Ext.getCmp('tree-container').layout.setActiveItem(2);
    },

    /**
@@ -41,6 +73,10 @@ Ext.define('Docs.controller.Guides', {
     * @param {Boolean} noHistory  true to disable adding entry to browser history
     */
    loadGuide: function(url, noHistory) {
        Ext.getCmp('card-panel').layout.setActiveItem('guide');
        Ext.getCmp('tree-container').show();
        Ext.getCmp('tree-container').layout.setActiveItem(2);

        if (this.activeUrl === url) return;
        this.activeUrl = url;

@@ -54,7 +90,7 @@ Ext.define('Docs.controller.Guides', {
                success: function(json) {
                    this.getViewport().setPageTitle(json.guide.match(/<h1>(.*)<\/h1>/)[1]);
                    Ext.getCmp("guide").update(json.guide);
                    Ext.getCmp('card-panel').layout.setActiveItem(2);

                    Docs.Syntax.highlight(Ext.get("guide"));
                    this.fireEvent('showGuide', name[1]);
                    this.getTree().selectUrl(url);
@@ -65,14 +101,6 @@ Ext.define('Docs.controller.Guides', {
                scope: this
            });
        }
    },

    /**
     * Returns base URL used for making AJAX requests.
     * @return {String} URL
     */
    getBaseUrl: function() {
        return document.location.href.replace(/#.*/, "").replace(/index.html/, "");
    }

});
Loading