# HG changeset patch # User veltr # Date 1372427220 -7200 # Node ID 24607434c13b040f9023636c7f70036367c0971a # Parent 2b050be8ffd7e7d4c3309616673c4d7519cf1b5f Added keyboard control on slideshow diff -r 2b050be8ffd7 -r 24607434c13b integration/v2/img/slideshow-controls.png Binary file integration/v2/img/slideshow-controls.png has changed diff -r 2b050be8ffd7 -r 24607434c13b integration/v2/js/slideshow.js --- a/integration/v2/js/slideshow.js Fri Jun 28 15:38:29 2013 +0200 +++ b/integration/v2/js/slideshow.js Fri Jun 28 15:47:00 2013 +0200 @@ -71,13 +71,36 @@ } } - function nextSlide() { + var playInterval, playing = false; + + function toggleSlideShow() { + clearInterval(playInterval); + playing = !playing; + var jqppbtn = $(".play-pause"); + if (playing) { + jqppbtn.addClass("pause"); + playInterval = setInterval(nextSlide,4000,false); + } else { + jqppbtn.removeClass("pause"); + } + return false; + } + + function nextSlide(resetInterval) { + if (!!resetInterval && playing) { + playing = false; + toggleSlideShow(); + } currentSlide = (currentSlide + 1) % slides.length; showSlide(); return false; } - function prevSlide() { + function prevSlide(resetInterval) { + if (!!resetInterval && playing) { + playing = false; + toggleSlideShow(); + } currentSlide = (currentSlide > 0 ? currentSlide - 1 : slides.length - 1); showSlide(); return false; @@ -126,20 +149,8 @@ && typeof document.webkitIsFullScreen === "undefined") { $(".full-screen").remove(); } - - var playInterval, playing = false; - - $(".play-pause").click(function() { - clearInterval(playInterval); - playing = !playing; - if (playing) { - $(this).addClass("pause"); - playInterval = setInterval(nextSlide,4000); - } else { - $(this).removeClass("pause"); - } - return false; - }); + + $(".play-pause").click(toggleSlideShow); slides.forEach(function(slide, k) { if (!slide.path) { @@ -158,4 +169,25 @@ jqwin.resize(showSlide); + $(document).keydown(function(e) { + if (e.keyCode === 122) { // F11 + fullScreen(); + return false; + } + if (e.keyCode === 32) { // Space + jqControls.show(); + resetTO(); + toggleSlideShow(); + return false; + } + if (e.keyCode === 37) { // Left-Arrow + prevSlide(true); + return false; + } + if (e.keyCode === 39) { // Right-Arrow + nextSlide(true); + return false; + } + }); + }); \ No newline at end of file