(function($) { // 鍒ゆ柇鍏冪礌鏄惁瀛樺湪 $.fn.isexit = function() { if ($(this).length && $(this).length > 0) { return true; } return false; }; })(jQuery); $(document).ready(function() { // 绉诲姩绔鑸 $('.btn-menu').click(function() { $('body').toggleClass('open'); }) $('.mask').click(function() { $('body').removeClass('open'); }) $('.btn-search').click(function() { $('header').addClass('active'); $('.search').slideDown(); }) $('.search .btn-close').click(function() { $('header').removeClass('active'); $('.search').hide(); }) // 宸︿晶瀛愯彍鍗曟墜椋庣惔 if ($('.subnav').isexit()) { var topid = $('.subnav').attr('data-id'); $('#leftnav-'+topid).addClass('active'); var typeid = $('.subnav').attr('data-typeid'); $('#nav-'+typeid).addClass('active'); } $('.subnav .dropdown > a').click(function() { $(this).siblings('ul').slideToggle(); }) if ($('.owl-banner').isexit()) { // 棣栭〉骞荤伅鐗 $('.owl-banner .owl-carousel').owlCarousel({ items: 1, loop: true, autoplay: true, autoplayTimeout: 3000, autoplayHoverPause: true }); } if ($('.history').isexit()) { // 棣栭〉澶т簨璁 $('.history .owl-carousel').owlCarousel({ loop: true, responsiveClass: true, responsive: { 0: { items: 2, nav: true }, 768: { items: 3, nav: false }, 1200: { items: 5, nav: true, loop: false, margin: 20 } } }) } if ($('.article').isexit()) { // 鍐呭椤靛浘鐗囪嚜閫傚簲 $(".article img").each(function() { $(this).removeAttr("width"); $(this).removeAttr("height"); }); } if ($('.article video').isexit()) { $('.article video').attr('poster', $('.article').attr('data-poster')); } if ($('#timeline').isexit()) { // 鍐呴〉澶т簨璁 $().timelinr({ arrowKeys: 'true', startAt: 2 }) } $(window).scroll(function(e) { var scrollTop = $(window).scrollTop(); if(scrollTop >= 10) { $('body').removeClass('open'); } //杩斿洖椤堕儴鎸夐挳 鏄剧ず/闅愯棌 if(scrollTop >= 100) { $('.backtop').show(); } else { $('.backtop').hide(); } }) $('.backtop').click(function(){ $("html,body").animate({scrollTop:0}, 300); }) })