"use strict"; (function () { // Global variables var userAgent = navigator.userAgent.toLowerCase(), $html = $("html"), isIE = userAgent.indexOf("msie") !== -1 ? parseInt(userAgent.split("msie")[1], 10) : userAgent.indexOf("trident") !== -1 ? 11 : userAgent.indexOf("edge") !== -1 ? 12 : false, isNoviBuilder = false, plugins = { rdNavbar: $(".rd-navbar"), swiper: $(".swiper-slider"), lightGallery: $('[data-lightgallery="group"]'), lightGalleryItem: $('[data-lightgallery="item"]'), lightDynamicGalleryItem: $('[data-lightgallery="dynamic"]'), slick: $(".slick-slider"), }; // Initialize scripts $(function () { // IE Polyfills if (isIE) { if (isIE === 12) $html.addClass("ie-edge"); if (isIE === 11) $html.addClass("ie-11"); if (isIE < 10) $html.addClass("lt-ie-10"); if (isIE < 11) $html.addClass("ie-10"); } // right toolbox scroll $('.scroll-top').click(function () { $('html,body').animate({ scrollTop: '0px' }, 800); }); $('.online dl').on("mouseover", function () { $(this).find("dt").show(); $(this).siblings().find("dt").hide(); }); $('.online dl').find('.remove').on("click", function () { $(this).parents("dt").hide(); }); $(window).scroll(function () { if ($(document).scrollTop() <= 100) { $('.online .scroll-top').hide(); } else { $('.online .scroll-top').show(); } }); function addSubNavSwiper() { if ($(".swiper-subnav").length > 0) { $(".swiper-subnav").addClass("swiper"); $(".swiper-subnav").find("ul").addClass("swiper-wrapper"); $(".swiper-subnav li.subnavli").each(function (e) { $(this).addClass("swiper-slide"); }); $(".swiper-subnav").find("ul").after("
"); var subNavSwiper = new Swiper('.subnavlist .swiper', { init: false, autoplay: false, slidesPerView: "auto", scrollbar: { el: '.swiper-scrollbar', dragSize: 130, } }); subNavSwiper.init(); } } function addSubTabSwiper() { if ($(".tabs-custom").length > 0) { $(".tabs-custom").addClass("swiper"); $(".tabs-custom").find("ul").addClass("swiper-wrapper"); $(".tabs-custom li.nav-item").each(function (e) { $(this).addClass("swiper-slide"); }); var subTabSwiper = new Swiper('.tabs-custom.swiper', { init: false, autoplay: false, slidesPerView: "auto" }); subTabSwiper.init(); } } function removeSubNavSwiper() { if (typeof subNavSwiper !== "undefined") { if ($(".swiper-subnav").length > 0) { $(".swiper-subnav").removeClass("swiper"); $(".swiper-subnav").find("ul").removeClass("swiper-wrapper"); $(".swiper-subnav li.subnavli").each(function (e) { $(this).removeClass("swiper-slide"); }); $(".swiper-subnav .swiper-scrollbar").remove(); subNavSwiper.destroy(); } } } if (window.innerWidth < 768) { addSubNavSwiper(); } else if (window.innerWidth >= 768) { removeSubNavSwiper(); } $(window).resize(function () { if (window.innerWidth < 768) { addSubNavSwiper(); } else if (window.innerWidth >= 768) { if ($(".swiper-subnav.swiper").length > 0) { $(".swiper-subnav").removeClass("swiper"); $(".swiper-subnav").find("ul").removeClass("swiper-wrapper"); $(".swiper-subnav li.subnavli").each(function (e) { $(this).removeClass("swiper-slide"); }); $(".swiper-subnav .swiper-scrollbar").remove(); if (typeof subNavSwiper !== "undefined") { subNavSwiper.destroy(); } } } }); if ($(".tabs-custom").length > 0) { addSubTabSwiper(); } /** * @desc Initialize the gallery with set of images * @param {object} itemsToInit - jQuery object * @param {string} addClass - additional gallery class */ function initLightGallery(itemsToInit, addClass) { if (!isNoviBuilder) { $(itemsToInit).lightGallery({ thumbnail: $(itemsToInit).attr("data-lg-thumbnail") !== "false", selector: "[data-lightgallery='item']", autoplay: $(itemsToInit).attr("data-lg-autoplay") === "true", pause: parseInt($(itemsToInit).attr("data-lg-autoplay-delay")) || 5000, addClass: addClass, mode: $(itemsToInit).attr("data-lg-animation") || "lg-slide", loop: $(itemsToInit).attr("data-lg-loop") !== "false", showThumbByDefault: false, }); } } /** * @desc Initialize the gallery with dynamic addition of images * @param {object} itemsToInit - jQuery object * @param {string} addClass - additional gallery class */ function initDynamicLightGallery(itemsToInit, addClass) { if (!isNoviBuilder) { $(itemsToInit).on("click", function () { $(itemsToInit).lightGallery({ thumbnail: $(itemsToInit).attr("data-lg-thumbnail") !== "false", selector: "[data-lightgallery='item']", autoplay: $(itemsToInit).attr("data-lg-autoplay") === "true", pause: parseInt($(itemsToInit).attr("data-lg-autoplay-delay")) || 5000, addClass: addClass, mode: $(itemsToInit).attr("data-lg-animation") || "lg-slide", loop: $(itemsToInit).attr("data-lg-loop") !== "false", dynamic: true, dynamicEl: JSON.parse($(itemsToInit).attr("data-lg-dynamic-elements")) || [], }); }); } } /** * @desc Initialize the gallery with one image * @param {object} itemToInit - jQuery object * @param {string} addClass - additional gallery class */ function initLightGalleryItem(itemToInit, addClass) { if (!isNoviBuilder) { $(itemToInit).lightGallery({ selector: "this", addClass: addClass, counter: false, youtubePlayerParams: { modestbranding: 1, showinfo: 0, rel: 0, controls: 0, }, vimeoPlayerParams: { byline: 0, portrait: 0, }, }); } } // lightGallery if (plugins.lightGallery.length) { for (var i = 0; i < plugins.lightGallery.length; i++) { initLightGallery(plugins.lightGallery[i]); } } // lightGallery item if (plugins.lightGalleryItem.length) { // Filter carousel items var notCarouselItems = []; for (var z = 0; z < plugins.lightGalleryItem.length; z++) { if ( !$(plugins.lightGalleryItem[z]).parents(".owl-carousel").length && !$(plugins.lightGalleryItem[z]).parents(".swiper-slider").length && !$(plugins.lightGalleryItem[z]).parents(".slick-slider").length ) { notCarouselItems.push(plugins.lightGalleryItem[z]); } } plugins.lightGalleryItem = notCarouselItems; for (var i = 0; i < plugins.lightGalleryItem.length; i++) { initLightGalleryItem(plugins.lightGalleryItem[i]); } } // Dynamic lightGallery if (plugins.lightDynamicGalleryItem.length) { for (var i = 0; i < plugins.lightDynamicGalleryItem.length; i++) { initDynamicLightGallery(plugins.lightDynamicGalleryItem[i]); } } // Slick carousel if (plugins.slick.length) { var i; for (i = 0; i < plugins.slick.length; i++) { var $slickItem = $(plugins.slick[i]); $slickItem .slick({ slidesToScroll: parseInt($slickItem.attr("data-slide-to-scroll")) || 1, asNavFor: $slickItem.attr("data-for") || false, dots: $slickItem.attr("data-dots") == "true", infinite: isNoviBuilder ? false : $slickItem.attr("data-loop") == "true", focusOnSelect: true, arrows: true, swipe: true, autoplay: $slickItem.attr("data-autoplay") == "true", vertical: $slickItem.attr("data-vertical") == "true", centerMode: $slickItem.attr("data-center-mode") == "true", centerPadding: $slickItem.attr("data-center-padding") ? $slickItem.attr("data-center-padding") : "0.50", mobileFirst: true, responsive: [ { breakpoint: 0, settings: { slidesToShow: parseInt($slickItem.attr("data-items")) || 1, }, }, { breakpoint: 575, settings: { slidesToShow: parseInt($slickItem.attr("data-xs-items")) || 1, }, }, { breakpoint: 767, settings: { slidesToShow: parseInt($slickItem.attr("data-sm-items")) || 1, }, }, { breakpoint: 991, settings: { slidesToShow: parseInt($slickItem.attr("data-md-items")) || 1, }, }, { breakpoint: 1199, settings: { slidesToShow: parseInt($slickItem.attr("data-lg-items")) || 1, swipe: false, }, }, ], }) .on("afterChange", function (event, slick, currentSlide, nextSlide) { var $this = $(this), childCarousel = $this.attr("data-child"); if (childCarousel) { $(childCarousel + " .slick-slide").removeClass("slick-current"); $(childCarousel + " .slick-slide") .eq(currentSlide) .addClass("slick-current"); } }); } } // Animate captions function initCaptionAnimate(swiper) { var animate = function (caption) { return function () { var duration; if ((duration = caption.getAttribute("data-caption-duration"))) caption.style.animationDuration = duration + "ms"; caption.classList.remove("not-animated"); caption.classList.add(caption.getAttribute("data-caption-animate")); caption.classList.add("animated"); }; }, initializeAnimation = function (captions) { for (var i = 0; i < captions.length; i++) { var caption = captions[i]; caption.classList.remove("animated"); caption.classList.remove( caption.getAttribute("data-caption-animate") ); caption.classList.add("not-animated"); } }, finalizeAnimation = function (captions) { for (var i = 0; i < captions.length; i++) { var caption = captions[i]; if (caption.getAttribute("data-caption-delay")) { setTimeout(animate(caption), Number(1500)); } else { animate(caption)(); } } }; // Caption parameters swiper.params.caption = { animationEvent: "slideChangeTransitionEnd", }; initializeAnimation( swiper.$wrapperEl[0].querySelectorAll("[data-caption-animate]") ); finalizeAnimation( swiper.$wrapperEl[0].children[swiper.activeIndex].querySelectorAll( "[data-caption-animate]" ) ); if (swiper.params.caption.animationEvent === "slideChangeTransitionEnd") { swiper.on(swiper.params.caption.animationEvent, function () { initializeAnimation( swiper.$wrapperEl[0].children[ swiper.previousIndex ].querySelectorAll("[data-caption-animate]") ); finalizeAnimation( swiper.$wrapperEl[0].children[swiper.activeIndex].querySelectorAll( "[data-caption-animate]" ) ); }); } else { swiper.on("slideChangeTransitionEnd", function () { initializeAnimation( swiper.$wrapperEl[0].children[ swiper.previousIndex ].querySelectorAll("[data-caption-animate]") ); }); swiper.on(swiper.params.caption.animationEvent, function () { finalizeAnimation( swiper.$wrapperEl[0].children[swiper.activeIndex].querySelectorAll( "[data-caption-animate]" ) ); }); } } // Swiper if (plugins.swiper.length) { for (let i = 0; i < plugins.swiper.length; i++) { let sliderMarkup = plugins.swiper[i], swiper, options = { loop: sliderMarkup.getAttribute("data-loop") === "true" || false, effect: isIE ? "slide" : sliderMarkup.getAttribute("data-slide-effect") || "slide", direction: sliderMarkup.getAttribute("data-direction") || "horizontal", speed: 1000, separateCaptions: sliderMarkup.getAttribute("data-separate-captions") === "true" || false, simulateTouch: sliderMarkup.getAttribute("data-simulate-touch") && !isNoviBuilder ? sliderMarkup.getAttribute("data-simulate-touch") === "true" : false, watchOverflow: true, }; if (sliderMarkup.getAttribute("data-autoplay")) { options.autoplay = { delay: 3000, stopOnLastSlide: false, disableOnInteraction: true, reverseDirection: false, }; } if (sliderMarkup.getAttribute("data-keyboard") === "true") { options.keyboard = { enabled: sliderMarkup.getAttribute("data-keyboard") === "true", onlyInViewport: true, }; } if (sliderMarkup.getAttribute("data-mousewheel") === "true") { options.mousewheel = { releaseOnEdges: true, sensitivity: 0.1, }; } if ( sliderMarkup.querySelector(".swiper-button-next, .swiper-button-prev") ) { options.navigation = { nextEl: ".swiper-button-next", prevEl: ".swiper-button-prev", }; } if (sliderMarkup.querySelector(".swiper-pagination")) { options.pagination = { el: ".swiper-pagination", type: "bullets", clickable: true, }; } if (sliderMarkup.querySelector(".swiper-scrollbar")) { options.scrollbar = { el: ".swiper-scrollbar", hide: true, draggable: true, }; } options.on = { init: function () { setBackgrounds(this); initCaptionAnimate(this); }, }; swiper = new Swiper(plugins.swiper[i], options); } } }); // haeder // 显示二级 $(".header_mid_mid ul li dl.navson dd").hover( function () { if ($(this).find("p").length > 0) { $(".header_mid_mid ul li dl.navson").addClass("b"); } }, function () { $(".header_mid_mid ul li dl.navson").removeClass("b"); } ); // 存在三级给二级加navson $('.header_mid_mid ul li p').parents('dl').first().addClass("navson"); $(".header_mid_mid ul li").hover( function () { if ($(this).find("dl").length > 0) { $(this).children("a.biga").addClass("bigaon"); $(this).children("dl").stop(false, false).show(); $(".menubg").show(); } }, function () { $(this).children("a.biga").removeClass("bigaon"); $(this).children("dl").stop(false, false).hide(); $(".menubg").hide(); } ); $(".navigate ul li a.mobile_alink").click(function () { $(this).parent().siblings().find("dl").slideUp(); $(this).siblings().find("p").slideUp(); $(this).siblings().find("dd").removeClass("on"); $(this).parent().siblings().removeClass("on"); $(this).parent().find("dl").slideToggle(); $(this).parent().stop().toggleClass("on"); }); $(".mobilenav").click(function () { $(this).stop().toggleClass("has-menu"); $(".navmask,.navigate").toggleClass("show"); $(".header_mid_right a,#header .header_mid_left a").toggleClass("wh"); $("body").toggleClass("ovh"); }); $(".navmask").click(function () { $(".menubtn").removeClass("active"); $(".navigate").removeClass("show"); $(".mobilenav").removeClass("has-menu"); $(".navmask").removeClass("show"); $(".header_mid_right a,#header .header_mid_left a").removeClass("wh"); $("body").removeClass("ovh"); }); $('.showsub').click(function () { $(this).parent().siblings().find("p").slideUp(); $(this).parent().siblings().removeClass("on"); $(this).parent().find("p").slideToggle(); $(this).parent().stop().toggleClass("on"); }); // haeder })();