0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-22 17:27:57 +01:00

Generalized Popups

This commit is contained in:
peteruithoven 2014-01-16 21:30:57 +01:00
parent 548ea2732a
commit bbed35d877
8 changed files with 119 additions and 133 deletions

View File

@ -1,4 +1,5 @@
var shapeResolution=3; var shapeResolution=3;
var shapePopup;
function initShapeDialog() { function initShapeDialog() {
$("#btnShapeOk").on("onButtonClick",onShapeOk); $("#btnShapeOk").on("onButtonClick",onShapeOk);
@ -6,18 +7,19 @@ function initShapeDialog() {
$("#btnShapePlus").on("onButtonHold",onShapePlus); $("#btnShapePlus").on("onButtonHold",onShapePlus);
$("#btnShapeMin").on("onButtonHold",onShapeMin); $("#btnShapeMin").on("onButtonHold",onShapeMin);
updateShapePreview(); updateShapePreview();
shapePopup = new Popup($("#popupShape"), $("#popupMask"));
} }
function showShapeDialog() { function showShapeDialog() {
showPopup(popupShape); shapePopup.open();
} }
function onShapeCancel() { function onShapeCancel() {
hidePopup(popupShape); shapePopup.close();
} }
function onShapeOk() { function onShapeOk() {
hidePopup(popupShape); shapePopup.close();
var res = shapeResolution; var res = shapeResolution;

View File

@ -1,11 +1,20 @@
function showPopup(popup) { function Popup(element,mask) {
popupMask.fadeIn(POPUP_SHOW_DURATION);
popup.fadeIn(POPUP_SHOW_DURATION);
keyboardShortcutsEnabled=false;
}
function hidePopup(popup) { var self = this;
popupMask.fadeOut(POPUP_SHOW_DURATION);
popup.fadeOut(POPUP_SHOW_DURATION); this.open = function(complete,disableMaskClick) {
keyboardShortcutsEnabled=true; mask.fadeIn(POPUP_SHOW_DURATION);
element.fadeIn(POPUP_SHOW_DURATION, complete);
keyboardShortcutsEnabled=false;
document.body.removeEventListener('touchmove',prevent,false);
mask.bind("onButtonClick", function() { self.close() });
}
this.close = function(complete) {
mask.fadeOut(POPUP_SHOW_DURATION);
element.fadeOut(POPUP_SHOW_DURATION,complete);
keyboardShortcutsEnabled=true;
document.body.addEventListener('touchmove',prevent,false);
mask.unbind("onButtonClick");
}
} }

View File

@ -1,9 +1,11 @@
//these settings are defined in the firmware (conf_defaults.lua) and will be initialized in loadSettings() //these settings are defined in the firmware (conf_defaults.lua) and will be initialized in loadSettings()
var settings = { } var settings = { }
var settingsPopup;
//wrapper to prevent scoping issues in showSettings() //wrapper to prevent scoping issues in showSettings()
function openSettingsWindow() { function openSettingsWindow() {
settingsWindow.showSettings(); settingsWindow.loadSettings(function() { // reload settings
settingsPopup.open();
});
} }
function SettingsWindow() { function SettingsWindow() {
@ -73,10 +75,12 @@ function SettingsWindow() {
this.wifiboxURL = wifiboxURL; this.wifiboxURL = wifiboxURL;
this.wifiboxCGIBinURL = wifiboxCGIBinURL; this.wifiboxCGIBinURL = wifiboxCGIBinURL;
this.window = $("#settings"); this.window = $("#popupSettings");
this.btnOK = this.window.find(".btnOK"); this.btnOK = this.window.find(".btnOK");
enableButton(this.btnOK,this.submitwindow); enableButton(this.btnOK,this.submitwindow);
settingsPopup = new Popup($("#popupSettings"), $("#popupMask"));
this.window.find("#settingsContainer").load("settings.html", function() { this.window.find("#settingsContainer").load("settings.html", function() {
console.log("Settings:finished loading settings.html, now loading settings..."); console.log("Settings:finished loading settings.html, now loading settings...");
@ -130,6 +134,14 @@ function SettingsWindow() {
}); //this.window.find }); //this.window.find
} //this.init } //this.init
this.openSettings = function() {
self.loadSettings(function() { // reload settings
settingsPopup.open();
});
}
this.closeSettings = function(complete) {
settingsPopup.close(complete);
}
this.submitwindow = function(e) { this.submitwindow = function(e) {
disableButton(self.btnOK,self.submitwindow); disableButton(self.btnOK,self.submitwindow);
@ -137,7 +149,7 @@ function SettingsWindow() {
e.stopPropagation(); e.stopPropagation();
self.saveSettings(self.readForm(),function(success){ self.saveSettings(self.readForm(),function(success){
if(success) { if(success) {
self.hideSettings(function() { self.closeSettings(function() {
enableButton(self.btnOK,self.submitwindow); enableButton(self.btnOK,self.submitwindow);
}); });
self.signin(); self.signin();
@ -149,23 +161,6 @@ function SettingsWindow() {
clearTimeout(self.retryRetrieveNetworkStatusDelay); clearTimeout(self.retryRetrieveNetworkStatusDelay);
} }
this.showSettings = function() {
keyboardShortcutsEnabled = false;
this.loadSettings(function() { // reload settings
$("#contentOverlay").fadeIn(175, function() {
document.body.removeEventListener('touchmove',prevent,false);
});
});
}
this.hideSettings = function(complete) {
keyboardShortcutsEnabled = true;
$("#contentOverlay").fadeOut(175, function() {
document.body.addEventListener('touchmove',prevent,false);
// self.window.css("display","none");
complete();
});
}
this.loadSettings = function(complete) { this.loadSettings = function(complete) {
if (!communicateWithWifibox) { if (!communicateWithWifibox) {
console.log(" communicateWithWifibox is false: settings aren't being loaded from wifibox...") console.log(" communicateWithWifibox is false: settings aren't being loaded from wifibox...")

View File

@ -1,26 +1,26 @@
var wordArtPopup;
function initWordArt() { function initWordArt() {
$("body").append('<div id="svgfont" style="display:none"></div>'); $("body").append('<div id="svgfont" style="display:none"></div>');
$("#svgfont").load("img/font.svg?"); $("#svgfont").load("img/font.svg?");
$("#btnWordArtOk").on("onButtonClick",onWordArtOk); $("#btnWordArtOk").on("onButtonClick",onWordArtOk);
$("#btnWordArtCancel").on("onButtonClick",onWordArtCancel); $("#btnWordArtCancel").on("onButtonClick",onWordArtCancel);
wordArtPopup = new Popup($("#popupWordArt"),$("#popupMask"));
} }
function showWordArtDialog() { function showWordArtDialog() {
buttonGroupAdd.hide(); buttonGroupAdd.hide();
showPopup(popupWordArt); wordArtPopup.open();
popupMask.bind("onButtonClick", onWordArtCancel);
$("#txtWordArt").focus(); $("#txtWordArt").focus();
$("#txtWordArt").val(""); //clear textbox $("#txtWordArt").val(""); //clear textbox
} }
function onWordArtCancel() { function onWordArtCancel() {
popupMask.unbind("onButtonClick"); wordArtPopup.close();
hidePopup(popupWordArt);
} }
function onWordArtOk() { function onWordArtOk() {
hidePopup(popupWordArt); wordArtPopup.close();
var s = $("#txtWordArt").val(); var s = $("#txtWordArt").val();
drawTextOnCanvas(s); drawTextOnCanvas(s);
} }

View File

@ -3,10 +3,7 @@
SETTINGS POPUP - MOBILE SETTINGS POPUP - MOBILE
*/ */
#contentOverlay { #popupSettings {
z-index: 200;
#settings {
width: 87%; width: 87%;
height: 82%; height: 82%;
margin: 6% 4%; margin: 6% 4%;
@ -15,4 +12,3 @@
width: 14%; width: 14%;
} }
} }
}

View File

@ -3,20 +3,7 @@
SETTINGS POPUP SETTINGS POPUP
*/ */
#contentOverlay { #popupSettings {
background-color: rgba(255, 255, 255, 0.65);
z-index: 20;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
display:none;
user-select: text;
#settings {
background-color: #fff; background-color: #fff;
position: absolute; position: absolute;
top: 0; top: 0;
@ -90,4 +77,3 @@
} }
} }
} }
}

View File

@ -140,8 +140,7 @@
</div> </div>
</div> </div>
<div id="contentOverlay"> <div id="popupSettings" class="popup">
<div id="settings">
<div class="toppanel"> <div class="toppanel">
<div id="settingsLabelContainer"> <div id="settingsLabelContainer">
<img id="settingsLabelImg" src="img/settings_lable.png" alt="settings" /> <img id="settingsLabelImg" src="img/settings_lable.png" alt="settings" />
@ -157,7 +156,6 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<div id="portrait"> <div id="portrait">
<img id="vertImage" src="img/bg_vertical.png"/> <img id="vertImage" src="img/bg_vertical.png"/>