diff options
author | Alex Xu <alex_y_xu@yahoo.ca> | 2013-07-14 14:07:53 -0400 |
---|---|---|
committer | Alex Xu <alex_y_xu@yahoo.ca> | 2013-07-14 14:07:53 -0400 |
commit | 1e340e15fd069a9983f8bf9f3ddc1d013265ee67 (patch) | |
tree | c071e9b30052bdc078437e0fd1061645cd07606b /www/js | |
parent | 522121bef7211c28e848218f31a5019a9724b1d4 (diff) | |
download | html5ks-1e340e15fd069a9983f8bf9f3ddc1d013265ee67.tar.xz html5ks-1e340e15fd069a9983f8bf9f3ddc1d013265ee67.zip |
fix various bugs
Diffstat (limited to 'www/js')
-rw-r--r-- | www/js/api.js | 6 | ||||
-rw-r--r-- | www/js/menu.js | 31 |
2 files changed, 27 insertions, 10 deletions
diff --git a/www/js/api.js b/www/js/api.js index 5b494ab..91a28d7 100644 --- a/www/js/api.js +++ b/www/js/api.js @@ -200,15 +200,15 @@ window.html5ks.api = { bgleft: { xpos: 0.4, xanchor: 0.5, ypos: 1.0, yanchor: 1.0 }, bgright: { xpos: 0.6, xanchor: 0.5, ypos: 1.0, yanchor: 1.0 } }; - var pos = positions[location]; + var pos = positions[location] || positions["center"]; // TODO: implement transitions if (pos) { el.style.left = pos.xpos * 800 + "px"; el.style.top = pos.ypos * 600 + "px"; el.style.marginLeft = "-" + pos.xanchor * el.width + "px"; el.style.marginTop = "-" + pos.yanchor * el.height + "px"; - el.style.display = "block"; } + el.style.display = "block"; } deferred.resolve(); }; @@ -231,7 +231,7 @@ window.html5ks.api = { image = type; break; default: - image = "sprites/" + name + "/" + name + "_" + type + ".png"; + image = "sprites/" + name + "/" + (type && type.indexOf("_close") > -1 ? "close/" : "") + name + "_" + type + ".png"; } } if (typeof image == "string") { diff --git a/www/js/menu.js b/www/js/menu.js index ca0637f..4259ce1 100644 --- a/www/js/menu.js +++ b/www/js/menu.js @@ -30,6 +30,7 @@ main: { start: document.getElementById("start"), optionsButton: document.getElementById("options-button"), + quit: document.getElementById("quit") } }; }, @@ -57,29 +58,45 @@ console.error("unknown option type %s", option.type); } } + + this.elements.main.optionsButton.addEventListener("click", function () { + html5ks.menu.dialog("options"); + }, false); }, init: function () { this.initElements(); this.initOptions(); + this.elements.main.start.addEventListener("click", function () { if (this._imachine_loaded) { this.elements.mainMenu.style.display = "none"; html5ks.imachine.start().then(this.mainMenu.bind(this)); } }.bind(this), false); - this.elements.main.optionsButton.addEventListener("click", function () { - html5ks.menu.dialog("options"); - }, false); - this.elements.dialog.return.addEventListener("click", function (e) { - html5ks.menu.activeDialog.style.display = "none"; - html5ks.menu.elements.dialogs.style.display = "none"; - }, false); html5ks.fetch("imachine").then(function () { var start = this.elements.main.start; start.className = start.className.replace("button-disabled", ""); this._imachine_loaded = true; }.bind(this)); + + this.elements.dialog.return.addEventListener("click", function (e) { + html5ks.menu.activeDialog.style.display = "none"; + html5ks.menu.elements.dialogs.style.display = "none"; + }, false); + + ["AppleWebKit", "MSIE", "Trident"].forEach(function (ua) { + if (navigator.userAgent.indexOf(ua) > -1) { + var quit = this.elements.main.quit; + quit.className = quit.className.replace("button-disabled", ""); + this.elements.main.quit.addEventListener("click", function () { + window.close(); + top.open('','_self',''); + top.close(); + }, false); + return false; + } + }, this); } }; }()); |