/** *@author readkid *@dependence jquery 1.2 *@since 2010/1/15 *@version 1.0 */ (function () { //using namespace $.suning; $.suning || ($.suning = {}); //extends $.suning.extend = function (subclass, superclass) { var f = function() {}; f.prototype = superclass.prototype; subclass.prototype = new f(); superclass.prototype.constructor = superclass; subclass.prototype.constructor = subclass; subclass.base = superclass.prototype; } })(); //sidenav $.suning.menunav = function() { var timer; if($("#sidenav").css("display") == "none"){ $(".sn_menu").hover(function(){ clearinterval(timer); $("#sidenav").css("display","block"); $(this).find(".sn_menuicon").addclass("on"); $("#sidenav").find("dl").each(function(i){ $(this).mouseover(function() { navshow(i); }); }); function navshow(i){ $("#sidenav").find(".icon").removeclass('on').eq(i).addclass("on"); $("#sidenav").find(".sidenavchild").hide().eq(i).show(); }; },function(){ timer = setinterval(function(){ $("#sidenav").css("display","none"); },1); $("#sidenav").find(".icon").removeclass('on'); $(this).find(".sn_menuicon").removeclass("on"); $(this).find(".sidenavchild").hide(); }); }else{ $("#sidenav").find("dl").each(function(i){ $(this).mouseover(function(){ $(this).find(".icon").addclass("on"); $(this).find(".sidenavchild").css("display","block"); }).mouseout(function(){ $(this).find(".icon").removeclass("on"); $(this).find(".sidenavchild").css("display","none"); }) }); } } /* 首页八联版 */ $.suning.sntabflash = function(){ var len = $("#snflashbtn").find("li").length ; var index = 0 ; var timer,settime; $("#snflashcontent").find("ul").width( 580*len ); $("#snflashbtn").find("li").click(function(e){ index = $("#snflashbtn li").index(this); settime = settimeout(function(){scrollauto(index)},60); }) $("#snflash").hover(function(){ clearinterval(timer); },function(){ timer = setinterval(function(){ scrollauto(index); index++; if(index==len){index=0;} } , 3600); }).trigger("mouseleave"); function scrollauto(index){ $("#snflashbtn").find("li").removeclass("on").eq(index).addclass("on"); $("#snflashcontent").find("ul").stop().animate({"marginleft":-580*index},300); }; } /* tab点击 */ $.suning.tabclick = function(id,showid){ $("#"+id).find("li").each(function(i){ $(this).find("a").mouseover(function(e){ $(this).addclass("on").parent().siblings().find("a").removeclass("on"); $("."+showid).hide().eq(i).show(); }) }); } /* 切换事件 */ $.suning.indextab = function(){ var index = 0 ; var timer,settime; $("#sn_sevice").hover(function(){ $("#sn_sevicemore").show(); },function(){ $("#sn_sevicemore").hide(); }); $("#basket").hover(function(){ $("#basketshow").show(); },function(){ $("#basketshow").hide(); }); var len = $("#package").find("li").length ; $("#package").find(".package ul").width(576*len); $("#package").find(".packageright a").click(function(){ if(index>=len-1){ return false; } index ++ ; $("#package").find(".package ul").stop().animate({"marginleft":-576*index},300); }); $("#package").find(".packageleft a").click(function(){ if(index<=0){ return false; } index -- ; $("#package").find(".package ul").stop().animate({"marginleft":-576*index},300); }); $("#package").hover(function(){ clearinterval(timer); },function(){ timer = setinterval(function(){ if(index==len-1){index=-1;} index++; $("#package").find(".package ul").stop().animate({"marginleft":-576*index},300); } , 4000); }).trigger("mouseleave"); $("#promoretab").find("a").click(function(e){ e.preventdefault(); index = $("#promoretab a").index(this); scrollauto(index); }); $("#promoretab").hover(function(){ clearinterval(timer); },function(){ timer = setinterval(function(){ scrollauto(index); index++; if(index==7){index=0;} } , 3600); }).trigger("mouseleave"); function scrollauto(index){ $("#promoretab").find("a").eq(index).addclass("on").siblings().removeclass("on"); $("#promoretablist li").hide().eq(index).show(); }; } //排行榜 var sntoplist = function(tabid,id){ var btn = $('#'+id).find('li'); var len = btn.length ; return{ init:function(){ var that = this ; $("#"+tabid).find("a").mouseover(function(e){ e.preventdefault(); $(this).addclass("on").parent().siblings().find("a").removeclass("on"); var href = $(this).attr("href"); $("#"+id).html("
"); $.post(href,function(data){ $("#"+id).html(data); sntoplist('indextab01','indextoplist01').changelist(); sntoplist('indextab02','indextoplist02').changelist(); }); }).click(function(e){ return false; }).bind('focus', function(){ if(this.blur){ this.blur(); } }); that.changelist(); $("#tabindex01").find("li").each(function(i){ $(this).find("a").mouseover(function(){ $(this).addclass("on").parent().siblings().find("a").removeclass('on'); $(".tabindexcontent01").hide().eq(i).show(); }) }); $("#tabindex02").find("li").each(function(i){ $(this).find("a").mouseover(function(){ $(this).addclass("on").parent().siblings().find("a").removeclass('on'); $(".tabindexcontent02").hide().eq(i).show(); }) }); }, changelist:function(){ btn.each(function(i){ $(this).mouseover(function(){ $(this).addclass('on').siblings().removeclass('on'); btn.eq(0).find(".topshow").hide(); btn.eq(0).find(".tophide").show(); for(var j=0;j