function LoadContent(url) {
if ($('.product-filter').length) {
Top = ($('.product-filter').position().top + $('.product-filter').height() - 20)
} else {
Top = $('#content').position().top
}
showMask();
$('html, body').animate({
scrollTop: Top
}, 800).promise().done(function () {
$.ajax({
cache: false,
timeout: 10000,
type: "GET",
dataType: "html",
url: url + getSearchUrl() + '&mini=true',
error: function () {
location = url
},
success: function (data) {
contents = $("<div>").append(data).find("#content > *");
if (contents.length) {
$('#content').html(contents);
if (typeof display == 'function') {
display($.cookie('display'))
}
reBind()
} else {
location = url
}
}
})
})
}
function showMask() {
if ($('.product-filter').length) {
Top = ($('.product-filter').position().top + $('.product-filter').height() + 20)
} else {
Top = ($('#content').outerHeight() / 4)
}
$('#content').css('position', 'relative').block({
message: '<img src="catalog/view/theme/default/image/ajax-load.gif" />',
css: {
border: 'none',
backgroundColor: 'inherit',
top: Top
},
overlayCSS: {
backgroundColor: '#FFFFFF',
opacity: 0.8
},
centerY: false
})
}
function getSearchUrl() {
if (!isSearch) {
return ''
}
url = '';
var filter_name = $('#content input[name=\'filter_name\']').attr('value');
if (filter_name) {
url += '&filter_name=' + encodeURIComponent(filter_name)
}
var filter_category_id = $('#content select[name=\'filter_category_id\']').attr('value');
if (filter_category_id > 0) {
url += '&filter_category_id=' + encodeURIComponent(filter_category_id)
}
var filter_sub_category = $('#content input[name=\'filter_sub_category\']:checked').attr('value');
if (filter_sub_category) {
url += '&filter_sub_category=true'
}
var filter_description = $('#content input[name=\'filter_description\']:checked').attr('value');
if (filter_description) {
url += '&filter_description=true'
}
return url
}
function reBind() {
$('.pagination a').click(function (e) {
e.preventDefault();
LoadContent(this)
});
$('.sort select').attr('onchange', 'return false;').unbind('change').change(function () {
LoadContent($(this).children('option:selected').val())
});
$('.limit select').attr('onchange', 'return false;').unbind('change').change(function () {
LoadContent($(this).children('option:selected').val())
});
if (isSearch) {
$('#button-search').unbind('click').click(function () {
LoadContent('index.php?route=product/search')
});
$('#content input[name=\'filter_name\']').keydown(function (e) {
if (e.keyCode == 13) {
$('#button-search').trigger('click')
}
})
}
custom()
}
$(document).ready(function () {
reBind()
});
очень много кода, посмотрите как сделано в filterpro.min.js, там всё гораздо проще