PageSourceSearch

https://www.pesticidenews.cn/zgny/images/bclmnr/jquery.SuperSlide.js

js pesticidenews.cn collected 2026-10-04 01:23:56 UTC 8,910 bytes, 176 lines download raw bytes

1/* SuperSlide1.2 --  Copyright ©2012 大话主席 
2 */
3(function($){
4	$.fn.slide=function(options){
5		$.fn.slide.deflunt={
6		effect : "fade", //效果 || fade:渐显; || top:上滚动;|| left:左滚动;|| topLoop:上循环滚动;|| leftLoop:左循环滚动;|| topMarquee:上无缝循环滚动;|| leftMarquee:左无缝循环滚动;
7		autoPlay:false, //自动运行
8		delayTime : 500, //效果持续时间
9		interTime : 2500,//自动运行间隔。当effect为无缝滚动的时候,相当于运行速度。
10		defaultIndex : 0,//默认的当前位置索引。0是第一个
11		titCell:".hd li",//导航元素
12		mainCell:".bd",//内容元素的父层对象
13		trigger: "mouseover",//触发方式 || mouseover:鼠标移过触发;|| click:鼠标点击触发;
14		scroll:1,//每次滚动个数。
15		vis:1,//visible,可视范围个数,当内容个数少于可视个数的时候,不执行效果。
16		titOnClassName:"on",//当前位置自动增加的class名称
17		autoPage:false,//系统自动分页,当为true时,titCell则为导航元素父层对象,同时系统会在titCell里面自动插入分页li元素(1.2版本新增)
18		prevCell:".prev",//前一个按钮元素。
19		nextCell:".next"//后一个按钮元素。
20		};
21
22		return this.each(function() {
23			var opts = $.extend({},$.fn.slide.deflunt,options);
24			var index=opts.defaultIndex;
25			var prevBtn = $(opts.prevCell, $(this));
26			var nextBtn = $(opts.nextCell, $(this));
27			var navObj = $(opts.titCell, $(this));//导航子元素结合
28			var navObjSize = navObj.size();
29			var conBox = $(opts.mainCell , $(this));//内容元素父层对象
30			var conBoxSize=conBox.children().size();
31			var slideH=0;
32			var slideW=0;
33			var selfW=0;
34			var selfH=0;
35			var autoPlay = opts.autoPlay;
36			var inter=null;//setInterval名称 
37			var oldIndex = index;
38
39			if(conBoxSize<opts.vis) return; //当内容个数少于可视个数,不执行效果。
40
41			//处理分页
42			if( navObjSize==0 )navObjSize=conBoxSize;
43			if( opts.autoPage ){
44				var tempS = conBoxSize-opts.vis;
45				navObjSize=1+parseInt(tempS%opts.scroll!=0?(tempS/opts.scroll+1):(tempS/opts.scroll)); 
46				navObj.html(""); 
47				for( var i=0; i<navObjSize; i++ ){ navObj.append("<li>"+(i+1)+"</li>") }
48				var navObj = $("li", navObj);//重置导航子元素对象
49			}
50
51			conBox.children().each(function(){ //取最大值
52				if( $(this).width()>selfW ){ selfW=$(this).width(); slideW=$(this).outerWidth(true);  }
53				if( $(this).height()>selfH ){ selfH=$(this).height(); slideH=$(this).outerHeight(true);  }
54			});
55
56			switch(opts.effect)
57			{
58				case "top": conBox.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; height:'+opts.vis*slideH+'px"></div>').css( { "position":"relative","padding":"0","margin":"0"}).children().css( {"height":selfH} ); break;
59				case "left": conBox.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; width:'+opts.vis*slideW+'px"></div>').css( { "width":conBoxSize*slideW,"position":"relative","overflow":"hidden","padding":"0","margin":"0"}).children().css( {"float":"left","width":selfW} ); break;
60				case "leftLoop":
61				case "leftMarquee":
62					conBox.children().clone().appendTo(conBox).clone().prependTo(conBox); 
63					conBox.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; width:'+opts.vis*slideW+'px"></div>').css( { "width":conBoxSize*slideW*3,"position":"relative","overflow":"hidden","padding":"0","margin":"0","left":-conBoxSize*slideW}).children().css( {"float":"left","width":selfW}  ); break;
64				case "topLoop":
65				case "topMarquee":
66					conBox.children().clone().appendTo(conBox).clone().prependTo(conBox); 
67					conBox.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; height:'+opts.vis*slideH+'px"></div>').css( { "height":conBoxSize*slideH*3,"position":"relative","padding":"0","margin":"0","top":-conBoxSize*slideH}).children().css( {"height":selfH} ); break;
68			}
69
70			//效果函数
71			var doPlay=function(){
72				switch(opts.effect)
73				{
74					case "fade": case "top": case "left": if ( index >= navObjSize) { index = 0; } else if( index < 0) { index = navObjSize-1; } break;
75					case "leftMarquee":case "topMarquee": if ( index>= 2) { index=1; } else if( index<0) { index = 0; } break;
76					case "leftLoop": case "topLoop":
77						var tempNum = index - oldIndex; 
78						if( navObjSize>2 && tempNum==-(navObjSize-1) ) tempNum=1;
79						if( navObjSize>2 && tempNum==(navObjSize-1) ) tempNum=-1;
80						var scrollNum = Math.abs( tempNum*opts.scroll );
81						if ( index >= navObjSize) { index = 0; } else if( index < 0) { index = navObjSize-1; }
82					break;
83				}
84				switch (opts.effect)
85				{
86					case "fade":conBox.children().stop(true,true).eq(index).fadeIn(opts.delayTime).siblings().hide();break;
87					case "top":conBox.stop(true,true).animate({"top":-index*opts.scroll*slideH},opts.delayTime);break;
88					case "left":conBox.stop(true,true).animate({"left":-index*opts.scroll*slideW},opts.delayTime);break;
89					case "leftLoop":
90						if(tempNum<0 ){
91								conBox.stop(true,true).animate({"left":-(conBoxSize-scrollNum )*slideW},opts.delayTime,function(){
92								for(var i=0;i<scrollNum;i++){ conBox.children().last().prependTo(conBox); }
93								conBox.css("left",-conBoxSize*slideW);
94							});
95						}
96						else{
97							conBox.stop(true,true).animate({"left":-( conBoxSize + scrollNum)*slideW},opts.delayTime,function(){
98								for(var i=0;i<scrollNum;i++){ conBox.children().first().appendTo(conBox); }
99								conBox.css("left",-conBoxSize*slideW);
100							});
101						}break;// leftLoop end
102
103					case "topLoop":
104						if(tempNum<0 ){
105								conBox.stop(true,true).animate({"top":-(conBoxSize-scrollNum )*slideH},opts.delayTime,function(){
106								for(var i=0;i<scrollNum;i++){ conBox.children().last().prependTo(conBox); }
107								conBox.css("top",-conBoxSize*slideH);
108							});
109						}
110						else{
111							conBox.stop(true,true).animate({"top":-( conBoxSize + scrollNum)*slideH},opts.delayTime,function(){
112								for(var i=0;i<scrollNum;i++){ conBox.children().first().appendTo(conBox); }
113								conBox.css("top",-conBoxSize*slideH);
114							});
115						}break;//topLoop end
116
117					case "leftMarquee":
118						var tempLeft = conBox.css("left").replace("px",""); 
119
120						if(index==0 ){
121								conBox.animate({"left":++tempLeft},0,function(){
122									if( conBox.css("left").replace("px","")>= 0){ for(var i=0;i<conBoxSize;i++){ conBox.children().last().prependTo(conBox); }conBox.css("left",-conBoxSize*slideW);}
123								});
124						}
125						else{
126								conBox.animate({"left":--tempLeft},0,function(){
127									if(  conBox.css("left").replace("px","")<= -conBoxSize*slideW*2){ for(var i=0;i<conBoxSize;i++){ conBox.children().first().appendTo(conBox); }conBox.css("left",-conBoxSize*slideW);}
128								});
129						}break;// leftMarquee end
130
131						case "topMarquee":
132						var tempTop = conBox.css("top").replace("px",""); 
133							if(index==0 ){
134									conBox.animate({"top":++tempTop},0,function(){
135										if( conBox.css("top").replace("px","") >= 0){ for(var i=0;i<conBoxSize;i++){ conBox.children().last().prependTo(conBox); }conBox.css("top",-conBoxSize*slideH);}
136									});
137							}
138							else{
139									conBox.animate({"top":--tempTop},0,function(){
140										if( conBox.css("top").replace("px","")<= -conBoxSize*slideH*2){ for(var i=0;i<conBoxSize;i++){ conBox.children().first().appendTo(conBox); }conBox.css("top",-conBoxSize*slideH);}
141									});
142							}break;// topMarquee end
143
144
145				}//switch end
146					navObj.removeClass(opts.titOnClassName).eq(index).addClass(opts.titOnClassName);
147					oldIndex=index;
148			};
149			//初始化执行
150			doPlay();
151
152			//自动播放
153			if (autoPlay) {
154					if( opts.effect=="leftMarquee" || opts.effect=="topMarquee"  ){
155						index++; inter = setInterval(doPlay, opts.interTime);
156						conBox.hover(function(){if(autoPlay){clearInterval(inter); }},function(){if(autoPlay){clearInterval(inter);inter = setInterval(doPlay, opts.interTime);}});
157					}else{
158						 inter=setInterval(function(){index++; doPlay() }, opts.interTime); 
159						$(this).hover(function(){if(autoPlay){clearInterval(inter); }},function(){if(autoPlay){clearInterval(inter); inter=setInterval(function(){index++; doPlay() }, opts.interTime); }});
160					}
161			}
162
163			//鼠标事件
164			var mst;
165			if(opts.trigger=="mouseover"){
166				navObj.hover(function(){ clearTimeout(mst); index=navObj.index(this); mst = window.setTimeout(doPlay,200); }, function(){ if(!mst)clearTimeout(mst); });
167			}else{ navObj.click(function(){index=navObj.index(this);  doPlay(); })  }
168			nextBtn.click(function(){ index++; doPlay(); });
169			prevBtn.click(function(){  index--; doPlay(); });
170
171    	});//each End
172
173	};//slide End
174
175})(jQuery);
176

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.