Skip to content

Commit

Permalink
write explanatory comments publiclab#8897
Browse files Browse the repository at this point in the history
  • Loading branch information
noi5e committed Jan 9, 2021
1 parent fd606ba commit fe2c155
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/assets/javascripts/dragdrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@ jQuery(function() {
$('#side-dropzone').removeClass('hover');
});
$('.dropzone').on('drop',function(e) {
// this 'drop' listener is also reused for pages with just one form, ie. /wiki/new
$D.selected = $(e.target).closest('div.comment-form-wrapper').eq(0);
e.preventDefault();
let params = {};
if ($D.selected.hasOwnProperty(0)) {
params['textarea'] = $D.selected[0].querySelector('textarea').id
// $D.selected will look different for multi vs. single form pages, because of what $.closest returns:
// multiple comments: { 0: the_closest_element }
// /wiki/new: .comment-form-wrapper doesn't exist!
if ($D.selected.hasOwnProperty(0)) { // eg. jQuery finds a .comment-form-wrapper somewhere on the page.
params['textarea'] = $D.selected[0].querySelector('textarea').id // assign the ID of the textarea within the closest comment-form-wrapper
} else {
params['textarea'] = 'text-input'
// default to #text-input
// ideally there should only be one per page
params['textarea'] = 'text-input'
}
$E.initialize(params);
});
Expand Down

0 comments on commit fe2c155

Please sign in to comment.