PageSourceSearch

https://arheolog.eu/wp-content/themes/magazinebook/js/jquery.easy-ticker.js?ver=3.1.0

js arheolog.eu collected 2026-10-06 16:16:36 UTC 6,308 bytes, 229 lines download raw bytes

1/* 
2 * jQuery - Easy Ticker plugin - v3.1.0
3 * https://www.aakashweb.com/
4 * Copyright 2020, 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: true,
19            controls: {
20                up: '',
21                down: '',
22                toggle: '',
23                playText: 'Play',
24                stopText: 'Stop'
25            },
26            callbacks: {
27                before: false,
28                after: false
29            }
30        };
31
32    // Constructor
33    function EasyTicker(el, options) {
34        
35        var s = this;
36        
37        s.opts = $.extend({}, defaults, options);
38        s.elem = $(el);
39        s.targ = $(el).children(':first-child');
40        s.timer = 0;
41        s.winFocus = 1;
42        
43        init();
44        start();
45        
46        $([window, document]).off('focus').on('focus', function(){
47            s.winFocus = 1;
48        }).off('blur').on('blur', function(){
49            s.winFocus = 0;
50        });
51        
52        if(s.opts.mousePause){
53            s.elem.mouseenter(function(){
54                s.timerTemp = s.timer;
55                stop();
56            }).mouseleave(function(){
57                if(s.timerTemp !== 0)
58                    start();
59            });
60        }
61        
62        $(s.opts.controls.up).on('click', function(e){
63            e.preventDefault();
64            moveDir('up');
65        });
66        
67        $(s.opts.controls.down).on('click', function(e){
68            e.preventDefault();
69            moveDir('down');
70        });
71        
72        $(s.opts.controls.toggle).on('click', function(e){
73            e.preventDefault();
74            if(s.timer == 0) start();
75            else stop();
76        });
77        
78        function init(){
79            
80            s.elem.children().css('margin', 0).children().css('margin', 0);
81            
82            s.elem.css({
83                position: 'relative',
84                height: s.opts.height,
85                overflow: 'hidden'
86            });
87            
88            s.targ.css({
89                'position': 'absolute',
90                'margin': 0
91            });
92            
93            s.heightTimer = setInterval(function(){
94                adjustHeight(false);
95            }, 100);
96        
97        }
98        
99        function start(){
100            s.timer = setInterval(function(){
101                if(s.winFocus == 1){
102                    move(s.opts.direction);
103                }
104            }, s.opts.interval);
105
106            $(s.opts.controls.toggle).addClass('et-run').html(s.opts.controls.stopText);
107            
108        }
109        
110        function stop(){
111            clearInterval(s.timer);
112            s.timer = 0;
113            $(s.opts.controls.toggle).removeClass('et-run').html(s.opts.controls.playText);
114        }
115        
116        function move(dir){
117            var sel, eq, appType;
118
119            if(!s.elem.is(':visible')) return;
120
121            if(dir == 'up'){
122                sel = ':first-child';
123                eq = '-=';
124                appType = 'appendTo';
125            }else{
126                sel = ':last-child';
127                eq = '+=';
128                appType = 'prependTo';
129            }
130
131            var selChild = s.targ.children(sel);
132            var height = selChild.outerHeight();
133
134            if(typeof s.opts.callbacks.before === 'function'){
135                s.opts.callbacks.before.call(s, s.targ, selChild);
136            }
137
138            s.targ.stop(true, true).animate({
139                'top': eq + height + 'px'
140            }, s.opts.speed, s.opts.easing, function(){
141                
142                selChild.hide()[appType](s.targ).fadeIn();
143                s.targ.css('top', 0);
144                
145                adjustHeight(true);
146                
147                if(typeof s.opts.callbacks.after === 'function'){
148                    s.opts.callbacks.after.call(s, s.targ, selChild);
149                }
150
151            });
152        }
153        
154        function moveDir(dir){
155            stop();
156            if(dir == 'up') move('up'); else move('down');
157            // start();
158        }
159        
160        function setFullHeight(){
161            var height = 0;
162            var tempDisplay = s.elem.css('display'); // Get the current el display value
163            
164            s.elem.css('display', 'block');
165            
166            s.targ.children().each(function(){
167                height += $(this).outerHeight();
168            });
169            
170            s.elem.css({
171                'display': tempDisplay,
172                'height': height
173            });
174        }
175        
176        function setVisibleHeight(animate){
177            var wrapHeight = 0;
178            var visibleItemClass = 'et-item-visible';
179
180            s.targ.children().removeClass(visibleItemClass);
181
182            s.targ.children(':lt(' + s.opts.visible + ')').each(function(){
183                wrapHeight += $(this).outerHeight();
184                $(this).addClass(visibleItemClass);
185            });
186            
187            if(animate){
188                s.elem.stop(true, true).animate({height: wrapHeight}, s.opts.speed);
189            }else{
190                s.elem.css('height', wrapHeight);
191            }
192        }
193        
194        function adjustHeight(animate){
195
196            if(s.opts.height == 'auto'){
197                if(s.opts.visible > 0){
198                    setVisibleHeight(animate);
199                }else{
200                    setFullHeight();
201                }
202            }
203
204            if(!animate){
205                clearInterval(s.heightTimer);
206            }
207
208        }
209        
210        return {
211            up: function(){ moveDir('up'); },
212            down: function(){ moveDir('down'); },
213            start: start,
214            stop: stop,
215            options: s.opts
216        };
217        
218    }
219
220    // Attach the object to the DOM
221    $.fn[name] = function(options) {
222        return this.each(function () {
223            if (!$.data(this, name)) {
224                $.data(this, name, new EasyTicker(this, options));
225            }
226        });
227    };
228
229})(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.