Skip to content

Commit

Permalink
Make editor big where needed
Browse files Browse the repository at this point in the history
This way the editor textarea gets maximized most of the times, that is
what users want.
Don't show always the bottom box. We prefer to see more from the
editor textarea.

Co-authored-by: Eduardo Navarro <enavarro@suse.com>
  • Loading branch information
hellcp and eduardoj committed Jul 24, 2019
1 parent 344d0c0 commit eb30e4a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/api/app/assets/javascripts/webui2/cm2/use-codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function cmMarkDiffLines(id) {
$('#revision_details_' + id + ' .cm-negative').parents('.CodeMirror-line').addClass('CodeMirror-negative-line');
}

function use_codemirror(id, read_only, mode) {
function use_codemirror(id, read_only, mode, big_editor) {
var codeMirrorOptions = {
lineNumbers: true,
matchBrackets: false,
Expand All @@ -36,6 +36,10 @@ function use_codemirror(id, read_only, mode) {
var textarea = $('#editor_' + id);
var editor = CodeMirror.fromTextArea(document.getElementById("editor_" + id), codeMirrorOptions);
editor.id = id;
if (big_editor) {
$(editor.getWrapperElement()).addClass('big-editor');
editor.refresh();
}

cmMarkDiffLines(id);
editor.on('scroll', function() { cmMarkDiffLines(id); });
Expand Down
4 changes: 4 additions & 0 deletions src/api/app/assets/stylesheets/webui2/cm2.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
.short-progress {
height: 5px;
}

.big-editor {
height: auto;
}
6 changes: 3 additions & 3 deletions src/api/app/views/webui2/shared/_editor.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:ruby
save ||= {}
style ||= { read_only: false }
style ||= { read_only: false, big_editor: true }
uid ||= next_codemirror_uid
content_for(:head_style, codemirror_style(style))

Expand Down Expand Up @@ -31,7 +31,7 @@
= text_area_tag("editor_#{uid}", text, cols: '0', rows: '0', data: data, class: 'form-control')

- unless style[:read_only]
.sticky-bottom.bg-light{ id: "bottom_#{uid}" }
.bg-light{ id: "bottom_#{uid}" }
.card-footer
.d-flex.justify-content-end
%p.small.text-muted
Expand All @@ -50,4 +50,4 @@
= render partial: 'shared/editor_modal', locals: { uid: uid }

- content_for :ready_function do
use_codemirror(#{uid}, #{style[:read_only]}, '#{mode}');
use_codemirror(#{uid}, #{style[:read_only]}, '#{mode}', #{style[:big_editor]});
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
= calculate_filename(filename, file)
%span.badge{ class: "badge-#{file['state']}" }= file['state'].capitalize
%div
= render partial: 'shared/editor', locals: { text: diff_content, mode: 'diff', style: { read_only: true } }
= render partial: 'shared/editor', locals: { text: diff_content, mode: 'diff', style: { read_only: true, big_editor: false } }
- else
.card{ id: "revision_details_#{index}" }
.card-header
Expand Down

0 comments on commit eb30e4a

Please sign in to comment.