From 8160b9303de43e96981662ce4698e82c4660208d Mon Sep 17 00:00:00 2001 From: doakey3 Date: Sun, 12 Nov 2017 22:19:29 -0700 Subject: [PATCH 1/6] Only play autoplay media on current slide; footnotes & citations trigger = goto target slide --- landslide/themes/default/js/gifffer.min.js | 1 + landslide/themes/default/js/slides.js | 83 ++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 landslide/themes/default/js/gifffer.min.js diff --git a/landslide/themes/default/js/gifffer.min.js b/landslide/themes/default/js/gifffer.min.js new file mode 100644 index 00000000..4f979ff3 --- /dev/null +++ b/landslide/themes/default/js/gifffer.min.js @@ -0,0 +1 @@ +(function webpackUniversalModuleDefinition(root,factory){if(typeof exports==="object"&&typeof module==="object")module.exports=factory();else if(typeof define==="function"&&define.amd)define("Gifffer",[],factory);else if(typeof exports==="object")exports["Gifffer"]=factory();else root["Gifffer"]=factory()})(this,function(){var d=document;var playSize=60;var Gifffer=function(options){var images,i=0,gifs=[];images=d.querySelectorAll("[data-gifffer]");for(;i0?"":"px")}function parseStyles(styles){var stylesStr="";for(prop in styles)stylesStr+=prop+":"+styles[prop]+";";return stylesStr}function createContainer(w,h,el,altText,opts){var alt;var con=d.createElement("BUTTON");var cls=el.getAttribute("class");var id=el.getAttribute("id");var playButtonStyles=opts&&opts.playButtonStyles?parseStyles(opts.playButtonStyles):["width:"+playSize+"px","height:"+playSize+"px","border-radius:"+playSize/2+"px","background:rgba(0, 0, 0, 0.3)","position:absolute","top:50%","left:50%","margin:-"+playSize/2+"px"].join(";");var playButtonIconStyles=opts&&opts.playButtonIconStyles?parseStyles(opts.playButtonIconStyles):["width: 0","height: 0","border-top: 14px solid transparent","border-bottom: 14px solid transparent","border-left: 14px solid rgba(0, 0, 0, 0.5)","position: absolute","left: 26px","top: 16px"].join(";");cls?con.setAttribute("class",el.getAttribute("class")):null;id?con.setAttribute("id",el.getAttribute("id")):null;con.setAttribute("style","position:relative;cursor:pointer;background:none;border:none;padding:0;");con.setAttribute("aria-hidden","true");var play=d.createElement("DIV");play.setAttribute("class","gifffer-play-button");play.setAttribute("style",playButtonStyles);var trngl=d.createElement("DIV");trngl.setAttribute("style",playButtonIconStyles);play.appendChild(trngl);if(altText){alt=d.createElement("p");alt.setAttribute("class","gifffer-alt");alt.setAttribute("style","border:0;clip:rect(0 0 0 0);height:1px;overflow:hidden;padding:0;position:absolute;width:1px;");alt.innerText=altText+", image"}con.appendChild(play);el.parentNode.replaceChild(con,el);altText?con.parentNode.insertBefore(alt,con.nextSibling):null;return{c:con,p:play}}function calculatePercentageDim(el,w,h,wOrig,hOrig){var parentDimW=el.parentNode.offsetWidth;var parentDimH=el.parentNode.offsetHeight;var ratio=wOrig/hOrig;if(w.toString().indexOf("%")>0){w=parseInt(w.toString().replace("%",""));w=w/100*parentDimW;h=w/ratio}else if(h.toString().indexOf("%")>0){h=parseInt(h.toString().replace("%",""));h=h/100*parentDimW;w=h*ratio}return{w:w,h:h}}function process(el,gifs,options){var url,con,c,w,h,duration,play,gif,playing=false,cc,isC,durationTimeout,dims,altText;url=el.getAttribute("data-gifffer");w=el.getAttribute("data-gifffer-width");h=el.getAttribute("data-gifffer-height");duration=el.getAttribute("data-gifffer-duration");altText=el.getAttribute("data-gifffer-alt");el.style.display="block";c=document.createElement("canvas");isC=!!(c.getContext&&c.getContext("2d"));if(w&&h&&isC)cc=createContainer(w,h,el,altText,options);el.onload=function(){if(!isC)return;w=w||el.width;h=h||el.height;if(!cc)cc=createContainer(w,h,el,altText,options);con=cc.c;play=cc.p;dims=calculatePercentageDim(con,w,h,el.width,el.height);gifs.push(con);con.addEventListener("click",function(){clearTimeout(durationTimeout);if(!playing){playing=true;gif=document.createElement("IMG");gif.setAttribute("style","width:100%;height:100%;");gif.setAttribute("data-uri",Math.floor(Math.random()*1e5)+1);setTimeout(function(){gif.src=url},0);con.removeChild(play);con.removeChild(c);con.appendChild(gif);if(parseInt(duration)>0){durationTimeout=setTimeout(function(){playing=false;con.appendChild(play);con.removeChild(gif);con.appendChild(c);gif=null},duration)}}else{playing=false;con.appendChild(play);con.removeChild(gif);con.appendChild(c);gif=null}});c.width=dims.w;c.height=dims.h;c.getContext("2d").drawImage(el,0,0,dims.w,dims.h);con.appendChild(c);con.setAttribute("style","position:relative;cursor:pointer;width:"+dims.w+"px;height:"+dims.h+"px;background:none;border:none;padding:0;");c.style.width="100%";c.style.height="100%";if(w.toString().indexOf("%")>0&&h.toString().indexOf("%")>0){con.style.width=w;con.style.height=h}else if(w.toString().indexOf("%")>0){con.style.width=w;con.style.height="inherit"}else if(h.toString().indexOf("%")>0){con.style.width="inherit";con.style.height=h}else{con.style.width=dims.w+"px";con.style.height=dims.h+"px"}};el.src=url}return Gifffer}); \ No newline at end of file diff --git a/landslide/themes/default/js/slides.js b/landslide/themes/default/js/slides.js index cae8d018..6b2c8f69 100644 --- a/landslide/themes/default/js/slides.js +++ b/landslide/themes/default/js/slides.js @@ -171,6 +171,7 @@ function main() { currentSlideNo++; } updateSlideClasses(true); + handleAutoplays(); }; var prevSlide = function() { @@ -178,7 +179,15 @@ function main() { currentSlideNo--; } updateSlideClasses(true); + handleAutoplays(); }; + + var gotoSlide = function(slideNumber) { + currentSlideNo = slideNumber; + updateSlideClasses(true); + handleAutoplays(); + } + main.gotoSlide = gotoSlide; var showNotes = function() { var notes = getSlideEl(currentSlideNo).getElementsByClassName('notes'); @@ -506,6 +515,7 @@ function main() { if (e.data.indexOf("slide#") != -1) { currentSlideNo = Number(e.data.replace('slide#', '')); updateSlideClasses(false); + handleAutoplays(); } }, false); }; @@ -539,6 +549,75 @@ function main() { } } }; + + var handleAutoplays = function() { + // Stop autoplaying video and audio on all slides except current + var videos = document.getElementsByTagName('video'); + var audios = document.getElementsByTagName('audio'); + var cSlide = document.getElementsByClassName('current')[0]; + + for (var i = 0; i < videos.length; i++) { + if (videos[i].hasAttribute('autoplay')) { + if (isPresenterView) { + videos[i].pause(); + videos[i].currentTime = 0; + } + else { + if (cSlide.contains(videos[i])) { + videos[i].play(); + } + else { + videos[i].pause(); + videos[i].currentTime = 0; + } + } + } + } + for (var i = 0; i < audios.length; i++) { + if (audios[i].hasAttribute('autoplay')) { + if (isPresenterView) { + audios[i].pause(); + audios[i].currentTime = 0; + } + else { + if (cSlide.contains(audios[i])) { + audios[i].play(); + } + else { + audios[i].pause(); + audios[i].currentTime = 0; + } + } + } + } + }; + + var setInternalTargets = function(refs) { + for (var i = 0; i < refs.length; i++) { + var parts = refs[i].href.split('#'); + var target_id = parts[parts.length - 1]; + var target = document.getElementById(target_id); + for (var x = 0; x < slides.length; x++) { + if (slides[x].contains(target)) { + var slideNumber = (x + 1).toString(); + refs[i].href = 'javascript:main.gotoSlide(' + slideNumber + ');'; + break; + } + } + } + } + + var adaptInternalHyperlinks = function() { + // Set internal hyperlink (like footnotes) to goto target slide + var forwardRefs = document.getElementsByClassName('footnote-reference'); + setInternalTargets(forwardRefs); + + var forwardCites = document.getElementsByClassName('citation-reference'); + setInternalTargets(forwardCites); + + var backRefs = document.getElementsByClassName('fn-backref'); + setInternalTargets(backRefs); + }; // initialize @@ -576,5 +655,9 @@ function main() { addSlideClickListeners(); addRemoteWindowControls(); + + handleAutoplays(); + adaptInternalHyperlinks(); + })(); } From 00c35d6907b25bc37de4149b2da194c6232055a4 Mon Sep 17 00:00:00 2001 From: doakey3 Date: Sun, 12 Nov 2017 22:35:27 -0700 Subject: [PATCH 2/6] Autoplay media on current slide; handle footnotes --- landslide/themes/default/js/gifffer.min.js | 1 - landslide/themes/default/js/slides.js | 47 +++++++++------------- 2 files changed, 18 insertions(+), 30 deletions(-) delete mode 100644 landslide/themes/default/js/gifffer.min.js diff --git a/landslide/themes/default/js/gifffer.min.js b/landslide/themes/default/js/gifffer.min.js deleted file mode 100644 index 4f979ff3..00000000 --- a/landslide/themes/default/js/gifffer.min.js +++ /dev/null @@ -1 +0,0 @@ -(function webpackUniversalModuleDefinition(root,factory){if(typeof exports==="object"&&typeof module==="object")module.exports=factory();else if(typeof define==="function"&&define.amd)define("Gifffer",[],factory);else if(typeof exports==="object")exports["Gifffer"]=factory();else root["Gifffer"]=factory()})(this,function(){var d=document;var playSize=60;var Gifffer=function(options){var images,i=0,gifs=[];images=d.querySelectorAll("[data-gifffer]");for(;i0?"":"px")}function parseStyles(styles){var stylesStr="";for(prop in styles)stylesStr+=prop+":"+styles[prop]+";";return stylesStr}function createContainer(w,h,el,altText,opts){var alt;var con=d.createElement("BUTTON");var cls=el.getAttribute("class");var id=el.getAttribute("id");var playButtonStyles=opts&&opts.playButtonStyles?parseStyles(opts.playButtonStyles):["width:"+playSize+"px","height:"+playSize+"px","border-radius:"+playSize/2+"px","background:rgba(0, 0, 0, 0.3)","position:absolute","top:50%","left:50%","margin:-"+playSize/2+"px"].join(";");var playButtonIconStyles=opts&&opts.playButtonIconStyles?parseStyles(opts.playButtonIconStyles):["width: 0","height: 0","border-top: 14px solid transparent","border-bottom: 14px solid transparent","border-left: 14px solid rgba(0, 0, 0, 0.5)","position: absolute","left: 26px","top: 16px"].join(";");cls?con.setAttribute("class",el.getAttribute("class")):null;id?con.setAttribute("id",el.getAttribute("id")):null;con.setAttribute("style","position:relative;cursor:pointer;background:none;border:none;padding:0;");con.setAttribute("aria-hidden","true");var play=d.createElement("DIV");play.setAttribute("class","gifffer-play-button");play.setAttribute("style",playButtonStyles);var trngl=d.createElement("DIV");trngl.setAttribute("style",playButtonIconStyles);play.appendChild(trngl);if(altText){alt=d.createElement("p");alt.setAttribute("class","gifffer-alt");alt.setAttribute("style","border:0;clip:rect(0 0 0 0);height:1px;overflow:hidden;padding:0;position:absolute;width:1px;");alt.innerText=altText+", image"}con.appendChild(play);el.parentNode.replaceChild(con,el);altText?con.parentNode.insertBefore(alt,con.nextSibling):null;return{c:con,p:play}}function calculatePercentageDim(el,w,h,wOrig,hOrig){var parentDimW=el.parentNode.offsetWidth;var parentDimH=el.parentNode.offsetHeight;var ratio=wOrig/hOrig;if(w.toString().indexOf("%")>0){w=parseInt(w.toString().replace("%",""));w=w/100*parentDimW;h=w/ratio}else if(h.toString().indexOf("%")>0){h=parseInt(h.toString().replace("%",""));h=h/100*parentDimW;w=h*ratio}return{w:w,h:h}}function process(el,gifs,options){var url,con,c,w,h,duration,play,gif,playing=false,cc,isC,durationTimeout,dims,altText;url=el.getAttribute("data-gifffer");w=el.getAttribute("data-gifffer-width");h=el.getAttribute("data-gifffer-height");duration=el.getAttribute("data-gifffer-duration");altText=el.getAttribute("data-gifffer-alt");el.style.display="block";c=document.createElement("canvas");isC=!!(c.getContext&&c.getContext("2d"));if(w&&h&&isC)cc=createContainer(w,h,el,altText,options);el.onload=function(){if(!isC)return;w=w||el.width;h=h||el.height;if(!cc)cc=createContainer(w,h,el,altText,options);con=cc.c;play=cc.p;dims=calculatePercentageDim(con,w,h,el.width,el.height);gifs.push(con);con.addEventListener("click",function(){clearTimeout(durationTimeout);if(!playing){playing=true;gif=document.createElement("IMG");gif.setAttribute("style","width:100%;height:100%;");gif.setAttribute("data-uri",Math.floor(Math.random()*1e5)+1);setTimeout(function(){gif.src=url},0);con.removeChild(play);con.removeChild(c);con.appendChild(gif);if(parseInt(duration)>0){durationTimeout=setTimeout(function(){playing=false;con.appendChild(play);con.removeChild(gif);con.appendChild(c);gif=null},duration)}}else{playing=false;con.appendChild(play);con.removeChild(gif);con.appendChild(c);gif=null}});c.width=dims.w;c.height=dims.h;c.getContext("2d").drawImage(el,0,0,dims.w,dims.h);con.appendChild(c);con.setAttribute("style","position:relative;cursor:pointer;width:"+dims.w+"px;height:"+dims.h+"px;background:none;border:none;padding:0;");c.style.width="100%";c.style.height="100%";if(w.toString().indexOf("%")>0&&h.toString().indexOf("%")>0){con.style.width=w;con.style.height=h}else if(w.toString().indexOf("%")>0){con.style.width=w;con.style.height="inherit"}else if(h.toString().indexOf("%")>0){con.style.width="inherit";con.style.height=h}else{con.style.width=dims.w+"px";con.style.height=dims.h+"px"}};el.src=url}return Gifffer}); \ No newline at end of file diff --git a/landslide/themes/default/js/slides.js b/landslide/themes/default/js/slides.js index 6b2c8f69..03fe01c8 100644 --- a/landslide/themes/default/js/slides.js +++ b/landslide/themes/default/js/slides.js @@ -550,48 +550,37 @@ function main() { } }; - var handleAutoplays = function() { - // Stop autoplaying video and audio on all slides except current - var videos = document.getElementsByTagName('video'); - var audios = document.getElementsByTagName('audio'); + var setPlayStatuses = function(medias) { var cSlide = document.getElementsByClassName('current')[0]; - for (var i = 0; i < videos.length; i++) { - if (videos[i].hasAttribute('autoplay')) { - if (isPresenterView) { - videos[i].pause(); - videos[i].currentTime = 0; - } - else { - if (cSlide.contains(videos[i])) { - videos[i].play(); - } - else { - videos[i].pause(); - videos[i].currentTime = 0; - } - } - } - } - for (var i = 0; i < audios.length; i++) { - if (audios[i].hasAttribute('autoplay')) { + for (var i = 0; i < medias.length; i++) { + if (medias[i].hasAttribute('autoplay')) { if (isPresenterView) { - audios[i].pause(); - audios[i].currentTime = 0; + medias[i].pause(); + medias[i].currentTime = 0; } else { - if (cSlide.contains(audios[i])) { - audios[i].play(); + if (cSlide.contains(medias[i])) { + medias[i].play(); } else { - audios[i].pause(); - audios[i].currentTime = 0; + medias[i].pause(); + medias[i].currentTime = 0; } } } } }; + var handleAutoplays = function() { + // Stop autoplaying video and audio on all slides except current + var videos = document.getElementsByTagName('video'); + setPlayStatuses(videos); + + var audios = document.getElementsByTagName('audio'); + setPlayStatuses(audios); + }; + var setInternalTargets = function(refs) { for (var i = 0; i < refs.length; i++) { var parts = refs[i].href.split('#'); From 42489b39db79a9bea3d48bfe6fc1e27574d22165 Mon Sep 17 00:00:00 2001 From: doakey3 Date: Mon, 13 Nov 2017 10:23:11 -0700 Subject: [PATCH 3/6] disallow hide context for presenter view --- landslide/themes/default/js/slides.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/landslide/themes/default/js/slides.js b/landslide/themes/default/js/slides.js index 03fe01c8..0938d228 100644 --- a/landslide/themes/default/js/slides.js +++ b/landslide/themes/default/js/slides.js @@ -344,10 +344,12 @@ function main() { }; var hideContext = function() { - try { - var presentation = document.getElementsByClassName('slides')[0]; - addClass(presentation, 'nocontext'); - } catch (e) {} + if (!isPresenterView) { + try { + var presentation = document.getElementsByClassName('slides')[0]; + addClass(presentation, 'nocontext'); + } catch (e) {} + } }; var processContext = function() { From bc4e40a4e7aadba86b60e49eab3d511c234be65d Mon Sep 17 00:00:00 2001 From: doakey3 Date: Fri, 17 Nov 2017 21:01:25 -0700 Subject: [PATCH 4/6] Animated gifs play when current slide is active This update required the use of the autoplayed media (video & audio) was also fixed (going in and out of expose mode now behaves as expected). --- landslide/themes/default/js/slides.js | 54 +++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/landslide/themes/default/js/slides.js b/landslide/themes/default/js/slides.js index 0938d228..24859ed9 100644 --- a/landslide/themes/default/js/slides.js +++ b/landslide/themes/default/js/slides.js @@ -1,3 +1,6 @@ +// Gifffer, for controlling GIFs +(function webpackUniversalModuleDefinition(root,factory){if(typeof exports==="object"&&typeof module==="object")module.exports=factory();else if(typeof define==="function"&&define.amd)define("Gifffer",[],factory);else if(typeof exports==="object")exports["Gifffer"]=factory();else root["Gifffer"]=factory()})(this,function(){var d=document;var playSize=60;var Gifffer=function(options){var images,i=0,gifs=[];images=d.querySelectorAll("[data-gifffer]");for(;i0?"":"px")}function parseStyles(styles){var stylesStr="";for(prop in styles)stylesStr+=prop+":"+styles[prop]+";";return stylesStr}function createContainer(w,h,el,altText,opts){var alt;var con=d.createElement("BUTTON");var cls=el.getAttribute("class");var id=el.getAttribute("id");var playButtonStyles=opts&&opts.playButtonStyles?parseStyles(opts.playButtonStyles):["width:"+playSize+"px","height:"+playSize+"px","border-radius:"+playSize/2+"px","background:rgba(0, 0, 0, 0.3)","position:absolute","top:50%","left:50%","margin:-"+playSize/2+"px"].join(";");var playButtonIconStyles=opts&&opts.playButtonIconStyles?parseStyles(opts.playButtonIconStyles):["width: 0","height: 0","border-top: 14px solid transparent","border-bottom: 14px solid transparent","border-left: 14px solid rgba(0, 0, 0, 0.5)","position: absolute","left: 26px","top: 16px"].join(";");cls?con.setAttribute("class",el.getAttribute("class")):null;id?con.setAttribute("id",el.getAttribute("id")):null;con.setAttribute("style","position:relative;cursor:pointer;background:none;border:none;padding:0;");con.setAttribute("aria-hidden","true");var play=d.createElement("DIV");play.setAttribute("class","gifffer-play-button");play.setAttribute("style",playButtonStyles);var trngl=d.createElement("DIV");trngl.setAttribute("style",playButtonIconStyles);play.appendChild(trngl);if(altText){alt=d.createElement("p");alt.setAttribute("class","gifffer-alt");alt.setAttribute("style","border:0;clip:rect(0 0 0 0);height:1px;overflow:hidden;padding:0;position:absolute;width:1px;");alt.innerText=altText+", image"}con.appendChild(play);el.parentNode.replaceChild(con,el);altText?con.parentNode.insertBefore(alt,con.nextSibling):null;return{c:con,p:play}}function calculatePercentageDim(el,w,h,wOrig,hOrig){var parentDimW=el.parentNode.offsetWidth;var parentDimH=el.parentNode.offsetHeight;var ratio=wOrig/hOrig;if(w.toString().indexOf("%")>0){w=parseInt(w.toString().replace("%",""));w=w/100*parentDimW;h=w/ratio}else if(h.toString().indexOf("%")>0){h=parseInt(h.toString().replace("%",""));h=h/100*parentDimW;w=h*ratio}return{w:w,h:h}}function process(el,gifs,options){var url,con,c,w,h,duration,play,gif,playing=false,cc,isC,durationTimeout,dims,altText;url=el.getAttribute("data-gifffer");w=el.getAttribute("data-gifffer-width");h=el.getAttribute("data-gifffer-height");duration=el.getAttribute("data-gifffer-duration");altText=el.getAttribute("data-gifffer-alt");el.style.display="block";c=document.createElement("canvas");isC=!!(c.getContext&&c.getContext("2d"));if(w&&h&&isC)cc=createContainer(w,h,el,altText,options);el.onload=function(){if(!isC)return;w=w||el.width;h=h||el.height;if(!cc)cc=createContainer(w,h,el,altText,options);con=cc.c;play=cc.p;dims=calculatePercentageDim(con,w,h,el.width,el.height);gifs.push(con);con.addEventListener("click",function(){clearTimeout(durationTimeout);if(!playing){playing=true;gif=document.createElement("IMG");gif.setAttribute("style","width:100%;height:100%;");gif.setAttribute("data-uri",Math.floor(Math.random()*1e5)+1);setTimeout(function(){gif.src=url},0);con.removeChild(play);con.removeChild(c);con.appendChild(gif);if(parseInt(duration)>0){durationTimeout=setTimeout(function(){playing=false;con.appendChild(play);con.removeChild(gif);con.appendChild(c);gif=null},duration)}}else{playing=false;con.appendChild(play);con.removeChild(gif);con.appendChild(c);gif=null}});c.width=dims.w;c.height=dims.h;c.getContext("2d").drawImage(el,0,0,dims.w,dims.h);con.appendChild(c);con.setAttribute("style","position:relative;cursor:pointer;width:"+dims.w+"px;height:"+dims.h+"px;background:none;border:none;padding:0;");c.style.width="100%";c.style.height="100%";if(w.toString().indexOf("%")>0&&h.toString().indexOf("%")>0){con.style.width=w;con.style.height=h}else if(w.toString().indexOf("%")>0){con.style.width=w;con.style.height="inherit"}else if(h.toString().indexOf("%")>0){con.style.width="inherit";con.style.height=h}else{con.style.width=dims.w+"px";con.style.height=dims.h+"px"}};el.src=url}return Gifffer}); + function main() { // Since we don't have the fallback of attachEvent and // other IE only stuff we won't try to run JS for IE. @@ -20,6 +23,7 @@ function main() { var showingPresenterView = false; var presenterViewWin = null; var isPresenterView = false; + var gifs = []; var str2array = function(s) { if (typeof s == 'string' || s instanceof String) { @@ -129,6 +133,8 @@ function main() { document.getElementsByTagName('title')[0].innerText = getSlideTitle(currentSlideNo); updatePresenterNotes(); + + handleAutoplays(); if (updateOther) { updateOtherPage(); } }; @@ -171,7 +177,6 @@ function main() { currentSlideNo++; } updateSlideClasses(true); - handleAutoplays(); }; var prevSlide = function() { @@ -179,13 +184,11 @@ function main() { currentSlideNo--; } updateSlideClasses(true); - handleAutoplays(); }; var gotoSlide = function(slideNumber) { currentSlideNo = slideNumber; updateSlideClasses(true); - handleAutoplays(); } main.gotoSlide = gotoSlide; @@ -276,6 +279,9 @@ function main() { } processContext(); updateOverview(); + + + }; var updateOverview = function() { @@ -334,6 +340,7 @@ function main() { setScale(scale); expanded = true; } + }; var showContext = function() { @@ -517,7 +524,6 @@ function main() { if (e.data.indexOf("slide#") != -1) { currentSlideNo = Number(e.data.replace('slide#', '')); updateSlideClasses(false); - handleAutoplays(); } }, false); }; @@ -581,8 +587,47 @@ function main() { var audios = document.getElementsByTagName('audio'); setPlayStatuses(audios); + + var cSlide = document.getElementsByClassName('current')[0]; + for (var i = 0; i < gifs.length; i++) { + if (isPresenterView) { + if (gifs[i].hasAttribute('playing')) { + gifs[i].click(); + gifs[i].removeAttribute('playing'); + } + } + else { + if (cSlide.contains(gifs[i])) { + gifs[i].click(); + gifs[i].setAttribute('playing', ''); + } + else { + if (gifs[i].hasAttribute('playing')) { + gifs[i].click(); + gifs[i].removeAttribute('playing'); + } + } + } + } }; + var setupGIFs = function() { + var images = document.getElementsByTagName('img'); + for (var i = 0; i < images.length; i++) { + var src = images[i].src; + var src_end = src.slice(src.length - 3, src.length); + + var alt = images[i].alt; + var alt_end = alt.slice(alt.length - 3, alt.length); + if (src_end == 'gif' || alt_end == 'gif') { + images[i].setAttribute('data-gifffer', src); + images[i].removeAttribute('src'); + } + } + gifs = Gifffer({playButtonStyles: {}, playButtonIconStyles: {}}); + } + + var setInternalTargets = function(refs) { for (var i = 0; i < refs.length; i++) { var parts = refs[i].href.split('#'); @@ -647,6 +692,7 @@ function main() { addRemoteWindowControls(); + setupGIFs(); handleAutoplays(); adaptInternalHyperlinks(); From 0bb3541ebbde479366d70442ef7a59040526ef18 Mon Sep 17 00:00:00 2001 From: doakey3 Date: Fri, 17 Nov 2017 21:33:00 -0700 Subject: [PATCH 5/6] removal of extra spaces --- landslide/themes/default/js/slides.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/landslide/themes/default/js/slides.js b/landslide/themes/default/js/slides.js index 24859ed9..5e6cdc0d 100644 --- a/landslide/themes/default/js/slides.js +++ b/landslide/themes/default/js/slides.js @@ -133,7 +133,6 @@ function main() { document.getElementsByTagName('title')[0].innerText = getSlideTitle(currentSlideNo); updatePresenterNotes(); - handleAutoplays(); if (updateOther) { updateOtherPage(); } @@ -279,9 +278,6 @@ function main() { } processContext(); updateOverview(); - - - }; var updateOverview = function() { @@ -625,8 +621,7 @@ function main() { } } gifs = Gifffer({playButtonStyles: {}, playButtonIconStyles: {}}); - } - + }; var setInternalTargets = function(refs) { for (var i = 0; i < refs.length; i++) { @@ -641,7 +636,7 @@ function main() { } } } - } + }; var adaptInternalHyperlinks = function() { // Set internal hyperlink (like footnotes) to goto target slide From 33b705cf6f292125bb597b8565c40daa6c85da58 Mon Sep 17 00:00:00 2001 From: doakey3 Date: Sun, 19 Nov 2017 10:19:35 -0700 Subject: [PATCH 6/6] GIF bug occurred when closing overview --- landslide/themes/default/js/slides.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/landslide/themes/default/js/slides.js b/landslide/themes/default/js/slides.js index 5e6cdc0d..60e85cfa 100644 --- a/landslide/themes/default/js/slides.js +++ b/landslide/themes/default/js/slides.js @@ -336,7 +336,6 @@ function main() { setScale(scale); expanded = true; } - }; var showContext = function() { @@ -594,8 +593,10 @@ function main() { } else { if (cSlide.contains(gifs[i])) { - gifs[i].click(); - gifs[i].setAttribute('playing', ''); + if (!gifs[i].hasAttribute('playing')) { + gifs[i].click(); + gifs[i].setAttribute('playing', ''); + } } else { if (gifs[i].hasAttribute('playing')) { @@ -690,6 +691,5 @@ function main() { setupGIFs(); handleAutoplays(); adaptInternalHyperlinks(); - })(); }