Skip to content

Commit 6fd31f9

Browse files
committed
vertical and horizontal split of ide/terminal at runtime
1 parent ac5de88 commit 6fd31f9

File tree

3 files changed

+46
-22
lines changed

3 files changed

+46
-22
lines changed

src/resources/css/scribbler-landing.css

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ nav {
7171
}
7272

7373
.ide {
74-
width: 0%;
75-
height: inherit;
74+
width: 100%;
75+
height: 100%;
7676
position: inherit;
7777
margin: initial;
7878
text-align: left;
@@ -97,7 +97,7 @@ nav {
9797

9898
.terminal {
9999
width: 100%;
100-
height: inherit;
100+
height: 100%;
101101
position: inherit;
102102
margin: initial;
103103
text-align: left;
@@ -308,12 +308,6 @@ nav {
308308
}
309309

310310
@media (max-width: 750px) {
311-
.terminal {
312-
width: 70%;
313-
}
314-
.demo__terminal {
315-
width: 70%;
316-
}
317311
.tab__container > ul {
318312
right: auto;
319313
left: 0;
@@ -677,6 +671,12 @@ display: block;
677671
float: left;
678672
cursor: ew-resize;
679673
}
674+
675+
.gutter.gutter-vertical {
676+
float: left;
677+
cursor: ew-resize;
678+
}
679+
680680
/* Add arrow indicator to the gutter */
681681
.gutter::after {
682682
content: '';
@@ -702,7 +702,7 @@ display: block;
702702
opacity: 0.2;
703703
}
704704

705-
.gutter.gutter-horizontal:hover::after {
705+
.gutter.gutter-vertical:hover::after {
706706
opacity: 0.8;
707707
}
708708

src/resources/index.html

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ <h4 class="mb-1">
294294
<div class="fullscreen-toggle tooltip" id="debug-play-button" onclick="RunandDebug();"><i class="fa fas" style="font-size:12px;">debug</i><span class="tooltiptext">Debug Editor Code</span></div>
295295
<div class="fullscreen-toggle tooltip" id="download-button" onclick="DownloadEditor();"><i class="fa fa-download"></i><span class="tooltiptext">Download Editor Code</span></div>
296296
<div class="fullscreen-toggle tooltip" id="upload-button" onclick="document.getElementById('fileToLoad').click();"><i class="fa fa-upload"><input type="file" id="fileToLoad" oninput="uploadFile();" style="display: none;"></i><span class="tooltiptext">Upload Files to OpenREPL Server</span></div>
297+
<div class="fullscreen-toggle rotate-fa tooltip" id="rotate-button" onclick="ToggleRotateEditor();"><i class="fa fa-mobile"></i><span class="tooltiptext revrotate-fa">Flip/Rotate Editor and REPL</span></div>
297298
</div>
298299
<div class="ide" id="ide" >
299300
<h2>Welcome to <span class="go__color">Open</span>REPL</h2>
@@ -493,7 +494,6 @@ <h2>Welcome to <span class="go__color">Open</span>REPL</h2>
493494

494495
<!-- ends here -->
495496
</div>
496-
<div class="gutter gutter-horizontal" id="gutter-div"></div>
497497
<div class="terminal-div" id="terminal-div">
498498
<div class="terminal-tabs" id="terminal-tabs">
499499
<div class="tab active"><span class="tab-title">Terminal</span></div>
@@ -655,16 +655,8 @@ <h3 class="section__title">Share/Collaborate</h3>
655655
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.15/jstree.min.js"></script>
656656
<script src="./js/scribbler.js"></script>
657657
<script>
658-
/*var inst = Split(['.ide', '.terminal'], {
659-
gutterSize: 3,
660-
sizes: [50,50]
661-
});*/
662-
if (ismob()) {
663-
$("#gutter-div").toggleClass("hide-tag");
664-
} else {
665-
ToggleEditor();
666-
}
667-
LoadOptionFromUrl();
658+
ToggleEditor();
659+
LoadOptionFromUrl();
668660
var demo_done = localStorage.getItem("OpenREPL_Demo");
669661
if (demo_done !== "done") {
670662
// demo not done

src/resources/js/scribbler.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ function ToggleFunction() {
169169
}
170170

171171
var einst = null;
172+
var direction = null;
172173

173174
// updates editor content by ID
174175
function updateEditorContent(cmd="", content="/* Welcome to openrepl! */", forceupdate=false) {
@@ -244,7 +245,16 @@ function SaveSelectedNodeToFile(oldSelectedNodeId, errcallback=null) {
244245
}
245246
}
246247

247-
function ToggleEditor() {
248+
function ToggleEditor(direction=null) {
249+
if (direction===null) {
250+
// first time
251+
if (ismob()) {
252+
direction = 'vertical';
253+
} else {
254+
direction = 'horizontal'
255+
}
256+
257+
}
248258
TermElement = get("#terminal-div");
249259
ideElement = get("#ide");
250260
editorbtn = get("#editor-button");
@@ -257,6 +267,7 @@ function ToggleEditor() {
257267
einst = Split(['#ide', '#terminal-div'], {
258268
gutterSize: 3,
259269
sizes: [55,45],
270+
direction: direction,
260271
onDrag: function(event) {
261272
let currentMouseX = event[0] || 0;
262273
let prevMouseX = default_prevMouseX;
@@ -294,6 +305,27 @@ function ToggleEditor() {
294305
einst = null;
295306
}
296307
}
308+
/* rotates direction of editor/REPL vertical <-> horizontal */
309+
function ToggleRotateEditor() {
310+
if (direction===null) {
311+
// first time
312+
if (ismob()) {
313+
direction = 'vertical';
314+
} else {
315+
direction = 'horizontal';
316+
}
317+
} else {
318+
//toggle direction
319+
if (direction=='vertical') {
320+
direction = 'horizontal';
321+
} else if (direction=='horizontal') {
322+
direction = 'vertical';
323+
}
324+
}
325+
einst.destroy();
326+
einst = null; // destroy and reset splitter
327+
ToggleEditor(direction);
328+
}
297329

298330
function ToggleReconnect() {
299331
const optionMenu = get("#optionMenu");

0 commit comments

Comments
 (0)