mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 01:07:56 +01:00
Change settings window to use popup handlers as well.
This commit is contained in:
parent
74b9149175
commit
7288ac8b1e
14
js/Popup.js
14
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();
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user