From 4f9eb0fc677c2fbcfcd4ba10d29907bd1c7672a9 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Wed, 13 Jan 2016 17:04:38 +0800 Subject: [PATCH] Allow date-picker component to be extended with custom options. --- .../discourse/components/date-picker.js.es6 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/components/date-picker.js.es6 b/app/assets/javascripts/discourse/components/date-picker.js.es6 index 3f7c446f5c6..906724ea43f 100644 --- a/app/assets/javascripts/discourse/components/date-picker.js.es6 +++ b/app/assets/javascripts/discourse/components/date-picker.js.es6 @@ -12,13 +12,15 @@ export default Em.Component.extend({ const input = this.$()[0]; loadScript("/javascripts/pikaday.js").then(() => { - this._picker = new Pikaday({ + const default_opts = { field: input, format: "YYYY-MM-DD", defaultDate: moment().add(1, "day").toDate(), 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; }, + _opts: function() { + return null; + } + });