// $(function() { // let inp = document.querySelectorAll("#regervation") // let dspreg = document.querySelectorAll("#displayRegervation") // if (inp.length > 1){ // for (let i = 0;i < inp.length;i++){ // inp[i].daterangepicker({ // "autoapply": true, // "linkedCalendars": false, // }, // function(start, end, label) { // // dspreg[i].text('Registration date is: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD')); // }); // $('.drp-calendar.right').hide(); // $('.drp-calendar.left').addClass('single'); // // $('.calendar-table').on('DOMSubtreeModified', function() { // var el = $(".prev.available").parent().children().last(); // if (el.hasClass('next available')) { // return; // } // el.addClass('next available'); // el.append(''); // }); // } // } else { // $('#regervation').daterangepicker({ // "autoapply": true, // "linkedCalendars": false, // }, // function(start, end, label) { // // $('#displayRegervation').text('Registration date is: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD')); // }); // $('.drp-calendar.right').hide(); // $('.drp-calendar.left').addClass('single'); // // $('.calendar-table').on('DOMSubtreeModified', function() { // var el = $(".prev.available").parent().children().last(); // if (el.hasClass('next available')) { // return; // } // el.addClass('next available'); // el.append(''); // }); // } // }); locale_ru = new Object({ direction: "ltr", // format: t.localeData().longDateFormat("L"), format: "DD.MM.YYYY", separator: " - ", applyLabel: "Принять", cancelLabel: "Отменить", weekLabel: "Н", customRangeLabel: "Custom Range", }); locale_en = new Object({ direction: "ltr", // format: t.localeData().longDateFormat("L"), format: "DD.MM.YYYY", separator: " - ", applyLabel: "Apply", cancelLabel: "Cancel", weekLabel: "W", customRangeLabel: "Custom Range", }); function changeLangForDateTimePicker() { if (document.documentElement.lang === 'ru'){ locale_lang = locale_ru; lang = 'ru'; } else { locale_lang = locale_en; lang ='en'; } moment.locale(lang); return locale_lang } function init_arrival_DT (date=null,single=true,hour=true){ let minDate = null if (date){ minDate = date } else { minDate = moment() } let onl_param = "" if (window.location.href === "http://localhost:8016/ru/profile/page/create_route_for_mover/" || window.location.href === "http://localhost:8016/ru/profile/page/create_route_for_customer/"){ onl_param = "singleDatePicker" } let place_1 = document.querySelector("#id_arrival_DT") if (place_1) { $(place_1).daterangepicker({ "autoapply": true, "linkedCalendars": false, "singleDatePicker":single, "timePicker":hour, "timePicker24Hour":true, "minDate":minDate, "locale": changeLangForDateTimePicker(), }, function (start, end, label) { // $('#displayRegervation').text('Registration date is: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD')); if (single === true){ $('#id_arrival_DT').val(start.format('DD.MM.YYYY HH:mm')) } else if (single === false){ $('#id_arrival_DT').val(start.format('DD.MM.YYYY') + " - " + end.format('DD.MM.YYYY')) } }); $(`${place_1.id} .drp-calendar.right`).hide(); $(`${place_1.id} .drp-calendar.left`).addClass('single'); $(`${place_1.id} .calendar-table`).on('DOMSubtreeModified', function () { var el = $(`${place_1.id} .prev.available`).parent().children().last(); if (el.hasClass('next available')) { return; } el.addClass('next available'); el.append(''); }); } } function init_departure_DT() { let place_1 = document.querySelector("#id_departure_DT"); if (!place_1) return; let hiddenTime = document.querySelector('.local_city_time').innerText; let startDate; if (window.location.href.includes("/ru/")) { startDate = moment(hiddenTime, "D MMMM YYYY г. HH:mm", 'ru'); } else { startDate = moment(hiddenTime, "MMMM D, YYYY, h:mm a", 'en'); } $(place_1).daterangepicker({ "autoapply": true, "linkedCalendars": false, "singleDatePicker": true, "timePicker": true, "timePicker24Hour": true, "minDate": startDate, "locale": changeLangForDateTimePicker(), }, function (start, end, label) { $('#id_departure_DT').val(start.format('DD.MM.YYYY HH:mm')); }); $(`${place_1.id} .drp-calendar.right`).hide(); $(`${place_1.id} .drp-calendar.left`).addClass('single'); $(`${place_1.id} .calendar-table`).on('DOMSubtreeModified', function () { var el = $(`${place_1.id} .prev.available`).parent().children().last(); if (el.hasClass('next available')) { return; } el.addClass('next available'); el.append(''); }); } $(function () { let onl_param = {}; if (window.location.href.includes("/ru/profile/page/create_route_for_mover/") || window.location.href.includes("/ru/profile/page/create_route_for_customer/")) { onl_param = { singleDatePicker: true }; } let place_1 = document.querySelector("#id_arrival_DT"); if (place_1) { $(place_1).daterangepicker({ "autoapply": true, "linkedCalendars": false, "locale": changeLangForDateTimePicker(), ...onl_param }, function (start, end, label) { $('#id_arrival_DT').val(start.format('DD.MM.YYYY') + " - " + end.format('DD.MM.YYYY')); }); $(`${place_1.id} .drp-calendar.right`).hide(); $(`${place_1.id} .drp-calendar.left`).addClass('single'); $(`${place_1.id} .calendar-table`).on('DOMSubtreeModified', function () { var el = $(`${place_1.id} .prev.available`).parent().children().last(); if (el.hasClass('next available')) { return; } el.addClass('next available'); el.append(''); }); } }); $(function() { let place_1 = document.querySelector("#id_departure_DT"); let onl_param = {}; if (window.location.href.includes("/ru/profile/page/create_route_for_mover/") || window.location.href.includes("/ru/profile/page/create_route_for_customer/")) { onl_param = { singleDatePicker: true }; } if (place_1) { $(place_1).daterangepicker({ "autoapply": true, "linkedCalendars": false, "locale": changeLangForDateTimePicker(), ...onl_param }, function (start, end, label) { $('#id_departure_DT').val(start.format('DD.MM.YYYY') + " - " + end.format('DD.MM.YYYY')); $('#id_arrival_DT').val(''); init_arrival_DT(start.format('DD.MM.YYYY'), false, false); }); $(`${place_1.id} .drp-calendar.right`).hide(); $(`${place_1.id} .drp-calendar.left`).addClass('single'); $(`${place_1.id} .calendar-table`).on('DOMSubtreeModified', function () { var el = $(`${place_1.id} .prev.available`).parent().children().last(); if (el.hasClass('next available')) { return; } el.addClass('next available'); el.append(''); }); } });