PageSourceSearch

https://aast.edu/template/50yrs-slider/js/jquery.mScroll.js

js aast.edu collected 2026-10-01 11:28:51 UTC 15,531 bytes, 567 lines download raw bytes

1/*
2======Example=====
3<style>
4body{margin:20px;}
5#focus{height:200px;width:500px;position:relative;margin:auto;border:5px solid #ccc;}
6.frame{width:100%;height:100%;overflow:hidden;}
7.frame .child{height:100%;float:left;}
8.nav{position:absolute;width:60px;height:20px;overflow:hidden;left:50%;bottom:5px;margin-left:-31px;border:1px solid #aaa;}
9.nav a{float:left;width:20px;height:20px;line-height:20px;font-size:12px;color:#000;text-align:center;background:#f5f5f5;}
10.nav a.now{background:#aaa;color:#fff;}
11.prev{right:30px;bottom:5px;width:20px;height:20px;line-height:20px;text-align:center;background:#f5f5f5;position:absolute;color:#000;font-size:12px;font-family:Arial;}
12.next{right:5px;bottom:5px;width:20px;height:20px;line-height:20px;text-align:center;background:#f5f5f5;position:absolute;color:#000;font-size:12px;font-family:Arial;}
13.title{height:30px;line-height:30px;float:left;}
14.count{height:30px;line-height:30px;float:right;}
15.count b{font-weight:normal;}
16.count em{font-style:normal;}
17</style>
18<div class="focus"><a href="javascript:;" class="prev">&lt;</a><a href="javascript:;" class="next">&gt;</a>
19  <div class="frame">
20	<div class="child" style="background:#faa;" title="c1"></div>
21	<div class="child" style="background:#afa;" title="c2"></div>
22	<div class="child" style="background:#aaf;" title="c3"></div>
23	<div class="child" style="background:#ffa;" title="c4"></div>
24	<div class="child" style="background:#aff;" title="c5"></div>
25  </div>
26  <div class="nav">
27	<i>1</i>
28	<i>2</i>
29	<i>3</i>
30	<i>4</i>
31	<i>5</i>
32  </div>
33  <div class="title"></div>
34  <div class="count"><b></b>/<em></em></div>
35</div>
36<script>
37$('.focus .frame').mScroll({
38auto : 1, // start automatically
39direction : "h", //scrolling direction, h horizontal, v vertical
40dtype : "left", //forward and reverse
41isfocus : 0, //whether as focus image
42minsize : [
43{
44width:0,
45size:1
46},
47{
48width:1000,
49size:4
50}
51								],                 //minimum amount
52speed : 500, //scrolling speed
53easing : "", //buffer type
54delay : 5000, //Auto scroll interval
55nav : ".focus .nav i", //navigation button
56event : "click", //Navigation button event type
57scrollnav : 0, //navigation scroll
58nav_direction : "h", //navigation direction, h horizontal, v vertical
59prev : ".focus .prev", //previous
60next : ".focus .next", //next
61index : ".focus .index", //current serial number
62count : ".focus .count b", //total
63title : ".focus .count em", //title
64arrow : 1, //whether to reverse
65cycle : 1, //whether to cycle
66mousestop : 1, //mouse-in to stop
67mousewheel : 0, //Enable scroll wheel event
68touch : 0, //Enable touch event
69callback : function(idx){} //callback function
70});
71</script>
72===============
73*/
74//Variable explanation
75/*
76f = object body frame
77s= frame Scroll element inside
78c=s in Child element 
79n=navigation child element
80np=navigation parent element
81ns=Scroll element within navigation
82w,h=roll distance
83ww,hh=original total length
84The original number of child elements in size=s
85iv,ti=timer
86sw=control switch
87idx=current serial number
88Child element margins within cm=s
89*/
90(function($) {
91	$.fn.mScroll = function(options) {
92		var opts = $.extend({},$.fn.mScroll.defaults,options);
93		this.each(function(){
94			//Initialize variables
95			var f = $(this);
96			var s,c,n,np,ns,w,ww,h,hh,wn,hn,size,iv,ti,sw=1,sw1=0,idx=0,ids=0,idx1=0,cm=0;
97			//var tt=5000;
98			
99			//Control judgment initialization
100			if(opts.cycle==0){opts.auto=0;}
101			if(opts.touch==1){
102				opts.minsize=1;
103				opts.mousestop=0;
104				opts.mousewheel=0;
105			}
106			
107			function getMinsize(){				
108				if(typeof(opts.minsize)=="object"){
109					var minsize=0;//var minsize=opts.minsize[0].size;
110					for(var i=0;i<opts.minsize.length;i++){
111						var mz=new Object(opts.minsize[i]);
112						if($(window).width()>mz.width){
113							minsize=mz.size;
114						}
115					}
116					return minsize;
117				}
118				else{
119					return opts.minsize;
120				}
121			}
122			
123			if(f.children().size==1){return false;}
124			
125			//Generate scroll structure, assign s
126			if(f.children().is("ul") && f.children().length>1 && !f.children().hasClass("child")){
127				f.children().addClass("scroll");
128			}
129			else{
130				f.children().wrapAll("<div class='scroll' style='height:100%;'></div>");
131			}
132			s = f.find(".scroll");
133			
134			//initialize size
135			size=s.children().length;			
136			
137			
138			//Create c image, assign c
139			if(opts.cycle==1 && size>getMinsize()){s.append(s.html());}
140			c = s.children();
141			
142			//Initialize navigation
143			n = $(opts.nav);
144			if(opts.scrollnav){
145				wn = parseInt(n.outerWidth()+parseInt(n.css("margin-left"))+parseInt(n.css("margin-right")));
146				hn = parseInt(n.outerHeight()+parseInt(n.css("margin-top"))+parseInt(n.css("margin-bottom")));
147				np= $(opts.nav).parent();
148				n.wrapAll("<div class='scroll' style='height:100%;'></div>");
149				n.width(wn);
150				ns=np.find(".scroll");
151				if(opts.nav_direction=="h"){
152					ns.width(n.length*wn);
153					np.stop().animate({scrollLeft:0},100);
154				}
155				if(opts.nav_direction=="v"){
156					ns.height(n.length*hn);
157					np.stop().animate({scrollTop:0},100);
158				}
159			}
160			n.eq(0).addClass("now");
161			if(opts.cycle!==1){$(opts.prev).css("opacity","0.3");}
162			
163			//Initialize the size of each element
164			function setWH(){
165				if(opts.direction=="h"){
166					setH();
167					s.width(100000);
168					s.height("100%");
169					f.stop().animate({scrollLeft:0},100);
170				}
171				if(opts.direction=="v"){		
172					setV();		
173					s.height(100000);				
174					f.stop().animate({scrollTop:0},100);
175				}
176			}
177			setWH();
178			
179			//size setting function
180			function setH(){
181				f.css("width","");
182				c.css("width","");
183				cm=parseInt(c.last().css("margin-left"))+parseInt(c.last().css("margin-right"));
184				if(cm==0){
185					w = Math.floor(f.width()/getMinsize());
186					if(opts.isfocus!=1){
187						f.width(w*getMinsize());
188					}
189					else{
190						f.width("auto");
191					}
192					c.width(w);
193				}
194				else{
195					//if(opts.isfocus!=1){
196						w=Math.floor((f.width()+cm)/4);
197						c.width(w-cm);
198						f.width(w*getMinsize()-cm);
199					//}
200				}
201				ww=c.length*w;
202			}
203			function setV(){
204				f.height("auto");
205				c.css("height","");
206				cm=parseInt(c.css("margin-top"))+parseInt(c.css("margin-bottom"));
207				if(cm==0){
208					h = Math.floor(f.height()/getMinsize());
209					if(opts.isfocus!=1){
210						f.height(h*getMinsize());
211					}
212					else{
213						f.height("auto");
214					}
215					c.height(h);
216				}
217				else{
218					if(opts.isfocus!=1){
219						h=c.height()+cm;
220						f.height(h*getMinsize()-cm);
221					}
222				}
223				hh=c.length*h;
224			}
225			
226			//set title
227			$(opts.count).text(size);
228			$(opts.title).text(c.eq(0).attr("title"));
229			$(opts.index).text(1);
230			
231			//Focus map adaptive
232			$(window).resize(function(){
233				if(f.is(":visible")){rs();}
234			});
235			rs();
236			
237			//adaptive
238			function rs(){
239				sw==0;
240				clearTimeout(ti);
241				if(getMinsize()!=0){
242					if(opts.direction=="h"){
243						setH();
244						f.stop().scrollLeft(idx*w);
245					}
246					if(opts.direction=="v"){
247						setV();
248						f.stop().scrollTop(idx*h);
249					}
250					ti=setTimeout(function(){
251						sw=1;
252					},500);
253					//Resume rotation
254					if(opts.direction=="h"){
255						if(s.width()!==100000){
256							setWH();
257						}
258					}
259					if(opts.direction=="v"){
260						if(s.height()!==100000){
261							setWH();
262						}
263					}
264					if(size<=getMinsize()){
265						s.css({margin:"auto",width:w*size});
266						$(opts.prev).hide();
267						$(opts.next).hide();
268					}
269					else{
270						if(opts.direction=="h"){
271							s.removeAttr("style").width(100000);
272						}
273						if(opts.direction=="v"){
274							s.removeAttr("style").height(100000);
275						}
276						$(opts.prev).show();
277						$(opts.next).show();
278					}
279				}
280				else{
281					//Cancel carousel
282					f.removeAttr("style");
283					s.removeAttr("style");					
284				}
285				
286			}
287			
288			//Determine whether the number of c satisfies the start condition
289			if(size>getMinsize()){
290			
291			//start automatically
292			if(opts.auto==1){
293				run();
294			}
295			
296			function run(){				
297				var t=opts.delay;
298				if(idx==0){
299					//t=tt;
300				}				
301				clearTimeout(iv);
302				iv=setTimeout(function(){
303					move(opts.dtype);
304					run();
305				},t);
306			}
307			
308			//execute callback function
309			if(typeof(opts.callback)=="function"){
310				opts.callback(idx);
311			}
312			
313			//-------------start-------------//
314			//scroll function
315			function move(act,speed){
316				if(!speed){speed=opts.speed;}
317				if(sw==1){
318					sw=0;
319					if(act=="left"){
320						if(opts.cycle!=1){
321							if(idx+getMinsize()<size){
322								idx++;ids++;
323								if(opts.direction=="h"){
324									f.animate({scrollLeft:ids*w},speed,opts.easing,function(){sw=1;});
325								}
326								if(opts.direction=="v"){
327									f.animate({scrollTop:ids*h},speed,opts.easing,function(){sw=1;});
328								}
329								$(opts.prev).css("opacity","1");
330								if(idx+getMinsize()==size){
331									$(opts.next).css("opacity","0.3");
332								}
333							}
334							else{
335								sw=1;								
336							}							
337						}
338						if(opts.cycle==1){	
339							if(idx==size-1){idx=0;}
340							else{idx++;}
341							ids++;
342							if(opts.direction=="h"){
343								f.animate({scrollLeft:ids*w},speed,opts.easing,function(){									
344									if(f.scrollLeft()>=ww*0.5){f.scrollLeft(0);ids=0;}
345									sw=1;
346								});
347							}
348							if(opts.direction=="v"){
349								f.animate({scrollTop:ids*h},speed,opts.easing,function(){
350									if(f.scrollTop()>=hh*0.5){f.scrollTop(0);ids=0;}
351									sw=1;
352								});
353							}
354							
355						}
356					}
357					if(act=="right"){
358						if(opts.cycle!=1){
359							if(idx>0){
360								idx--;ids--;
361								if(opts.direction=="h"){
362									f.animate({scrollLeft:ids*w},speed,opts.easing,function(){sw=1;});
363								}
364								if(opts.direction=="v"){
365									f.animate({scrollTop:ids*h},speed,opts.easing,function(){sw=1;});
366								}
367								$(opts.next).css("opacity","1");
368								if(idx==0){
369									$(opts.prev).css("opacity","0.3");									
370								}
371							}
372							else{
373								sw=1;
374							}
375						}
376						if(opts.cycle==1){
377							if(idx==0){idx=size-1;ids=size;}
378							else{idx--;}
379							ids--;
380							if(opts.direction=="h"){
381								if(f.scrollLeft()<=0){f.scrollLeft(ww*0.5);}
382								f.animate({scrollLeft:ids*w},speed,opts.easing,function(){sw=1;});
383							}
384							if(opts.direction=="v"){
385								if(f.scrollTop()<=0){f.scrollTop(hh*0.5);}
386								f.animate({scrollTop:ids*h},speed,opts.easing,function(){sw=1;});
387							}
388						}
389					}						
390					n.removeClass("now");
391					n.eq(idx).addClass("now");
392					$(opts.title).text(c.eq(idx).attr("title"));
393					$(opts.index).text(idx+1);					
394					if(opts.scrollnav){autonav();}
395					if(typeof(opts.callback)=="function"){
396						opts.callback(idx);//Perform custom animation
397					}
398				}
399			}
400			//Left and right buttons
401			if(opts.prev){
402				$(opts.prev).hover(function(){sw=1;});
403				$(opts.prev).unbind("click");
404				$(opts.prev).click(function(){
405					if(opts.arrow==1){move("right");}
406					else{move("left");}
407					if(opts.auto){
408						//clearInterval(iv);
409						//iv = window.setInterval(function(){move(opts.dtype);},opts.delay);
410						run();
411					}
412					if(idx1>0){idx1--;c.eq(idx1).click();}
413					
414				});
415				
416			}
417			if(opts.next){
418				$(opts.next).hover(function(){sw=1;});
419				$(opts.next).unbind("click");
420				$(opts.next).click(function(){
421					if(opts.arrow==1){move("left");}
422					else{move("right");}
423					if(opts.auto){
424						//clearInterval(iv);
425						//iv = window.setInterval(function(){move(opts.dtype);},opts.delay);
426						run();
427					}
428					if(idx1<size-1){idx1++;c.eq(idx1).click();}
429					
430				});
431			}
432			c.click(function(){
433				idx1=$(this).index();
434			});
435			
436			//Navigation overflow section sliding display
437			
438			//Navigation Click
439			
440			//mouse wheel
441			if(opts.mousewheel){
442				f.mousewheel(function(event,delta,deltaX,deltaY){
443					if(delta<0){
444						if(opts.arrow==1){move("left");}
445						else{move("right");}
446					}
447					else{
448						if(opts.arrow==1){move("right");}
449						else{move("left");}
450					}
451					event.stopPropagation();
452					event.preventDefault();
453				});
454			}
455			//mouse swipe stop
456			if(opts.mousestop && !opts.mousewheel){
457				f.hover(function(){sw=0},function(){sw=1});
458			}
459			
460			//touch control
461			if(opts.touch && document.addEventListener){
462				f.attr("id","frame"+f.offset().top);
463				var touch,p0,fl,m;
464				var obj1=document.getElementById(f.attr("id"));
465				var start,end="";
466				
467				obj1.addEventListener('touchstart',function(event){
468					if(sw==1){
469						sw1=1;
470						touch = event.targetTouches[0];
471						if(opts.direction=="h"){
472							p0=touch.screenX;
473							start=touch.screenX;
474							fl=f.scrollLeft();
475							m=w;
476						}
477						if(opts.direction=="v"){
478							p0=touch.screenY;
479							start=touch.screenY;
480							fl=f.scrollTop();
481							m=h;
482						}						
483						if(opts.auto){
484							clearInterval(iv);
485						}
486					}
487				},false);
488				obj1.addEventListener('touchmove',function(event){
489					if(sw==1 && sw1==1){
490						touch = event.targetTouches[0];
491						if(opts.direction=="h"){
492							f.scrollLeft(fl-(touch.screenX-p0));
493							end=touch.screenX;
494							if(Math.abs(touch.screenX-p0)>$(window).width()*0.05){
495								event.preventDefault();//Block browser default events
496							}
497						}
498						if(opts.direction=="v"){
499							f.scrollTop(fl-(touch.screenY-p0));
500							end=touch.screenY;
501							if(Math.abs(touch.screenY-p0)>f.height()*0.05){
502								
503							}
504							event.preventDefault();//Block browser default events
505						}
506					}
507				},false);
508				obj1.addEventListener('touchend',function(event){
509					if(sw==1 && end!=""){
510						if(end-start<m*-0.1){
511							move("left",(m-Math.abs(end-start))/m*opts.speed);
512						}
513						else if(end-start>m*0.1){
514							move("right",(m-Math.abs(end-start))/m*opts.speed);
515						}
516						else{
517							sw=0;						
518							if(opts.direction=="h"){
519								f.stop().animate({scrollLeft:ids*m},opts.speed*0.5,opts.easing,function(){sw=1;});
520							}
521							else{
522								f.stop().animate({scrollTop:ids*m},opts.speed*0.5,opts.easing,function(){sw=1;});
523							}
524							
525						}
526						if(opts.auto){
527							//clearInterval(iv);
528							//iv = window.setInterval(function(){move(opts.dtype);},opts.delay);
529							run();
530						}
531						sw1=0;
532						end="";
533					}
534				},false);
535			}
536				
537			//-------------end-------------//
538			}
539		})
540	};
541	$.fn.mScroll.defaults = {
542		auto : 1,                           // start automatically
543		direction : "h",                   //scrolling direction, h horizontal, v vertical
544		dtype : "left",                   //forward and reverse
545		isfocus : 0,                     //whether as focus image
546		minsize : 1,                    //minimum size
547		speed : 500,                   //scrolling speed
548		easing : "",                  //buffer type
549		delay : 5000,                //Auto scroll interval
550		nav : null,                 //navigation button
551		event : "click",           //navigation event
552				scrollnav : 0,    //navigation scroll
553		navspeed : 500,                         //navigation scrolling speed
554			nav_direction : "h",               //navigation direction, h horizontal, v vertical
555		prev : null,                          //previous
556		next : null,                         //next
557		index : null,                       //current serial number
558		count : null,                      //total
559		title : null,                     //title
560		arrow : 1,                       //whether to reverse
561		cycle : 1,                      //whether to cycle
562		mousestop : 1,                 //mouse-in to stop
563		mousewheel : 0,               //Enable scroll wheel event
564		touch : 0,                   //Enable touch event
565		callback : function(idx){}  // callback function
566	}
567})(jQuery);

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.