decide.nolog.cz/app/views/datepicker.js

38 lines
899 B
JavaScript
Raw Normal View History

2014-10-30 21:44:22 +01:00
import Ember from "ember";
export default Ember.View.extend({
2014-07-06 19:22:38 +02:00
classNames: ['datepicker'],
didInsertElement: function() {
var self = this;
this._super();
2014-11-01 18:00:46 +01:00
Ember.$('.datepicker').datepicker({
2014-07-06 19:22:38 +02:00
format: "yyyy-mm-dd hh:mm:ss",
multidate: true,
multidateSeparator: ";",
calendarWeeks: true,
todayHighlight: true,
2014-11-06 21:17:48 +01:00
language: this.get('controller.language.selected')
2014-07-06 19:22:38 +02:00
})
// bind date changes to option array in model
.on('changeDate', function(e){
var dates = e.dates,
newOptions = [];
// sort dates
dates.sort(function(a,b){
return new Date(a) - new Date(b);
});
// get array in correct form
dates.forEach(function(option) {
newOptions.pushObject({title: option});
});
// set options
self.set('_parentView.controller.options', newOptions);
});
}
2014-07-06 17:37:54 +02:00
});