-
Notifications
You must be signed in to change notification settings - Fork 0
/
datepicker.js
50 lines (42 loc) · 1.11 KB
/
datepicker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Kendo.DatePicker = Ember.TextField.extend({
fields: ['culture', 'depth', 'start', 'format'],
dateFields: ['min', 'max', 'value'],
willInsertElement: function() {
var i, f,
options = {
change: $.proxy(this._change, this)
};
if(this.get('options')) {
options = this.get('options');
}
else {
for(i = 0; i < this.dateFields.length; i++) {
f = this.dateFields[i];
if(this.get(f))
options[f] = kendo.parseDate(this.get(f));
}
for(i = 0; i < this.fields.length; i++) {
f = this.fields[i];
if(this.get(f)) {
options[f] = this.get(f);
}
}
}
this.$().kendoDatePicker(options);
this.set('value', this._data().value());
this.set('min', this._data().min());
this.set('max', this._data().max());
},
_data: function() {
return this.$().data('kendoDatePicker');
},
_change: function() {
this.set('value', this._data().value());
},
_fixupStringToDateOrSetKendoValue: function() {
if(typeof this.get('value') === 'string')
this.set('value', kendo.parseDate(this.get('value')));
else
this._data().value(this.get('value'));
}.observes('value')
});