Sha256: 74dd6295dc8abdee30204680d972ae74462bc44a355a000108f360ab5e3014b5

Contents?: true

Size: 1.82 KB

Versions: 36

Compression:

Stored size: 1.82 KB

Contents

(function() {
  var activate, onContentBrowserSave;

  activate = function(element) {
    var cmsField, objId;
    cmsField = $(element);
    if (!cmsField.is('video, audio, img')) {
      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

36 entries across 36 versions & 1 rubygems

Version Path
scrivito_editors-1.5.5 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.5.5.rc1 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.4.3 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.5.4 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.5.4.rc1 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.5.3 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.5.3.rc1 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.5.2 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.5.2.rc1 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.5.1 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.5.1.rc2 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.5.1.rc1 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.5.0 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.5.0.rc2 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.5.0.rc1 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.4.2 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.4.1 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.4.1.rc1 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.4.0 app/assets/javascripts/scrivito_editors/reference_editor.js
scrivito_editors-1.4.0.rc2 app/assets/javascripts/scrivito_editors/reference_editor.js