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

More history dropdown support

parent f1506514
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -10,7 +10,9 @@ Ext.define('Docs.controller.Classes', {

    views: [
        'cls.List',
        'clsTree.Tree'
        'clsTree.Tree',
        'clsTree.History',
        'clsTree.HistoryItems'
    ],

	stores: [
@@ -118,7 +120,8 @@ Ext.define('Docs.controller.Classes', {
                showClass = container.down('showclass'),
                classHeader = showClass.down('classheader'),
                classOverview = showClass.down('classoverview'),
                docTabPanel = Ext.getCmp('docTabPanel');
                docTabPanel = Ext.getCmp('docTabPanel'),
				historyStore = this.getStore('History');

            classHeader.update(classHeader.tpl.apply(cls));
            classOverview.load(cls);
@@ -128,6 +131,12 @@ Ext.define('Docs.controller.Classes', {
                docTabPanel.setLoading(false);
            }
			
			var prevCls = historyStore.find('cls', cls.name);
			if (prevCls == -1) {
				historyStore.add({cls: cls.name});
				historyStore.sync();
			}

            Ext.getCmp('treePanelCmp').selectClass(cls.name);
        }

+3 −0
Original line number Diff line number Diff line
/**
 * Previously visited classes / guides
 */
Ext.define('Docs.model.History', {
    fields: ['id', 'cls', 'scrollPosision', 'hideInherited', 'expandedMembers'],
    extend: 'Ext.data.Model',
+3 −0
Original line number Diff line number Diff line
/**
 * History Store
 */
Ext.define('Docs.store.History', {
	extend: 'Ext.data.Store',
    model: 'Docs.model.History'
+58 −0
Original line number Diff line number Diff line
Ext.define('Docs.view.clsTree.History', {
	
	extend: 'Ext.button.Button',
	alias: 'widget.docshistorybutton',
	id: 'historyBtn',
	
	text: 'History',
	
	afterRender: function() {
	    
        this.on({
            mouseover: function() {
                
                if (!this.hoverMenu) {
                    this.renderMenu();
                }
                
                this.hoverMenu.show();
                clearTimeout(this.hideTimeout);
    	    },
            mouseout: this.deferHideMenu,
            scope: this
        });

	},
	
    renderMenu: function() {
        
        this.hoverMenu = Ext.create('Docs.view.clsTree.HistoryItems', {
            store: Docs.App.getStore('History')
        });
        
        this.hoverMenu.getEl().setVisibilityMode(Ext.core.Element.DISPLAY);
        
        this.hoverMenu.getEl().on({
            mouseover: function() {
                clearTimeout(this.hideTimeout);
            },
            mouseout: this.deferHideMenu,
            click: function() {
                this.hoverMenu.hide();
            },
            scope: this
        });
        
        var p = this.getEl().getXY();
        this.hoverMenu.getEl().setStyle({
            left: "35px",
            top: (p[1]+23)+"px"
        });
    },

    deferHideMenu: function() {
        this.hideTimeout = Ext.Function.defer(function() {
            this.hoverMenu.hide();
        }, 200, this);
    }
});
+15 −0
Original line number Diff line number Diff line

Ext.define('Docs.view.clsTree.HistoryItems', {
    extend: 'Ext.view.View',
    
    itemSelector: 'div.a',
    emptyText: 'No history',
    renderTo: Ext.getBody(),
    cls: 'hover-menu-menu show',
    
    tpl: new Ext.XTemplate(
        '<tpl for=".">',
            '<a href="{cls}" rel="{cls}" class="docClass">{cls}</a>',
        '</tpl>'
    )
});
Loading