From 5fba8078435fc307aad53965022676344234e538 Mon Sep 17 00:00:00 2001 From: danielmitd Date: Sun, 10 Jun 2012 11:42:42 +0200 Subject: [PATCH 1/3] controls are not necessary no need to include the controls in html --- js/reveal.js | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/js/reveal.js b/js/reveal.js index 8ff8e0ba..cb4e3f98 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 (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 (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,8 @@ var Reveal = (function(){ * Updates the state and link pointers of the controls. */ function updateControls() { + if (!dom.controls) return; + var routes = availableRoutes(); // Remove the 'enabled' class from all directions From 60d70f483c833c3611dc6e8daa96466a3bd16373 Mon Sep 17 00:00:00 2001 From: danielmitd Date: Sun, 10 Jun 2012 11:51:11 +0200 Subject: [PATCH 2/3] use config --- js/reveal.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/reveal.js b/js/reveal.js index cb4e3f98..50b86405 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -160,7 +160,7 @@ var Reveal = (function(){ document.addEventListener( 'touchend', onDocumentTouchEnd, false ); window.addEventListener( 'hashchange', onWindowHashChange, false ); - if (dom.controls) { + 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 ); @@ -175,7 +175,7 @@ var Reveal = (function(){ document.removeEventListener( 'touchend', onDocumentTouchEnd, false ); window.removeEventListener( 'hashchange', onWindowHashChange, false ); - if (dom.controls) { + 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 ); @@ -699,7 +699,7 @@ var Reveal = (function(){ * Updates the state and link pointers of the controls. */ function updateControls() { - if (!dom.controls) return; + if (!config.controls || !dom.controls) return; var routes = availableRoutes(); From 9de23f022c512a0be4edc593c14ffb22e5b0ebb2 Mon Sep 17 00:00:00 2001 From: danielmitd Date: Sun, 10 Jun 2012 11:53:44 +0200 Subject: [PATCH 3/3] adapt coding style --- js/reveal.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/js/reveal.js b/js/reveal.js index 50b86405..694d1365 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -88,7 +88,7 @@ var Reveal = (function(){ dom.progress = document.querySelector( '.reveal .progress' ); dom.progressbar = document.querySelector( '.reveal .progress span' ); - if (config.controls) { + if ( config.controls ) { dom.controls = document.querySelector( '.reveal .controls' ); dom.controlsLeft = document.querySelector( '.reveal .controls .left' ); dom.controlsRight = document.querySelector( '.reveal .controls .right' ); @@ -160,7 +160,7 @@ var Reveal = (function(){ document.addEventListener( 'touchend', onDocumentTouchEnd, false ); window.addEventListener( 'hashchange', onWindowHashChange, false ); - if (config.controls && dom.controls) { + 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 ); @@ -175,7 +175,7 @@ var Reveal = (function(){ document.removeEventListener( 'touchend', onDocumentTouchEnd, false ); window.removeEventListener( 'hashchange', onWindowHashChange, false ); - if (config.controls && dom.controls) { + 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 ); @@ -699,7 +699,9 @@ var Reveal = (function(){ * Updates the state and link pointers of the controls. */ function updateControls() { - if (!config.controls || !dom.controls) return; + if ( !config.controls || !dom.controls ) { + return; + } var routes = availableRoutes();