$(function () { $("#goods_list ul li a,#news_list dl dt a,.show_list li a,.is_top .box a,.is_red ul li a,#goods ul li a").click(function () { popwin.showwin("1000", $(window).height(), $(this).attr("title"), $(this).attr("name")); }); //* navigation dropdown //* 导航下拉伸缩 $('#nav li').mousemove(function () { $(this).find('ul').slidedown();//you can give it a speed }); $('#nav li').mouseleave(function () { $(this).find('ul').slideup("fast"); }); $('#nav li:last').css('background-position', '0 -50px'); //* name: back top //* tag: 返回顶部 function backtop() { this.init(); } backtop.prototype = { constructor: backtop, init: function () { this._initbacktop(); }, _initbacktop: function () { var $backtop = this.$backtop = $('
' + //''+ //'
'+ //'
'+ '' + '' + '' + '
'); $('body').append($backtop); $backtop.click(function () { $("html, body").animate({ scrolltop: 0 }, 120); }); var timmer = null; $(window).bind("scroll", function () { var d = $(document).scrolltop(), e = $(window).height(); 0 < d ? $backtop.css("bottom", "10px") : $backtop.css("bottom", "-90px"); cleartimeout(timmer); timmer = settimeout(function () { cleartimeout(timmer) }, 100); }); } } var backtop = new backtop(); //* slider //* 滑块新闻焦点图 $("#focus").hover(function () { $("#focus-prev,#focus-next").show(); }, function () { $("#focus-prev,#focus-next").hide(); }); $("#focus").slide({ maincell: "#focus-bar-box ul", targetcell: "#focus-title a", titcell: "#focus-num a", prevcell: "#focus-prev", nextcell: "#focus-next", effect: "left", easing: "easeinoutcirc", autoplay: true, delaytime: 200 }); //* qqservice //* qq在线客服 var kf = $(".qqservice"); var wkbox = $(".qqservice_box"); var kf_close = $(".qqservice .qqservice_close"); var icon_qqservice = $(".icon_qqservice"); var kh = wkbox.height(); var kw = wkbox.width(); var wh = $(window).height(); kf.css({ height: kh }); icon_qqservice.css("top", parseint((kh - 100) / 2)); var kf_top = (wh - kh) / 2; if (kf_top < 0) kf_top = 0; kf.css("top", kf_top); $(kf_close).click(function () { kf.animate({ width: "0" }, 200, function () { wkbox.hide(); icon_qqservice.show(); kf.animate({ width: 26 }, 300); }); }); $(icon_qqservice).click(function () { $(this).hide(); wkbox.show(); kf.animate({ width: kw }, 200); }); //* ifocus //* 内页横向切换带索引焦点图 //* var swidth = $("#ifocus").width(); //获取焦点图的宽度(显示面积) var len = $("#ifocus ul li").length; //获取焦点图个数 var index = 0; var ind = 0; var pictimer; //以下代码添加数字按钮和按钮后的半透明长条 var btn = "
"; for (var i = 0; i < len; i++) { btn += "" + (i + 1) + ""; } btn += "
" $("#ifocus").append(btn); $("#ifocus .btn_bg").css("opacity", 0.0); //为数字按钮添加鼠标滑入事件,以显示相应的内容 $("#ifocus .btn span").mouseenter(function () { index = $("#ifocus .btn span").index(this); showpics(index); }).eq(0).trigger("mouseenter"); //本例为左右滚动,即所有li元素都是在同一排向左浮动,所以这里需要计算出外围ul元素的宽度 $("#ifocus ul").css("width", swidth * (len + 1)); //鼠标滑上焦点图时停止自动播放,滑出时开始自动播放 $("#ifocus").hover(function () { clearinterval(pictimer); }, function () { pictimer = setinterval(function () { if (index == len) { //如果索引值等于li元素个数,说明最后一张图播放完毕,接下来要显示第一张图,即调用showfirpic(),然后将索引值清零 showfirpic(); index = 0; } else { //如果索引值不等于li元素个数,按普通状态切换,调用showpics() showpics(index); } index++; }, 5000); //此3000代表自动播放的间隔,单位:毫秒 }).trigger("mouseleave"); //显示图片函数,根据接收的index值显示相应的内容 function showpics(index) { //普通切换 var nowleft = -index * swidth; //根据index值计算ul元素的left值 $("#ifocus ul").stop(true, false).animate({ "left": nowleft }, 500); //通过animate()调整ul元素滚动到计算出的position $("#ifocus .btn span").removeclass("on").eq(index).addclass("on"); //为当前的按钮切换到选中的效果 } function showfirpic() { //最后一张图自动切换到第一张图时专用 $("#ifocus ul").append($("#ifocus ul li:first").clone()); var nowleft = -len * swidth; //通过li元素个数计算ul元素的left值,也就是最后一个li元素的右边 $("#ifocus ul").stop(true, false).animate({ "left": nowleft }, 500, function () { //通过callback,在动画结束后把ul元素重新定位到起点,然后删除最后一个复制过去的元素 $("#ifocus ul").css("left", "0"); $("#ifocus ul li:last").remove(); }); $("#ifocus .btn span").removeclass("on").eq(0).addclass("on"); //为第一个按钮添加选中的效果 } //* nav cursor droplist //* 光标跟随带下拉菜单导航栏 //* plugin: jquery.superslide.2.1.1.js var nav = $(".nav"); var init = $(".nav .m").eq(ind); var block = $(".nav .block"); block.css({ "left": init.position().left - 0 }); nav.hover(function () { }, function () { block.stop().animate({ "left": init.position().left - 0 }, 500); }); $(".nav").slide({ type: "menu", titcell: ".m", targetcell: ".sub", delaytime: 500, triggertime: 0, returndefault: true, defaultindex: ind, startfun: function (i, c, s, tit) { block.stop().animate({ "left": tit.eq(i).position().left - 0 }, 500); } }); //* name: images scroll //* tag: 图片滚动 //* plugin: jquery.imgscroll.js $("#count1").dayuwscroll({ parent_ele: '#wrapbox1', list_btn: '#tabt04', pre_btn: '#left1', next_btn: '#right1', path: 'left', auto: true,//true为自动播放,false为不自动播放 time: 3000, num: 4, gd_num: 3, waite_time: 1000 }); $("#count2").dayuwscroll({ parent_ele: '#wrapbox2', list_btn: '#tabt04', pre_btn: '#left2', next_btn: '#right2', path: 'left', auto: false, time: 3000, num: 3, gd_num: 3, waite_time: 1000 }); $('#goods').hover(function () { $(".prev", this).stop().animate({ left: '0px' }, { queue: false, duration: 110 }); $(".next", this).stop().animate({ right: '0px' }, { queue: false, duration: 110 }); }, function () { $(".prev", this).stop().animate({ left: '-50px' }, { queue: false, duration: 110 }); $(".next", this).stop().animate({ right: '-50px' }, { queue: false, duration: 110 }); }); $('#goods li').hover(function () { $(".cover", this).stop().animate({ bottom: '0px' }, { queue: false, duration: 110 }); }, function () { $(".cover", this).stop().animate({ bottom: '-50px' }, { queue: false, duration: 110 }); }); //* name: touch slider //* tag: 横向切换焦点图 //* plugin: jquery.touchslider.js $(".focus").hover(function () { $("#btn_prev,#btn_next").fadein() }, function () { $("#btn_prev,#btn_next").fadeout() }) $dragbln = false; $(".focus_item").touchslider({ flexible: true, speed: 300, btn_prev: $("#btn_prev"), btn_next: $("#btn_next"), paging: $(".flicking_btn a"), counter: function (e) { $(".flicking_btn a").removeclass("on").eq(e.current - 1).addclass("on"); } }); $(".focus_item").bind("mousedown", function () { $dragbln = false; }) $(".focus_item").bind("dragstart", function () { $dragbln = true; }) $(".focus_item a").click(function () { if ($dragbln) { return false; } }) timer = setinterval(function () { $("#btn_next").click(); }, 5000); $(".focus").hover(function () { clearinterval(timer); }, function () { timer = setinterval(function () { $("#btn_next").click(); }, 5000); }) $(".focus_item").bind("touchstart", function () { clearinterval(timer); }).bind("touchend", function () { timer = setinterval(function () { $("#btn_next").click(); }, 5000); }); function initmenu() { $('#menu ul').hide(); $('#menu ul').children('.current').parent().show(); //$('#menu ul:first').show(); $('#menu li a').click( function () { var checkelement = $(this).next(); if ((checkelement.is('ul')) && (checkelement.is(':visible'))) { return false; } if ((checkelement.is('ul')) && (!checkelement.is(':visible'))) { $('#menu ul:visible').slideup('normal'); checkelement.slidedown('normal'); return false; } } ); } $(document).ready(function () { initmenu(); }); ////////////////////////// });