diff --git a/main.css b/main.css index 6b20717..0cb83fd 100644 --- a/main.css +++ b/main.css @@ -60,6 +60,25 @@ div.progress-container:hover div.hint { width: 686px; } +body.bare #main.window { + position: fixed; + left: 0; + top: 0; +} +/* +This is goood to get rid of in chrome, but other browsers don't have a sensible +title bar (on Mac at least) +*/ + +body.bare #titlebar { + display: none; +} + +_::-webkit-full-page-media, _:future, :root body.bare #titlebar { + display: block; +} + + #Trats, #Plots, #Plots table, #Quests, #Quests table { diff --git a/main.js b/main.js index e38c9e4..e24c26d 100644 --- a/main.js +++ b/main.js @@ -990,8 +990,39 @@ function FormCreate() { var name = unescape(window.location.href.split('#')[1]); storage.loadSheet(name, LoadGame); + + if (window.opener) { + // Opened as a popup, so go bare style + prepPopup(); + } } +function prepPopup() { + document.body.classList.add("bare"); + window.resizeBy($("#main")[0].offsetWidth - window.innerWidth, + $("#main")[0].offsetHeight - window.innerHeight); + + let titlebar = $("#titlebar"); + let delta; + + titlebar.on("mousedown", e => { + delta = { + x: e.pageX, + y: e.pageY + }; + console.log(delta); + }); + + $("html").on("mouseup", e => { delta = null; }); + + $("html").on("mousemove", e => { + if (!e.which) delta = null; + if (delta) { + window.moveBy(e.pageX - delta.x, + e.pageY - delta.y); + } + }); +} function pause(msec) { @@ -1004,7 +1035,13 @@ function pause(msec) { function quit() { $(window).unbind('unload'); - SaveGame(function () { window.location.href = "roster.html"; }); + SaveGame(() => { + if (window.opener) { + window.close(); + } else { + window.location.href = "roster.html"; + } + }); } @@ -1163,6 +1200,20 @@ function FormKeyDown(e) { alert('Saved (' + JSON.stringify(game).length + ' bytes).'); } + if (key === 'w') { + if (window.opener) return; + $(window).unbind('unload'); // we're about to save it anyway + SaveGame(() => { + let ext = window.open(window.location.href, "Progress Quest", + `resizable,width=${$("#main")[0].offsetWidth},height=${$("#main")[0].offsetHeight},popup,location=0`); + console.log(ext); + if(ext && !ext.closed && typeof ext.closed !== 'undefined') { + // popup was apparently not blocked + window.location.href = "roster.html"; // this window can go back to the roster + } + }); + } + /* if (key === 't') { TaskBar.reposition(TaskBar.Max()); diff --git a/progros.css b/progros.css index 2dd44fe..947260b 100644 --- a/progros.css +++ b/progros.css @@ -112,6 +112,10 @@ body { margin-top: 1em; } +body.bare { + background: silver; +} + div.scroll { overflow: scroll; height: 100px;