From: Hakim El Hattab Date: Thu, 25 Oct 2012 01:30:52 +0000 (-0400) Subject: fix keyboard navigation in ie9 (closes #202) X-Git-Tag: 2.1.0~13 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=747c4c4b3d7862d5c6889438b96bd7ad408b24bc;p=reveal.js.git fix keyboard navigation in ie9 (closes #202) --- diff --git a/js/reveal.js b/js/reveal.js index cb0205e..fcc064d 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -1088,9 +1088,14 @@ var Reveal = (function(){ * @param {Object} event */ function onDocumentKeyDown( event ) { - // Disregard the event if the target is editable or a - // modifier is present - if ( document.querySelector( ':focus' ) !== null || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey ) return; + // Check if there's a focused element that could be using + // the keyboard + var activeElement = document.activeElement; + var hasFocus = !!( document.activeElement && ( document.activeElement.type || document.activeElement.href || document.activeElement.contentEditable !== 'inherit' ) ); + + // Disregard the event if there's a focused element or a + // keyboard modifier key is present + if ( hasFocus || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey ) return; var triggered = true; diff --git a/js/reveal.min.js b/js/reveal.min.js index 278d5e8..958d271 100644 --- a/js/reveal.min.js +++ b/js/reveal.min.js @@ -64,10 +64,11 @@ if(am.length){am[am.length-1].classList.remove("visible");r("fragmenthidden",{fr if(al.length){al[al.length-1].classList.remove("visible");r("fragmenthidden",{fragment:al[al.length-1]});return true;}}return false;}function O(){clearTimeout(k); if(Y){k=setTimeout(x,Y);}}function B(){if(L()||Q()===false){a(m-1,0);}}function j(){if(L()||v()===false){a(m+1,0);}}function u(){if(L()||Q()===false){a(m,e-1); }}function F(){if(L()||v()===false){a(m,e+1);}}function Z(){if(Q()===false){if(g().up){u();}else{var al=document.querySelector(".reveal .slides>section.past:nth-child("+m+")"); -if(al){e=(al.querySelectorAll("section").length+1)||0;m--;a();}}}}function x(){if(v()===false){g().down?F():j();}O();}function ah(am){if(document.querySelector(":focus")!==null||am.shiftKey||am.altKey||am.ctrlKey||am.metaKey){return; -}var al=true;switch(am.keyCode){case 80:case 33:Z();break;case 78:case 34:x();break;case 72:case 37:B();break;case 76:case 39:j();break;case 75:case 38:u(); +if(al){e=(al.querySelectorAll("section").length+1)||0;m--;a();}}}}function x(){if(v()===false){g().down?F():j();}O();}function ah(an){var am=document.activeElement; +var ao=!!(document.activeElement&&(document.activeElement.type||document.activeElement.href||document.activeElement.contentEditable!=="inherit"));if(ao||an.shiftKey||an.altKey||an.ctrlKey||an.metaKey){return; +}var al=true;switch(an.keyCode){case 80:case 33:Z();break;case 78:case 34:x();break;case 72:case 37:B();break;case 76:case 39:j();break;case 75:case 38:u(); break;case 74:case 40:F();break;case 36:a(0);break;case 35:a(Number.MAX_VALUE);break;case 32:L()?ae():x();break;case 13:L()?ae():al=false;break;case 66:case 190:aa(); -break;case 70:ab();break;default:al=false;}if(al){am.preventDefault();}else{if(am.keyCode===27&&T){X();am.preventDefault();}}O();}function A(al){ac.startX=al.touches[0].clientX; +break;case 70:ab();break;default:al=false;}if(al){an.preventDefault();}else{if(an.keyCode===27&&T){X();an.preventDefault();}}O();}function A(al){ac.startX=al.touches[0].clientX; ac.startY=al.touches[0].clientY;ac.startCount=al.touches.length;if(al.touches.length===2&&R.overview){ac.startSpan=S({x:al.touches[1].clientX,y:al.touches[1].clientY},{x:ac.startX,y:ac.startY}); }}function af(aq){if(!ac.handled){var ao=aq.touches[0].clientX;var an=aq.touches[0].clientY;if(aq.touches.length===2&&ac.startCount===2&&R.overview){var ap=S({x:aq.touches[1].clientX,y:aq.touches[1].clientY},{x:ac.startX,y:ac.startY}); if(Math.abs(ac.startSpan-ap)>ac.threshold){ac.handled=true;if(ap