Merge pull request #147 from pepelsbey/master

Key handling refactoring
This commit is contained in:
Vadim Makeev 2013-07-11 12:13:45 -07:00
commit 3115491a9e
2 changed files with 37 additions and 42 deletions

View File

@ -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
if (e.altKey || e.ctrlKey || e.metaKey) { return; }
currentSlideNumber = shower.getCurrentSlideNumber();
slide = shower.slideList[currentSlideNumber];
switch (e.which) { switch (e.which) {
case 116: // F5 case 80: // P Alt Cmd
if (shower.isListMode() && e.altKey && e.metaKey) {
e.preventDefault(); e.preventDefault();
if (shower.isListMode()) { slideNumber = slide.number;
var slideNumber = e.shiftKey ? currentSlideNumber : 0,
slide; 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.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) {
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) {
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) {
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:

2
shower.min.js vendored

File diff suppressed because one or more lines are too long