Sha256: 43d91ba134ab338a4f25b1c23af2f78a0b3c3a814bc3a01afff747459b383248

Contents?: true

Size: 1.39 KB

Versions: 14

Compression:

Stored size: 1.39 KB

Contents

(function() {
  var activate, showDeleteButton;

  activate = function(element) {
    var cmsField, container;
    cmsField = $(element);
    container = scrivito.editors._setup_binary_button_container(cmsField, 'scrivito-editor-binary-button-container');
    scrivito.editors._file_dropzone(container, function(_, file) {
      return cmsField.scrivito('save', file).then(function() {
        return cmsField.scrivito('reload');
      });
    }, 'image-editor-dragover');
    if (cmsField.scrivito('content') && cmsField.is('[data-scrivito-editors-allow-delete]')) {
      return showDeleteButton(container, cmsField);
    }
  };

  showDeleteButton = function(container, cmsField) {
    if (container && container.find('.delete-binary').length === 0) {
      return $("<a href='#' class='delete-binary editing-button'> <i class='editing-icon editing-icon-trash'></i></a>").prependTo(container).click(function() {
        return cmsField.scrivito('save', null).then(function() {
          return cmsField.scrivito('reload');
        }) && false;
      });
    }
  };

  scrivito.editors.binary_editor = {
    can_edit: function(element) {
      return $(element).is('[data-scrivito-field-type=binary]');
    },
    activate: function(element) {
      return activate(element);
    }
  };

  scrivito.on('load', function() {
    return scrivito.define_editor('binary', scrivito.editors.binary_editor);
  });

}).call(this);

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
scrivito_editors-1.1.1 app/assets/javascripts/scrivito_editors/binary_editor.js
scrivito_editors-1.1.0 app/assets/javascripts/scrivito_editors/binary_editor.js
scrivito_editors-1.1.0.rc3 app/assets/javascripts/scrivito_editors/binary_editor.js
scrivito_editors-1.1.0.rc2 app/assets/javascripts/scrivito_editors/binary_editor.js
scrivito_editors-1.1.0.rc1 app/assets/javascripts/scrivito_editors/binary_editor.js
scrivito_editors-1.0.0 app/assets/javascripts/scrivito_editors/binary_editor.js
scrivito_editors-1.0.0.rc4 app/assets/javascripts/scrivito_editors/binary_editor.js
scrivito_editors-1.0.0.rc3 app/assets/javascripts/scrivito_editors/binary_editor.js
scrivito_editors-1.0.0.rc2 app/assets/javascripts/scrivito_editors/binary_editor.js
scrivito_editors-1.0.0.rc1 app/assets/javascripts/scrivito_editors/binary_editor.js
scrivito_editors-0.90.0 app/assets/javascripts/scrivito_editors/binary_editor.js
scrivito_editors-0.90.0.rc3 app/assets/javascripts/scrivito_editors/binary_editor.js
scrivito_editors-0.90.0.rc2 app/assets/javascripts/scrivito_editors/binary_editor.js
scrivito_editors-0.90.0.rc1 app/assets/javascripts/scrivito_editors/binary_editor.js