Focus body when page visibility changes to ensure keyboard shortcuts are usable
This commit is contained in:
1 parent
059311923b
commit
6043756b2e
2 files changed
+37
-3
No files matched your search
+35
-1
@@ -80,6 +80,9 @@ var Reveal = (function(){
|
|||||||
// Opens links in an iframe preview overlay
|
// Opens links in an iframe preview overlay
|
||||||
previewLinks: false,
|
previewLinks: false,
|
||||||
|
|
||||||
|
// Focuses body when page changes visiblity to ensure keyboard shortcuts work
|
||||||
|
focusBodyOnPageVisiblityChange: true,
|
||||||
|
|
||||||
// Theme (see /css/theme)
|
// Theme (see /css/theme)
|
||||||
theme: null,
|
theme: null,
|
||||||
|
|
||||||
@@ -606,10 +609,23 @@ var Reveal = (function(){
|
|||||||
document.addEventListener( 'keydown', onDocumentKeyDown, false );
|
document.addEventListener( 'keydown', onDocumentKeyDown, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( config.progress && dom.progress ) {
|
if( config.progress && dom.progress ) {
|
||||||
dom.progress.addEventListener( 'click', onProgressClicked, false );
|
dom.progress.addEventListener( 'click', onProgressClicked, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( config.focusBodyOnPageVisiblityChange ) {
|
||||||
|
var visibilityChange;
|
||||||
|
if ('hidden' in document) {
|
||||||
|
visibilityChange = 'visibilitychange';
|
||||||
|
} else if ('msHidden' in document) {
|
||||||
|
visibilityChange = 'msvisibilitychange';
|
||||||
|
} else if ('webkitHidden' in document) {
|
||||||
|
visibilityChange = 'webkitvisibilitychange';
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener(visibilityChange, onPageVisibilityChange, false);
|
||||||
|
}
|
||||||
|
|
||||||
[ 'touchstart', 'click' ].forEach( function( eventName ) {
|
[ 'touchstart', 'click' ].forEach( function( eventName ) {
|
||||||
dom.controlsLeft.forEach( function( el ) { el.addEventListener( eventName, onNavigateLeftClicked, false ); } );
|
dom.controlsLeft.forEach( function( el ) { el.addEventListener( eventName, onNavigateLeftClicked, false ); } );
|
||||||
dom.controlsRight.forEach( function( el ) { el.addEventListener( eventName, onNavigateRightClicked, false ); } );
|
dom.controlsRight.forEach( function( el ) { el.addEventListener( eventName, onNavigateRightClicked, false ); } );
|
||||||
@@ -2655,6 +2671,24 @@ var Reveal = (function(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle for the window level 'visibilitychange' event.
|
||||||
|
*/
|
||||||
|
function onPageVisibilityChange( event ) {
|
||||||
|
|
||||||
|
var isHidden = document.webkitHidden ||
|
||||||
|
document.msHidden ||
|
||||||
|
document.hidden;
|
||||||
|
|
||||||
|
// If, after clicking a link or similar and we're coming back,
|
||||||
|
// focus the document.body to ensure we can use keyboard shortcuts
|
||||||
|
if( isHidden === false && document.activeElement !== document.body ) {
|
||||||
|
document.activeElement.blur();
|
||||||
|
document.body.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoked when a slide is and we're in the overview.
|
* Invoked when a slide is and we're in the overview.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Vendored
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
/*!
|
/*!
|
||||||
* reveal.js 2.6.0-dev (2013-09-19, 23:31)
|
* reveal.js 2.6.0-dev (2013-09-21, 22:18)
|
||||||
* http://lab.hakim.se/reveal-js
|
* http://lab.hakim.se/reveal-js
|
||||||
* MIT licensed
|
* MIT licensed
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Hakim El Hattab, http://hakim.se
|
* Copyright (C) 2013 Hakim El Hattab, http://hakim.se
|
||||||
*/
|
*/
|
||||||
var Reveal=function(){"use strict";function a(a){return b(),Lb||Kb?(window.addEventListener("load",C,!1),l(Rb,a),s(),c(),void 0):(document.body.setAttribute("class","no-transforms"),void 0)}function b(){Kb="WebkitPerspective"in document.body.style||"MozPerspective"in document.body.style||"msPerspective"in document.body.style||"OPerspective"in document.body.style||"perspective"in document.body.style,Lb="WebkitTransform"in document.body.style||"MozTransform"in document.body.style||"msTransform"in document.body.style||"OTransform"in document.body.style||"transform"in document.body.style,Mb=navigator.userAgent.match(/(iphone|ipod|android)/gi)}function c(){function a(){c.length&&head.js.apply(null,c),d()}for(var b=[],c=[],e=0,f=Rb.dependencies.length;f>e;e++){var g=Rb.dependencies[e];(!g.condition||g.condition())&&(g.async?c.push(g.src):b.push(g.src),"function"==typeof g.callback&&head.ready(g.src.match(/([\w\d_\-]*)\.?js$|[^\\\/]*$/i)[0],g.callback))}b.length?(head.ready(a),head.js.apply(null,b)):a()}function d(){f(),e(),i(),ab(),setTimeout(function(){Wb.slides.classList.remove("no-transition"),Sb=!0,u("ready",{indexh:Gb,indexv:Hb,currentSlide:Jb})},1)}function e(){var a=m(document.querySelectorAll(Ob));a.forEach(function(a){var b=m(a.querySelectorAll("section"));b.forEach(function(a,b){b>0&&a.classList.add("future")})})}function f(){Wb.theme=document.querySelector("#theme"),Wb.wrapper=document.querySelector(".reveal"),Wb.slides=document.querySelector(".reveal .slides"),Wb.slides.classList.add("no-transition"),Wb.background=g(Wb.wrapper,"div","backgrounds",null),Wb.progress=g(Wb.wrapper,"div","progress","<span></span>"),Wb.progressbar=Wb.progress.querySelector("span"),g(Wb.wrapper,"aside","controls",'<div class="navigate-left"></div><div class="navigate-right"></div><div class="navigate-up"></div><div class="navigate-down"></div>'),g(Wb.wrapper,"div","state-background",null),g(Wb.wrapper,"div","pause-overlay",null),Wb.controls=document.querySelector(".reveal .controls"),Wb.controlsLeft=m(document.querySelectorAll(".navigate-left")),Wb.controlsRight=m(document.querySelectorAll(".navigate-right")),Wb.controlsUp=m(document.querySelectorAll(".navigate-up")),Wb.controlsDown=m(document.querySelectorAll(".navigate-down")),Wb.controlsPrev=m(document.querySelectorAll(".navigate-prev")),Wb.controlsNext=m(document.querySelectorAll(".navigate-next"))}function g(a,b,c,d){var e=a.querySelector("."+c);return e||(e=document.createElement(b),e.classList.add(c),null!==d&&(e.innerHTML=d),a.appendChild(e)),e}function h(){function a(a,b){var c={background:a.getAttribute("data-background"),backgroundSize:a.getAttribute("data-background-size"),backgroundImage:a.getAttribute("data-background-image"),backgroundColor:a.getAttribute("data-background-color"),backgroundRepeat:a.getAttribute("data-background-repeat"),backgroundPosition:a.getAttribute("data-background-position"),backgroundTransition:a.getAttribute("data-background-transition")},d=document.createElement("div");return d.className="slide-background",c.background&&(/^(http|file|\/\/)/gi.test(c.background)||/\.(png|jpg|jpeg|gif|bmp)$/gi.test(c.background)?d.style.backgroundImage="url("+c.background+")":d.style.background=c.background),c.backgroundSize&&(d.style.backgroundSize=c.backgroundSize),c.backgroundImage&&(d.style.backgroundImage='url("'+c.backgroundImage+'")'),c.backgroundColor&&(d.style.backgroundColor=c.backgroundColor),c.backgroundRepeat&&(d.style.backgroundRepeat=c.backgroundRepeat),c.backgroundPosition&&(d.style.backgroundPosition=c.backgroundPosition),c.backgroundTransition&&d.setAttribute("data-background-transition",c.backgroundTransition),b.appendChild(d),d}r()&&document.body.classList.add("print-pdf"),Wb.background.innerHTML="",Wb.background.classList.add("no-transition"),m(document.querySelectorAll(Ob)).forEach(function(b){var c;c=r()?a(b,b):a(b,Wb.background),m(b.querySelectorAll("section")).forEach(function(b){r()?a(b,b):a(b,c)})}),Rb.parallaxBackgroundImage?(Wb.background.style.backgroundImage='url("'+Rb.parallaxBackgroundImage+'")',Wb.background.style.backgroundSize=Rb.parallaxBackgroundSize,setTimeout(function(){Wb.wrapper.classList.add("has-parallax-background")},1)):(Wb.background.style.backgroundImage="",Wb.wrapper.classList.remove("has-parallax-background"))}function i(a){if(Wb.wrapper.classList.remove(Rb.transition),"object"==typeof a&&l(Rb,a),Kb===!1&&(Rb.transition="linear"),Wb.wrapper.classList.add(Rb.transition),Wb.wrapper.setAttribute("data-transition-speed",Rb.transitionSpeed),Wb.wrapper.setAttribute("data-background-transition",Rb.backgroundTransition),Wb.controls.style.display=Rb.controls?"block":"none",Wb.progress.style.display=Rb.progress?"block":"none",Rb.rtl?Wb.wrapper.classList.add("rtl"):Wb.wrapper.classList.remove("rtl"),Rb.center?Wb.wrapper.classList.add("center"):Wb.wrapper.classList.remove("center"),Rb.mouseWheel?(document.addEventListener("DOMMouseScroll",ub,!1),document.addEventListener("mousewheel",ub,!1)):(document.removeEventLiLine truncated
|
var Reveal=function(){"use strict";function a(a){return b(),Mb||Lb?(window.addEventListener("load",C,!1),l(Sb,a),s(),c(),void 0):(document.body.setAttribute("class","no-transforms"),void 0)}function b(){Lb="WebkitPerspective"in document.body.style||"MozPerspective"in document.body.style||"msPerspective"in document.body.style||"OPerspective"in document.body.style||"perspective"in document.body.style,Mb="WebkitTransform"in document.body.style||"MozTransform"in document.body.style||"msTransform"in document.body.style||"OTransform"in document.body.style||"transform"in document.body.style,Nb=navigator.userAgent.match(/(iphone|ipod|android)/gi)}function c(){function a(){c.length&&head.js.apply(null,c),d()}for(var b=[],c=[],e=0,f=Sb.dependencies.length;f>e;e++){var g=Sb.dependencies[e];(!g.condition||g.condition())&&(g.async?c.push(g.src):b.push(g.src),"function"==typeof g.callback&&head.ready(g.src.match(/([\w\d_\-]*)\.?js$|[^\\\/]*$/i)[0],g.callback))}b.length?(head.ready(a),head.js.apply(null,b)):a()}function d(){f(),e(),i(),ab(),setTimeout(function(){Xb.slides.classList.remove("no-transition"),Tb=!0,u("ready",{indexh:Hb,indexv:Ib,currentSlide:Kb})},1)}function e(){var a=m(document.querySelectorAll(Pb));a.forEach(function(a){var b=m(a.querySelectorAll("section"));b.forEach(function(a,b){b>0&&a.classList.add("future")})})}function f(){Xb.theme=document.querySelector("#theme"),Xb.wrapper=document.querySelector(".reveal"),Xb.slides=document.querySelector(".reveal .slides"),Xb.slides.classList.add("no-transition"),Xb.background=g(Xb.wrapper,"div","backgrounds",null),Xb.progress=g(Xb.wrapper,"div","progress","<span></span>"),Xb.progressbar=Xb.progress.querySelector("span"),g(Xb.wrapper,"aside","controls",'<div class="navigate-left"></div><div class="navigate-right"></div><div class="navigate-up"></div><div class="navigate-down"></div>'),g(Xb.wrapper,"div","state-background",null),g(Xb.wrapper,"div","pause-overlay",null),Xb.controls=document.querySelector(".reveal .controls"),Xb.controlsLeft=m(document.querySelectorAll(".navigate-left")),Xb.controlsRight=m(document.querySelectorAll(".navigate-right")),Xb.controlsUp=m(document.querySelectorAll(".navigate-up")),Xb.controlsDown=m(document.querySelectorAll(".navigate-down")),Xb.controlsPrev=m(document.querySelectorAll(".navigate-prev")),Xb.controlsNext=m(document.querySelectorAll(".navigate-next"))}function g(a,b,c,d){var e=a.querySelector("."+c);return e||(e=document.createElement(b),e.classList.add(c),null!==d&&(e.innerHTML=d),a.appendChild(e)),e}function h(){function a(a,b){var c={background:a.getAttribute("data-background"),backgroundSize:a.getAttribute("data-background-size"),backgroundImage:a.getAttribute("data-background-image"),backgroundColor:a.getAttribute("data-background-color"),backgroundRepeat:a.getAttribute("data-background-repeat"),backgroundPosition:a.getAttribute("data-background-position"),backgroundTransition:a.getAttribute("data-background-transition")},d=document.createElement("div");return d.className="slide-background",c.background&&(/^(http|file|\/\/)/gi.test(c.background)||/\.(png|jpg|jpeg|gif|bmp)$/gi.test(c.background)?d.style.backgroundImage="url("+c.background+")":d.style.background=c.background),c.backgroundSize&&(d.style.backgroundSize=c.backgroundSize),c.backgroundImage&&(d.style.backgroundImage='url("'+c.backgroundImage+'")'),c.backgroundColor&&(d.style.backgroundColor=c.backgroundColor),c.backgroundRepeat&&(d.style.backgroundRepeat=c.backgroundRepeat),c.backgroundPosition&&(d.style.backgroundPosition=c.backgroundPosition),c.backgroundTransition&&d.setAttribute("data-background-transition",c.backgroundTransition),b.appendChild(d),d}r()&&document.body.classList.add("print-pdf"),Xb.background.innerHTML="",Xb.background.classList.add("no-transition"),m(document.querySelectorAll(Pb)).forEach(function(b){var c;c=r()?a(b,b):a(b,Xb.background),m(b.querySelectorAll("section")).forEach(function(b){r()?a(b,b):a(b,c)})}),Sb.parallaxBackgroundImage?(Xb.background.style.backgroundImage='url("'+Sb.parallaxBackgroundImage+'")',Xb.background.style.backgroundSize=Sb.parallaxBackgroundSize,setTimeout(function(){Xb.wrapper.classList.add("has-parallax-background")},1)):(Xb.background.style.backgroundImage="",Xb.wrapper.classList.remove("has-parallax-background"))}function i(a){if(Xb.wrapper.classList.remove(Sb.transition),"object"==typeof a&&l(Sb,a),Lb===!1&&(Sb.transition="linear"),Xb.wrapper.classList.add(Sb.transition),Xb.wrapper.setAttribute("data-transition-speed",Sb.transitionSpeed),Xb.wrapper.setAttribute("data-background-transition",Sb.backgroundTransition),Xb.controls.style.display=Sb.controls?"block":"none",Xb.progress.style.display=Sb.progress?"block":"none",Sb.rtl?Xb.wrapper.classList.add("rtl"):Xb.wrapper.classList.remove("rtl"),Sb.center?Xb.wrapper.classList.add("center"):Xb.wrapper.classList.remove("center"),Sb.mouseWheel?(document.addEventListener("DOMMouseScroll",ub,!1),document.addEventListener("mousewheel",ub,!1)):(document.removeEventLiLine truncated
|
||||||
Reference in new issue
Block a user