Allow date-picker component to be extended with custom options.

This commit is contained in:
Guo Xiang Tan 2016-01-13 17:04:38 +08:00
parent 65e808b26d
commit 4f9eb0fc67

View file

@ -12,13 +12,15 @@ export default Em.Component.extend({
const input = this.$()[0]; const input = this.$()[0];
loadScript("/javascripts/pikaday.js").then(() => { loadScript("/javascripts/pikaday.js").then(() => {
this._picker = new Pikaday({ const default_opts = {
field: input, field: input,
format: "YYYY-MM-DD", format: "YYYY-MM-DD",
defaultDate: moment().add(1, "day").toDate(), defaultDate: moment().add(1, "day").toDate(),
minDate: new Date(), minDate: new Date(),
onSelect: date => this.set("value", moment(date).format("YYYY-MM-DD")), onSelect: date => this.set("value", moment(date).format("YYYY-MM-DD"))
}); };
this._picker = new Pikaday(Object.assign(default_opts, this._opts()));
}); });
}, },
@ -27,4 +29,8 @@ export default Em.Component.extend({
this._picker = null; this._picker = null;
}, },
_opts: function() {
return null;
}
}); });