New DateRangePicker
This commit is contained in:
parent
faa508b4ca
commit
81e42b76f5
12 changed files with 398 additions and 88 deletions
103
web/js/_fewoBooking-script-min.js
vendored
Normal file
103
web/js/_fewoBooking-script-min.js
vendored
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
$(document).ready(function () {
|
||||
var i = $(".st-booking-form"),
|
||||
a = $(".st-booking-summary"),
|
||||
t = $("#fewo_booking_request_toDate_day"),
|
||||
e = $("#fewo_booking_request_toDate_month"),
|
||||
s = $("#fewo_booking_request_toDate_year");
|
||||
function h() {
|
||||
var t = location.href.split("?"),
|
||||
e = t[0].split("/");
|
||||
e.pop();
|
||||
var s = e.join("/") + "/berechne-gesamtpreis";
|
||||
t[1] && (s += "?" + t[1]),
|
||||
$.ajax({ url: s, type: "post", data: i.serialize() }).then(
|
||||
function (t) {
|
||||
a.html(t);
|
||||
},
|
||||
function () {
|
||||
a.html(
|
||||
"Aufgrund eines Fehlers konnte kein Angebot ermittelt werden."
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
i.find("input, select").change(function () {
|
||||
h();
|
||||
});
|
||||
var n = $("#fewo_booking_request_fromDate").val(),
|
||||
r = $("#fewo_booking_request_toDate").val(),
|
||||
o = $("#hidden_toDate").val(),
|
||||
l = JSON.parse($("#hidden_reservationDays").val()),
|
||||
d = JSON.parse($("#hidden_customDays").val()),
|
||||
c = function (t) {
|
||||
var e = t.format("DD.MM.YYYY");
|
||||
return (
|
||||
-1 < l.indexOf(e) ||
|
||||
(void 0 !== d[e] &&
|
||||
-1 == d[e].indexOf("bookable") &&
|
||||
-1 == d[e].indexOf("bookable-end"))
|
||||
);
|
||||
},
|
||||
u = function (t) {
|
||||
if (!1 !== t) {
|
||||
var e = t.format("DD.MM.YYYY");
|
||||
if (void 0 !== d[e]) return d[e];
|
||||
}
|
||||
};
|
||||
$(
|
||||
"#fewo_booking_request_fromDate, #fewo_booking_request_toDate"
|
||||
).daterangepicker(
|
||||
{
|
||||
isInvalidDate: c,
|
||||
isCustomDate: u,
|
||||
minDate: moment(),
|
||||
maxDate: o,
|
||||
timePickerSeconds: !0,
|
||||
locale: {
|
||||
format: "DD.MM.YYYY",
|
||||
separator: " - ",
|
||||
applyLabel: "OK",
|
||||
cancelLabel: "X",
|
||||
fromLabel: "Von",
|
||||
toLabel: "Bis",
|
||||
customRangeLabel: "Custom",
|
||||
weekLabel: "W",
|
||||
daysOfWeek: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"],
|
||||
monthNames: [
|
||||
"Januar",
|
||||
"Februar",
|
||||
"März",
|
||||
"April",
|
||||
"Mai",
|
||||
"Juni",
|
||||
"Juli",
|
||||
"August",
|
||||
"September",
|
||||
"Oktober",
|
||||
"November",
|
||||
"Dezember",
|
||||
],
|
||||
firstDay: 1,
|
||||
},
|
||||
autoApply: !0,
|
||||
autoUpdateInput: !1,
|
||||
startDate: n,
|
||||
endDate: r,
|
||||
},
|
||||
function (t, e, s) {
|
||||
var i = t.format("DD.MM.YYYY"),
|
||||
a = e.format("DD.MM.YYYY"),
|
||||
n = $("#fewo_booking_request_fromDate"),
|
||||
r = $("#fewo_booking_request_toDate");
|
||||
n.val(i), r.val(a);
|
||||
var o = r.data("daterangepicker");
|
||||
o.setStartDate(i), o.setEndDate(a);
|
||||
var l = n.data("daterangepicker");
|
||||
l.setStartDate(i), l.setEndDate(a), h();
|
||||
}
|
||||
),
|
||||
$("#fewo_booking_request_fromDate, #fewo_booking_request_toDate").on(
|
||||
"show.daterangepicker",
|
||||
function (t, e) {}
|
||||
);
|
||||
});
|
||||
12
web/js/fewoBooking-min.js
vendored
12
web/js/fewoBooking-min.js
vendored
File diff suppressed because one or more lines are too long
160
web/js/fewoBooking-script-min.js
vendored
Normal file
160
web/js/fewoBooking-script-min.js
vendored
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
$(document).ready(function() {
|
||||
|
||||
var frm$ = $('.st-booking-form');
|
||||
var summary$ = $('.st-booking-summary');
|
||||
|
||||
var toDateDay$ = $('#fewo_booking_request_toDate_day');
|
||||
var toDateMonth$ = $('#fewo_booking_request_toDate_month');
|
||||
var toDateYear$ = $('#fewo_booking_request_toDate_year');
|
||||
|
||||
function loadCalculationFewo(){
|
||||
var tmp = location.href.split('?');
|
||||
var tmp2 = tmp[0].split('/');
|
||||
tmp2.pop();
|
||||
var url = tmp2.join('/') + '/berechne-gesamtpreis';
|
||||
if (tmp[1])
|
||||
{
|
||||
url += '?'+ tmp[1];
|
||||
}
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'post',
|
||||
data: frm$.serialize()
|
||||
|
||||
}).then(function(r) {
|
||||
summary$.html(r);
|
||||
|
||||
}, function() {
|
||||
summary$.html('Aufgrund eines Fehlers konnte kein Angebot ermittelt werden.');
|
||||
});
|
||||
}
|
||||
frm$.find('input, select').change(function() {
|
||||
loadCalculationFewo();
|
||||
});
|
||||
|
||||
// var currentDate = moment().format("DD.MM.YYYY");
|
||||
|
||||
var startDate = $('#fewo_booking_request_fromDate').val();
|
||||
var endDate = $('#fewo_booking_request_toDate').val();
|
||||
var maxDate = $('#hidden_toDate').val();
|
||||
var reservationDays = JSON.parse($('#hidden_reservationDays').val());
|
||||
var customDays = JSON.parse($('#hidden_customDays').val());
|
||||
|
||||
var checkDates = function (date) {
|
||||
var formatted = date.format('DD.MM.YYYY');
|
||||
if(reservationDays.indexOf(formatted) > -1){
|
||||
return true;
|
||||
}
|
||||
if(customDays[formatted] !== undefined && customDays[formatted].indexOf('bookable') == -1 && customDays[formatted].indexOf('bookable-end') == -1){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
var checkCustom = function (date) {
|
||||
if (date !== false) {
|
||||
var formatted = date.format('DD.MM.YYYY');
|
||||
if(customDays[formatted] !== undefined){
|
||||
return customDays[formatted];
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
var $start = $('#start'),
|
||||
$end = $('#end');
|
||||
|
||||
$start.datepicker({
|
||||
onSelect: function (fd, date) {
|
||||
$end.data('datepicker')
|
||||
.update('minDate', date);
|
||||
|
||||
$end.focus();
|
||||
}
|
||||
})
|
||||
|
||||
$end.datepicker({
|
||||
onSelect: function (fd, date) {
|
||||
$start.data('datepicker')
|
||||
.update('maxDate', date)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
$('#fewo_booking_request_datepicker').daterangepicker({
|
||||
isInvalidDate: checkDates,
|
||||
isCustomDate: checkCustom,
|
||||
"minDate": moment(),
|
||||
"maxDate": maxDate,
|
||||
"timePickerSeconds": true,
|
||||
"locale": {
|
||||
"format": "DD.MM.YYYY",
|
||||
"separator": " - ",
|
||||
"applyLabel": "OK",
|
||||
"cancelLabel": "X",
|
||||
"fromLabel": "Von",
|
||||
"toLabel": "Bis",
|
||||
"customRangeLabel": "Custom",
|
||||
"weekLabel": "W",
|
||||
"daysOfWeek": [
|
||||
"So",
|
||||
"Mo",
|
||||
"Di",
|
||||
"Mi",
|
||||
"Do",
|
||||
"Fr",
|
||||
"Sa"
|
||||
],
|
||||
"monthNames": [
|
||||
"Januar",
|
||||
"Februar",
|
||||
"März",
|
||||
"April",
|
||||
"Mai",
|
||||
"Juni",
|
||||
"Juli",
|
||||
"August",
|
||||
"September",
|
||||
"Oktober",
|
||||
"November",
|
||||
"Dezember"
|
||||
],
|
||||
"firstDay": 1
|
||||
},
|
||||
autoApply: true,
|
||||
autoUpdateInput: true,
|
||||
singleDatePicker: false,
|
||||
alwaysShowCalendars: true,
|
||||
"startDate": startDate,
|
||||
"endDate": endDate,
|
||||
allowInput: true,
|
||||
}, function(start, end, label) {
|
||||
|
||||
// console.log('New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')');
|
||||
// Lets update the fields manually this event fires on selection of range
|
||||
var selectedStartDate = start.format('DD.MM.YYYY'); // selected start
|
||||
var selectedEndDate = end.format('DD.MM.YYYY'); // selected end
|
||||
|
||||
var $checkinInput = $('#fewo_booking_request_fromDate');
|
||||
var $checkoutInput = $('#fewo_booking_request_toDate');
|
||||
|
||||
// Updating Fields with selected dates
|
||||
$checkinInput.val(selectedStartDate);
|
||||
$checkoutInput.val(selectedEndDate);
|
||||
|
||||
/*
|
||||
// Setting the Selection of dates on calender on CHECKOUT FIELD (To get this it must be binded by Ids not Calss)
|
||||
var checkOutPicker = $checkoutInput.data('daterangepicker');
|
||||
checkOutPicker.setStartDate(selectedStartDate);
|
||||
checkOutPicker.setEndDate(selectedEndDate);
|
||||
|
||||
// Setting the Selection of dates on calender on CHECKIN FIELD (To get this it must be binded by Ids not Calss)
|
||||
var checkInPicker = $checkinInput.data('daterangepicker');
|
||||
checkInPicker.setStartDate(selectedStartDate);
|
||||
checkInPicker.setEndDate(selectedEndDate);
|
||||
*/
|
||||
loadCalculationFewo();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue