PageSourceSearch

https://www.nudt.edu.cn/press/js/script.js

js nudt.edu.cn collected 2026-10-02 10:18:56 UTC 22,755 bytes, 634 lines download raw bytes

1Nav('#nav') //导航
2mobileMenu('#gp-menu'); //移动端导航
3SerMax('#gp-serBtn4', '#gp-search4', '.serachClose');
4SerMax('#searchBtn5', '#gp-search5');
5asideMenu('#gp-subLeft');
6mobileAsideMenu('#gp-m-subNav')
7// HeaderFix()  //头部固定
8if (isTouchDevice()) {
9    $('body').removeClass('desktop').addClass('mobile')
10    mobileDivSelect()
11} else {
12    $('body').addClass('desktop').removeClass('mobile')
13    desktopDivSelect()
14}
15/*
16下拉菜单 
17例调用:Nav('#nav');
18*/
19function Nav(id) {
20    var oNav = $(id);
21    var aLi = oNav.find('li');
22    var aLia = oNav.find('li >a');
23    aLi.hover(function () {
24        $(this).addClass('on');
25    }, function () {
26        $(this).removeClass('on');
27    })
28    aLia.hover(function () {
29        $(this).addClass('on');
30    }, function () {
31        $(this).removeClass('on');
32    })
33};
34/*
35搜索点击弹出效果 
36例调用:SerMax('#gp-serBtn2','#gp-search2');
37*/
38function SerMax(id, main, close) {
39    var serBtn = $(id);
40    var wrapSer = $(main);
41    serBtn.click(function () {
42        $(this).filter('#gp-serBtn2').fadeOut(300);
43        $(this).filter('#gp-serBtn3').toggleClass('active');
44        $(this).filter('#gp-serBtn3').toggleClass('icon-sousuo', 'icon-')
45        if ($(main).hasClass('no-overlay')) {
46            wrapSer.toggleClass('active');
47        } else {
48            serFun()
49        }
50
51    })
52    $(close).click(function () {
53        serFun()
54    })
55
56    function serFun() {
57        console.log(1)
58        wrapSer.toggleClass('active');
59        if ($(wrapSer).hasClass('active')) {
60            $('body').addClass('searchActive');
61            $('.gp-overlay').fadeIn(300)
62        } else {
63            wrapSer.removeClass('active');
64            $('.gp-overlay').fadeOut(300)
65            $('body').removeClass('searchActive');
66        }
67    }
68
69    //点击空白处隐藏弹出层,下面为滑动消失效果和淡出消失效果。
70    //  $(document).click(function(event){
71    // 	 var _con1 = serBtn  // 设置目标区域
72    // 	 var _con2 = wrapSer;  // 设置目标区域
73    // 	 if(!_con1.is(event.target) && _con1.has(event.target).length === 0 && !_con2.is(event.target) && _con2.has(event.target).length === 0){
74    //     wrapSer.removeClass('active')
75    //     $('body').removeClass('searchActive')
76    //     serBtn.delay(300).fadeIn(300)
77    // 	 }
78    // });
79}
80
81
82/*
83移动端主导航 
84例调用:mobileMenu('#gp-menu');
85*/
86function mobileMenu(id) {
87    var oMenu = $(id);
88    oMenu.find(".gp-menu-header .gp-menu-header-icon").click(function () {
89        oMenu.find(this).toggleClass("gp-menu-header-icon-click gp-menu-header-icon-out");
90        $('.mobile_bg').fadeToggle(300)
91        oMenu.find(".gp-menu-nav").filter('.gp-menu-dropdown1').slideToggle(300); //下拉竖排
92        oMenu.find(".gp-menu-nav").filter('.gp-menu-dropdown2').slideToggle(300); //下拉横排
93        oMenu.find(".gp-menu-nav").filter('.gp-menu-dropdown2').find('ul:first').children('li').find('a.iconfont').attr('href', 'javascript:void(0)')
94        // oMenu.find(".gp-menu-nav").filter('.gp-menu-offcanvas1').slideToggle(300);//下拉横排
95        $('body').toggleClass('open')
96    });
97    $('.mobile_bg').click(function () {
98        oMenu.find('.gp-menu-header-icon').toggleClass("gp-menu-header-icon-click gp-menu-header-icon-out");
99        oMenu.find(".gp-menu-nav").filter('.gp-menu-dropdown1,.gp-menu-dropdown2').slideToggle(300);
100        $(this).fadeToggle(300)
101        $('body').removeClass('open');
102    })
103    // oMenu.find(".gp-menu-nav > ul > li").each(function( index ) {
104    //   var len = oMenu.find(".gp-menu-nav > ul > li").length;
105    // 	$( this ).css({'transition-delay': (index/len)+0.5+'s'});
106    // });
107    oMenu.find(".gp-menu-nav li > ul").each(function () {
108        var $this = $(this);
109        $this.find('li').each(function (index) {
110            var len = $this.find('li').length;
111            $(this).css({
112                'animation-delay': (index / len) + 's'
113            });
114        })
115    });
116    oMenu.find('.gp-menu-nav li .gp-menu-arrow').click(function () {
117        if ($(this).parent('li').hasClass('on')) {
118            $(this).next('ul').slideUp(500)
119            $(this).parent('li').removeClass('on')
120        } else {
121            $(this).next('ul').slideDown(500);
122            $(this).parent().siblings().find('ul').slideUp(500)
123            $(this).parent().siblings().removeClass('on')
124            $(this).parent('li').addClass('on')
125        }
126    })
127    oMenu.find('.gp-menu-nav').filter('.gp-menu-dropdown2').find('a.icon-down').click(function () {
128        if ($(this).parent('li').hasClass('on')) {
129            $(this).next('ul').slideUp(500)
130            $(this).parent('li').removeClass('on')
131        } else {
132            $(this).next('ul').slideDown(500);
133            $(this).parent().siblings().find('ul').slideUp(500)
134            $(this).parent().siblings().removeClass('on')
135            $(this).parent('li').addClass('on')
136        }
137    })
138
139}
140
141
142
143/*
144tab切换
145例调用:$(".tab").tab({ev : 'mouseover',more : false,auto : false});
146*/
147;
148(function ($) {
149    $.fn.extend({
150        tab: function (options) {
151            var defaults = { //默认参数
152                ev: 'mouseover', //默认事件'mouseover','click'
153                delay: 100, //延迟时间
154                auto: true, //是否自动切换 true,false
155                speed: 2000, //自动切换间隔时间(毫秒)
156                more: false //是否有more,false,true
157            };
158            var options = $.extend(defaults, options); //用户设置参数覆盖默认参数
159            return this.each(function () {
160                var o = options;
161                var obj = $(this);
162                var oTil = obj.find('.til_tab');
163                var oBox = obj.find('.tabListBox');
164                var oMore = null;
165                var iNum = 0;
166                var iLen = oTil.length;
167                obj.find('.til_tab').eq(0).addClass('on')
168                obj.find('.tabListBox').eq(0).css('display', 'block')
169                obj.find('.more_tab').eq(0).css('display', 'block')
170                //鼠标事件绑定
171                oTil.bind(o.ev, function () {
172                    var _this = this;
173                    if (o.ev == 'mouseover' && o.delay) {
174                        _this.timer = setTimeout(function () {
175                            change(_this);
176                        }, o.delay);
177                    } else {
178                        change(_this);
179                    };
180                })
181
182                oTil.bind('mouseout', function () {
183                    var _this = this;
184                    clearTimeout(_this.timer);
185                });
186
187                //自动切换效果
188                (function autoPlay() {
189                    var timer2 = null;
190                    if (o.auto) {
191                        function play() {
192                            iNum++;
193                            if (iNum >= iLen) {
194                                iNum = 0;
195                            };
196                            change(oTil.eq(iNum));
197                        };
198                        timer2 = setInterval(play, o.speed);
199
200                        obj.on('mouseover', function () {
201                            clearInterval(timer2);
202                        })
203
204                        obj.on('mouseout', function () {
205                            timer2 = setInterval(play, o.speed);
206                        })
207                    };
208                })();
209
210                function change(box) {
211                    iNum = $(box).index();
212                    oTil.removeClass('on');
213                    oBox.css('display', 'none');
214                    if (o.more) {
215                        oMore = obj.find('.more_tab');
216                        oMore.css('display', 'none');
217                        oMore.eq(iNum).css('display', 'block');
218                    };
219                    oTil.eq(iNum).addClass('on');
220                    oBox.eq(iNum).css('display', 'block');
221
222                }
223            });
224        },
225        tab2: function (options) {
226            var defaults = { //默认参数
227                ev: 'mouseover', //默认事件'mouseover','click'
228                delay: 200, //延迟时间
229                auto: true, //是否自动切换 true,false
230                speed: 2000, //自动切换间隔时间(毫秒)
231                more: false //是否有more,false,true
232            };
233            var options = $.extend(defaults, options); //用户设置参数覆盖默认参数
234            return this.each(function () {
235                var o = options;
236                var obj = $(this);
237                var oTil = obj.find('.til_tab');
238                var oBox = obj.find('.tabListBox');
239                var oMore = null;
240                var iNum = 0;
241                var iLen = oTil.length;
242                obj.find('.til_tab').eq(0).addClass('on')
243                obj.find('.tabListBox').eq(0).addClass('show')
244                obj.find('.more_tab').eq(0).css('display', 'block')
245                //鼠标事件绑定
246                oTil.bind(o.ev, function () {
247                    var _this = this;
248                    if (o.ev == 'mouseover' && o.delay) {
249                        _this.timer = setTimeout(function () {
250                            change(_this);
251                        }, o.delay);
252                    } else {
253                        change(_this);
254                    };
255                })
256
257                oTil.bind('mouseout', function () {
258                    var _this = this;
259                    clearTimeout(_this.timer);
260                });
261
262                //自动切换效果
263                (function autoPlay() {
264                    var timer2 = null;
265                    if (o.auto) {
266                        function play() {
267                            iNum++;
268                            if (iNum >= iLen) {
269                                iNum = 0;
270                            };
271                            change(oTil.eq(iNum));
272                        };
273                        timer2 = setInterval(play, o.speed);
274
275                        obj.on('mouseover', function () {
276                            clearInterval(timer2);
277                        })
278
279                        obj.on('mouseout', function () {
280                            timer2 = setInterval(play, o.speed);
281                        })
282                    };
283                })();
284
285                function change(box) {
286                    iNum = $(box).index();
287                    oTil.removeClass('on');
288                    oBox.addClass('hide').removeClass('show')
289                    if (o.more) {
290                        oMore = obj.find('.more_tab');
291                        oMore.css('display', 'none');
292                        oMore.eq(iNum).css('display', 'block');
293                    };
294                    console.log(iNum);
295                    oTil.eq(iNum).addClass('on');
296                    oBox.eq(iNum).addClass('show').removeClass('hide')
297                    // $('.tabList4').find('.slick-slider').eq(iNum).slick('slickNext',1)
298                }
299            });
300        }
301    })
302})(jQuery);
303
304/*
305返回顶部
306*/
307$(window).scroll(function () {
308    var docHeight = $(document).height()
309    var winHeight = $(window).height();
310    var scrollTop = $(window).scrollTop();
311    if (scrollTop > 200) {
312        $('.gp-goTop').fadeIn(500)
313    } else {
314        $('.gp-goTop').fadeOut(500)
315    }
316    if (scrollTop >= docHeight - winHeight) {
317        $('.gp-goTop-fixed').addClass('bottom')
318    } else {
319        $('.gp-goTop-fixed').removeClass('bottom')
320    }
321})
322$('.gp-goTop').click(function () {
323    $('body,html').stop().animate({
324        scrollTop: 0
325    });
326    return false;
327});
328
329/*
330侧边栏三级
331例调用: asideMenu('#gp-subLeft')
332*/
333function asideMenu(menu) {
334    //当前状态高亮
335    $(menu).find('.active').each(function () {
336        if ($(this).parents('dl').hasClass('gp-second-nav')) {
337            $(this).parents('dl').css('display', 'block');
338            $(this).parents('li').addClass('active')
339            $(this).parents('li').find('.gp-toggles').addClass('icon-down').removeClass('icon-you');
340            $(this).parents('.gp-subNavs').css('padding-bottom', '43px')
341        }
342    })
343    $(menu).find('.gp-toggles').click(function () {
344        if ($(this).parents('li').hasClass('active')) {
345            $(this).addClass('icon-you').removeClass('icon-down')
346            $(this).next('.gp-second-nav').slideUp(500)
347            $(this).parents('li').removeClass('active')
348            $(this).parents('.gp-subNavs').css('padding-bottom', '0')
349        } else {
350            $(this).addClass('icon-down').removeClass('icon-you');
351            $(this).next('.gp-second-nav').slideDown(500);
352            $(this).parents('li').siblings().find('.gp-second-nav').slideUp(500)
353            $(this).parents('li').siblings().removeClass('active')
354            $(this).parents('li').siblings().find('.gp-toggles').addClass('icon-you').removeClass('icon-down')
355            $(this).parents('li').addClass('active')
356            $(this).parents('.gp-subNavs').css('padding-bottom', '43px')
357        }
358    })
359}
360
361
362//移动端侧边栏菜单
363function mobileAsideMenu(menu, main) {
364    $(menu).find('.gp-m-inner-header').click(function () {
365        $(this).toggleClass("gp-m-inner-header-icon-click gp-m-inner-header-icon-out");
366        $(this).find('.iconfont').toggleClass("icon-up icon-down")
367        $(".gp-subNavm").slideToggle(500);
368
369    });
370    $('.gp-subNavm').find('.gp-m-toggle').click(function () {
371        if ($(this).parents('li').hasClass('active')) {
372            $(this).addClass('icon-right').removeClass('icon-down')
373            $(this).next('dl').slideUp(500)
374            $(this).parents('li').removeClass('active')
375        } else {
376            $(this).addClass('icon-down').removeClass('icon-right');
377            $(this).next('dl').slideDown(500);
378            $(this).parents('li').siblings().find('dl').slideUp(500)
379            $(this).parents('li').siblings().removeClass('active')
380            $(this).parents('li').siblings().find('.gp-m-toggle').addClass('icon-right').removeClass('icon-down')
381            $(this).parents('li').addClass('active')
382        }
383    })
384};
385//首页头部置顶固定
386function HeaderFix() {
387    var iWSon = document.documentElement.clientWidth;
388    var $windowHeight = $(window).height();
389    var bodyHeight = $(document.body).height();
390    var $headerHeight = $('header').height() - 60;
391    $(window).scroll(function () {
392        var scrollTop = $(window).scrollTop();
393        if (scrollTop >= 40 && bodyHeight > $windowHeight + $headerHeight * 2) {
394            if (iWSon > 1020) {
395                $('header,body').addClass('currents');
396            } else {
397                $('header,body').removeClass('currents');
398            }
399        } else {
400            $('header,body').removeClass('currents');
401        }
402    })
403}
404
405$(window).scroll(function () {
406    $(".effect2").each(function (index, element) {
407        var e = $(this);
408        var f = 9;
409        if (!f && f != 0) {
410            f = $(window).height() * 6 * 0.1;
411        } else {
412            f = $(window).height() * f * 0.1;
413        }
414        if ($(window).scrollTop() >= $(e).offset().top - f) {
415            if (!$(e).hasClass("isView")) {
416                $(e).addClass("isView");
417
418            }
419        } else {
420            if ($(e).hasClass("isView")) {
421                $(e).removeClass("isView");
422            }
423        }
424    });
425});
426
427// 鼠标滚动渐渐出现
428$('.effect1,.effect2,.effect3,.effect4').each(function () {
429	$(this).find("li").each(function (index) {
430		var len = $(this).parent().find("li").length;
431		$(this).css({ 'transition-delay': (index * 0.5 / len) + 's' });
432	})
433});
434function enterEffects() {
435	var sWSon = document.documentElement.clientWidth;
436	if (sWSon >= 992) {
437		$(".effect").each(function (index, element) {
438			var e = $(this);
439			var c = $(window).height();
440			if ($(window).scrollTop() >= $(e).offset().top - 0.9 * c) {
441				$(e).addClass("isView");
442			} else {
443				$(e).removeClass("isView");
444			}
445		});
446	}
447}
448
449/*
450top置顶
451*/
452$(window).scroll(function () {
453    var docHeight = $(document).height()
454    var winHeight = $(window).height();
455    var scrollTop = $(window).scrollTop();
456    if (scrollTop >= 165) {
457        $('.gp-goTop').fadeIn(500)
458    } else {
459        $('.gp-goTop').fadeOut(500)
460    }
461    if (scrollTop >= docHeight - winHeight) {
462        $('.gp-goTop-fixed').addClass('bottom')
463    } else {
464        $('.gp-goTop-fixed').removeClass('bottom')
465    }
466})
467// var goTopHtml = '<a href="javascript:void(0)" class="gp-goTop gp-goTop-fixed iconfont icon-up"></a>'
468// $(goTopHtml).insertAfter('footer')
469$('.gp-goTop').click(function () {
470    $('body,html').stop().animate({
471        scrollTop: 0
472    });
473    return false;
474});
475
476function isTouchDevice() {
477    return 'ontouchstart' in document.documentElement;
478}
479
480function desktopDivSelect() {
481    $('.divSelect').hover(function (event) {
482        //取消事件冒泡 
483        $(this).find('ul').stop().slideToggle(300);
484        $(this).toggleClass('active');
485        return false;
486    }, function () {
487        $(this).find('ul').stop().slideUp(300);
488        $(this).removeClass('active');
489        return false;
490    });
491}
492
493function mobileDivSelect() {
494    $('.divSelect').find('cite').click(function (event) {
495        //取消事件冒泡 
496        event.stopPropagation('active');
497        $('.divSelect2').find('ul').slideUp(300);
498        $('.divSelect2').removeClass('active');
499        if ($(this).parents('.divSelect2').hasClass('active')) {
500            $(this).next('ul').slideUp(300);
501            $(this).parents('.divSelect2').removeClass('active');
502        } else {
503            $(this).next('ul').slideDown(300);
504            $(this).parents('.divSelect2').addClass('active');
505        }
506        return false;
507    });
508}
509
510
511
512//点击空白处隐藏弹出层,下面为滑动消失效果和淡出消失效果。
513$(document).click(function (event) {
514    var _con = $('.divSelect'); // 设置目标区域
515    if (!_con.is(event.target) && _con.has(event.target).length === 0) {
516        //$('#divTop').slideUp('slow');  //滑动消失
517        $('.divSelect').find('.linkList02').slideUp(300); //淡出消失
518        $('.divSelect').removeClass('active')
519    }
520});
521
522
523
524$(window).resize(function () {
525    var resizeTimer = null;
526    if (resizeTimer) clearTimeout(resizeTimer);
527    resizeTimer = setTimeout(function () {}, 100);
528})
529
530function directionNav() {
531    $('.slick-arrow').each(function (e) {
532        var $this = $(this)
533        $this.text('');
534        $(this).addClass('iconfont')
535        if ($this.hasClass('slick-prev')) {
536            $(this).addClass('icon-left')
537        } else if ($this.hasClass('slick-next')) {
538            $(this).addClass('icon-right')
539        }
540    })
541}
542var maodian = function (id) {
543    var target_top = $("#" + id).offset().top - 60;
544    $("html,body").animate({
545        scrollTop: target_top
546    }, 1000); //带滑动效果的跳转
547}
548
549function asideFix() {
550    $(window).scroll(function () {
551        var scrollTop = $(window).scrollTop();
552        var asideHeight = $(".t-left").height()
553        var conHeight = $(".t-right").innerHeight();
554        var headerHeight = $('.xw-mode1').offset().top
555        var footerHeight = $('.wrap_footer').offset().top
556        var $ww = $(window).width()
557        conHeight2 = (conHeight + headerHeight) - asideHeight;
558        console.log(headerHeight)
559        if ($ww > 767) {
560            if (asideHeight < conHeight) {
561                if (scrollTop < headerHeight) {
562                    $('.t-left').removeClass('fixTop');
563                } else {
564                    $('.t-left').addClass('fixTop');
565                }
566                if (scrollTop > conHeight2) {
567                    $('.t-left').removeClass('fixTop');
568                    $('.t-left').addClass('fixBottom');
569                } else {
570                    $('.t-left').removeClass('fixBottom');
571                }
572            }
573        }
574        $('.t-left').find('li').click(function () {
575            $(this).addClass('active').siblings().removeClass('active')
576        })
577    })
578}
579
580function scrollActive(wrap, ele) {
581    if ($(wrap).length > 0) {
582        $(wrap).find(ele + ' > .active').each(function () {
583            var index = $(this).parent(ele).index();
584            var thisWidth = $(this).parent(ele)[0].offsetWidth
585            var distance = index * thisWidth;
586            var left = ($(wrap).scrollLeft() + distance);
587
588            $(wrap).scrollLeft(left)
589        })
590    }
591}
592if ($('.gp-subLeft').length > 0) {
593    scrollActive('.gp-subLeft', 'li')
594}
595// scrollActive('.gp-subLeft','li')
596// scrollActive('.phone-second-nav','dd')
597
598
599function slideToggle() {
600    $('.gf-list10 li').find('.gf_title').click(function () {
601        if ($(this).parents('li').hasClass('active')) {
602            $(this).find('.toggle2').addClass('icon-right').removeClass('icon-down');
603            $(this).next('dl').slideUp(500);
604            $(this).parents('li').removeClass('active')
605        } else {
606            $(this).find('.toggle2').addClass('icon-down').removeClass('icon-right');
607            $(this).next('dl').slideDown(500);
608            $(this).parents('li').siblings().find('dl').slideUp(500)
609            $(this).parents('li').siblings().removeClass('active')
610            $(this).parents('li').siblings().find('.toggle2').addClass('icon-right').removeClass('icon-down')
611            $(this).parents('li').addClass('active')
612        }
613
614    })
615}
616
617// 折叠展开逻辑
618document.querySelectorAll('.catalog-link').forEach(item => {
619    item.addEventListener('click', function(){
620        let parentLi = this.parentElement;
621        let subMenu = parentLi.querySelector('.sub-catalog');
622        let arrow = this.querySelector('.arrow');
623        if(subMenu){
624            subMenu.classList.toggle('show');
625            arrow.classList.toggle('open');
626        }
627    })
628
629    if( $(item).parent().hasClass('active') ){
630        $(item).find('.arrow').addClass('open');
631        $(item).parent().closest('.sub-catalog').addClass('show');
632    }
633})
634

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.