Skip to content

Commit b7a2c53

Browse files
committed
Merge pull request processing-js#161 from processing-js/consolecss
updated how the console is styled
2 parents a698015 + da3e18a commit b7a2c53

File tree

6 files changed

+588
-488
lines changed

6 files changed

+588
-488
lines changed

lib/Browser.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ module.exports = (function fakeBrowser() {
1919
localName: tag,
2020
style: {},
2121
setAttribute: __empty_func__,
22-
appendChild: __empty_func__
22+
appendChild: __empty_func__,
23+
classList: {
24+
add: __empty_func__,
25+
remove: __empty_func__,
26+
contains: __empty_func__
27+
}
2328
};
2429
};
2530

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "git@github.com/processing-js/processing-js.git"
88
},
99
"main": "processing.min.js",
10-
"bugs": "https://github.com/processing-js/processing-js/issues",
10+
"bugs": "https://github.com/processing-js/processing-js/issues",
1111
"devDependencies": {
1212
"argv": "~0.0.2",
1313
"browserify": "~2.18.1",
@@ -22,5 +22,5 @@
2222
"scripts": {
2323
"test": "node test"
2424
},
25-
"license": "MIT"
25+
"license": "MIT"
2626
}

processing.js

Lines changed: 90 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ window.Processing = require('./src/')(Browser);
2525
},{"./src/":28}],2:[function(require,module,exports){
2626
module.exports={
2727
"name": "processing-js",
28-
"version": "1.4.12",
28+
"version": "1.4.13",
2929
"author": "Processing.js",
3030
"repository": {
3131
"type": "git",
3232
"url": "git@github.com/processing-js/processing-js.git"
3333
},
3434
"main": "processing.min.js",
35-
"bugs": "https://github.com/processing-js/processing-js/issues",
35+
"bugs": "https://github.com/processing-js/processing-js/issues",
3636
"devDependencies": {
3737
"argv": "~0.0.2",
3838
"browserify": "~2.18.1",
@@ -47,7 +47,7 @@ module.exports={
4747
"scripts": {
4848
"test": "node test"
4949
},
50-
"license": "MIT"
50+
"license": "MIT"
5151
}
5252

5353
},{}],3:[function(require,module,exports){
@@ -378,39 +378,90 @@ module.exports = {
378378
},{}],5:[function(require,module,exports){
379379
// the logger for println()
380380
module.exports = function PjsConsole(document) {
381-
var e = {}, added = false;
382-
e.BufferMax = 200;
381+
var e = { BufferMax: 200 },
382+
style = document.createElement("style"),
383+
added = false;
383384

384-
e.wrapper = document.createElement("div");
385+
style.textContent = [
386+
".pjsconsole.hidden {",
387+
" display: none!important;",
388+
"}"
389+
].join('\n');
385390

386-
e.wrapper.setAttribute("style", "opacity:.75;display:block;position:fixed;bottom:0px;left:0px;right:0px;height:50px;background-color:#aaa");
391+
e.wrapper = document.createElement("div");
392+
style.textContent += [
393+
"",
394+
".pjsconsole {",
395+
" opacity: .75;",
396+
" display: block;",
397+
" position: fixed;",
398+
" bottom: 0px;",
399+
" left: 0px;",
400+
" right: 0px;",
401+
" height: 50px;",
402+
" background-color: #aaa;",
403+
"}"
404+
].join('\n');
405+
e.wrapper.classList.add("pjsconsole");
387406

388407
e.dragger = document.createElement("div");
389-
390-
e.dragger.setAttribute("style", "display:block;border:3px black raised;cursor:n-resize;position:absolute;top:0px;left:0px;right:0px;height:5px;background-color:#333");
408+
style.textContent += [
409+
"",
410+
".pjsconsole .dragger {",
411+
" display: block;",
412+
" border: 3px black raised;",
413+
" cursor: n-resize;",
414+
" position: absolute;",
415+
" top: 0px;",
416+
" left: 0px;",
417+
" right: 0px;",
418+
" height: 5px;",
419+
" background-color: #333;",
420+
"}"
421+
].join('\n');
422+
e.dragger.classList.add("dragger");
391423

392424
e.closer = document.createElement("div");
393-
394-
e.closer.onmouseover = function () {
395-
e.closer.style.setProperty("background-color", "#ccc");
396-
};
397-
398-
e.closer.onmouseout = function () {
399-
e.closer.style.setProperty("background-color", "#ddd");
400-
};
401-
425+
style.textContent += [
426+
"",
427+
".pjsconsole .closer {",
428+
" opacity: .5;",
429+
" display: block;",
430+
" border: 3px black raised;",
431+
" position: absolute;",
432+
" top: 10px;",
433+
" right: 30px;",
434+
" height: 20px;",
435+
" width: 20px;",
436+
" background-color: #ddd;",
437+
" color: #000;",
438+
" line-height: 20px;",
439+
" text-align: center;",
440+
" cursor: pointer",
441+
"}"
442+
].join('\n');
443+
e.closer.classList.add("closer");
402444
e.closer.innerHTML = "✖";
403445

404-
e.closer.setAttribute("style", "opacity:.5;display:block;border:3px black raised;position:absolute;top:10px;right:30px;height:20px;width:20px;background-color:#ddd;color:#000;line-height:20px;text-align:center;cursor:pointer;");
405-
406446
e.javaconsole = document.createElement("div");
407-
408-
e.javaconsole.setAttribute("style", "overflow-x: auto;display:block;position:absolute;left:10px;right:0px;bottom:5px;top:10px;overflow-y:scroll;height:40px;");
447+
style.textContent += [
448+
"",
449+
".pjsconsole .console {",
450+
" overflow-x: auto;",
451+
" display: block;",
452+
" position: absolute;",
453+
" left: 10px;",
454+
" right: 0px;",
455+
" bottom: 5px;",
456+
" top: 10px;",
457+
" overflow-y: scroll;",
458+
" height: 40px;",
459+
"}"
460+
].join('\n');
461+
e.javaconsole.setAttribute("class", "console");
409462

410463
e.wrapper.appendChild(e.dragger);
411-
412464
e.wrapper.appendChild(e.javaconsole);
413-
414465
e.wrapper.appendChild(e.closer);
415466

416467
e.dragger.onmousedown = function (t) {
@@ -440,33 +491,29 @@ module.exports = function PjsConsole(document) {
440491
if (e.BufferArray[e.BufferArray.length - 1]) e.BufferArray[e.BufferArray.length - 1] += (t) + "";
441492
else e.BufferArray.push(t);
442493
e.javaconsole.innerHTML = e.BufferArray.join('');
443-
if (e.wrapper.style.visibility === "hidden") {
444-
e.wrapper.style.visibility = "visible";
445-
}
446-
if (e.wrapper.style.visibility === "hidden") {
447-
e.wrapper.style.visibility = "visible";
448-
}
494+
e.showconsole();
449495
};
450496

451497
e.println = function () {
452-
if(!added) { document.body.appendChild(e.wrapper); }
498+
if(!added) {
499+
document.body.appendChild(style);
500+
document.body.appendChild(e.wrapper);
501+
added = true;
502+
}
453503
var args = Array.prototype.slice.call(arguments);
454504
args.push('<br>');
455505
e.print.apply(e, args);
456-
if (e.BufferArray.length > e.BufferMax) e.BufferArray.splice(0, 1);
457-
else e.javaconsole.scrollTop = e.javaconsole.scrollHeight;
458-
};
459-
e.showconsole = function () {
460-
e.wrapper.style.visibility = "visible";
506+
if (e.BufferArray.length > e.BufferMax) {
507+
e.BufferArray.splice(0, 1);
508+
} else {
509+
e.javaconsole.scrollTop = e.javaconsole.scrollHeight;
510+
}
461511
};
462512

463-
e.hideconsole = function () {
464-
e.wrapper.style.visibility = "hidden";
465-
};
513+
e.showconsole = function () { e.wrapper.classList.remove("hidden"); };
514+
e.hideconsole = function () { e.wrapper.classList.add("hidden"); };
466515

467-
e.closer.onclick = function () {
468-
e.hideconsole();
469-
};
516+
e.closer.onclick = function () { e.hideconsole(); };
470517

471518
e.hideconsole();
472519

@@ -2107,7 +2154,7 @@ module.exports = function(options,undef) {
21072154

21082155
// set up the template element
21092156
var element = document.createElement("span");
2110-
element.style.cssText = 'position: absolute; top: 0; left: 0; opacity: 0; font-family: "PjsEmptyFont", fantasy;';
2157+
element.style.cssText = 'position: absolute; top: -1000; left: 0; opacity: 0; font-family: "PjsEmptyFont", fantasy;';
21112158
element.innerHTML = "AAAAAAAA";
21122159
document.body.appendChild(element);
21132160
this.template = element;

0 commit comments

Comments
 (0)