PageSourceSearch

https://www.sinchew.com.my/public/js/marquee.js?v=1.0.08

js sinchew.com.my collected 2026-09-24 09:02:44 UTC 17,624 bytes, 364 lines download raw bytes

vendor: 3,996 bytes, lines 1-92
1(function(factory) {
2    "use strict";
3    if (typeof define === "function" && define.amd) {
4        define(["jquery"], factory)
5    } else if (typeof exports !== "undefined") {
6        module.exports = factory(require("jquery"))
7    } else {
8        factory(jQuery)
9    }
10})(function($) {
11    $.fn.marquee = function(options) {
12        return this.each(function() {
13            var o = $.extend({}, $.fn.marquee.defaults, options),
14                $this = $(this),
15                $marqueeWrapper, containerWidth, animationCss, verticalDir, elWidth, loopCount = 3,
16                playState = "animation-play-state",
17                css3AnimationIsSupported = false,
18                _prefixedEvent = function(element, type, callback) {
19                    var pfx = ["webkit", "moz", "MS", "o", ""];
20                    for (var p = 0; p < pfx.length; p++) {
21                        if (!pfx[p]) type = type.toLowerCase();
22                        element.addEventListener(pfx[p] + type, callback, false)
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                _startAnimationWithDelay = function() {
36                    $this.timer = setTimeout(animate, o.delayBeforeStart)
37                },
38                methods = {
39                    pause: function() {
40                        if (css3AnimationIsSupported && o.allowCss3Support) {
41                            $marqueeWrapper.css(playState, "paused")
42                        } else {
43                            if ($.fn.pause) {
44                                $marqueeWrapper.pause()
45                            }
46                        }
47                        $this.data("runningStatus", "paused");
48                        $this.trigger("paused")
49                    },
50                    resume: function() {
51                        if (css3AnimationIsSupported && o.allowCss3Support) {
52                            $marqueeWrapper.css(playState, "running")
53                        } else {
54                            if ($.fn.resume) {
55                                $marqueeWrapper.resume()
56                            }
57                        }
58                        $this.data("runningStatus", "resumed");
59                        $this.trigger("resumed")
60                    },
61                    toggle: function() {
62                        methods[$this.data("runningStatus") === "resumed" ? "pause" : "resume"]()
63                    },
64                    destroy: function() {
65                        clearTimeout($this.timer);
66                        $this.find("*").addBack().off();
67                        $this.html($this.find(".js-marquee:first").html())
68                    }
69                };
70            if (typeof options === "string") {
71                if ($.isFunction(methods[options])) {
72                    if (!$marqueeWrapper) {
73                        $marqueeWrapper = $this.find(".js-marquee-wrapper")
74                    }
75                    if ($this.data("css3AnimationIsSupported") === true) {
76                        css3AnimationIsSupported = true
77                    }
78                    methods[options]()
79                }
80                return
81            }
82            var dataAttributes = {},
83                attr;
84            $.each(o, function(key) {
85                attr = $this.attr("data-" + key);
86                if (typeof attr !== "undefined") {
87                    switch (attr) {
88                        case "true":
89                            attr = true;
90                            break;
91                        case "false":
92                            attr = false;
vendor: 4,575 bytes, lines 93-179
93                            break
94                    }
95                    o[key] = attr
96                }
97            });
98            if (o.speed) {
99                o.duration = parseInt($this.width(), 10) / o.speed * 1e3
100            }
101            verticalDir = o.direction === "up" || o.direction === "down";
102            o.gap = o.duplicated ? parseInt(o.gap) : 0;
103            $this.wrapInner('<div class="js-marquee"></div>');
104            var $el = $this.find(".js-marquee").css({
105                "margin-right": o.gap,
106                float: "left"
107            });
108            if (o.duplicated) {
109                $el.clone(true).appendTo($this)
110            }
111            $this.wrapInner('<div style="width:100000px" class="js-marquee-wrapper"></div>');
112            $marqueeWrapper = $this.find(".js-marquee-wrapper");
113            if (verticalDir) {
114                var containerHeight = $this.height();
115                $marqueeWrapper.removeAttr("style");
116                $this.height(containerHeight);
117                $this.find(".js-marquee").css({
118                    float: "none",
119                    "margin-bottom": o.gap,
120                    "margin-right": 0
121                });
122                if (o.duplicated) {
123                    $this.find(".js-marquee:last").css({
124                        "margin-bottom": 0
125                    })
126                }
127                var elHeight = $this.find(".js-marquee:first").height() + o.gap;
128                if (o.startVisible && !o.duplicated) {
129                    o._completeDuration = (parseInt(elHeight, 10) + parseInt(containerHeight, 10)) / parseInt(containerHeight, 10) * o.duration;
130                    o.duration = parseInt(elHeight, 10) / parseInt(containerHeight, 10) * o.duration
131                } else {
132                    o.duration = (parseInt(elHeight, 10) + parseInt(containerHeight, 10)) / parseInt(containerHeight, 10) * o.duration
133                }
134            } else {
135                elWidth = $this.find(".js-marquee:first").width() + o.gap;
136                containerWidth = $this.width();
137                if (o.startVisible && !o.duplicated) {
138                    o._completeDuration = (parseInt(elWidth, 10) + parseInt(containerWidth, 10)) / parseInt(containerWidth, 10) * o.duration;
139                    o.duration = parseInt(elWidth, 10) / parseInt(containerWidth, 10) * o.duration
140                } else {
141                    o.duration = (parseInt(elWidth, 10) + parseInt(containerWidth, 10)) / parseInt(containerWidth, 10) * o.duration
142                }
143            }
144            if (o.duplicated) {
145                o.duration = o.duration / 2
146            }
147            if (o.allowCss3Support) {
148                var elm = document.body || document.createElement("div"),
149                    animationName = "marqueeAnimation-" + Math.floor(Math.random() * 1e7),
150                    domPrefixes = "Webkit Moz O ms Khtml".split(" "),
151                    animationString = "animation",
152                    animationCss3Str = "",
153                    keyframeString = "";
154                if (elm.style.animation !== undefined) {
155                    keyframeString = "@keyframes " + animationName + " ";
156                    css3AnimationIsSupported = true
157                }
158                if (css3AnimationIsSupported === false) {
159                    for (var i = 0; i < domPrefixes.length; i++) {
160                        if (elm.style[domPrefixes[i] + "AnimationName"] !== undefined) {
161                            var prefix = "-" + domPrefixes[i].toLowerCase() + "-";
162                            animationString = prefix + animationString;
163                            playState = prefix + playState;
164                            keyframeString = "@" + prefix + "keyframes " + animationName + " ";
165                            css3AnimationIsSupported = true;
166                            break
167                        }
168                    }
169                }
170                if (css3AnimationIsSupported) {
171                    animationCss3Str = animationName + " " + o.duration / 1e3 + "s " + o.delayBeforeStart / 1e3 + "s infinite " + o.css3easing;
172                    $this.data("css3AnimationIsSupported", true)
173                }
174            }
175            var _rePositionVertically = function() {
176                    $marqueeWrapper.css("transform", "translateY(" + (o.direction === "up" ? containerHeight + "px" : "-" + elHeight + "px") + ")")
177                },
178                _rePositionHorizontally = function() {
179                    $marqueeWrapper.css("transform", "translateX(" 
vendor: 4,649 bytes, lines 179-265
179+ (o.direction === "left" ? containerWidth + "px" : "-" + elWidth + "px") + ")")
180                };
181            if (o.duplicated) {
182                if (verticalDir) {
183                    if (o.startVisible) {
184                        $marqueeWrapper.css("transform", "translateY(0)")
185                    } else {
186                        $marqueeWrapper.css("transform", "translateY(" + (o.direction === "up" ? containerHeight + "px" : "-" + (elHeight * 2 - o.gap) + "px") + ")")
187                    }
188                } else {
189                    if (o.startVisible) {
190                        $marqueeWrapper.css("transform", "translateX(0)")
191                    } else {
192                        $marqueeWrapper.css("transform", "translateX(" + (o.direction === "left" ? containerWidth + "px" : "-" + (elWidth * 2 - o.gap) + "px") + ")")
193                    }
194                }
195                if (!o.startVisible) {
196                    loopCount = 1
197                }
198            } else if (o.startVisible) {
199                loopCount = 2
200            } else {
201                if (verticalDir) {
202                    _rePositionVertically()
203                } else {
204                    _rePositionHorizontally()
205                }
206            }
207            var animate = function() {
208                if (o.duplicated) {
209                    if (loopCount === 1) {
210                        o._originalDuration = o.duration;
211                        if (verticalDir) {
212                            o.duration = o.direction === "up" ? o.duration + containerHeight / (elHeight / o.duration) : o.duration * 2
213                        } else {
214                            o.duration = o.direction === "left" ? o.duration + containerWidth / (elWidth / o.duration) : o.duration * 2
215                        }
216                        if (animationCss3Str) {
217                            animationCss3Str = animationName + " " + o.duration / 1e3 + "s " + o.delayBeforeStart / 1e3 + "s " + o.css3easing
218                        }
219                        loopCount++
220                    } else if (loopCount === 2) {
221                        o.duration = o._originalDuration;
222                        if (animationCss3Str) {
223                            animationName = animationName + "0";
224                            keyframeString = $.trim(keyframeString) + "0 ";
225                            animationCss3Str = animationName + " " + o.duration / 1e3 + "s 0s infinite " + o.css3easing
226                        }
227                        loopCount++
228                    }
229                }
230                if (verticalDir) {
231                    if (o.duplicated) {
232                        if (loopCount > 2) {
233                            $marqueeWrapper.css("transform", "translateY(" + (o.direction === "up" ? 0 : "-" + elHeight + "px") + ")")
234                        }
235                        animationCss = {
236                            transform: "translateY(" + (o.direction === "up" ? "-" + elHeight + "px" : 0) + ")"
237                        }
238                    } else if (o.startVisible) {
239                        if (loopCount === 2) {
240                            if (animationCss3Str) {
241                                animationCss3Str = animationName + " " + o.duration / 1e3 + "s " + o.delayBeforeStart / 1e3 + "s " + o.css3easing
242                            }
243                            animationCss = {
244                                transform: "translateY(" + (o.direction === "up" ? "-" + elHeight + "px" : containerHeight + "px") + ")"
245                            };
246                            loopCount++
247                        } else if (loopCount === 3) {
248                            o.duration = o._completeDuration;
249                            if (animationCss3Str) {
250                                animationName = animationName + "0";
251                                keyframeString = $.trim(keyframeString) + "0 ";
252                                animationCss3Str = animationName + " " + o.duration / 1e3 + "s 0s infinite " + o.css3easing
253                            }
254                            _rePositionVertically()
255                        }
256                    } else {
257                        _rePositionVertically();
258                        animationCss = {
259                            transform: "translateY(" + (o.direction === "up" ? "-" + $marqueeWrapper.height() + "px" : containerHeight + "px") + ")"
260                        }
261                    }
262                } else {
263                    if (o.duplicated) {
264                        if (loopCount > 2) {
265                            $marqueeWrapper.css("transform", "translateX(" 
265+ (o.direction === "left" ? 0 : "-" + elWidth + "px") + ")")
266                        }
267                        animationCss = {
268                            transform: "translateX(" + (o.direction === "left" ? "-" + elWidth + "px" : 0) + ")"
269                        }
270                    } else if (o.startVisible) {
271                        if (loopCount === 2) {
272                            if (animationCss3Str) {
273                                animationCss3Str = animationName + " " + o.duration / 1e3 + "s " + o.delayBeforeStart / 1e3 + "s " + o.css3easing
274                            }
275                            animationCss = {
276                                transform: "translateX(" + (o.direction === "left" ? "-" + elWidth + "px" : containerWidth + "px") + ")"
277                            };
278                            loopCount++
279                        } else if (loopCount === 3) {
280                            o.duration = o._completeDuration;
281                            if (animationCss3Str) {
282                                animationName = animationName + "0";
283                                keyframeString = $.trim(keyframeString) + "0 ";
284                                animationCss3Str = animationName + " " + o.duration / 1e3 + "s 0s infinite " + o.css3easing
285                            }
286                            _rePositionHorizontally()
287                        }
288                    } else {
289                        _rePositionHorizontally();
290                        animationCss = {
291                            transform: "translateX(" + (o.direction === "left" ? "-" + elWidth + "px" : containerWidth + "px") + ")"
292                        }
293                    }
294                }
295                $this.trigger("beforeStarting");
296                if (css3AnimationIsSupported) {
297                    $marqueeWrapper.css(animationString, animationCss3Str);
298                    var keyframeCss = keyframeString + " { 100%  " + _objToString(animationCss) + "}",
299                        $styles = $marqueeWrapper.find("style");
300                    if ($styles.length !== 0) {
301                        $styles.filter(":last").html(keyframeCss)
302                    } else {
303                        $("head").append("<style>" + keyframeCss + "</style>")
304                    }
305                    _prefixedEvent($marqueeWrapper[0], "AnimationIteration", function() {
306                        $this.trigger("finished")
307                    });
308                    _prefixedEvent($marqueeWrapper[0], "AnimationEnd", function() {
309                        animate();
310                        $this.trigger("finished")
311                    })
312                } else {
313                    $marqueeWrapper.animate(animationCss, o.duration, o.easing, function() {
314                        $this.trigger("finished");
315                        if (o.pauseOnCycle) {
316                            _startAnimationWithDelay()
317                        } else {
318                            animate()
319                        }
320                    })
321                }
322                $this.data("runningStatus", "resumed")
323            };
324            $this.on("pause", methods.pause);
325            $this.on("resume", methods.resume);
326            if (o.pauseOnHover) {
327                $this.on("mouseenter", methods.pause);
328                $this.on("mouseleave", 
329                function(){
330                    if(o.pauseBtnId && o.pauseBtnId !== ""){
331                            var btnhtml = $("#"+o.pauseBtnId).html();
332                            if(btnhtml.includes("fa-pause")){
333                                 $this.trigger("resume");
334                            }
335                    }
336                    else{
337                        $this.trigger("resume");
338                    }
339                }
340                );
341            }
342            if (css3AnimationIsSupported && o.allowCss3Support) {
343                animate()
344            } else {
345                _startAnimationWithDelay()
346            }
347        })
348    };
349    $.fn.marquee.defaults = {
350        allowCss3Support: true,
351        css3easing: "linear",
352        easing: "linear",
353        delayBeforeStart: 1e3,
354        direction: "left",
355        duplicated: false,
356        duration: 5e3,
357        speed: 0,
358        gap: 20,
359        pauseOnCycle: false,
360        pauseOnHover: false,
361        startVisible: false,
362        pauseBtnId: ""
363    }
364});

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.