diff --git a/app/assets/javascripts/comment.js b/app/assets/javascripts/comment.js index 0715459e34..da5dc92abf 100644 --- a/app/assets/javascripts/comment.js +++ b/app/assets/javascripts/comment.js @@ -7,9 +7,9 @@ $(this).find('.text-input').val(''); $('#comments-container').append(xhr.responseText); $(this).find(".btn-primary").button('reset'); - $(this).find('#preview').hide(); + $(this).find('.comment-preview').hide(); $(this).find('.text-input').show(); - $(this).find('#preview-btn').button('toggle'); + $(this).find('.preview-btn').button('toggle'); }); } diff --git a/app/assets/javascripts/editor.js b/app/assets/javascripts/editor.js index 823813b9a8..82cdf9f24d 100644 --- a/app/assets/javascripts/editor.js +++ b/app/assets/javascripts/editor.js @@ -8,7 +8,7 @@ $E = { $E.textarea = $('#'+args['textarea']) $E.textarea.bind('input propertychange',$E.save) // preview - args['preview'] = args['preview'] || 'preview' + args['preview'] = args['preview'] || 'preview-main' $E.preview = $('#'+args['preview']) marked.setOptions({ @@ -35,7 +35,7 @@ $E = { $E.textarea = ($D.selected).find('textarea').eq(0); $E.textarea.bind('input propertychange',$E.save); // preview - $E.preview = ($D.selected).find('#preview').eq(0); + $E.preview = ($D.selected).find('.comment-preview').eq(0); }, // wraps currently selected text in textarea with strings a and b wrap: function(a,b,args) { @@ -123,25 +123,17 @@ $E = { generate_preview: function(id,text) { $('#'+id)[0].innerHTML = marked(text) }, - toggle_preview: function (comment_id = null) { + toggle_preview: function() { let previewBtn; let dropzone; // if the element is part of a multi-comment page, // ensure to grab the current element and not the other comment element. - if (comment_id) { - previewBtn = $('#' + comment_id); - const currentComment = $('#'+comment_id).parent('.control-group') - $E.preview = currentComment.siblings('#preview') - dropzone = currentComment.siblings('.dropzone') - $E.textarea = dropzone.children('.text-input') - } else { - previewBtn = $(this.textarea.context).find('#post_comment'); - dropzone = $(this.textarea.context).find('.dropzone'); - } + previewBtn = $(this.textarea.context).find('.preview-btn'); + dropzone = $(this.textarea.context).find('.dropzone'); - $E.preview[0].innerHTML = marked($E.textarea.val()) - $E.preview.toggle() - dropzone.toggle() + $E.preview[0].innerHTML = marked($E.textarea.val()); + $E.preview.toggle(); + dropzone.toggle(); this.toggleButtonPreviewMode(previewBtn); }, diff --git a/app/assets/stylesheets/editor.css b/app/assets/stylesheets/editor.css index ee219b5089..c7b6d02024 100644 --- a/app/assets/stylesheets/editor.css +++ b/app/assets/stylesheets/editor.css @@ -86,18 +86,18 @@ version of the editor is released. */ border-radius: 3px; } +.comment-preview { + margin:0; + margin-bottom:10px; + background:white; +} + .moderation-notice { font-style: italic; color: #888; padding-left: 8px; } -#preview { - margin:0; - margin-bottom:10px; - background:white; -} - .side-dropzone, .profile-dropzone { border:4px dashed #ccc; color: #aaa; diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 90e98dcd60..49e68c83e9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -66,7 +66,7 @@ def feature_node(title) end # used in views/comments/_form.html.erb - def get_large_dropzone_id(location, reply_to) + def get_comment_form_id(location, reply_to) case location when :main '-main' diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index a9ac3eeb6a..187a6f148b 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -34,8 +34,8 @@ - <% dropzone_large_id = get_large_dropzone_id(location, local_assigns[:reply_to]) %> -