refactor: remove the modal dialog when adding a product to cart

pagebuilder
Dinesh Salunke 2023-12-06 19:05:27 +05:30
parent 086352ed5a
commit 3b7f88956a
3 changed files with 1 additions and 52 deletions

View File

@ -25,41 +25,8 @@
import prestashop from 'prestashop'; import prestashop from 'prestashop';
import $ from 'jquery'; import $ from 'jquery';
// TODO: kept here as a reference, to be removed in future once we have our own modal implementaion
// prestashop.blockcart.showModal = (html) => {
// function getBlockCartModal() {
// return $('#blockcart-modal');
// }
//
// let $blockCartModal = getBlockCartModal();
//
// if ($blockCartModal.length) {
// $blockCartModal.remove();
// }
//
// $('body').append(html);
//
// $blockCartModal = getBlockCartModal();
// $blockCartModal.modal('show').on('hidden.bs.modal', (event) => {
// prestashop.emit('updateProduct', {
// reason: event.currentTarget.dataset,
// event,
// });
// });
// };
$(function() { $(function() {
prestashop.blockcart = prestashop.blockcart || {}; prestashop.blockcart = prestashop.blockcart || {};
var showModal = prestashop.blockcart.showModal || function(modal) {
var $body = $('body');
$body.append(modal);
$body.one('click', '#blockcart-modal', function(event) {
if (event.target.id === 'blockcart-modal') {
$(event.target).remove()
}
})
}
;
prestashop.on('updateCart', function(event) { prestashop.on('updateCart', function(event) {
var refreshURL = $('.blockcart').data('refresh-url'); var refreshURL = $('.blockcart').data('refresh-url');
var requestData = {}; var requestData = {};
@ -77,12 +44,7 @@ $(function() {
}) })
} }
$.post(refreshURL, requestData).then(function(resp) { $.post(refreshURL, requestData).then(function(resp) {
// TODO: keeping this over here, for later purposes if need be
var html = $('<div />').append($.parseHTML(resp.preview));
$('.blockcart').replaceWith($(resp.preview).find('.blockcart')); $('.blockcart').replaceWith($(resp.preview).find('.blockcart'));
if (resp.modal) {
showModal(resp.modal)
}
}).fail(function(resp) { }).fail(function(resp) {
prestashop.emit('handleError', { prestashop.emit('handleError', {
eventType: 'updateShoppingCart', eventType: 'updateShoppingCart',

File diff suppressed because one or more lines are too long