<commit_before>import Ember from 'ember';

export default Ember.Mixin.create({
  mustUpdateInput: true,
  value: null,
  minViewMode: undefined,
  format: undefined,

  setupBootstrapDatepicker: Ember.on('didInsertElement', function() {
    var self = this;

    this.$().
      datepicker({
        autoclose: this.get('autoclose'),
        calendarWeeks: this.get('calendarWeeks'),
        clearBtn: this.get('clearBtn'),
        container: this.get('widgetContainer'),
        daysOfWeekDisabled: this.get('daysOfWeekDisabled'),
        defaultViewDate: this.get('defaultViewDate'),
        disableTouchKeyboard: this.get('disableTouchKeyboard'),
        enableOnReadonly: this.get('enableOnReadonly'),
        endDate: this.get('endDate'),
        forceParse: this.get('forceParse'),
        format: this.get('format'),
        immediateUpdates: this.get('immediateUpdates'),
        keyboardNavigation: this.get('keyboardNavigation'),
        language: this.get('language'),
        maxViewMode: this.get('maxViewMode'),
        minViewMode: this.get('minViewMode'),
        multidate: this.get('multidate'),
        multidateSeparator: this.get('multidateSeparator'),
        orientation: this.get('orientation'),
        showOnFocus: this.get('showOnFocus'),
        startDate: this.get('startDate'),
        startView: this.get('startView'),
        todayBtn: this.get('todayBtn'),
        todayHighlight: this.get('todayHighlight'),
        toggleActive: this.get('toggleActive'),
        weekStart: this.get('weekStart'),
        datesDisabled: this.get('datesDisabled')
      }).
      on('changeDate', function(event) {
        Ember.run(function() {
          self._didChangeDate(event);
        });
      }).
      on('input', function() {
        if (!self.$().val()) {
          self.set('value', null);
        }
      });

    this._updateDatepicker();
  }),

  teardownBootstrapDatepicker: Ember.on('willDestroyElement', function() {
    this.$().datepicker('remove');
  }),

  didChangeValue: Ember.observer('value', function() {
    this._updateDatepicker();
  }),

  _didChangeDate: function(event) {
    var value = null;

    if (event.date) {
      if (this.get('multidate')) {
        value = this.$().datepicker('getDates');
      } else {
        value = this.$().datepicker('getDate');
      }
    }

    this.set('mustUpdateInput', false);
    this.set('value', value);
    this.sendAction('changeDate', value);
  },

  _didChangeLanguage: Ember.observer('language', function() {
    this.$().datepicker('remove');
    this.setupBootstrapDatepicker();
  }),

  _updateStartDate: Ember.observer('startDate', function() {
    this.$().datepicker('setStartDate', this.get('startDate'));
    this._updateDatepicker();
  }),

  _updateEndDate: Ember.observer('endDate', function() {
    this.$().datepicker('setEndDate', this.get('endDate'));
    this._updateDatepicker();
  }),

  _updateDatesDisabled: Ember.observer('datesDisabled', function() {
    this.$().datepicker('setDatesDisabled', this.get('datesDisabled'));
    this._updateDatepicker();
  }),

  _updateMinViewMode: Ember.observer('minViewMode', function() {
    this.$().datepicker('minViewMode', this.get('minViewMode'));
    this.$().data('datepicker')._process_options({minViewMode: this.get('minViewMode')});
    this._updateDatepicker();
  }),

  _updateFomat: Ember.observer('format', function() {
    this.$().datepicker('format', this.get('format'));
    this.$().data('datepicker')._process_options({format: this.get('format')});
    this._updateDatepicker();
  }),

<commit_msg>Sync with updates on master<commit_after>import Ember from 'ember';

export default Ember.Mixin.create({
  mustUpdateInput: true,
  value: null,
  // add the observed properties
  minViewMode: undefined,
  format: undefined,
  language: undefined,
  startDate: undefined,
  endDate: undefined,

  setupBootstrapDatepicker: Ember.on('didInsertElement', function() {
    var self = this;

    this.$().
      datepicker({
        autoclose: this.get('autoclose'),
        calendarWeeks: this.get('calendarWeeks'),
        clearBtn: this.get('clearBtn'),
        container: this.get('widgetContainer'),
        daysOfWeekDisabled: this.get('daysOfWeekDisabled'),
        defaultViewDate: this.get('defaultViewDate'),
        disableTouchKeyboard: this.get('disableTouchKeyboard'),
        enableOnReadonly: this.get('enableOnReadonly'),
        endDate: this.get('endDate'),
        forceParse: this.get('forceParse'),
        format: this.get('format'),
        immediateUpdates: this.get('immediateUpdates'),
        keyboardNavigation: this.get('keyboardNavigation'),
        language: this.get('language') || undefined,
        maxViewMode: this.get('maxViewMode'),
        minViewMode: this.get('minViewMode'),
        multidate: this.get('multidate'),
        multidateSeparator: this.get('multidateSeparator'),
        orientation: this.get('orientation'),
        showOnFocus: this.get('showOnFocus'),
        startDate: this.get('startDate'),
        startView: this.get('startView'),
        todayBtn: this.get('todayBtn'),
        todayHighlight: this.get('todayHighlight'),
        toggleActive: this.get('toggleActive'),
        weekStart: this.get('weekStart'),
        datesDisabled: this.get('datesDisabled')
      }).
      on('changeDate', function(event) {
        Ember.run(function() {
          self._didChangeDate(event);
        });
      }).
      on('input', function() {
        if (!self.$().val()) {
          self.set('value', null);
        }
      });

    this._updateDatepicker();
  }),

  teardownBootstrapDatepicker: Ember.on('willDestroyElement', function() {
    this.$().datepicker('remove');
  }),

  didChangeValue: Ember.observer('value', function() {
    this._updateDatepicker();
  }),

  _didChangeDate: function(event) {
    var value = null;

    if (event.date) {
      if (this.get('multidate')) {
        value = this.$().datepicker('getDates');
      } else {
        value = this.$().datepicker('getDate');
      }
    }

    this.set('mustUpdateInput', false);
    this.set('value', value);
    this.sendAction('changeDate', value);
  },

  _didChangeLanguage: Ember.observer('language', function() {
    this.$().datepicker('remove');
    this.setupBootstrapDatepicker();
  }),

  _updateStartDate: Ember.observer('startDate', function() {
    this.$().datepicker('setStartDate', this.get('startDate'));
    this._updateDatepicker();
  }),

  _updateEndDate: Ember.observer('endDate', function() {
    this.$().datepicker('setEndDate', this.get('endDate'));
    this._updateDatepicker();
  }),

  _updateDatesDisabled: Ember.observer('datesDisabled', function() {
    this.$().datepicker('setDatesDisabled', this.get('datesDisabled'));
    this._updateDatepicker();
  }),

  _updateMinViewMode: Ember.observer('minViewMode', function() {
    this.$().datepicker('minViewMode', this.get('minViewMode'));
    this.$().data('datepicker')._process_options({minViewMode: this.get('minViewMode')});
    this._updateDatepicker();
  }),

  _updateFomat: Ember.observer('format', function() {
    this.$().datepicker('format', this.get('format'));
    this.$().data('datepicker')._process_options({format: this.get('format')});
    this._updateDatepicker();
  }),

{'fraction_non_alphanumeric': 0.17105985722130698, 'fraction_numerical': 0.0, 'mean_word_length': 3.5502810743285447, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7304940', 'n_tokens_mistral': 2174, 'n_tokens_neox': 2107, 'n_words': 325}