list.js
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* 商品列表页
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/11/23
*/
var $ = require('yoho.jquery'),
lazyLoad = require('yoho.lazyload');
require('yoho.placeholder');
require('./filter');
require('./sort-pager');
require('./product');
//最近浏览的商品Lazyload
lazyLoad($('.latest-walk .lazy'));
//无搜索结果
if ($('.no-result').length > 0) {
$('#no-result-input').placeholder();
$('#search-again-btn').click(function() {
$(this).closest('form').submit();
});
}
//NEW页面图片轮播切换
(function() {
var $brands = $('.brands');
var wrapWidth,
$firstBrand,
totalWidth,
perWidth;
if ($brands.length === 0) {
return;
}
wrapWidth = $('.brands-wrap').width();
$firstBrand = $brands.children('li:first-child');
perWidth = $firstBrand.width() + $firstBrand.css('margin-left').replace('px', '') * 1;
totalWidth = perWidth * $brands.children('li').length;
//针对NEW页面Header的brand banner切换
$('.new-brands').on('click', '.pre,.next', function() {
var $this = $(this),
left;
left = $brands.css('left');
if (left === 'auto') {
left = 0;
} else {
left = +left.replace('px', '');
}
if (($this).hasClass('pre')) {
//左边界
if (left + wrapWidth > 0) {
return;
}
$brands.css('left', left + wrapWidth + 'px');
} else {
//右边界
if (left - wrapWidth < -totalWidth) {
return;
}
$brands.css('left', left - wrapWidth + 'px');
}
});
}());