]>
git.proxmox.com Git - proxmox-widget-toolkit.git/blob - button/Button.js
15619a325309a3a0c56ee65c0de677c5dcca6a14
2 * - observe selection changes to enable/disable the button using enableFn()
3 * - pop up confirmation dialog using confirmMsg()
5 Ext
.define('Proxmox.button.Button', {
6 extend
: 'Ext.button.Button',
7 alias
: 'widget.proxmoxButton',
9 // the selection model to observe
12 // if 'false' handler will not be called (button disabled)
13 enableFn: function(record
) { },
15 // function(record) or text
18 // take special care in confirm box (select no as default).
21 initComponent: function() {
22 /*jslint confusion: true */
27 me
.realHandler
= me
.handler
;
29 me
.handler = function(button
, event
) {
32 rec
= me
.selModel
.getSelection()[0];
33 if (!rec
|| (me
.enableFn(rec
) === false)) {
40 if (Ext
.isFunction(me
.confirmMsg
)) {
41 msg
= me
.confirmMsg(rec
);
43 Ext
.MessageBox
.defaultButton
= me
.dangerous
? 2 : 1;
45 title
: gettext('Confirm'),
46 icon
: me
.dangerous
? Ext
.Msg
.WARNING
: Ext
.Msg
.QUESTION
,
48 buttons
: Ext
.Msg
.YESNO
,
49 callback: function(btn
) {
53 me
.realHandler(button
, event
, rec
);
57 me
.realHandler(button
, event
, rec
);
66 me
.mon(me
.selModel
, "selectionchange", function() {
67 var rec
= me
.selModel
.getSelection()[0];
68 if (!rec
|| (me
.enableFn(rec
) === false)) {
71 me
.setDisabled(false);