Sha256: 997ac1dd29eea841a78318cb7488cb59542349b11505f8f181604406124b9fe8
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
$ -> # Define editor behavior for date attributes. scrivito.on 'editing', -> template = -> $('<input />') .attr('type', 'text') onKeyup = (event) -> key = event.keyCode || event.which switch key when 27 # Esc # Prevent the property view to close when the ESC key is pressed. event.stopPropagation() save = (dateTimeText) -> element = $(this) cmsField = element.data('cmsField') if dateTimeText? && dateTimeText.length > 0 dateTimeText = new Date(dateTimeText) cmsField.scrivito('save', dateTimeText) .done -> cmsField.trigger('save.scrivito_editors') cmsField.trigger('scrivito_reload') $('body').on 'click', '[data-scrivito-field-type="date"]:not(.hasDatepicker):not([data-editor]), [data-editor="date"]', (event) -> event.preventDefault() cmsField = $(this) content = cmsField.html().trim() dateFormat = cmsField.attr('data-date-format') || 'yy-mm-dd' timeFormat = cmsField.attr('data-time-format') || 'HH:mm:ss' $('body').keyup(onKeyup) template() .data('cmsField', cmsField) .insertAfter(cmsField) .val(content) .keyup(onKeyup) .datetimepicker( dateFormat: dateFormat timeFormat: timeFormat onClose: save ) .focus() cmsField.hide()
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
scrivito_editors-0.0.11 | app/assets/javascripts/scrivito_editors/date_editor.js.coffee |