support for swipe and pinch gestures #48
authorHakim El Hattab <hakim.elhattab@gmail.com>
Sat, 2 Jun 2012 21:45:06 +0000 (17:45 -0400)
committerHakim El Hattab <hakim.elhattab@gmail.com>
Sat, 2 Jun 2012 21:45:06 +0000 (17:45 -0400)
1  2 
js/reveal.js
js/reveal.min.js

diff --cc js/reveal.js
index d6c5b5bfa994fa9a492012f153c34f911b98305e,a4881e003ac7073d469345fbb64107a4d90ef44c..33b58cf5a7dd90810b919e5f6bef4e83e86d939d
@@@ -53,7 -54,9 +53,18 @@@ var Reveal = (function()
                mouseWheelTimeout = 0,
  
                // Delays updates to the URL due to a Chrome thumbnailer bug
--              writeURLTimeout = 0;
 -              
++              writeURLTimeout = 0,
++
++              // Holds information about the currently ongoing touch input
++              touch = {
++                      startX: 0,
++                      startY: 0,
++                      startSpan: 0,
++                      startCount: 0,
++                      handled: false,
++                      threshold: 40
++              };
+       
        
        /**
         * Starts up the slideshow by applying configuration
                dom.controlsUp = document.querySelector( '#reveal .controls .up' );
                dom.controlsDown = document.querySelector( '#reveal .controls .down' );
  
-               // Bind all view events
-               document.addEventListener( 'keydown', onDocumentKeyDown, false );
-               document.addEventListener( 'touchstart', onDocumentTouchStart, 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 );
 -              addEvents();
++              addEventListeners();
  
                // Copy options over to our config object
                extend( config, options );
                        window.addEventListener( 'load', removeAddressBar, false );
                        window.addEventListener( 'orientationchange', removeAddressBar, false );
                }
 -      function addEvents() {
 -              // Bind all view events
+               
+       }
 -      function removeEvents(){
 -              // Bind all view events
++
++      function addEventListeners() {
+               document.addEventListener( 'keydown', onDocumentKeyDown, false );
+               document.addEventListener( 'touchstart', onDocumentTouchStart, false );
+               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 );
+       }
++
++      function removeEventListeners() {
+               document.removeEventListener( 'keydown', onDocumentKeyDown, false );
+               document.removeEventListener( 'touchstart', onDocumentTouchStart, false );
+               document.removeEventListener( 'touchmove', onDocumentTouchMove, false );
+               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 );
        }
 +
        /**
         * Extend object a with the properties of object b. 
         * If there's a conflict, object b takes precedence.
                }
        }
  
++      function distanceBetween( a, b ) {
++              var dx = a.x - b.x,
++                      dy = a.y - b.y;
++
++              return Math.sqrt( dx*dx + dy*dy );
++      }
++
        /**
         * Prevents an events defaults behavior calls the 
         * specified delegate.
                }
  
        }
-       
++
        /**
--       * Handler for the document level 'touchstart' event.
--       * 
--       * This enables very basic tap interaction for touch
--       * devices. Added mainly for performance testing of 3D
--       * transforms on iOS but was so happily surprised with
--       * how smoothly it runs so I left it in here. Apple +1
--       * 
--       * @param {Object} event
++       * Handler for the document level 'touchstart' event,
++       * enables support for swipe and pinch gestures.
         */
 -       var touchStart = {}
 -       var gesture = false;
        function onDocumentTouchStart( event ) {
-               // We're only interested in one point taps
-               if (event.touches.length === 1) {
-                       // Never prevent taps on anchors and images
-                       if( event.target.tagName.toLowerCase() === 'a' || event.target.tagName.toLowerCase() === 'img' ) {
-                               return;
-                       }
-                       
-                       event.preventDefault();
-                       
-                       var point = {
-                               x: event.touches[0].clientX,
-                               y: event.touches[0].clientY
-                       };
-                       
-                       // Define the extent of the areas that may be tapped
-                       // to navigate
-                       var wt = window.innerWidth * 0.3;
-                       var ht = window.innerHeight * 0.3;
--                      
-                       if( point.x < wt ) {
-                               navigateLeft();
-                       }
-                       else if( point.x > window.innerWidth - wt ) {
-                               navigateRight();
 -              touchStart = {
 -                      x: event.touches[0].clientX,
 -                      y: event.touches[0].clientY
 -              };
 -              if( event.target.tagName.toLowerCase() === 'a' || event.target.tagName.toLowerCase() === 'img' ) {
 -                      } else { 
 -                              event.preventDefault(); 
--                      }
-                       else if( point.y < ht ) {
-                               navigateUp();
++              touch.startX = event.touches[0].clientX;
++              touch.startY = event.touches[0].clientY;
++              touch.startCount = event.touches.length;
++
++              // If there's two touches we need to memorize the distance 
++              // between those two points to detect pinching
++              if( event.touches.length === 2 ) {
++                      touch.startSpan = distanceBetween( {
++                              x: event.touches[1].clientX,
++                              y: event.touches[1].clientY
++                      }, {
++                              x: touch.startX,
++                              y: touch.startY
++                      } );
++              }
+       }
+       
++      /**
++       * Handler for the document level 'touchmove' event.
++       */
+       function onDocumentTouchMove( event ) {
 -              
 -              event.preventDefault();
 -                      
 -              if(!gesture) {
 -                      var touch = {
 -                                      x: event.touches[0].clientX,
 -                                      y: event.touches[0].clientY
 -                              };
 -                      if((touch.x - touchStart.x) > config.swipeDist){
 -                              gesture = true;
 -                              navigateLeft();
 -                      } else if((touch.x - touchStart.x) < -config.swipeDist){
 -                              gesture = true;
 -                              navigateRight();
 -                      } else if((touch.y - touchStart.y) > config.swipeDist){
 -                              gesture = true;
 -                              navigateUp();
 -                      } else if((touch.y - touchStart.y) < -config.swipeDist){
 -                              gesture = true;
 -                              navigateDown();
++              // Each touch should only trigger one action
++              if( !touch.handled ) {
++                      var currentX = event.touches[0].clientX;
++                      var currentY = event.touches[0].clientY;
++
++                      // If the touch started off with two points and still has 
++                      // two active touches; test for the pinch gesture
++                      if( event.touches.length === 2 && touch.startCount === 2 ) {
++
++                              // The current distance in pixels between the two touch points
++                              var currentSpan = distanceBetween( {
++                                      x: event.touches[1].clientX,
++                                      y: event.touches[1].clientY
++                              }, {
++                                      x: touch.startX,
++                                      y: touch.startY
++                              } );
++
++                              // If the span is larger than the desire amount we've got 
++                              // ourselves a pinch
++                              if( Math.abs( touch.startSpan - currentSpan ) > touch.threshold ) {
++                                      touch.handled = true;
++
++                                      if( currentSpan < touch.startSpan ) {
++                                              activateOverview();
++                                      }
++                                      else {
++                                              deactivateOverview();
++                                      }
++                              }
++
                        }
-                       else if( point.y > window.innerHeight - ht ) {
-                               navigateDown();
++                      // There was only one touch point, look for a swipe
++                      else if( event.touches.length === 1 ) {
++                              var deltaX = currentX - touch.startX,
++                                      deltaY = currentY - touch.startY;
++
++                              if( deltaX > touch.threshold && Math.abs( deltaX ) > Math.abs( deltaY ) ) {
++                                      touch.handled = true;
++                                      navigateLeft();
++                              } 
++                              else if( deltaX < -touch.threshold && Math.abs( deltaX ) > Math.abs( deltaY ) ) {
++                                      touch.handled = true;
++                                      navigateRight();
++                              } 
++                              else if( deltaY > touch.threshold ) {
++                                      touch.handled = true;
++                                      navigateUp();
++                              } 
++                              else if( deltaY < -touch.threshold ) {
++                                      touch.handled = true;
++                                      navigateDown();
++                              }
 +                      }
-                       
-                       slide();
++
++                      event.preventDefault();
                }
        }
 -              if(!gesture){
 -                      // Never prevent taps on anchors and images
 -                      if( event.target.tagName.toLowerCase() === 'a' || event.target.tagName.toLowerCase() === 'img' ) {
 -                              return;
 -                      }
 -                      
 -                      // Define the extent of the areas that may be tapped
 -                      // to navigate
 -                      var wt = window.innerWidth * 0.3;
 -                      var ht = window.innerHeight * 0.3;
 -                      
 -                      if( touchStart.x < wt ) {
 -                              navigateLeft();
 -                      }
 -                      else if( touchStart.x > window.innerWidth - wt ) {
 -                              navigateRight();
 -                      }
 -                      else if( touchStart.y < ht ) {
 -                              navigateUp();
 -                      }
 -                      else if( touchStart.y > window.innerHeight - ht ) {
 -                              navigateDown();
 -                      }
 -              }
 -              gesture = false;
 -              event.preventDefault();
 +
++      /**
++       * Handler for the document level 'touchend' event.
++       */
+       function onDocumentTouchEnd( event ) {
++              touch.handled = false;
+       }
  
        /**
         * Handles mouse wheel scrolling, throttled to avoid 
                        availableRoutes().down ? navigateDown() : navigateRight();
                }
        }
 -      function overviewToggle (){
++
++      /**
++       * Toggles the slide overview mode on and off.
++       */
++      function toggleOverview() {
+               if( overviewIsActive() ) {
+                       deactivateOverview();
+               }
+               else {
+                       activateOverview();
+               }
+       }
        
        // Expose some methods publicly
        return {
                navigateRight: navigateRight,
                navigateUp: navigateUp,
                navigateDown: navigateDown,
 -              overviewToggle: overviewToggle,
 -              addEvents: addEvents,
 -              removeEvents: removeEvents,
++              toggleOverview: toggleOverview,
  
                // Forward event binding to the reveal DOM element
                addEventListener: function( type, listener, useCapture ) {
index 08b8a972b39f358a7125cb7d4d26795544e9744a,7977da4a0be783d624751f7029d1e9acdb2f355e..41f93470f739da4bf76e2b4b81c8c640b8dccebc
@@@ -1,52 -1,7 +1,60 @@@
  /*!
 -  reveal.js 1.3
 -  http://lab.hakim.se/reveal-js
 -  MIT licensed
 -  
 -  Copyright (C) 2012 Hakim El Hattab, http://hakim.se
 - */var Reveal=(function(){var HORIZONTAL_SLIDES_SELECTOR='#reveal .slides>section',VERTICAL_SLIDES_SELECTOR='#reveal .slides>section.present>section',IS_TOUCH_DEVICE=!!('ontouchstart'in window),indexh=0,indexv=0,config={controls:false,progress:false,history:false,loop:false,mouseWheel:true,rollingLinks:true,transition:'default',theme:'default',swipeDist:40},state=[],dom={},supports3DTransforms=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,supports2DTransforms=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,mouseWheelTimeout=0,writeURLTimeout=0;function initialize(options){if(!supports2DTransforms&&!supports3DTransforms){document.body.setAttribute('class','no-transforms');return;}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');addEvents();extend(config,options);if(supports3DTransforms===false){config.transition='linear';}if(config.controls){dom.controls.style.display='block';}if(config.progress){dom.progress.style.display='block';}if(config.transition!=='default'){dom.wrapper.classList.add(config.transition);}if(config.theme!=='default'){dom.wrapper.classList.add(config.theme);}if(config.mouseWheel){document.addEventListener('DOMMouseScroll',onDocumentMouseScroll,false);document.addEventListener('mousewheel',onDocumentMouseScroll,false);}if(config.rollingLinks){linkify();}readURL();if(navigator.userAgent.match(/(iphone|ipod|android)/i)){document.documentElement.style.overflow='scroll';document.body.style.height='120%';window.addEventListener('load',removeAddressBar,false);window.addEventListener('orientationchange',removeAddressBar,false);}}function addEvents(){document.addEventListener('keydown',onDocumentKeyDown,false);document.addEventListener('touchstart',onDocumentTouchStart,false);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);}function removeEvents(){document.removeEventListener('keydown',onDocumentKeyDown,false);document.removeEventListener('touchstart',onDocumentTouchStart,false);document.removeEventListener('touchmove',onDocumentTouchMove,false);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);}function extend(a,b){for(var i in b){a[i]=b[i];}}function preventAndForward(delegate){return function(event){event.preventDefault();delegate.call();}}function removeAddressBar(){setTimeout(function(){window.scrollTo(0,1);},0);}function onDocumentKeyDown(event){if(event.target.contentEditable!='inherit'||event.shiftKey||event.altKey||event.ctrlKey||event.metaKey)return;var triggered=false;switch(event.keyCode){case 80:case 33:navigatePrev();triggered=true;break;case 78:case 34:navigateNext();triggered=true;break;case 72:case 37:navigateLeft();triggered=true;break;case 76:case 39:navigateRight();triggered=true;break;case 75:case 38:navigateUp();triggered=true;break;case 74:case 40:navigateDown();triggered=true;break;case 36:navigateTo(0);triggered=true;break;case 35:navigateTo(Number.MAX_VALUE);triggered=true;break;case 32:overviewIsActive()?deactivateOverview():navigateNext();triggered=true;break;case 13:if(overviewIsActive()){deactivateOverview();triggered=true;}break;}if(triggered){event.preventDefault();}else if(event.keyCode===27&&supports3DTransforms){if(overviewIsActive()){deactivateOverview();}else{activateOverview();}event.preventDefault();}}var touchStart={}var gesture=false;function onDocumentTouchStart(event){touchStart={x:event.touches[0].clientX,y:event.touches[0].clientY};if(event.target.tagName.toLowerCase()==='a'||event.target.tagName.toLowerCase()==='img'){}else{event.preventDefault();}}function onDocumentTouchMove(event){event.preventDefault();if(!gesture){var touch={x:event.touches[0].clientX,y:event.touches[0].clientY};if((touch.x-touchStart.x)>config.swipeDist){gesture=true;navigateLeft();}else if((touch.x-touchStart.x)<-config.swipeDist){gesture=true;navigateRight();}else if((touch.y-touchStart.y)>config.swipeDist){gesture=true;navigateUp();}else if((touch.y-touchStart.y)<-config.swipeDist){gesture=true;navigateDown();}}}function onDocumentTouchEnd(event){if(!gesture){if(event.target.tagName.toLowerCase()==='a'||event.target.tagName.toLowerCase()==='img'){return;}var wt=window.innerWidth*0.3;var ht=window.innerHeight*0.3;if(touchStart.x<wt){navigateLeft();}else if(touchStart.x>window.innerWidth-wt){navigateRight();}else if(touchStart.y<ht){navigateUp();}else if(touchStart.y>window.innerHeight-ht){navigateDown();}}gesture=false;event.preventDefault();}function onDocumentMouseScroll(event){clearTimeout(mouseWheelTimeout);mouseWheelTimeout=setTimeout(function(){var delta=event.detail||-event.wheelDelta;if(delta>0){navigateNext();}else{navigatePrev();}},100);}function onWindowHashChange(event){readURL();}function linkify(){if(supports3DTransforms){var nodes=document.querySelectorAll('#reveal .slides section a:not(.image)');for(var i=0,len=nodes.length;i<len;i++){var node=nodes[i];if(node.textContent&&!node.querySelector('img')&&(!node.className||!node.classList.contains(node,'roll'))){node.classList.add('roll');node.innerHTML='<span data-title="'+node.text+'">'+node.innerHTML+'</span>';}};}}function activateOverview(){dom.wrapper.classList.add('overview');var horizontalSlides=Array.prototype.slice.call(document.querySelectorAll(HORIZONTAL_SLIDES_SELECTOR));for(var i=0,len1=horizontalSlides.length;i<len1;i++){var hslide=horizontalSlides[i],htransform='translateZ(-2500px) translate('+((i-indexh)*105)+'%, 0%)';hslide.setAttribute('data-index-h',i);hslide.style.display='block';hslide.style.WebkitTransform=htransform;hslide.style.MozTransform=htransform;hslide.style.msTransform=htransform;hslide.style.OTransform=htransform;hslide.style.transform=htransform;if(!hslide.classList.contains('stack')){hslide.addEventListener('click',onOverviewSlideClicked,true);}var verticalSlides=Array.prototype.slice.call(hslide.querySelectorAll('section'));for(var j=0,len2=verticalSlides.length;j<len2;j++){var vslide=verticalSlides[j],vtransform='translate(0%, '+((j-indexv)*105)+'%)';vslide.setAttribute('data-index-h',i);vslide.setAttribute('data-index-v',j);vslide.style.display='block';vslide.style.WebkitTransform=vtransform;vslide.style.MozTransform=vtransform;vslide.style.msTransform=vtransform;vslide.style.OTransform=vtransform;vslide.style.transform=vtransform;vslide.addEventListener('click',onOverviewSlideClicked,true);}}}function deactivateOverview(){dom.wrapper.classList.remove('overview');var slides=Array.prototype.slice.call(document.querySelectorAll('#reveal .slides section'));for(var i=0,len=slides.length;i<len;i++){var element=slides[i];element.style.WebkitTransform='';element.style.MozTransform='';element.style.msTransform='';element.style.OTransform='';element.style.transform='';element.removeEventListener('click',onOverviewSlideClicked);}slide();}function overviewIsActive(){return dom.wrapper.classList.contains('overview');}function onOverviewSlideClicked(event){if(overviewIsActive()){event.preventDefault();deactivateOverview();indexh=this.getAttribute('data-index-h');indexv=this.getAttribute('data-index-v');slide();}}function updateSlides(selector,index){var slides=Array.prototype.slice.call(document.querySelectorAll(selector)),slidesLength=slides.length;if(slidesLength){if(config.loop){index%=slidesLength;if(index<0){index=slidesLength+index;}}index=Math.max(Math.min(index,slidesLength-1),0);for(var i=0;i<slidesLength;i++){var slide=slides[i];if(overviewIsActive()===false){var distance=Math.abs((index-i)%(slidesLength-3))||0;slide.style.display=distance>3?'none':'block';}slides[i].classList.remove('past');slides[i].classList.remove('present');slides[i].classList.remove('future');if(i<index){slides[i].classList.add('past');}else if(i>index){slides[i].classList.add('future');}if(slide.querySelector('section')){slides[i].classList.add('stack');}}slides[index].classList.add('present');var slideState=slides[index].getAttribute('data-state');if(slideState){state=state.concat(slideState.split(' '));}}else{index=0;}return index;}function slide(){var stateBefore=state.concat();state.length=0;indexh=updateSlides(HORIZONTAL_SLIDES_SELECTOR,indexh);indexv=updateSlides(VERTICAL_SLIDES_SELECTOR,indexv);stateLoop:for(var i=0,len=state.length;i<len;i++){for(var j=0;j<stateBefore.length;j++){if(stateBefore[j]===state[i]){stateBefore.splice(j,1);continue stateLoop;}}document.documentElement.classList.add(state[i]);dispatchEvent(state[i]);}while(stateBefore.length){document.documentElement.classList.remove(stateBefore.pop());}if(config.progress){dom.progressbar.style.width=(indexh/(document.querySelectorAll(HORIZONTAL_SLIDES_SELECTOR).length-1))*window.innerWidth+'px';}if(overviewIsActive()){activateOverview();}updateControls();clearTimeout(writeURLTimeout);writeURLTimeout=setTimeout(writeURL,1500);dispatchEvent('slidechanged',{'indexh':indexh,'indexv':indexv});}function updateControls(){var routes=availableRoutes();[dom.controlsLeft,dom.controlsRight,dom.controlsUp,dom.controlsDown].forEach(function(node){node.classList.remove('enabled');})if(routes.left)dom.controlsLeft.classList.add('enabled');if(routes.right)dom.controlsRight.classList.add('enabled');if(routes.up)dom.controlsUp.classList.add('enabled');if(routes.down)dom.controlsDown.classList.add('enabled');}function availableRoutes(){var horizontalSlides=document.querySelectorAll(HORIZONTAL_SLIDES_SELECTOR);var verticalSlides=document.querySelectorAll(VERTICAL_SLIDES_SELECTOR);return{left:indexh>0,right:indexh<horizontalSlides.length-1,up:indexv>0,down:indexv<verticalSlides.length-1};}function readURL(){var bits=window.location.hash.slice(2).split('/');indexh=parseInt(bits[0])||0;indexv=parseInt(bits[1])||0;navigateTo(indexh,indexv);}function writeURL(){if(config.history){var url='/';if(indexh>0||indexv>0)url+=indexh;if(indexv>0)url+='/'+indexv;window.location.hash=url;}}function dispatchEvent(type,properties){var event=document.createEvent("HTMLEvents",1,2);event.initEvent(type,true,true);extend(event,properties);dom.wrapper.dispatchEvent(event);}function nextFragment(){if(document.querySelector(VERTICAL_SLIDES_SELECTOR+'.present')){var verticalFragments=document.querySelectorAll(VERTICAL_SLIDES_SELECTOR+'.present .fragment:not(.visible)');if(verticalFragments.length){verticalFragments[0].classList.add('visible');return true;}}else{var horizontalFragments=document.querySelectorAll(HORIZONTAL_SLIDES_SELECTOR+'.present .fragment:not(.visible)');if(horizontalFragments.length){horizontalFragments[0].classList.add('visible');return true;}}return false;}function previousFragment(){if(document.querySelector(VERTICAL_SLIDES_SELECTOR+'.present')){var verticalFragments=document.querySelectorAll(VERTICAL_SLIDES_SELECTOR+'.present .fragment.visible');if(verticalFragments.length){verticalFragments[verticalFragments.length-1].classList.remove('visible');return true;}}else{var horizontalFragments=document.querySelectorAll(HORIZONTAL_SLIDES_SELECTOR+'.present .fragment.visible');if(horizontalFragments.length){horizontalFragments[horizontalFragments.length-1].classList.remove('visible');return true;}}return false;}function navigateTo(h,v){indexh=h===undefined?indexh:h;indexv=v===undefined?indexv:v;slide();}function navigateLeft(){if(overviewIsActive()||previousFragment()===false){indexh--;indexv=0;slide();}}function navigateRight(){if(overviewIsActive()||nextFragment()===false){indexh++;indexv=0;slide();}}function navigateUp(){if(overviewIsActive()||previousFragment()===false){indexv--;slide();}}function navigateDown(){if(overviewIsActive()||nextFragment()===false){indexv++;slide();}}function navigatePrev(){if(previousFragment()===false){if(availableRoutes().up){navigateUp();}else{var previousSlide=document.querySelector('#reveal .slides>section.past:nth-child('+indexh+')');if(previousSlide){indexv=(previousSlide.querySelectorAll('section').length+1)||0;indexh--;slide();}}}}function navigateNext(){if(nextFragment()===false){availableRoutes().down?navigateDown():navigateRight();}}function overviewToggle(){if(overviewIsActive()){deactivateOverview();}else{activateOverview();}}return{initialize:initialize,navigateTo:navigateTo,navigateLeft:navigateLeft,navigateRight:navigateRight,navigateUp:navigateUp,navigateDown:navigateDown,overviewToggle:overviewToggle,addEvents:addEvents,removeEvents:removeEvents,addEventListener:function(type,listener,useCapture){(dom.wrapper||document.querySelector('#reveal')).addEventListener(type,listener,useCapture);},removeEventListener:function(type,listener,useCapture){(dom.wrapper||document.querySelector('#reveal')).removeEventListener(type,listener,useCapture);}};})();
 + * reveal.js 1.3
 + * http://lab.hakim.se/reveal-js
 + * MIT licensed
 + * 
 + * Copyright (C) 2012 Hakim El Hattab, http://hakim.se
 + */
- var Reveal=(function(){var j="#reveal .slides>section",a="#reveal .slides>section.present>section",e=!!("ontouchstart" in window),k=0,c=0,G={controls:false,progress:false,history:false,loop:false,mouseWheel:true,rollingLinks:true,transition:"default",theme:"default"},N=[],d={},H=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,l=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,v=0,y=0;
- function h(P){if(!l&&!H){document.body.setAttribute("class","no-transforms");return;}d.wrapper=document.querySelector("#reveal");d.progress=document.querySelector("#reveal .progress");
++var Reveal=(function(){var j="#reveal .slides>section",a="#reveal .slides>section.present>section",e=!!("ontouchstart" in window),k=0,c=0,H={controls:false,progress:false,history:false,loop:false,mouseWheel:true,rollingLinks:true,transition:"default",theme:"default"},U=[],d={},J=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,l=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,v=0,y=0,P={startX:0,startY:0,startSpan:0,startCount:0,handled:false,threshold:40};
++function h(W){if(!l&&!J){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.controlsRight=document.querySelector("#reveal .controls .right");d.controlsUp=document.querySelector("#reveal .controls .up");d.controlsDown=document.querySelector("#reveal .controls .down");
- document.addEventListener("keydown",M,false);document.addEventListener("touchstart",w,false);window.addEventListener("hashchange",t,false);d.controlsLeft.addEventListener("click",n(x),false);
- d.controlsRight.addEventListener("click",n(i),false);d.controlsUp.addEventListener("click",n(r),false);d.controlsDown.addEventListener("click",n(A),false);
- q(G,P);if(H===false){G.transition="linear";}if(G.controls){d.controls.style.display="block";}if(G.progress){d.progress.style.display="block";}if(G.transition!=="default"){d.wrapper.classList.add(G.transition);
- }if(G.theme!=="default"){d.wrapper.classList.add(G.theme);}if(G.mouseWheel){document.addEventListener("DOMMouseScroll",m,false);document.addEventListener("mousewheel",m,false);
- }if(G.rollingLinks){D();}C();if(navigator.userAgent.match(/(iphone|ipod|android)/i)){document.documentElement.style.overflow="scroll";document.body.style.height="120%";
- window.addEventListener("load",K,false);window.addEventListener("orientationchange",K,false);}}function q(Q,P){for(var R in P){Q[R]=P[R];}}function n(P){return function(Q){Q.preventDefault();
- P.call();};}function K(){setTimeout(function(){window.scrollTo(0,1);},0);}function M(Q){if(Q.target.contentEditable!="inherit"||Q.shiftKey||Q.altKey||Q.ctrlKey||Q.metaKey){return;
- }var P=false;switch(Q.keyCode){case 80:case 33:I();P=true;break;case 78:case 34:u();P=true;break;case 72:case 37:x();P=true;break;case 76:case 39:i();P=true;
- break;case 75:case 38:r();P=true;break;case 74:case 40:A();P=true;break;case 36:E(0);P=true;break;case 35:E(Number.MAX_VALUE);P=true;break;case 32:J()?L():u();
- P=true;break;case 13:if(J()){L();P=true;}break;}if(P){Q.preventDefault();}else{if(Q.keyCode===27&&H){if(J()){L();}else{B();}Q.preventDefault();}}}function w(S){if(S.touches.length===1){if(S.target.tagName.toLowerCase()==="a"||S.target.tagName.toLowerCase()==="img"){return;
- }S.preventDefault();var Q={x:S.touches[0].clientX,y:S.touches[0].clientY};var P=window.innerWidth*0.3;var R=window.innerHeight*0.3;if(Q.x<P){x();}else{if(Q.x>window.innerWidth-P){i();
- }else{if(Q.y<R){r();}else{if(Q.y>window.innerHeight-R){A();}}}}b();}}function m(P){clearTimeout(v);v=setTimeout(function(){var Q=P.detail||-P.wheelDelta;
- if(Q>0){u();}else{I();}},100);}function t(P){C();}function D(){if(H){var Q=document.querySelectorAll("#reveal .slides section a:not(.image)");for(var R=0,P=Q.length;
- R<P;R++){var S=Q[R];if(S.textContent&&!S.querySelector("img")&&(!S.className||!S.classList.contains(S,"roll"))){S.classList.add("roll");S.innerHTML='<span data-title="'+S.text+'">'+S.innerHTML+"</span>";
- }}}}function B(){d.wrapper.classList.add("overview");var P=Array.prototype.slice.call(document.querySelectorAll(j));for(var U=0,S=P.length;U<S;U++){var R=P[U],Y="translateZ(-2500px) translate("+((U-k)*105)+"%, 0%)";
- R.setAttribute("data-index-h",U);R.style.display="block";R.style.WebkitTransform=Y;R.style.MozTransform=Y;R.style.msTransform=Y;R.style.OTransform=Y;R.style.transform=Y;
- if(!R.classList.contains("stack")){R.addEventListener("click",z,true);}var X=Array.prototype.slice.call(R.querySelectorAll("section"));for(var T=0,Q=X.length;
- T<Q;T++){var W=X[T],V="translate(0%, "+((T-c)*105)+"%)";W.setAttribute("data-index-h",U);W.setAttribute("data-index-v",T);W.style.display="block";W.style.WebkitTransform=V;
- W.style.MozTransform=V;W.style.msTransform=V;W.style.OTransform=V;W.style.transform=V;W.addEventListener("click",z,true);}}}function L(){d.wrapper.classList.remove("overview");
- var S=Array.prototype.slice.call(document.querySelectorAll("#reveal .slides section"));for(var R=0,P=S.length;R<P;R++){var Q=S[R];Q.style.WebkitTransform="";
- Q.style.MozTransform="";Q.style.msTransform="";Q.style.OTransform="";Q.style.transform="";Q.removeEventListener("click",z);}b();}function J(){return d.wrapper.classList.contains("overview");
- }function z(P){if(J()){P.preventDefault();L();k=this.getAttribute("data-index-h");c=this.getAttribute("data-index-v");b();}}function O(Q,S){var U=Array.prototype.slice.call(document.querySelectorAll(Q)),V=U.length;
- if(V){if(G.loop){S%=V;if(S<0){S=V+S;}}S=Math.max(Math.min(S,V-1),0);for(var T=0;T<V;T++){var P=U[T];if(J()===false){var W=Math.abs((S-T)%(V-3))||0;P.style.display=W>3?"none":"block";
- }U[T].classList.remove("past");U[T].classList.remove("present");U[T].classList.remove("future");if(T<S){U[T].classList.add("past");}else{if(T>S){U[T].classList.add("future");
- }}if(P.querySelector("section")){U[T].classList.add("stack");}}U[S].classList.add("present");var R=U[S].getAttribute("data-state");if(R){N=N.concat(R.split(" "));
- }}else{S=0;}return S;}function b(){var S=N.concat();N.length=0;k=O(j,k);c=O(a,c);stateLoop:for(var R=0,P=N.length;R<P;R++){for(var Q=0;Q<S.length;Q++){if(S[Q]===N[R]){S.splice(Q,1);
- continue stateLoop;}}document.documentElement.classList.add(N[R]);o(N[R]);}while(S.length){document.documentElement.classList.remove(S.pop());}if(G.progress){d.progressbar.style.width=(k/(document.querySelectorAll(j).length-1))*window.innerWidth+"px";
- }if(J()){B();}p();clearTimeout(y);y=setTimeout(g,1500);o("slidechanged",{indexh:k,indexv:c});}function p(){var P=f();[d.controlsLeft,d.controlsRight,d.controlsUp,d.controlsDown].forEach(function(Q){Q.classList.remove("enabled");
- });if(P.left){d.controlsLeft.classList.add("enabled");}if(P.right){d.controlsRight.classList.add("enabled");}if(P.up){d.controlsUp.classList.add("enabled");
- }if(P.down){d.controlsDown.classList.add("enabled");}}function f(){var P=document.querySelectorAll(j);var Q=document.querySelectorAll(a);return{left:k>0,right:k<P.length-1,up:c>0,down:c<Q.length-1};
- }function C(){var P=window.location.hash.slice(2).split("/");k=parseInt(P[0])||0;c=parseInt(P[1])||0;E(k,c);}function g(){if(G.history){var P="/";if(k>0||c>0){P+=k;
- }if(c>0){P+="/"+c;}window.location.hash=P;}}function o(Q,P){var R=document.createEvent("HTMLEvents",1,2);R.initEvent(Q,true,true);q(R,P);d.wrapper.dispatchEvent(R);
- }function s(){if(document.querySelector(a+".present")){var Q=document.querySelectorAll(a+".present .fragment:not(.visible)");if(Q.length){Q[0].classList.add("visible");
- o("fragmentshown",{fragment:Q[0]});return true;}}else{var P=document.querySelectorAll(j+".present .fragment:not(.visible)");if(P.length){P[0].classList.add("visible");
- o("fragmentshown",{fragment:P[0]});return true;}}return false;}function F(){if(document.querySelector(a+".present")){var Q=document.querySelectorAll(a+".present .fragment.visible");
- if(Q.length){Q[Q.length-1].classList.remove("visible");o("fragmenthidden",{fragment:Q[0]});return true;}}else{var P=document.querySelectorAll(j+".present .fragment.visible");
- if(P.length){P[P.length-1].classList.remove("visible");o("fragmenthidden",{fragment:P[0]});return true;}}return false;}function E(Q,P){k=Q===undefined?k:Q;
- c=P===undefined?c:P;b();}function x(){if(J()||F()===false){k--;c=0;b();}}function i(){if(J()||s()===false){k++;c=0;b();}}function r(){if(J()||F()===false){c--;
- b();}}function A(){if(J()||s()===false){c++;b();}}function I(){if(F()===false){if(f().up){r();}else{var P=document.querySelector("#reveal .slides>section.past:nth-child("+k+")");
- if(P){c=(P.querySelectorAll("section").length+1)||0;k--;b();}}}}function u(){if(s()===false){f().down?A():i();}}return{initialize:h,navigateTo:E,navigateLeft:x,navigateRight:i,navigateUp:r,navigateDown:A,addEventListener:function(Q,R,P){(d.wrapper||document.querySelector("#reveal")).addEventListener(Q,R,P);
- },removeEventListener:function(Q,R,P){(d.wrapper||document.querySelector("#reveal")).removeEventListener(Q,R,P);}};})();
++A();q(H,W);if(J===false){H.transition="linear";}if(H.controls){d.controls.style.display="block";}if(H.progress){d.progress.style.display="block";}if(H.transition!=="default"){d.wrapper.classList.add(H.transition);
++}if(H.theme!=="default"){d.wrapper.classList.add(H.theme);}if(H.mouseWheel){document.addEventListener("DOMMouseScroll",m,false);document.addEventListener("mousewheel",m,false);
++}if(H.rollingLinks){E();}D();if(navigator.userAgent.match(/(iphone|ipod|android)/i)){document.documentElement.style.overflow="scroll";document.body.style.height="120%";
++window.addEventListener("load",Q,false);window.addEventListener("orientationchange",Q,false);}}function A(){document.addEventListener("keydown",T,false);
++document.addEventListener("touchstart",w,false);document.addEventListener("touchmove",S,false);document.addEventListener("touchend",L,false);window.addEventListener("hashchange",t,false);
++d.controlsLeft.addEventListener("click",n(x),false);d.controlsRight.addEventListener("click",n(i),false);d.controlsUp.addEventListener("click",n(r),false);
++d.controlsDown.addEventListener("click",n(B),false);}function K(){document.removeEventListener("keydown",T,false);document.removeEventListener("touchstart",w,false);
++document.removeEventListener("touchmove",S,false);document.removeEventListener("touchend",L,false);window.removeEventListener("hashchange",t,false);d.controlsLeft.removeEventListener("click",n(x),false);
++d.controlsRight.removeEventListener("click",n(i),false);d.controlsUp.removeEventListener("click",n(r),false);d.controlsDown.removeEventListener("click",n(B),false);
++}function q(X,W){for(var Y in W){X[Y]=W[Y];}}function I(Y,W){var Z=Y.x-W.x,X=Y.y-W.y;return Math.sqrt(Z*Z+X*X);}function n(W){return function(X){X.preventDefault();
++W.call();};}function Q(){setTimeout(function(){window.scrollTo(0,1);},0);}function T(X){if(X.target.contentEditable!="inherit"||X.shiftKey||X.altKey||X.ctrlKey||X.metaKey){return;
++}var W=false;switch(X.keyCode){case 80:case 33:N();W=true;break;case 78:case 34:u();W=true;break;case 72:case 37:x();W=true;break;case 76:case 39:i();W=true;
++break;case 75:case 38:r();W=true;break;case 74:case 40:B();W=true;break;case 36:F(0);W=true;break;case 35:F(Number.MAX_VALUE);W=true;break;case 32:O()?R():u();
++W=true;break;case 13:if(O()){R();W=true;}break;}if(W){X.preventDefault();}else{if(X.keyCode===27&&J){if(O()){R();}else{C();}X.preventDefault();}}}function w(W){P.startX=W.touches[0].clientX;
++P.startY=W.touches[0].clientY;P.startCount=W.touches.length;if(W.touches.length===2){P.startSpan=I({x:W.touches[1].clientX,y:W.touches[1].clientY},{x:P.startX,y:P.startY});
++}}function S(ab){if(!P.handled){var Z=ab.touches[0].clientX;var Y=ab.touches[0].clientY;if(ab.touches.length===2&&P.startCount===2){var aa=I({x:ab.touches[1].clientX,y:ab.touches[1].clientY},{x:P.startX,y:P.startY});
++if(Math.abs(P.startSpan-aa)>P.threshold){P.handled=true;if(aa<P.startSpan){C();}else{R();}}}else{if(ab.touches.length===1){var X=Z-P.startX,W=Y-P.startY;
++if(X>P.threshold&&Math.abs(X)>Math.abs(W)){P.handled=true;x();}else{if(X<-P.threshold&&Math.abs(X)>Math.abs(W)){P.handled=true;i();}else{if(W>P.threshold){P.handled=true;
++r();}else{if(W<-P.threshold){P.handled=true;B();}}}}}}ab.preventDefault();}}function L(W){P.handled=false;}function m(W){clearTimeout(v);v=setTimeout(function(){var X=W.detail||-W.wheelDelta;
++if(X>0){u();}else{N();}},100);}function t(W){D();}function E(){if(J){var X=document.querySelectorAll("#reveal .slides section a:not(.image)");for(var Y=0,W=X.length;
++Y<W;Y++){var Z=X[Y];if(Z.textContent&&!Z.querySelector("img")&&(!Z.className||!Z.classList.contains(Z,"roll"))){Z.classList.add("roll");Z.innerHTML='<span data-title="'+Z.text+'">'+Z.innerHTML+"</span>";
++}}}}function C(){d.wrapper.classList.add("overview");var W=Array.prototype.slice.call(document.querySelectorAll(j));for(var ab=0,Z=W.length;ab<Z;ab++){var Y=W[ab],af="translateZ(-2500px) translate("+((ab-k)*105)+"%, 0%)";
++Y.setAttribute("data-index-h",ab);Y.style.display="block";Y.style.WebkitTransform=af;Y.style.MozTransform=af;Y.style.msTransform=af;Y.style.OTransform=af;
++Y.style.transform=af;if(!Y.classList.contains("stack")){Y.addEventListener("click",z,true);}var ae=Array.prototype.slice.call(Y.querySelectorAll("section"));
++for(var aa=0,X=ae.length;aa<X;aa++){var ad=ae[aa],ac="translate(0%, "+((aa-c)*105)+"%)";ad.setAttribute("data-index-h",ab);ad.setAttribute("data-index-v",aa);
++ad.style.display="block";ad.style.WebkitTransform=ac;ad.style.MozTransform=ac;ad.style.msTransform=ac;ad.style.OTransform=ac;ad.style.transform=ac;ad.addEventListener("click",z,true);
++}}}function R(){d.wrapper.classList.remove("overview");var Z=Array.prototype.slice.call(document.querySelectorAll("#reveal .slides section"));for(var Y=0,W=Z.length;
++Y<W;Y++){var X=Z[Y];X.style.WebkitTransform="";X.style.MozTransform="";X.style.msTransform="";X.style.OTransform="";X.style.transform="";X.removeEventListener("click",z);
++}b();}function O(){return d.wrapper.classList.contains("overview");}function z(W){if(O()){W.preventDefault();R();k=this.getAttribute("data-index-h");c=this.getAttribute("data-index-v");
++b();}}function V(X,Z){var ab=Array.prototype.slice.call(document.querySelectorAll(X)),ac=ab.length;if(ac){if(H.loop){Z%=ac;if(Z<0){Z=ac+Z;}}Z=Math.max(Math.min(Z,ac-1),0);
++for(var aa=0;aa<ac;aa++){var W=ab[aa];if(O()===false){var ad=Math.abs((Z-aa)%(ac-3))||0;W.style.display=ad>3?"none":"block";}ab[aa].classList.remove("past");
++ab[aa].classList.remove("present");ab[aa].classList.remove("future");if(aa<Z){ab[aa].classList.add("past");}else{if(aa>Z){ab[aa].classList.add("future");
++}}if(W.querySelector("section")){ab[aa].classList.add("stack");}}ab[Z].classList.add("present");var Y=ab[Z].getAttribute("data-state");if(Y){U=U.concat(Y.split(" "));
++}}else{Z=0;}return Z;}function b(){var Z=U.concat();U.length=0;k=V(j,k);c=V(a,c);stateLoop:for(var Y=0,W=U.length;Y<W;Y++){for(var X=0;X<Z.length;X++){if(Z[X]===U[Y]){Z.splice(X,1);
++continue stateLoop;}}document.documentElement.classList.add(U[Y]);o(U[Y]);}while(Z.length){document.documentElement.classList.remove(Z.pop());}if(H.progress){d.progressbar.style.width=(k/(document.querySelectorAll(j).length-1))*window.innerWidth+"px";
++}if(O()){C();}p();clearTimeout(y);y=setTimeout(g,1500);o("slidechanged",{indexh:k,indexv:c});}function p(){var W=f();[d.controlsLeft,d.controlsRight,d.controlsUp,d.controlsDown].forEach(function(X){X.classList.remove("enabled");
++});if(W.left){d.controlsLeft.classList.add("enabled");}if(W.right){d.controlsRight.classList.add("enabled");}if(W.up){d.controlsUp.classList.add("enabled");
++}if(W.down){d.controlsDown.classList.add("enabled");}}function f(){var W=document.querySelectorAll(j);var X=document.querySelectorAll(a);return{left:k>0,right:k<W.length-1,up:c>0,down:c<X.length-1};
++}function D(){var W=window.location.hash.slice(2).split("/");k=parseInt(W[0])||0;c=parseInt(W[1])||0;F(k,c);}function g(){if(H.history){var W="/";if(k>0||c>0){W+=k;
++}if(c>0){W+="/"+c;}window.location.hash=W;}}function o(X,W){var Y=document.createEvent("HTMLEvents",1,2);Y.initEvent(X,true,true);q(Y,W);d.wrapper.dispatchEvent(Y);
++}function s(){if(document.querySelector(a+".present")){var X=document.querySelectorAll(a+".present .fragment:not(.visible)");if(X.length){X[0].classList.add("visible");
++o("fragmentshown",{fragment:X[0]});return true;}}else{var W=document.querySelectorAll(j+".present .fragment:not(.visible)");if(W.length){W[0].classList.add("visible");
++o("fragmentshown",{fragment:W[0]});return true;}}return false;}function G(){if(document.querySelector(a+".present")){var X=document.querySelectorAll(a+".present .fragment.visible");
++if(X.length){X[X.length-1].classList.remove("visible");o("fragmenthidden",{fragment:X[0]});return true;}}else{var W=document.querySelectorAll(j+".present .fragment.visible");
++if(W.length){W[W.length-1].classList.remove("visible");o("fragmenthidden",{fragment:W[0]});return true;}}return false;}function F(X,W){k=X===undefined?k:X;
++c=W===undefined?c:W;b();}function x(){if(O()||G()===false){k--;c=0;b();}}function i(){if(O()||s()===false){k++;c=0;b();}}function r(){if(O()||G()===false){c--;
++b();}}function B(){if(O()||s()===false){c++;b();}}function N(){if(G()===false){if(f().up){r();}else{var W=document.querySelector("#reveal .slides>section.past:nth-child("+k+")");
++if(W){c=(W.querySelectorAll("section").length+1)||0;k--;b();}}}}function u(){if(s()===false){f().down?B():i();}}function M(){if(O()){R();}else{C();}}return{initialize:h,navigateTo:F,navigateLeft:x,navigateRight:i,navigateUp:r,navigateDown:B,toggleOverview:M,addEventListener:function(X,Y,W){(d.wrapper||document.querySelector("#reveal")).addEventListener(X,Y,W);
++},removeEventListener:function(X,Y,W){(d.wrapper||document.querySelector("#reveal")).removeEventListener(X,Y,W);}};})();