$ -> selector = '[data-scrivito-field-type=binary]:not([data-editor])' status_indicator_class = 'image-editor-dragover' image_container_class = 'scrivito-editor-image-container' handle_file_upload = (event, element, file) -> element.scrivito('save', file).then -> element.scrivito('reload') delete_binary = (cms_field) -> if $(cms_field).scrivito('content') $(cms_field).scrivito('save', null).then -> $(cms_field).scrivito('reload') binary_field_container = (binary_field) -> if $(binary_field).prop('tagName') == 'IMG' if $(binary_field).parent(".#{image_container_class}").length == 0 $(binary_field).wrap("
") $(binary_field).parent(".#{image_container_class}") else binary_field add_delete_to_binary = (binary_element) -> if $(binary_element).scrivito('content') container = binary_field_container(binary_element) if $(container).find('delete-binary').length == 0 delete_icon = $( '' + '' ) delete_icon.click (event) -> event.preventDefault() delete_binary(binary_element) $(container).prepend(delete_icon) scrivito.on 'content', (content_root) -> if scrivito.in_editable_view() binary_elements = $(content_root).find( "#{selector}[data-scrivito-editors-allow-delete]") for binary_element in binary_elements add_delete_to_binary(binary_element) scrivito.on 'load', -> if scrivito.in_editable_view() scrivito.editors._file_drop_zone(selector, handle_file_upload, status_indicator_class)