Skip to content

Commit

Permalink
Merge comments/edit & comments/form Partials (publiclab#9183)
Browse files Browse the repository at this point in the history
* merge comments/_edit & comments/_form partials

* delete templates functionality

* merge comments/_edit & comments/_form partials; change #edit-comment-form-wrapper to #comment-form-wrapper-edit

* stop attaching ajax:event to edit forms

* stop running scripts on edit forms

* add hidden_field_tag for reply_to
  • Loading branch information
noi5e authored and billymoroney1 committed Dec 28, 2021
1 parent e8c92e1 commit d7603f5
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 186 deletions.
10 changes: 6 additions & 4 deletions app/assets/javascripts/comment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$(function() {
// attach AJAX eventHandlers to comment forms for form submission
// EXCEPT for edit comment forms (those don't use AJAX form submission)
$('.comment-form').each(function() {
if(!$(this).hasClass('bound-success')) {
if(!$(this).hasClass('bound-success') && !$(this).hasClass('edit-comment-form')) {
$(this).addClass('bound-success').on('ajax:success', function(e, data, status, xhr){
$(this).find('.text-input').prop('disabled',false);
$(this).find('.text-input').val('');
Expand All @@ -12,15 +14,15 @@ $(function() {
});
}

if(!$(this).hasClass('bound-beforeSend')) {
if(!$(this).hasClass('bound-beforeSend') && !$(this).hasClass('edit-comment-form')) {
$(this).addClass('bound-beforeSend').on('ajax:beforeSend', function(event){
$(this).find(".text-input").prop('disabled',true)
$(this).find('.text-input').val('');
$(this).find(".btn-primary").button('loading',true);
});
}

if(!$(this).hasClass('bound-error')) {
if(!$(this).hasClass('bound-error') && !$(this).hasClass('edit-comment-form')) {
$(this).addClass('bound-error').on('ajax:error', function(e,response){
notyNotification('mint', 3000, 'error', 'topRight', 'Some error occured while adding comment');
$(this).find('.text-input').prop('disabled',false);
Expand All @@ -31,7 +33,7 @@ $(function() {
});
}

if(!$(this).hasClass('bound-keypress')) {
if(!$(this).hasClass('bound-keypress') && !$(this).hasClass('edit-comment-form')) {
$(this).addClass('bound-keypress');

$(this).find('.text-input').val('');
Expand Down
104 changes: 0 additions & 104 deletions app/views/comments/_edit.html.erb

This file was deleted.

Loading

0 comments on commit d7603f5

Please sign in to comment.