Skip to content

Commit

Permalink
Bug: Fix Image Drag & Drop Cross-Wiring in Edit Comment Form (#8897)
Browse files Browse the repository at this point in the history
* add test for comment image crosswiring

* wrap everything in comment-form-wrapper, assign .selected in drop listener (#8670)

* delete defunct function, fix indentation & spacing #8670

* rewrite tests that rely on comment-form-wrapper

* remove deprecated code, comments; fix indent

* initialize  on pageload (#8670)

* rewrite for multiple file inputs

* change test to focus on image drag & drop #8670

* restore E.initialize call in drop #8670

* undo E.initialize call #8670

* assign unique IDs to comment form textareas #8670

* change ID selectors to class ones to match new IDs #8670

* fix indentation #8670

* change ID reference to class reference #8670

* initialize E with parameters in drop listener #8670

* update tests for new text-input selectors #8670

* change ID text-input reference to class ref #8670

* change text-input ID to class #8670

* drop: initialize E with params #8670

* remove semicolon
  • Loading branch information
noi5e authored Jan 8, 2021
1 parent 73c336a commit d38da1c
Show file tree
Hide file tree
Showing 10 changed files with 427 additions and 423 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/atwho_autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
limit: 100
}

$('textarea#text-input')
$('textarea.text-input')
.atwho(at_config)
.atwho(hashtags_config)
.atwho(emojis_config);
Expand Down
16 changes: 8 additions & 8 deletions app/assets/javascripts/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@
$('.comment-form').each(function() {
if(!$(this).hasClass('bound-success')) {
$(this).addClass('bound-success').bind('ajax:success', function(e, data, status, xhr){
$(this).find('#text-input').prop('disabled',false);
$(this).find('#text-input').val('');
$(this).find('.text-input').prop('disabled',false);
$(this).find('.text-input').val('');
$('#comments-container').append(xhr.responseText);
$(this).find(".btn-primary").button('reset');
$(this).find('#preview').hide();
$(this).find('#text-input').show();
$(this).find('.text-input').show();
$(this).find('#preview-btn').button('toggle');
});
}

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

if(!$(this).hasClass('bound-error')) {
$(this).addClass('bound-error').bind('ajax:error', function(e,response){
notyNotification('mint', 3000, 'error', 'topRight', 'Some error occured while adding comment');
$(this).find('#text-input').prop('disabled',false);
$(this).find('.text-input').prop('disabled',false);
$(this).find('.control-group').addClass('has-error')
$(this).find('.control-group .help-block ').remove()
$(this).find('#text-input').val('');
$(this).find('.text-input').val('');
$(this).find('.control-group').append('<span class="help-block ">Error: there was a problem.</span>')
});
}

if(!$(this).hasClass('bound-keypress')) {
$(this).addClass('bound-keypress');

$(this).find('#text-input').val('');
$(this).find('.text-input').val('');
$(this).on('keypress', function (e) {
var isPostCommentShortcut = (e.ctrlKey && e.keyCode === 10) || (e.metaKey && e.keyCode === 13);

Expand Down
Loading

0 comments on commit d38da1c

Please sign in to comment.