This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/date-picker.js.es6
2015-08-10 12:50:38 +02:00

31 lines
744 B
JavaScript

/* global Pikaday:true */
import loadScript from "discourse/lib/load-script";
export default Em.Component.extend({
tagName: "input",
classNames: ["date-picker"],
_picker: null,
_loadDatePicker: function() {
const self = this,
input = this.$()[0];
loadScript("/javascripts/pikaday.js").then(function() {
self._picker = new Pikaday({
field: input,
format: "YYYY-MM-DD",
defaultDate: moment().add(1, "day").toDate(),
minDate: new Date(),
onSelect: function(date) {
self.set("value", moment(date).format("YYYY-MM-DD"));
},
});
});
}.on("didInsertElement"),
_destroy: function() {
this._picker = null;
}.on("willDestroyElement"),
});