reveal.js 39 KB

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