Sha256: 434f67cd2b8e5ffa3e5d360363ca58a263826edaef4ca8b01932dbae583d1f7b

Contents?: true

Size: 1.94 KB

Versions: 45

Compression:

Stored size: 1.94 KB

Contents

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

  template = function() {
    return $('<input />').attr('type', 'text');
  };

  save = function(datetimepickerElement, dateTimeText, additionalDoneEvent) {
    var cmsField, datetime;
    cmsField = datetimepickerElement.data('cmsField');
    datetime = datetimepickerElement.datetimepicker('getDate');
    return cmsField.scrivito('save', datetime).done(function() {
      cmsField.trigger('save.scrivito_editors');
      if (additionalDoneEvent) {
        return cmsField.trigger(additionalDoneEvent);
      }
    });
  };

  onClose = function(dateTimeText) {
    return save($(this), dateTimeText, 'scrivito_editors:blur');
  };

  onSelect = function(dateTimeText) {
    return save($(this), dateTimeText);
  };

  activate = function(element) {
    var cmsField;
    cmsField = $(element);
    return cmsField.on('click', function(event) {
      var content, dateFormat, options, timeFormat;
      if (cmsField.is('.hasDatepicker')) {
        return;
      }
      event.preventDefault();
      content = cmsField.text().trim();
      dateFormat = cmsField.data('scrivitoEditorsDateFormat');
      timeFormat = cmsField.data('scrivitoEditorsTimeFormat');
      options = {
        onClose: onClose,
        onSelect: onSelect
      };
      options.dateFormat = dateFormat || 'yy-mm-dd';
      if (timeFormat) {
        options.timeFormat = timeFormat;
      }
      template().data('cmsField', cmsField).insertAfter(cmsField).datetimepicker(options).datetimepicker('setDate', $(cmsField).scrivito('content')).focus();
      return cmsField.hide();
    });
  };

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

  scrivito.on('load', function() {
    return scrivito.define_editor('date', scrivito.editors.date_editor);
  });

}).call(this);

Version data entries

45 entries across 45 versions & 1 rubygems

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