reveal.js 39 KB

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