/* * Copyright 2017 BianFusheng * Email: bfszxp@sina.com */ var isSupportTouch = !!('ontouchend' in document) || navigator.userAgent.indexOf('Windows Phone') > 0; (function ($, document) { $(document).ready(function () { var now_date = new Date(), now_year = now_date.getFullYear(), now_month = now_date.getMonth(), now_day = now_date.getDate(), now_today = now_date.getDay(); $('.wn-date .date').html('今天是:' + now_year + '年' + (now_month + 1) + '月' + now_day + '日 星期' + '日一二三四五六'.charAt(now_today)); var inputs = 'textarea, input:text, input:password', notKeyCode = '16,17,18,9,27,45,46,112,113,114,115,116,117,118,119,120,121,122,123,33,34,35,36,37,38,39,40,', isSupportTouch = !!('ontouchend' in document) || navigator.userAgent.indexOf('Windows Phone') > 0; $(inputs).focus(function () { $(this).next('label.clew').addClass('light-color'); if ($(this).val() > 0) { $(this).next('label.clew').hide(); } }); $(inputs).blur(function () { if ($(this).val() == 0) { $(this).next('label.clew').show().removeClass('light-color'); } else { $(this).next('label.clew').hide(); } }); $(inputs).keydown(function (e) { if ($(this).val().length == 0) { var kc = e.keyCode; if (notKeyCode.indexOf(kc + ',') == -1) { $(this).next('label.clew').hide(); return; } } if ($(this).val().length != 0) { $(this).next('label.clew').hide(); } else { $(this).next('label.clew').show().addClass('light-color'); } }); $(inputs).keyup(function () { if ($(this).val().length != 0) { $(this).next('label.clew').hide(); } else { $(this).next('label.clew').show().addClass('light-color'); } }); $('label.clew').click(function () { $(this).addClass(); $(this).prev().focus(); }); var nchd = '.noyau-cr-header-deputy'; $(window).resize(function () { var window_width = $(window).width(); if($('.noyau-cr-side-bar').length) { if(window_width < 1086) { $('.noyau-cr-side-bar').addClass('welt'); $('body').addClass('noyau-cr-small-screen'); } else { $('.noyau-cr-side-bar').removeClass('welt'); $('body').removeClass('noyau-cr-small-screen'); } } if ($('#noyau-cr-home-page').length) { if (window_width >= 1420) { $('body').addClass('noyau-cr-big-screen'); } else { $('body').removeClass('noyau-cr-big-screen'); } if($('#noyau-cr-header').offset().left - 60 > 0) { $(nchd).css('margin-right', -($('#noyau-cr-header').offset().left - 60)); } else { $(nchd).css('margin-right', 0); } } }).trigger('resize'); $('.noyau-cr-home-banner img').each(function() { mainBgResize(this); }); if ($.fn.cycle) { $('.noyau-cr-home-banner ul').cycle({ pause: 0, timeout: 3000 }); } banner('banner-box', 5000); $('[class*=tabs-nav]').each(function() { var $tabs_nav = $(this), $nav_li = $tabs_nav.children('.list').children('li'), $panel = $tabs_nav.next().children('.panel'); $nav_li.hover(function() { var $this = $(this), ti = $this.index(); if(!$this.hasClass('selected')) { $this.addClass('selected').siblings('.selected').removeClass('selected'); $panel.eq(ti).show().siblings(':visible').hide(); } }).first().trigger('mouseover'); }); var ndw_content = '.ndw-content'; $('.font-size-control span').click(function() { var $this = $(this); $this.addClass('selected').siblings('.selected').removeClass('selected'); if($this.hasClass('fz-b-btn')) { $(ndw_content).css({fontSize: '16px', lineHeight: '38px'}); } if($this.hasClass('fz-n-btn')) { $(ndw_content).removeAttr('style'); } if($this.hasClass('fz-s-btn')) { $(ndw_content).css({fontSize: '12px', lineHeight: '24px'}); } return false; }); $('.font-size-control .fz-n-btn').trigger('click'); $(window).resize(function() { if($('.noyau-cr-home-banner').length) { $('.noyau-cr-home-banner').height($(window).height() - 135 < 575 ? 575 : $(window).height() - 135); } }).trigger('resize'); var sb_flag = true; $(document).click(function() { if(sb_flag) { $('.noyau-cr-side-bar li > a + div').animate({width: 0}); $('.noyau-cr-side-bar li.selected').removeClass('selected'); } }); $('.noyau-cr-side-bar li > a + div, .noyau-cr-side-bar li > a').hover(function() { sb_flag = false; }, function() { sb_flag = true; }); var nc_email_timeout1, nc_email_timeout2; /* $('.noyau-cr-side-bar li > a').click(function() { var $this = $(this); if(!$this.hasClass('noyau-cr-email-btn')) { if($this.next('div').width() == 0 && !$this.next('div').is(':animated')) { $this.parent().addClass('selected'); $this.next('div').animate({width: $this.next('div').children('.noyau-cr-inner').width()}); $this.parent().siblings('li').children('div').animate({width: 0}); $this.parent().siblings('li').removeClass('selected'); } else { $this.parent().removeClass('selected'); $this.next('div').animate({width: 0}); } } }); */ $('.noyau-cr-side-bar li').hover(function () { var $this = $(this).children('a'); if ($this.next('div').is(':animated')) { !$this.next('div').stop(); } $this.parent().addClass('selected'); $this.next('div').animate({ width: $this.next('div').children('.noyau-cr-inner').width() }); $this.parent().siblings('li').children('div').stop().animate({ width: 0 }); $this.parent().siblings('li').removeClass('selected'); }, function () { var $this = $(this).children('a'); if ($this.next('div').is(':animated')) { !$this.next('div').stop(); } $this.next('div').animate({ width: 0 }); $this.parent().removeClass('selected'); }); $('.noyau-cr-email-btn').hover(function() { var $this = $(this); clearTimeout(nc_email_timeout1); clearTimeout(nc_email_timeout2); if($this.hasClass('noyau-cr-email-btn')) { nc_email_timeout1 = setTimeout(function() { $this.next().show().stop().animate({marginRight: 1, opacity: 1, width: 'auto'}); }, 200); } }, function() { var $this = $(this); clearTimeout(nc_email_timeout1); clearTimeout(nc_email_timeout2); if($this.hasClass('noyau-cr-email-btn')) { nc_email_timeout2 = setTimeout(function() { $this.next().stop().animate({marginRight: 11, opacity: 0}, function() { $(this).hide(); }); }, 200); } }); $('.noyau-cr-search-btn').click(function () { if ($(this).siblings('.noyau-cr-sb-search-box').is(':visible')) { $(this).siblings('.noyau-cr-sb-search-box').find('form').submit(); } }); $('.noyau-cr-sb-email-box').hover(function () { clearTimeout(nc_email_timeout1); clearTimeout(nc_email_timeout2); }, function () { var $this = $(this) nc_email_timeout2 = setTimeout(function () { $this.stop().animate({ marginRight: 11, opacity: 0 }, function () { $(this).hide(); }); }, 200); }); if ($.ui) { $(".noyau-cr-date-box:first .noyau-cr-input-text").datepicker({ prevText: "", nextText: "", changeYear: true, changeMonth: true }); $(".noyau-cr-date-box:eq(1) .noyau-cr-input-text").datepicker({ prevText: "", nextText: "", align: "right", changeYear: true, changeMonth: true }); $(".noyau-cr-date-btn").click(function () { if ($("#ui-datepicker-div").is(":hidden")) { $(this).prev("input").focus(); } else { $(this).prev("input").blur(); } }); } }); })(jQuery, document); function banner(name,speed){ var banner_name=$("."+name); $(banner_name).each(function() { var $this = $(this); var timer=null; var intervalCount=0; var banner_size=$this.find("ul li").size(); for(var createSpan=0; createSpan'); } $this.find(".control span:eq(0)").removeClass("active").addClass("active").siblings().removeClass("active"); $this.find("li").eq(0).css("zIndex",2).show().siblings().css("zIndex",1).hide(); $this.find(".control span").bind("click",function(){ if(!$this.find("li").is(":animated")){ var nIndex = $this.find(".control span").index(this); filp(nIndex); } }); $this.find(".prev").bind("click", function() { if(!$this.find("li").is(":animated")){ var nIndex=$this.find("li:visible").index(); nIndex = nIndex == 0 ? banner_size-1 : --nIndex; filp(nIndex); } }); $this.find(".next").bind("click", function() { if(!$this.find("li").is(":animated")){ var nIndex=$this.find("li:visible").index(); nIndex = nIndex == banner_size-1 ? 0 : ++nIndex; filp(nIndex); } }); function move(nIndex){ if(!$this.find("li").is(":animated")){ nIndex = nIndex == banner_size-1 ? 0 : ++nIndex; filp(nIndex); } } function filp(nindex) { $this.find("li").eq(nindex).fadeIn().siblings().fadeOut(); $this.find("li").eq(nindex).css("zIndex",2).siblings().css("zIndex",1); $this.find(".control span:eq("+nindex+")").removeClass("active").addClass("active").siblings().removeClass("active"); intervalCount=nindex; } $("."+name+",."+name+" .control span"+",."+name+" .control a").bind("mouseover",function(){ clearInterval(timer); }); $("."+name+",."+name+" .control span"+",."+name+" .control a").bind("mouseout",function(){ clearInterval(timer); timer=setInterval(function(){ move(intervalCount); }, speed); }); timer = setInterval(function(){ move(intervalCount); }, speed); }); } /*打印标记*/ function doPrint() { bdhtml=window.document.body.innerHTML; sprnstr=""; eprnstr=""; prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17); prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr)); OpenWindow = window.open(""); OpenWindow.document.write("打印页<\/TITLE><link href=/bz/liuxian2.html rel=\"stylesheet\" type=\"text\/css\" \/><link href=/qingsong.html rel=\"stylesheet\" type=\"text\/css\" \/><\/HEAD><BODY><div id=\"printbox\" class=\"news_cont\" ><\/div><\/BODY><\/HTML>"); OpenWindow.document.getElementById("printbox").innerHTML=prnhtml; OpenWindow.document.close(); OpenWindow.print(); } /*打印区的内容一定要加<!--startprint-->和<!--endprint-->标记*/ //<a href="javascript:;" onClick="doPrint()">打印</a> function mainBgResize(img, width, height) { var $img = $(img), _img = img, new_img = new Image(), img_timeout; new_img.src = $(_img).attr('src'); $(_img).one('load', function () { cycleImg(); }).each(function () { if (this.complete) { $(this).trigger('load'); } }); function cycleImg() { img_timeout = setTimeout(function () { if (new_img.width > 0 && new_img.complete) { imgResize(); clearTimeout(img_timeout); } else { cycleImg(); } }, 17); } $(window).resize(function () { imgResize(); }).trigger('resize'); function imgResize() { var ratio; if (typeof $(_img).data('old-width') == 'undefined') { if (new_img.width > 0 && new_img.height > 0) { $(_img).data('old-width', new_img.width); $(_img).data('old-height', new_img.height); } } if (new_img.width > 0 && new_img.height > 0) { $(_img).width(new_img.width).height(new_img.height); } ratio = new_img.width / new_img.height; var browser_w = $('.noyau-cr-home-banner').width(), browser_h = $(window).height() - 135; browser_h = browser_h < 575 ? 575 : browser_h; if ($(_img).width() < browser_w || $(_img).height() > browser_w) { $img.css({ width: browser_w, height: browser_w / ratio }); if ($(_img).height() < browser_h) { $img.css({ width: browser_h * ratio, height: browser_h }); } } else if ($(_img).width() < browser_h || $(_img).width() > browser_h) { $img.css({ width: browser_h * ratio, height: browser_h }); if ($(_img).width() < browser_w) { $img.css({ width: browser_w, height: browser_w / ratio }); } } $(_img).css({ marginTop: -($(_img).height() - browser_h) / 2, marginLeft: -($(_img).width() - browser_w) / 2, 'visibility': 'visible' }); } }