1(function ($, _) { 2 ("use strict"); 3 4 const setupMarquee = (scope, widgetPrefix) => { 5 let marqueeContainer = $(scope).find(`.${widgetPrefix}-marquee`); 6 let marqueeGroup = $(scope).find(`.${widgetPrefix}-marquee-group`); 7 8 // Determine orientation 9 let isVertical = 10 marqueeContainer.hasClass(`deensimc-marquee-vertical`) || 11 $(scope).find(`.deensimc-wrapper-vertical`).length > 0; 12 // Fallback if specific class isn't on marqueeContainer itself: check the parent wrapper generated by your PHP 13 if (!isVertical) { 14 isVertical = marqueeContainer 15 .closest(".deensimc-wrapper") 16 .hasClass("deensimc-wrapper-vertical"); 17 } 18 19 let isAnimationEnabled = marqueeContainer.data("animation-status") || "yes"; 20 let isPausedOnHover = marqueeContainer.data("pause-on-hover") || "no"; 21 let isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); 22 23 let originalChildElements = marqueeGroup.children().clone(true, true); 24 25 marqueeGroup.empty(); 26 originalChildElements.each(function () { 27 marqueeGroup.append($(this)); 28 }); 29 originalChildElements.each(function () { 30 marqueeGroup.append($(this).clone(true, true)); 31 }); 32 33 let originalContentSize = 0; 34 const originalChildElementsArray = Array.from(originalChildElements); 35 originalContentSize = originalChildElementsArray.reduce( 36 (accumulator, currentElement) => { 37 let aspect = currentElement.clientWidth + currentElement.clientHeight; 38 return accumulator + aspect; 39 }, 40 0 41 ); 42 43 if (isVertical) { 44 // Vertical 45 originalChildElements.each(function () { 46 // Temporarily ensure the item is block to measure height correctly if it was display:none 47 let $item = $(this); 48 let originalDisplay = $item.css("display"); 49 if (originalDisplay === "none") { 50 $item.css({ display: "block", visibility: "hidden" }); 51 } 52 originalContentSize += $item.outerHeight(true); 53 if (originalDisplay === "none") { 54 $item.css({ display: originalDisplay, visibility: "" }); 55 } 56 }); 57 } else { 58 // Horizontal 59 originalChildElements.each(function () { 60 let $item = $(this); 61 let originalDisplay = $item.css("display"); 62 // For horizontal, items are typically inline-block or flex items. 63 if (originalDisplay === "none") { 64 $item.css({ display: "inline-block", visibility: "hidden" }); 65 } 66 originalContentSize += $item.outerWidth(true); 67 if (originalDisplay === "none") { 68 $item.css({ display: originalDisplay, visibility: "" }); 69 } 70 }); 71 } 72 73 if (originalContentSize === 0) { 74 marqueeGroup.addClass(`${widgetPrefix}-paused`); 75 console.warn( 76 `Marquee original content ${ 77 isVertical ? "height" : "width" 78 } is 0. Animation paused.` 79 ); 80 return; 81 } 82 83 let pixelsPerSecondSetting = marqueeContainer.data("animation-speed"); 84 let pixelsPerSecond = 50; 85 86 if (typeof pixelsPerSecondSetting !== "undefined") { 87 const parsedSpeed = parseFloat(pixelsPerSecondSetting); 88 if (!isNaN(parsedSpeed) && parsedSpeed > 0) { 89 pixelsPerSecond = parsedSpeed; 90 } else { 91 console.warn( 92 `Invalid data-animation-speed value: ${pixelsPerSecondSetting}. Using default ${pixelsPerSecond}px/s.` 93 ); 94 } 95 } 96 97 if (pixelsPerSecond <= 0) { 98 marqueeGroup.addClass(`${widgetPrefix}-paused`); 99 console.warn("Marquee speed is 0 or negative. Animation paused."); 100 return; 101 } 102 103 let animationDuration = originalContentSize / pixelsPerSecond; 104 105 if (isSafari && Math.abs(animationDuration - 3) < 0.01) { 106 animationDuration += 0.01; 107 } 108 109 marqueeGroup.css("animation-duration", animationDuration + "s"); 110 111 // Ensure correct animation name is applied based on orientation if not already handled by more specific CSS 112 handlePauseOnHover(marqueeGroup, isPausedOnHover); 113 114 if (isAnimationEnabled === "yes") { 115 marqueeGroup.css("animation-play-state", "running"); 116 } else { 117 marqueeGroup.css("animation-play-state", "paused"); 118 } 119 120 if ( 121 isAnimationEnabled === "yes" && 122 originalContentSize > 0 && 123 pixelsPerSecond > 0 124 ) { 125 marqueeGroup.removeClass(`${widgetPrefix}-paused`); 126 } 127 }; 128 window.setupMarquee = setupMarquee; 129})(jQuery, window._);
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.