let slides = document.getElementsByClassName("slide");
let dots = document.getElementsByClassName("dot");
let stateBtn = document.getElementById("state");
+let expandBtn = document.getElementById("expand");
// Global state
let maxIndex = slides.length - 1;
if (dots.length - 1 != maxIndex) {
console.log("Number of control dots does not match number of slides");
}
+expandBtn.addEventListener("click", expand);
for (i = 0; i <= dots.length - 1; i++) {
dots[i].addEventListener("click", goToSlide);
dots[i].slide = i;
for (i = 1; i <= maxIndex; i++) {
var captionHeight = slides[i].getElementsByTagName("figcaption")[0].offsetHeight;
// Set figure height
- slides[i].style.height = slides[0].offsetHeight.toString() + "px";
+ slides[i].style.maxHeight = slides[0].offsetHeight.toString() + "px";
// Set image height
- slides[i].getElementsByTagName("img")[0].style.height = (firstSlideHeight - captionHeight).toString() + "px";
+ slides[i].getElementsByTagName("img")[0].style.maxHeight = (firstSlideHeight - captionHeight).toString() + "px";
}
}
// Play immediately despite mouseover
stateBtn.innerHTML = STATE_PAUSE;
timeout = setTimeout(playSlideshow, INTERVAL);
+ stateBtn.title = "Pause";
}
else {
// Pause until user presses play again
clearTimeout(timeout); // make sure timer is stopped
timeout = null;
stateBtn.innerHTML = STATE_PLAY;
+ stateBtn.title = "Play";
}
paused = !paused;
}
+
+function expand() {
+ // Open the image in a new tab
+ window.open(slides[currentSlide].getElementsByTagName('img')[0].src, 'blank');
+}