Created
April 12, 2013 22:29
-
-
Save BlakeWilliams/5375707 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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