|
|
/*
|
|
|
* @fileOverview magazine页的JS
|
|
|
* @author fei.hong@yoho.cn
|
|
|
* @date 2014-05-30
|
|
|
* magazine页js
|
|
|
* @author: yue.liu@yoho.cn
|
|
|
* @date: 2015-04-22
|
|
|
*/
|
|
|
|
|
|
var $ = require("jquery");
|
|
|
var dot = require("dot");
|
|
|
var json = require("json");
|
|
|
var share = require("yoho-share");
|
|
|
var swiper = require('yoho.swiper');
|
|
|
|
|
|
require('../plugin/lazyloadImage');
|
|
|
require('../plugin/imgSlider');
|
|
|
require('jquery.cycle');
|
|
|
require('../plugin/imgZoom');
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 初始化
|
|
|
*/
|
|
|
exports.init = function()
|
|
|
{
|
|
|
var shareUrl = $(".share").attr("data-link");
|
|
|
share.init({
|
|
|
shareUrl:shareUrl,
|
|
|
img:$(".mags-slide li").eq(0).find("img").attr("src"),
|
|
|
sinaText:'随时引领潮流生活,我正在看《YOHO!潮流志》'+$(".date-price").find("span").text()+'期点杂志,每月7日,17日,27日出刊哦~',
|
|
|
fbTextFunction:function(){
|
|
|
return {
|
|
|
des:'随时引领潮流生活,我正在看《YOHO!潮流志》'+$(".date-price").find("span").text()+'期点杂志,每月7日,17日,27日出刊哦~',
|
|
|
name:'随时引领潮流生活,我正在看《YOHO!潮流志》'+$(".date-price").find("span").text()+'期点杂志,每月7日,17日,27日出刊哦~',
|
|
|
caption:'随时引领潮流生活,我正在看《YOHO!潮流志》'+$(".date-price").find("span").text()+'期点杂志,每月7日,17日,27日出刊哦~',
|
|
|
url:location.href
|
|
|
}
|
|
|
},
|
|
|
tweetText:'随时引领潮流生活,我正在看《YOHO!潮流志》'+$(".date-price").find("span").text()+'期点杂志,每月7日,17日,27日出刊哦~',
|
|
|
qqText:'随时引领潮流生活,我正在看《YOHO!潮流志》'+$(".date-price").find("span").text()+'期点杂志,每月7日,17日,27日出刊哦~'
|
|
|
var $ = require('jquery'),
|
|
|
share = require('../plugin/share'),
|
|
|
swiper = require('yoho-idangerous.swiper');
|
|
|
|
|
|
require('lazyload');
|
|
|
require('../plugin/imgslider');
|
|
|
|
|
|
exports.init = function() {
|
|
|
var shareUrl = $('.share').attr('data-link'),
|
|
|
shareCover = $('.share').attr('cover-url'),
|
|
|
detailTitle = $('.detail-title').find('h1'),
|
|
|
detailSubtitle = $('.detail-title').find('h2'),
|
|
|
magazineSlide,
|
|
|
timer,
|
|
|
magazineTimer;
|
|
|
|
|
|
//分享
|
|
|
share.init({
|
|
|
shareUrl: shareUrl,
|
|
|
img: shareCover,
|
|
|
sinaText:'【Yoho!Girls】' + detailTitle.text() + '\r\n' + detailSubtitle.text(),
|
|
|
fbTextFunction: function(){
|
|
|
return {
|
|
|
des: '【Yoho!Girls】' + detailTitle.text() + '\r\n' + detailSubtitle.text() + '#YohoGirl',
|
|
|
name: '【Yoho!Girls】' + detailTitle.text() + '\r\n' + detailSubtitle.text() + '#YohoGirl',
|
|
|
caption: '【Yoho!Girls】' + detailTitle.text() + '\r\n' + detailSubtitle.text() + '#YohoGirl',
|
|
|
url: location.href
|
|
|
}
|
|
|
},
|
|
|
tweetText: '【Yoho!Girls】' + detailTitle.text() + '\r\n' + detailSubtitle.text(),
|
|
|
qqText: '【Yoho!Girls】' + detailTitle.text() + ' ' + detailSubtitle.text() + '(来自Yoho!Girls)'
|
|
|
});
|
|
|
|
|
|
//图片懒加载
|
|
|
$('img.lazy').lazyload({
|
|
|
placeholder: 'data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///93d3f///yH5BAEAAAMALAAAAAABAAEAAAICVAEAOw=='
|
|
|
});
|
|
|
|
|
|
//显示控制箭头
|
|
|
(function() {
|
|
|
$('.column-slide').on('mouseenter',function() {
|
|
|
$('.column-slide').find('.slide-ctrl').hide();
|
|
|
if ($(this).find('li').size() <= 4) return;
|
|
|
clearTimeout(timer);
|
|
|
$(this).find('.slide-ctrl').show();
|
|
|
}).on('mouseleave',function(event) {
|
|
|
var $that = $(this);
|
|
|
timer = setTimeout(function() {
|
|
|
$that.find('.slide-ctrl').hide();
|
|
|
}, 1000)
|
|
|
});
|
|
|
//显示控制箭头
|
|
|
(function(){
|
|
|
var timer;
|
|
|
$(".column-slide").on("mouseenter",function(){
|
|
|
$(".column-slide").find(".slide-ctrl").hide();
|
|
|
if($(this).find("li").size()<=4) return;
|
|
|
clearTimeout(timer);
|
|
|
$(this).find(".slide-ctrl").show();
|
|
|
}).on("mouseleave",function(event){
|
|
|
var $that = $(this);
|
|
|
timer=setTimeout(function(){
|
|
|
$that.find(".slide-ctrl").hide();
|
|
|
},1000)
|
|
|
});
|
|
|
|
|
|
$(".column-slide .slide-ctrl").on("mouseenter",function(){
|
|
|
clearTimeout(timer);
|
|
|
$(this).show();
|
|
|
}).on("mouseleave",function(){
|
|
|
timer=setTimeout(function(){
|
|
|
$(this).hide();
|
|
|
},100)
|
|
|
});
|
|
|
|
|
|
})();
|
|
|
$("img.lazy").lazyload({
|
|
|
effect : "fadeIn"
|
|
|
$('.column-slide .slide-ctrl').on('mouseenter',function() {
|
|
|
clearTimeout(timer);
|
|
|
$(this).show();
|
|
|
}).on('mouseleave',function() {
|
|
|
timer=setTimeout(function() {
|
|
|
$(this).hide();
|
|
|
}, 100)
|
|
|
});
|
|
|
|
|
|
})();
|
|
|
|
|
|
//封面杂志图滚动
|
|
|
magazineSlide = new swiper('.mags-slide .swiper-container', {
|
|
|
pagination: '.slide-ctrl-tabs',
|
|
|
wrapperClass: 'slide-piclist',
|
|
|
slideClass: 'magazine-swiper',
|
|
|
paginationClickable: true,
|
|
|
autoplay: 5000,
|
|
|
loop: true,
|
|
|
slidesPerView: 'auto',
|
|
|
slideElement: 'li'
|
|
|
});
|
|
|
|
|
|
$('.column-slide.magazine-list').imgSlider({
|
|
|
itemClass:'magazine'
|
|
|
});
|
|
|
|
|
|
//当页面改变大小,ipad横竖屏切换重新加载插件
|
|
|
$(window).resize(function() {
|
|
|
clearTimeout(magazineTimer);
|
|
|
magazineTimer = setTimeout(function() {
|
|
|
$('.column-slide.magazine-list').imgSlider('resize');
|
|
|
}, 0)
|
|
|
});
|
|
|
|
|
|
$.ajax({
|
|
|
type:'GET',
|
|
|
url:'/channel/magazine/ezine',
|
|
|
success:function(response) {
|
|
|
var data = response.data,
|
|
|
len = data.length;
|
|
|
item ='',
|
|
|
ulNum = Math.ceil(len/16),
|
|
|
ulItem ='',
|
|
|
ulAnimateIndex = 0;
|
|
|
|
|
|
var animateWidth,
|
|
|
slideWrapWidth,
|
|
|
itemIndexStart,
|
|
|
itemIndexEnd,
|
|
|
i;
|
|
|
|
|
|
$('.e-zine .slide-box').html('<div class="slide-piclist-wrap clearfix" style="position:relative;top:0;left:0;"></div>');
|
|
|
|
|
|
//添加4个ul
|
|
|
for (var i=0; i<ulNum; i++) {
|
|
|
ulItem += '<ul class="slide-piclist clearfix"></ul>';
|
|
|
}
|
|
|
|
|
|
var magazineSlide = new swiper('.mags-slide .swiper-container',{
|
|
|
pagination: '.slide-ctrl-tabs',
|
|
|
wrapperClass:'slide-piclist',
|
|
|
slideClass:'magazine-swiper',
|
|
|
paginationClickable: true,
|
|
|
autoplay:5000,
|
|
|
loop:true,
|
|
|
slidesPerView: 'auto',
|
|
|
slideElement: 'li'
|
|
|
})
|
|
|
/*var magazineSlide=new swiper('.magazine-list .swiper-container',{
|
|
|
//slidesPerView: 'auto',
|
|
|
//slideElement: 'li'
|
|
|
simulateTouch:false,
|
|
|
wrapperClass:'slide-piclist',
|
|
|
slideClass:'magazine',
|
|
|
paginationClickable: true,
|
|
|
slidesPerView: 'auto',
|
|
|
slideElement: 'li',
|
|
|
onSlideChangeEnd: fallSwiperItems_buy
|
|
|
});
|
|
|
$('.slide-piclist-wrap').html(ulItem);
|
|
|
|
|
|
function fallSwiperItems_buy(){
|
|
|
var currentSlide=arguments[0];
|
|
|
_fallSwiperItems(currentSlide,"buy");
|
|
|
}
|
|
|
animateWidth = $('.mags-column').find('.slide-piclist').outerWidth();
|
|
|
slideWrapWidth = animateWidth * ulNum;
|
|
|
$('.slide-piclist-wrap').css({'width': slideWrapWidth});
|
|
|
|
|
|
function fallSwiperItems_rule(){
|
|
|
var currentSlide=arguments[0];
|
|
|
_fallSwiperItems(currentSlide,"rule");
|
|
|
}
|
|
|
var currentPageNumber=1;
|
|
|
function _fallSwiperItems(currentSlide,type){
|
|
|
var url="";
|
|
|
if(type=="buy") {
|
|
|
url="/channel/magazine/page?type=1&p=";
|
|
|
} else if( type=="zine") {
|
|
|
url="/channel/magazine/page?type=2&p=";
|
|
|
} else {
|
|
|
url="/channel/magazine/rules?p=";
|
|
|
//分别插入数据到4个ul
|
|
|
for (i=0; i<ulNum; i++) {
|
|
|
itemIndexStart = i * 16,
|
|
|
itemIndexEnd = i * 16 + 16;
|
|
|
item = '';
|
|
|
if (itemIndexEnd > len) {
|
|
|
itemIndexEnd = len;
|
|
|
}
|
|
|
for(var j = itemIndexStart;j<itemIndexEnd;j++){
|
|
|
item += '<li data-type='+data[j].magazineType+'><a href="javascript:;" title="'+data[j].releaseDate+'"><div class="img-wrap"><img src="'+data[j].cover+'" alt="" /></div><span>'+data[j].releaseDate+'</span></a></li>';
|
|
|
}
|
|
|
|
|
|
$('.slide-piclist-wrap').find('.slide-piclist').eq(i).html(item);
|
|
|
}
|
|
|
|
|
|
var totalLength=$(currentSlide.container).find(".swiper-slide").length;
|
|
|
var currentIndex=currentSlide.activeIndex;
|
|
|
if(totalLength-currentIndex<=6) {
|
|
|
$.ajax({
|
|
|
url:YohoConfig.mainUrl+url+(currentPageNumber++),
|
|
|
cache:false,
|
|
|
success:function(data){
|
|
|
for(var i=0;i<data.data.length;i++) {
|
|
|
var msg=data.data;
|
|
|
var newAppend=currentSlide.createSlide('<li class="'+_this.options.itemClass+' swiper-slide"><a href="javascript:;"><img src="" data-slide="'+msg[i].pics+'" data-original="'+msg[i].cover+'"/><span>'+msg[i].title+'</span></a></li>');
|
|
|
newAppend.append();
|
|
|
}
|
|
|
var oLi=$(currentSlide.container).find(".swiper-slide");
|
|
|
var LastSlide = currentSlide.getLastSlide();
|
|
|
currentSlide.reInit();
|
|
|
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}*/
|
|
|
//滚动
|
|
|
$('.mags-column').find('.slide-ctrl-prev').hide();
|
|
|
|
|
|
/*$(".magazine-list").find(".slide-ctrl").find('.slide-ctrl-prev').on('click', function(e){
|
|
|
e.preventDefault();
|
|
|
magazineSlide.swipePrev();
|
|
|
});
|
|
|
$(".magazine-list").find(".slide-ctrl").find('.slide-ctrl-next').on('click', function(e){
|
|
|
e.preventDefault()
|
|
|
magazineSlide.swipeNext();
|
|
|
$(".magazine").find("img").lazyload();
|
|
|
});*/
|
|
|
/*$(".mags-slide .slide-piclist").cycle({
|
|
|
fx: 'scrollHorz',
|
|
|
speed: 300,
|
|
|
timeout: 5000,
|
|
|
pager: '.mags-slide .slide-ctrl-tabs'
|
|
|
});*/
|
|
|
|
|
|
$.ajax({
|
|
|
type:'GET',
|
|
|
url:'/channel/magazine/ezine',
|
|
|
success:function(response){
|
|
|
var data = response.data;
|
|
|
var len = data.length;
|
|
|
var item ='';
|
|
|
var ulNum = Math.ceil(len/16);
|
|
|
var ulItem ='';
|
|
|
var ulAnimateIndex = 0;
|
|
|
|
|
|
$(".mags-column .slide-box").html('<div class="slide-piclist-wrap clearfix" style="position:relative;top:0;left:0;"></div>');
|
|
|
$(window).resize(function() {
|
|
|
animateWidth = $('.mags-column').find('.slide-piclist').outerWidth();
|
|
|
slideWrapWidth = animateWidth * ulNum;
|
|
|
|
|
|
//添加4个ul
|
|
|
for(var r=0;r<ulNum;r++){
|
|
|
ulItem += '<ul class="slide-piclist clearfix"></ul>';
|
|
|
}
|
|
|
$(".slide-piclist-wrap").html(ulItem);
|
|
|
|
|
|
var animateWidth = $(".mags-column").find(".slide-piclist").outerWidth();
|
|
|
var slideWrapWidth = animateWidth * ulNum;
|
|
|
$(".slide-piclist-wrap").css({"width":slideWrapWidth});
|
|
|
|
|
|
//分别插入数据到4个ul
|
|
|
for(var i=0;i<ulNum;i++){
|
|
|
var itemIndexStart = i*16;
|
|
|
var itemIndexEnd = i*16+16;
|
|
|
item = '';
|
|
|
if(itemIndexEnd>len){
|
|
|
itemIndexEnd=len;
|
|
|
}
|
|
|
for(var j = itemIndexStart;j<itemIndexEnd;j++){
|
|
|
item += '<li data-type='+data[j].magazineType+'><a href="javascript:;" title="'+data[j].releaseDate+'"><div class="img-wrap"><img src="'+data[j].cover+'" alt="" /></div><span>'+data[j].releaseDate+'</span></a></li>';
|
|
|
}
|
|
|
|
|
|
$(".slide-piclist-wrap").find(".slide-piclist").eq(i).html(item);
|
|
|
}
|
|
|
|
|
|
//滚动
|
|
|
$(".mags-column").find(".slide-ctrl-prev").hide();
|
|
|
$(".mags-column").on("click.next",".slide-ctrl-next",function(){
|
|
|
if(ulAnimateIndex>=ulNum-1) return;
|
|
|
if($(".slide-piclist-wrap").is(":animated")) return;
|
|
|
if(ulAnimateIndex==ulNum-2){
|
|
|
$('.mags-column').on('click.next','.slide-ctrl-next',function() {
|
|
|
if (ulAnimateIndex >= ulNum-1) return;
|
|
|
if ($('.slide-piclist-wrap').is(':animated')) return;
|
|
|
if (ulAnimateIndex==ulNum-2) {
|
|
|
$(this).hide();
|
|
|
}
|
|
|
$(this).siblings(".slide-ctrl-prev").show();
|
|
|
$(this).siblings('.slide-ctrl-prev').show();
|
|
|
ulAnimateIndex++;
|
|
|
$(".slide-piclist-wrap").stop().animate({"left":-animateWidth*ulAnimateIndex},500);
|
|
|
$('.slide-piclist-wrap').stop().animate({'left':-animateWidth * ulAnimateIndex}, 500);
|
|
|
});
|
|
|
|
|
|
$(".mags-column").on("click.prev",".slide-ctrl-prev",function(){
|
|
|
if(ulAnimateIndex<=0) return;
|
|
|
if($(".slide-piclist-wrap").is(":animated")) return;
|
|
|
if(ulAnimateIndex==1){
|
|
|
$('.mags-column').on('click.prev','.slide-ctrl-prev',function() {
|
|
|
if (ulAnimateIndex <= 0) return;
|
|
|
if ($('.slide-piclist-wrap').is(':animated')) return;
|
|
|
if (ulAnimateIndex === 1) {
|
|
|
$(this).hide();
|
|
|
}
|
|
|
$(this).siblings(".slide-ctrl-next").show();
|
|
|
$(this).siblings('.slide-ctrl-next').show();
|
|
|
ulAnimateIndex--;
|
|
|
$(".slide-piclist-wrap").stop().animate({"left":-animateWidth*ulAnimateIndex},500);
|
|
|
$('.slide-piclist-wrap').stop().animate({'left':-animateWidth * ulAnimateIndex}, 500);
|
|
|
});
|
|
|
|
|
|
/*for(var i=0;i<len;i++){
|
|
|
item += '<li data-type='+data[i].magazineType+'><a href="javascript:;" title="'+data[i].releaseDate+'"><div class="img-wrap"><img src="'+data[i].cover+'" alt="" /></div><span>'+data[i].releaseDate+'</span></a></li>';
|
|
|
}
|
|
|
$(".mags-column .slide-piclist").html(item);
|
|
|
$(".column-slide").imgSlider();
|
|
|
*/
|
|
|
|
|
|
$(".mags-column .slide-piclist").find("li").each(function(){
|
|
|
if($(this).data("type") ==2){
|
|
|
$('<em class="border"></em><i class="special-icon"></i>').appendTo($(this).find(".img-wrap"));
|
|
|
};
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
|
|
|
$(".column-slide.magazine-list").imgSlider({
|
|
|
itemClass:'magazine'
|
|
|
});
|
|
|
$(".column-slide.rule").imgSlider();
|
|
|
//ipad横竖屏切换
|
|
|
$(window).resize(function(){
|
|
|
clearTimeout(timer);
|
|
|
var timer = setTimeout(function(){
|
|
|
$(".column-slide.rule").imgSlider('resize');
|
|
|
$(".column-slide.magazine-list").imgSlider('resize');
|
|
|
},0)
|
|
|
clearTimeout(timer);
|
|
|
timer = setTimeout(function() {
|
|
|
$('.slide-piclist-wrap').css({'width': slideWrapWidth});
|
|
|
$('.slide-piclist-wrap').css({'left':-animateWidth * ulAnimateIndex}, 500);
|
|
|
}, 0)
|
|
|
}).resize();
|
|
|
|
|
|
});
|
|
|
$('.column-slide.rule').ImgZoom({
|
|
|
imgSrcAttr:'data-imgZoom'
|
|
|
});
|
|
|
|
|
|
$(".slide-piclist").on("click",".magazine",function(){
|
|
|
if(!$(this).find("img").attr("data-slide")) return;
|
|
|
if($(this).find("ul").size()>=1) return;
|
|
|
var data = decodeURIComponent($(this).find("img").attr("data-slide"));
|
|
|
var arr =eval("("+data+")");
|
|
|
var len = arr.length;
|
|
|
var $picList = $('<ul style="display:none;" class="magazine-content"></ul').appendTo($(this));
|
|
|
var item =''
|
|
|
|
|
|
for(var i=0;i<len;i++){
|
|
|
item += '<li><img src="" data-imgzoom="'+arr[i]+'" alt="" /></li>';
|
|
|
|
|
|
/*for(var i=0;i<len;i++){
|
|
|
item += '<li data-type='+data[i].magazineType+'><a href='javascript:;' title=''+data[i].releaseDate+''><div class='img-wrap'><img src=''+data[i].cover+'' alt='' /></div><span>'+data[i].releaseDate+'</span></a></li>';
|
|
|
}
|
|
|
$(item).appendTo($picList);
|
|
|
$(this).ImgZoom({
|
|
|
isContainFather: true
|
|
|
});
|
|
|
});
|
|
|
|
|
|
$(".column-slide.rule").on("mouseenter","li",function(){
|
|
|
var gifSrc = $(this).find("img").attr("data-imgzoom");
|
|
|
$(this).find("img").attr("src",gifSrc);
|
|
|
}).on("mouseleave","li",function(){
|
|
|
var staticSrc = $(this).find("img").attr("data-original");
|
|
|
$(this).find("img").attr("src",staticSrc);
|
|
|
})
|
|
|
}
|
|
|
|
|
|
$('.mags-column .slide-piclist').html(item);
|
|
|
$('.column-slide').imgSlider();
|
|
|
*/
|
|
|
|
|
|
$('.mags-column .slide-piclist').find('li').each(function() {
|
|
|
if($(this).data('type') ==2) {
|
|
|
$('<em class="border"></em><i class="special-icon"></i>').appendTo($(this).find('.img-wrap'));
|
|
|
};
|
|
|
});
|
|
|
}
|
|
|
})
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|