$(function() { // hack 苏迪 tag with frag=面板n $("div[frag^='面板']").each(function(idx, el) { $(el).replaceWith($(el).html()); }); // hack 苏迪 tag with frag=窗口n $("div[frag^='窗口']").each(function(idx, el) { $(el).replaceWith($(el).html()); }); $("div[frag^='窗口内容']").each(function(idx, el) { $(el).replaceWith($(el).html()); }); $(window).ready(function() { $('.navlist>li').hover(function() { $(this).children('.nav-item-menu').slideDown(); }, function() { $(this).children('.nav-item-menu').stop(true, false).slideUp(); }) $('.mobile-navlist .nav-item>a').click(function() { if($(this).parent('.nav-item').hasClass('on')) { $(this).parent('.nav-item').removeClass('on'); } else { $(this).parent('.nav-item').addClass('on').siblings().removeClass('on'); } }) }) ////ie8 placeholder效果兼容 //$(document).ready(function() { // // val()无参数是取值,有参数是设置 // // 为了更好的兼容性,将下面的val()设置与input中的placeholder的值设置相同 // $("input.keywords").val("搜索...").css("color", "#d6d6d6"); // $("input.mobile-input-search").val("搜索...").css("color", "#666"); // textFill($('input.keywords')); // textFill($('input.mobile-input-search')); //}); function textFill(input) { var originalvalue = input.val(); input.focus(function() { if($.trim(input.val()) == originalvalue) { input.val(''); } }); input.blur(function() { if($.trim(input.val()) == '') { input.val(originalvalue); } }); } //手机版导航条 $('.nav-collapse').click(function() { $('.nav-mobile').stop(true, false).slideToggle('slow'); $('.bg-nav-mobilce').toggle(); if($('.box-mobile-form').css('display') == 'block') { $('.box-mobile-form').hide(); $('.bg-nav-mobilce2').hide(); } }) $('.bg-nav-mobilce').click(function() { $(this).hide(); $('.nav-mobile').slideUp(); $('.nav-collapse').parent('.box-icon').removeClass('open'); }) //手机版点击 $('.nav-collapse').click(function() { if($(this).parent('.box-icon').hasClass('open')) { $(this).parent('.box-icon').removeClass('open'); } else { $(this).parent('.box-icon').addClass('open').siblings().removeClass('open'); $('.bg-nav-mobilce2').hide(); } }) //手机版搜索框 $('.box-icon-other').click(function(event) { $('.box-mobile-form').stop(true, false).slideToggle('slow'); $('.bg-nav-mobilce2').toggle(); $('.nav-collapse').parent('.box-icon').removeClass('open'); // $('.mobile-input-search').focus(); if($('.nav-mobile').css('display') == 'block') { $('.nav-mobile').hide(); $('.bg-nav-mobilce').hide(); } }) $('.bg-nav-mobilce2').click(function() { $(this).hide(); $('.box-mobile-form').slideUp(); }) //字符长度 function maxLength(ele, len) { ele.each(function() { if($(this).text().length > len) { $(this).text($(this).text().substring(0, len)); $(this).html($(this).html() + '...'); } }); } //footer and words //轮播图 if($('.bxslider').length > 0) { var bxslider_1 = $('.main-zt .bxslider').bxSlider({ pause: 4000, pager: true, auto: true, autoHover: true, controls:false, onSliderLoad: function() { $(".main-zt .bx-controls-direction a").click(function() { bxslider_1.goToNextSlide(); bxslider_1.startAuto(); }) } }); } //详情页图片添加图片类 img-responsive $(document).ready(function () { $('.article-content img,.wp_articlecontent img').each(function(){ // var photoType = $(this).data().layer; // if(photoType=='photo'){ $(this).addClass('img-responsive').css({ 'display': 'inline-block' }); // } }) }) //左侧二级栏目 //底部位置 function footerLoad() { setTimeout(function() { $('.footer').css('display', 'block'); var $screenHeight = document.documentElement.clientHeight; var $bodyHeight = $('body').height(); // console.log($screenHeight) // console.log($bodyHeight) if($bodyHeight <= $screenHeight) { $('.footer').css({ 'position': 'absolute', 'bottom': '0', 'left': '0', 'right': '0' }) } else { $('.footer').css({ 'position': 'static' }) } }, 12) } $(window).resize(function() { $('.footer').css({'position': 'static'}); footerLoad(); }) $(window).load(function() { footerLoad(); }) //手机端有下拉栏目时增加向下的箭头 $('.mobile-navlist .nav-item .nav-item-menu').prev('a').append(""); // 手机端导航栏自动设置scroll function mobileScroll() { var bodyHeight=document.documentElement.clientHeight, mobileUl=bodyHeight-102; $('.mobile-navlist').css('max-height',mobileUl); } mobileScroll(); // 收藏本站 function AddFavorite(title, url) { try { window.external.addFavorite(url, title); } catch(e) { try { window.sidebar.addPanel(title, url, ""); } catch(e) { alert("抱歉,您所使用的浏览器无法完成此操作。\n\n加入收藏失败,请使用Ctrl+D进行添加"); } } } $('.header-collection').click(function() { AddFavorite(); }) //首页学院新闻 $('.main-news-word li').hover(function () { if ($(this).hasClass('current')) { return false; } else{ var index=$(this).index(); $(this).addClass('current').siblings().removeClass('current'); $('.main-news-img li').hide().eq(index).stop(true,false).fadeIn(300); } },function () { return false; }) //首页通知公告等切换 if ($('.main-title2').length>0) { $('.main-title2 a').attr('href',$('.main-title2 h4').eq(0).data().href); $('.main-title2 h4').hover(function () { if ($(this).hasClass('active')) { return false; } else{ var $href=$(this).data().href; var index=$(this).index(); $(this).addClass('active').siblings().removeClass('active'); $('.main-title2 a').attr('href',$href); $('.main-list1').hide().eq(index).stop(true,false).fadeIn(300); } },function () { return false; }) } //是否显示navlist2 if ($('.navlist2 li').length>0) { $('.navlist2').show(); }else{ $('.navlist2').hide(); } //列表没图时隐藏 if ($('.common-list').length>0) { $('.common-list-left').each(function () { console.log(); if ($(this).children('img').attr('src')!='') { $(this).css('display','block'); } else{ $(this).css('display','none'); } }) } // 手机端控制左侧栏打开 $('.list-show').click(function() { $('.common-left').stop().slideToggle(); setTimeout(function() { $('.footer').css({ 'position': 'static' }); footerLoad(); }, 300); }) //人物列表添加默认图 $('.people-list>li img').each(function () { if ($(this).attr('src')=='') { $(this).attr('src','/_upload/tpl/04/d2/1234/template1234/images/base.jpg'); } }) //最后一个导航存在二级时 下拉框位置调整 function lastNav() { $('.navlist>.nav-item:last-child>.nav-item-menu').css({ 'left': 'inherit', 'right': '0px' }); } lastNav(); //三级栏目当前状态 $('.navlist2>li>a').each(function() { if($(this).hasClass('active')) { $(this).next('.thr-sub').addClass('sub-open'); } if($(this).next('.thr-sub').hasClass('sub-open')) { $(this).css({ 'border-bottom': 'none' }) } }) //三级栏目点击改变状态 $('.navlist2>li>a').click(function() { if($(this).next('.thr-sub').hasClass('sub-open')) { $(this).next('.thr-sub').removeClass('sub-open'); $(this).css({ 'border-bottom': '1px solid #fff' }); } else { $(this).next('.thr-sub').addClass('sub-open').siblings().removeClass('sub-open'); $(this).css({ 'border-bottom': 'none' }) } $('.footer').css({ 'position': 'static' }); footerLoad(); }) })