1. #1
    Sencha User
    Join Date
    Sep 2007
    Posts
    98
    Vote Rating
    1
    adam.jimenez is on a distinguished road

      0  

    Default Ext.ux.TabCloseOnMiddleClick

    Ext.ux.TabCloseOnMiddleClick


    Closes tab when middle mouse button is clicked on the tab bar.

    Based on: http://www.sencha.com/forum/showthre...l=1#post172321


    Code:
    Ext.define('Ext.ux.TabCloseOnMiddleClick', {    
        alias: 'plugin.TabCloseOnMiddleClick',
    
        mixins: {
            observable: 'Ext.util.Observable'
        },
        
        init : function(tabpanel){        
            this.tabPanel = tabpanel;
            this.tabBar = tabpanel.down("tabbar");
    
            this.mon(this.tabPanel, {
                scope: this,
                afterlayout: this.onAfterLayout,
                single: true
            });
        },
        
        onAfterLayout: function(){
            this.mon(this.tabBar.el, {
                scope: this,
                mousedown: this.onMouseDown,
                delegate: '.x-tab'
            });
            this.mon(this.tabBar.el, {
                scope: this,
                mouseup: this.onMouseUp,
                delegate: '.x-tab'
            });
        },
    
        onMouseDown: function(e){
            e.preventDefault();
        },
    
        onMouseUp: function(e, target){
            e.preventDefault();
            
            if( target && e.button==1  ){
                var item = this.tabBar.getComponent(target.id);
                item.onCloseClick();
            }
        }
    });
    usage:
    Code:
    Ext.onReady(function(){
        var panel = new Ext.TabPanel({
            renderTo: Ext.getBody(),
            plugins: [Ext.create('Ext.ux.TabCloseOnMiddleClick')],
            width: 500,
            height: 300,
            activeItem: 0,
            items: [{
                title: 'item 1'
            }, {
                title: 'item 2',
                closable: true
            }, {
                title: 'item 3',
                closable: true
            }]
        });
    });

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,081
    Vote Rating
    467
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Thank you for the contribution.

Thread Participants: 1

Tags for this Thread