merge detail page update. code review by XWG
Showing
1 changed file
with
20 additions
and
12 deletions
@@ -12,13 +12,17 @@ var goodsSwiper, | @@ -12,13 +12,17 @@ var goodsSwiper, | ||
12 | $discountFolder = $('.goodsDiscount .discount-folder'), | 12 | $discountFolder = $('.goodsDiscount .discount-folder'), |
13 | $discountArrow = $('.goodsDiscount .first-item span'); | 13 | $discountArrow = $('.goodsDiscount .first-item span'); |
14 | 14 | ||
15 | -var goodsDiscountHammer = new Hammer(document.getElementById('goodsDiscount')); | 15 | +var goodsDiscountEl = document.getElementById('goodsDiscount'), |
16 | + goodsDiscountHammer = goodsDiscountEl && new Hammer(goodsDiscountEl); | ||
16 | 17 | ||
17 | require('./desc'); | 18 | require('./desc'); |
18 | require('./comments-consults'); | 19 | require('./comments-consults'); |
19 | 20 | ||
20 | //add extra marign-bottom for footer to show the yoho copyright | 21 | //add extra marign-bottom for footer to show the yoho copyright |
21 | -window.reMarginFooter('.cart-bar'); | 22 | + |
23 | +function showFooter() { | ||
24 | + window.reMarginFooter('.cart-bar'); | ||
25 | +} | ||
22 | 26 | ||
23 | lazyLoad($('img.lazy')); | 27 | lazyLoad($('img.lazy')); |
24 | 28 | ||
@@ -40,15 +44,19 @@ if (0 === $('.goodsDiscount .discount-folder').children().length) { | @@ -40,15 +44,19 @@ if (0 === $('.goodsDiscount .discount-folder').children().length) { | ||
40 | } | 44 | } |
41 | 45 | ||
42 | //goods-discount下拉按钮点击事件 | 46 | //goods-discount下拉按钮点击事件 |
43 | -goodsDiscountHammer.on('tap', function(e) { | ||
44 | - if ($discountFolder.is(':hidden')) { | ||
45 | - $discountArrow.removeClass('icon-down').addClass('icon-up').html(''); | ||
46 | - $discountFolder.slideDown(); | ||
47 | - } else { | ||
48 | - $discountArrow.removeClass('icon-up').addClass('icon-down').html(''); | ||
49 | - $discountFolder.slideUp(); | ||
50 | - } | ||
51 | - return false; | ||
52 | -}); | 47 | +if (goodsDiscountHammer) { |
48 | + goodsDiscountHammer.on('tap', function(e) { | ||
49 | + if ($discountFolder.is(':hidden')) { | ||
50 | + $discountArrow.removeClass('icon-down').addClass('icon-up').html(''); | ||
51 | + $discountFolder.slideDown(); | ||
52 | + } else { | ||
53 | + $discountArrow.removeClass('icon-up').addClass('icon-down').html(''); | ||
54 | + $discountFolder.slideUp(); | ||
55 | + } | ||
56 | + return false; | ||
57 | + }); | ||
58 | +} | ||
53 | 59 | ||
54 | require('./like'); | 60 | require('./like'); |
61 | + | ||
62 | +$(document).ready(showFooter); |
-
Please register or login to post a comment