app/js/gallery.js in servel-0.27.0 vs app/js/gallery.js in servel-0.28.0

- old
+ new

@@ -2,10 +2,12 @@ var Gallery = (function() { var LAYOUT_MODES = ["fit-both", "fit-width", "clamp-width"]; var $gallery; + var $video; + var $audio; var currentIndex; var layoutModeIndex = 0; function renderText(url) { var http = new XMLHttpRequest(); @@ -18,13 +20,14 @@ http.send(); } function clearContent() { $gallery.classList.remove("image", "video", "audio", "text"); - $("#image").removeAttribute('src'); - $("#video").removeAttribute('src'); - $("#audio").removeAttribute('src'); + $video.removeAttribute('src'); + $video.pause(); + $audio.removeAttribute('src'); + $audio.pause(); $("#text-content").innerHTML = ""; } function render() { clearContent(); @@ -96,11 +99,10 @@ layoutModeIndex++; if(layoutModeIndex >= LAYOUT_MODES.length) layoutModeIndex = 0; } function playPauseVideo() { - var $video = $("#video"); if ($video.paused || $video.ended) $video.play(); else $video.pause(); } function initEvents() { @@ -160,14 +162,14 @@ var maxHeight = layoutMode == "fit-both" ? viewportHeight : "none"; var maxWidth = layoutMode == "clamp-width" ? "1000px" : "100%"; $("#image").style.maxWidth = maxWidth; $("#image").style.maxHeight = maxHeight; - $("#video").style.maxWidth = maxWidth; - $("#video").style.maxHeight = maxHeight; - $("#audio").style.maxWidth = maxWidth; - $("#audio").style.maxHeight = maxHeight; + $video.style.maxWidth = maxWidth; + $video.style.maxHeight = maxHeight; + $audio.style.maxWidth = maxWidth; + $audio.style.maxHeight = maxHeight; } function initLayout() { window.addEventListener("resize", layout); layout(); @@ -178,9 +180,11 @@ if(Entries.hasMedia()) render(); } function init() { $gallery = $("#gallery"); + $video = $("#video"); + $audio = $("#audio"); onEntriesUpdate(); if(Entries.hasMedia()) { document.body.classList.add("has-gallery"); \ No newline at end of file