pianello-api/resources/js/components/litepicker/index.js
Ale Gallo 82f958e5da Committing laravel (part 3)
committing js templating files and components
2023-11-10 16:00:59 +01:00

44 lines
1.1 KiB
JavaScript

(function () {
"use strict";
// Litepicker
$(".datepicker").each(function () {
let options = {
autoApply: false,
singleMode: false,
numberOfColumns: 2,
numberOfMonths: 2,
showWeekNumbers: true,
format: "D MMM, YYYY",
dropdowns: {
minYear: 1990,
maxYear: null,
months: true,
years: true,
},
};
if ($(this).data("single-mode")) {
options.singleMode = true;
options.numberOfColumns = 1;
options.numberOfMonths = 1;
}
if ($(this).data("format")) {
options.format = $(this).data("format");
}
if (!$(this).val()) {
let date = dayjs().format(options.format);
date += !options.singleMode
? " - " + dayjs().add(1, "month").format(options.format)
: "";
$(this).val(date);
}
new Litepicker({
element: this,
...options,
});
});
})();