Код:
130535
Код:
76133
Код:
162763
Код:
104994
Код:
105484
Код:
194739
Код:
194740
Код:
194741
Код:
115617
Код:
205629
Код:
205630
Код:
205631
Код:
206942
Код:
223290
Код:
214619
Код:
192633
Код:
194745
Код:
194746
Код:
83922
Код:
132318
Код:
158448
Код:
58311
Код:
54583
Код:
54585
Код:
176214
Код:
165041
Код:
165043
Код:
165047
Код:
88490
Код:
224250
Код:
224251
Код:
224249
Код:
224253
Код:
224252
Код:
218089
Код:
225126
Код:
167141
Код:
204666
Код:
115891
Код:
54577
Код:
54576
Код:
54580
Код:
156763
Код:
54578
Код:
205649
Код:
205651
Код:
54579
Код:
123641
Код:
154230
Код:
201410
Код:
123634
Код:
165246
Код:
199787
Код:
198532
Код:
163723
function getUrlFilter() {
var params = [];
var urlSplit = linkPage.split('?');
var resultUrl = urlSplit[0];
$('#ocfilter-content .option-values').each(function (key, value) {
var filterName = $(this).data('filter-name');
var filterUrl = $(this).data('filter-url');
var filterId = $(this).data('filter-id');
var filterType = $(this).data('filter-type');
var filterParams = [];
$(this).find('input').each(function () {
if ($(this).is(':checked')) {
if ($(this).data('filter-value') != '')
filterParams[filterParams.length] = $(this).data('filter-value');
}
});
if (filterParams.length > 0) {
if (filterName == '') {
params[params.length] = filterParams.join('/');
} else {
params[params.length] = filterName + '/' + filterParams.join('/');
}
}
if (filterType == 'slide_dual') {
console.log(filterUrl);
var min = $('#scale-' + filterId).data('range-min');
var max = $('#scale-' + filterId).data('range-max');
var start = $('#left-value-' + filterId).text();
var end = $('#right-value-' + filterId).text();
if ((min != start) || (max != end)) {
resultUrl += filterUrl + '/' + start + '-' + end + '/';
}
console.log(resultUrl);
}
});
var stringParams = params.join('/').replace(/\/\//gi, '/');
resultUrl += stringParams;
var minPrice = $('#scale-price').data('range-min');
var maxPrice = $('#scale-price').data('range-max');
var startPrice = $('#price-from').text();
var endPrice = $('#price-to').text();
if ((minPrice != startPrice) || (maxPrice != endPrice)) {
resultUrl += '/price/' + startPrice + '-' + endPrice;
}
if (typeof urlSplit[1] != 'undefined') {
var paramsUrl = urlSplit[1].replace(/&/gi, '&');
resultUrl += '?' + paramsUrl;
}
return resultUrl;
}
$('.option-values label input').click(function () {
ajaxGetFilterValue();
});
function ajaxGetFilterValue() {
var url = getUrlFilter();
if (url.indexOf('?') == -1) {
url += '&ajax_filter=true';
} else {
url += '?ajax_filter=true';
}
$.ajax({
url: url,
dataType: "json"
}).done(function (json) {
var jsonParse = JSON.parse(JSON.stringify(json));
var options = [];
var optionsObject = {};
for (key in jsonParse) {
for (keyOption in jsonParse[key].values) {
options = options.concat(jsonParse[key].values[keyOption].id);
optionsObject[jsonParse[key].values[keyOption].id + ""] = jsonParse[key].values[keyOption];
}
}
refreshFilterOptions(options, optionsObject);
});
}
function refreshFilterOptions(options, optionsObject) {
//console.log(optionsObject["60009572730598"]);
$('#ocfilter-content .option-values label').each(function (key, value) {
var id = $(this).attr('id');
id = id.substr(2);
if (options.indexOf("" + id) !== -1) {
if ($(this).hasClass('inactive_option')) {
$(this).removeClass('inactive_option');
}
$(this).find('.badge').text(optionsObject[id].count);
$(this).find('input').prop('disabled', false);
} else {
$(this).addClass('inactive_option');
$(this).find('input').prop('checked', false);
$(this).find('input').prop('disabled', true);
}
});
}
// $(document).mouseup(function (e) {
// var container = $(".panel-oc-ocfilter");
// if (container.has(e.target).length === 0){
// $('#ocfilter').animate({
// right: '-250px'
// }, 200);
// $(this).animate({
// right: '0'
// }, 200);
// $(this).removeClass("actives");
// }
// });
let filterOc = function () { //главная функция
$('#filter-click').click(function () {
if ($(this).hasClass('actives')) {
$('#ocfilter').animate({
right: '-250px'
}, 200);
$(this).animate({
right: '0'
}, 200);
$(this).removeClass("actives");
} else {
$(this).animate({
right: '250px'
}, 200);
$('#ocfilter').animate({
right: '0'
}, 200);
$(this).addClass("actives");
}
});
};
$(document).ready(filterOc);