Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/extensions/admin_ui/media/javascript/ux/TabCloseMenu.js
1154 views
1
//
2
// Copyright (c) 2006-2025 Wade Alcorn - [email protected]
3
// Browser Exploitation Framework (BeEF) - https://beefproject.com
4
// See the file 'doc/COPYING' for copying permission
5
//
6
7
/*!
8
* Ext JS Library 3.1.1
9
* Copyright(c) 2006-2010 Ext JS, LLC
10
* [email protected]
11
* http://www.extjs.com/license
12
*/
13
/**
14
* @class Ext.ux.TabCloseMenu
15
* @extends Object
16
* Plugin (ptype = 'tabclosemenu') for adding a close context menu to tabs.
17
*
18
* @ptype tabclosemenu
19
*/
20
Ext.ux.TabCloseMenu = function(){
21
var tabs, menu, ctxItem;
22
this.init = function(tp){
23
tabs = tp;
24
tabs.on('contextmenu', onContextMenu);
25
};
26
27
function onContextMenu(ts, item, e){
28
if(!menu){ // create context menu on first right click
29
menu = new Ext.menu.Menu({
30
items: [{
31
id: tabs.id + '-close',
32
text: 'Close Tab',
33
handler : function(){
34
tabs.remove(ctxItem);
35
}
36
},{
37
id: tabs.id + '-close-others',
38
text: 'Close Other Tabs',
39
handler : function(){
40
tabs.items.each(function(item){
41
if(item.closable && item != ctxItem){
42
tabs.remove(item);
43
}
44
});
45
}
46
}]});
47
}
48
ctxItem = item;
49
var items = menu.items;
50
items.get(tabs.id + '-close').setDisabled(!item.closable);
51
var disableOthers = true;
52
tabs.items.each(function(){
53
if(this != item && this.closable){
54
disableOthers = false;
55
return false;
56
}
57
});
58
items.get(tabs.id + '-close-others').setDisabled(disableOthers);
59
e.stopEvent();
60
menu.showAt(e.getPoint());
61
}
62
};
63
64
Ext.preg('tabclosemenu', Ext.ux.TabCloseMenu);
65
66