aurelia-bootstrap-datetimepicker
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -119,5 +119,4 @@ define(['exports', 'aurelia-framework', 'moment', 'jquery', './picker-global-options', 'eonasdan-bootstrap-datetimepicker'], function (exports, _aureliaFramework, _moment, _jquery, _pickerGlobalOptions) { | ||
this.domElm.on('dp.change', function (e) { | ||
var format = _this.getOption('format'); | ||
_this.model = (0, _moment2.default)(e.date).toDate(); | ||
_this.value = (0, _moment2.default)(e.date).format(format); | ||
_this.value = (0, _moment2.default)(e.date).format(_this._format); | ||
}); | ||
@@ -164,6 +163,5 @@ | ||
AbpDatetimePickerCustomElement.prototype.bind = function bind() { | ||
var format = void 0; | ||
var options = this.options || this.elm.getAttribute('options'); | ||
if (options) { | ||
format = this._originalDateFormat = options.hasOwnProperty('format') ? options.format : null; | ||
this._format = this._originalDateFormat = options.hasOwnProperty('format') ? options.format : null; | ||
} | ||
@@ -178,3 +176,3 @@ if (this.model) { | ||
this.model = (0, _moment2.default)(value).toDate(); | ||
this.value = (0, _moment2.default)(value).format(format); | ||
this.value = (0, _moment2.default)(value).format(this._format); | ||
} | ||
@@ -282,5 +280,6 @@ }; | ||
} | ||
if (newValue !== oldValue) { | ||
var format = this.getOption('format') || this._originalDateFormat; | ||
this.value = (0, _moment2.default)(newValue).format(format); | ||
if (newValue !== oldValue && newValue) { | ||
if ((0, _moment2.default)(newValue, this._format, true).isValid()) { | ||
this.value = (0, _moment2.default)(newValue).format(this._format); | ||
} | ||
} | ||
@@ -290,4 +289,6 @@ }; | ||
AbpDatetimePickerCustomElement.prototype.valueChanged = function valueChanged(newValue, oldValue) { | ||
if (newValue !== oldValue) { | ||
this.model = (0, _moment2.default)(newValue).toDate(); | ||
if (newValue !== oldValue && newValue) { | ||
if ((0, _moment2.default)(newValue, this._format, true).isValid()) { | ||
this.model = (0, _moment2.default)(newValue).toDate(); | ||
} | ||
} | ||
@@ -294,0 +295,0 @@ }; |
@@ -120,5 +120,4 @@ 'use strict'; | ||
this.domElm.on('dp.change', function (e) { | ||
var format = _this.getOption('format'); | ||
_this.model = (0, _moment2.default)(e.date).toDate(); | ||
_this.value = (0, _moment2.default)(e.date).format(format); | ||
_this.value = (0, _moment2.default)(e.date).format(_this._format); | ||
}); | ||
@@ -165,6 +164,5 @@ | ||
AbpDatetimePickerCustomElement.prototype.bind = function bind() { | ||
var format = void 0; | ||
var options = this.options || this.elm.getAttribute('options'); | ||
if (options) { | ||
format = this._originalDateFormat = options.hasOwnProperty('format') ? options.format : null; | ||
this._format = this._originalDateFormat = options.hasOwnProperty('format') ? options.format : null; | ||
} | ||
@@ -179,3 +177,3 @@ if (this.model) { | ||
this.model = (0, _moment2.default)(value).toDate(); | ||
this.value = (0, _moment2.default)(value).format(format); | ||
this.value = (0, _moment2.default)(value).format(this._format); | ||
} | ||
@@ -283,5 +281,6 @@ }; | ||
} | ||
if (newValue !== oldValue) { | ||
var format = this.getOption('format') || this._originalDateFormat; | ||
this.value = (0, _moment2.default)(newValue).format(format); | ||
if (newValue !== oldValue && newValue) { | ||
if ((0, _moment2.default)(newValue, this._format, true).isValid()) { | ||
this.value = (0, _moment2.default)(newValue).format(this._format); | ||
} | ||
} | ||
@@ -291,4 +290,6 @@ }; | ||
AbpDatetimePickerCustomElement.prototype.valueChanged = function valueChanged(newValue, oldValue) { | ||
if (newValue !== oldValue) { | ||
this.model = (0, _moment2.default)(newValue).toDate(); | ||
if (newValue !== oldValue && newValue) { | ||
if ((0, _moment2.default)(newValue, this._format, true).isValid()) { | ||
this.model = (0, _moment2.default)(newValue).toDate(); | ||
} | ||
} | ||
@@ -295,0 +296,0 @@ }; |
@@ -98,5 +98,4 @@ var _dec, _dec2, _dec3, _dec4, _class, _desc, _value, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11; | ||
this.domElm.on('dp.change', e => { | ||
let format = this.getOption('format'); | ||
this.model = moment(e.date).toDate(); | ||
this.value = moment(e.date).format(format); | ||
this.value = moment(e.date).format(this._format); | ||
}); | ||
@@ -143,6 +142,5 @@ | ||
bind() { | ||
let format; | ||
let options = this.options || this.elm.getAttribute('options'); | ||
if (options) { | ||
format = this._originalDateFormat = options.hasOwnProperty('format') ? options.format : null; | ||
this._format = this._originalDateFormat = options.hasOwnProperty('format') ? options.format : null; | ||
} | ||
@@ -157,3 +155,3 @@ if (this.model) { | ||
this.model = moment(value).toDate(); | ||
this.value = moment(value).format(format); | ||
this.value = moment(value).format(this._format); | ||
} | ||
@@ -255,5 +253,6 @@ } | ||
} | ||
if (newValue !== oldValue) { | ||
let format = this.getOption('format') || this._originalDateFormat; | ||
this.value = moment(newValue).format(format); | ||
if (newValue !== oldValue && newValue) { | ||
if (moment(newValue, this._format, true).isValid()) { | ||
this.value = moment(newValue).format(this._format); | ||
} | ||
} | ||
@@ -263,4 +262,6 @@ } | ||
valueChanged(newValue, oldValue) { | ||
if (newValue !== oldValue) { | ||
this.model = moment(newValue).toDate(); | ||
if (newValue !== oldValue && newValue) { | ||
if (moment(newValue, this._format, true).isValid()) { | ||
this.model = moment(newValue).toDate(); | ||
} | ||
} | ||
@@ -267,0 +268,0 @@ } |
@@ -120,5 +120,4 @@ 'use strict'; | ||
this.domElm.on('dp.change', function (e) { | ||
var format = _this.getOption('format'); | ||
_this.model = moment(e.date).toDate(); | ||
_this.value = moment(e.date).format(format); | ||
_this.value = moment(e.date).format(_this._format); | ||
}); | ||
@@ -165,6 +164,5 @@ | ||
AbpDatetimePickerCustomElement.prototype.bind = function bind() { | ||
var format = void 0; | ||
var options = this.options || this.elm.getAttribute('options'); | ||
if (options) { | ||
format = this._originalDateFormat = options.hasOwnProperty('format') ? options.format : null; | ||
this._format = this._originalDateFormat = options.hasOwnProperty('format') ? options.format : null; | ||
} | ||
@@ -179,3 +177,3 @@ if (this.model) { | ||
this.model = moment(value).toDate(); | ||
this.value = moment(value).format(format); | ||
this.value = moment(value).format(this._format); | ||
} | ||
@@ -283,5 +281,6 @@ }; | ||
} | ||
if (newValue !== oldValue) { | ||
var format = this.getOption('format') || this._originalDateFormat; | ||
this.value = moment(newValue).format(format); | ||
if (newValue !== oldValue && newValue) { | ||
if (moment(newValue, this._format, true).isValid()) { | ||
this.value = moment(newValue).format(this._format); | ||
} | ||
} | ||
@@ -291,4 +290,6 @@ }; | ||
AbpDatetimePickerCustomElement.prototype.valueChanged = function valueChanged(newValue, oldValue) { | ||
if (newValue !== oldValue) { | ||
this.model = moment(newValue).toDate(); | ||
if (newValue !== oldValue && newValue) { | ||
if (moment(newValue, this._format, true).isValid()) { | ||
this.model = moment(newValue).toDate(); | ||
} | ||
} | ||
@@ -295,0 +296,0 @@ }; |
{ | ||
"name": "aurelia-bootstrap-datetimepicker", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "An Aurelia Custom Element for the 3rd party addon [Eonasdan Bootstrap Datepicker]", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -6,2 +6,8 @@ # Aurelia-Bootstrap-Datetimepicker | ||
### Screenshots | ||
Screenshots from the demo app | ||
![Aurelia-Bootstrap-Datetimepicker](/aurelia-bootstrap-datetimepicker/printscreen/abp-datetimepicker.jpg) | ||
### Usage | ||
@@ -8,0 +14,0 @@ A quick example of the code in action. Note that the value is available under the `value.bind`. |
@@ -33,2 +33,3 @@ import {inject, bindable, bindingMode} from 'aurelia-framework'; | ||
_methods = {}; | ||
_format; | ||
@@ -58,5 +59,4 @@ constructor(elm) { | ||
this.domElm.on('dp.change', (e) => { | ||
let format = this.getOption('format'); | ||
this.model = moment(e.date).toDate(); | ||
this.value = moment(e.date).format(format); | ||
this.value = moment(e.date).format(this._format); | ||
}); | ||
@@ -108,6 +108,5 @@ | ||
bind() { | ||
let format; | ||
let options = this.options || this.elm.getAttribute('options'); | ||
if (options) { | ||
format = this._originalDateFormat = options.hasOwnProperty('format') ? options.format : null; | ||
this._format = this._originalDateFormat = options.hasOwnProperty('format') ? options.format : null; | ||
} | ||
@@ -122,3 +121,3 @@ if (this.model) { | ||
this.model = moment(value).toDate(); | ||
this.value = moment(value).format(format); | ||
this.value = moment(value).format(this._format); | ||
} | ||
@@ -277,5 +276,6 @@ } | ||
} | ||
if (newValue !== oldValue) { | ||
let format = this.getOption('format') || this._originalDateFormat; | ||
this.value = moment(newValue).format(format); | ||
if (newValue !== oldValue && newValue) { | ||
if (moment(newValue, this._format, true).isValid()) { | ||
this.value = moment(newValue).format(this._format); | ||
} | ||
} | ||
@@ -285,4 +285,6 @@ } | ||
valueChanged(newValue, oldValue) { | ||
if (newValue !== oldValue) { | ||
this.model = moment(newValue).toDate(); | ||
if (newValue !== oldValue && newValue) { | ||
if (moment(newValue, this._format, true).isValid()) { | ||
this.model = moment(newValue).toDate(); | ||
} | ||
} | ||
@@ -289,0 +291,0 @@ } |
325084
51
1945
266