0.0.318 work with datarangepicker.js

This commit is contained in:
2023-12-05 20:16:44 +03:00
parent 75ddb002fd
commit b23e440efd
2 changed files with 74 additions and 43 deletions

View File

@@ -5,35 +5,6 @@
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
// let locale_ru = {
// direction: "ltr",
// // format: t.localeData().longDateFormat("L"),
// format: "DD.MM.YYYY",
// separator: " - ",
// applyLabel: "Принять",
// cancelLabel: "Отменить",
// weekLabel: "Н",
// customRangeLabel: "Custom Range",
// daysOfWeek: t.weekdaysMin(),
// monthNames: t.monthsShort(),
// firstDay: t.localeData().firstDayOfWeek()
// };
// let locale_en = {
// direction: "ltr",
// // format: t.localeData().longDateFormat("L"),
// format: "DD.MM.YYYY",
// separator: " - ",
// applyLabel: "Apply",
// cancelLabel: "Cancel",
// weekLabel: "W",
// customRangeLabel: "Custom Range",
// daysOfWeek: t.weekdaysMin(),
// monthNames: t.monthsShort(),
// firstDay: t.localeData().firstDayOfWeek()
// };
!function(t,e) {
@@ -79,19 +50,26 @@
this.buttonClasses = "btn btn-sm",
this.applyButtonClasses = "btn-primary",
this.cancelButtonClasses = "btn-default",
this.locale = {
direction: "ltr",
// format: t.localeData().longDateFormat("L"),
format: "DD.MM.YYYY",
separator: " - ",
applyLabel: "Принять",
cancelLabel: "Отменить",
weekLabel: "Н",
customRangeLabel: "Custom Range",
daysOfWeek: t.weekdaysMin(),
monthNames: t.monthsShort(),
firstDay: t.localeData().firstDayOfWeek()
}, this.callback = function () {
this.locale = i.locale,
this.locale.daysOfWeek = t.weekdaysMin(),
this.locale.monthNames = t.monthsShort(),
this.locale.firstDay = t.localeData().firstDayOfWeek(),
// this.locale = {
// direction: "ltr",
// // format: t.localeData().longDateFormat("L"),
// format: "DD.MM.YYYY",
// separator: " - ",
// applyLabel: "Принять",
// cancelLabel: "Отменить",
// weekLabel: "Н",
// customRangeLabel: "Custom Range",
// daysOfWeek: t.weekdaysMin(),
// monthNames: t.monthsShort(),
// firstDay: t.localeData().firstDayOfWeek()
// }
this.callback = function () {
}, this.isShowing = !1, this.leftCalendar = {}, this.rightCalendar = {}, "object" == typeof i && null !== i || (i = {}), "string" == typeof (i = e.extend(this.element.data(), i)).template || i.template instanceof e || (i.template = '<div class="daterangepicker"><div class="ranges"></div><div class="drp-calendar left"><div class="calendar-table"></div><div class="calendar-time"></div></div><div class="drp-calendar right"><div class="calendar-table"></div><div class="calendar-time"></div></div><div class="drp-buttons"><span class="drp-selected"></span><button class="cancelBtn" type="button"></button><button class="applyBtn" disabled="disabled" type="button"></button> </div></div>'), this.parentEl = i.parentEl && e(i.parentEl).length ? e(i.parentEl) : e(this.parentEl), this.container = e(i.template).appendTo(this.parentEl), "object" == typeof i.locale && ("string" == typeof i.locale.direction && (this.locale.direction = i.locale.direction), "string" == typeof i.locale.format && (this.locale.format = i.locale.format), "string" == typeof i.locale.separator && (this.locale.separator = i.locale.separator), "object" == typeof i.locale.daysOfWeek && (this.locale.daysOfWeek = i.locale.daysOfWeek.slice()), "object" == typeof i.locale.monthNames && (this.locale.monthNames = i.locale.monthNames.slice()), "number" == typeof i.locale.firstDay && (this.locale.firstDay = i.locale.firstDay), "string" == typeof i.locale.applyLabel && (this.locale.applyLabel = i.locale.applyLabel), "string" == typeof i.locale.cancelLabel && (this.locale.cancelLabel = i.locale.cancelLabel), "string" == typeof i.locale.weekLabel && (this.locale.weekLabel = i.locale.weekLabel), "string" == typeof i.locale.customRangeLabel)) {
(p = document.createElement("textarea")).innerHTML = i.locale.customRangeLabel;
var n = p.value;

View File

@@ -43,6 +43,52 @@
// });
// }
// });
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){
@@ -58,7 +104,9 @@ function init_arrival_DT (date=null,single=true,hour=true){
}
let place_1 = document.querySelector("#id_arrival_DT")
if (place_1) {
moment.locale('ru');
$(place_1).daterangepicker({
"autoapply": true,
"linkedCalendars": false,
@@ -66,6 +114,7 @@ function init_arrival_DT (date=null,single=true,hour=true){
"timePicker":hour,
"timePicker24Hour":true,
"minDate":minDate,
"locale": changeLangForDateTimePicker(),
},
function (start, end, label) {
@@ -78,6 +127,7 @@ function init_arrival_DT (date=null,single=true,hour=true){
}
});
$(`${place_1.id} .drp-calendar.right`).hide();
$(`${place_1.id} .drp-calendar.left`).addClass('single');
@@ -109,6 +159,7 @@ function init_departure_DT (){
"singleDatePicker":true,
"timePicker":true,
"timePicker24Hour":true,
"locale": changeLangForDateTimePicker(),
},
function(start, end, label) {
// $('#displayRegervation').text('Registration date is: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));
@@ -143,6 +194,7 @@ $(function () {
$(place_1).daterangepicker({
"autoapply": true,
"linkedCalendars": false,
"locale": changeLangForDateTimePicker(),
},
function (start, end, label) {
@@ -175,6 +227,7 @@ $(function() {
$(place_1).daterangepicker({
"autoapply": true,
"linkedCalendars": false,
"locale": changeLangForDateTimePicker(),
onl_param
},
function(start, end, label) {