atcheck/public/js/map/seatchart-custom.js

53 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-12-07 19:49:42 +01:00
function savePlaceNumber() {
const selected_id = $('.selected')[0].innerText;
if(selected_id) {
const seat_number_input = $('.seat_number')[0];
seat_number_input.value = selected_id;
console.log(seat_number_input.value)
}
}
function toggleButtonAvailability() {
2019-12-08 00:00:52 +01:00
const buttons = $('.checkout-button');
2019-12-07 19:49:42 +01:00
const selected_place = $('.selected')[0];
2019-12-08 00:00:52 +01:00
buttons.each(function(e) {
if(!$(this).hasClass('end-button')) {
if(!selected_place){
$(this).css('pointer-events', 'none');
$(this).css('cursor', 'unset');
} else {
$(this).css('pointer-events', 'unset');
$(this).css('cursor', 'pointer');
}
}
})
2019-12-07 19:49:42 +01:00
}
function checkForUnavailablePlaces() {
const unavailablePlaces = Array();
$('.unavailable_place').each(function(){
unavailablePlaces.push($(this).val());
});
console.log(unavailablePlaces);
const allPlaces = $('.seatCharts-seat.seatCharts-cell.available');
if(unavailablePlaces){
allPlaces.each(function(){
if(unavailablePlaces.includes($(this).text()) && !$(this).parent().hasClass('seatCharts-legendItem')) {
$(this).addClass('unavailable');
$(this).css('pointer-events', 'none');
}
});
}
}
$(document).ready(function(){
checkForUnavailablePlaces();
toggleButtonAvailability();
$('.seatCharts-seat').on('click', function(){
toggleButtonAvailability();
savePlaceNumber();
});
});