1/** 2 * Optional autoplay for inline media videos in gsma/text-image-columns. 3 * 4 * Defers to the site-wide playback preference published by 5 * `assets/js/ota-playback.js`: 6 * - document.documentElement.dataset.otaAutoplay === 'on' | 'off' 7 * - CustomEvent 'ota:playback-change' on document. 8 * 9 * Respects prefers-reduced-motion when the visitor has not set an 10 * explicit preference via the header toggle. 11 */ 12( function () { 13 function prefersReducedMotion() { 14 return ( 15 window.matchMedia && 16 window.matchMedia( '(prefers-reduced-motion: reduce)' ).matches 17 ); 18 } 19 20 function autoplayEnabled() { 21 var flag = document.documentElement && document.documentElement.dataset.otaAutoplay; 22 if ( flag === 'on' ) { return true; } 23 if ( flag === 'off' ) { return false; } 24 return ! prefersReducedMotion(); 25 } 26 27 function play( video ) { 28 try { 29 video.muted = true; 30 video.setAttribute( 'playsinline', '' ); 31 var p = video.play(); 32 if ( p && typeof p.catch === 'function' ) { 33 p.catch( function () {} ); 34 } 35 } catch ( e ) {} 36 } 37 38 function pause( video ) { 39 try { 40 video.pause(); 41 } catch ( e ) {} 42 } 43 44 function allVideos() { 45 return document.querySelectorAll( 46 '.block-text-image-columns__video[data-text-image-columns-video="1"]' 47 ); 48 } 49 50 function syncAll() { 51 var enabled = autoplayEnabled(); 52 allVideos().forEach( enabled ? play : pause ); 53 } 54 55 function boot() { 56 syncAll(); 57 document.addEventListener( 'ota:playback-change', syncAll ); 58 } 59 60 if ( document.readyState === 'loading' ) { 61 document.addEventListener( 'DOMContentLoaded', boot ); 62 } else { 63 boot(); 64 } 65} )();
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.