Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function loadCustomDatepicker() {
- if (!window.jQuery || !window.jQuery.fn || !window.jQuery.fn.datepicker) {
- setTimeout(loadCustomDatepicker, 500);
- return;
- }
- var datepickerInput = window.Shoppad.$('#infiniteoptions-container .datepicker');
- if (datepickerInput.length) {
- datepickerInput.datepicker('option', {
- beforeShowDay: function(date) {
- var timedBlock = true;
- var timedBlockClosingHour = 24;
- var timedBlockClosingMinute = 00;
- // example: no delivery on sundays or saturdays
- var onlySpecificDays = false;
- var specificDaysAllowed = [
- // checks for 0-6, starting with Sunday being 0.
- ];
- var blockUntilDate = null;
- var blockSpecificDates = [
- new Date(2000,01,01),
- new Date(2019,8,02),
- new Date(2019,9,24),
- ];
- // Specific day not added yet
- var now = new Date();
- var isToday = date.getFullYear() == now.getFullYear() &&
- date.getMonth() == now.getMonth() &&
- date.getDate() == now.getDate();
- var isEnabled = true;
- if (onlySpecificDays) {
- isEnabled = specificDaysAllowed.indexOf(date.getDay()) > -1;
- }
- if (isToday && timedBlock) {
- if (now.getHours() > timedBlockClosingHour) {
- isEnabled = false;
- }
- else if (now.getHours() == timedBlockClosingHour && now.getMinutes() >= timedBlockClosingMinute) {
- isEnabled = false;
- }
- }
- if (blockUntilDate != null && date.getTime() < blockUntilDate.getTime()) {
- isEnabled = false;
- }
- for (var i = 0; i < blockSpecificDates.length; i++) {
- var checkDate = blockSpecificDates[i];
- if (date.getFullYear() == checkDate.getFullYear() &&
- date.getMonth() == checkDate.getMonth() &&
- date.getDay() == checkDate.getDay()) {
- isEnabled = false;
- }
- }
- return [isEnabled];
- }
- });
- }
- }
- loadCustomDatepicker();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement