Merge pull request #91 from EvgenyZhlobo/f5-hotkeys

Add F5 hotkey
This commit is contained in:
Vadim Makeev 2012-12-08 11:04:17 -08:00
commit daddeee656
1 changed files with 25 additions and 1 deletions

View File

@ -483,7 +483,7 @@ window.shower = (function(window, document, undefined) {
}, false); }, false);
document.addEventListener('keydown', function (e) { document.addEventListener('keydown', function (e) {
// Shortcut for alt, shift and meta keys // Shortcut for alt, ctrl and meta keys
if (e.altKey || e.ctrlKey || e.metaKey) { return; } if (e.altKey || e.ctrlKey || e.metaKey) { return; }
var currentSlideNumber = shower.getCurrentSlideNumber(), var currentSlideNumber = shower.getCurrentSlideNumber(),
@ -491,6 +491,30 @@ window.shower = (function(window, document, undefined) {
switch (e.which) { switch (e.which) {
case 116: // F5 case 116: // F5
e.preventDefault();
if (shower.isListMode()) {
var slideNumber = e.shiftKey ? currentSlideNumber : 0;
shower.go(slideNumber);
if (isHistoryApiSupported) {
history.pushState(null, null, url.pathname + '?full' + shower.getSlideHash(slideNumber));
}
shower.enterSlideMode();
shower.updateProgress(slideNumber);
shower.updateCurrentAndPassedSlides(slideNumber);
shower.runSlideshowIfPresented(slideNumber);
} else {
if (isHistoryApiSupported) {
history.pushState(null, null, url.pathname + shower.getSlideHash(currentSlideNumber));
}
shower.enterListMode();
shower.scrollToSlide(currentSlideNumber);
}
break;
case 13: // Enter case 13: // Enter
if (shower.isListMode() && -1 !== currentSlideNumber) { if (shower.isListMode() && -1 !== currentSlideNumber) {
e.preventDefault(); e.preventDefault();