From 470cabaea81626b9983923cbe59bc6bbc673a169 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Sun, 14 Oct 2012 21:02:32 -0400 Subject: [PATCH] new shorter api method names (closes #178), restructured and cleaned up core js --- README.md | 14 +- index.html | 39 ++ js/reveal.js | 786 +++++++++++++++++---------------- js/reveal.min.js | 83 ++-- plugin/speakernotes/notes.html | 4 +- 5 files changed, 499 insertions(+), 427 deletions(-) diff --git a/README.md b/README.md index b4dbf89..877169b 100644 --- a/README.md +++ b/README.md @@ -124,13 +124,13 @@ The Reveal class provides a minimal JavaScript API for controlling navigation an ```javascript // Navigation -Reveal.navigateTo( indexh, indexv ); -Reveal.navigateLeft(); -Reveal.navigateRight(); -Reveal.navigateUp(); -Reveal.navigateDown(); -Reveal.navigatePrev(); -Reveal.navigateNext(); +Reveal.slide( indexh, indexv ); +Reveal.left(); +Reveal.right(); +Reveal.up(); +Reveal.down(); +Reveal.prev(); +Reveal.next(); Reveal.toggleOverview(); // Retrieves the previous and current slide elements diff --git a/index.html b/index.html index 3ea2412..313c33c 100644 --- a/index.html +++ b/index.html @@ -353,5 +353,44 @@ function linkify( selector ) { + + +
+ + + + + + + +
+ + Fork me on GitHub + + + + + + + diff --git a/js/reveal.js b/js/reveal.js index 3372029..c1ffb8f 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -1,5 +1,5 @@ /*! - * reveal.js 2.1 r32 + * reveal.js 2.1 r33 * http://lab.hakim.se/reveal-js * MIT licensed * @@ -285,18 +285,6 @@ var Reveal = (function(){ dom.progress.style.display = 'block'; } - // Load the theme in the config, if it's not already loaded - if( config.theme && dom.theme ) { - var themeURL = dom.theme.getAttribute( 'href' ); - var themeFinder = /[^\/]*?(?=\.css)/; - var themeName = themeURL.match(themeFinder)[0]; - - if( config.theme !== themeName ) { - themeURL = themeURL.replace(themeFinder, config.theme); - dom.theme.setAttribute( 'href', themeURL ); - } - } - if( config.transition !== 'default' ) { dom.wrapper.classList.add( config.transition ); } @@ -306,12 +294,27 @@ var Reveal = (function(){ document.addEventListener( 'mousewheel', onDocumentMouseScroll, false ); } + // 3D links if( config.rollingLinks ) { - // Add some 3D magic to our anchors linkify(); } + + // Load the theme in the config, if it's not already loaded + if( config.theme && dom.theme ) { + var themeURL = dom.theme.getAttribute( 'href' ); + var themeFinder = /[^\/]*?(?=\.css)/; + var themeName = themeURL.match(themeFinder)[0]; + + if( config.theme !== themeName ) { + themeURL = themeURL.replace(themeFinder, config.theme); + dom.theme.setAttribute( 'href', themeURL ); + } + } } + /** + * Binds all event listeners. + */ function addEventListeners() { document.addEventListener( 'touchstart', onDocumentTouchStart, false ); document.addEventListener( 'touchmove', onDocumentTouchMove, false ); @@ -330,6 +333,9 @@ var Reveal = (function(){ } } + /** + * Unbinds all event listeners. + */ function removeEventListeners() { document.removeEventListener( 'keydown', onDocumentKeyDown, false ); document.removeEventListener( 'touchstart', onDocumentTouchStart, false ); @@ -403,210 +409,6 @@ var Reveal = (function(){ extend( event, properties ); dom.wrapper.dispatchEvent( event ); } - - /** - * Handler for the document level 'keydown' event. - * - * @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; - - var triggered = true; - - switch( event.keyCode ) { - // p, page up - case 80: case 33: navigatePrev(); break; - // n, page down - case 78: case 34: navigateNext(); break; - // h, left - case 72: case 37: navigateLeft(); break; - // l, right - case 76: case 39: navigateRight(); break; - // k, up - case 75: case 38: navigateUp(); break; - // j, down - case 74: case 40: navigateDown(); break; - // home - case 36: navigateTo( 0 ); break; - // end - case 35: navigateTo( Number.MAX_VALUE ); break; - // space - case 32: isOverviewActive() ? deactivateOverview() : navigateNext(); break; - // return - case 13: isOverviewActive() ? deactivateOverview() : triggered = false; break; - // b, period - case 66: case 190: togglePause(); break; - // f - case 70: enterFullscreen(); break; - default: - triggered = false; - } - - // If the input resulted in a triggered action we should prevent - // the browsers default behavior - if( triggered ) { - event.preventDefault(); - } - else if ( event.keyCode === 27 && supports3DTransforms ) { - toggleOverview(); - - event.preventDefault(); - } - - // If auto-sliding is enabled we need to cue up - // another timeout - cueAutoSlide(); - - } - - /** - * Handler for the document level 'touchstart' event, - * enables support for swipe and pinch gestures. - */ - function onDocumentTouchStart( event ) { - 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 && config.overview ) { - 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 ) { - // 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 && config.overview ) { - - // 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(); - } - } - - event.preventDefault(); - - } - // There was only one touch point, look for a swipe - else if( event.touches.length === 1 && touch.startCount !== 2 ) { - - 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(); - } - - event.preventDefault(); - - } - } - // There's a bug with swiping on some Android devices unless - // the default action is always prevented - else if( navigator.userAgent.match( /android/gi ) ) { - event.preventDefault(); - } - } - - /** - * Handler for the document level 'touchend' event. - */ - function onDocumentTouchEnd( event ) { - touch.handled = false; - } - - /** - * Handles mouse wheel scrolling, throttled to avoid - * skipping multiple slides. - */ - function onDocumentMouseScroll( event ){ - clearTimeout( mouseWheelTimeout ); - - mouseWheelTimeout = setTimeout( function() { - var delta = event.detail || -event.wheelDelta; - if( delta > 0 ) { - navigateNext(); - } - else { - navigatePrev(); - } - }, 100 ); - } - - /** - * Handler for the window level 'hashchange' event. - * - * @param {Object} event - */ - function onWindowHashChange( event ) { - readURL(); - } - - /** - * Invoked when a slide is and we're in the overview. - */ - function onOverviewSlideClicked( event ) { - // TODO There's a bug here where the event listeners are not - // removed after deactivating the overview. - if( isOverviewActive() ) { - event.preventDefault(); - - deactivateOverview(); - - indexh = this.getAttribute( 'data-index-h' ); - indexv = this.getAttribute( 'data-index-v' ); - - slide(); - } - } /** * Wrap all links in 3D goodness. @@ -795,109 +597,14 @@ var Reveal = (function(){ function isPaused() { return dom.wrapper.classList.contains( 'paused' ); } - + /** - * Updates one dimension of slides by showing the slide - * with the specified index. - * - * @param {String} selector A CSS selector that will fetch - * the group of slides we are working with - * @param {Number} index The index of the slide that should be - * shown - * - * @return {Number} The index of the slide that is now shown, - * might differ from the passed in index if it was out of - * bounds. - */ - function updateSlides( selector, index ) { - // Select all slides and convert the NodeList result to - // an array - var slides = Array.prototype.slice.call( document.querySelectorAll( selector ) ), - slidesLength = slides.length; - - if( slidesLength ) { - - // Should the index loop? - if( config.loop ) { - index %= slidesLength; - - if( index < 0 ) { - index = slidesLength + index; - } - } - - // Enforce max and minimum index bounds - index = Math.max( Math.min( index, slidesLength - 1 ), 0 ); - - for( var i = 0; i < slidesLength; i++ ) { - var slide = slides[i]; - - // Optimization; hide all slides that are three or more steps - // away from the present slide - if( isOverviewActive() === false ) { - // The distance loops so that it measures 1 between the first - // and last slides - 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 ) { - // Any element previous to index is given the 'past' class - slides[i].classList.add( 'past' ); - } - else if( i > index ) { - // Any element subsequent to index is given the 'future' class - slides[i].classList.add( 'future' ); - } - - // If this element contains vertical slides - if( slide.querySelector( 'section' ) ) { - slides[i].classList.add( 'stack' ); - } - } - - // Mark the current slide as present - slides[index].classList.add( 'present' ); - - // If this slide has a state associated with it, add it - // onto the current state of the deck - var slideState = slides[index].getAttribute( 'data-state' ); - if( slideState ) { - state = state.concat( slideState.split( ' ' ) ); - } - - // If this slide has a data-autoslide attribtue associated use this as - // autoSlide value otherwise use the global configured time - var slideAutoSlide = slides[index].getAttribute( 'data-autoslide' ); - if( slideAutoSlide ) { - autoSlide = parseInt( slideAutoSlide ); - } else { - autoSlide = config.autoSlide - } - - } - else { - // Since there are no slides we can't be anywhere beyond the - // zeroth index - index = 0; - } - - return index; - - } - - /** - * Steps from the current point in the presentation to the - * slide which matches the specified horizontal and vertical - * indices. - * - * @param {int} h Horizontal index of the target slide - * @param {int} v Vertical index of the target slide + * Steps from the current point in the presentation to the + * slide which matches the specified horizontal and vertical + * indices. + * + * @param {int} h Horizontal index of the target slide + * @param {int} v Vertical index of the target slide */ function slide( h, v ) { // Remember where we were at before @@ -986,26 +693,121 @@ var Reveal = (function(){ } } + /** + * Updates one dimension of slides by showing the slide + * with the specified index. + * + * @param {String} selector A CSS selector that will fetch + * the group of slides we are working with + * @param {Number} index The index of the slide that should be + * shown + * + * @return {Number} The index of the slide that is now shown, + * might differ from the passed in index if it was out of + * bounds. + */ + function updateSlides( selector, index ) { + // Select all slides and convert the NodeList result to + // an array + var slides = Array.prototype.slice.call( document.querySelectorAll( selector ) ), + slidesLength = slides.length; + + if( slidesLength ) { + + // Should the index loop? + if( config.loop ) { + index %= slidesLength; + + if( index < 0 ) { + index = slidesLength + index; + } + } + + // Enforce max and minimum index bounds + index = Math.max( Math.min( index, slidesLength - 1 ), 0 ); + + for( var i = 0; i < slidesLength; i++ ) { + var element = slides[i]; + + // Optimization; hide all slides that are three or more steps + // away from the present slide + if( isOverviewActive() === false ) { + // The distance loops so that it measures 1 between the first + // and last slides + var distance = Math.abs( ( index - i ) % ( slidesLength - 3 ) ) || 0; + + element.style.display = distance > 3 ? 'none' : 'block'; + } + + slides[i].classList.remove( 'past' ); + slides[i].classList.remove( 'present' ); + slides[i].classList.remove( 'future' ); + + if( i < index ) { + // Any element previous to index is given the 'past' class + slides[i].classList.add( 'past' ); + } + else if( i > index ) { + // Any element subsequent to index is given the 'future' class + slides[i].classList.add( 'future' ); + } + + // If this element contains vertical slides + if( element.querySelector( 'section' ) ) { + slides[i].classList.add( 'stack' ); + } + } + + // Mark the current slide as present + slides[index].classList.add( 'present' ); + + // If this slide has a state associated with it, add it + // onto the current state of the deck + var slideState = slides[index].getAttribute( 'data-state' ); + if( slideState ) { + state = state.concat( slideState.split( ' ' ) ); + } + + // If this slide has a data-autoslide attribtue associated use this as + // autoSlide value otherwise use the global configured time + var slideAutoSlide = slides[index].getAttribute( 'data-autoslide' ); + if( slideAutoSlide ) { + autoSlide = parseInt( slideAutoSlide ); + } else { + autoSlide = config.autoSlide + } + + } + else { + // Since there are no slides we can't be anywhere beyond the + // zeroth index + index = 0; + } + + return index; + + } + /** * Updates the state and link pointers of the controls. */ function updateControls() { - if ( !config.controls || !dom.controls ) { - return; + if ( config.controls && dom.controls ) { + + var routes = availableRoutes(); + + // Remove the 'enabled' class from all directions + [ dom.controlsLeft, dom.controlsRight, dom.controlsUp, dom.controlsDown ].forEach( function( node ) { + node.classList.remove( 'enabled' ); + } ); + + // Add the 'enabled' class to the available routes + 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' ); + } - - var routes = availableRoutes(); - - // Remove the 'enabled' class from all directions - [ dom.controlsLeft, dom.controlsRight, dom.controlsUp, dom.controlsDown ].forEach( function( node ) { - node.classList.remove( 'enabled' ); - } ); - - // Add the 'enabled' class to the available routes - 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' ); } /** @@ -1039,16 +841,16 @@ var Reveal = (function(){ // assume that this is a named link if( isNaN( parseInt( bits[0], 10 ) ) && name.length ) { // Find the slide with the specified name - var slide = document.querySelector( '#' + name ); + var element = document.querySelector( '#' + name ); - if( slide ) { + if( element ) { // Find the position of the named slide and navigate to it - var indices = Reveal.getIndices( slide ); - navigateTo( indices.h, indices.v ); + var indices = Reveal.getIndices( element ); + slide( indices.h, indices.v ); } // If the slide doesn't exist, navigate to the current slide else { - navigateTo( indexh, indexv ); + slide( indexh, indexv ); } } else { @@ -1056,7 +858,7 @@ var Reveal = (function(){ var h = parseInt( bits[0], 10 ) || 0, v = parseInt( bits[1], 10 ) || 0; - navigateTo( h, v ); + slide( h, v ); } } @@ -1077,6 +879,41 @@ var Reveal = (function(){ } } + /** + * Retrieves the h/v location of the current, or specified, + * slide. + * + * @param {HTMLElement} slide If specified, the returned + * index will be for this slide rather than the currently + * active one + * + * @return {Object} { h: , v: } + */ + function getIndices( slide ) { + // By default, return the current indices + var h = indexh, + v = indexv; + + // If a slide is specified, return the indices of that slide + if( slide ) { + var isVertical = !!slide.parentNode.nodeName.match( /section/gi ); + var slideh = isVertical ? slide.parentNode : slide; + + // Select all horizontal slides + var horizontalSlides = Array.prototype.slice.call( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ); + + // Now that we know which the horizontal slide is, get its index + h = Math.max( horizontalSlides.indexOf( slideh ), 0 ); + + // If this is a vertical slide, grab the vertical index + if( isVertical ) { + v = Math.max( Array.prototype.slice.call( slide.parentNode.children ).indexOf( slide ), 0 ); + } + } + + return { h: h, v: v }; + } + /** * Navigate to the next slide fragment. * @@ -1155,16 +992,6 @@ var Reveal = (function(){ } } - /** - * Triggers a navigation to the specified indices. - * - * @param {Number} h The horizontal index of the slide to show - * @param {Number} v The vertical index of the slide to show - */ - function navigateTo( h, v ) { - slide( h, v ); - } - function navigateLeft() { // Prioritize hiding fragments if( isOverviewActive() || previousFragment() === false ) { @@ -1232,16 +1059,244 @@ var Reveal = (function(){ cueAutoSlide(); } - // Expose some methods publicly + + // --------------------------------------------------------------------// + // ----------------------------- EVENTS -------------------------------// + // --------------------------------------------------------------------// + + + /** + * Handler for the document level 'keydown' event. + * + * @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; + + var triggered = true; + + switch( event.keyCode ) { + // p, page up + case 80: case 33: navigatePrev(); break; + // n, page down + case 78: case 34: navigateNext(); break; + // h, left + case 72: case 37: navigateLeft(); break; + // l, right + case 76: case 39: navigateRight(); break; + // k, up + case 75: case 38: navigateUp(); break; + // j, down + case 74: case 40: navigateDown(); break; + // home + case 36: slide( 0 ); break; + // end + case 35: slide( Number.MAX_VALUE ); break; + // space + case 32: isOverviewActive() ? deactivateOverview() : navigateNext(); break; + // return + case 13: isOverviewActive() ? deactivateOverview() : triggered = false; break; + // b, period + case 66: case 190: togglePause(); break; + // f + case 70: enterFullscreen(); break; + default: + triggered = false; + } + + // If the input resulted in a triggered action we should prevent + // the browsers default behavior + if( triggered ) { + event.preventDefault(); + } + else if ( event.keyCode === 27 && supports3DTransforms ) { + toggleOverview(); + + event.preventDefault(); + } + + // If auto-sliding is enabled we need to cue up + // another timeout + cueAutoSlide(); + + } + + /** + * Handler for the document level 'touchstart' event, + * enables support for swipe and pinch gestures. + */ + function onDocumentTouchStart( event ) { + 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 && config.overview ) { + 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 ) { + // 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 && config.overview ) { + + // 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(); + } + } + + event.preventDefault(); + + } + // There was only one touch point, look for a swipe + else if( event.touches.length === 1 && touch.startCount !== 2 ) { + + 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(); + } + + event.preventDefault(); + + } + } + // There's a bug with swiping on some Android devices unless + // the default action is always prevented + else if( navigator.userAgent.match( /android/gi ) ) { + event.preventDefault(); + } + } + + /** + * Handler for the document level 'touchend' event. + */ + function onDocumentTouchEnd( event ) { + touch.handled = false; + } + + /** + * Handles mouse wheel scrolling, throttled to avoid + * skipping multiple slides. + */ + function onDocumentMouseScroll( event ){ + clearTimeout( mouseWheelTimeout ); + + mouseWheelTimeout = setTimeout( function() { + var delta = event.detail || -event.wheelDelta; + if( delta > 0 ) { + navigateNext(); + } + else { + navigatePrev(); + } + }, 100 ); + } + + /** + * Handler for the window level 'hashchange' event. + * + * @param {Object} event + */ + function onWindowHashChange( event ) { + readURL(); + } + + /** + * Invoked when a slide is and we're in the overview. + */ + function onOverviewSlideClicked( event ) { + // TODO There's a bug here where the event listeners are not + // removed after deactivating the overview. + if( isOverviewActive() ) { + event.preventDefault(); + + deactivateOverview(); + + indexh = this.getAttribute( 'data-index-h' ); + indexv = this.getAttribute( 'data-index-v' ); + + slide(); + } + } + + + // --------------------------------------------------------------------// + // ------------------------------- API --------------------------------// + // --------------------------------------------------------------------// + + return { initialize: initialize, - navigateTo: navigateTo, + + // Navigation methods + slide: slide, + left: navigateLeft, + right: navigateRight, + up: navigateUp, + down: navigateDown, + prev: navigatePrev, + next: navigateNext, + + // Deprecated aliases + navigateTo: slide, navigateLeft: navigateLeft, navigateRight: navigateRight, navigateUp: navigateUp, navigateDown: navigateDown, navigatePrev: navigatePrev, navigateNext: navigateNext, + + // Toggles the overview mode on/off toggleOverview: toggleOverview, // Adds or removes all internal event listeners (such as keyboard) @@ -1249,30 +1304,7 @@ var Reveal = (function(){ removeEventListeners: removeEventListeners, // Returns the indices of the current, or specified, slide - getIndices: function( slide ) { - // By default, return the current indices - var h = indexh, - v = indexv; - - // If a slide is specified, return the indices of that slide - if( slide ) { - var isVertical = !!slide.parentNode.nodeName.match( /section/gi ); - var slideh = isVertical ? slide.parentNode : slide; - - // Select all horizontal slides - var horizontalSlides = Array.prototype.slice.call( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ); - - // Now that we know which the horizontal slide is, get its index - h = Math.max( horizontalSlides.indexOf( slideh ), 0 ); - - // If this is a vertical slide, grab the vertical index - if( isVertical ) { - v = Math.max( Array.prototype.slice.call( slide.parentNode.children ).indexOf( slide ), 0 ); - } - } - - return { h: h, v: v }; - }, + getIndices: getIndices, // Returns the previous slide element, may be null getPreviousSlide: function() { diff --git a/js/reveal.min.js b/js/reveal.min.js index b4f4083..8f25320 100644 --- a/js/reveal.min.js +++ b/js/reveal.min.js @@ -1,5 +1,5 @@ /*! - * reveal.js 2.1 r32 + * reveal.js 2.1 r33 * http://lab.hakim.se/reveal-js * MIT licensed * @@ -18,28 +18,18 @@ f.controlsDown=document.querySelector(".reveal .controls .down");}}function d(){ document.body.style.height="120%";window.addEventListener("load",ad,false);window.addEventListener("orientationchange",ad,false);}}function V(){var al=[],ap=[]; for(var am=0,ak=R.dependencies.length;amac.threshold){ac.handled=true;if(aoac.threshold&&Math.abs(al)>Math.abs(ak)){ac.handled=true;B();}else{if(al<-ac.threshold&&Math.abs(al)>Math.abs(ak)){ac.handled=true;j();}else{if(ak>ac.threshold){ac.handled=true; -u();}else{if(ak<-ac.threshold){ac.handled=true;F();}}}}ap.preventDefault();}}}else{if(navigator.userAgent.match(/android/gi)){ap.preventDefault();}}}function W(ak){ac.handled=false; -}function p(ak){clearTimeout(z);z=setTimeout(function(){var al=ak.detail||-ak.wheelDelta;if(al>0){x();}else{Z();}},100);}function w(ak){J();}function C(ak){if(L()){ak.preventDefault(); -ae();m=this.getAttribute("data-index-h");e=this.getAttribute("data-index-v");a();}}function M(){if(T&&!("msPerspective" in document.body.style)){var al=document.querySelectorAll(".reveal .slides section a:not(.image)"); +t(am,ak);f.wrapper.dispatchEvent(am);}function N(){if(T&&!("msPerspective" in document.body.style)){var al=document.querySelectorAll(".reveal .slides section a:not(.image)"); for(var am=0,ak=al.length;am'+an.innerHTML+"";}}}}function I(){if(R.overview){f.wrapper.classList.add("overview");var ak=document.querySelectorAll(l); for(var ap=0,an=ak.length;ap3?"none":"block";}al[ap].classList.remove("past"); -al[ap].classList.remove("present");al[ap].classList.remove("future");if(apat){al[ap].classList.add("future"); +}}function c(){f.wrapper.classList.add("paused");}function p(){f.wrapper.classList.remove("paused");}function aa(){if(ag()){p();}else{c();}}function ag(){return f.wrapper.classList.contains("paused"); +}function a(aq,av){y=G;var an=aj.concat();aj.length=0;var au=m,al=e;m=ai(l,aq===undefined?m:aq);e=ai(b,av===undefined?e:av);stateLoop:for(var ao=0,ar=aj.length; +ao3?"none":"block"; +}al[ap].classList.remove("past");al[ap].classList.remove("present");al[ap].classList.remove("future");if(apat){al[ap].classList.add("future"); }}if(aq.querySelector("section")){al[ap].classList.add("stack");}}al[at].classList.add("present");var am=al[at].getAttribute("data-state");if(am){aj=aj.concat(am.split(" ")); -}var ao=al[at].getAttribute("data-autoslide");if(ao){Y=parseInt(ao);}else{Y=R.autoSlide;}}else{at=0;}return at;}function a(aq,av){y=G;var an=aj.concat(); -aj.length=0;var au=m,al=e;m=ai(l,aq===undefined?m:aq);e=ai(b,av===undefined?e:av);stateLoop:for(var ao=0,ar=aj.length;ao0,right:m0,down:e0||e>0){ak+=m;}if(e>0){ak+="/"+e;}window.location.hash=ak;}}function v(){if(document.querySelector(b+".present")){var al=document.querySelectorAll(b+".present .fragment:not(.visible)"); -if(al.length){al[0].classList.add("visible");r("fragmentshown",{fragment:al[0]});return true;}}else{var ak=document.querySelectorAll(l+".present .fragment:not(.visible)"); -if(ak.length){ak[0].classList.add("visible");r("fragmentshown",{fragment:ak[0]});return true;}}return false;}function Q(){if(document.querySelector(b+".present")){var al=document.querySelectorAll(b+".present .fragment.visible"); +}var ao=al[at].getAttribute("data-autoslide");if(ao){Y=parseInt(ao);}else{Y=R.autoSlide;}}else{at=0;}return at;}function s(){if(R.controls&&f.controls){var ak=g(); +[f.controlsLeft,f.controlsRight,f.controlsUp,f.controlsDown].forEach(function(al){al.classList.remove("enabled");});if(ak.left){f.controlsLeft.classList.add("enabled"); +}if(ak.right){f.controlsRight.classList.add("enabled");}if(ak.up){f.controlsUp.classList.add("enabled");}if(ak.down){f.controlsDown.classList.add("enabled"); +}}}function g(){var ak=document.querySelectorAll(l),al=document.querySelectorAll(b);return{left:m>0,right:m0,down:e0||e>0){ak+=m; +}if(e>0){ak+="/"+e;}window.location.hash=ak;}}function M(ak){var ao=m,am=e;if(ak){var ap=!!ak.parentNode.nodeName.match(/section/gi);var an=ap?ak.parentNode:ak; +var al=Array.prototype.slice.call(document.querySelectorAll(l));ao=Math.max(al.indexOf(an),0);if(ap){am=Math.max(Array.prototype.slice.call(ak.parentNode.children).indexOf(ak),0); +}}return{h:ao,v:am};}function v(){if(document.querySelector(b+".present")){var al=document.querySelectorAll(b+".present .fragment:not(.visible)");if(al.length){al[0].classList.add("visible"); +r("fragmentshown",{fragment:al[0]});return true;}}else{var ak=document.querySelectorAll(l+".present .fragment:not(.visible)");if(ak.length){ak[0].classList.add("visible"); +r("fragmentshown",{fragment:ak[0]});return true;}}return false;}function Q(){if(document.querySelector(b+".present")){var al=document.querySelectorAll(b+".present .fragment.visible"); if(al.length){al[al.length-1].classList.remove("visible");r("fragmenthidden",{fragment:al[al.length-1]});return true;}}else{var ak=document.querySelectorAll(l+".present .fragment.visible"); -if(ak.length){ak[ak.length-1].classList.remove("visible");r("fragmenthidden",{fragment:ak[ak.length-1]});return true;}}return false;}function N(){clearTimeout(k); -if(Y){k=setTimeout(x,Y);}}function O(al,ak){a(al,ak);}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); +if(ak.length){ak[ak.length-1].classList.remove("visible");r("fragmenthidden",{fragment:ak[ak.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 ak=document.querySelector(".reveal .slides>section.past:nth-child("+m+")"); -if(ak){e=(ak.querySelectorAll("section").length+1)||0;m--;a();}}}}function x(){if(v()===false){g().down?F():j();}N();}return{initialize:i,navigateTo:O,navigateLeft:B,navigateRight:j,navigateUp:u,navigateDown:F,navigatePrev:Z,navigateNext:x,toggleOverview:X,addEventListeners:E,removeEventListeners:U,getIndices:function(ak){var ao=m,am=e; -if(ak){var ap=!!ak.parentNode.nodeName.match(/section/gi);var an=ap?ak.parentNode:ak;var al=Array.prototype.slice.call(document.querySelectorAll(l));ao=Math.max(al.indexOf(an),0); -if(ap){am=Math.max(Array.prototype.slice.call(ak.parentNode.children).indexOf(ak),0);}}return{h:ao,v:am};},getPreviousSlide:function(){return y;},getCurrentSlide:function(){return G; -},getQueryHash:function(){var ak={};location.search.replace(/[A-Z0-9]+?=(\w*)/gi,function(al){ak[al.split("=").shift()]=al.split("=").pop();});return ak; -},addEventListener:function(al,am,ak){if("addEventListener" in window){(f.wrapper||document.querySelector(".reveal")).addEventListener(al,am,ak);}},removeEventListener:function(al,am,ak){if("addEventListener" in window){(f.wrapper||document.querySelector(".reveal")).removeEventListener(al,am,ak); +if(ak){e=(ak.querySelectorAll("section").length+1)||0;m--;a();}}}}function x(){if(v()===false){g().down?F():j();}O();}function ah(al){if(document.querySelector(":focus")!==null||al.shiftKey||al.altKey||al.ctrlKey||al.metaKey){return; +}var ak=true;switch(al.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():ak=false;break;case 66:case 190:aa(); +break;case 70:ab();break;default:ak=false;}if(ak){al.preventDefault();}else{if(al.keyCode===27&&T){X();al.preventDefault();}}O();}function A(ak){ac.startX=ak.touches[0].clientX; +ac.startY=ak.touches[0].clientY;ac.startCount=ak.touches.length;if(ak.touches.length===2&&R.overview){ac.startSpan=S({x:ak.touches[1].clientX,y:ak.touches[1].clientY},{x:ac.startX,y:ac.startY}); +}}function af(ap){if(!ac.handled){var an=ap.touches[0].clientX;var am=ap.touches[0].clientY;if(ap.touches.length===2&&ac.startCount===2&&R.overview){var ao=S({x:ap.touches[1].clientX,y:ap.touches[1].clientY},{x:ac.startX,y:ac.startY}); +if(Math.abs(ac.startSpan-ao)>ac.threshold){ac.handled=true;if(aoac.threshold&&Math.abs(al)>Math.abs(ak)){ac.handled=true;B();}else{if(al<-ac.threshold&&Math.abs(al)>Math.abs(ak)){ac.handled=true;j();}else{if(ak>ac.threshold){ac.handled=true; +u();}else{if(ak<-ac.threshold){ac.handled=true;F();}}}}ap.preventDefault();}}}else{if(navigator.userAgent.match(/android/gi)){ap.preventDefault();}}}function W(ak){ac.handled=false; +}function o(ak){clearTimeout(z);z=setTimeout(function(){var al=ak.detail||-ak.wheelDelta;if(al>0){x();}else{Z();}},100);}function w(ak){J();}function C(ak){if(L()){ak.preventDefault(); +ae();m=this.getAttribute("data-index-h");e=this.getAttribute("data-index-v");a();}}return{initialize:i,slide:a,left:B,right:j,up:u,down:F,prev:Z,next:x,navigateTo:a,navigateLeft:B,navigateRight:j,navigateUp:u,navigateDown:F,navigatePrev:Z,navigateNext:x,toggleOverview:X,addEventListeners:E,removeEventListeners:U,getIndices:M,getPreviousSlide:function(){return y; +},getCurrentSlide:function(){return G;},getQueryHash:function(){var ak={};location.search.replace(/[A-Z0-9]+?=(\w*)/gi,function(al){ak[al.split("=").shift()]=al.split("=").pop(); +});return ak;},addEventListener:function(al,am,ak){if("addEventListener" in window){(f.wrapper||document.querySelector(".reveal")).addEventListener(al,am,ak); +}},removeEventListener:function(al,am,ak){if("addEventListener" in window){(f.wrapper||document.querySelector(".reveal")).removeEventListener(al,am,ak); }}};})(); \ No newline at end of file diff --git a/plugin/speakernotes/notes.html b/plugin/speakernotes/notes.html index 1106233..13f043d 100644 --- a/plugin/speakernotes/notes.html +++ b/plugin/speakernotes/notes.html @@ -119,8 +119,8 @@ notes.innerHTML = data.notes; } - currentSlide.contentWindow.Reveal.navigateTo(data.indexh, data.indexv); - nextSlide.contentWindow.Reveal.navigateTo(data.nextindexh, data.nextindexv); + currentSlide.contentWindow.Reveal.slide(data.indexh, data.indexv); + nextSlide.contentWindow.Reveal.slide(data.nextindexh, data.nextindexv); }); -- 2.26.2