Skip to content

Commit 529c5f6

Browse files
committed
Added support of resizable editor
1 parent b86a695 commit 529c5f6

19 files changed

Lines changed: 47 additions & 2 deletions

public/css/index.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,23 @@ body {
4242
cursor: pointer;
4343
margin: 2px;
4444
}
45-
.row {
45+
.ui-content {
46+
height: 100%;
4647
margin-left: 0;
4748
margin-right: 0;
4849
}
4950
.ui-edit-area {
51+
height: 100%;
5052
/*padding-left: 15px;*/
5153
padding-left: 0 !important;
5254
padding-right: 0 !important;
5355
}
56+
.ui-edit-area .ui-resizable-handle.ui-resizable-e {
57+
cursor: col-resize;
58+
width: 5px;
59+
background-color: white;
60+
box-shadow: 5px 0px 10px #e7e7e7;
61+
}
5462
.ui-view-area {
5563
/*overflow-y: scroll;*/
5664
-webkit-overflow-scrolling: touch;

public/js/index.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,8 @@ function checkResponsive() {
511511
emitUserStatus();
512512
}
513513

514+
var lastEditorWidth = 0;
515+
514516
function checkEditorStyle() {
515517
var scrollbarStyle = editor.getOption('scrollbarStyle');
516518
if (scrollbarStyle == 'overlay' || currentMode == modeType.both) {
@@ -531,6 +533,15 @@ function checkEditorStyle() {
531533
//set sizer height to make it at least height as editor
532534
var editorSizerHeight = ui.area.edit.height() - (statusBar ? statusBar.outerHeight() : 0);
533535
$('.CodeMirror-sizer').css('height', editorSizerHeight + 'px');
536+
//make editor resizable
537+
ui.area.edit.resizable({
538+
handles: 'e',
539+
maxWidth: $(window).width() * 0.7,
540+
minWidth: $(window).width() * 0.2,
541+
stop: function (e) {
542+
lastEditorWidth = ui.area.edit.width();
543+
}
544+
});
534545
}
535546

536547
function checkTocStyle() {
@@ -657,7 +668,7 @@ function changeMode(type) {
657668
ui.area.codemirror.addClass(scrollClass);
658669
ui.area.edit.addClass(responsiveClass).show();
659670
ui.area.view.addClass(scrollClass);
660-
ui.area.view.addClass(responsiveClass).show();
671+
ui.area.view.show();
661672
break;
662673
}
663674
if (currentMode != modeType.view && visibleLG) {
@@ -685,6 +696,17 @@ function changeMode(type) {
685696
} else {
686697
$(document.body).css('background-color', ui.area.codemirror.css('background-color'));
687698
}
699+
//check resizable editor style
700+
if (currentMode == modeType.both) {
701+
if (lastEditorWidth > 0)
702+
ui.area.edit.css('width', lastEditorWidth + 'px');
703+
else
704+
ui.area.edit.css('width', '');
705+
ui.area.edit.find('.ui-resizable-handle').show();
706+
} else {
707+
ui.area.edit.css('width', '');
708+
ui.area.edit.find('.ui-resizable-handle').hide();
709+
}
688710

689711
windowResizeInner();
690712

212 Bytes
Loading
208 Bytes
Loading
335 Bytes
Loading
207 Bytes
Loading
262 Bytes
Loading
262 Bytes
Loading
332 Bytes
Loading
280 Bytes
Loading

0 commit comments

Comments
 (0)