Commit 1731ffbf authored by Vadim Makeev's avatar Vadim Makeev

Fixes #139 (Shift-F5 bug) and #95 (Cmd-Alt-P feature)

parent 25382541
...@@ -798,30 +798,34 @@ window.shower = window.shower || (function(window, document, undefined) { ...@@ -798,30 +798,34 @@ window.shower = window.shower || (function(window, document, undefined) {
}, false); }, false);
document.addEventListener('keydown', function(e) { document.addEventListener('keydown', function(e) {
var currentSlideNumber, var currentSlideNumber = shower.getCurrentSlideNumber(),
slide; slide = shower.slideList[ currentSlideNumber !== -1 ? currentSlideNumber : 0 ],
slideNumber;
// Shortcut for alt, ctrl and meta keys switch (e.which) {
if (e.altKey || e.ctrlKey || e.metaKey) { return; } case 80: // P Alt Cmd
if (shower.isListMode() && e.altKey && e.metaKey) {
e.preventDefault();
currentSlideNumber = shower.getCurrentSlideNumber(); slideNumber = slide.number;
slide = shower.slideList[currentSlideNumber];
switch (e.which) { shower.go(slideNumber);
case 116: // F5 shower.enterSlideMode();
e.preventDefault(); shower.showPresenterNotes(slideNumber);
slide.timing && slide.initTimer(shower);
}
break;
case 116: // F5 (Shift)
e.preventDefault();
if (shower.isListMode()) { if (shower.isListMode()) {
var slideNumber = e.shiftKey ? currentSlideNumber : 0, slideNumber = e.shiftKey ? slide.number : 0;
slide;
// Warning: go must be before enterSlideMode.
// Otherwise there is a bug in Chrome
shower.go(slideNumber); shower.go(slideNumber);
shower.enterSlideMode(); shower.enterSlideMode();
shower.showPresenterNotes(slideNumber); shower.showPresenterNotes(slideNumber);
slide = shower.slideList[currentSlideNumber];
slide.timing && slide.initTimer(shower); slide.timing && slide.initTimer(shower);
} else { } else {
shower.enterListMode(); shower.enterListMode();
...@@ -831,12 +835,11 @@ window.shower = window.shower || (function(window, document, undefined) { ...@@ -831,12 +835,11 @@ window.shower = window.shower || (function(window, document, undefined) {
case 13: // Enter case 13: // Enter
if (shower.isListMode() && -1 !== currentSlideNumber) { if (shower.isListMode() && -1 !== currentSlideNumber) {
e.preventDefault(); e.preventDefault();
shower.enterSlideMode(); shower.enterSlideMode();
shower.showPresenterNotes(currentSlideNumber); shower.showPresenterNotes(currentSlideNumber);
if (slide.timing) { slide.timing && slide.initTimer(shower);
slide.initTimer(shower);
}
} }
break; break;
...@@ -852,10 +855,9 @@ window.shower = window.shower || (function(window, document, undefined) { ...@@ -852,10 +855,9 @@ window.shower = window.shower || (function(window, document, undefined) {
case 37: // Left case 37: // Left
case 72: // H case 72: // H
case 75: // K case 75: // K
if (shower.isSlideMode()) { if (e.altKey || e.ctrlKey || e.metaKey) { return; }
e.preventDefault(); e.preventDefault();
shower._turnPreviousSlide(); shower._turnPreviousSlide();
}
break; break;
case 34: // PgDown case 34: // PgDown
...@@ -863,32 +865,25 @@ window.shower = window.shower || (function(window, document, undefined) { ...@@ -863,32 +865,25 @@ window.shower = window.shower || (function(window, document, undefined) {
case 39: // Right case 39: // Right
case 76: // L case 76: // L
case 74: // J case 74: // J
if (shower.isSlideMode()) { if (e.altKey || e.ctrlKey || e.metaKey) { return; }
e.preventDefault(); e.preventDefault();
shower._turnNextSlide(); shower._turnNextSlide();
}
break; break;
case 36: // Home case 36: // Home
if (shower.isSlideMode()) { e.preventDefault();
e.preventDefault(); shower.first();
shower.first();
}
break; break;
case 35: // End case 35: // End
if (shower.isSlideMode()) { e.preventDefault();
e.preventDefault(); shower.last();
shower.last();
}
break; break;
case 9: // Tab = +1; Shift + Tab = -1 case 9: // Tab (Shift)
case 32: // Space = +1; Shift + Space = -1 case 32: // Space (Shift)
if (shower.isSlideMode()) { e.preventDefault();
e.preventDefault(); shower[e.shiftKey ? '_turnPreviousSlide' : '_turnNextSlide']();
shower[e.shiftKey ? '_turnPreviousSlide' : '_turnNextSlide']();
}
break; break;
default: default:
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment