1/* global document */ 2/* global jQuery */ 3 4(function ($) { 5 6 'use strict'; 7 8 var loadYoutube = function() { 9 $('.mace-youtube').each(function() { 10 var $youtube = $(this); 11 12 if($youtube.is('.mace-youtube-loaded')) { 13 return; 14 } 15 16 var videoUrl = $youtube.attr('data-mace-video'); 17 var thumbUrl = $youtube.attr('data-mace-video-thumb'); 18 19 var image = new Image(); 20 image.src = thumbUrl; 21 image.addEventListener('load', function() { 22 $youtube.append( image ); 23 }()); 24 25 // Click to play YT. 26 $youtube.on('click', function() { 27 $youtube.find('iframe').remove(); 28 29 var $iframe = $('<iframe>'); 30 31 $iframe.on('load', function() { 32 $youtube.trigger('maceIframeLoaded', [$iframe]); 33 34 // Play video. 35 $iframe[0].contentWindow.postMessage(JSON.stringify({ 36 'event': 'command', 37 'func': 'playVideo', 38 'args': ''}), 39 '*'); 40 }); 41 42 $iframe.attr('frameborder', '0'); 43 $iframe.attr('allowfullscreen', ''); 44 $iframe.attr('src', videoUrl); 45 46 $youtube.empty().append($iframe); 47 }); 48 49 $youtube.addClass('mace-youtube-loaded'); 50 }); 51 }; 52 53 $(document).ready(function() { 54 55 loadYoutube(); 56 57 $('body').on('maceLoadYoutube', loadYoutube); 58 59 }); 60 61})(jQuery); 62
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.