<script type="text/javascript">
$(document)
.on('click', '.clickable_area.area_free', function () {
let uuidArea = $(this).data('uuid-area');
let url = '{{ path("app_frontend_cart_modal_add", {'uuidArea': 'uuidArea'}) }}';
url = url.replace("uuidArea", uuidArea);
$.ajax({
url : url,
method: "GET",
success: function(response) {
let $modal = $('#addToCartModal')
$modal.find('.modal-body').html(response);
$modal.modal('show');
}
});
})
.on('click', '.clickable_area.area_sold', function () {
let uuidArea = $(this).data('uuid-area');
let url = '{{ path("app_frontend_ajax_get_sponsor", {'uuidArea': 'uuidArea'}) }}';
url = url.replace("uuidArea", uuidArea);
$.ajax({
url : url,
method: "GET",
success: function (modalContent) {
let $modal = $('#areaSoldModal');
$modal.find('.modal-content').html(modalContent);
$modal.modal('show');
}
});
})
.on('click', '.addToCartButton', function () {
let $modal = $('#addToCartModal');
let uuidCustomerAdvertisingArea = $modal.find('#uuid-area').val();
let withinSetupPrice = $modal.find('.withinSetupPrice').is(':checked');
$.ajax({
url: '{{ path("app_frontend_cart_add_item") }}',
method: "POST",
data: {
'uuidCustomerAdvertisingArea': uuidCustomerAdvertisingArea,
'withinSetupPrice': withinSetupPrice
},
success: function (area) {
markAreaAsSelected(uuidCustomerAdvertisingArea);
let $shoppingCart = $('#shopping-cart');
let template = getShoppingCartItem(area);
$shoppingCart.find('.product-area').append(template);
refreshCartTotalAndItemCount();
$modal.modal('hide');
}
});
})
;
function markAreaAsSelected(uuidArea) {
let prefix = 'customer-advertising-area-'
let $area = $('#'+prefix+uuidArea);
$area
.addClass('area_selected')
.removeClass('area_free')
;
}
</script>