star.page.js
1.74 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
/**
* 星潮教室首页
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/5/31
*/
var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper'),
lazyLoad = require('yoho-jquery-lazyload'),
ellipsis = require('yoho-mlellipsis');
var avatarSwiper, avatarKey, $this, $title, $cont;
lazyLoad($('img.lazy'));
ellipsis.init();
if ($('.banner-swiper .swiper-slide').length > 1) {
new Swiper('.banner-swiper', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
pagination: '.banner-top .pagination-inner'
});
}
if ($('.avatar-swiper .swiper-slide').length > 1) {
avatarSwiper = new Swiper('.avatar-swiper', {
loop: true,
initialSlide: 3,
centeredSlides: true,
lazyLoading: true,
lazyLoadingInPrevNext: true,
slidesPerView: 'auto',
slidesOffsetBefore: '-' + $('.avatar-swiper').find('li').not('.swiper-slide-visible').width() / 2,
watchSlidesProgress: true,
watchSlidesVisibility: true
});
}
if ($('.star-info').find('li').length > 0) {
// 限制标题字数
$('.star-article').each(function() {
$this = $(this);
$title = $this.find('.article-title');
$cont = $this.find('p');
$title[0].mlellipsis(2);
$cont[0].mlellipsis(3);
});
}
$('body').addClass('star-index-bg');
$('.avatar-swiper li').not('.swiper-slide-active').on('click', function() {
avatarKey = $(this).index();
avatarSwiper.slideTo(avatarKey, 1000, false);
});
$('.swiper-slide-active').on('click', function() {
location.href = $(this).find('img').data('url');
});