]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/menu/MenuItem.js
ui: eslint: fix trailing comma and comma related whitespaces errors
[pve-manager.git] / www / manager6 / menu / MenuItem.js
1 Ext.define('PVE.menu.Item', {
2 extend: 'Ext.menu.Item',
3 alias: 'widget.pveMenuItem',
4
5 // set to wrap the handler callback in a confirm dialog showing this text
6 confirmMsg: false,
7
8 // set to focus 'No' instead of 'Yes' button and show a warning symbol
9 dangerous: false,
10
11 initComponent: function() {
12 var me = this;
13
14 if (me.handler) {
15 me.setHandler(me.handler, me.scope);
16 }
17
18 me.callParent();
19 },
20
21 setHandler: function(fn, scope) {
22 var me = this;
23 me.scope = scope;
24 me.handler = function(button, e) {
25 var rec, msg;
26 if (me.confirmMsg) {
27 msg = me.confirmMsg;
28 Ext.MessageBox.defaultButton = me.dangerous ? 2 : 1;
29 Ext.Msg.show({
30 title: gettext('Confirm'),
31 icon: me.dangerous ? Ext.Msg.WARNING : Ext.Msg.QUESTION,
32 msg: msg,
33 buttons: Ext.Msg.YESNO,
34 defaultFocus: me.dangerous ? 'no' : 'yes',
35 callback: function(btn) {
36 if (btn === 'yes') {
37 Ext.callback(fn, me.scope, [me, e], 0, me);
38 }
39 },
40 });
41 } else {
42 Ext.callback(fn, me.scope, [me, e], 0, me);
43 }
44 };
45 },
46 });