/*var winWidth = document.documentElement.clientWidth; if(winWidth <= 996){ $('body').removeClass('desktop').addClass('mobile') }else{ $('body').addClass('desktop').removeClass('mobile') } */ function isTouchDevice() { return 'ontouchstart' in document.documentElement; } if (isTouchDevice()) { $('body').removeClass('desktop').addClass('mobile') }else { $('body').addClass('desktop').removeClass('mobile') } /* 下拉菜单 例调用:Nav('#nav'); */ function Nav(id){ var oNav = $(id); var aLi = oNav.find('li'); aLi.hover(function (){ $(this).addClass('on'); },function (){ $(this).removeClass('on'); }) }; /* 搜索点击弹出效果 例调用:SerMax('#gp-serBtn2','#gp-search2'); */ function SerMax(id,main){ var serBtn = $(id); var wrapSer = $(main); serBtn.click(function(){ $(this).filter('#gp-serBtn2').fadeOut(300); $(this).filter('#gp-serBtn3').toggleClass('active'); if($(main).hasClass('no-overlay')){ wrapSer.toggleClass('active'); }else{ serFun () } }) function serFun (){ wrapSer.toggleClass('active'); if($(wrapSer).hasClass('active')){ $('body').css('overflow','hidden').addClass('searchActive'); $('.gp-overlay').fadeIn(300) }else{ wrapSer.removeClass('active'); $('.gp-overlay').fadeOut(300) $('body').css('overflow','auto').removeClass('searchActive'); } } $('.gp-overlay').click(function(){ serFun () }) //点击空白处隐藏弹出层,下面为滑动消失效果和淡出消失效果。 $(document).click(function(event){ var _con1 = serBtn // 设置目标区域 var _con2 = wrapSer; // 设置目标区域 if(!_con1.is(event.target) && _con1.has(event.target).length === 0 && !_con2.is(event.target) && _con2.has(event.target).length === 0){ wrapSer.removeClass('active') serBtn.delay(300).fadeIn(300) } }); } /* 移动端主导航 例调用:mobileMenu('#gp-menu'); */ function mobileMenu(id){ var oMenu = $(id); oMenu.find(".gp-menu-header .gp-menu-header-icon").click(function(){ oMenu.find(this).toggleClass("gp-menu-header-icon-click gp-menu-header-icon-out"); $('.mobile_bg').fadeToggle(300) oMenu.find(".gp-menu-nav").filter('.gp-menu-dropdown1').slideToggle(300);//下拉竖排 oMenu.find(".gp-menu-nav").filter('.gp-menu-dropdown2').slideToggle(300);//下拉横排 oMenu.find(".gp-menu-nav").filter('.gp-menu-dropdown2').find('ul:first').children('li').find('a.iconfont').attr('href','javascript:void(0)') // oMenu.find(".gp-menu-nav").filter('.gp-menu-offcanvas1').slideToggle(300);//下拉横排 oMenu.toggleClass('open'); $('.gp-logo').toggleClass('open') }); $('.mobile_bg').click(function(){ oMenu.find('.gp-menu-header-icon').toggleClass("gp-menu-header-icon-click gp-menu-header-icon-out"); oMenu.find(".gp-menu-nav").filter('.gp-menu-dropdown1,.gp-menu-dropdown2').slideToggle(300); $(this).fadeToggle(300) oMenu.removeClass('open'); $('.gp-logo').removeClass('open') }) oMenu.find(".gp-menu-nav > ul > li").each(function( index ) { var len = oMenu.find(".gp-menu-nav > ul > li").length; $( this ).css({'animation-delay': (index/len)+'s'}); }); oMenu.find(".gp-menu-nav li > ul").each(function() { var $this = $(this); $this.find('li').each(function(index){ var len = $this.find('li').length; $(this).css({'animation-delay': (index/len)+'s'}); }) }); oMenu.find('.gp-menu-nav li .gp-menu-arrow').click(function(){ if($(this).parent('li').hasClass('on')){ $(this).next('ul').slideUp(500) $(this).parent('li').removeClass('on') }else{ $(this).next('ul').slideDown(500); $(this).parent().siblings().find('ul').slideUp(500) $(this).parent().siblings().removeClass('on') $(this).parent('li').addClass('on') } }) oMenu.find('.gp-menu-nav').filter('.gp-menu-dropdown2').find('a.icon-down').click(function(){ if($(this).parent('li').hasClass('on')){ $(this).next('ul').slideUp(500) $(this).parent('li').removeClass('on') }else{ $(this).next('ul').slideDown(500); $(this).parent().siblings().find('ul').slideUp(500) $(this).parent().siblings().removeClass('on') $(this).parent('li').addClass('on') } }) } /* tab切换 例调用:$(".tab").tab({ev : 'mouseover',more : false,auto : false}); */ /* tab切换 例调用:$(".tab").tab2({ev : 'mouseover',more : false,auto : false}); */ ;(function($){ $.fn.extend({ tab: function (options){ var defaults = { //默认参数 ev : 'mouseover', //默认事件'mouseover','click' delay : 100, //延迟时间 auto : true, //是否自动切换 true,false speed : 2000, //自动切换间隔时间(毫秒) more : false //是否有more,false,true }; var options = $.extend(defaults, options); //用户设置参数覆盖默认参数 return this.each(function (){ var o = options; var obj = $(this); var oTil = obj.find('.til_tab'); var oBox = obj.find('.tabListBox'); var oMore = null; var iNum = 0; var iLen = oTil.length; obj.find('.til_tab').eq(0).addClass('on') obj.find('.tabListBox').eq(0).css('display','block').siblings().css('display','none') obj.find('.more_tab').eq(0).css('display','block') //鼠标事件绑定 oTil.bind(o.ev , function (){ var _this = this; if(o.ev == 'mouseover' && o.delay){ _this.timer = setTimeout(function (){ change(_this); },o.delay); }else{ change(_this); }; }) oTil.bind('mouseout',function (){ var _this = this; clearTimeout(_this.timer); }); //自动切换效果 (function autoPlay(){ var timer2 = null; if(o.auto){ function play(){ iNum++; if(iNum >= iLen){ iNum =0; }; change(oTil.eq(iNum)); }; timer2 = setInterval(play,o.speed); obj.on('mouseover',function (){ clearInterval(timer2); }) obj.on('mouseout',function (){ timer2 = setInterval(play,o.speed); }) }; })(); function change(box){ iNum = $(box).index(); oTil.removeClass('on'); oBox.css('display','none'); if(o.more){ oMore = obj.find('.more_tab'); oMore.css('display','none'); oMore.eq(iNum).css('display','block'); }; oTil.eq(iNum).addClass('on'); oBox.eq(iNum).css('display','block'); if(oBox.find('.gpCarousel')){ //console.log( iNum,$('.gpTabListBox').eq(iNum).children('div').children('.gpCarousel')) //oBox.eq(iNum).children('div').children('.gpCarousel').slick("refresh"); //oBox.eq(iNum).children('div').children('.gpCarousel').slick("refresh"); oBox.eq(iNum).children('div').children('.gpCarousel').children('button.slick-next').trigger("click"); //$('.gpCarousel')[iNum].slick('refresh'); } if(oBox.eq(iNum).find('.gpCarouseLinkage')){ //oBox.eq(iNum).find('.gpCarouseLinkage.slider-for').slick("refresh"); //oBox.eq(iNum).find('.gpCarouseLinkage.slider-nav').slick("refresh"); } } }); }, tab2: function (options){ var defaults = { //默认参数 ev : 'mouseover', //默认事件'mouseover','click' delay : 200, //延迟时间 auto : true, //是否自动切换 true,false speed : 2000, //自动切换间隔时间(毫秒) more : false //是否有more,false,true }; var options = $.extend(defaults, options); //用户设置参数覆盖默认参数 return this.each(function (){ var o = options; var obj = $(this); var oTil = obj.find('.til_tab'); var oBox = obj.find('.tabListBox'); var oMore = null; var iNum = 0; var iLen = oTil.length; obj.find('.til_tab').eq(0).addClass('on') obj.find('.tabListBox').eq(0).addClass('show') obj.find('.more_tab').eq(0).css('display','block') //鼠标事件绑定 oTil.bind(o.ev , function (){ var _this = this; if(o.ev == 'mouseover' && o.delay){ _this.timer = setTimeout(function (){ change(_this); },o.delay); }else{ change(_this); }; }) oTil.bind('mouseout',function (){ var _this = this; clearTimeout(_this.timer); }); //自动切换效果 (function autoPlay(){ var timer2 = null; if(o.auto){ function play(){ iNum++; if(iNum >= iLen){ iNum =0; }; change(oTil.eq(iNum)); }; timer2 = setInterval(play,o.speed); obj.on('mouseover',function (){ clearInterval(timer2); }) obj.on('mouseout',function (){ timer2 = setInterval(play,o.speed); }) }; })(); function change(box){ iNum = $(box).index(); oTil.removeClass('on'); oBox.addClass('hide').removeClass('show') if(o.more){ oMore = obj.find('.more_tab'); oMore.css('display','none'); oMore.eq(iNum).css('display','block'); }; oTil.eq(iNum).addClass('on'); oBox.eq(iNum).addClass('show').removeClass('hide') // $('.tabList4').find('.slick-slider').eq(iNum).slick('slickNext',1) } }); } }) })(jQuery); /* 返回顶部 */ $(window).scroll(function(){ var docHeight = $(document).height() var winHeight = $(window).height(); var scrollTop = $(window).scrollTop(); if(scrollTop >= 165){ $('.gp-goTop').fadeIn(500) }else{ $('.gp-goTop').fadeOut(500) } if(scrollTop >= docHeight - winHeight){ $('.gp-goTop-fixed').addClass('bottom') }else{ $('.gp-goTop-fixed').removeClass('bottom') } }) // var goTopHtml = '' // $(goTopHtml).insertAfter('footer') $('.gp-goTop').click(function(){ $('body,html').stop().animate({scrollTop:0}); return false; }); /* 奇数偶数不同的样式 例调用: odd= {"background":"#fff","color":"#666"};//奇数样式 even={"background":"#f7f7f5","color":"#666"};//偶数样式 单个元素: odd_even('.list',odd,even,'tr'); 多个元素: odd= {"background":"#fff","color":"#666"};//奇数样式 even={"background":"#f7f7f5","color":"#666"};//偶数样式 $('.list').each(function(){ odd_even($(this),odd,even,'tr'); }) */ function odd_even(id,odd,even,className){ $(id).find(className).each(function(index,element){ if(index % 2 == 1){ $(this).css(odd); $(this).addClass('odd'); } else{ $(this).css(even); $(this).addClass('even'); } }); } /* 侧边栏三级 例调用: asideMenu('#gp-subLeft') */ function asideMenu(menu){ //当前状态高亮 $(menu).find('.active').each(function(){ if($(this).parents('dl').hasClass('gp-second-nav')){ $(this).parents('dl').css('display','block'); $(this).parents('li').addClass('active') $(this).parents('li').find('.gp-toggles').addClass('icon-down').removeClass('icon-right'); } }) $(menu).find('.gp-toggles').click(function(){ if($(this).parents('li').hasClass('active')){ $(this).addClass('icon-right').removeClass('icon-down') $(this).next('.gp-second-nav').slideUp(500) $(this).parents('li').removeClass('active') }else{ $(this).addClass('icon-down').removeClass('icon-right'); $(this).next('.gp-second-nav').slideDown(500); $(this).parents('li').siblings().find('.gp-second-nav').slideUp(500) $(this).parents('li').siblings().removeClass('active') $(this).parents('li').siblings().find('.gp-toggles').addClass('icon-right').removeClass('icon-down') $(this).parents('li').addClass('active') } }) } //移动端侧边栏菜单 function mobileAsideMenu(menu,main){ var winWidth = document.documentElement.clientWidth; if(winWidth <= 996){ //移动端 $(menu).find('.gp-m-inner-header').click(function(){ $(this).find('.gp-m-inner-header-icon').toggleClass("gp-m-inner-header-icon-click gp-m-inner-header-icon-out"); $(this).find('.iconfont').toggleClass("icon-jia icon-jian") $(menu).find("ul").slideToggle(500); }); }else{ $('body').addClass('desktop').removeClass('mobile') } // $('.gp-subNavm').find('.gp-m-toggle').click(function(){ // if($(this).parents('li').hasClass('active')){ // $(this).addClass('icon-right').removeClass('icon-down') // $(this).next('dl').slideUp(500) // $(this).parents('li').removeClass('active') // }else{ // $(this).addClass('icon-down').removeClass('icon-right'); // $(this).next('dl').slideDown(500); // $(this).parents('li').siblings().find('dl').slideUp(500) // $(this).parents('li').siblings().removeClass('active') // $(this).parents('li').siblings().find('.gp-m-toggle').addClass('icon-right').removeClass('icon-down') // $(this).parents('li').addClass('active') // } // }) }; //头部置顶固定 function headerFix(){ var iWSon = document.documentElement.clientWidth; var $windowHeight = $(window).height(); var bodyHeight = $(document.body).height(); var $headerHeight = $('header').height(); $(window).scroll(function(){ var scrollTop = $(window).scrollTop(); if(scrollTop >= $headerHeight && bodyHeight > $windowHeight+$headerHeight*2){ if(iWSon > 1020){ $('header,body').addClass('currents'); $('body').css('padding-top',$headerHeight); }else{ $('header,body').removeClass('currents'); $('body').css('padding-top','0'); } }else{ $('header,body').removeClass('currents'); $('body').css('padding-top','0'); } }) } // 分页 $(function(){   $('.selectDiv').mouseenter(function() { $(this).children('ul').addClass('on') }) $('.selectDiv').mouseleave(function() { $(this).children('ul').removeClass('on') }) }); /* 显示今日日期,格式: 年-月-日 星期* 例调用:GetDate('#date'); */ function GetDate(id) { var date = new Date(); var year = date.getFullYear(); var mounth = date.getMonth() + 1; var day = date.getDate(); var week = "日一二三四五六".charAt(date.getDay()); $(id).text(year + "年" + mounth + "月" + day + "日 " + "星期" + week); } //点击空白处隐藏弹出层,下面为滑动消失效果和淡出消失效果。 $(document).click(function(event){ var _con = $('.gp-divSelect'); // 设置目标区域 if(!_con.is(event.target) && _con.has(event.target).length === 0){ //$('#divTop').slideUp('slow'); //滑动消失 $('.gp-divSelect').find('ul').slideUp(300); //淡出消失 $('.gp-divSelect').removeClass('active') } }); //电脑端模拟下拉框 function desktopDivSelect(main){ $(main).hover(function (event) { //取消事件冒泡 $(this).find('ul').stop().slideToggle(300); $(this).toggleClass('active'); return false; },function(){ $(this).find('ul').stop().slideUp(300); $(this).removeClass('active'); return false; }); } //移动端模拟下拉框 function mobileDivSelect(main){ $(main).find('cite').click(function (event) { //取消事件冒泡 event.stopPropagation(); $(main).find('ul').slideUp(300); $(main).removeClass('active'); if($(this).parents(main).hasClass('active')){ $(this).next('ul').slideUp(300); $(this).parents(main).removeClass('active'); }else{ $(this).next('ul').slideDown(300); $(this).parents(main).addClass('active'); } return false; }); } var gpAsideConf $(function() { for (var i in gpAsideConf) { var aDiv = $('.gp-subLeft').find('a'); aDiv.each(function(e) { if (gpAsideConf[i].show == 'false' && ($(this).attr('data-id') == gpAsideConf[i].id)) { $(this).parent().remove() $(this).next().remove(); $(this).next('dl').remove(); } }) } });var gpAsideConf = [{"name":"部门概况","show":false,"id":"727e6fecc1b046cdb6d5f9d0677736be"},{"name":"支部建设","show":false,"id":"1244964f4cdc45bab4a0ba408dd37a42"},{"name":"工程建设","show":false,"id":"dcbaa43f74b343a79f9f33a7bf81c96a"},{"name":"后勤服务","show":false,"id":"55718a09e5334f17a2dd6f52157f2eba"},{"name":"能源管理","show":false,"id":"f50d0f784f4c46a4aefea80c6f3c5581"},{"name":"规章制度","show":false,"id":"bd46b4d8710449db87d3e0f7424fcc5e"},{"name":"办事指南","show":false,"id":"512bee126e87491ea181ce8e8e1d029f"},{"name":"轮播大图","show":false,"id":"6fe8ada59540422ca67adab7452a0580"},{"name":"通知公告","show":false,"id":"1d8858f2002b49d7a4d7274329e4d498"},{"name":"常用服务","show":false,"id":"5749c9c2ffbc44c7bc856f383c5032d1"},{"name":"管理平台","show":false,"id":"cf9403460a8e4b3ab0d837b005b965a1"},{"name":"新闻资讯","show":false,"id":"23fa8c3f6b93425d8863d4ccc622a2da"},{"name":"风采","show":false,"id":"d0a241ae9e2640eaaa7aab07568d4a04"},{"name":"部门简介","show":false,"id":"f32bfc4167bd4e96b5724c7ee27b06c6"},{"name":"机构设置","show":false,"id":"4584bd744f134fabb138eee7adb4d98a"},{"name":"工作职责","show":false,"id":"8400bd1e8d9c44ca9e38ee42ea1ed92f"},{"name":"支部简介","show":false,"id":"cb2342d5c66e4d9c9eaee0125a5cc98d"},{"name":"支部活动","show":false,"id":"c8d67f7b332042779ddb514a5a20738c"},{"name":"校园规划","show":false,"id":"74a1904f70434e11b8f87c617823050c"},{"name":"竣工项目","show":false,"id":"aab4b902ce934c4a9d3aea131c4fde83"},{"name":"在施项目","show":false,"id":"1f787a4864b8419b96bff4dde4be6f5d"},{"name":"食堂服务","show":false,"id":"0751a421e02a417ca4dcea0efc670be7"},{"name":"班车运行","show":false,"id":"52465393ef38418d86d660f18193a0b6"},{"name":"物业服务","show":false,"id":"3b0e13f959924b789dbbd7cca2080bb6"},{"name":"校园绿化","show":false,"id":"9806b54c4e114004ac55a4ceecf502d0"},{"name":"节能宣传","show":false,"id":"c9ffa8527484431a899c30c3ec8f4e36"},{"name":"能源管理体系","show":false,"id":"e46a98ffeb7e4867827878760120b71f"},{"name":"能效公示","show":false,"id":"fb00fe6f3e8142f7b747a837b08414cc"},{"name":"上级制度","show":false,"id":"b1651afbc5534ab8ae6d2d0d7211af49"},{"name":"学校制度","show":false,"id":"72259cf3daac408dae00631f7a9506a9"},{"name":"部门制度","show":false,"id":"226070e1b7ea4fbcaf1e5d28cbc6181f"},{"name":"联系我们","show":false,"id":"4a512b2f0e6e4f6f991dc34fb968be04"},{"name":"办事流程","show":false,"id":"dd10c535ee3d40b7819d1b14ca2d1396"},{"name":"下载专区","show":false,"id":"2666507f56fc44d7b4c24ca8ff58b87c"},{"name":"临时侧栏文字列表页","show":false,"id":"4d848f24500f4ccd87df909801a58cac"},{"name":"临时侧栏简介页","show":false,"id":"9b42b9b43e464a2694761eb2c26dc932"},{"name":"临时栏目跳转子栏目","show":false,"id":"986de1acbf1346fdb9d203a34efc62ff"},{"name":"临时侧栏图片列表页","show":false,"id":"773bebed421c4a3994f3b1965be92d2e"},{"name":"临时通栏简介页","show":false,"id":"a4e2a7f3802e433a8534d49a6c09552d"},{"name":"临时通栏文字列表页","show":false,"id":"2c25b3c12a244b1b8a941e8d2f082063"},{"name":"临时通栏图片列表页","show":false,"id":"8599023490f74a78bd8f79d7e597ac54"},{"name":"临时侧栏文章页","show":false,"id":"555e0df702f449abae4cca24d879525c"},{"name":"临时通栏文章页","show":false,"id":"867e87ef6bd4476ea93aa593a48c9c0f"},{"name":"餐饮服务指南","show":false,"id":"60c8219123814b90ace7fa639ba0576d"},{"name":"公告公示","show":false,"id":"5a2a8e1b8f954a68a6acba2b268b8940"}];