Skip to content
This repository has been archived by the owner on Mar 20, 2022. It is now read-only.

Commit

Permalink
improve sync
Browse files Browse the repository at this point in the history
  • Loading branch information
wakirin committed Feb 13, 2019
1 parent eff1de3 commit 564037b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

[1.2.11] - 2019-02-13
* Improve sync values with fields

[1.2.10] - 2019-02-12
* fixed bug #36

Expand Down
25 changes: 20 additions & 5 deletions lightpick.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@
}
}

this.syncFields();
self.syncFields();

if (!self.isShowing) {
self.show();
Expand Down Expand Up @@ -902,12 +902,27 @@

syncFields: function()
{
if (moment(this._opts.field.value, this._opts.format).isValid()) {
this._opts.startDate = moment(this._opts.field.value, this._opts.format);
if (this._opts.singleDate || this._opts.secondField) {
if (moment(this._opts.field.value, this._opts.format).isValid()) {
this._opts.startDate = moment(this._opts.field.value, this._opts.format);
}

if (this._opts.secondField && moment(this._opts.secondField.value, this._opts.format).isValid()) {
this._opts.endDate = moment(this._opts.secondField.value, this._opts.format);
}
}
else {
var dates = this._opts.field.value.split(this._opts.separator);

if (dates.length === 2) {
if (moment(dates[0], this._opts.format).isValid()) {
this._opts.startDate = moment(dates[0], this._opts.format);
}

if (this._opts.secondField && moment(this._opts.secondField.value, this._opts.format).isValid()) {
this._opts.endDate = moment(this._opts.secondField.value, this._opts.format);
if (moment(dates[1], this._opts.format).isValid()) {
this._opts.endDate = moment(dates[1], this._opts.format);
}
}
}
},

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lightpick",
"version": "1.2.10",
"version": "1.2.11",
"description": "Javascript date range picker - lightweight, no jQuery",
"main": "lightpick.js",
"scripts": {
Expand Down

0 comments on commit 564037b

Please sign in to comment.