Showing
2 changed files
with
54 additions
and
54 deletions
@@ -11,8 +11,7 @@ var $ = require('jquery'), | @@ -11,8 +11,7 @@ var $ = require('jquery'), | ||
11 | 11 | ||
12 | var $authorIntro = $('.author .intro'); | 12 | var $authorIntro = $('.author .intro'); |
13 | 13 | ||
14 | -var isEzinPage = false, | ||
15 | - isIphone = navigator.userAgent.indexOf('iPhone') > 0 ? true : false; | 14 | +var pageInIscroll = false; |
16 | 15 | ||
17 | var hasCollocationBlock = $('.collocation-block').length > 0 ? true : false; | 16 | var hasCollocationBlock = $('.collocation-block').length > 0 ? true : false; |
18 | 17 | ||
@@ -42,7 +41,7 @@ function posCollocationArrow($curCo) { | @@ -42,7 +41,7 @@ function posCollocationArrow($curCo) { | ||
42 | backgroundPosition: bgPos + ' bottom' | 41 | backgroundPosition: bgPos + ' bottom' |
43 | }); | 42 | }); |
44 | 43 | ||
45 | - if (isIphone && !isEzinPage) { | 44 | + if (pageInIscroll) { |
46 | $fixedThumbContainer.css({ | 45 | $fixedThumbContainer.css({ |
47 | backgroundPosition: bgPos + ' bottom' | 46 | backgroundPosition: bgPos + ' bottom' |
48 | }); | 47 | }); |
@@ -62,7 +61,7 @@ function thumbTouchEvt(e) { | @@ -62,7 +61,7 @@ function thumbTouchEvt(e) { | ||
62 | 61 | ||
63 | $thumbs.filter('.focus').removeClass('focus'); | 62 | $thumbs.filter('.focus').removeClass('focus'); |
64 | 63 | ||
65 | - if (isIphone && !isEzinPage) { | 64 | + if (pageInIscroll) { |
66 | if ($curCo.closest('.fixed-thumb-container').length > 0) { | 65 | if ($curCo.closest('.fixed-thumb-container').length > 0) { |
67 | $brother = $thumbContainer; | 66 | $brother = $thumbContainer; |
68 | } else { | 67 | } else { |
@@ -86,7 +85,7 @@ function thumbTouchEvt(e) { | @@ -86,7 +85,7 @@ function thumbTouchEvt(e) { | ||
86 | // | 85 | // |
87 | lazyLoad($curProds.find('.lazy')); | 86 | lazyLoad($curProds.find('.lazy')); |
88 | 87 | ||
89 | - if (isIphone && !isEzinPage) { | 88 | + if (pageInIscroll) { |
90 | if (myScroll) { | 89 | if (myScroll) { |
91 | myScroll.scrollToElement(scrollToEl, 400); | 90 | myScroll.scrollToElement(scrollToEl, 400); |
92 | } | 91 | } |
@@ -99,14 +98,6 @@ function thumbTouchEvt(e) { | @@ -99,14 +98,6 @@ function thumbTouchEvt(e) { | ||
99 | myScroll && myScroll.refresh(); | 98 | myScroll && myScroll.refresh(); |
100 | } | 99 | } |
101 | 100 | ||
102 | -if (isIphone && !isEzinPage) { | ||
103 | - if ($('.yoho-header').length > 0) { | ||
104 | - $('#wrapper').addClass('ios has-head'); | ||
105 | - } else { | ||
106 | - $('#wrapper').addClass('ios'); | ||
107 | - } | ||
108 | -} | ||
109 | - | ||
110 | ellipsis.init(); | 101 | ellipsis.init(); |
111 | 102 | ||
112 | lazyLoad($('.lazy')); | 103 | lazyLoad($('.lazy')); |
@@ -122,45 +113,6 @@ if ($authorIntro.offset() && (parseInt($authorIntro.offset().left, 10) === | @@ -122,45 +113,6 @@ if ($authorIntro.offset() && (parseInt($authorIntro.offset().left, 10) === | ||
122 | $authorIntro.css('padding-top', 0); | 113 | $authorIntro.css('padding-top', 0); |
123 | } | 114 | } |
124 | 115 | ||
125 | -//有搭配模块,iphone使用iscroll初始化滚动并有固定的搭配栏,其他的没有 | ||
126 | -if (hasCollocationBlock) { | ||
127 | - $coBlock = $('.collocation-block'); | ||
128 | - $thumbContainer = $coBlock.children('.thumb-container'); | ||
129 | - $thumbs = $thumbContainer.find('li'); | ||
130 | - $prods = $coBlock.find('.prod'); | ||
131 | - | ||
132 | - thumbWidth = $thumbs.width(); | ||
133 | - | ||
134 | - if (isIphone) { | ||
135 | - $fixedThumbContainer = $('#wrapper') | ||
136 | - .after($thumbContainer.clone().addClass('fixed-thumb-container fixed-bottom')) | ||
137 | - .next('.thumb-container'); | ||
138 | - | ||
139 | - //load img of fixed thumb container | ||
140 | - lazyLoad($fixedThumbContainer.find('.lazy'), { | ||
141 | - event: 'sporty' | ||
142 | - }); | ||
143 | - } | ||
144 | - | ||
145 | - //Init Arrow Position | ||
146 | - posCollocationArrow($thumbs.filter('.focus')); | ||
147 | - | ||
148 | - $thumbContainer.delegate('.thumb', 'touchend', thumbTouchEvt); | ||
149 | - | ||
150 | - if (isIphone && !isEzinPage) { | ||
151 | - $fixedThumbContainer.delegate('.thumb', 'touchend', thumbTouchEvt); | ||
152 | - } | ||
153 | -} | ||
154 | - | ||
155 | -/** | ||
156 | - * 初始化页面参数 | ||
157 | - */ | ||
158 | -exports.init = function (flag) { | ||
159 | - if (flag === true) { | ||
160 | - isEzinPage = true; | ||
161 | - } | ||
162 | -}; | ||
163 | - | ||
164 | // 初始化iscroll | 116 | // 初始化iscroll |
165 | window.onload = function() { | 117 | window.onload = function() { |
166 | var $scroller = $('#scroller'), | 118 | var $scroller = $('#scroller'), |
@@ -169,7 +121,7 @@ window.onload = function() { | @@ -169,7 +121,7 @@ window.onload = function() { | ||
169 | var hH = 0, | 121 | var hH = 0, |
170 | winH, tcH, cbH, cbTop, fixedThumbDom; | 122 | winH, tcH, cbH, cbTop, fixedThumbDom; |
171 | 123 | ||
172 | - if (!isIphone || isEzinPage) { | 124 | + if (!pageInIscroll) { |
173 | return; | 125 | return; |
174 | } | 126 | } |
175 | 127 | ||
@@ -241,4 +193,50 @@ window.onload = function() { | @@ -241,4 +193,50 @@ window.onload = function() { | ||
241 | } | 193 | } |
242 | $scroller.trigger('scroll'); | 194 | $scroller.trigger('scroll'); |
243 | }); | 195 | }); |
196 | +}; | ||
197 | + | ||
198 | +//是否使用iscroll初始化页面 | ||
199 | +//接口暴露在HTML中,使用压缩名 | ||
200 | +exports.i = function(useIscroll) { | ||
201 | + var isIphone = navigator.userAgent.indexOf('iPhone') > 0 ? true : false; | ||
202 | + | ||
203 | + pageInIscroll = isIphone && useIscroll; | ||
204 | + | ||
205 | + if (pageInIscroll) { | ||
206 | + if ($('.yoho-header').length > 0) { | ||
207 | + $('#wrapper').addClass('ios has-head'); | ||
208 | + } else { | ||
209 | + $('#wrapper').addClass('ios'); | ||
210 | + } | ||
211 | + } | ||
212 | + | ||
213 | + //有搭配模块,iphone使用iscroll初始化滚动并有固定的搭配栏,其他的没有 | ||
214 | + if (hasCollocationBlock) { | ||
215 | + $coBlock = $('.collocation-block'); | ||
216 | + $thumbContainer = $coBlock.children('.thumb-container'); | ||
217 | + $thumbs = $thumbContainer.find('li'); | ||
218 | + $prods = $coBlock.find('.prod'); | ||
219 | + | ||
220 | + thumbWidth = $thumbs.width(); | ||
221 | + | ||
222 | + if (pageInIscroll) { | ||
223 | + $fixedThumbContainer = $('#wrapper') | ||
224 | + .after($thumbContainer.clone().addClass('fixed-thumb-container fixed-bottom')) | ||
225 | + .next('.thumb-container'); | ||
226 | + | ||
227 | + //load img of fixed thumb container | ||
228 | + lazyLoad($fixedThumbContainer.find('.lazy'), { | ||
229 | + event: 'sporty' | ||
230 | + }); | ||
231 | + } | ||
232 | + | ||
233 | + //Init Arrow Position | ||
234 | + posCollocationArrow($thumbs.filter('.focus')); | ||
235 | + | ||
236 | + $thumbContainer.delegate('.thumb', 'touchend', thumbTouchEvt); | ||
237 | + | ||
238 | + if (pageInIscroll) { | ||
239 | + $fixedThumbContainer.delegate('.thumb', 'touchend', thumbTouchEvt); | ||
240 | + } | ||
241 | + } | ||
244 | }; | 242 | }; |
-
Please register or login to post a comment