(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));