scrivito.editors._file_dropzone = (fields, callback) -> fields.each(-> setup $(this), callback) setup = (el, callback) -> field = el.closest('[data-scrivito-field-name]') el.on 'dragenter', -> field.addClass('image-editor-dragover') and off el.on 'dragleave', -> field.removeClass('image-editor-dragover') and off el.on 'drop', (e) -> field.removeClass 'image-editor-dragover' if (files = e.originalEvent.dataTransfer?.files)?.length is 1 callback field, files[0] off