New DateRangePicker
This commit is contained in:
parent
faa508b4ca
commit
81e42b76f5
12 changed files with 398 additions and 88 deletions
|
|
@ -2,12 +2,11 @@ $(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('/');
|
||||
|
|
@ -21,10 +20,10 @@ $(document).ready(function() {
|
|||
url: url,
|
||||
type: 'post',
|
||||
data: frm$.serialize()
|
||||
|
||||
|
||||
}).then(function(r) {
|
||||
summary$.html(r);
|
||||
|
||||
|
||||
}, function() {
|
||||
summary$.html('Aufgrund eines Fehlers konnte kein Angebot ermittelt werden.');
|
||||
});
|
||||
|
|
@ -32,16 +31,15 @@ $(document).ready(function() {
|
|||
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){
|
||||
|
|
@ -52,7 +50,7 @@ $(document).ready(function() {
|
|||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
var checkCustom = function (date) {
|
||||
if (date !== false) {
|
||||
var formatted = date.format('DD.MM.YYYY');
|
||||
|
|
@ -60,16 +58,15 @@ $(document).ready(function() {
|
|||
return customDays[formatted];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$('#fewo_booking_request_fromDate1, #fewo_booking_request_toDate1').daterangepicker({
|
||||
|
||||
$('#fewo_booking_request_datepicker').daterangepicker({
|
||||
isInvalidDate: checkDates,
|
||||
isCustomDate: checkCustom,
|
||||
"minDate": moment(),
|
||||
"maxDate": maxDate,
|
||||
"timePickerSeconds": true,
|
||||
|
||||
"locale": {
|
||||
"format": "DD.MM.YYYY",
|
||||
"separator": " - ",
|
||||
|
|
@ -105,40 +102,39 @@ $(document).ready(function() {
|
|||
"firstDay": 1
|
||||
},
|
||||
autoApply: true,
|
||||
autoUpdateInput: false,
|
||||
singleDatePicker: 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 + ')");
|
||||
|
||||
// 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();
|
||||
|
||||
});
|
||||
|
||||
$('#fewo_booking_request_fromDate, #fewo_booking_request_toDate').on('show.daterangepicker', function(ev, picker) {
|
||||
/* console.log(picker.startDate.format('YYYY-MM-DD'));
|
||||
console.log(picker.endDate.format('YYYY-MM-DD'));
|
||||
*/
|
||||
loadCalculationFewo();
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue