Comparing version 1.2.9 to 1.2.10
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
[1.2.10] - 2019-02-12 | ||
* fixed bug #36 | ||
[1.2.9] - 2019-01-15 | ||
@@ -5,0 +8,0 @@ * fixed bugs #28, #29, #30 |
@@ -75,6 +75,6 @@ /** | ||
if (typeof i === "string") i = parseInt(i, 10); | ||
if (i === 1 && 'one' in locale) return locale.one; | ||
if ('other' in locale) return locale.other; | ||
return ''; | ||
@@ -255,3 +255,3 @@ } | ||
renderCalendar = function(el, opts) | ||
renderCalendar = function(el, opts) | ||
{ | ||
@@ -266,5 +266,5 @@ var html = '', | ||
html += '<header class="lightpick__month-title-bar">' | ||
html += '<h1 class="lightpick__month-title" data-ym="' + day.format('YYYY-MM') + '">' | ||
+ '<b class="lightpick__month-title-accent">' + day.toDate().toLocaleString(opts.lang, { month: 'long' }) + '</b> ' | ||
+ day.format('YYYY') | ||
html += '<h1 class="lightpick__month-title" data-ym="' + day.format('YYYY-MM') + '">' | ||
+ '<b class="lightpick__month-title-accent">' + day.toDate().toLocaleString(opts.lang, { month: 'long' }) + '</b> ' | ||
+ day.format('YYYY') | ||
+ '</h1>'; | ||
@@ -345,5 +345,5 @@ | ||
for (var i = 1; i <= 12; i++) { | ||
html += '<div class="lightpick__month-of-the-year" data-goto-month="' + ym.format('YYYY') + '-' + i + '">' | ||
html += '<div class="lightpick__month-of-the-year" data-goto-month="' + ym.format('YYYY') + '-' + i + '">' | ||
+ '<div>' + moment(i, 'M').toDate().toLocaleString(opts.lang, { month: 'long' }) + '</div>' | ||
+ '<div>' + ym.format('YYYY') + '</div>' | ||
+ '<div>' + ym.format('YYYY') + '</div>' | ||
+ '</div>'; | ||
@@ -388,3 +388,3 @@ } | ||
if ( | ||
(closestPrev && day.isBefore(closestPrev) && opts.startDate.isAfter(closestPrev)) | ||
(closestPrev && day.isBefore(closestPrev) && opts.startDate.isAfter(closestPrev)) | ||
|| (closestNext && day.isAfter(closestNext) && closestNext.isAfter(opts.startDate)) | ||
@@ -434,4 +434,9 @@ ) { | ||
document.querySelector(opts.parentEl).appendChild(self.el); | ||
if (opts.parentEl instanceof Node) { | ||
opts.parentEl.appendChild(self.el) | ||
} else { | ||
document.querySelector(opts.parentEl).appendChild(self.el); | ||
} | ||
self._onMouseDown = function(e) | ||
@@ -461,3 +466,3 @@ { | ||
end = day.isAfter(opts.startDate) ? moment(day) : moment(opts.startDate), | ||
isInvalidRange = opts.disableDates.filter(function(d) { | ||
@@ -467,6 +472,6 @@ if (d instanceof Array || Object.prototype.toString.call(d) === '[object Array]') { | ||
_to = moment(d[1]); | ||
return _from.isValid() && _to.isValid() && (_from.isBetween(start, end, 'day', '[]') || _to.isBetween(start, end, 'day', '[]')); | ||
} | ||
return moment(d).isBetween(start, end, 'day', '[]'); | ||
@@ -555,6 +560,6 @@ }); | ||
var footerMessage = self.el.querySelector('.lightpick__footer-message'); | ||
if (footerMessage) { | ||
footerMessage.innerHTML = opts.locale.not_allowed_range; | ||
setTimeout(function(){ | ||
@@ -757,6 +762,6 @@ footerMessage.innerHTML = ''; | ||
} | ||
self.setStartDate(opts.field.value); | ||
} | ||
this.syncFields(); | ||
if (!self.isShowing) { | ||
@@ -900,10 +905,4 @@ self.show(); | ||
if (this.getStartDate() === null && moment(this._opts.field.value, this._opts.format).isValid()) { | ||
this._opts.startDate = moment(this._opts.field.value, this._opts.format); | ||
} | ||
this.syncFields(); | ||
if (this.getEndDate() === null && this._opts.secondField && moment(this._opts.secondField.value, this._opts.format).isValid()) { | ||
this._opts.endDate = moment(this._opts.secondField.value, this._opts.format); | ||
} | ||
this.setStartDate(this._opts.startDate, true); | ||
@@ -915,2 +914,13 @@ this.setEndDate(this._opts.endDate, true); | ||
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.secondField && moment(this._opts.secondField.value, this._opts.format).isValid()) { | ||
this._opts.endDate = moment(this._opts.secondField.value, this._opts.format); | ||
} | ||
}, | ||
swapDate: function() | ||
@@ -942,3 +952,3 @@ { | ||
gotoMonth: function(month) | ||
gotoMonth: function(month) | ||
{ | ||
@@ -998,3 +1008,3 @@ if (isNaN(month)) { | ||
left = 0; | ||
if (orientation[0] == 'auto' || !(/top|bottom/.test(orientation[0]))) { | ||
@@ -1179,2 +1189,4 @@ if (rect.bottom + calRect.height > window.innerHeight && window.pageYOffset > calRect.height) { | ||
this.syncFields(); | ||
if (this._opts.secondField && this._opts.secondField === target && this._opts.endDate) { | ||
@@ -1268,2 +1280,2 @@ this.gotoDate(this._opts.endDate); | ||
return Lightpick; | ||
})); | ||
})); |
{ | ||
"name": "lightpick", | ||
"version": "1.2.9", | ||
"version": "1.2.10", | ||
"description": "Javascript date range picker - lightweight, no jQuery", | ||
@@ -5,0 +5,0 @@ "main": "lightpick.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
115079
1866