diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 6238b2c1f2..23521824ff 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -1232,7 +1232,19 @@ phpbb.applyCodeEditor = function(textarea) { }); }; -phpbb.applyDragNDrop = function(textarea) { +/** + * Show drag and drop animation when textarea is present + * + * This function will enable the drag and drop animation for a specified + * textarea. + * + * @param {object} textarea Textarea DOM object to apply editor to + */ +phpbb.showDragNDrop = function(textarea) { + if (textarea === 'undefined') { + return; + } + $('body').on('dragenter dragover', function () { $(textarea).addClass('drag-n-drop'); }).on('dragleave dragout dragend drop', function() { diff --git a/phpBB/assets/javascript/editor.js b/phpBB/assets/javascript/editor.js index 45060c113b..c58e4d19dd 100644 --- a/phpBB/assets/javascript/editor.js +++ b/phpBB/assets/javascript/editor.js @@ -355,7 +355,9 @@ function getCaretPosition(txtarea) { textarea = doc.forms[form_name].elements[text_name]; phpbb.applyCodeEditor(textarea); - phpbb.applyDragNDrop(textarea); + if ($('#attach-panel').length) { + phpbb.showDragNDrop(textarea); + } }); })(jQuery);