//无缝滚动 var rollmove = function(id,options){ this.$el = $(id); this.timer = null; this.init(options); } rollmove.defaults = { animation: true, distance : 0, visiblenumber : 0 } rollmove.prototype.init = function(options){ this.options = this.getoptions(options); this.$ul = this.$el.find('ul'); var ali = this.$ul.find('li'); this.$ul.width(ali.size()*2*this.distance); if(ali.size() < 2){ return; }else if(ali.size() < this.options.visiblenumber+1){ this.$ul.append(this.$ul.children().clone()) this.$ul.width(ali.size()*2*this.distance); } this.bindevent(); } rollmove.prototype.bindevent = function(){ var _this = this; this.$el.on('click','.prev',function(){ _this.prev(); _this.boff = true; }); this.$el.on('click','.next',function(){ _this.next(); _this.boff = false; }); this.options.animation && this.play(); this.hover(); } rollmove.prototype.prev = function(){ var _this = this; var first = this.$ul.find('li:first'); this.$ul.append(first.clone()).stop().animate({left: -this.options.distance},500, function(){ first.remove(); _this.$ul.css('left',0); }); } rollmove.prototype.next = function(){ var last = this.$ul.find('li:last'); this.$ul.prepend(last.clone()).css('left',-this.options.distance).stop().animate({left: 0},500, function() { last.remove(); }); } rollmove.prototype.fnauto = function(){ if(this.boff){ this.prev() }else{ this.next() } } rollmove.prototype.play = function(){ var _this = this; this.timer = setinterval(function(){ _this.fnauto(); },3000); } rollmove.prototype.stop = function(){ clearinterval(this.timer); } rollmove.prototype.hover = function(){ var _this = this; this.$el.hover(function() { _this.stop(); }, function() { _this.stop(); _this.play(); }); } rollmove.prototype.getoptions = function (option) { return $.extend({}, this.getdefaults(), option);; } rollmove.prototype.getdefaults = function () { return rollmove.defaults; } rollmove.prototype.destroy = function () { this.$el = null; this.stop(); }; $(function(){ navfn($); bannerfn($); sidepicfn($); certificatefn($); businessfn($); casefn($); }); function navfn($){ var $nav = $('#j-nav'); var $ali = $nav.children('li'); var current = $nav.children('li[class*="active"]').index(); $nav.children('li').each(function(index, el) { $(el).hover(function() { toogleclass($(this).index()); }, function() { toogleclass(current); }); }); function toogleclass(i){ $ali.eq(i).addclass('active hover').siblings('li').removeclass('active hover'); } } function bannerfn($){ var $banner = $('#j-banner'); var $ali = $banner.find('ul li'); var obtns = $banner.find('.btns'); var sbtn = ''; var inow = 0; var timer = null; var length = $ali.size(); for (var i = 0; i < length; i++) { sbtn += '
  • '; } obtns.html(sbtn); var abtns = obtns.children('li'); function move(){ $ali.css('zindex',0); $ali.eq(inow).css('zindex',10).stop().fadeto(500,1).siblings().stop().fadeto(500,0); abtns.eq(inow).addclass('active').siblings().removeclass('active'); } move(); abtns.each(function(index, el){ $(el).on('click',function(){ inow = $(this).index(); move(); }); }); function next(){ if(inow == length -1){ inow = 0; }else{ inow++; } move(); } function prev(){ if(inow == 0){ inow = length -1; }else{ inow--; } move(); } itmer = setinterval(function(){ next() },5000); $banner.hover(function(){ clearinterval(itmer); },function(){ clearinterval(itmer); itmer = setinterval(function(){ next(); },5000); }); } function sidepicfn($){ var $sidepic = $('#j-sidepic'); var $oul = $sidepic.find('.sidepic-pic ul'); var $ali = $oul.find('li'); var otext = $sidepic.find('.text'); var obtns = $sidepic.find('.btns'); var sbtn = ''; var inow = 0; var timer = null; var length = $ali.size(); var abtns = obtns.children('li'); function move(){ otext.stop().animate({top: -60*inow}); $oul.stop().animate({left: -463*inow}); abtns.eq(inow).addclass('active').siblings().removeclass('active'); } move(); abtns.each(function(index, el){ $(el).on('click',function(){ inow = $(this).index(); move(); }); }); function next(){ if(inow == length -1){ inow = 0; }else{ inow++; } move(); } function prev(){ if(inow == 0){ inow = length -1; }else{ inow--; } move(); } itmer = setinterval(function(){ next() },5000); $sidepic.hover(function(){ clearinterval(itmer); },function(){ clearinterval(itmer); itmer = setinterval(function(){ next(); },5000); }); } function certificatefn($){ var $certificate = $('#j-certificate'); var $oul = $certificate.find('.pic ul'); var $ali = $oul.find('li'); var atext = $certificate.find('.text li'); var obtns = $certificate.find('.btns'); var sbtn = ''; var inow = 0; var timer = null; var length = $ali.size(); if(length < 2){ $certificate.find('.toggle').hide(); } for (var i = 0; i < length; i++) { sbtn += '
  • '; } obtns.html(sbtn); var abtns = obtns.children('li'); function move(){ $oul.stop().animate({left: -252*inow}); abtns.eq(inow).addclass('active').siblings().removeclass('active'); atext.eq(inow).addclass('active').siblings().removeclass('active'); } move(); abtns.each(function(index, el){ $(el).on('click',function(){ inow = $(this).index(); move(); }); }); function next(){ if(inow == length -1){ inow = 0; }else{ inow++; } move(); } function prev(){ if(inow == 0){ inow = length -1; }else{ inow--; } move(); } $certificate.on('click','.prev',function(){ prev() }); $certificate.on('click','.next',function(){ next() }); itmer = setinterval(function(){ next() },5000); $certificate.hover(function(){ clearinterval(itmer); },function(){ clearinterval(itmer); itmer = setinterval(function(){ next(); },5000); }); } function businessfn($){ var $business = $('#j-business'); var $oul = $business.children('ul'); var $ali = $oul.children('li'); var config = { animation: true, distance : 226, visiblenumber : 3 } var roll = new rollmove($ali.eq(0).find('.content .m-roll'),config); $ali.find('.content').stop().animate({width: 0}); $ali.eq(0).find('.content').stop().animate({width: 771}); $ali.each(function(index, el){ $(el).on('click','.title',function(){ var parents = $(this).parents('li'); parents.addclass('active').siblings('li').removeclass('active'); $ali.find('.content').stop().animate({width: 0}); parents.find('.content').stop().animate({width: 771}); roll.destroy(); roll = new rollmove(parents.find('.content .m-roll'),config); }); }); } function casefn($){ new rollmove('#j-case',{'distance':281,'visiblenumber':4}); } 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进行添加"); } } }