#set ($HIDE_CONFIRM_TITLE = $CommonFunctions.encodeJavaScriptString($CommonFunctions.getTermFromResourceBundle($currentUserId, "GSprintDialog", "gsprintdialog.title.hideconfirm"))) #set ($HIDE_CONFIRM_MSG = $CommonFunctions.encodeJavaScriptString($CommonFunctions.getTermFromResourceBundle($currentUserId, "GSprintDialog", "gsprintdialog.msg.hideconfirm"))) Ext.namespace("Bxt"); Bxt.BMSWindow = Ext.extend(Ext.Window, { // Prototype Defaults, can be overridden by user's config object confirmHide : false, formCtrl : null, saveFunc : null, origVals : null, initComponent: function(){ // Call parent (required) Bxt.BMSWindow.superclass.initComponent.apply(this, arguments); this.on('show', function(component) { this.origVals = null; this.origVals = Ext.encode(this.formCtrl.getForm().getValues()); }, this); this.formCtrl.getForm().on('actioncomplete', function(component) { this.origVals = Ext.encode(this.formCtrl.getForm().getValues()); }, this); this.on('beforehide', function(component) { if (this.isDirty(Ext.encode(this.formCtrl.getForm().getValues())) && !this.confirmHide) { Ext.Msg.show({ title:'$HIDE_CONFIRM_TITLE', msg: '$HIDE_CONFIRM_MSG', buttons: Ext.Msg.YESNOCANCEL, fn: this.confirmHandler.createDelegate(this), animEl: this.getEl(), icon: Ext.MessageBox.QUESTION }); return false; } else { return true; } }, this); }, confirmHandler : function(btn) { if (btn == "yes") { this.saveFunc(); } else if (btn == "no") { this.confirmHide = true; this.hide(); } }, isDirty : function(newVals) { return (this.origVals != newVals); }, setOriginalValues : function(origVals) { this.origVals = Ext.encode(origVals); } });