PageSourceSearch

https://go-for-broke.net/skin/js/jquery.sgallery.js

js go-for-broke.net collected 2026-10-06 18:41:56 UTC 5,611 bytes, 206 lines download raw bytes

1/*
2 *	sGallery 1.0 - simple gallery with jQuery
3 *	made by bujichong 2009-11-25
4 *	作者:不羁虫  2009-11-25
5 * http://hi.baidu.com/bujichong/
6 *	欢迎交流转载,但请尊重作者劳动成果,标明插件来源及作者
7 */
8
9(function ($) {
10$.fn.sGallery = function (o) {
11    return  new $sG(this, o);
12			//alert('do');
13    };
14
15	var settings = {
16		thumbObj:null,//预览对象
17		titleObj:null,//标题
18		botLast:null,//按钮上一个
19		botNext:null,//按钮下一个
20		thumbNowClass:'now',//预览对象当前的class,默认为now
21		slideTime:800,//平滑过渡时间
22		autoChange:true,//是否自动切换
23		changeTime:5000,//自动切换时间
24		delayTime:100//鼠标经过时反应的延迟时间
25	};
26
27 $.sGalleryLong = function(e, o) {
28    this.options = $.extend({}, settings, o || {});
29	var _self = $(e);
30	var set = this.options;
31	var thumb;
32	var size = _self.size();
33	var nowIndex = 0; //定义全局指针
34	var index;//定义全局指针
35	var startRun;//预定义自动运行参数
36	var delayRun;//预定义延迟运行参数
37
38//初始化
39	_self.eq(0).show();
40
41//主切换函数
42function fadeAB () {
43	if (nowIndex != index) {
44		if (set.thumbObj!=null) {
45		$(set.thumbObj).removeClass().eq(index).addClass(set.thumbNowClass);}
46		_self.eq(nowIndex).stop(false,true).fadeOut(set.slideTime);
47		_self.eq(index).stop(true,true).fadeIn(set.slideTime);
48		$(set.titleObj).eq(nowIndex).hide();//新增加title
49		$(set.titleObj).eq(index).show();//新增加title
50		nowIndex = index;
51		if (set.autoChange==true) {
52		clearInterval(startRun);//重置自动切换函数
53		startRun = setInterval(runNext,set.changeTime);}
54		}
55}
56
57//切换到下一个
58function runNext() {
59	index =  (nowIndex+1)%size;
60	fadeAB();
61}
62
63//点击任一图片
64	if (set.thumbObj!=null) {
65	thumb = $(set.thumbObj);
66//初始化
67	thumb.eq(0).addClass(set.thumbNowClass);
68		thumb.bind("mousemove",function(event){
69			index = thumb.index($(this));
70			fadeAB();
71			delayRun = setTimeout(fadeAB,set.delayTime);
72			clearTimeout(delayRun);
73			event.stopPropagation();
74		})
75	}
76
77//点击上一个
78	if (set.botNext!=null) {
79		var botNext = $(set.botNext);
80		botNext.mousemove(function () {
81			runNext();
82			return false;
83		});
84	}
85
86//点击下一个
87	if (set.botLast!=null) {
88		var botLast = $(set.botLast);
89		botLast.mousemove(function () {
90			index = (nowIndex+size-1)%size;
91			fadeAB();
92			return false;
93	});
94	}
95
96//自动运行
97	if (set.autoChange==true) {
98	startRun = setInterval(runNext,set.changeTime);
99	}
100
101}
102
103var $sG = $.sGalleryLong;
104
105})(jQuery);
106
107function slide(Name,Class,Width,Height,fun){
108	$(Name).width(Width);
109	$(Name).height(Height);
110	
111	if(fun == true){
112		$(Name).append('<div class="title-bg"></div><div class="title"></div><div class="change"></div>')
113		var atr = $(Name+' div.changeDiv a');
114		var sum = atr.length;
115		for(i=1;i<=sum;i++){
116			var title = atr.eq(i-1).attr("title");
117			var href = atr.eq(i-1).attr("href");
118			$(Name+' .change').append('<i>'+i+'</i>');
119			$(Name+' .title').append('<a href="'+href+'">'+title+'</a>');
120		}
121		$(Name+' .change i').eq(0).addClass('cur');
122	}
123	$(Name+' div.changeDiv a').sGallery({//对象指向层,层内包含图片及标题
124		titleObj:Name+' div.title a',
125		thumbObj:Name+' .change i',
126		thumbNowClass:Class
127	});
128	$(Name+" .title-bg").width(Width);
129}
130
131//缩略图
132jQuery.fn.LoadImage=function(scaling,width,height,loadpic){
133    if(loadpic==null)loadpic="../images/msg_img/loading.gif";
134return this.each(function(){
135   var t=$(this);
136   var src=$(this).attr("src")
137   var img=new Image();
138   img.src=src;
139   //自动缩放图片
140   var autoScaling=function(){
141    if(scaling){
142     if(img.width>0 && img.height>0){ 
143           if(img.width/img.height>=width/height){ 
144               if(img.width>width){ 
145                   t.width(width); 
146                   t.height((img.height*width)/img.width); 
147               }else{ 
148                   t.width(img.width); 
149                   t.height(img.height); 
150               } 
151           } 
152           else{ 
153               if(img.height>height){ 
154                   t.height(height); 
155                   t.width((img.width*height)/img.height); 
156               }else{ 
157                   t.width(img.width); 
158                   t.height(img.height); 
159               } 
160           } 
161       } 
162    } 
163   }
164   //处理ff下会自动读取缓存图片
165   if(img.complete){
166    autoScaling();
167      return;
168   }
169   $(this).attr("src","");
170   var loading=$("<img alt=\"加载中...\" title=\"图片加载中...\" src=\""+loadpic+"\" />");
171  
172   t.hide();
173   t.after(loading);
174   $(img).load(function(){
175    autoScaling();
176    loading.remove();
177    t.attr("src",this.src);
178    t.show();
179	//$('.photo_prev a,.photo_next a').height($('#big-pic img').height());
180   });
181  });
182}
183
184//向上滚动代码
185function startmarquee(elementID,h,n,speed,delay){
186 var t = null;
187 var box = '#' + elementID;
188 $(box).hover(function(){
189  clearInterval(t);
190  }, function(){
191  t = setInterval(start,delay);
192 }).trigger('mouseout');
193 function start(){
194  $(box).children('ul:first').animate({marginTop: '-='+h},speed,function(){
195   $(this).css({marginTop:'0'}).find('li').slice(0,n).appendTo(this);
196  })
197 }
198}
199
200//TAB切换
201function SwapTab(name,title,content,Sub,cur){
202  $(name+' '+title).mouseover(function(){
203	  $(this).addClass(cur).siblings().removeClass(cur);
204	  $(content+" > "+Sub).eq($(name+' '+title).index(this)).show().siblings().hide();
205  });
206}

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.