Sha256: 63a55814fd191a46b0fa615d17a4c38e350179939e298d3e6a18f2b8f5420cd1
Contents?: true
Size: 1.22 KB
Versions: 6
Compression:
Stored size: 1.22 KB
Contents
$ -> # Define editor behavior for multienum attributes. scrivito.on 'load', -> if scrivito.in_editable_view() template = (values) -> element = $('<select></select>') .attr('multiple', 'true') .addClass('form-control') $.each values, (index, value) -> $('<option></option>') .attr('value', value) .text(value) .appendTo(element) element save = (event) -> element = $(event.currentTarget) cmsField = element.data('cmsField') content = element.val() cmsField.scrivito('save', content).done -> cmsField.trigger('save.scrivito_editors') multienumEditSelector = '[data-values][data-scrivito-field-type="multienum"]' + ':not([data-editor]), [data-editor~="multienum"]' $(document).on 'click', multienumEditSelector, (event) -> cmsField = $(event.currentTarget) selected = cmsField.scrivito('content') values = cmsField.data('values') template(values) .data('cmsField', cmsField) .val(selected) .insertAfter(cmsField) .change(save) .focusout(save) .focus() cmsField.hide()
Version data entries
6 entries across 6 versions & 1 rubygems