diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2015-05-08 08:55:26 +0200 |
---|---|---|
committer | Hakim El Hattab <hakim.elhattab@gmail.com> | 2015-05-08 08:55:33 +0200 |
commit | 5f90a449cf1fa6edc93aaa4e69e6152c6096cd2e (patch) | |
tree | 9864617b7a0d353d6322adf4357235d41904ba89 /js | |
parent | e16a220a624cc3f9888ae59feebbd989669a7f31 (diff) | |
download | perl-software-in-gnu-guix-5f90a449cf1fa6edc93aaa4e69e6152c6096cd2e.tar perl-software-in-gnu-guix-5f90a449cf1fa6edc93aaa4e69e6152c6096cd2e.tar.gz |
consider lazy loaded iframes when formatting src
Diffstat (limited to 'js')
-rw-r--r-- | js/reveal.js | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/js/reveal.js b/js/reveal.js index c46ddb6..ff5ea53 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -2871,21 +2871,22 @@ */ function formatEmbeddedContent() { + var _appendParamToIframeSource = function( sourceAttribute, sourceURL, param ) { + toArray( dom.slides.querySelectorAll( 'iframe['+ sourceAttribute +'*="'+ sourceURL +'"]' ) ).forEach( function( el ) { + var src = el.getAttribute( sourceAttribute ); + if( src && src.indexOf( param ) === -1 ) { + el.setAttribute( sourceAttribute, src + ( !/\?/.test( src ) ? '?' : '&' ) + param ); + } + }); + }; + // YouTube frames must include "?enablejsapi=1" - toArray( dom.slides.querySelectorAll( 'iframe[src*="youtube.com/embed/"]' ) ).forEach( function( el ) { - var src = el.getAttribute( 'src' ); - if( !/enablejsapi\=1/gi.test( src ) ) { - el.setAttribute( 'src', src + ( !/\?/.test( src ) ? '?' : '&' ) + 'enablejsapi=1' ); - } - }); + _appendParamToIframeSource( 'src', 'youtube.com/embed/', 'enablejsapi=1' ); + _appendParamToIframeSource( 'data-src', 'youtube.com/embed/', 'enablejsapi=1' ); // Vimeo frames must include "?api=1" - toArray( dom.slides.querySelectorAll( 'iframe[src*="player.vimeo.com/"]' ) ).forEach( function( el ) { - var src = el.getAttribute( 'src' ); - if( !/api\=1/gi.test( src ) ) { - el.setAttribute( 'src', src + ( !/\?/.test( src ) ? '?' : '&' ) + 'api=1' ); - } - }); + _appendParamToIframeSource( 'src', 'player.vimeo.com/', 'api=1' ); + _appendParamToIframeSource( 'data-src', 'player.vimeo.com/', 'api=1' ); } |