PageSourceSearch

https://15below.com/themes/custom/coherence_custom/js/video_autoplay_fallback.js?ti5i4p

js 15below.com collected 2026-10-03 20:36:15 UTC 2,068 bytes, 47 lines download raw bytes

1(function ($, Drupal, once) {
2  Drupal.behaviors.videoAutoplayFallback = {
3    attach: function (context) {
4      once('video-autoplay-fallback', '.video-cta-banner .coh-video video', context).forEach(function (video) {
5        // Check if video is supposed to autoplay
6        if (!video.hasAttribute('autoplay')) {
7          return;
8        }
9
10        // Give the video a moment to attempt autoplay
11        setTimeout(function () {
12          // If video is paused (autoplay blocked), add fallback class
13          if (video.paused) {
14            var $container = $(video).closest('.coh-video');
15            var $banner = $(video).closest('.video-cta-banner');
16            var $mobileImg = $banner.find('.mobile-img');
17            var hasFallbackImg = $mobileImg.length > 0 && $mobileImg.find('img').length > 0;
18
19            $container.addClass('autoplay-blocked');
20
21            // If fallback image exists, use it; otherwise just hide play button
22            if (hasFallbackImg) {
23              $banner.addClass('autoplay-blocked-with-fallback');
24            }
25
26            // Try to play on first user interaction
27            var playOnInteraction = function () {
28              video.play().then(function () {
29                $container.removeClass('autoplay-blocked');
30                $banner.removeClass('autoplay-blocked-with-fallback');
31              }).catch(function () {
32                // Still blocked, keep fallback visible
33              });
34              document.removeEventListener('click', playOnInteraction);
35              document.removeEventListener('touchstart', playOnInteraction);
36              document.removeEventListener('scroll', playOnInteraction);
37            };
38
39            document.addEventListener('click', playOnInteraction, { once: true, passive: true });
40            document.addEventListener('touchstart', playOnInteraction, { once: true, passive: true });
41            document.addEventListener('scroll', playOnInteraction, { once: true, passive: true });
42          }
43        }, 500);
44      });
45    }
46  };
47})(jQuery, Drupal, once);

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.