| 1 |
(function($) { |
| 2 |
|
| 3 |
let ESHBADMIN = { |
| 4 |
init: function () { |
| 5 |
$( document ) |
| 6 |
.on( 'click.ESHBADMIN', '.eshb-booking-info-calendar-tables a.booking-info', this.openBookingInfoModal ) |
| 7 |
.on( 'click.ESHBADMIN', '#eshb-booking-info-modal .booking-info-modal-close', this.closeBookingInfoModal ) |
| 8 |
.on( 'change.ESHBADMIN', '#eshb-calendar-filter-period', this.updateCalendarRangeField ) |
| 9 |
.on( 'click.ESHBADMIN', '.has-required-notice button, .has-required-notice input', this.disableClick ) |
| 10 |
; |
| 11 |
|
| 12 |
const scrollContainer = document.querySelector('.eshb-booking-info-calendar .eshb-booking-info-calendar-tables .eshb-accomodations-dates-table-wrapper'); |
| 13 |
const scrollSpeed = 3; |
| 14 |
|
| 15 |
if(scrollContainer){ |
| 16 |
scrollContainer.addEventListener('wheel', function (e) { |
| 17 |
// e.deltaY is vertical scroll, we use it to scroll horizontally |
| 18 |
if (e.deltaY !== 0) { |
| 19 |
e.preventDefault(); |
| 20 |
scrollContainer.scrollLeft += e.deltaY * scrollSpeed; |
| 21 |
} |
| 22 |
}); |
| 23 |
} |
| 24 |
|
| 25 |
}, |
| 26 |
|
| 27 |
clickTest: function () { |
| 28 |
alert('working'); |
| 29 |
}, |
| 30 |
closeBookingInfoModal: function (e) { |
| 31 |
e.preventDefault(); |
| 32 |
$('#eshb-booking-info-modal').fadeOut(); |
| 33 |
}, |
| 34 |
disableClick: function(e) { |
| 35 |
e.preventDefault(); |
| 36 |
return false; |
| 37 |
}, |
| 38 |
updateCalendarRangeField: function (){ |
| 39 |
let period = $(this).val(); |
| 40 |
if(period != 'custom' ) { |
| 41 |
$('#eshb-calendar-filter-date-range').css('display', 'none'); |
| 42 |
$('#eshb-calendar-filter-period .period-navigator').css('display', 'block'); |
| 43 |
}else{ |
| 44 |
$('#eshb-calendar-filter-date-range').css('display', 'block'); |
| 45 |
$('#eshb-calendar-filter-period .period-navigator').css('display', 'none'); |
| 46 |
} |
| 47 |
}, |
| 48 |
openBookingInfoModal: function (e) { |
| 49 |
e.preventDefault(); |
| 50 |
|
| 51 |
let bookingId = $(this).data('booking-id'); |
| 52 |
let sourceType = $(this).data('source-type'); |
| 53 |
let bookingInfo = ''; |
| 54 |
|
| 55 |
console.log(bookingId); |
| 56 |
|
| 57 |
$.ajax({ |
| 58 |
url: eshb_ajax.ajaxurl, |
| 59 |
type: 'POST', |
| 60 |
data: { |
| 61 |
action: 'eshb_get_booking_data_tables', |
| 62 |
post: bookingId, |
| 63 |
nonce: eshb_ajax.nonce |
| 64 |
}, |
| 65 |
success: function (response) { |
| 66 |
console.log(response); |
| 67 |
if (response) { |
| 68 |
|
| 69 |
|
| 70 |
bookingInfo = response; |
| 71 |
$('#eshb-booking-info-modal .booking-info-modal-content').html(bookingInfo); |
| 72 |
$('#eshb-booking-info-modal').fadeIn(); |
| 73 |
} else { |
| 74 |
alert('Error fetching booking info.'); |
| 75 |
} |
| 76 |
}, |
| 77 |
error: function () { |
| 78 |
alert('Error fetching booking info.'); |
| 79 |
} |
| 80 |
}); |
| 81 |
|
| 82 |
}, |
| 83 |
|
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
ESHBADMIN.init(); |
| 88 |
|
| 89 |
|
| 90 |
})(jQuery); |