Skip to content

Commit 9ce2156

Browse files
authored
Hide code by default (except when new shader) (#69)
* Hide code by default. * Clean up * Removed css transition prefixes. * Improved buttons styling
1 parent a7ab0a4 commit 9ce2156

File tree

2 files changed

+49
-37
lines changed

2 files changed

+49
-37
lines changed

static/css/codemirror.css

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@
1111
font-size: 14px;
1212
font-weight: bold;
1313
visibility: visible;
14-
14+
1515
/* transition between transparent and semi-transparent black on hover */
1616
transition: background-color 500ms;
17-
-webkit-transition: background-color 500ms;
18-
-o-transition: background-color 500ms;
19-
-moz-transition: background-color 500ms;
20-
-ms-transition: background-color 500ms;
2117
}
2218

2319
.CodeMirror:hover {
@@ -118,4 +114,4 @@ span.CodeMirror-selected {
118114
background-image: url('resizer.png');
119115
background-repeat: no-repeat;
120116
cursor: se-resize;
121-
}
117+
}

static/index.html

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,28 @@
1919

2020
padding: 8px 12px 8px 12px;
2121

22-
border: none;
22+
border: solid 1px #222;
2323
border-radius: 5px;
2424
margin-right: 5px;
2525

2626
color: #ffffff;
2727
background-color: #000000;
2828
opacity: 0.5;
2929

30-
font-family: Monospace;
31-
font-size: 12px;
32-
font-weight: bold;
30+
font-family: monospace;
31+
font-size: 11px;
3332

3433
cursor: pointer;
3534
text-decoration: none;
3635

36+
text-transform: uppercase;
37+
3738
}
3839

3940
button:hover, select:hover, a:hover {
4041

4142
opacity: 1;
42-
box-shadow: 0 0 4px #FFF;
43+
border: solid 1px #FFF;
4344

4445
}
4546

@@ -137,8 +138,8 @@
137138
// Greetings to Iq/RGBA! ;)
138139

139140
var quality = 2, quality_levels = [ 0.5, 1, 2, 4, 8 ];
140-
var toolbar, compileButton, fullscreenButton, compileTimer, errorLines = [];
141-
var code, canvas, gl, buffer, currentProgram, vertexPosition, screenVertexPosition, panButton, timeButton,
141+
var toolbar, showButton, timeButton, compileButton, panButton, fullscreenButton, compileTimer, errorLines = [];
142+
var code, canvas, gl, buffer, currentProgram, vertexPosition, screenVertexPosition,
142143
parameters = { startTime: Date.now(), time: 0, mouseX: 0.5, mouseY: 0.5, screenWidth: 0, screenHeight: 0 },
143144
surface = { centerX: 0, centerY: 0, width: 1, height: 1, isPanning: false, isZooming: false, lastX: 0, lastY: 0 },
144145
frontTarget, backTarget, screenProgram, getWebGL, resizer = {}, compileOnChangeCode = true;
@@ -194,31 +195,14 @@
194195
button.href = '/';
195196
rightside.appendChild( button );
196197

197-
var button = document.createElement( 'button' );
198-
button.textContent = 'hide code';
199-
button.addEventListener( 'click', function ( event ) {
200-
201-
if ( isCodeVisible() ) {
202-
203-
button.textContent = 'show code';
204-
code.getWrapperElement().style.display = 'none';
205-
compileButton.style.visibility = 'hidden';
206-
set_save_button('hidden');
207-
set_parent_button('hidden');
208-
stopHideUI();
209-
210-
} else {
211-
212-
button.textContent = 'hide code';
213-
code.getWrapperElement().style.display = '';
214-
compileButton.style.visibility = 'visible';
215-
set_save_button('visible');
216-
set_parent_button('visible');
198+
showButton = document.createElement( 'button' );
199+
showButton.textContent = 'show code';
200+
showButton.addEventListener( 'click', function () {
217201

218-
}
202+
isCodeVisible() ? hideCode() : showCode();
219203

220204
}, false );
221-
toolbar.appendChild( button );
205+
toolbar.appendChild( showButton );
222206

223207
timeButton = document.createElement( 'button' );
224208
timeButton.textContent = '0:00.00';
@@ -304,7 +288,6 @@
304288
}
305289
}
306290
});
307-
code.getWrapperElement().style.display = '';
308291

309292
resizer.offsetMouseX = 0;
310293
resizer.offsetMouseY = 0;
@@ -440,10 +423,37 @@
440423

441424
compileScreenProgram();
442425

426+
// show code when is new effect
427+
428+
location.hash === '' ? showCode() : hideCode();
429+
430+
}
431+
432+
function showCode() {
433+
434+
showButton.textContent = 'hide code';
435+
code.getWrapperElement().style.visibility = 'visible';
436+
compileButton.style.visibility = 'visible';
437+
set_save_button('visible');
438+
set_parent_button('visible');
439+
440+
}
441+
442+
function hideCode() {
443+
444+
showButton.textContent = 'show code';
445+
code.getWrapperElement().style.visibility = 'hidden';
446+
compileButton.style.visibility = 'hidden';
447+
set_save_button('hidden');
448+
set_parent_button('hidden');
449+
stopHideUI();
450+
443451
}
444452

445453
function isCodeVisible() {
446-
return code && code.getWrapperElement().style.display !== 'none';
454+
455+
return code && code.getWrapperElement().style.visibility === 'visible';
456+
447457
}
448458

449459
var hideUITimer;
@@ -558,6 +568,8 @@
558568

559569
if ( !gl.getProgramParameter( program, gl.LINK_STATUS ) ) {
560570

571+
showCode();
572+
561573
var error = gl.getProgramInfoLog( program );
562574

563575
compileButton.title = error;
@@ -632,6 +644,8 @@
632644

633645
if ( !gl.getProgramParameter( program, gl.LINK_STATUS ) ) {
634646

647+
showCode();
648+
635649
console.error( 'VALIDATE_STATUS: ' + gl.getProgramParameter( program, gl.VALIDATE_STATUS ), 'ERROR: ' + gl.getError() );
636650

637651
return;
@@ -748,6 +762,8 @@
748762

749763
if ( !gl.getShaderParameter( shader, gl.COMPILE_STATUS ) ) {
750764

765+
showCode();
766+
751767
var error = gl.getShaderInfoLog( shader );
752768

753769
// Remove trailing linefeed, for FireFox's benefit.

0 commit comments

Comments
 (0)