From 54ae31fc07be850d3a55f85dade4a8e28bdfe856 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 22 Jul 2011 14:31:47 +0200 Subject: [PATCH] screenshots: end slide show when navigating back to an empty hash (Thanks IsoLnCHiP) --- screenshots/index.html.mako | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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); + } }); }); -- 2.39.5