aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2012-06-13 07:21:50 -0700
committerHakim El Hattab <hakim.elhattab@gmail.com>2012-06-13 07:21:50 -0700
commit2d44d1e25f7f3704ad5abd1c25cb73e09292425e (patch)
treebebb65cdbd751a24b6e005be4a0660b2dd4e396a
parenta91d40191984679276a0549f5d8adc20005bc8d2 (diff)
parent9de23f022c512a0be4edc593c14ffb22e5b0ebb2 (diff)
downloadperl-software-in-gnu-guix-2d44d1e25f7f3704ad5abd1c25cb73e09292425e.tar
perl-software-in-gnu-guix-2d44d1e25f7f3704ad5abd1c25cb73e09292425e.tar.gz
Merge pull request #58 from danielmitd/controls
fix JS error when controls are removed from HTML
-rw-r--r--js/reveal.js41
1 files changed, 26 insertions, 15 deletions
diff --git a/js/reveal.js b/js/reveal.js
index 9744abd..2d9603c 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -87,11 +87,14 @@ var Reveal = (function(){
dom.wrapper = document.querySelector( '.reveal' );
dom.progress = document.querySelector( '.reveal .progress' );
dom.progressbar = document.querySelector( '.reveal .progress span' );
- dom.controls = document.querySelector( '.reveal .controls' );
- dom.controlsLeft = document.querySelector( '.reveal .controls .left' );
- dom.controlsRight = document.querySelector( '.reveal .controls .right' );
- dom.controlsUp = document.querySelector( '.reveal .controls .up' );
- dom.controlsDown = document.querySelector( '.reveal .controls .down' );
+
+ if ( config.controls ) {
+ dom.controls = document.querySelector( '.reveal .controls' );
+ dom.controlsLeft = document.querySelector( '.reveal .controls .left' );
+ dom.controlsRight = document.querySelector( '.reveal .controls .right' );
+ dom.controlsUp = document.querySelector( '.reveal .controls .up' );
+ dom.controlsDown = document.querySelector( '.reveal .controls .down' );
+ }
addEventListeners();
@@ -123,7 +126,7 @@ var Reveal = (function(){
config.transition = 'linear';
}
- if( config.controls ) {
+ if( config.controls && dom.controls ) {
dom.controls.style.display = 'block';
}
@@ -156,11 +159,13 @@ var Reveal = (function(){
document.addEventListener( 'touchmove', onDocumentTouchMove, false );
document.addEventListener( 'touchend', onDocumentTouchEnd, false );
window.addEventListener( 'hashchange', onWindowHashChange, false );
-
- dom.controlsLeft.addEventListener( 'click', preventAndForward( navigateLeft ), false );
- dom.controlsRight.addEventListener( 'click', preventAndForward( navigateRight ), false );
- dom.controlsUp.addEventListener( 'click', preventAndForward( navigateUp ), false );
- dom.controlsDown.addEventListener( 'click', preventAndForward( navigateDown ), false );
+
+ if ( config.controls && dom.controls ) {
+ dom.controlsLeft.addEventListener( 'click', preventAndForward( navigateLeft ), false );
+ dom.controlsRight.addEventListener( 'click', preventAndForward( navigateRight ), false );
+ dom.controlsUp.addEventListener( 'click', preventAndForward( navigateUp ), false );
+ dom.controlsDown.addEventListener( 'click', preventAndForward( navigateDown ), false );
+ }
}
function removeEventListeners() {
@@ -170,10 +175,12 @@ var Reveal = (function(){
document.removeEventListener( 'touchend', onDocumentTouchEnd, false );
window.removeEventListener( 'hashchange', onWindowHashChange, false );
- dom.controlsLeft.removeEventListener( 'click', preventAndForward( navigateLeft ), false );
- dom.controlsRight.removeEventListener( 'click', preventAndForward( navigateRight ), false );
- dom.controlsUp.removeEventListener( 'click', preventAndForward( navigateUp ), false );
- dom.controlsDown.removeEventListener( 'click', preventAndForward( navigateDown ), false );
+ if ( config.controls && dom.controls ) {
+ dom.controlsLeft.removeEventListener( 'click', preventAndForward( navigateLeft ), false );
+ dom.controlsRight.removeEventListener( 'click', preventAndForward( navigateRight ), false );
+ dom.controlsUp.removeEventListener( 'click', preventAndForward( navigateUp ), false );
+ dom.controlsDown.removeEventListener( 'click', preventAndForward( navigateDown ), false );
+ }
}
/**
@@ -692,6 +699,10 @@ var Reveal = (function(){
* Updates the state and link pointers of the controls.
*/
function updateControls() {
+ if ( !config.controls || !dom.controls ) {
+ return;
+ }
+
var routes = availableRoutes();
// Remove the 'enabled' class from all directions