aurelia-bootstrap-datetimepicker
Advanced tools
Comparing version
@@ -125,4 +125,9 @@ 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) { | ||
_this2.model = (0, _moment2.default)(e.date).toDate(); | ||
_this2.value = (0, _moment2.default)(e.date).format(_this2._format); | ||
if ((0, _moment2.default)(e.date, _this2._format, true).isValid()) { | ||
_this2.model = (0, _moment2.default)(e.date).toDate(); | ||
_this2.value = (0, _moment2.default)(e.date).format(_this2._format); | ||
} else if (!e.date) { | ||
_this2.model = null; | ||
_this2.value = null; | ||
} | ||
}); | ||
@@ -181,3 +186,3 @@ | ||
if (value) { | ||
if (value && (0, _moment2.default)(value, this._format, true).isValid()) { | ||
this.model = (0, _moment2.default)(value).toDate(); | ||
@@ -289,3 +294,3 @@ this.value = (0, _moment2.default)(value).format(this._format); | ||
AbpDatetimePickerCustomElement.prototype.modelChanged = function modelChanged(newValue, oldValue) { | ||
if (typeof newValue.getMonth !== 'function') { | ||
if (isNaN(Date.parse(newValue)) && newValue !== null) { | ||
throw new Error('Datetimepicker, model.bind must be of type Date'); | ||
@@ -292,0 +297,0 @@ } |
@@ -126,4 +126,9 @@ 'use strict'; | ||
this.domElm.on('dp.change', function (e) { | ||
_this2.model = (0, _moment2.default)(e.date).toDate(); | ||
_this2.value = (0, _moment2.default)(e.date).format(_this2._format); | ||
if ((0, _moment2.default)(e.date, _this2._format, true).isValid()) { | ||
_this2.model = (0, _moment2.default)(e.date).toDate(); | ||
_this2.value = (0, _moment2.default)(e.date).format(_this2._format); | ||
} else if (!e.date) { | ||
_this2.model = null; | ||
_this2.value = null; | ||
} | ||
}); | ||
@@ -182,3 +187,3 @@ | ||
if (value) { | ||
if (value && (0, _moment2.default)(value, this._format, true).isValid()) { | ||
this.model = (0, _moment2.default)(value).toDate(); | ||
@@ -290,3 +295,3 @@ this.value = (0, _moment2.default)(value).format(this._format); | ||
AbpDatetimePickerCustomElement.prototype.modelChanged = function modelChanged(newValue, oldValue) { | ||
if (typeof newValue.getMonth !== 'function') { | ||
if (isNaN(Date.parse(newValue)) && newValue !== null) { | ||
throw new Error('Datetimepicker, model.bind must be of type Date'); | ||
@@ -293,0 +298,0 @@ } |
@@ -100,4 +100,9 @@ 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 => { | ||
this.model = moment(e.date).toDate(); | ||
this.value = moment(e.date).format(this._format); | ||
if (moment(e.date, this._format, true).isValid()) { | ||
this.model = moment(e.date).toDate(); | ||
this.value = moment(e.date).format(this._format); | ||
} else if (!e.date) { | ||
this.model = null; | ||
this.value = null; | ||
} | ||
}); | ||
@@ -156,3 +161,3 @@ | ||
if (value) { | ||
if (value && moment(value, this._format, true).isValid()) { | ||
this.model = moment(value).toDate(); | ||
@@ -258,3 +263,3 @@ this.value = moment(value).format(this._format); | ||
modelChanged(newValue, oldValue) { | ||
if (typeof newValue.getMonth !== 'function') { | ||
if (isNaN(Date.parse(newValue)) && newValue !== null) { | ||
throw new Error('Datetimepicker, model.bind must be of type Date'); | ||
@@ -261,0 +266,0 @@ } |
@@ -127,4 +127,9 @@ 'use strict'; | ||
this.domElm.on('dp.change', function (e) { | ||
_this2.model = moment(e.date).toDate(); | ||
_this2.value = moment(e.date).format(_this2._format); | ||
if (moment(e.date, _this2._format, true).isValid()) { | ||
_this2.model = moment(e.date).toDate(); | ||
_this2.value = moment(e.date).format(_this2._format); | ||
} else if (!e.date) { | ||
_this2.model = null; | ||
_this2.value = null; | ||
} | ||
}); | ||
@@ -183,3 +188,3 @@ | ||
if (value) { | ||
if (value && moment(value, this._format, true).isValid()) { | ||
this.model = moment(value).toDate(); | ||
@@ -291,3 +296,3 @@ this.value = moment(value).format(this._format); | ||
AbpDatetimePickerCustomElement.prototype.modelChanged = function modelChanged(newValue, oldValue) { | ||
if (typeof newValue.getMonth !== 'function') { | ||
if (isNaN(Date.parse(newValue)) && newValue !== null) { | ||
throw new Error('Datetimepicker, model.bind must be of type Date'); | ||
@@ -294,0 +299,0 @@ } |
{ | ||
"name": "aurelia-bootstrap-datetimepicker", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "An Aurelia Custom Element for the 3rd party addon [Eonasdan Bootstrap Datepicker]", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -150,3 +150,5 @@ # Aurelia-Bootstrap-Datetimepicker | ||
For `CLI` you will need to add (`eonasdan-bootstrap-datetimepicker` and `aurelia-bootstrap-datetimepicker`) to your `aurelia.json` file. The exported class is `abp-datetime-picker`. | ||
```javascript | ||
"moment", | ||
{ | ||
@@ -170,2 +172,11 @@ "name": "eonasdan-bootstrap-datetimepicker", | ||
**Note** for `moment.js` locales, if you wish to include all locales, you can include them as shown below with `min/moment-with-locales`. | ||
```javascript | ||
{ | ||
"name": "moment", | ||
"path": "../node_modules/moment", | ||
"main": "min/moment-with-locales" | ||
} | ||
``` | ||
_index.html_ | ||
@@ -198,2 +209,3 @@ ```html | ||
+ plugins: [ | ||
+ // choose the moment.js locale that you want to add, in this example here, we are adding 'en', 'fr' | ||
+ new ContextReplacementPlugin(/moment[\/\\]locale$/, /en|fr/), | ||
@@ -200,0 +212,0 @@ + new ProvidePlugin({ |
@@ -62,4 +62,9 @@ import {inject, bindable, bindingMode, DOM} from 'aurelia-framework'; | ||
this.domElm.on('dp.change', (e) => { | ||
this.model = moment(e.date).toDate(); | ||
this.value = moment(e.date).format(this._format); | ||
if (moment(e.date, this._format, true).isValid()) { | ||
this.model = moment(e.date).toDate(); | ||
this.value = moment(e.date).format(this._format); | ||
} else if (!e.date) { | ||
this.model = null; | ||
this.value = null; | ||
} | ||
}); | ||
@@ -124,3 +129,3 @@ | ||
if (value) { | ||
if (value && moment(value, this._format, true).isValid()) { | ||
this.model = moment(value).toDate(); | ||
@@ -288,3 +293,3 @@ this.value = moment(value).format(this._format); | ||
modelChanged(newValue, oldValue) { | ||
if (typeof newValue.getMonth !== 'function') { | ||
if (isNaN(Date.parse(newValue)) && newValue !== null) { | ||
throw new Error('Datetimepicker, model.bind must be of type Date'); | ||
@@ -291,0 +296,0 @@ } |
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
340115
1.21%52
1.96%2026
1.25%278
4.51%