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

This commit is contained in:
Vadim Makeev 2013-07-11 23:08:59 +04:00
parent 25382541d4
commit 1731ffbf9f
2 changed files with 37 additions and 42 deletions

View File

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

2
shower.min.js vendored

File diff suppressed because one or more lines are too long