PageSourceSearch

https://www.greatdirectorsfilm.com/wp-content/themes/newses/js/jquery.marquee.js?ver=7.1.2

js greatdirectorsfilm.com collected 2026-09-28 01:15:11 UTC 23,985 bytes, 489 lines download raw bytes

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