Last active
December 15, 2015 21:19
-
-
Save BlakeWilliams/5324726 to your computer and use it in GitHub Desktop.
Custom Ember view for the jQuery PickADate plugin.
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'], | |
attributeBindings: ['type', 'value', 'placeholder'], | |
type: 'text', | |
tagName: 'input', | |
classNames: 'pickadate', | |
didInsertElement: function() { | |
var options = {} | |
var self = this | |
this.get('events').forEach(function(event) { | |
var callback = self[event]; | |
if(callback) { | |
callback.call(this); | |
} | |
}); | |
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