atcheck/public/js/map/seatchart-custom.js
2020-01-13 17:50:20 +01:00

53 lines
1.5 KiB
JavaScript

function savePlaceNumber() {
var selected = $('.selected');
if(selected.length) {
var selected_id = $('.selected')[0].innerText;
const seat_number_input = $('.seat_number')[0];
seat_number_input.value = selected_id;
}
}
function toggleButtonAvailability() {
const buttons = $('.checkout-button');
const selected_place = $('.selected')[0];
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');
}
}
})
}
function checkForUnavailablePlaces() {
const unavailablePlaces = Array();
$('.unavailable_place').each(function(){
unavailablePlaces.push($(this).val());
});
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();
});
});