Sha256: 5b23588c1f4acd9eecf4bd9166f05e9862cdd6a6b6e8530b64fa62b129678e7b

Contents?: true

Size: 1.41 KB

Versions: 14

Compression:

Stored size: 1.41 KB

Contents

(function() {
  var activate, save, template;

  template = function(values) {
    var element;
    element = $('<select></select>').attr('multiple', 'true');
    $.each(values, function(index, value) {
      return $('<option></option>').attr('value', value).text(value).appendTo(element);
    });
    return element;
  };

  save = function(event) {
    var cmsField, content, element, ref;
    element = $(event.currentTarget);
    cmsField = element.data('cmsField');
    content = (ref = element.val()) != null ? ref : [];
    return cmsField.scrivito('save', content).done(function() {
      return cmsField.trigger('save.scrivito_editors');
    });
  };

  activate = function(element) {
    var cmsField;
    cmsField = $(element);
    return cmsField.on('click', function() {
      var selected, values;
      selected = cmsField.scrivito('content');
      values = cmsField.scrivito('allowed_values');
      template(values).data('cmsField', cmsField).val(selected).insertAfter(cmsField).change(save).focusout(save).focus();
      return cmsField.hide();
    });
  };

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

  scrivito.on('load', function() {
    return scrivito.define_editor('multienum', scrivito.editors.multienum_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/multienum_editor.js
scrivito_editors-1.1.0 app/assets/javascripts/scrivito_editors/multienum_editor.js
scrivito_editors-1.1.0.rc3 app/assets/javascripts/scrivito_editors/multienum_editor.js
scrivito_editors-1.1.0.rc2 app/assets/javascripts/scrivito_editors/multienum_editor.js
scrivito_editors-1.1.0.rc1 app/assets/javascripts/scrivito_editors/multienum_editor.js
scrivito_editors-1.0.0 app/assets/javascripts/scrivito_editors/multienum_editor.js
scrivito_editors-1.0.0.rc4 app/assets/javascripts/scrivito_editors/multienum_editor.js
scrivito_editors-1.0.0.rc3 app/assets/javascripts/scrivito_editors/multienum_editor.js
scrivito_editors-1.0.0.rc2 app/assets/javascripts/scrivito_editors/multienum_editor.js
scrivito_editors-1.0.0.rc1 app/assets/javascripts/scrivito_editors/multienum_editor.js
scrivito_editors-0.90.0 app/assets/javascripts/scrivito_editors/multienum_editor.js
scrivito_editors-0.90.0.rc3 app/assets/javascripts/scrivito_editors/multienum_editor.js
scrivito_editors-0.90.0.rc2 app/assets/javascripts/scrivito_editors/multienum_editor.js
scrivito_editors-0.90.0.rc1 app/assets/javascripts/scrivito_editors/multienum_editor.js