(function() { var activate, save, template; template = function(values) { var element; element = $('').attr('multiple', 'true'); $.each(values, function(index, value) { return $('').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);