forked from gsamokovarov/web-console
-
Notifications
You must be signed in to change notification settings - Fork 177
/
Copy pathmain.js.erb
30 lines (24 loc) · 1.15 KB
/
main.js.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
REPLConsole.installInto('console');
// Push the page body upwards by the size of the console
// so it doesn't obscure any of the page content.
//
// An event handler is added to adjust the size of the margin
// whenever the console is resized.
document.addEventListener('DOMContentLoaded', function() {
var consoleElement = document.getElementById('console');
var resizerElement = consoleElement.getElementsByClassName('resizer')[0];
var consoleContainerElement = document.getElementById('console-container');
function setConsoleContainerMargin(pixels) {
consoleContainerElement.style.marginTop = pixels + 'px';
}
var currentConsoleElementHeight = consoleElement.offsetHeight;
setConsoleContainerMargin(currentConsoleElementHeight);
resizerElement.addEventListener('mousedown', function(event) {
function recordConsoleElementHeight(event) {
resizerElement.removeEventListener('mouseup', recordConsoleElementHeight);
var currentConsoleElementHeight = consoleElement.offsetHeight;
setConsoleContainerMargin(currentConsoleElementHeight);
}
resizerElement.addEventListener('mouseup', recordConsoleElementHeight);
});
});