Authored by xuqi

fix guang detail

... ... @@ -11,8 +11,7 @@ var $ = require('jquery'),
var $authorIntro = $('.author .intro');
var isEzinPage = false,
isIphone = navigator.userAgent.indexOf('iPhone') > 0 ? true : false;
var pageInIscroll = false;
var hasCollocationBlock = $('.collocation-block').length > 0 ? true : false;
... ... @@ -42,7 +41,7 @@ function posCollocationArrow($curCo) {
backgroundPosition: bgPos + ' bottom'
});
if (isIphone && !isEzinPage) {
if (pageInIscroll) {
$fixedThumbContainer.css({
backgroundPosition: bgPos + ' bottom'
});
... ... @@ -62,7 +61,7 @@ function thumbTouchEvt(e) {
$thumbs.filter('.focus').removeClass('focus');
if (isIphone && !isEzinPage) {
if (pageInIscroll) {
if ($curCo.closest('.fixed-thumb-container').length > 0) {
$brother = $thumbContainer;
} else {
... ... @@ -86,7 +85,7 @@ function thumbTouchEvt(e) {
//
lazyLoad($curProds.find('.lazy'));
if (isIphone && !isEzinPage) {
if (pageInIscroll) {
if (myScroll) {
myScroll.scrollToElement(scrollToEl, 400);
}
... ... @@ -99,14 +98,6 @@ function thumbTouchEvt(e) {
myScroll && myScroll.refresh();
}
if (isIphone && !isEzinPage) {
if ($('.yoho-header').length > 0) {
$('#wrapper').addClass('ios has-head');
} else {
$('#wrapper').addClass('ios');
}
}
ellipsis.init();
lazyLoad($('.lazy'));
... ... @@ -122,45 +113,6 @@ if ($authorIntro.offset() && (parseInt($authorIntro.offset().left, 10) ===
$authorIntro.css('padding-top', 0);
}
//有搭配模块,iphone使用iscroll初始化滚动并有固定的搭配栏,其他的没有
if (hasCollocationBlock) {
$coBlock = $('.collocation-block');
$thumbContainer = $coBlock.children('.thumb-container');
$thumbs = $thumbContainer.find('li');
$prods = $coBlock.find('.prod');
thumbWidth = $thumbs.width();
if (isIphone) {
$fixedThumbContainer = $('#wrapper')
.after($thumbContainer.clone().addClass('fixed-thumb-container fixed-bottom'))
.next('.thumb-container');
//load img of fixed thumb container
lazyLoad($fixedThumbContainer.find('.lazy'), {
event: 'sporty'
});
}
//Init Arrow Position
posCollocationArrow($thumbs.filter('.focus'));
$thumbContainer.delegate('.thumb', 'touchend', thumbTouchEvt);
if (isIphone && !isEzinPage) {
$fixedThumbContainer.delegate('.thumb', 'touchend', thumbTouchEvt);
}
}
/**
* 初始化页面参数
*/
exports.init = function (flag) {
if (flag === true) {
isEzinPage = true;
}
};
// 初始化iscroll
window.onload = function() {
var $scroller = $('#scroller'),
... ... @@ -169,7 +121,7 @@ window.onload = function() {
var hH = 0,
winH, tcH, cbH, cbTop, fixedThumbDom;
if (!isIphone || isEzinPage) {
if (!pageInIscroll) {
return;
}
... ... @@ -242,3 +194,49 @@ window.onload = function() {
$scroller.trigger('scroll');
});
};
//是否使用iscroll初始化页面
//接口暴露在HTML中,使用压缩名
exports.i = function(useIscroll) {
var isIphone = navigator.userAgent.indexOf('iPhone') > 0 ? true : false;
pageInIscroll = isIphone && useIscroll;
if (pageInIscroll) {
if ($('.yoho-header').length > 0) {
$('#wrapper').addClass('ios has-head');
} else {
$('#wrapper').addClass('ios');
}
}
//有搭配模块,iphone使用iscroll初始化滚动并有固定的搭配栏,其他的没有
if (hasCollocationBlock) {
$coBlock = $('.collocation-block');
$thumbContainer = $coBlock.children('.thumb-container');
$thumbs = $thumbContainer.find('li');
$prods = $coBlock.find('.prod');
thumbWidth = $thumbs.width();
if (pageInIscroll) {
$fixedThumbContainer = $('#wrapper')
.after($thumbContainer.clone().addClass('fixed-thumb-container fixed-bottom'))
.next('.thumb-container');
//load img of fixed thumb container
lazyLoad($fixedThumbContainer.find('.lazy'), {
event: 'sporty'
});
}
//Init Arrow Position
posCollocationArrow($thumbs.filter('.focus'));
$thumbContainer.delegate('.thumb', 'touchend', thumbTouchEvt);
if (pageInIscroll) {
$fixedThumbContainer.delegate('.thumb', 'touchend', thumbTouchEvt);
}
}
};
\ No newline at end of file
... ...
... ... @@ -25,7 +25,9 @@
{{/if}}
{{#if guangDetail}}
<script>
seajs.use('js/guang/detail');
seajs.use('js/guang/detail', function(d) {
d.i(true);
});
</script>
{{/if}}
... ...