Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #213 from bjb568/fullscreen-programs
Browse files Browse the repository at this point in the history
Fullscreen bug fixes
  • Loading branch information
bjb568 committed Jun 13, 2015
2 parents 205785a + 71bc01f commit a3168a1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
2 changes: 1 addition & 1 deletion html/dev/canvas.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<section id="main">
<h1><span id="title">$title</span> <a id="fullscreen-button" href="#fullscreen" hidden=""></a> <a id="regular-layout" hidden=""></a> <input type="text" id="edit-title" hidden="" value="$title" /> <small><a id="save">Save</a></small></h1>
<h1><span id="title">$title</span> <input type="text" id="edit-title" hidden="" value="$title" /> <a id="fullscreen-button" href="#fullscreen" hidden=""></a> <a id="regular-layout" hidden=""></a> <small><a id="save">Save</a></small></h1>
<div id="row" class="row">
<textarea id="code" autofocus="">$code</textarea>
<iframe id="output" sandbox="allow-scripts"></iframe>
Expand Down
1 change: 1 addition & 0 deletions http/a/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ body {
.scrl { overflow: auto }
.scrlx { overflow-x: auto }
.scrly, #sidebar { overflow-y: auto }
.noscrl { overflow: hidden }
.br, .desc, aside.rit { border-radius: 4px }
.hglt, .desc, .comment, section, article { background: rgba(255, 255, 255, .4) }
.shglt, #content, #sidebar, #footer { background: rgba(255, 255, 255, .8) }
Expand Down
14 changes: 12 additions & 2 deletions http/dev/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ document.body.appendChild(textarea);
textarea.style.position = 'fixed';
textarea.style.top = '0';
textarea.style.zIndex = '-1';
textarea.style.opacity = '0';
function handleTA() {
if (document.activeElement == textarea || document.activeElement == document.body) {
textarea.focus();
Expand Down Expand Up @@ -54,8 +55,9 @@ Number.prototype.bound = function(l, h) {
};
function requestFullLayoutMode() {
enabledFullScreen = requestEnableFullScreen = true;
size();
document.getElementById('console').style.height = 'auto';
document.getElementById('console').style.maxHeight = '240px';
size();
reset(true);
}
function rand(x, y) {
Expand Down Expand Up @@ -146,18 +148,26 @@ function bg() {
stroke(oldStroke);
}
function size(x, y) {
if (enabledFullScreen) (x = innerWidth) && (y = innerHeight - 4);
if (enabledFullScreen) {
x = innerWidth;
y = innerHeight - document.getElementById('console').offsetHeight - 32;
}
canvas.width = width = x;
canvas.height = height = y;
}
function resetLog() {
var node = document.getElementById('console'), child;
while (child = node.firstChild) node.removeChild(child);
}
function removeLog() {
resetLog();
document.getElementById('console').hidden = true;
}
function print(input) {
var pre = document.createElement('pre');
pre.innerHTML = input;
document.getElementById('console').appendChild(pre);
document.getElementById('console').hidden = false;
}
var refresh = function() {};
function reset(a) {
Expand Down
30 changes: 15 additions & 15 deletions http/dev/runcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,26 @@ addEventListener('DOMContentLoaded', function() {
document.body.classList.remove('fullscreen');
this.hidden = true;
};
function hashChangeFullScreenHandler() {
if (location.hash == '#fullscreen') {
output.classList.add('fullscreen');
document.body.classList.add('noscrl');
document.getElementById('close-fullscreen').hidden = false;
output.focus();
} else {
output.classList.remove('fullscreen');
document.body.classList.remove('noscrl');
document.getElementById('close-fullscreen').hidden = true;
code.focus();
}
}
if (fsBtn) {
fsBtn.onclick = function() {
document.getElementById('close-fullscreen').hidden = false;
enableFullScreen();
};
addEventListener('hashchange', function(e) {
if (location.hash == '#fullscreen') {
output.classList.add('fullscreen');
document.getElementById('close-fullscreen').hidden = false;
output.focus();
} else {
output.classList.remove('fullscreen');
document.getElementById('close-fullscreen').hidden = true;
code.focus();
}
});
if (location.hash == '#fullscreen') {
output.classList.add('fullscreen');
output.focus();
}
addEventListener('hashchange', hashChangeFullScreenHandler);
hashChangeFullScreenHandler();
}
var oldValue;
function handleCode(init) {
Expand Down

0 comments on commit a3168a1

Please sign in to comment.