PageSourceSearch

https://www.pesticidenews.cn/images/jquery.tab.js

js pesticidenews.cn collected 2026-10-04 01:23:58 UTC 7,515 bytes, 292 lines download raw bytes

1/**
2 *	jQuery插件
3 *	Author:	[email protected]
4 *	Date  :	2011-02-25
5 *	Params: 
6 *			defaults:{
7					currentClass:当前样式,
8					trigger:触发方式,
9					callBack:回调函数,
10					auto:是否自运行,
11					detay:延迟时间,
12					index:当前位置
13 *			}
14 *	Return: null
15 *  Note  : Tab选项框插件
16 *		     
17 */
18(function($){
19	$.fn.tabBuild=function(options){
20		return $(this).each(function(){
21			var defaults={
22				currentClass:"jQtabone",
23				trigger:"mouseover",
24				callBack:null,
25				auto:false,
26				detay:3000,
27				index:0,
28				timer:null
29			}
30			var params=$.extend(defaults,options);
31			var $this=$(this);
32			var items=$('.jQtabmenu',$this),i=0,l=items.size()-1;
33			var autoTimer,curro=0;
34			
35			items.each(function(){
36				$(this).data('lvl',i);
37				if(i==params.index){
38					$('.jQtabcontent',$this).eq(i).show();
39					$('.jQtabmore',$this).eq(i).show();
40					$(this).addClass(params.currentClass);
41				}else{
42					$('.jQtabcontent',$this).eq(i).hide();
43					$('.jQtabmore',$this).eq(i).hide();
44				}
45				i++;
46				$(this).bind(params.trigger,function(e){
47					//移除自动运行
48					if(params.auto){
49						if(autoTimer) clearInterval(autoTimer);
50					}
51					move($(this).data("lvl"));
52					//清除冒泡
53					if (e.stopPropagation) { 
54						e.stopPropagation(); // for Mozilla and Opera 
55					} 
56					else if (window.event) { 
57						window.event.cancelBubble = true; // for IE 
58					}
59				});
60				$(this).bind("mouseout",function(e){
61					auto();
62				});
63			});
64			//移动播放
65			function move(i){
66				if(params.timer!==null){
67					clearTimeout(params.timer);
68					params.timer=null;
69				}
70				params.timer=setTimeout(function(){
71					//移除上一个效果
72					items.eq(params.index).removeClass(params.currentClass);
73					$('.jQtabcontent',$this).eq(params.index).hide();
74					$('.jQtabmore',$this).eq(params.index).hide();
75					//移至当前位置
76					items.eq(i).addClass(params.currentClass);
77					$('.jQtabcontent',$this).eq(i).show();
78					$('.jQtabmore',$this).eq(i).show();
79					params.index=i;
80					if(params.callBack) params.callBack.call($this,i);
81				},180); 
82				
83			}
84			//自动运行
85			function auto(){
86				if(params.auto){
87					autoTimer=setInterval(function(){
88						curro=(params.index>=l)?0:(params.index+1);
89						move(curro);
90					},params.detay);
91				}else{
92					if(autoTimer) clearInterval(autoTimer);
93				}
94			}
95			auto();
96		}); 
97	};
98	
99	
100	
101
102
103
104
105	$.fn.tabBuild_to=function(options){
106		return $(this).each(function(){
107			var defaults={
108				currentClass:"jQtabone",
109				trigger:"mouseover",
110				callBack:null,
111				auto:false,
112				detay:3000,
113				index:0,
114				timer:null
115			}
116			var params=$.extend(defaults,options);
117			var $this=$(this);
118			var items=$('.tabmenu',$this),i=0,l=items.size()-1;
119			var autoTimer,curro=0;
120			
121			items.each(function(){
122				$(this).data('lvl',i);
123				if(i==params.index){
124					$('.tabcontent',$this).eq(i).show();
125					$('.tabmore',$this).eq(i).show();
126					$(this).addClass(params.currentClass);
127				}else{
128					$('.tabcontent',$this).eq(i).hide();
129					$('.tabmore',$this).eq(i).hide();
130				}
131				i++;
132				$(this).bind(params.trigger,function(e){
133					//移除自动运行
134					if(params.auto){
135						if(autoTimer) clearInterval(autoTimer);
136					}
137					move($(this).data("lvl"));
138					//清除冒泡
139					if (e.stopPropagation) { 
140						e.stopPropagation(); // for Mozilla and Opera 
141					} 
142					else if (window.event) { 
143						window.event.cancelBubble = true; // for IE 
144					}
145				});
146				$(this).bind("mouseout",function(e){
147					if(params.timer!==null){
148						clearTimeout(params.timer);
149						params.timer=null;
150					}
151				});
152			});
153			//移动播放
154			function move(i){
155				if(params.timer!==null){
156					clearTimeout(params.timer);
157					params.timer=null;
158				}
159				params.timer=setTimeout(function(){
160					//移除上一个效果
161					items.eq(params.index).removeClass(params.currentClass);
162					$('.tabcontent',$this).eq(params.index).hide();
163					$('.tabmore',$this).eq(params.index).hide();
164					//移至当前位置
165					items.eq(i).addClass(params.currentClass);
166					$('.tabcontent',$this).eq(i).show();
167					$('.tabmore',$this).eq(i).show();
168					params.index=i;
169					if(params.callBack) params.callBack.call($this,i);
170				},180); 
171				
172			}
173			//自动运行
174			function auto(){
175				if(params.auto){
176					autoTimer=setInterval(function(){
177						curro=(params.index>=l)?0:(params.index+1);
178						move(curro);
179					},params.detay);
180				}else{
181					if(autoTimer) clearInterval(autoTimer);
182				}
183			}
184			auto();
185		}); 
186	};
187	
188	
189	
190	
191	//鼠标移过变换class
192	$.fn.classBuild=function(options){
193		return $(this).each(function(){
194			var defaults={
195				currentClass:"hover",
196				trigger:"mouseover",
197				callBack:null,
198				auto:false,
199				detay:3000,
200				index:0
201			}
202			var params=$.extend(defaults,options);
203			var $this=$(this);
204			var items=$('.menul',$this),i=0,l=items.size()-1;
205			var autoTimer,curro=0;
206			
207			items.each(function(){
208				$(this).data('lvl',i);
209				if(i==params.index){
210					$(this).addClass(params.currentClass);
211				}
212				i++;
213				$(this).bind(params.trigger,function(e){
214					//移除自动运行
215					if(params.auto){
216						if(autoTimer) clearInterval(autoTimer);
217					}
218					move($(this).data("lvl"));
219				});
220			});
221			//移动播放
222			function move(i){
223				//移除上一个效果
224				items.eq(params.index).removeClass(params.currentClass);
225				//移至当前位置
226				items.eq(i).addClass(params.currentClass);
227				params.index=i;
228				if(params.callBack) params.callBack.call($this,i);
229			}
230			//自动运行
231			function auto(){
232				if(params.auto){
233					autoTimer=setInterval(function(){
234						curro=(params.index>=l)?0:(params.index+1);
235						move(curro);
236					},params.detay);
237				}else{
238					if(autoTimer) clearInterval(autoTimer);
239				}
240			}
241			auto();
242		});
243	};
244	
245	//隔行换色
246	$.fn.swapRowColor=function(options){
247		return $(this).each(function(){
248			var defaults={
249				currentClass:"hover",
250				trigger:"click",
251				callBack:null,
252				even:'even',
253				odd:'odd',
254				target:null
255			}
256			var params=$.extend(defaults,options);
257			var $this=$(this);
258			var items=$(params.target,$this),i=1;
259			var autoTimer,curro=0;
260			
261			items.each(function(){
262				(i%2==0)?$(this).addClass(params.even).data('cachs',params.even):$(this).addClass(params.odd).data('cachs',params.odd);
263				i++;
264				$(this).bind(params.trigger,function(e){
265					if(params.callBack) params.callBack.call($this,e);
266				}).hover(function(){
267					$(this).removeClass($(this).data('cachs')).addClass(params.currentClass);
268				},function(){
269					$(this).removeClass(params.currentClass).addClass($(this).data('cachs'));
270				});
271			});
272		});
273	};
274})(jQuery);
275
276/**
277 * @description 设置图片按钮切换效果
278 * @param {String} key  元素钩子
279 * @return {Null} null null
280 */
281function bindImgButtonEvents(key){
282	$(key).each(function(){
283		var src=$(this).attr('src');
284		$(this).data('p',src.replace(src.split('/')[src.split('/').length-1],'')).data('i',src.split('/')[src.split('/').length-1]);
285		$(this).hover(function(){
286			$(this).attr('src',$(this).data('p')+'o.'+$(this).data('i'));
287		},function(){
288			$(this).attr('src',$(this).data('p')+$(this).data('i'));
289		});
290	});
291}
292bindImgButtonEvents('.jQibtn');

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.