PageSourceSearch

https://dystonia-bb.org/wp-content/themes/news-store/assets/js/jquery.jConveyorTicker.js?ver=1.1.0

js dystonia-bb.org collected 2026-10-07 15:40:14 UTC 8,096 bytes, 239 lines download raw bytes

1/*!
2 * jQuery Conveyor Ticker (jConveyorTicker)
3 * Description: jQuery plugin to create simple horizontal conveyor belt animated tickers.
4 *
5 * Copyright (c) 2017 Luis Luz - UXD Lda
6 *
7 * Licensed under the MIT license:
8 *   http://www.opensource.org/licenses/mit-license.php
9 *
10 * Project home:
11 *   https://github.com/lluz/jquery-conveyor-ticker
12 *
13 * Version:  1.1.0
14 *
15 */
16
17(function($, window, document, undefined) {
18
19    $.fn.jConveyorTicker = function(options) {
20        if ( this === undefined || this.length === 0 ) {
21            console.log('jquery.jConveyorTicker() INITIALIZATION ERROR: You need to select one or more elements. See documentation form more information.');
22            return false;
23        }
24
25        var settings = {
26            anim_duration: 200,
27            reverse_elm: false,
28            force_loop: false,
29            start_paused: false,
30        };
31        var cycle_duration = settings.anim_duration;
32        var reverse_commute = settings.reverse_elm;
33        var initialization_forced = settings.force_loop;
34        var paused_oninit = settings.start_paused;
35        
36        if (options) {
37            if ( options.anim_duration !== undefined ) {
38                cycle_duration = options.anim_duration;
39            }
40
41            if ( options.reverse_elm !== undefined ) {
42                reverse_commute = options.reverse_elm;
43            }
44
45            if ( options.force_loop !== undefined ) {
46                initialization_forced = options.force_loop;
47            }
48
49            if ( options.start_paused !== undefined ) {
50                paused_oninit = options.start_paused;
51            }
52
53            $.extend(settings, options);
54        }
55
56        var $self = $(this);
57        var $list = $self.children('ul');
58
59        var output = {
60
61            'init': function(){
62
63                $self.each(function(){
64
65                    output.destroy();
66
67                    $list
68                    .css({
69                        'margin': '0',
70                        'padding': '0',
71                        'list-style': 'none'
72                    })
73                    .children('li')
74                    .css({
75                        'display': 'inline-block'
76                    });
77        
78                    var $listRawWidth = $list.width();
79                    var $parentWidth = $list.parent().width();
80                    var $parent1stThreshold = ($parentWidth / 2) - 20;
81        
82                    $list
83                    .removeAttr('style')
84                    .children('li')
85                    .removeAttr('style');
86        
87                    $self.addClass('jctkr-wrapper');
88        
89                    var conveyorInit = function(){
90                        var $listItems1stClone = $list.clone().children('li');
91                        $listItems1stClone.each(function(){
92                            $(this).addClass('clone');
93                        });
94                        $list.append($listItems1stClone);
95        
96                        var listTotalWidth = 0;
97                        $list.children().each(function(){
98                            listTotalWidth += $(this).outerWidth();
99                        });
100                        $list.width(listTotalWidth);
101        
102                        $self.hover(function(){
103                            output.pauseAnim();
104                        }, function(){
105                            output.pauseAnim();
106                            output.conveyorAnimate('normal');
107                        });
108        
109                        if ( reverse_commute ){
110                            $self.prev('.jctkr-label')
111                            .hover(function(){
112                                output.pauseAnim();
113                                output.conveyorAnimate('reverse');
114                            }, function(){
115                                output.pauseAnim();
116                                output.conveyorAnimate('normal');
117                            }).click(function(){
118                                return false;
119                            });
120                        }
121                        output.conveyorAnimate('normal');
122                    };
123        
124                    if ( $listRawWidth >= $parent1stThreshold ){
125                        conveyorInit();
126                    }
127                    else if ( initialization_forced ){
128                        var $itemsWidth, $containerWidth = 0;
129                        var itemsReplicate = function(){
130                            var $listItems1stClone = $list.clone().children('li');
131                            $listItems1stClone.each(function(){
132                                $(this).addClass('clone');
133                            });
134                            $list.append($listItems1stClone);
135        
136                            $itemsWidth = $list.width();
137                            $containerWidth = $list.parent().width();
138        
139                            if ( $itemsWidth < $containerWidth ){
140                                itemsReplicate();
141                            }
142                            else {
143                                conveyorInit();
144                                return false;
145                            }
146                        };
147        
148                        itemsReplicate();
149        
150                        while ( $itemsWidth < $containerWidth ) {
151                            if ( $itemsWidth >= $parent1stThreshold ) {
152                                conveyorInit();
153                                break;
154                            }
155                            itemsReplicate();
156                        }
157                    }
158
159                    $self.addClass('jctkr-initialized');
160
161                });
162
163                if ( paused_oninit ){
164                    output.pauseAnim();
165                }
166
167            },
168
169            'destroy': function(){
170
171                $self.each(function(){
172
173                    output.pauseAnim();
174
175                    $(this)
176                    .unbind().removeData()
177                    .removeClass('jctkr-wrapper jctkr-initialized');
178
179                    $list
180                    .unbind().removeData()
181                    .removeAttr('style')
182                    .find('.clone').remove();
183
184                });
185
186            },
187
188            'conveyorAnimate': function(action){
189
190                var tw = $list.width();
191                var tp = $list.position().left;
192                var operator = '-';
193                var direction = 'normal';
194                var tcal;
195
196                if (action !== undefined && action === 'reverse'){
197                    tcal = (tw / 2);
198                    if (tp > 0){
199                        $list.css('left', '-' + tcal + 'px');
200                        output.conveyorAnimate('reverse');
201                        return;
202                    }
203                    operator = '+';
204                    direction = 'reverse';
205                }
206                else {
207                    tcal = -1 * (tw / 2);
208                    if (tp < tcal){
209                        var toffs = -1 * (tcal - tp);
210                        $list.css('left', toffs + 'px');
211                        output.conveyorAnimate(direction);
212                        return;
213                    }
214                }
215
216                $list.stop().animate({
217                    left: operator + '=10px'
218                }, cycle_duration, 'linear', function(){
219                    output.conveyorAnimate(direction);
220                });
221
222            },
223
224            'pauseAnim': function(){
225                $list.stop();
226            },
227
228            'playAnim': function(){
229                output.conveyorAnimate('normal');
230            },
231
232        };
233
234        output.init();
235        return output;
236
237    };
238
239})(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.