2017-02-23 15:37:06 +01:00

105 lines
3.6 KiB
Smarty
Executable File

<script type="text/javascript">{literal}
$(document).ready(function() {
var loading = false;
var error = false;
var endreached = false;
var filter = new Array();
$('.random').each(function(){
$(this).hover(function() {
$(this).parent().children('.info_random').stop(true, true).fadeIn();
}, function(){
$(this).parent().children('.info_random').stop(true, true).fadeOut();
});
});
$(window).scroll(function() {
if(!endreached && !error) {
if((($(window).scrollTop() + $(window).height()) + 550) >= $(document).height()) {
if(loading == false) {
filter.length = 0;
$(".block_filter input:checkbox[name=size]:checked").each(function(){
filter.push($(this).val());
});
loading = true;
$.get("{/literal}{$base_dir_ssl}{literal}modules/categoryscroll/ajax.php?c={/literal}{$id_category}{literal}&f="+ filter +"&p=" + $("#product_list").val(), function(loaded) {
loaded = $.parseJSON(loaded)[0];
if(loaded.error == false) {
endreached = loaded.endreached;
$("#product_list").append(loaded.products);
$("#product_list").val(parseInt($("#product_list").val()) + 1);
$('.flexslider').flexslider({
animation: "slide",
controlNav: false,
slideshow: false,
itemWidth: 300,
pauseOnHover : false,
mousewheel: false,
});
} else {
error = true;
var error_i18n = {
"privatesale_inactive": "{/literal}{l s='This sale is now disabled.' mod='categoryscroll'}{literal}",
"permission_denied": "{/literal}{l s='You can\'t access this content.' mod='categoryscroll'}{literal}",
"invalid_request": "{/literal}{l s='Invalid request.' mod='categoryscroll'}{literal}",
"inactive_category": "{/literal}{l s='This category is disabled.' mod='categoryscroll'}{literal}"
};
$('<div class="error">' + error_i18n[loaded.error] + '</div>').insertAfter("#product_list");
}
loading = false;
$("#product_list").trigger('updated');
});
}
}
}
});
$(".block_filter :checkbox").change(function(){
if(loading == false) {
filter.length = 0;
$(".block_filter input:checkbox[name=size]:checked").each(function(){
filter.push($(this).val());
});
$("#product_list").val(0);
loading = true;
$.get("{/literal}{$base_dir_ssl}{literal}modules/categoryscroll/ajax.php?c={/literal}{$id_category}{literal}&init=1&f="+ filter +"&p=1", function(loaded) {
loaded = $.parseJSON(loaded)[0];
if(loaded.error == false) {
endreached = loaded.endreached;
$("#product_list").html(loaded.products);
$("#product_list").val(parseInt($("#product_list").val()) + 1);
$('.flexslider').flexslider({
animation: "slide",
controlNav: false,
slideshow: false,
itemWidth: 300,
pauseOnHover : false,
mousewheel: false,
});
} else {
error = true;
var error_i18n = {
"privatesale_inactive": "{/literal}{l s='This sale is now disabled.' mod='categoryscroll'}{literal}",
"permission_denied": "{/literal}{l s='You can\'t access this content.' mod='categoryscroll'}{literal}",
"invalid_request": "{/literal}{l s='Invalid request.' mod='categoryscroll'}{literal}",
"inactive_category": "{/literal}{l s='This category is disabled.' mod='categoryscroll'}{literal}"
};
$('<div class="error">' + error_i18n[loaded.error] + '</div>').insertAfter("#product_list");
}
loading = false;
$("#product_list").trigger('updated');
});
}
// $.scrollTo('#product_list', 400);
});
$("#product_list").val(1);
});
{/literal}</script>