var ie6 = !-[1,] && !window.xmlhttprequest; var useragent = navigator.useragent.tolowercase(); var browser = { ie8: /msie 8/.test(useragent), ie7: /msie 7/.test(useragent) }; //下拉 $.fn.sele=function() { var ev=$(this).data('click')?'click':'mouseenter'; $(this).bind(ev,function(){sele_show(this,ev)}).bind('mouseleave',function(){sele_hide(this)}); function sele_show(me,evt){ $(me).children('span').addclass('on').end().find('.sele_').stop(1,1).slidedown(200).children('a').click(function(event){ event.stoppropagation(); if(!$(this).attr('target')){ event.preventdefault(); if($(me).find('.btn').length){ $(me).find('.btn').attr('href',$(this).attr('href')).click(function(event){event.stoppropagation()}); }; $(this).parent().hide().parents('.sele').children('span').text($(this).text()); } }) }; function sele_hide(me){ $(me).children('span').removeclass('on').end().find('.sele_').stop(1,0).slideup(200) }; }; var $sele=$('.sele'); $sele.each(function(i) {$(this).css('z-index',$sele.length-i).sele()}); //导航 var $nav=$('.nav').find('.li'), $navcur=$('.nav').find('.cur').length?$('.nav').find('.cur').index():0, $navline=$('.nav_line'); $navline.css('left',$navcur*$nav.eq(0).width()); $nav.mouseenter(function(){ $(this).addclass('hover'); $navline.stop(1,0).animate({left:$(this).index()*$nav.eq(0).width()},200) }).mouseleave(function(){ $(this).removeclass('hover'); $navline.stop(1,0).animate({left:($('.nav').find('.cur').length?$('.nav').find('.cur').index():0)*$nav.eq(0).width()},200) }); //选项卡 $.fn.tab=function(){ var $key=$(this).find('.key'), $cont=$(this).find('.tab_c'); $key.eq(0).addclass('on'); $cont.hide().eq(0).show(); $key.hover(function(){ $(this).addclass('on').siblings().removeclass('on'); $cont.hide().eq($(this).index()).show(); }) }; $('.tab').each(function() {$(this).tab()}); //顶部ico $('.log,.glos,.mob').mouseenter(function(){ $(this).addclass('hover') }).mouseleave(function(){ $(this).removeclass('hover') }); $('.comp').mouseenter(function(){ $(this).addclass('comp_hover') }).mouseleave(function(){ $(this).removeclass('comp_hover') }).find('.sele_').prepend('
'); $('.mob').mouseenter(function(){ $(this).addclass('mob_hover') }).mouseleave(function(){ $(this).removeclass('mob_hover') }).find('.sele_').prepend('
'); $('.lang').mouseenter(function(){ $(this).addclass('langhover') }).mouseleave(function(){ $(this).removeclass('langhover') }); //ie6定位修复 $.fn.ie6fix=function(){ var $this=$(this), positop=$this.css('top')!='auto' ? true : ($this.css('bottom')!='auto' ? false : null), selfhei=$(this).outerheight(true), $h, posival=parseint($this.css(positop ? 'top' : 'bottom')); if(positop!=null){ $this.css('position','absolute'); reposi(); $(window).resize(function(){reposi();}); $(window).scroll(function(){reposi();}); function reposi(){ $h=$(window).height(); $this.css('top',positop ? $(window).scrolltop()+posival : $h-selfhei-posival+$(window).scrolltop()); }; }else{ //console.warn('ie6fix():对象缺少top或bottom属性') } }; if(ie6){$('.ie6fix').each(function() {$(this).ie6fix()})}; $(document).ready(function() { jquery.jqtab = function(tabtit,tab_conbox,shijian) { $(tab_conbox).find("li").hide(); $(tabtit).find("li:first").addclass("on").show(); $(tab_conbox).find("li:first").show(); $(tabtit).find("li").bind(shijian,function(){ $(this).addclass("on").siblings("li").removeclass("on"); var activeindex = $(tabtit).find("li").index(this); $(tab_conbox).children().eq(activeindex).show().siblings().hide(); return false; }); }; /*调用方法如下:*/ $.jqtab("#tabs","#tab_conbox","click"); $.jqtab("#tabs2","#tab_conbox2","mouseenter"); });