Path: blob/master/extensions/admin_ui/media/javascript/ux/TabCloseMenu.js
1154 views
//1// Copyright (c) 2006-2025 Wade Alcorn - [email protected]2// Browser Exploitation Framework (BeEF) - https://beefproject.com3// See the file 'doc/COPYING' for copying permission4//56/*!7* Ext JS Library 3.1.18* Copyright(c) 2006-2010 Ext JS, LLC9* [email protected]10* http://www.extjs.com/license11*/12/**13* @class Ext.ux.TabCloseMenu14* @extends Object15* Plugin (ptype = 'tabclosemenu') for adding a close context menu to tabs.16*17* @ptype tabclosemenu18*/19Ext.ux.TabCloseMenu = function(){20var tabs, menu, ctxItem;21this.init = function(tp){22tabs = tp;23tabs.on('contextmenu', onContextMenu);24};2526function onContextMenu(ts, item, e){27if(!menu){ // create context menu on first right click28menu = new Ext.menu.Menu({29items: [{30id: tabs.id + '-close',31text: 'Close Tab',32handler : function(){33tabs.remove(ctxItem);34}35},{36id: tabs.id + '-close-others',37text: 'Close Other Tabs',38handler : function(){39tabs.items.each(function(item){40if(item.closable && item != ctxItem){41tabs.remove(item);42}43});44}45}]});46}47ctxItem = item;48var items = menu.items;49items.get(tabs.id + '-close').setDisabled(!item.closable);50var disableOthers = true;51tabs.items.each(function(){52if(this != item && this.closable){53disableOthers = false;54return false;55}56});57items.get(tabs.id + '-close-others').setDisabled(disableOthers);58e.stopEvent();59menu.showAt(e.getPoint());60}61};6263Ext.preg('tabclosemenu', Ext.ux.TabCloseMenu);646566