PageSourceSearch

https://hellot.net/js/common/jquery.easy-ticker.js

js hellot.net collected 2026-10-01 10:31:28 UTC 4,278 bytes, 208 lines download raw bytes

1/* 
2 * jQuery - Easy Ticker plugin - v2.0
3 * http://www.aakashweb.com/
4 * Copyright 2014, Aakash Chakravarthy
5 * Released under the MIT License.
6 */
7 
8;(function ( $, window, document, undefined ) {
9	
10    var name = "easyTicker",
11        defaults = {
12			direction: 'up',
13			easing: 'swing',
14			speed: 'slow',
15			interval: 2000,
16			height: 'auto',
17			visible: 0,
18			mousePause: 1,
19			controls: {
20				up: '',
21				down: '',
22				toggle: '',
23				playText: 'Play',
24				stopText: 'Stop'
25			}
26        };
27
28    // Constructor
29    function EasyTicker( el, options ) {
30		
31		var s = this;
32		
33        s.opts = $.extend( {}, defaults, options );
34        s.elem = $(el);
35		s.targ = $(el).children(':first-child');
36		s.timer = 0;
37		s.mHover = 0;
38		s.winFocus = 1;
39		
40		init();
41		start();
42		
43		$([window, document]).off('focus.jqet').on('focus.jqet', function(){
44			s.winFocus = 1;
45		}).off('blur.jqet').on('blur.jqet', function(){
46			s.winFocus = 0;
47		});
48		
49		if( s.opts.mousePause == 1 ){
50			s.elem.mouseenter(function(){
51				s.timerTemp = s.timer;
52				stop();
53			}).mouseleave(function(){
54				if( s.timerTemp !== 0 )
55					start();
56			});
57		}
58		
59		$(s.opts.controls.up).on('click', function(e){
60			e.preventDefault();
61			moveDir('up');
62		});
63		
64		$(s.opts.controls.down).on('click', function(e){
65			e.preventDefault();
66			moveDir('down');
67		});
68		
69		$(s.opts.controls.toggle).on('click', function(e){
70			e.preventDefault();
71			if( s.timer == 0 ) start();
72			else stop();
73		});
74		
75		function init(){
76			
77			s.elem.children().css('margin', 0).children().css('margin', 0);
78			
79			s.elem.css({
80				position : 'relative',
81				height: s.opts.height,
82				overflow : 'hidden'
83			});
84			
85			s.targ.css({
86				'position' : 'absolute',
87				'margin' : 0
88			});
89			
90			setInterval( function(){
91				adjHeight();
92			}, 100);
93			
94		} // Init Method
95		
96		function start(){
97			s.timer = setInterval(function(){
98				if( s.winFocus == 1 ){
99					move( s.opts.direction );
100				}
101			}, s.opts.interval);
102
103			$(s.opts.controls.toggle).addClass('et-run').html(s.opts.controls.stopText);
104			
105		} // Start method
106		
107		
108		function stop(){
109			clearInterval( s.timer );
110			s.timer = 0;
111			$(s.opts.controls.toggle).removeClass('et-run').html(s.opts.controls.playText);
112		}// Stop
113		
114		
115		function move( dir ){
116			var sel, eq, appType;
117			
118			if( !s.elem.is(':visible') ) return;
119
120			if( dir == 'up' ){
121				sel = ':first-child';
122				eq = '-=';
123				appType = 'appendTo';
124			}else{
125				sel = ':last-child';
126				eq = '+=';
127				appType = 'prependTo';
128			}
129		
130			var selChild = s.targ.children(sel);
131			var height = selChild.outerHeight();
132			
133			s.targ.stop(true, true).animate({
134				'top': eq + height + "px"
135			}, s.opts.speed, s.opts.easing, function(){
136				
137				selChild.hide()[appType]( s.targ ).fadeIn();
138				s.targ.css('top', 0);
139				
140				adjHeight();
141				
142			});
143		}// Move
144		
145		function moveDir( dir ){
146			stop();
147			if( dir == 'up' ) move('up'); else move('down'); 
148			// start();
149		}
150		
151		function fullHeight(){
152			var height = 0;
153			var tempDisp = s.elem.css('display'); // Get the current el display value
154			
155			s.elem.css('display', 'block');
156					
157			s.targ.children().each(function(){
158				height += $(this).outerHeight();
159			});
160		
161			s.elem.css({
162				'display' : tempDisp,
163				'height' : height
164			});
165		}
166		
167		function visHeight( anim ){
168			var wrapHeight = 0;
169			s.targ.children(':lt(' + s.opts.visible + ')').each(function(){
170				wrapHeight += $(this).outerHeight();
171			});
172			
173			if( anim == 1 ){
174				s.elem.stop(true, true).animate({height: wrapHeight}, s.opts.speed);
175			}else{
176				s.elem.css( 'height', wrapHeight);
177			}
178		}
179		
180		function adjHeight(){
181			if( s.opts.height == 'auto' && s.opts.visible != 0 ){
182				anim = arguments.callee.caller.name == 'init' ? 0 : 1;
183				visHeight( anim );
184			}else if( s.opts.height == 'auto' ){
185				fullHeight();
186			}
187		}
188		
189		return {
190			up: function(){ moveDir('up'); },
191			down: function(){ moveDir('down'); },
192			start: start,
193			stop: stop,
194			options: s.opts
195		};
196		
197    }
198
199    // Attach the object to the DOM
200    $.fn[name] = function ( options ) {
201        return this.each(function () {
202            if (!$.data(this, name)) {
203                $.data(this, name, new EasyTicker( this, options ));
204            }
205        });
206    };
207
208})( jQuery, window, document );

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.