RememberChoiceMessageBox.js (1803B)
1 /** 2 * Implementation of a message box which supports a "remember choice" checkbox. 3 */ 4 Ext.define('PartKeepr.RememberChoiceMessageBox', { 5 extend: 'Ext.window.MessageBox', 6 7 escButtonAction: null, 8 9 /** 10 * The user preference to set when "remember choice" is selected 11 * @var string 12 */ 13 dontAskAgainProperty: null, 14 15 /** 16 * The value to set the user preference to 17 */ 18 dontAskAgainValue: false, 19 20 initComponent: function () 21 { 22 this.callParent(); 23 24 this.rememberChoiceCheckbox = Ext.create("Ext.form.field.Checkbox", { 25 boxLabel: i18n("Don't ask again"), 26 margin: { 27 top: 10 28 } 29 }); 30 31 this.promptContainer.add(this.rememberChoiceCheckbox); 32 33 }, 34 onEsc: function () 35 { 36 if (this.escButtonAction !== null) { 37 var btnIdx; 38 39 switch (this.escButtonAction) { 40 case "ok": 41 btnIdx = 0; 42 break; 43 case "yes": 44 btnIdx = 1; 45 break; 46 case "no": 47 btnIdx = 2; 48 break; 49 case "cancel": 50 btnIdx = 3; 51 break; 52 default: 53 btnIdx = 3; 54 break; 55 } 56 57 this.btnCallback(this.msgButtons[btnIdx]); 58 } else { 59 this.callParent(); 60 } 61 }, 62 btnCallback: function (btn, event) 63 { 64 this.callParent(arguments); 65 66 if (btn.itemId === "ok") { 67 if (this.rememberChoiceCheckbox.getValue()) { 68 PartKeepr.getApplication().setUserPreference(this.dontAskAgainProperty, this.dontAskAgainValue); 69 } 70 } 71 72 } 73 });