PageSourceSearch

https://welcomebreak.co.uk/wp-content/plugins/cn-core-widgets/widgets/media/js/media.js

js welcomebreak.co.uk collected 2026-09-25 18:42:23 UTC 2,674 bytes, 72 lines download raw bytes

1(function($) {
2    'use strict';
3
4    $(document).on('cnInitMediaWidget', function (event, data) {
5        $('.c-media').each(function() {
6            var mediaEl = $(this),
7                options = $(this).data('module-options'),
8                videoEl = mediaEl.find('.c-media__video'),
9                audioEl = mediaEl.find('.c-media__audio'),
10                actionEl = mediaEl.find('.c-media__actions li'),
11                galleryTriggerEl = mediaEl.find('[data-module="media-gallery-trigger"]');
12
13            if (videoEl.length) {
14                var player = new Plyr(videoEl[0]);
15            }
16
17            if(audioEl.length) {
18                let audioPlayer = audioEl.find('audio')[0]
19
20                audioEl.find('.js-media-audio-play').on('click', function(e) {
21                    e.preventDefault()
22
23                    if(audioPlayer.paused){
24                        audioPlayer.play()
25                    } else {
26                        audioPlayer.pause()
27                    }
28                })
29
30                $(audioPlayer).on({
31                    'play': function(){
32                        audioEl.addClass('is-playing')
33                    },
34                    'pause ended': function(){
35                        audioEl.removeClass('is-playing')
36                    },
37                    'canplay': function() {
38                        $(this).trigger('displayTime', { time: this.duration })
39                    },
40                    'timeupdate': function(e){
41                        $(this).trigger('displayTime', { time: this.currentTime })
42                    },
43                    'displayTime': function(e, data){
44                        let minutes = "0" + Math.floor(data.time / 60);
45                        let seconds = "0" + (Math.floor(data.time) - minutes * 60);
46                        let timeDisplay = minutes.substr(-2) + ":" + seconds.substr(-2);
47
48                        audioEl.find('.js-media-audio-time').html(timeDisplay)
49                    }
50                })
51            }
52
53            if (options.actionImageBehaviour === 'replace_on_hover') {
54                actionEl.on('mouseenter mouseleave', function () {
55                    var imageId = $(this).data('image-id');
56                    var relatedImageEl = $('.c-media__image--' + imageId);
57
58                    if (relatedImageEl.length) {
59                        relatedImageEl.toggleClass('is-active');
60                    }
61                });
62            }
63
64            if (galleryTriggerEl.length) {
65                new CN.ImageGallery(galleryTriggerEl);
66            }
67        });
68    });
69
70    $(document).trigger('cnInitMediaWidget');
71
72})(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.