merge keyboard shortcut changes

This commit is contained in:
Hakim El Hattab 2012-04-28 11:50:22 -04:00
parent 83e4a1f0ac
commit eee6e5f964
4 changed files with 33 additions and 21 deletions

View file

@ -97,6 +97,7 @@ document.addEventListener( 'someState', function() {
## History ## History
#### 1.3 (master) #### 1.3 (master)
- Revised keyboard shortcuts, including ESC for overview, N for next, P for previous. Thanks [mahemoff](https://github.com/mahemoff)
#### 1.2 #### 1.2
@ -151,4 +152,4 @@ document.addEventListener( 'someState', function() {
MIT licensed MIT licensed
Copyright (C) 2011 Hakim El Hattab, http://hakim.se Copyright (C) 2012 Hakim El Hattab, http://hakim.se

View file

@ -82,7 +82,7 @@
<section> <section>
<h2>Holistic Overview</h2> <h2>Holistic Overview</h2>
<p> <p>
Press <strong>SPACE</strong> to enter the slide overview! Press <strong>ESC</strong> to enter the slide overview!
</p> </p>
</section> </section>

View file

@ -3,7 +3,7 @@
* http://lab.hakim.se/reveal-js * http://lab.hakim.se/reveal-js
* MIT licensed * MIT licensed
* *
* Copyright (C) 2011 Hakim El Hattab, http://hakim.se * Copyright (C) 2012 Hakim El Hattab, http://hakim.se
*/ */
var Reveal = (function(){ var Reveal = (function(){
@ -37,7 +37,8 @@ var Reveal = (function(){
supports3DTransforms = document.body.style['perspectiveProperty'] !== undefined || supports3DTransforms = document.body.style['perspectiveProperty'] !== undefined ||
document.body.style['WebkitPerspective'] !== undefined || document.body.style['WebkitPerspective'] !== undefined ||
document.body.style['MozPerspective'] !== undefined || document.body.style['MozPerspective'] !== undefined ||
document.body.style['msPerspective'] !== undefined, document.body.style['msPerspective'] !== undefined ||
document.body.style['OPerspective'] !== undefined,
supports2DTransforms = document.body.style['transformProperty'] !== undefined || supports2DTransforms = document.body.style['transformProperty'] !== undefined ||
document.body.style['WebkitTransform'] !== undefined || document.body.style['WebkitTransform'] !== undefined ||
@ -155,22 +156,31 @@ var Reveal = (function(){
// FFT: Use document.querySelector( ':focus' ) === null // FFT: Use document.querySelector( ':focus' ) === null
// instead of checking contentEditable? // instead of checking contentEditable?
if ( event.target.contentEditable != 'inherit' || // Disregard the event if the target is editable or a
event.shiftKey || event.altKey || event.ctrlKey || event.metaKey ) return; // modifier is present
if ( event.target.contentEditable != 'inherit' || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey ) return;
var triggered = false; var triggered = false;
switch( event.keyCode ) { switch( event.keyCode ) {
case 80: case 33: navigatePrev(); triggered = true; break; // prev for wireless presenter (PgUp) // p, page up
case 78: case 32: case 34: navigateNext(); triggered = true; break; // next for wireless presenter (PgDn, Space) case 80: case 33: navigatePrev(); triggered = true; break;
case 72: case 37: navigateLeft(); triggered = true; break; // h, left // n, page down, space
case 76: case 39: navigateRight(); triggered = true; break; // l, right case 78: case 32: case 34: navigateNext(); triggered = true; break;
case 75: case 38: navigateUp(); triggered = true; break; // k, up // h, left
case 74: case 40: navigateDown(); triggered = true; break; // j, down case 72: case 37: navigateLeft(); triggered = true; break;
// l, right
case 76: case 39: navigateRight(); triggered = true; break;
// k, up
case 75: case 38: navigateUp(); triggered = true; break;
// j, down
case 74: case 40: navigateDown(); triggered = true; break;
} }
if (triggered) return event.preventDefault()
if ( event.keyCode === 27 && supports3DTransforms ) {
if( triggered ) {
event.preventDefault();
}
else if ( event.keyCode === 27 && supports3DTransforms ) {
if( overviewIsActive() ) { if( overviewIsActive() ) {
deactivateOverview(); deactivateOverview();
} }

13
js/reveal.min.js vendored
View file

@ -3,9 +3,9 @@
* http://lab.hakim.se/reveal-js * http://lab.hakim.se/reveal-js
* MIT licensed * MIT licensed
* *
* Copyright (C) 2011 Hakim El Hattab, http://hakim.se * Copyright (C) 2012 Hakim El Hattab, http://hakim.se
*/ */
var Reveal=(function(){var i="#reveal .slides>section",a="#reveal .slides>section.present>section",j=0,c=0,E={controls:false,progress:false,history:false,transition:"default",theme:"default",mouseWheel:true,rollingLinks:true},K=[],d={},F=document.body.style.perspectiveProperty!==undefined||document.body.style.WebkitPerspective!==undefined||document.body.style.MozPerspective!==undefined||document.body.style.msPerspective!==undefined,k=document.body.style.transformProperty!==undefined||document.body.style.WebkitTransform!==undefined||document.body.style.MozTransform!==undefined||document.body.style.msTransform!==undefined||document.body.style.OTransform!==undefined,t=0,w=0; var Reveal=(function(){var i="#reveal .slides>section",a="#reveal .slides>section.present>section",j=0,c=0,E={controls:false,progress:false,history:false,transition:"default",theme:"default",mouseWheel:true,rollingLinks:true},K=[],d={},F=document.body.style.perspectiveProperty!==undefined||document.body.style.WebkitPerspective!==undefined||document.body.style.MozPerspective!==undefined||document.body.style.msPerspective!==undefined||document.body.style.OPerspective!==undefined,k=document.body.style.transformProperty!==undefined||document.body.style.WebkitTransform!==undefined||document.body.style.MozTransform!==undefined||document.body.style.msTransform!==undefined||document.body.style.OTransform!==undefined,t=0,w=0;
function g(M){if(!k&&!F){document.body.setAttribute("class","no-transforms");return;}d.wrapper=document.querySelector("#reveal");d.progress=document.querySelector("#reveal .progress"); function g(M){if(!k&&!F){document.body.setAttribute("class","no-transforms");return;}d.wrapper=document.querySelector("#reveal");d.progress=document.querySelector("#reveal .progress");
d.progressbar=document.querySelector("#reveal .progress span");d.controls=document.querySelector("#reveal .controls");d.controlsLeft=document.querySelector("#reveal .controls .left"); d.progressbar=document.querySelector("#reveal .progress span");d.controls=document.querySelector("#reveal .controls");d.controlsLeft=document.querySelector("#reveal .controls .left");
d.controlsRight=document.querySelector("#reveal .controls .right");d.controlsUp=document.querySelector("#reveal .controls .up");d.controlsDown=document.querySelector("#reveal .controls .down"); d.controlsRight=document.querySelector("#reveal .controls .right");d.controlsUp=document.querySelector("#reveal .controls .up");d.controlsDown=document.querySelector("#reveal .controls .down");
@ -13,10 +13,11 @@ document.addEventListener("keydown",J,false);document.addEventListener("touchsta
d.controlsRight.addEventListener("click",m(h),false);d.controlsUp.addEventListener("click",m(p),false);d.controlsDown.addEventListener("click",m(y),false); d.controlsRight.addEventListener("click",m(h),false);d.controlsUp.addEventListener("click",m(p),false);d.controlsDown.addEventListener("click",m(y),false);
o(E,M);if(F===false){E.transition="linear";}if(E.controls){d.controls.style.display="block";}if(E.progress){d.progress.style.display="block";}if(E.transition!=="default"){d.wrapper.classList.add(E.transition); o(E,M);if(F===false){E.transition="linear";}if(E.controls){d.controls.style.display="block";}if(E.progress){d.progress.style.display="block";}if(E.transition!=="default"){d.wrapper.classList.add(E.transition);
}if(E.theme!=="default"){d.wrapper.classList.add(E.theme);}if(E.mouseWheel){document.addEventListener("DOMMouseScroll",l,false);document.addEventListener("mousewheel",l,false); }if(E.theme!=="default"){d.wrapper.classList.add(E.theme);}if(E.mouseWheel){document.addEventListener("DOMMouseScroll",l,false);document.addEventListener("mousewheel",l,false);
}if(E.rollingLinks){B();}A();}function o(N,M){for(var O in M){N[O]=M[O];}}function m(M){return function(N){N.preventDefault();M.call();};}function J(M){if(M.target.contentEditable==="inherit"){if(M.keyCode>=33&&M.keyCode<=40){switch(M.keyCode){case 33:G(); }if(E.rollingLinks){B();}A();}function o(N,M){for(var O in M){N[O]=M[O];}}function m(M){return function(N){N.preventDefault();M.call();};}function J(N){if(N.target.contentEditable!="inherit"||N.shiftKey||N.altKey||N.ctrlKey||N.metaKey){return;
break;case 34:s();break;case 37:v();break;case 39:h();break;case 38:p();break;case 40:y();break;}M.preventDefault();}else{if(M.keyCode===32&&F){if(H()){I(); }var M=false;switch(N.keyCode){case 80:case 33:G();M=true;break;case 78:case 32:case 34:s();M=true;break;case 72:case 37:v();M=true;break;case 76:case 39:h();
}else{z();}M.preventDefault();}}}}function u(P){if(P.touches.length===1){if(P.target.tagName.toLowerCase()==="a"||P.target.tagName.toLowerCase()==="img"){return; M=true;break;case 75:case 38:p();M=true;break;case 74:case 40:y();M=true;break;}if(M){N.preventDefault();}else{if(N.keyCode===27&&F){if(H()){I();}else{z();
}P.preventDefault();var N={x:P.touches[0].clientX,y:P.touches[0].clientY};var M=window.innerWidth*0.3;var O=window.innerHeight*0.3;if(N.x<M){v();}else{if(N.x>window.innerWidth-M){h(); }N.preventDefault();}}}function u(P){if(P.touches.length===1){if(P.target.tagName.toLowerCase()==="a"||P.target.tagName.toLowerCase()==="img"){return;}P.preventDefault();
var N={x:P.touches[0].clientX,y:P.touches[0].clientY};var M=window.innerWidth*0.3;var O=window.innerHeight*0.3;if(N.x<M){v();}else{if(N.x>window.innerWidth-M){h();
}else{if(N.y<O){p();}else{if(N.y>window.innerHeight-O){y();}}}}b();}}function l(M){clearTimeout(t);t=setTimeout(function(){var N=M.detail||-M.wheelDelta; }else{if(N.y<O){p();}else{if(N.y>window.innerHeight-O){y();}}}}b();}}function l(M){clearTimeout(t);t=setTimeout(function(){var N=M.detail||-M.wheelDelta;
if(N>0){s();}else{G();}},100);}function r(M){A();}function B(){if(F){var N=document.querySelectorAll("#reveal .slides section a:not(.image)");for(var O=0,M=N.length; if(N>0){s();}else{G();}},100);}function r(M){A();}function B(){if(F){var N=document.querySelectorAll("#reveal .slides section a:not(.image)");for(var O=0,M=N.length;
O<M;O++){var P=N[O];if(P.textContent&&!P.querySelector("img")&&(!P.className||!P.classList.contains(P,"roll"))){P.classList.add("roll");P.innerHTML='<span data-title="'+P.text+'">'+P.innerHTML+"</span>"; O<M;O++){var P=N[O];if(P.textContent&&!P.querySelector("img")&&(!P.className||!P.classList.contains(P,"roll"))){P.classList.add("roll");P.innerHTML='<span data-title="'+P.text+'">'+P.innerHTML+"</span>";