App.PickADate = Ember.View.extend({ | |
attributes: ['monthsFull', 'monthsShort', 'weekdaysFull', 'weekdaysShort', | |
'monthPrev', 'monthNext', 'showMonthsFull', 'showWeekdaysShort', 'today', | |
'clear', 'format', 'formatSubmit', 'hiddenSuffix', 'firstDay', 'monthSelector', | |
'yearSelector', 'dateMin', 'dateMax', 'datesDisabled', 'disablePicker'], | |
events: ['onOpen', 'onClose', 'onSelect', 'onStart'], | |
tagName: 'input', | |
classNames: 'pickadate', | |
didInsertElement: function() { | |
var options = {}; | |
var self = this; | |
this.get('events').forEach(function(event) { | |
var callback = self[event]; | |
if (callback) { | |
options[event] = callback | |
} | |
}); | |
this.get('attributes').forEach(function(attr) { | |
if (self[attr] !== undefined) { | |
options[attr] = self[attr]; | |
} | |
}); | |
var onSelectCallback = options.onSelect; | |
options.onSelect = function() { | |
Ember.set(self, 'value', this.getDate(true)); | |
if (onSelectCallback) { | |
onSelectCallback.call(this) | |
} | |
} | |
this.$().pickadate(options); | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment