...
|
...
|
@@ -15,6 +15,7 @@ moreUnicode = { |
|
|
down: ''
|
|
|
};
|
|
|
|
|
|
//品牌相关变量
|
|
|
var $brandDefault = $('.brand .default'),
|
|
|
$brandPanel = $('.brand .brand-panel'),
|
|
|
$brandAttrs = $('.brand .attr'),
|
...
|
...
|
@@ -23,7 +24,19 @@ var $brandDefault = $('.brand .default'), |
|
|
|
|
|
var $brandMoreTxt, $brandMoreIcon;
|
|
|
|
|
|
// var uriLoc = require('./uri');
|
|
|
//价格相关变量
|
|
|
var $udPrice = $('.ud-price-range'),
|
|
|
interReg = /^\d+$/,
|
|
|
$limit, $min, $max, $btn;
|
|
|
|
|
|
//分类相关变量
|
|
|
var $sortSub = $('.sort-sub-wrap');
|
|
|
|
|
|
//高级选项相关变量
|
|
|
var $seniorSubWrap = $('.senior-sub-wrap'),
|
|
|
$seniorAttrWrap = $('.senior-attr-wrap');
|
|
|
|
|
|
var seniorHoverTime, hoveredIndex;
|
|
|
|
|
|
//清除checkbox选中状态
|
|
|
function clearChecked($checkbox) {
|
...
|
...
|
@@ -57,9 +70,11 @@ function uriLoc(attr, val) { |
|
|
window.location.href = newHref;
|
|
|
}
|
|
|
|
|
|
if ($brandMore.length > 0) {
|
|
|
$brandMoreTxt = $brandMore.children('em');
|
|
|
$brandMoreIcon = $brandMore.children('.iconfont');
|
|
|
//隐藏高级选项面板
|
|
|
function hideSeniorPanel(index) {
|
|
|
$seniorSubWrap.children('.senior-sub:eq(' + hoveredIndex + ')').addClass('hide');
|
|
|
$seniorAttrWrap.children('.attr:eq(' + hoveredIndex + ')').removeClass('hover');
|
|
|
hoveredIndex = -1;
|
|
|
}
|
|
|
|
|
|
//屏蔽筛选项双击文字选中
|
...
|
...
|
@@ -67,30 +82,21 @@ $('.filter-box').on('selectstart', '.attr, .brands-index span', function() { |
|
|
return false;
|
|
|
});
|
|
|
|
|
|
//checkbox
|
|
|
$('.check-container').on('click', '.attr', function() {
|
|
|
var $this = $(this),
|
|
|
$check = $this.find('.checkbox'),
|
|
|
$btnOk = $this.parent('.check-container').next('.btns').find('.multi-select-ok');
|
|
|
//【分类】
|
|
|
$('.sort-pre').on('click', 'li', function() {
|
|
|
var index = $(this).index();
|
|
|
|
|
|
$check.toggleClass('checked');
|
|
|
|
|
|
if ($check.hasClass('checked')) {
|
|
|
$check.html(checkUnicode.checked);
|
|
|
} else {
|
|
|
$check.html(checkUnicode.unchecked);
|
|
|
}
|
|
|
|
|
|
//更新按钮状态
|
|
|
if ($check.hasClass('checked') ||
|
|
|
$this.siblings('.attr').find('.checked').length > 0) {
|
|
|
$btnOk.removeClass('dis');
|
|
|
} else {
|
|
|
$btnOk.addClass('dis');
|
|
|
}
|
|
|
$sortSub.children(':not(.hide)').addClass('hide');
|
|
|
$sortSub.children(':eq(' + index + ')').removeClass('hide');
|
|
|
});
|
|
|
|
|
|
//品牌多选
|
|
|
//【品牌】
|
|
|
if ($brandMore.length > 0) {
|
|
|
$brandMoreTxt = $brandMore.children('em');
|
|
|
$brandMoreIcon = $brandMore.children('.iconfont');
|
|
|
}
|
|
|
|
|
|
//【品牌】多选
|
|
|
$brandMulti.click(function() {
|
|
|
if ($brandPanel.css('display') === 'none') {
|
|
|
|
...
|
...
|
@@ -102,6 +108,7 @@ $brandMulti.click(function() { |
|
|
$(this).addClass('hide');
|
|
|
});
|
|
|
|
|
|
//【品牌】更多
|
|
|
$brandMore.click(function() {
|
|
|
var $this = $(this);
|
|
|
|
...
|
...
|
@@ -120,7 +127,7 @@ $brandMore.click(function() { |
|
|
$(this).toggleClass('more');
|
|
|
});
|
|
|
|
|
|
//品牌索引
|
|
|
//【品牌】索引
|
|
|
$('.brands-index').on('click', 'span', function() {
|
|
|
var $this = $(this),
|
|
|
index = $this.data('index');
|
...
|
...
|
@@ -134,7 +141,7 @@ $('.brands-index').on('click', 'span', function() { |
|
|
}
|
|
|
});
|
|
|
|
|
|
//品牌搜索
|
|
|
//【品牌】搜索
|
|
|
$('#brand-search-input').keyup(function() {
|
|
|
var val = $(this).val().toLowerCase();
|
|
|
|
...
|
...
|
@@ -145,6 +152,7 @@ $('#brand-search-input').keyup(function() { |
|
|
}
|
|
|
});
|
|
|
|
|
|
//【品牌】多选确定
|
|
|
$('#brand-multi-ok').click(function() {
|
|
|
var val = '';
|
|
|
|
...
|
...
|
@@ -161,7 +169,7 @@ $('#brand-multi-ok').click(function() { |
|
|
uriLoc('brand', val);
|
|
|
});
|
|
|
|
|
|
//多选取消(品牌/高级选项)
|
|
|
//【品牌/高级选项】多选取消
|
|
|
$('.multi-select-cancel').click(function() {
|
|
|
var $panel = $(this).closest('.multi');
|
|
|
|
...
|
...
|
@@ -175,21 +183,44 @@ $('.multi-select-cancel').click(function() { |
|
|
clearChecked($panel.find('.checkbox.checked')); //清除选中状态
|
|
|
});
|
|
|
|
|
|
//用户定义价格处理
|
|
|
(function() {
|
|
|
var $udPrice = $('.ud-price-range'),
|
|
|
interReg = /^\d+$/,
|
|
|
$limit, $min, $max, $btn;
|
|
|
//【品牌/高级选项】checkbox
|
|
|
$('.check-container').on('click', '.attr', function() {
|
|
|
var $this = $(this),
|
|
|
$check = $this.find('.checkbox'),
|
|
|
$btnOk = $this.parent('.check-container').next('.btns').find('.multi-select-ok');
|
|
|
|
|
|
if ($udPrice.length === 0) {
|
|
|
return;
|
|
|
$check.toggleClass('checked');
|
|
|
|
|
|
if ($check.hasClass('checked')) {
|
|
|
$check.html(checkUnicode.checked);
|
|
|
} else {
|
|
|
$check.html(checkUnicode.unchecked);
|
|
|
}
|
|
|
|
|
|
//更新按钮状态
|
|
|
if ($check.hasClass('checked') ||
|
|
|
$this.siblings('.attr').find('.checked').length > 0) {
|
|
|
$btnOk.removeClass('dis');
|
|
|
} else {
|
|
|
$btnOk.addClass('dis');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//【品牌/高级选项】当多选时阻止链接默认跳转
|
|
|
$('.brand, .senior').on('click', '.attr > a', function(e) {
|
|
|
if ($(this).closest('.multi').length > 0) {
|
|
|
e.preventDefault();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//【价格】用户定义价格处理
|
|
|
if ($udPrice.length > 0) {
|
|
|
$limit = $udPrice.find('.limit');
|
|
|
$min = $limit.filter('.min');
|
|
|
$max = $limit.filter('.max');
|
|
|
$btn = $udPrice.find('.price-sure');
|
|
|
|
|
|
//【价格】输入
|
|
|
$limit.keyup(function() {
|
|
|
var min = $.trim($min.val()),
|
|
|
max = $.trim($max.val()),
|
...
|
...
|
@@ -205,7 +236,7 @@ $('.multi-select-cancel').click(function() { |
|
|
}
|
|
|
});
|
|
|
|
|
|
//价格多项查询
|
|
|
//【价格】多项查询
|
|
|
$btn.click(function() {
|
|
|
var min = $.trim($min.val()),
|
|
|
max = $.trim($max.val()),
|
...
|
...
|
@@ -220,21 +251,30 @@ $('.multi-select-cancel').click(function() { |
|
|
|
|
|
uriLoc('price', min + ',' + max);
|
|
|
});
|
|
|
}());
|
|
|
}
|
|
|
|
|
|
//【高级选项】鼠标移入显示子项
|
|
|
$seniorAttrWrap.on('mouseenter', '.attr', function() {
|
|
|
var index = $(this).addClass('hover').index();
|
|
|
|
|
|
//高级选项
|
|
|
$('.senior-attr-wrap').on('mouseenter', '.attr', function() {
|
|
|
$(this).children('.sub').removeClass('hide');
|
|
|
$seniorSubWrap.children('.senior-sub:eq(' + index + ')').removeClass('hide');
|
|
|
}).on('mouseleave', '.attr', function() {
|
|
|
$(this).children('.sub').addClass('hide');
|
|
|
var $this = $(this),
|
|
|
index = $this.index();
|
|
|
|
|
|
hoveredIndex = index;
|
|
|
|
|
|
seniorHoverTime = setTimeout(function() {
|
|
|
hideSeniorPanel();
|
|
|
}, 100);
|
|
|
});
|
|
|
|
|
|
//高级选项多选
|
|
|
$('.sub').on('click', '.multi-select', function() {
|
|
|
$(this).closest('.sub').addClass('multi');
|
|
|
//【高级选项】多选
|
|
|
$('.senior-sub').on('click', '.multi-select', function() {
|
|
|
$(this).closest('.senior-sub').addClass('multi');
|
|
|
}).on('click', '.multi-select-ok', function() {
|
|
|
var $btn = $(this),
|
|
|
$sub = $btn.closest('.sub'),
|
|
|
$sub = $btn.closest('.senior-sub'),
|
|
|
val = '';
|
|
|
|
|
|
if ($btn.hasClass('dis')) {
|
...
|
...
|
@@ -248,11 +288,32 @@ $('.sub').on('click', '.multi-select', function() { |
|
|
});
|
|
|
|
|
|
uriLoc($sub.data('attr'), val);
|
|
|
}).on('mouseenter', function() {
|
|
|
clearTimeout(seniorHoverTime);
|
|
|
}).on('mouseleave', function() {
|
|
|
hideSeniorPanel();
|
|
|
});
|
|
|
|
|
|
//当多选时阻止品牌和高级选项的默认跳转
|
|
|
$('.brand, .senior').on('click', '.attr > a', function(e) {
|
|
|
if ($(this).closest('.multi').length > 0) {
|
|
|
e.preventDefault();
|
|
|
}
|
|
|
}); |
|
|
\ No newline at end of file |
|
|
//操作栏
|
|
|
(function() {
|
|
|
var $countPerPage = $('#count-per-page'),
|
|
|
$countChose = $countPerPage.next('ul');
|
|
|
|
|
|
var SLIDETIME = 200;
|
|
|
|
|
|
$(document).click(function(e) {
|
|
|
if ($(e.target).closest('.page-count').length > 0) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$countChose && $countChose.slideUp(SLIDETIME);
|
|
|
});
|
|
|
|
|
|
$countPerPage.click(function() {
|
|
|
if ($countChose.css('display') === 'none') {
|
|
|
$countChose.slideDown(SLIDETIME);
|
|
|
} else {
|
|
|
$countChose.slideUp(SLIDETIME);
|
|
|
}
|
|
|
});
|
|
|
}()); |
|
|
\ No newline at end of file |
...
|
...
|
|