2017-12-12 14:37:35 +01:00

60 lines
1.8 KiB
Smarty

<script type="text/javascript">{literal}
function hideExpressCart(event){
if($(".button.expresscart.active").parent().parent().has($(event.target)).length == 0 || $(".button.expresscart.active") == $(event.target)) {
event.data.m.removeClass('active');
$(".expresscart_frame").hide();
$("html").unbind("click", hideExpressCart);
$('a.button').css('opacity', 1);
$('.close_popup').remove();
}
return false;
}
function showExpressCart(event) {
var m = $(event.target);
m.toggleClass('active');
if ($('.box_add_to_cart').length > 0) {
$('.box_add_to_cart').remove();
$('.close_popup').remove();
}
var id_product = m.parent().children(".button.ajax_add_to_cart_button").attr("rel").split("_")[3];
$.ajax({
type: 'POST',
url: baseDir + 'modules/expresscart/ajax.php',
async: true,
cache: false,
dataType : "html",
data: 'id_product=' + id_product,
success: function(jsonData) {
$('.overlay_bbb').parent()
.append('<div class="box_add_to_cart"><div class="content"></div></div>')
.append('<a href="#" class="close_popup"></a>');
$('.box_add_to_cart .content').html(jsonData);
$('.overlay_bbb').fadeIn();
$('.box_add_to_cart').fadeIn();
},
error: function() {alert('ERROR: unable to display');}
});
return false;
}
function initButtons() {
$('.button.ajax_add_to_cart_button.exclusive').hide()
.after("{/literal}<a title=\"{l s='Express cart' mod='expresscart'}\" onclick=\"showExpressCart(event); return false;\" class=\"button expresscart\"></a><div style=\"display:none;\" class=\"expresscart_frame\"><p class=\"loading\"><img src=\"{$img_dir|replace:'"':'"'}ajax-loader.gif\" alt=\"\" /></p></div>{literal}");
}
$(document).ready(function() {
initButtons();
$("#product_list").bind("updated", function() {
initButtons();
return false;
});
});
{/literal}</script>