|
|
@@ -58,6 +58,16 @@ function monthSelectPlugin(pluginConfig) {
|
|
|
frag.appendChild(month);
|
|
|
}
|
|
|
self.monthsContainer.appendChild(frag);
|
|
|
+ if (fp.config.minDate &&
|
|
|
+ fp.currentYear === fp.config.minDate.getFullYear())
|
|
|
+ fp.prevMonthNav.classList.add("flatpickr-disabled");
|
|
|
+ else
|
|
|
+ fp.prevMonthNav.classList.remove("flatpickr-disabled");
|
|
|
+ if (fp.config.maxDate &&
|
|
|
+ fp.currentYear === fp.config.maxDate.getFullYear())
|
|
|
+ fp.nextMonthNav.classList.add("flatpickr-disabled");
|
|
|
+ else
|
|
|
+ fp.nextMonthNav.classList.remove("flatpickr-disabled");
|
|
|
}
|
|
|
function bindEvents() {
|
|
|
fp._bind(fp.prevMonthNav, "click", function (e) {
|
|
|
@@ -143,21 +153,25 @@ function monthSelectPlugin(pluginConfig) {
|
|
|
}
|
|
|
function setMonth(date) {
|
|
|
var selectedDate = new Date(fp.currentYear, date.getMonth(), date.getDate());
|
|
|
+ var selectedDates = [];
|
|
|
switch (fp.config.mode) {
|
|
|
case "single":
|
|
|
- fp.selectedDates = [selectedDate];
|
|
|
+ selectedDates = [selectedDate];
|
|
|
+ break;
|
|
|
+ case "multiple":
|
|
|
+ selectedDates.push(selectedDate);
|
|
|
break;
|
|
|
case "range":
|
|
|
if (fp.selectedDates.length === 2) {
|
|
|
- fp.clear(false, false);
|
|
|
- buildMonths();
|
|
|
+ selectedDates = [selectedDate];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ selectedDates = fp.selectedDates.concat([selectedDate]);
|
|
|
+ selectedDates.sort(function (a, b) { return a.getTime() - b.getTime(); });
|
|
|
}
|
|
|
- fp.selectedDates.push(selectedDate);
|
|
|
- fp.selectedDates.sort(function (a, b) { return a.getTime() - b.getTime(); });
|
|
|
break;
|
|
|
}
|
|
|
- fp.latestSelectedDateObj = selectedDate;
|
|
|
- fp.updateValue();
|
|
|
+ fp.setDate(selectedDates, true);
|
|
|
setCurrentlySelected();
|
|
|
}
|
|
|
var shifts = {
|
|
|
@@ -197,8 +211,8 @@ function monthSelectPlugin(pluginConfig) {
|
|
|
}
|
|
|
function stubCurrentMonth() {
|
|
|
config._stubbedCurrentMonth = fp._initialDate.getMonth();
|
|
|
- fp._initialDate.setMonth(0);
|
|
|
- fp.currentMonth = 0;
|
|
|
+ fp._initialDate.setMonth(config._stubbedCurrentMonth);
|
|
|
+ fp.currentMonth = config._stubbedCurrentMonth;
|
|
|
}
|
|
|
function unstubCurrentMonth() {
|
|
|
if (!config._stubbedCurrentMonth)
|