diff --git a/js/Popup.js b/js/Popup.js index 053c3b0..82d3993 100644 --- a/js/Popup.js +++ b/js/Popup.js @@ -1,4 +1,6 @@ function Popup(element, mask) { + var autoCloseEnabled = true; + var enterEnabled = true; var self = this; this.open = function(complete, disableMaskClick) { @@ -11,7 +13,7 @@ function Popup(element, mask) { document.body.removeEventListener('touchmove', prevent, false); mask.bind("onButtonClick", self.cancel); $(document).bind("onEscapeKey", self.cancel); - $(document).bind("onEnterKey", self.commit); + if (enterEnabled) $(document).bind("onEnterKey", self.commit); } this.close = function(complete) { @@ -24,16 +26,20 @@ function Popup(element, mask) { document.body.addEventListener('touchmove', prevent, false); mask.unbind("onButtonClick", self.cancel); $(document).unbind("onEscapeKey", self.cancel); - $(document).unbind("onEnterKey", self.commit); + if (enterEnabled) $(document).unbind("onEnterKey", self.commit); } + this.setEnterEnabled = function(enabled) { enterEnabled = enabled; } + + this.setAutoCloseEnabled = function(enabled) { autoCloseEnabled = enabled; } + this.cancel = function() { - self.close(); $(element).trigger('onPopupCancel'); + if (autoCloseEnabled) self.close(); } this.commit = function() { - self.close(); $(element).trigger('onPopupCommit'); + if (autoCloseEnabled) self.close(); } } \ No newline at end of file diff --git a/js/SettingsWindow.js b/js/SettingsWindow.js index d98c8ba..4214c09 100644 --- a/js/SettingsWindow.js +++ b/js/SettingsWindow.js @@ -90,9 +90,13 @@ function SettingsWindow() { this.window = $("#popupSettings"); this.btnOK = this.window.find(".btnOK"); - enableButton(this.btnOK,this.submitwindow); - settingsPopup = new Popup($("#popupSettings"), $("#popupMask")); + settingsPopup.setEnterEnabled(false); + settingsPopup.setAutoCloseEnabled(false); + + enableButton(this.btnOK,settingsPopup.commit); + $("#popupSettings").bind("onPopupCancel", function() { settingsPopup.close(); } ); + $("#popupSettings").bind("onPopupCommit", self.submitwindow); this.window.find("#settingsContainer").load("settings.html", function() { console.log("Settings:finished loading settings.html, now loading settings..."); @@ -155,23 +159,20 @@ function SettingsWindow() { }); }; - this.closeSettings = function(complete) { - settingsPopup.close(complete); - }; +// this.closeSettings = function(complete) { +// settingsPopup.close(complete); +// }; this.submitwindow = function(e) { - disableButton(self.btnOK,self.submitwindow); + disableButton(self.btnOK,settingsPopup.commit); e.preventDefault(); e.stopPropagation(); self.saveSettings(self.readForm(),function(success){ if(success) { - self.closeSettings(function() { - enableButton(self.btnOK,self.submitwindow); - }); + settingsPopup.close(); self.signin(); - } else { - enableButton(self.btnOK,self.submitwindow); } + enableButton(self.btnOK,settingsPopup.commit); }); clearTimeout(self.retryRetrieveNetworkStatusDelay);