forked from brooksbingham/theme-elegance
refactor: remove the modal dialog when adding a product to cart
parent
086352ed5a
commit
3b7f88956a
|
@ -25,41 +25,8 @@
|
|||
import prestashop from 'prestashop';
|
||||
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() {
|
||||
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) {
|
||||
var refreshURL = $('.blockcart').data('refresh-url');
|
||||
var requestData = {};
|
||||
|
@ -77,12 +44,7 @@ $(function() {
|
|||
})
|
||||
}
|
||||
$.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'));
|
||||
if (resp.modal) {
|
||||
showModal(resp.modal)
|
||||
}
|
||||
}).fail(function(resp) {
|
||||
prestashop.emit('handleError', {
|
||||
eventType: 'updateShoppingCart',
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue