Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.10 backport] Make editor big where needed #8590

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
}
4 changes: 2 additions & 2 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 @@ -55,4 +55,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