(function($){var defaluts={large_elem:'.large_elem',small_elem:'.small_elem',icon_elem:'.icon_elem',state:'on',speed:'normal',vis:4,autoplay:true,autotime:3000};$.fn.extend({'thumbnailImg':function(options){var opts=$.extend({},defaluts,options);return this.each(function(){var $this=$(this);var t=0;$(opts.large_elem).find('ul li').eq(0).show();$(opts.small_elem).find('ul li').eq(0).addClass(opts.state);$(opts.icon_elem).find('i').eq(0).addClass(opts.state);var l=$(opts.small_elem).find('ul li').length;var l_mean=0;var w=$(opts.small_elem).find('ul li').outerWidth(true);$(opts.small_elem).find('ul').css('width',l*w+'px');$(opts.small_elem).find('ul li').click(function(){$(this).addClass(opts.state).siblings().removeClass(opts.state);t=$(this).index();Img($(this).index())});function Img(i){$(opts.large_elem).find('ul li').eq(i).fadeIn().siblings().fadeOut();$(opts.small_elem).find('ul li').eq(i).addClass(opts.state).siblings().removeClass(opts.state);$(opts.icon_elem).find('i').eq(i).addClass(opts.state).siblings().removeClass(opts.state);var ml=i*w;if(ml<=l_mean*w){$(opts.small_elem).find('ul').stop().animate({marginLeft:-ml+'px'},opts.speed)}else{$(opts.small_elem).find('ul').stop().animate({marginLeft:-(l_mean*w)+'px'},opts.speed)}}if(opts.autoplay){var timing=setInterval(function(){t++;if(t>l-1){t=0}Img(t)},opts.autotime);$this.hover(function(){clearInterval(timing)},function(){timing=setInterval(function(){t++;if(t>l-1){t=0}Img(t)},opts.autotime)})}})}})})(jQuery); (function($) { $.fn.slides = function(options){ var defaluts = { large_elem: '.large_elem', small_elem: '.small_elem', icon_elem: '.icon_elem', right_elem : '.right_elem', left_elem : '.left_elem', child:'li', state: 'on', speed: 'normal', vis: 4, autoplay: true, autotime: 3000, disabledClass: 'grey' // 添加禁用状态的class }; var opts = $.extend({}, defaluts, options); return this.each(function() { var $this = $(this); var $large_elem = $this.find(opts.large_elem); var $small_elem = $this.find(opts.small_elem); var $icon_elem = $this.find(opts.icon_elem); var $right_elem = $this.find(opts.right_elem); var $left_elem = $this.find(opts.left_elem); var l = $large_elem.find(opts.child).length; var t = 0; // 初始化按钮状态 updateButtonState(); if($large_elem.find('dd.cur').length > 0){ var $pobj = $large_elem.find('dd.cur').parent(); t= $pobj.index(); $pobj.show().siblings().hide(); updateButtonState(); } if($icon_elem.length > 0){ $icon_elem.children().click(function(){ t = $(this).index(); Img(t); updateButtonState(); }); } if($right_elem.length > 0){ $right_elem.click(function(){ if (!$(this).hasClass(opts.disabledClass)) { t++; if (t > l - 1) { t = 0 } Img(t); updateButtonState(); } }); } if($left_elem.length > 0){ $left_elem.click(function(){ if (!$(this).hasClass(opts.disabledClass)) { t--; if (t < 0) { t = l - 1; } Img(t); updateButtonState(); } }); } if($small_elem.length > 0){ var l_mean = 0; if (l < opts.vis) { l_mean = 0 } else { l_mean = ((parseInt(l / opts.vis) - 1) * opts.vis) + (l % opts.vis) } var w = $small_elem.find(opts.child).outerWidth(true); $(opts.small_elem).find('ul').css('width', l * w + 'px'); $(opts.small_elem).find(opts.child).click(function() { $(this).addClass(opts.state).siblings().removeClass(opts.state); t = $(this).index(); Img(t); updateButtonState(); }); } function Img(i) { $large_elem.find(opts.child).eq(i).fadeIn(0).siblings().fadeOut(0); if($icon_elem.length > 0){ $icon_elem.children().eq(i).addClass(opts.state).siblings().removeClass(opts.state); } if($small_elem.length > 0){ $small_elem.find(opts.child).eq(i).addClass(opts.state).siblings().removeClass(opts.state); var ml = i * w; if (ml <= l_mean * w) { $(opts.small_elem).find('ul').stop().animate({marginLeft: -ml + 'px'}, opts.speed); } else { $(opts.small_elem).find('ul').stop().animate({marginLeft: -(l_mean * w) + 'px'}, opts.speed); } } } // 更新按钮状态函数 function updateButtonState() { if($right_elem.length > 0) { if(t === l - 1) { // 最后一页时禁用右箭头 $right_elem.addClass(opts.disabledClass); } else { $right_elem.removeClass(opts.disabledClass); } } if($left_elem.length > 0) { if(t === 0) { // 第一页时禁用左箭头 $left_elem.addClass(opts.disabledClass); } else { $left_elem.removeClass(opts.disabledClass); } } } if (opts.autoplay) { function auto(){ t++; if (t > l - 1) { t = 0 } Img(t); updateButtonState(); } var timing = setInterval(auto, opts.autotime); $this.hover(function() { clearInterval(timing); }, function() { timing = setInterval(auto, opts.autotime); }) } }) } })(jQuery); $(document).ready(function () { $('#banner').thumbnailImg({ large_elem: '.picBox', small_elem: '.listBox', }); $(".comContent").each(function () { $(".sect_cont li:not(.more)").hover(function () { $(this).addClass("on").siblings().removeClass("on"); $(this).parents(".comContent").find(".sect_grid .grList").eq($(this).index()).show().siblings().hide(); }); }) $(".sf_list li").each(function () { if ($(this).find("span.platform").length>0) { $(this).find("p.sf_desc").addClass("rows2"); } }) HomeScroll('.main_Left', '.main_Right'); $('.cateitem').slides({ large_elem: '.cate_box', right_elem: '.right_arrow', left_elem: '.left_arrow', child: 'dl', autoplay: false, disabledClass: 'grey' }); function HomeScroll(a, b) { function g(){var g=$(window).scrollLeft(),h=$(window).scrollTop(),i=$(document).height(),j=$(window).height(),k=c.height(),l=d.height(),m=k>l?f:e,n=k>l?d:c,o=k>l?(c.offset().left+c.outerWidth(!0)-g)+40:(d.offset().left-c.outerWidth(!0)-g)-30,p=k>l?l:k,q=k>l?k:l,r=parseInt(q-j)-parseInt(p-j);$(a+","+b).removeAttr("style"),j>i||p>q||m>h||p-j+m>=h?n.removeAttr("style"):j>p&&h-m>=r||p>j&&h-m>=q-j?n.attr("style","margin-top:"+r+"px;"):n.attr("style","_margin-top:"+(h-m)+"px;position:fixed;left:"+o+"px;"+(j>p?"top":"bottom")+":0;")}if($(a).length>0&&$(b).length>0){var c=$(a),d=$(b),e=c.offset().top,f=d.offset().top;$(window).resize(g).scroll(g).trigger('resize')} } var swiper = new Swiper('.swiper-container', { pagination: '.swiper-pagination', slidesPerView: 4, paginationClickable: true, spaceBetween: 20, nextButton: '.swiper-button-next', prevButton: '.swiper-button-prev', }); })