reveal.js 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438
  1. /*!
  2. * reveal.js 2.1 r37
  3. * http://lab.hakim.se/reveal-js
  4. * MIT licensed
  5. *
  6. * Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
  7. */
  8. var Reveal = (function(){
  9. 'use strict';
  10. var HORIZONTAL_SLIDES_SELECTOR = '.reveal .slides>section',
  11. VERTICAL_SLIDES_SELECTOR = '.reveal .slides>section.present>section',
  12. // Configurations defaults, can be overridden at initialization time
  13. config = {
  14. // Display controls in the bottom right corner
  15. controls: true,
  16. // Display a presentation progress bar
  17. progress: true,
  18. // Push each slide change to the browser history
  19. history: false,
  20. // Enable keyboard shortcuts for navigation
  21. keyboard: true,
  22. // Enable the slide overview mode
  23. overview: true,
  24. // Loop the presentation
  25. loop: false,
  26. // Number of milliseconds between automatically proceeding to the
  27. // next slide, disabled when set to 0, this value can be overwritten
  28. // by using a data-autoslide attribute on your slides
  29. autoSlide: 0,
  30. // Enable slide navigation via mouse wheel
  31. mouseWheel: true,
  32. // Apply a 3D roll to links on hover
  33. rollingLinks: true,
  34. // Transition style (see /css/theme)
  35. theme: null,
  36. // Transition style
  37. transition: 'default', // default/cube/page/concave/zoom/linear/none
  38. // Script dependencies to load
  39. dependencies: []
  40. },
  41. // Stores if the next slide should be shown automatically
  42. // after n milliseconds
  43. autoSlide = config.autoSlide,
  44. // The horizontal and verical index of the currently active slide
  45. indexh = 0,
  46. indexv = 0,
  47. // the fragment index
  48. indexf = 0,
  49. // The previous and current slide HTML elements
  50. previousSlide,
  51. currentSlide,
  52. // Slides may hold a data-state attribute which we pick up and apply
  53. // as a class to the body. This list contains the combined state of
  54. // all current slides.
  55. state = [],
  56. // Cached references to DOM elements
  57. dom = {},
  58. // Detect support for CSS 3D transforms
  59. supports3DTransforms = 'WebkitPerspective' in document.body.style ||
  60. 'MozPerspective' in document.body.style ||
  61. 'msPerspective' in document.body.style ||
  62. 'OPerspective' in document.body.style ||
  63. 'perspective' in document.body.style,
  64. supports2DTransforms = 'WebkitTransform' in document.body.style ||
  65. 'MozTransform' in document.body.style ||
  66. 'msTransform' in document.body.style ||
  67. 'OTransform' in document.body.style ||
  68. 'transform' in document.body.style,
  69. // Throttles mouse wheel navigation
  70. mouseWheelTimeout = 0,
  71. // An interval used to automatically move on to the next slide
  72. autoSlideTimeout = 0,
  73. // Delays updates to the URL due to a Chrome thumbnailer bug
  74. writeURLTimeout = 0,
  75. // Holds information about the currently ongoing touch input
  76. touch = {
  77. startX: 0,
  78. startY: 0,
  79. startSpan: 0,
  80. startCount: 0,
  81. handled: false,
  82. threshold: 80
  83. };
  84. /**
  85. * Starts up the presentation if the client is capable.
  86. */
  87. function initialize( options ) {
  88. if( ( !supports2DTransforms && !supports3DTransforms ) ) {
  89. document.body.setAttribute( 'class', 'no-transforms' );
  90. // If the browser doesn't support core features we won't be
  91. // using JavaScript to control the presentation
  92. return;
  93. }
  94. // Copy options over to our config object
  95. extend( config, options );
  96. // Hide the address bar in mobile browsers
  97. hideAddressBar();
  98. // Loads the dependencies and continues to #start() once done
  99. load();
  100. }
  101. /**
  102. * Finds and stores references to DOM elements which are
  103. * required by the presentation. If a required element is
  104. * not found, it is created.
  105. */
  106. function setupDOM() {
  107. // Cache references to key DOM elements
  108. dom.theme = document.querySelector( '#theme' );
  109. dom.wrapper = document.querySelector( '.reveal' );
  110. // Progress bar
  111. if( !dom.wrapper.querySelector( '.progress' ) && config.progress ) {
  112. var progressElement = document.createElement( 'div' );
  113. progressElement.classList.add( 'progress' );
  114. progressElement.innerHTML = '<span></span>';
  115. dom.wrapper.appendChild( progressElement );
  116. }
  117. // Arrow controls
  118. if( !dom.wrapper.querySelector( '.controls' ) && config.controls ) {
  119. var controlsElement = document.createElement( 'aside' );
  120. controlsElement.classList.add( 'controls' );
  121. controlsElement.innerHTML = '<div class="left"></div>' +
  122. '<div class="right"></div>' +
  123. '<div class="up"></div>' +
  124. '<div class="down"></div>';
  125. dom.wrapper.appendChild( controlsElement );
  126. }
  127. // Presentation background element
  128. if( !dom.wrapper.querySelector( '.state-background' ) ) {
  129. var backgroundElement = document.createElement( 'div' );
  130. backgroundElement.classList.add( 'state-background' );
  131. dom.wrapper.appendChild( backgroundElement );
  132. }
  133. // Overlay graphic which is displayed during the paused mode
  134. if( !dom.wrapper.querySelector( '.pause-overlay' ) ) {
  135. var pausedElement = document.createElement( 'div' );
  136. pausedElement.classList.add( 'pause-overlay' );
  137. dom.wrapper.appendChild( pausedElement );
  138. }
  139. // Cache references to elements
  140. dom.progress = document.querySelector( '.reveal .progress' );
  141. dom.progressbar = document.querySelector( '.reveal .progress span' );
  142. if ( config.controls ) {
  143. dom.controls = document.querySelector( '.reveal .controls' );
  144. dom.controlsLeft = document.querySelector( '.reveal .controls .left' );
  145. dom.controlsRight = document.querySelector( '.reveal .controls .right' );
  146. dom.controlsUp = document.querySelector( '.reveal .controls .up' );
  147. dom.controlsDown = document.querySelector( '.reveal .controls .down' );
  148. }
  149. }
  150. /**
  151. * Hides the address bar if we're on a mobile device.
  152. */
  153. function hideAddressBar() {
  154. if( navigator.userAgent.match( /(iphone|ipod|android)/i ) ) {
  155. // Give the page some scrollable overflow
  156. document.documentElement.style.overflow = 'scroll';
  157. document.body.style.height = '120%';
  158. // Events that should trigger the address bar to hide
  159. window.addEventListener( 'load', removeAddressBar, false );
  160. window.addEventListener( 'orientationchange', removeAddressBar, false );
  161. }
  162. }
  163. /**
  164. * Loads the dependencies of reveal.js. Dependencies are
  165. * defined via the configuration option 'dependencies'
  166. * and will be loaded prior to starting/binding reveal.js.
  167. * Some dependencies may have an 'async' flag, if so they
  168. * will load after reveal.js has been started up.
  169. */
  170. function load() {
  171. var scripts = [],
  172. scriptsAsync = [];
  173. for( var i = 0, len = config.dependencies.length; i < len; i++ ) {
  174. var s = config.dependencies[i];
  175. // Load if there's no condition or the condition is truthy
  176. if( !s.condition || s.condition() ) {
  177. if( s.async ) {
  178. scriptsAsync.push( s.src );
  179. }
  180. else {
  181. scripts.push( s.src );
  182. }
  183. // Extension may contain callback functions
  184. if( typeof s.callback === 'function' ) {
  185. head.ready( s.src.match( /([\w\d_\-]*)\.?[^\\\/]*$/i )[0], s.callback );
  186. }
  187. }
  188. }
  189. // Called once synchronous scritps finish loading
  190. function proceed() {
  191. if( scriptsAsync.length ) {
  192. // Load asynchronous scripts
  193. head.js.apply( null, scriptsAsync );
  194. }
  195. start();
  196. }
  197. if( scripts.length ) {
  198. head.ready( proceed );
  199. // Load synchronous scripts
  200. head.js.apply( null, scripts );
  201. }
  202. else {
  203. proceed();
  204. }
  205. }
  206. /**
  207. * Starts up reveal.js by binding input events and navigating
  208. * to the current URL deeplink if there is one.
  209. */
  210. function start() {
  211. // Make sure we've got all the DOM elements we need
  212. setupDOM();
  213. // Subscribe to input
  214. addEventListeners();
  215. // Updates the presentation to match the current configuration values
  216. configure();
  217. // Read the initial hash
  218. readURL();
  219. // Start auto-sliding if it's enabled
  220. cueAutoSlide();
  221. // Notify listeners that the presentation is ready but use a 1ms
  222. // timeout to ensure it's not fired synchronously after #initialize()
  223. setTimeout( function() {
  224. dispatchEvent( 'ready', {
  225. 'indexh': indexh,
  226. 'indexv': indexv,
  227. 'currentSlide': currentSlide
  228. } );
  229. }, 1 );
  230. }
  231. /**
  232. * Applies the configuration settings from the config object.
  233. */
  234. function configure() {
  235. if( supports3DTransforms === false ) {
  236. config.transition = 'linear';
  237. }
  238. if( config.controls && dom.controls ) {
  239. dom.controls.style.display = 'block';
  240. }
  241. if( config.progress && dom.progress ) {
  242. dom.progress.style.display = 'block';
  243. }
  244. if( config.transition !== 'default' ) {
  245. dom.wrapper.classList.add( config.transition );
  246. }
  247. if( config.mouseWheel ) {
  248. document.addEventListener( 'DOMMouseScroll', onDocumentMouseScroll, false ); // FF
  249. document.addEventListener( 'mousewheel', onDocumentMouseScroll, false );
  250. }
  251. // 3D links
  252. if( config.rollingLinks ) {
  253. linkify();
  254. }
  255. // Load the theme in the config, if it's not already loaded
  256. if( config.theme && dom.theme ) {
  257. var themeURL = dom.theme.getAttribute( 'href' );
  258. var themeFinder = /[^\/]*?(?=\.css)/;
  259. var themeName = themeURL.match(themeFinder)[0];
  260. if( config.theme !== themeName ) {
  261. themeURL = themeURL.replace(themeFinder, config.theme);
  262. dom.theme.setAttribute( 'href', themeURL );
  263. }
  264. }
  265. }
  266. /**
  267. * Binds all event listeners.
  268. */
  269. function addEventListeners() {
  270. document.addEventListener( 'touchstart', onDocumentTouchStart, false );
  271. document.addEventListener( 'touchmove', onDocumentTouchMove, false );
  272. document.addEventListener( 'touchend', onDocumentTouchEnd, false );
  273. window.addEventListener( 'hashchange', onWindowHashChange, false );
  274. if( config.keyboard ) {
  275. document.addEventListener( 'keydown', onDocumentKeyDown, false );
  276. }
  277. if ( config.progress && dom.progress ) {
  278. dom.progress.addEventListener( 'click', preventAndForward( onProgressClick ), false );
  279. }
  280. if ( config.controls && dom.controls ) {
  281. dom.controlsLeft.addEventListener( 'click', preventAndForward( navigateLeft ), false );
  282. dom.controlsRight.addEventListener( 'click', preventAndForward( navigateRight ), false );
  283. dom.controlsUp.addEventListener( 'click', preventAndForward( navigateUp ), false );
  284. dom.controlsDown.addEventListener( 'click', preventAndForward( navigateDown ), false );
  285. }
  286. }
  287. /**
  288. * Unbinds all event listeners.
  289. */
  290. function removeEventListeners() {
  291. document.removeEventListener( 'keydown', onDocumentKeyDown, false );
  292. document.removeEventListener( 'touchstart', onDocumentTouchStart, false );
  293. document.removeEventListener( 'touchmove', onDocumentTouchMove, false );
  294. document.removeEventListener( 'touchend', onDocumentTouchEnd, false );
  295. window.removeEventListener( 'hashchange', onWindowHashChange, false );
  296. if ( config.progress && dom.progress ) {
  297. dom.progress.removeEventListener( 'click', preventAndForward( onProgressClick ), false );
  298. }
  299. if ( config.controls && dom.controls ) {
  300. dom.controlsLeft.removeEventListener( 'click', preventAndForward( navigateLeft ), false );
  301. dom.controlsRight.removeEventListener( 'click', preventAndForward( navigateRight ), false );
  302. dom.controlsUp.removeEventListener( 'click', preventAndForward( navigateUp ), false );
  303. dom.controlsDown.removeEventListener( 'click', preventAndForward( navigateDown ), false );
  304. }
  305. }
  306. /**
  307. * Extend object a with the properties of object b.
  308. * If there's a conflict, object b takes precedence.
  309. */
  310. function extend( a, b ) {
  311. for( var i in b ) {
  312. a[ i ] = b[ i ];
  313. }
  314. }
  315. /**
  316. * Measures the distance in pixels between point a
  317. * and point b.
  318. *
  319. * @param {Object} a point with x/y properties
  320. * @param {Object} b point with x/y properties
  321. */
  322. function distanceBetween( a, b ) {
  323. var dx = a.x - b.x,
  324. dy = a.y - b.y;
  325. return Math.sqrt( dx*dx + dy*dy );
  326. }
  327. /**
  328. * Prevents an events defaults behavior calls the
  329. * specified delegate.
  330. *
  331. * @param {Function} delegate The method to call
  332. * after the wrapper has been executed
  333. */
  334. function preventAndForward( delegate ) {
  335. return function( event ) {
  336. event.preventDefault();
  337. delegate.call( null, event );
  338. };
  339. }
  340. /**
  341. * Causes the address bar to hide on mobile devices,
  342. * more vertical space ftw.
  343. */
  344. function removeAddressBar() {
  345. setTimeout( function() {
  346. window.scrollTo( 0, 1 );
  347. }, 0 );
  348. }
  349. /**
  350. * Dispatches an event of the specified type from the
  351. * reveal DOM element.
  352. */
  353. function dispatchEvent( type, properties ) {
  354. var event = document.createEvent( "HTMLEvents", 1, 2 );
  355. event.initEvent( type, true, true );
  356. extend( event, properties );
  357. dom.wrapper.dispatchEvent( event );
  358. }
  359. /**
  360. * Wrap all links in 3D goodness.
  361. */
  362. function linkify() {
  363. if( supports3DTransforms && !( 'msPerspective' in document.body.style ) ) {
  364. var nodes = document.querySelectorAll( '.reveal .slides section a:not(.image)' );
  365. for( var i = 0, len = nodes.length; i < len; i++ ) {
  366. var node = nodes[i];
  367. if( node.textContent && !node.querySelector( 'img' ) && ( !node.className || !node.classList.contains( node, 'roll' ) ) ) {
  368. node.classList.add( 'roll' );
  369. node.innerHTML = '<span data-title="'+ node.text +'">' + node.innerHTML + '</span>';
  370. }
  371. }
  372. }
  373. }
  374. /**
  375. * Displays the overview of slides (quick nav) by
  376. * scaling down and arranging all slide elements.
  377. *
  378. * Experimental feature, might be dropped if perf
  379. * can't be improved.
  380. */
  381. function activateOverview() {
  382. // Only proceed if enabled in config
  383. if( config.overview ) {
  384. dom.wrapper.classList.add( 'overview' );
  385. var horizontalSlides = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR );
  386. for( var i = 0, len1 = horizontalSlides.length; i < len1; i++ ) {
  387. var hslide = horizontalSlides[i],
  388. htransform = 'translateZ(-2500px) translate(' + ( ( i - indexh ) * 105 ) + '%, 0%)';
  389. hslide.setAttribute( 'data-index-h', i );
  390. hslide.style.display = 'block';
  391. hslide.style.WebkitTransform = htransform;
  392. hslide.style.MozTransform = htransform;
  393. hslide.style.msTransform = htransform;
  394. hslide.style.OTransform = htransform;
  395. hslide.style.transform = htransform;
  396. if( !hslide.classList.contains( 'stack' ) ) {
  397. // Navigate to this slide on click
  398. hslide.addEventListener( 'click', onOverviewSlideClicked, true );
  399. }
  400. var verticalSlides = hslide.querySelectorAll( 'section' );
  401. for( var j = 0, len2 = verticalSlides.length; j < len2; j++ ) {
  402. var vslide = verticalSlides[j],
  403. vtransform = 'translate(0%, ' + ( ( j - ( i === indexh ? indexv : 0 ) ) * 105 ) + '%)';
  404. vslide.setAttribute( 'data-index-h', i );
  405. vslide.setAttribute( 'data-index-v', j );
  406. vslide.style.display = 'block';
  407. vslide.style.WebkitTransform = vtransform;
  408. vslide.style.MozTransform = vtransform;
  409. vslide.style.msTransform = vtransform;
  410. vslide.style.OTransform = vtransform;
  411. vslide.style.transform = vtransform;
  412. // Navigate to this slide on click
  413. vslide.addEventListener( 'click', onOverviewSlideClicked, true );
  414. }
  415. }
  416. }
  417. }
  418. /**
  419. * Exits the slide overview and enters the currently
  420. * active slide.
  421. */
  422. function deactivateOverview() {
  423. // Only proceed if enabled in config
  424. if( config.overview ) {
  425. dom.wrapper.classList.remove( 'overview' );
  426. // Select all slides
  427. var slides = Array.prototype.slice.call( document.querySelectorAll( '.reveal .slides section' ) );
  428. for( var i = 0, len = slides.length; i < len; i++ ) {
  429. var element = slides[i];
  430. // Resets all transforms to use the external styles
  431. element.style.WebkitTransform = '';
  432. element.style.MozTransform = '';
  433. element.style.msTransform = '';
  434. element.style.OTransform = '';
  435. element.style.transform = '';
  436. element.removeEventListener( 'click', onOverviewSlideClicked );
  437. }
  438. slide();
  439. }
  440. }
  441. /**
  442. * Toggles the slide overview mode on and off.
  443. *
  444. * @param {Boolean} override Optional flag which overrides the
  445. * toggle logic and forcibly sets the desired state. True means
  446. * overview is open, false means it's closed.
  447. */
  448. function toggleOverview( override ) {
  449. if( typeof override === 'boolean' ) {
  450. override ? activateOverview() : deactivateOverview();
  451. }
  452. else {
  453. isOverviewActive() ? deactivateOverview() : activateOverview();
  454. }
  455. }
  456. /**
  457. * Checks if the overview is currently active.
  458. *
  459. * @return {Boolean} true if the overview is active,
  460. * false otherwise
  461. */
  462. function isOverviewActive() {
  463. return dom.wrapper.classList.contains( 'overview' );
  464. }
  465. /**
  466. * Handling the fullscreen functionality via the fullscreen API
  467. *
  468. * @see http://fullscreen.spec.whatwg.org/
  469. * @see https://developer.mozilla.org/en-US/docs/DOM/Using_fullscreen_mode
  470. */
  471. function enterFullscreen() {
  472. var element = document.body;
  473. // Check which implementation is available
  474. var requestMethod = element.requestFullScreen ||
  475. element.webkitRequestFullScreen ||
  476. element.mozRequestFullScreen ||
  477. element.msRequestFullScreen;
  478. if( requestMethod ) {
  479. requestMethod.apply( element );
  480. }
  481. }
  482. /**
  483. * Enters the paused mode which fades everything on screen to
  484. * black.
  485. */
  486. function pause() {
  487. dom.wrapper.classList.add( 'paused' );
  488. }
  489. /**
  490. * Exits from the paused mode.
  491. */
  492. function resume() {
  493. dom.wrapper.classList.remove( 'paused' );
  494. }
  495. /**
  496. * Toggles the paused mode on and off.
  497. */
  498. function togglePause() {
  499. if( isPaused() ) {
  500. resume();
  501. }
  502. else {
  503. pause();
  504. }
  505. }
  506. /**
  507. * Checks if we are currently in the paused mode.
  508. */
  509. function isPaused() {
  510. return dom.wrapper.classList.contains( 'paused' );
  511. }
  512. /**
  513. * Steps from the current point in the presentation to the
  514. * slide which matches the specified horizontal and vertical
  515. * indices.
  516. *
  517. * @param {int} h Horizontal index of the target slide
  518. * @param {int} v Vertical index of the target slide
  519. */
  520. function slide( h, v, f) {
  521. // Remember where we were at before
  522. previousSlide = currentSlide;
  523. // Remember the state before this slide
  524. var stateBefore = state.concat();
  525. // Reset the state array
  526. state.length = 0;
  527. var indexhBefore = indexh,
  528. indexvBefore = indexv;
  529. // Activate and transition to the new slide
  530. indexh = updateSlides( HORIZONTAL_SLIDES_SELECTOR, h === undefined ? indexh : h );
  531. indexv = updateSlides( VERTICAL_SLIDES_SELECTOR, v === undefined ? indexv : v );
  532. // Show fragment, if specified
  533. if ( typeof f !== undefined ) {
  534. // Hide all fragments in current slide
  535. while ( previousFragment() ) {
  536. // loop
  537. }
  538. if ( f !== 0 ) {
  539. var fragmentIndex = 0;
  540. while ( indexf < f && nextFragment() ) {
  541. fragmentIndex++;
  542. }
  543. // We cannot trust nextFragment for setting indexf: it can go beyond the max number of fragments available
  544. indexf = fragmentIndex;
  545. }
  546. } else {
  547. indexf = 0;
  548. }
  549. // Apply the new state
  550. stateLoop: for( var i = 0, len = state.length; i < len; i++ ) {
  551. // Check if this state existed on the previous slide. If it
  552. // did, we will avoid adding it repeatedly.
  553. for( var j = 0; j < stateBefore.length; j++ ) {
  554. if( stateBefore[j] === state[i] ) {
  555. stateBefore.splice( j, 1 );
  556. continue stateLoop;
  557. }
  558. }
  559. document.documentElement.classList.add( state[i] );
  560. // Dispatch custom event matching the state's name
  561. dispatchEvent( state[i] );
  562. }
  563. // Clean up the remaints of the previous state
  564. while( stateBefore.length ) {
  565. document.documentElement.classList.remove( stateBefore.pop() );
  566. }
  567. // Update progress if enabled
  568. if( config.progress && dom.progress ) {
  569. dom.progressbar.style.width = ( indexh / ( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ).length - 1 ) ) * window.innerWidth + 'px';
  570. }
  571. // If the overview is active, re-activate it to update positions
  572. if( isOverviewActive() ) {
  573. activateOverview();
  574. }
  575. updateControls();
  576. updateURL();
  577. // Query all horizontal slides in the deck
  578. var horizontalSlides = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR );
  579. // Find the current horizontal slide and any possible vertical slides
  580. // within it
  581. var currentHorizontalSlide = horizontalSlides[ indexh ],
  582. currentVerticalSlides = currentHorizontalSlide.querySelectorAll( 'section' );
  583. // Store references to the previous and current slides
  584. currentSlide = currentVerticalSlides[ indexv ] || currentHorizontalSlide;
  585. // Dispatch an event if the slide changed
  586. if( indexh !== indexhBefore || indexv !== indexvBefore ) {
  587. dispatchEvent( 'slidechanged', {
  588. 'indexh': indexh,
  589. 'indexv': indexv,
  590. 'previousSlide': previousSlide,
  591. 'currentSlide': currentSlide
  592. } );
  593. }
  594. else {
  595. // Ensure that the previous slide is never the same as the current
  596. previousSlide = null;
  597. }
  598. // Solves an edge case where the previous slide maintains the
  599. // 'present' class when navigating between adjacent vertical
  600. // stacks
  601. if( previousSlide ) {
  602. previousSlide.classList.remove( 'present' );
  603. }
  604. }
  605. /**
  606. * Updates one dimension of slides by showing the slide
  607. * with the specified index.
  608. *
  609. * @param {String} selector A CSS selector that will fetch
  610. * the group of slides we are working with
  611. * @param {Number} index The index of the slide that should be
  612. * shown
  613. *
  614. * @return {Number} The index of the slide that is now shown,
  615. * might differ from the passed in index if it was out of
  616. * bounds.
  617. */
  618. function updateSlides( selector, index ) {
  619. // Select all slides and convert the NodeList result to
  620. // an array
  621. var slides = Array.prototype.slice.call( document.querySelectorAll( selector ) ),
  622. slidesLength = slides.length;
  623. if( slidesLength ) {
  624. // Should the index loop?
  625. if( config.loop ) {
  626. index %= slidesLength;
  627. if( index < 0 ) {
  628. index = slidesLength + index;
  629. }
  630. }
  631. // Enforce max and minimum index bounds
  632. index = Math.max( Math.min( index, slidesLength - 1 ), 0 );
  633. for( var i = 0; i < slidesLength; i++ ) {
  634. var element = slides[i];
  635. // Optimization; hide all slides that are three or more steps
  636. // away from the present slide
  637. if( isOverviewActive() === false ) {
  638. // The distance loops so that it measures 1 between the first
  639. // and last slides
  640. var distance = Math.abs( ( index - i ) % ( slidesLength - 3 ) ) || 0;
  641. element.style.display = distance > 3 ? 'none' : 'block';
  642. }
  643. slides[i].classList.remove( 'past' );
  644. slides[i].classList.remove( 'present' );
  645. slides[i].classList.remove( 'future' );
  646. if( i < index ) {
  647. // Any element previous to index is given the 'past' class
  648. slides[i].classList.add( 'past' );
  649. }
  650. else if( i > index ) {
  651. // Any element subsequent to index is given the 'future' class
  652. slides[i].classList.add( 'future' );
  653. }
  654. // If this element contains vertical slides
  655. if( element.querySelector( 'section' ) ) {
  656. slides[i].classList.add( 'stack' );
  657. }
  658. }
  659. // Mark the current slide as present
  660. slides[index].classList.add( 'present' );
  661. // If this slide has a state associated with it, add it
  662. // onto the current state of the deck
  663. var slideState = slides[index].getAttribute( 'data-state' );
  664. if( slideState ) {
  665. state = state.concat( slideState.split( ' ' ) );
  666. }
  667. // If this slide has a data-autoslide attribtue associated use this as
  668. // autoSlide value otherwise use the global configured time
  669. var slideAutoSlide = slides[index].getAttribute( 'data-autoslide' );
  670. if( slideAutoSlide ) {
  671. autoSlide = parseInt( slideAutoSlide );
  672. } else {
  673. autoSlide = config.autoSlide
  674. }
  675. }
  676. else {
  677. // Since there are no slides we can't be anywhere beyond the
  678. // zeroth index
  679. index = 0;
  680. }
  681. return index;
  682. }
  683. /**
  684. * Updates the state and link pointers of the controls.
  685. */
  686. function updateControls() {
  687. if ( config.controls && dom.controls ) {
  688. var routes = availableRoutes();
  689. // Remove the 'enabled' class from all directions
  690. [ dom.controlsLeft, dom.controlsRight, dom.controlsUp, dom.controlsDown ].forEach( function( node ) {
  691. node.classList.remove( 'enabled' );
  692. } );
  693. // Add the 'enabled' class to the available routes
  694. if( routes.left ) dom.controlsLeft.classList.add( 'enabled' );
  695. if( routes.right ) dom.controlsRight.classList.add( 'enabled' );
  696. if( routes.up ) dom.controlsUp.classList.add( 'enabled' );
  697. if( routes.down ) dom.controlsDown.classList.add( 'enabled' );
  698. }
  699. }
  700. /**
  701. * Determine what available routes there are for navigation.
  702. *
  703. * @return {Object} containing four booleans: left/right/up/down
  704. */
  705. function availableRoutes() {
  706. var horizontalSlides = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ),
  707. verticalSlides = document.querySelectorAll( VERTICAL_SLIDES_SELECTOR );
  708. return {
  709. left: indexh > 0,
  710. right: indexh < horizontalSlides.length - 1,
  711. up: indexv > 0,
  712. down: indexv < verticalSlides.length - 1
  713. };
  714. }
  715. /**
  716. * Reads the current URL (hash) and navigates accordingly.
  717. */
  718. function readURL() {
  719. var hash = window.location.hash;
  720. var hashParts = hash.split( '?' );
  721. // Attempt to parse the hash as either an index or name
  722. var bits = hashParts[0].slice( 2 ).split( '/' ),
  723. name = hashParts[0].replace( /#|\//gi, '' );
  724. // If the first bit is invalid and there is a name we can
  725. // assume that this is a named link
  726. if( isNaN( parseInt( bits[0], 10 ) ) && name.length ) {
  727. // Find the slide with the specified name
  728. var element = document.querySelector( '#' + name );
  729. if( element ) {
  730. // Find the position of the named slide and navigate to it
  731. var indices = Reveal.getIndices( element );
  732. slide( indices.h, indices.v );
  733. }
  734. // If the slide doesn't exist, navigate to the current slide
  735. else {
  736. slide( indexh, indexv );
  737. }
  738. }
  739. else {
  740. // Read the index components of the hash
  741. var h = parseInt( bits[0], 10 ) || 0,
  742. v = parseInt( bits[1], 10 ) || 0;
  743. var f = 0;
  744. if ( hashParts.length > 1 ) {
  745. f = parseInt( hashParts[1] );
  746. }
  747. slide( h, v, f );
  748. }
  749. }
  750. function updateURL () {
  751. // Update the URL hash after a delay since updating it mid-transition
  752. // is likely to cause visual lag
  753. clearTimeout( writeURLTimeout );
  754. writeURLTimeout = setTimeout( writeURL, 1500 );
  755. }
  756. /**
  757. * Updates the page URL (hash) to reflect the current
  758. * state.
  759. */
  760. function writeURL() {
  761. if( config.history ) {
  762. var url = '/';
  763. // Only include the minimum possible number of components in
  764. // the URL
  765. if( indexh > 0 || indexv > 0 ) url += indexh;
  766. if( indexv > 0 ) url += '/' + indexv;
  767. if( indexf > 0 ) url += '?' + indexf;
  768. window.location.hash = url;
  769. }
  770. }
  771. /**
  772. * Retrieves the h/v location of the current, or specified,
  773. * slide.
  774. *
  775. * @param {HTMLElement} slide If specified, the returned
  776. * index will be for this slide rather than the currently
  777. * active one
  778. *
  779. * @return {Object} { h: <int>, v: <int> }
  780. */
  781. function getIndices( slide ) {
  782. // By default, return the current indices
  783. var h = indexh,
  784. v = indexv;
  785. // If a slide is specified, return the indices of that slide
  786. if( slide ) {
  787. var isVertical = !!slide.parentNode.nodeName.match( /section/gi );
  788. var slideh = isVertical ? slide.parentNode : slide;
  789. // Select all horizontal slides
  790. var horizontalSlides = Array.prototype.slice.call( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
  791. // Now that we know which the horizontal slide is, get its index
  792. h = Math.max( horizontalSlides.indexOf( slideh ), 0 );
  793. // If this is a vertical slide, grab the vertical index
  794. if( isVertical ) {
  795. v = Math.max( Array.prototype.slice.call( slide.parentNode.children ).indexOf( slide ), 0 );
  796. }
  797. }
  798. return { h: h, v: v };
  799. }
  800. /**
  801. * Navigate to the next slide fragment.
  802. *
  803. * @return {Boolean} true if there was a next fragment,
  804. * false otherwise
  805. */
  806. function nextFragment() {
  807. // Vertical slides:
  808. var fragment,
  809. fragmentFound = false;
  810. if( document.querySelector( VERTICAL_SLIDES_SELECTOR + '.present' ) ) {
  811. var verticalFragments = document.querySelectorAll( VERTICAL_SLIDES_SELECTOR + '.present .fragment:not(.visible)' );
  812. if( verticalFragments.length ) {
  813. verticalFragments[0].classList.add( 'visible' );
  814. fragment = verticalFragments[0];
  815. fragmentFound = true;
  816. }
  817. }
  818. // Horizontal slides:
  819. else {
  820. var horizontalFragments = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.present .fragment:not(.visible)' );
  821. if( horizontalFragments.length ) {
  822. horizontalFragments[0].classList.add( 'visible' );
  823. fragment = horizontalFragments[0];
  824. fragmentFound = true;
  825. }
  826. }
  827. if ( fragmentFound ) {
  828. indexf++;
  829. // Notify subscribers of the change
  830. dispatchEvent( 'fragmentshown', { fragment: fragment, index: indexf } );
  831. updateURL();
  832. } else {
  833. indexf = 0;
  834. }
  835. return fragmentFound;
  836. }
  837. /**
  838. * Navigate to the previous slide fragment.
  839. *
  840. * @return {Boolean} true if there was a previous fragment,
  841. * false otherwise
  842. */
  843. function previousFragment() {
  844. var fragment,
  845. fragmentFound = false;
  846. // Vertical slides:
  847. if( document.querySelector( VERTICAL_SLIDES_SELECTOR + '.present' ) ) {
  848. var verticalFragments = document.querySelectorAll( VERTICAL_SLIDES_SELECTOR + '.present .fragment.visible' );
  849. if( verticalFragments.length ) {
  850. verticalFragments[ verticalFragments.length - 1 ].classList.remove( 'visible' );
  851. fragment = verticalFragments[ verticalFragments.length - 1 ];
  852. fragmentFound = true;
  853. }
  854. }
  855. // Horizontal slides:
  856. else {
  857. var horizontalFragments = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.present .fragment.visible' );
  858. if( horizontalFragments.length ) {
  859. horizontalFragments[ horizontalFragments.length - 1 ].classList.remove( 'visible' );
  860. fragment = horizontalFragments[ horizontalFragments.length - 1 ];
  861. fragmentFound = true;
  862. }
  863. }
  864. if ( fragmentFound ) {
  865. indexf--;
  866. // Notify subscribers of the change
  867. dispatchEvent( 'fragmenthidden', { fragment: fragment, index: indexf } );
  868. updateURL();
  869. } else {
  870. indexf = 0;
  871. }
  872. return fragmentFound;
  873. }
  874. /**
  875. * Cues a new automated slide if enabled in the config.
  876. */
  877. function cueAutoSlide() {
  878. clearTimeout( autoSlideTimeout );
  879. // Cue the next auto-slide if enabled
  880. if( autoSlide ) {
  881. autoSlideTimeout = setTimeout( navigateNext, autoSlide );
  882. }
  883. }
  884. function navigateLeft() {
  885. // Prioritize hiding fragments
  886. if( availableRoutes().left && ( isOverviewActive() || previousFragment() === false ) ) {
  887. slide( indexh - 1, 0, Number.MAX_VALUE );
  888. }
  889. }
  890. function navigateRight() {
  891. // Prioritize revealing fragments
  892. if( availableRoutes().right && ( isOverviewActive() || nextFragment() === false ) ) {
  893. slide( indexh + 1, 0 );
  894. }
  895. }
  896. function navigateUp() {
  897. // Prioritize hiding fragments
  898. if( availableRoutes().up && ( isOverviewActive() || previousFragment() === false ) ) {
  899. slide( indexh, indexv - 1 );
  900. }
  901. }
  902. function navigateDown() {
  903. // Prioritize revealing fragments
  904. if( availableRoutes().down && ( isOverviewActive() || nextFragment() === false ) ) {
  905. slide( indexh, indexv + 1 );
  906. }
  907. }
  908. /**
  909. * Navigates backwards, prioritized in the following order:
  910. * 1) Previous fragment
  911. * 2) Previous vertical slide
  912. * 3) Previous horizontal slide
  913. */
  914. function navigatePrev() {
  915. // Prioritize revealing fragments
  916. if( previousFragment() === false ) {
  917. if( availableRoutes().up ) {
  918. navigateUp();
  919. }
  920. else {
  921. // Fetch the previous horizontal slide, if there is one
  922. var previousSlide = document.querySelector( '.reveal .slides>section.past:nth-child(' + indexh + ')' );
  923. if( previousSlide ) {
  924. indexv = ( previousSlide.querySelectorAll( 'section' ).length + 1 ) || 0;
  925. indexh --;
  926. slide();
  927. }
  928. }
  929. }
  930. }
  931. /**
  932. * Same as #navigatePrev() but navigates forwards.
  933. */
  934. function navigateNext() {
  935. // Prioritize revealing fragments
  936. if( nextFragment() === false ) {
  937. availableRoutes().down ? navigateDown() : navigateRight();
  938. }
  939. // If auto-sliding is enabled we need to cue up
  940. // another timeout
  941. cueAutoSlide();
  942. }
  943. // --------------------------------------------------------------------//
  944. // ----------------------------- EVENTS -------------------------------//
  945. // --------------------------------------------------------------------//
  946. /**
  947. * Handler for the document level 'keydown' event.
  948. *
  949. * @param {Object} event
  950. */
  951. function onDocumentKeyDown( event ) {
  952. // Check if there's a focused element that could be using
  953. // the keyboard
  954. var activeElement = document.activeElement;
  955. var hasFocus = !!( document.activeElement && ( document.activeElement.type || document.activeElement.href || document.activeElement.contentEditable !== 'inherit' ) );
  956. // Disregard the event if there's a focused element or a
  957. // keyboard modifier key is present
  958. if ( hasFocus || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey ) return;
  959. var triggered = true;
  960. switch( event.keyCode ) {
  961. // p, page up
  962. case 80: case 33: navigatePrev(); break;
  963. // n, page down
  964. case 78: case 34: navigateNext(); break;
  965. // h, left
  966. case 72: case 37: navigateLeft(); break;
  967. // l, right
  968. case 76: case 39: navigateRight(); break;
  969. // k, up
  970. case 75: case 38: navigateUp(); break;
  971. // j, down
  972. case 74: case 40: navigateDown(); break;
  973. // home
  974. case 36: slide( 0 ); break;
  975. // end
  976. case 35: slide( Number.MAX_VALUE ); break;
  977. // space
  978. case 32: isOverviewActive() ? deactivateOverview() : navigateNext(); break;
  979. // return
  980. case 13: isOverviewActive() ? deactivateOverview() : triggered = false; break;
  981. // b, period
  982. case 66: case 190: togglePause(); break;
  983. // f
  984. case 70: enterFullscreen(); break;
  985. default:
  986. triggered = false;
  987. }
  988. // If the input resulted in a triggered action we should prevent
  989. // the browsers default behavior
  990. if( triggered ) {
  991. event.preventDefault();
  992. }
  993. else if ( event.keyCode === 27 && supports3DTransforms ) {
  994. toggleOverview();
  995. event.preventDefault();
  996. }
  997. // If auto-sliding is enabled we need to cue up
  998. // another timeout
  999. cueAutoSlide();
  1000. }
  1001. /**
  1002. * Handler for the document level 'touchstart' event,
  1003. * enables support for swipe and pinch gestures.
  1004. */
  1005. function onDocumentTouchStart( event ) {
  1006. touch.startX = event.touches[0].clientX;
  1007. touch.startY = event.touches[0].clientY;
  1008. touch.startCount = event.touches.length;
  1009. // If there's two touches we need to memorize the distance
  1010. // between those two points to detect pinching
  1011. if( event.touches.length === 2 && config.overview ) {
  1012. touch.startSpan = distanceBetween( {
  1013. x: event.touches[1].clientX,
  1014. y: event.touches[1].clientY
  1015. }, {
  1016. x: touch.startX,
  1017. y: touch.startY
  1018. } );
  1019. }
  1020. }
  1021. /**
  1022. * Handler for the document level 'touchmove' event.
  1023. */
  1024. function onDocumentTouchMove( event ) {
  1025. // Each touch should only trigger one action
  1026. if( !touch.handled ) {
  1027. var currentX = event.touches[0].clientX;
  1028. var currentY = event.touches[0].clientY;
  1029. // If the touch started off with two points and still has
  1030. // two active touches; test for the pinch gesture
  1031. if( event.touches.length === 2 && touch.startCount === 2 && config.overview ) {
  1032. // The current distance in pixels between the two touch points
  1033. var currentSpan = distanceBetween( {
  1034. x: event.touches[1].clientX,
  1035. y: event.touches[1].clientY
  1036. }, {
  1037. x: touch.startX,
  1038. y: touch.startY
  1039. } );
  1040. // If the span is larger than the desire amount we've got
  1041. // ourselves a pinch
  1042. if( Math.abs( touch.startSpan - currentSpan ) > touch.threshold ) {
  1043. touch.handled = true;
  1044. if( currentSpan < touch.startSpan ) {
  1045. activateOverview();
  1046. }
  1047. else {
  1048. deactivateOverview();
  1049. }
  1050. }
  1051. event.preventDefault();
  1052. }
  1053. // There was only one touch point, look for a swipe
  1054. else if( event.touches.length === 1 && touch.startCount !== 2 ) {
  1055. var deltaX = currentX - touch.startX,
  1056. deltaY = currentY - touch.startY;
  1057. if( deltaX > touch.threshold && Math.abs( deltaX ) > Math.abs( deltaY ) ) {
  1058. touch.handled = true;
  1059. navigateLeft();
  1060. }
  1061. else if( deltaX < -touch.threshold && Math.abs( deltaX ) > Math.abs( deltaY ) ) {
  1062. touch.handled = true;
  1063. navigateRight();
  1064. }
  1065. else if( deltaY > touch.threshold ) {
  1066. touch.handled = true;
  1067. navigateUp();
  1068. }
  1069. else if( deltaY < -touch.threshold ) {
  1070. touch.handled = true;
  1071. navigateDown();
  1072. }
  1073. event.preventDefault();
  1074. }
  1075. }
  1076. // There's a bug with swiping on some Android devices unless
  1077. // the default action is always prevented
  1078. else if( navigator.userAgent.match( /android/gi ) ) {
  1079. event.preventDefault();
  1080. }
  1081. }
  1082. /**
  1083. * Handler for the document level 'touchend' event.
  1084. */
  1085. function onDocumentTouchEnd( event ) {
  1086. touch.handled = false;
  1087. }
  1088. /**
  1089. * Handles mouse wheel scrolling, throttled to avoid skipping
  1090. * multiple slides.
  1091. */
  1092. function onDocumentMouseScroll( event ){
  1093. clearTimeout( mouseWheelTimeout );
  1094. mouseWheelTimeout = setTimeout( function() {
  1095. var delta = event.detail || -event.wheelDelta;
  1096. if( delta > 0 ) {
  1097. navigateNext();
  1098. }
  1099. else {
  1100. navigatePrev();
  1101. }
  1102. }, 100 );
  1103. }
  1104. /**
  1105. * Clicking on the progress bar results in a navigation to the
  1106. * closest approximate horizontal slide using this equation:
  1107. *
  1108. * ( clickX / presentationWidth ) * numberOfSlides
  1109. */
  1110. function onProgressClick( event ) {
  1111. var slidesTotal = Array.prototype.slice.call( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).length;
  1112. var slideIndex = Math.floor( ( event.clientX / dom.wrapper.offsetWidth ) * slidesTotal );
  1113. slide( slideIndex );
  1114. }
  1115. /**
  1116. * Handler for the window level 'hashchange' event.
  1117. *
  1118. * @param {Object} event
  1119. */
  1120. function onWindowHashChange( event ) {
  1121. readURL();
  1122. }
  1123. /**
  1124. * Invoked when a slide is and we're in the overview.
  1125. */
  1126. function onOverviewSlideClicked( event ) {
  1127. // TODO There's a bug here where the event listeners are not
  1128. // removed after deactivating the overview.
  1129. if( isOverviewActive() ) {
  1130. event.preventDefault();
  1131. deactivateOverview();
  1132. indexh = this.getAttribute( 'data-index-h' );
  1133. indexv = this.getAttribute( 'data-index-v' );
  1134. slide();
  1135. }
  1136. }
  1137. // --------------------------------------------------------------------//
  1138. // ------------------------------- API --------------------------------//
  1139. // --------------------------------------------------------------------//
  1140. return {
  1141. initialize: initialize,
  1142. // Navigation methods
  1143. slide: slide,
  1144. left: navigateLeft,
  1145. right: navigateRight,
  1146. up: navigateUp,
  1147. down: navigateDown,
  1148. prev: navigatePrev,
  1149. next: navigateNext,
  1150. prevFragment: previousFragment,
  1151. nextFragment: nextFragment,
  1152. // Deprecated aliases
  1153. navigateTo: slide,
  1154. navigateLeft: navigateLeft,
  1155. navigateRight: navigateRight,
  1156. navigateUp: navigateUp,
  1157. navigateDown: navigateDown,
  1158. navigatePrev: navigatePrev,
  1159. navigateNext: navigateNext,
  1160. // Toggles the overview mode on/off
  1161. toggleOverview: toggleOverview,
  1162. // Adds or removes all internal event listeners (such as keyboard)
  1163. addEventListeners: addEventListeners,
  1164. removeEventListeners: removeEventListeners,
  1165. // Returns the indices of the current, or specified, slide
  1166. getIndices: getIndices,
  1167. // Returns the previous slide element, may be null
  1168. getPreviousSlide: function() {
  1169. return previousSlide;
  1170. },
  1171. // Returns the current slide element
  1172. getCurrentSlide: function() {
  1173. return currentSlide;
  1174. },
  1175. // Helper method, retrieves query string as a key/value hash
  1176. getQueryHash: function() {
  1177. var query = {};
  1178. location.search.replace( /[A-Z0-9]+?=(\w*)/gi, function(a) {
  1179. query[ a.split( '=' ).shift() ] = a.split( '=' ).pop();
  1180. } );
  1181. return query;
  1182. },
  1183. // Forward event binding to the reveal DOM element
  1184. addEventListener: function( type, listener, useCapture ) {
  1185. if( 'addEventListener' in window ) {
  1186. ( dom.wrapper || document.querySelector( '.reveal' ) ).addEventListener( type, listener, useCapture );
  1187. }
  1188. },
  1189. removeEventListener: function( type, listener, useCapture ) {
  1190. if( 'addEventListener' in window ) {
  1191. ( dom.wrapper || document.querySelector( '.reveal' ) ).removeEventListener( type, listener, useCapture );
  1192. }
  1193. }
  1194. };
  1195. })();