Sha256: 94d2998df7da37e20a38fef86324bc5ca60d87b4f8df6ba96d9acd584d85182b

Contents?: true

Size: 1.76 KB

Versions: 9

Compression:

Stored size: 1.76 KB

Contents

(function() {
  var activate, onContentBrowserSave;

  activate = function(element) {
    var cmsField, objId;
    cmsField = $(element);
    objId = cmsField.scrivito('content');
    if (objId && !cmsField.children().length) {
      scrivito.description_for_editor([objId]).then(function(results) {
        return cmsField.text(results[0]);
      });
    }
    return cmsField.on('click', function(event) {
      var filterContext, filters, isImage, selected;
      event.preventDefault();
      selected = [cmsField.scrivito('content')].filter(function(element) {
        return element;
      });
      isImage = cmsField.is('img');
      filters = cmsField.data('scrivitoEditorsFilters');
      filterContext = $.extend({
        _image: isImage
      }, cmsField.data('scrivitoEditorsFilterContext'));
      return scrivito.content_browser.open({
        filters: filters,
        filter_context: filterContext,
        selection: selected,
        selection_mode: 'single'
      }).done((function(_this) {
        return function(selection) {
          return onContentBrowserSave(selection, cmsField);
        };
      })(this));
    });
  };

  onContentBrowserSave = function(selection, cmsField) {
    var value;
    value = selection[0] || null;
    cmsField.scrivito('save', value).done(function() {
      cmsField.trigger('save.scrivito_editors');
      return cmsField.scrivito('reload');
    });
    return true;
  };

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

  scrivito.on('load', function() {
    return scrivito.define_editor('reference', scrivito.editors.reference_editor);
  });

}).call(this);

Version data entries

9 entries across 9 versions & 1 rubygems

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