//瀵艰埅鏉″垏鎹㈠姩鐢 let $ = jQuery; $(function() { //瀵艰埅鏍忓姩鐢 navbarAnimation(); initNavbarLinePosition(); relacLayout(); window.onscroll = function(){ navbarScroll(); } }) function initNavbarLinePosition(){ $('.nav-box-pc ul li').each(function(index,ele){ if($(this).hasClass('current-menu-item')){ $('.nav-box-pc .nav-line').css({ 'width' : $(this).css("width"), 'left' : $(this).position().left + "px" }) $('.nav-box-pc .nav-line').css("visibility", "visible"); return false; } }) } function navbarAnimation(){ $('.nav-box-pc li').on('mouseenter',function(){ $('.nav-box-pc .nav-line').stop(true,true).animate({ 'width' : $(this).css("width"), 'left' : $(this).position().left + "px" }) }) $('.nav-box-pc li').on('mouseleave',function(){ $('.nav-box-pc li').each(function(index,element){ if($(this).hasClass('current_page_item')){ $('.nav-box-pc .nav-line').stop(true,true).animate({ 'width' : $(this).css("width"), 'left' : $(this).position().left + "px" }) return false; } }) }) $('.nav-box-pc li').on('click',function(){ $(this).addClass('active').siblings('li').removeClass('active'); }) } //瀵艰埅鏉¤窡闅忔粴鍔 function navbarScroll(){ var scrollTop = $(window).scrollTop(); if (scrollTop > 0) { $('.nav-header').addClass('on'); $('.estate-nav').addClass('on'); } else if (scrollTop === 0) { $('.nav-header').removeClass('on'); $('.estate-nav').removeClass('on'); } if (scrollTop > 643) { $('.estate-nav').addClass('fixed'); } else { $('.estate-nav').removeClass('fixed'); } } function initSideNavbar(){ $('.nav-bar').onePageNav({ currentClass: 'current', changeHash: false, scrollSpeed: 750, scrollThreshold: 0.1, }); } function sideNavbarScroll($box){ var scrollTop = $(window).scrollTop(); var windowWidth = window.innerWidth; //渚ц竟瀵艰埅鏉 if (scrollTop >= $box.offset().top && windowWidth > 1200) { $('.side-nav-bar-wrapper').fadeIn(); } else { $('.side-nav-bar-wrapper').fadeOut(); } } // a閾炬帴婊氬姩鍔ㄧ敾 /* $(".banner-wrapper ul li a").click(function () { $("html, body").stop(true,true).animate({scrollTop: $($(this).attr("href")).offset().top + "px"}, 500); return false;//涓嶈杩欏彞浼氭湁鐐瑰崱椤 }); */ function dateFormat (date, format) { date = new Date(date); date.setHours(date.getHours()); var o = { 'M+' : date.getMonth() + 1, //month 'd+' : date.getDate(), //day 'H+' : date.getHours(), //hour 'm+' : date.getMinutes(), //minute 's+' : date.getSeconds(), //second 'q+' : Math.floor((date.getMonth() + 3) / 3), //quarter 'S' : date.getMilliseconds() //millisecond }; if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp('(' + k + ')').test(format)) format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)); return format; } function relacLayout(){ $('#nav').on('click',function(){ $(this).css('display','none'); $('.nav-box-wap').fadeIn(); $('.nav-box-wap .close-btn').on('click',function(){ $('.nav-box-wap').fadeOut('normal',function(){ $('#nav').fadeIn(); }); }) }) $('.nav-wap-list-box > ul > li .svg-icon').on('click',function(){ var $parentLi = $(this).parent('li'); if($parentLi.hasClass('expand')){ $parentLi.removeClass('expand'); }else{ $(this).parent('li').addClass('expand').siblings('li').removeClass('expand'); } }) }