(function($) { "use strict"; /* banner */ var banner_cont = $(".hm-banner .banner-carousel"), banner_pic = $(".hm-banner .carousel-pic"), _head = 'header', speed = 3; function bannerscroll() { var headh = $(_head).length ? $(_head).height() : 0; var h = banner_cont.height() + headh; banner_pic.css({ "position": "relative", "top": $(window).scrolltop() > h ? "" : $(window).scrolltop() / speed }); } function bannerbox() { imgfullscreen(banner_pic); if ($(window).width() > 991) { imgfullscreen(banner_pic); } else { imgfullscreen(banner_pic, $(window).width(), banner_pic.height() || ''); } } bannerscroll(); bannerbox(); $(window).resize(function () { bannerbox(); }); $(window).scroll(function () { bannerscroll(); }); var hmbanner = $('.hm-banner'), hmcarousel = hmbanner.find('.carousel'), carouselarrow = hmbanner.find('.carousel-arrow'), carouselpage = hmbanner.find('.carousel-page'), carouselprogress = hmbanner.find('.carousel-progress'); carouselpage.find('.total').text(hmcarousel.find('.carousel-item').length); hmcarousel.slick({ autoplay: true, autoplayspeed: 5700, speed: 377, prevarrow: carouselarrow.find('.prev'), nextarrow: carouselarrow.find('.next'), pauseonfocus: false, pauseonhover: false, fade: true }).on({ 'beforechange': function (event, slick, currentslide, nextslide) { var _item = $(this).find(".carousel-item"); _item.eq(nextslide).addclass("show").siblings().removeclass("show"); carouselprogress.removeclass('show'); carouselpage.find('.num').text(nextslide + 1); }, 'afterchange': function () { carouselprogress.addclass('show'); } }); settimeout(function () { hmcarousel.find(".carousel-item").eq(0).addclass("show"); carouselprogress.addclass('show'); }, 1); /* hot news */ var hmhot = $('.hm-hot'), hotcarousel = hmhot.find('.hot-carousel'); hotcarousel.find('.carousel').slick({ autoplay: true, autoplayspeed: 1200, speed: 1000, swipe: false, pauseonfocus: false, vertical: true, arrows: false, dots: true, appenddots: hotcarousel, custompaging: function() {return $('');} }); /* layout */ var hmlayout = $('.hm-layout'), hmlinfo = hmlayout.find('.hml-info'), hmlitem = hmlayout.find('.hml-item'); sethmlitem(); $(window).resize(function () { sethmlitem(); }); function sethmlitem() { if ($(window).width() > 991) { hmlitem.on({ mouseenter: function () { var _index = $(this).index() + 1; hmlinfo.addclass('hml' + _index); }, mouseleave: function () { var _index = $(this).index() + 1; hmlinfo.removeclass('hml' + _index); } }) } else { hmlitem.off('mouseenter mouseleave'); } } }(jquery));