PageSourceSearch

https://radiooxygene.com/wp-content/plugins/qtmplayer/assets/components/jquery.marquee.js?ver=PR.3.9.8

js radiooxygene.com collected 2026-10-02 19:30:40 UTC 23,726 bytes, 496 lines download raw bytes

vendor: 23,726 bytes, lines 1-496
1/**
2 * jQuery.marquee - scrolling text like old marquee element
3 * @author Aamir Afridi - aamirafridi(at)gmail(dot)com / http://aamirafridi.com/jquery/jquery-marquee-plugin
4 *
5 * Custom version for Pro.Radio ERPlayer
6 * Fixed jsHint errors
7 */
8(function($) {
9    "use strict";
10    $.fn.marquee = function(options) {
11        var elHeight;
12        return this.each(function() {
13            // Extend the options if any provided
14            var o = $.extend({}, $.fn.marquee.defaults, options),
15                $this = $(this),
16                $marqueeWrapper, containerWidth, animationCss, verticalDir, elWidth,
17                loopCount = 3,
18                playState = 'animation-play-state',
19                css3AnimationIsSupported = false,
20
21                // Private methods
22                _prefixedEvent = function(element, type, callback) {
23                    var pfx = ["webkit", "moz", "MS", "o", ""];
24                    for (var p = 0; p < pfx.length; p++) {
25                        if (!pfx[p]){ type = type.toLowerCase();}
26                        element.addEventListener(pfx[p] + type, callback, false);
27                    }
28                },
29
30                _objToString = function(obj) {
31                    var tabjson = [];
32                    for (var p in obj) {
33                        if (obj.hasOwnProperty(p)) {
34                            tabjson.push(p + ':' + obj[p]);
35                        }
36                    }
37                    tabjson.push();
38                    return '{' + tabjson.join(',') + '}';
39                },
40
41                _startAnimationWithDelay = function() {
42                    $this.timer = setTimeout(animate, o.delayBeforeStart);
43                },
44
45                // Public methods
46                methods = {
47                    pause: function() {
48                        if (css3AnimationIsSupported && o.allowCss3Support) {
49                            $marqueeWrapper.css(playState, 'paused');
50                        } else {
51                            // pause using pause plugin
52                            if ($.fn.pause) {
53                                $marqueeWrapper.pause();
54                            }
55                        }
56                        // save the status
57                        $this.data('runningStatus', 'paused');
58                        // fire event
59                        $this.trigger('paused');
60                    },
61
62                    resume: function() {
63                        // resume using css3
64                        if (css3AnimationIsSupported && o.allowCss3Support) {
65                            $marqueeWrapper.css(playState, 'running');
66                        } else {
67                            // resume using pause plugin
68                            if ($.fn.resume) {
69                                $marqueeWrapper.resume();
70                            }
71                        }
72                        // save the status
73                        $this.data('runningStatus', 'resumed');
74                        // fire event
75                        $this.trigger('resumed');
76                    },
77
78                    toggle: function() {
79                        methods[$this.data('runningStatus') === 'resumed' ? 'pause' : 'resume']();
80                    },
81
82                    destroy: function() {
83                        // Clear timer
84                        clearTimeout($this.timer);
85                        // Unbin all events
86                        $this.find("*").addBack().off();
87                        // Just unwrap the elements that has been added using this plugin
88                        $this.html($this.find('.js-marquee:first').html());
89                    }
90                };
91
92            // Check for methods
93            if (typeof options === 'string') {
94                if ($.isFunction(methods[options])) {
95                    // Following two IF statements to support public methods
96                    if (!$marqueeWrapper) {
97                        $marqueeWrapper = $this.find('.js-marquee-wrapper');
98                    }
99                    if ($this.data('css3AnimationIsSupported') === true) {
100                        css3AnimationIsSupported = true;
101                    }
102                    methods[options]();
103                }
104                return;
105            }
106
107            /* Check if element has data attributes. They have top priority
108               For details https://twitter.com/aamirafridi/status/403848044069679104 - Can't find a better solution :/
109               jQuery 1.3.2 doesn't support $.data().KEY hence writting the following */
110            var dataAttributes; 
111            dataAttributes = {};
112            var attr;
113            $.each(o, function(key) {
114                // Check if element has this data attribute
115                attr = $this.attr('data-' + key);
116                if (typeof attr !== 'undefined') {
117                    // Now check if value is boolean or not
118                    switch (attr) {
119                        case 'true':
120                            attr = true;
121                            break;
122                        case 'false':
123                            attr = false;
124                            break;
125                    }
126                    o[key] = attr;
127                }
128            });
129
130            // Reintroduce speed as an option. It calculates duration as a factor of the container width
131            // measured in pixels per second.
132            if (o.speed) {
133                o.duration = parseInt($this.width(), 10) / o.speed * 1000;
134            }
135
136            // Shortcut to see if direction is upward or downward
137            verticalDir = o.direction === 'up' || o.direction === 'down';
138
139            // no gap if not duplicated
140            o.gap = o.duplicated ? parseInt(o.gap) : 0;
141
142            // wrap inner content into a div
143            $this.wrapInner('<div class="js-marquee"></div>');
144
145            // Make copy of the element
146            var $el = $this.find('.js-marquee').css({
147                'margin-right': o.gap,
148                'float': 'left'
149            });
150
151            if (o.duplicated) {
152                $el.clone(true).appendTo($this);
153            }
154
155            // wrap both inner elements into one div
156            $this.wrapInner('<div style="width:100000px" class="js-marquee-wrapper"></div>');
157
158            // Save the reference of the wrapper
159            $marqueeWrapper = $this.find('.js-marquee-wrapper');
160            var containerHeight; // igor, fix jsHint http://linterrors.com/js/a-used-out-of-scope
161            // If direction is up or down, get the height of main element
162            if (verticalDir) {
163                containerHeight = $this.height();
164                $marqueeWrapper.removeAttr('style');
165                $this.height(containerHeight);
166
167                // Change the CSS for js-marquee element
168                $this.find('.js-marquee').css({
169                    'float': 'none',
170                    'margin-bottom': o.gap,
171                    'margin-right': 0
172                });
173
174                // Remove bottom margin from 2nd element if duplicated
175                if (o.duplicated) {
176		    $this.find('.js-marquee:last').css({
177			'margin-bottom': 0
178		    });
179		}
180            
181
182             elHeight = $this.find('.js-marquee:first').height() + o.gap;
183
184                // adjust the animation duration according to the text length
185            if (o.startVisible && !o.duplicated) {
186                    // Compute the complete animation duration and save it for later reference
187                    // formula is to: (Height of the text node + height of the main container / Height of the main container) * duration;
188                    o._completeDuration = ((parseInt(elHeight, 10) + parseInt(containerHeight, 10)) / parseInt(containerHeight, 10)) * o.duration;
189
190                    // formula is to: (Height of the text node / height of the main container) * duration
191                    o.duration = (parseInt(elHeight, 10) / parseInt(containerHeight, 10)) * o.duration;
192                } else {
193                    // formula is to: (Height of the text node + height of the main container / Height of the main container) * duration;
194                    o.duration = ((parseInt(elHeight, 10) + parseInt(containerHeight, 10)) / parseInt(containerHeight, 10)) * o.duration;
195                }
196
197            } else {
198                // Save the width of the each element so we can use it in animation
199                elWidth = $this.find('.js-marquee:first').width() + o.gap;
200
201                // container width
202                containerWidth = $this.width();
203
204                // adjust the animation duration according to the text length
205                if (o.startVisible && !o.duplicated) {
206                    // Compute the complete animation duration and save it for later reference
207                    // formula is to: (Width of the text node + width of the main container / Width of the main container) * duration;
208                    o._completeDuration = ((parseInt(elWidth, 10) + parseInt(containerWidth, 10)) / parseInt(containerWidth, 10)) * o.duration;
209
210                    // (Width of the text node / width of the main container) * duration
211                    o.duration = (parseInt(elWidth, 10) / parseInt(containerWidth, 10)) * o.duration;
212                } else {
213                    // formula is to: (Width of the text node + width of the main container / Width of the main container) * duration;
214                    o.duration = ((parseInt(elWidth, 10) + parseInt(containerWidth, 10)) / parseInt(containerWidth, 10)) * o.duration;
215                }
216            }
217
218            // if duplicated then reduce the duration
219            if (o.duplicated) {
220                o.duration = o.duration / 2;
221            }
222
223            if (o.allowCss3Support) {
224                var elm = document.body || document.createElement('div'),
225                    animationName = 'marqueeAnimation-' + Math.floor(Math.random() * 10000000),
226                    domPrefixes = 'Webkit Moz O ms Khtml'.split(' '),
227                    animationString = 'animation',
228                    animationCss3Str = '',
229                    keyframeString = '';
230
231                // Check css3 support
232                if (elm.style.animation !== undefined) {
233                    keyframeString = '@keyframes ' + animationName + ' ';
234                    css3AnimationIsSupported = true;
235                }
236
237                if (css3AnimationIsSupported === false) {
238                    for (var i = 0; i < domPrefixes.length; i++) {
239                        if (elm.style[domPrefixes[i] + 'AnimationName'] !== undefined) {
240                            var prefix = '-' + domPrefixes[i].toLowerCase() + '-';
241                            animationString = prefix + animationString;
242                            playState = prefix + playState;
243                            keyframeString = '@' + prefix + 'keyframes ' + animationName + ' ';
244                            css3AnimationIsSupported = true;
245                            break;
246                        }
247                    }
248                }
249
250                if (css3AnimationIsSupported) {
251                    animationCss3Str = animationName + ' ' + o.duration / 1000 + 's ' + o.delayBeforeStart / 1000 + 's infinite ' + o.css3easing;
252                    $this.data('css3AnimationIsSupported', true);
253                }
254            }
255
256            var _rePositionVertically = function() {
257                $marqueeWrapper.css('transform', 'translateY(' + (o.direction === 'up' ? containerHeight + 'px' : '-' + elHeight + 'px') + ')');
258            },
259            _rePositionHorizontally = function() {
260                $marqueeWrapper.css('transform', 'translateX(' + (o.direction === 'left' ? containerWidth + 'px' : '-' + elWidth + 'px') + ')');
261            };
262
263            // if duplicated option is set to true than position the wrapper
264            if (o.duplicated) {
265                if (verticalDir) {
266                    if (o.startVisible) {
267                        $marqueeWrapper.css('transform', 'translateY(0)');
268                    } else {
269                        $marqueeWrapper.css('transform', 'translateY(' + (o.direction === 'up' ? containerHeight + 'px' : '-' + ((elHeight * 2) - o.gap) + 'px') + ')');
270                    }
271                } else {
272                    if (o.startVisible) {
273                        $marqueeWrapper.css('transform', 'translateX(0)');
274                    } else {
275                        $marqueeWrapper.css('transform', 'translateX(' + (o.direction === 'left' ? containerWidth + 'px' : '-' + ((elWidth * 2) - o.gap) + 'px') + ')');
276                    }
277                }
278
279                // If the text starts out visible we can skip the two initial loops
280                if (!o.startVisible) {
281                  loopCount = 1;
282                }
283            } else if (o.startVisible) {
284                // We only have two different loops if marquee is duplicated and starts visible
285                loopCount = 2;
286            } else {
287                if (verticalDir) {
288                    _rePositionVertically();
289                } else {
290                    _rePositionHorizontally();
291                }
292            }
293
294            // Animate recursive method
295            var animate = function() {
296                if (o.duplicated) {
297                    // When duplicated, the first loop will be scroll longer so double the duration
298                    if (loopCount === 1) {
299                        o._originalDuration = o.duration;
300                        if (verticalDir) {
301                            o.duration = o.direction === 'up' ? o.duration + (containerHeight / ((elHeight) / o.duration)) : o.duration * 2;
302                        } else {
303                            o.duration = o.direction === 'left' ? o.duration + (containerWidth / ((elWidth) / o.duration)) : o.duration * 2;
304                        }
305                        // Adjust the css3 animation as well
306                        if (animationCss3Str) {
307                            animationCss3Str = animationName + ' ' + o.duration / 1000 + 's ' + o.delayBeforeStart / 1000 + 's ' + o.css3easing;
308                        }
309                        loopCount++;
310                    }
311                    // On 2nd loop things back to normal, normal duration for the rest of animations
312                    else if (loopCount === 2) {
313                        o.duration = o._originalDuration;
314                        // Adjust the css3 animation as well
315                        if (animationCss3Str) {
316                            animationName = animationName + '0';
317                            keyframeString = $.trim(keyframeString) + '0 ';
318                            animationCss3Str = animationName + ' ' + o.duration / 1000 + 's 0s infinite ' + o.css3easing;
319                        }
320                        loopCount++;
321                    }
322                }
323
324                if (verticalDir) {
325                    if (o.duplicated) {
326
327                        // Adjust the starting point of animation only when first loops finishes
328                        if (loopCount > 2) {
329                            $marqueeWrapper.css('transform', 'translateY(' + (o.direction === 'up' ? 0 : '-' + elHeight + 'px') + ')');
330                        }
331
332                        animationCss = {
333                            'transform': 'translateY(' + (o.direction === 'up' ? '-' + elHeight + 'px' : 0) + ')'
334                        };
335                    } else if (o.startVisible) {
336                        // This loop moves the marquee out of the container
337                        if (loopCount === 2) {
338                            // Adjust the css3 animation as well
339                            if (animationCss3Str) {
340                                animationCss3Str = animationName + ' ' + o.duration / 1000 + 's ' + o.delayBeforeStart / 1000 + 's ' + o.css3easing;
341                            }
342                            animationCss = {
343                                'transform': 'translateY(' + (o.direction === 'up' ? '-' + elHeight + 'px' : containerHeight + 'px') + ')'
344                            };
345                            loopCount++;
346                        } else if (loopCount === 3) {
347                            // Set the duration for the animation that will run forever
348                            o.duration = o._completeDuration;
349                            // Adjust the css3 animation as well
350                            if (animationCss3Str) {
351                                    animationName = animationName + '0';
352                                    keyframeString = $.trim(keyframeString) + '0 ';
353                                    animationCss3Str = animationName + ' ' + o.duration / 1000 + 's 0s infinite ' + o.css3easing;
354                            }
355                            _rePositionVertically();
356                        }
357                    } else {
358                        _rePositionVertically();
359                        animationCss = {
360                            'transform': 'translateY(' + (o.direction === 'up' ? '-' + ($marqueeWrapper.height()) + 'px' : containerHeight + 'px') + ')'
361                        };
362                    }
363                } else {
364                    if (o.duplicated) {
365
366                        // Adjust the starting point of animation only when first loops finishes
367                        if (loopCount > 2) {
368                            $marqueeWrapper.css('transform', 'translateX(' + (o.direction === 'left' ? 0 : '-' + elWidth + 'px') + ')');
369                        }
370
371                        animationCss = {
372                            'transform': 'translateX(' + (o.direction === 'left' ? '-' + elWidth + 'px' : 0) + ')'
373                        };
374
375                    } else if (o.startVisible) {
376                        // This loop moves the marquee out of the container
377                        if (loopCount === 2) {
378                            // Adjust the css3 animation as well
379                            if (animationCss3Str) {
380                                animationCss3Str = animationName + ' ' + o.duration / 1000 + 's ' + o.delayBeforeStart / 1000 + 's ' + o.css3easing;
381                            }
382                            animationCss = {
383                                'transform': 'translateX(' + (o.direction === 'left' ? '-' + elWidth + 'px' : containerWidth + 'px') + ')'
384                            };
385                            loopCount++;
386                        } else if (loopCount === 3) {
387                            // Set the duration for the animation that will run forever
388                            o.duration = o._completeDuration;
389                            // Adjust the css3 animation as well
390                            if (animationCss3Str) {
391                                animationName = animationName + '0';
392                                keyframeString = $.trim(keyframeString) + '0 ';
393                                animationCss3Str = animationName + ' ' + o.duration / 1000 + 's 0s infinite ' + o.css3easing;
394                            }
395                            _rePositionHorizontally();
396                        }
397                    } else {
398                        _rePositionHorizontally();
399                        animationCss = {
400                            'transform': 'translateX(' + (o.direction === 'left' ? '-' + elWidth + 'px' : containerWidth + 'px') + ')'
401                        };
402                    }
403                }
404
405                // fire event
406                $this.trigger('beforeStarting');
407
408                // If css3 support is available than do it with css3, otherwise use jQuery as fallback
409                if (css3AnimationIsSupported) {
410                    // Add css3 animation to the element
411                    $marqueeWrapper.css(animationString, animationCss3Str);
412                    var keyframeCss = keyframeString + ' { 100%  ' + _objToString(animationCss) + '}',
413                         $styles = $marqueeWrapper.find('style');
414
415                    // Now add the keyframe animation to the marquee element
416                    if ($styles.length !== 0) {
417                        // Bug fixed for jQuery 1.3.x - Instead of using .last(), use following
418                        $styles.filter(":last").html(keyframeCss);
419                    } else {
420                        $('head').append('<style>' + keyframeCss + '</style>');
421                    }
422
423                    // Animation iteration event
424                    _prefixedEvent($marqueeWrapper[0], "AnimationIteration", function() {
425                        $this.trigger('finished');
426                    });
427                    // Animation stopped
428                    _prefixedEvent($marqueeWrapper[0], "AnimationEnd", function() {
429                        animate();
430                        $this.trigger('finished');
431                    });
432
433                } else {
434                    // Start animating
435                    $marqueeWrapper.animate(animationCss, o.duration, o.easing, function() {
436                        // fire event
437                        $this.trigger('finished');
438                        // animate again
439                        if (o.pauseOnCycle) {
440                            _startAnimationWithDelay();
441                        } else {
442                            animate();
443                        }
444                    });
445                }
446                // save the status
447                $this.data('runningStatus', 'resumed');
448            };
449
450            // pause and resume events
451            $this.on('pause', methods.pause);
452            $this.on('resume', methods.resume);
453
454            if (o.pauseOnHover) {
455                $this.on('mouseenter', methods.pause);
456                $this.on('mouseleave', methods.resume);
457            }
458
459            // If css3 animation is supported than call animate method at once
460            if (css3AnimationIsSupported && o.allowCss3Support) {
461                animate();
462            } else {
463                // Starts the recursive method
464                _startAnimationWithDelay();
465            }
466
467        });
468    }; // End of Plugin
469    // Public: plugin defaults options
470    $.fn.marquee.defaults = {
471        // If you wish to always animate using jQuery
472        allowCss3Support: true,
473        // works when allowCss3Support is set to true - for full list see http://www.w3.org/TR/2013/WD-css3-transitions-20131119/#transition-timing-function
474        css3easing: 'linear',
475        // requires jQuery easing plugin. Default is 'linear'
476        easing: 'linear',
477        // pause time before the next animation turn in milliseconds
478        delayBeforeStart: 1000,
479        // 'left', 'right', 'up' or 'down'
480        direction: 'left',
481        // true or false - should the marquee be duplicated to show an effect of continues flow
482        duplicated: false,
483        // duration in milliseconds of the marquee in milliseconds
484        duration: 5000,
485        // Speed allows you to set a relatively constant marquee speed regardless of the width of the containing element. Speed is measured in pixels per second.
486        speed: 0,
487        // gap in pixels between the tickers
488        gap: 20,
489        // on cycle pause the marquee
490        pauseOnCycle: false,
491        // on hover pause the marquee - using jQuery plugin https://github.com/tobia/Pause
492        pauseOnHover: false,
493        // the marquee is visible initially positioned next to the border towards it will be moving
494        startVisible: false
495    };
496})(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.