From: Michael Stapelberg Date: Fri, 22 Jul 2011 12:31:47 +0000 (+0200) Subject: screenshots: end slide show when navigating back to an empty hash (Thanks IsoLnCHiP) X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=54ae31fc07be850d3a55f85dade4a8e28bdfe856;p=i3%2Fi3.github.io screenshots: end slide show when navigating back to an empty hash (Thanks IsoLnCHiP) --- diff --git a/screenshots/index.html.mako b/screenshots/index.html.mako index c3f15ec..7dd87d9 100644 --- a/screenshots/index.html.mako +++ b/screenshots/index.html.mako @@ -217,17 +217,17 @@ $(document).ready(function() { // clicking anywhere outside the image will bring you back to the page var masks = $('#mask, #bigimg'); - var endshow = function() { + var endshow = function(fromhash) { masks.hide(); $('#maskinner img').remove(); - if (window.history.pushState) { + if (!fromhash && window.history.pushState) { window.history.pushState(undefined, 'i3 screenshots', '#'); } }; masks.click(function() { - endshow(); + endshow(false); }); $('.shot img').click(function() { @@ -311,7 +311,7 @@ $(document).ready(function() { break; // escape case 27: - endshow(); + endshow(false); break; } }; @@ -329,11 +329,15 @@ $(document).ready(function() { $(window).hashchange(function() { if (location.hash.length === 0) { + endshow(true); return; } - //console.log('hash has changed to ' + location.hash); var url = location.hash.substring(1); - loadimage(url, undefined, true); + if (url.length === 0) { + endshow(true); + } else { + loadimage(url, undefined, true); + } }); });