Sha256: 61bcf70adbe43a15cbe20297de9f4a10541b41ee73d071f8166b8e432ce35a23

Contents?: true

Size: 944 Bytes

Versions: 160

Compression:

Stored size: 944 Bytes

Contents

// Lazy load YouTube videos
$(document).ready(function() {
    var youtube = document.querySelectorAll( ".youtube" );
    for (var i = 0; i < youtube.length; i++) {
        var source = "https://img.youtube.com/vi/"+ youtube[i].dataset.embed +"/sddefault.jpg";
        var image = new Image();
        image.src = source;
        image.addEventListener( "load", function() {
            youtube[ i ].appendChild( image );
        }( i ) );

        youtube[i].addEventListener( "click", function() {

            var iframe = document.createElement( "iframe" );

                    iframe.setAttribute( "frameborder", "0" );
                    iframe.setAttribute( "allowfullscreen", "" );
                    iframe.setAttribute( "src", "https://www.youtube.com/embed/"+ this.dataset.embed +"?rel=0&showinfo=0&autoplay=1" );

                    this.innerHTML = "";
                    this.appendChild( iframe );
        } );	
    }
  
});

Version data entries

160 entries across 160 versions & 1 rubygems

Version Path
jumbo-jekyll-theme-3.0.55 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.54 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.53 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.52 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.51 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.50 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.49 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.48 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.47 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.46 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.45 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.44 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.43 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.40 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.39 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.38 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.37 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.36 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.35 assets/js/app/youtube-lazy.js
jumbo-jekyll-theme-3.0.34 assets/js/app/youtube-lazy.js