reveal.js 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441
  1. /*!
  2. * reveal.js 2.2 r39
  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. // If the current slide has an ID, use that as a named link
  771. if( currentSlide && typeof currentSlide.getAttribute( 'id' ) === 'string' ) {
  772. url = '/' + currentSlide.getAttribute( 'id' );
  773. }
  774. // Otherwise use the /h/v index
  775. else {
  776. if( indexh > 0 || indexv > 0 ) url += indexh;
  777. if( indexv > 0 ) url += '/' + indexv;
  778. }
  779. window.location.hash = url;
  780. }
  781. }
  782. /**
  783. * Retrieves the h/v location of the current, or specified,
  784. * slide.
  785. *
  786. * @param {HTMLElement} slide If specified, the returned
  787. * index will be for this slide rather than the currently
  788. * active one
  789. *
  790. * @return {Object} { h: <int>, v: <int> }
  791. */
  792. function getIndices( slide ) {
  793. // By default, return the current indices
  794. var h = indexh,
  795. v = indexv;
  796. // If a slide is specified, return the indices of that slide
  797. if( slide ) {
  798. var isVertical = !!slide.parentNode.nodeName.match( /section/gi );
  799. var slideh = isVertical ? slide.parentNode : slide;
  800. // Select all horizontal slides
  801. var horizontalSlides = Array.prototype.slice.call( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
  802. // Now that we know which the horizontal slide is, get its index
  803. h = Math.max( horizontalSlides.indexOf( slideh ), 0 );
  804. // If this is a vertical slide, grab the vertical index
  805. if( isVertical ) {
  806. v = Math.max( Array.prototype.slice.call( slide.parentNode.children ).indexOf( slide ), 0 );
  807. }
  808. }
  809. return { h: h, v: v };
  810. }
  811. /**
  812. * Navigate to the next slide fragment.
  813. *
  814. * @return {Boolean} true if there was a next fragment,
  815. * false otherwise
  816. */
  817. function nextFragment() {
  818. // Vertical slides:
  819. if( document.querySelector( VERTICAL_SLIDES_SELECTOR + '.present' ) ) {
  820. var verticalFragments = document.querySelectorAll( VERTICAL_SLIDES_SELECTOR + '.present .fragment:not(.visible)' );
  821. if( verticalFragments.length ) {
  822. verticalFragments[0].classList.add( 'visible' );
  823. // Notify subscribers of the change
  824. dispatchEvent( 'fragmentshown', { fragment: verticalFragments[0] } );
  825. return true;
  826. }
  827. }
  828. // Horizontal slides:
  829. else {
  830. var horizontalFragments = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.present .fragment:not(.visible)' );
  831. if( horizontalFragments.length ) {
  832. horizontalFragments[0].classList.add( 'visible' );
  833. // Notify subscribers of the change
  834. dispatchEvent( 'fragmentshown', { fragment: horizontalFragments[0] } );
  835. return true;
  836. }
  837. }
  838. return false;
  839. }
  840. /**
  841. * Navigate to the previous slide fragment.
  842. *
  843. * @return {Boolean} true if there was a previous fragment,
  844. * false otherwise
  845. */
  846. function previousFragment() {
  847. // Vertical slides:
  848. if( document.querySelector( VERTICAL_SLIDES_SELECTOR + '.present' ) ) {
  849. var verticalFragments = document.querySelectorAll( VERTICAL_SLIDES_SELECTOR + '.present .fragment.visible' );
  850. if( verticalFragments.length ) {
  851. verticalFragments[ verticalFragments.length - 1 ].classList.remove( 'visible' );
  852. // Notify subscribers of the change
  853. dispatchEvent( 'fragmenthidden', { fragment: verticalFragments[ verticalFragments.length - 1 ] } );
  854. return true;
  855. }
  856. }
  857. // Horizontal slides:
  858. else {
  859. var horizontalFragments = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.present .fragment.visible' );
  860. if( horizontalFragments.length ) {
  861. horizontalFragments[ horizontalFragments.length - 1 ].classList.remove( 'visible' );
  862. // Notify subscribers of the change
  863. dispatchEvent( 'fragmenthidden', { fragment: horizontalFragments[ horizontalFragments.length - 1 ] } );
  864. return true;
  865. }
  866. }
  867. return false;
  868. }
  869. /**
  870. * Cues a new automated slide if enabled in the config.
  871. */
  872. function cueAutoSlide() {
  873. clearTimeout( autoSlideTimeout );
  874. // Cue the next auto-slide if enabled
  875. if( autoSlide ) {
  876. autoSlideTimeout = setTimeout( navigateNext, autoSlide );
  877. }
  878. }
  879. function navigateLeft() {
  880. // Prioritize hiding fragments
  881. if( availableRoutes().left && ( isOverviewActive() || previousFragment() === false ) ) {
  882. slide( indexh - 1, 0 );
  883. }
  884. }
  885. function navigateRight() {
  886. // Prioritize revealing fragments
  887. if( availableRoutes().right && ( isOverviewActive() || nextFragment() === false ) ) {
  888. slide( indexh + 1, 0 );
  889. }
  890. }
  891. function navigateUp() {
  892. // Prioritize hiding fragments
  893. if( availableRoutes().up && ( isOverviewActive() || previousFragment() === false ) ) {
  894. slide( indexh, indexv - 1 );
  895. }
  896. }
  897. function navigateDown() {
  898. // Prioritize revealing fragments
  899. if( availableRoutes().down && ( isOverviewActive() || nextFragment() === false ) ) {
  900. slide( indexh, indexv + 1 );
  901. }
  902. }
  903. /**
  904. * Navigates backwards, prioritized in the following order:
  905. * 1) Previous fragment
  906. * 2) Previous vertical slide
  907. * 3) Previous horizontal slide
  908. */
  909. function navigatePrev() {
  910. // Prioritize revealing fragments
  911. if( previousFragment() === false ) {
  912. if( availableRoutes().up ) {
  913. navigateUp();
  914. }
  915. else {
  916. // Fetch the previous horizontal slide, if there is one
  917. var previousSlide = document.querySelector( '.reveal .slides>section.past:nth-child(' + indexh + ')' );
  918. if( previousSlide ) {
  919. indexv = ( previousSlide.querySelectorAll( 'section' ).length + 1 ) || 0;
  920. indexh --;
  921. slide();
  922. }
  923. }
  924. }
  925. }
  926. /**
  927. * Same as #navigatePrev() but navigates forwards.
  928. */
  929. function navigateNext() {
  930. // Prioritize revealing fragments
  931. if( nextFragment() === false ) {
  932. availableRoutes().down ? navigateDown() : navigateRight();
  933. }
  934. // If auto-sliding is enabled we need to cue up
  935. // another timeout
  936. cueAutoSlide();
  937. }
  938. // --------------------------------------------------------------------//
  939. // ----------------------------- EVENTS -------------------------------//
  940. // --------------------------------------------------------------------//
  941. /**
  942. * Handler for the document level 'keydown' event.
  943. *
  944. * @param {Object} event
  945. */
  946. function onDocumentKeyDown( event ) {
  947. // Check if there's a focused element that could be using
  948. // the keyboard
  949. var activeElement = document.activeElement;
  950. var hasFocus = !!( document.activeElement && ( document.activeElement.type || document.activeElement.href || document.activeElement.contentEditable !== 'inherit' ) );
  951. // Disregard the event if there's a focused element or a
  952. // keyboard modifier key is present
  953. if ( hasFocus || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey ) return;
  954. var triggered = true;
  955. switch( event.keyCode ) {
  956. // p, page up
  957. case 80: case 33: navigatePrev(); break;
  958. // n, page down
  959. case 78: case 34: navigateNext(); break;
  960. // h, left
  961. case 72: case 37: navigateLeft(); break;
  962. // l, right
  963. case 76: case 39: navigateRight(); break;
  964. // k, up
  965. case 75: case 38: navigateUp(); break;
  966. // j, down
  967. case 74: case 40: navigateDown(); break;
  968. // home
  969. case 36: slide( 0 ); break;
  970. // end
  971. case 35: slide( Number.MAX_VALUE ); break;
  972. // space
  973. case 32: isOverviewActive() ? deactivateOverview() : navigateNext(); break;
  974. // return
  975. case 13: isOverviewActive() ? deactivateOverview() : triggered = false; break;
  976. // b, period
  977. case 66: case 190: togglePause(); break;
  978. // f
  979. case 70: enterFullscreen(); break;
  980. default:
  981. triggered = false;
  982. }
  983. // If the input resulted in a triggered action we should prevent
  984. // the browsers default behavior
  985. if( triggered ) {
  986. event.preventDefault();
  987. }
  988. else if ( event.keyCode === 27 && supports3DTransforms ) {
  989. toggleOverview();
  990. event.preventDefault();
  991. }
  992. // If auto-sliding is enabled we need to cue up
  993. // another timeout
  994. cueAutoSlide();
  995. }
  996. /**
  997. * Handler for the document level 'touchstart' event,
  998. * enables support for swipe and pinch gestures.
  999. */
  1000. function onDocumentTouchStart( event ) {
  1001. touch.startX = event.touches[0].clientX;
  1002. touch.startY = event.touches[0].clientY;
  1003. touch.startCount = event.touches.length;
  1004. // If there's two touches we need to memorize the distance
  1005. // between those two points to detect pinching
  1006. if( event.touches.length === 2 && config.overview ) {
  1007. touch.startSpan = distanceBetween( {
  1008. x: event.touches[1].clientX,
  1009. y: event.touches[1].clientY
  1010. }, {
  1011. x: touch.startX,
  1012. y: touch.startY
  1013. } );
  1014. }
  1015. }
  1016. /**
  1017. * Handler for the document level 'touchmove' event.
  1018. */
  1019. function onDocumentTouchMove( event ) {
  1020. // Each touch should only trigger one action
  1021. if( !touch.handled ) {
  1022. var currentX = event.touches[0].clientX;
  1023. var currentY = event.touches[0].clientY;
  1024. // If the touch started off with two points and still has
  1025. // two active touches; test for the pinch gesture
  1026. if( event.touches.length === 2 && touch.startCount === 2 && config.overview ) {
  1027. // The current distance in pixels between the two touch points
  1028. var currentSpan = distanceBetween( {
  1029. x: event.touches[1].clientX,
  1030. y: event.touches[1].clientY
  1031. }, {
  1032. x: touch.startX,
  1033. y: touch.startY
  1034. } );
  1035. // If the span is larger than the desire amount we've got
  1036. // ourselves a pinch
  1037. if( Math.abs( touch.startSpan - currentSpan ) > touch.threshold ) {
  1038. touch.handled = true;
  1039. if( currentSpan < touch.startSpan ) {
  1040. activateOverview();
  1041. }
  1042. else {
  1043. deactivateOverview();
  1044. }
  1045. }
  1046. event.preventDefault();
  1047. }
  1048. // There was only one touch point, look for a swipe
  1049. else if( event.touches.length === 1 && touch.startCount !== 2 ) {
  1050. var deltaX = currentX - touch.startX,
  1051. deltaY = currentY - touch.startY;
  1052. if( deltaX > touch.threshold && Math.abs( deltaX ) > Math.abs( deltaY ) ) {
  1053. touch.handled = true;
  1054. navigateLeft();
  1055. }
  1056. else if( deltaX < -touch.threshold && Math.abs( deltaX ) > Math.abs( deltaY ) ) {
  1057. touch.handled = true;
  1058. navigateRight();
  1059. }
  1060. else if( deltaY > touch.threshold ) {
  1061. touch.handled = true;
  1062. navigateUp();
  1063. }
  1064. else if( deltaY < -touch.threshold ) {
  1065. touch.handled = true;
  1066. navigateDown();
  1067. }
  1068. event.preventDefault();
  1069. }
  1070. }
  1071. // There's a bug with swiping on some Android devices unless
  1072. // the default action is always prevented
  1073. else if( navigator.userAgent.match( /android/gi ) ) {
  1074. event.preventDefault();
  1075. }
  1076. }
  1077. /**
  1078. * Handler for the document level 'touchend' event.
  1079. */
  1080. function onDocumentTouchEnd( event ) {
  1081. touch.handled = false;
  1082. }
  1083. /**
  1084. * Handles mouse wheel scrolling, throttled to avoid skipping
  1085. * multiple slides.
  1086. */
  1087. function onDocumentMouseScroll( event ){
  1088. clearTimeout( mouseWheelTimeout );
  1089. mouseWheelTimeout = setTimeout( function() {
  1090. var delta = event.detail || -event.wheelDelta;
  1091. if( delta > 0 ) {
  1092. navigateNext();
  1093. }
  1094. else {
  1095. navigatePrev();
  1096. }
  1097. }, 100 );
  1098. }
  1099. /**
  1100. * Clicking on the progress bar results in a navigation to the
  1101. * closest approximate horizontal slide using this equation:
  1102. *
  1103. * ( clickX / presentationWidth ) * numberOfSlides
  1104. */
  1105. function onProgressClick( event ) {
  1106. var slidesTotal = Array.prototype.slice.call( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).length;
  1107. var slideIndex = Math.floor( ( event.clientX / dom.wrapper.offsetWidth ) * slidesTotal );
  1108. slide( slideIndex );
  1109. }
  1110. /**
  1111. * Handler for the window level 'hashchange' event.
  1112. */
  1113. function onWindowHashChange( event ) {
  1114. readURL();
  1115. }
  1116. /**
  1117. * Handler for the window level 'resize' event.
  1118. */
  1119. function onWindowResize( event ) {
  1120. layout();
  1121. }
  1122. /**
  1123. * Invoked when a slide is and we're in the overview.
  1124. */
  1125. function onOverviewSlideClicked( event ) {
  1126. // TODO There's a bug here where the event listeners are not
  1127. // removed after deactivating the overview.
  1128. if( isOverviewActive() ) {
  1129. event.preventDefault();
  1130. deactivateOverview();
  1131. indexh = this.getAttribute( 'data-index-h' );
  1132. indexv = this.getAttribute( 'data-index-v' );
  1133. slide();
  1134. }
  1135. }
  1136. // --------------------------------------------------------------------//
  1137. // ------------------------------- API --------------------------------//
  1138. // --------------------------------------------------------------------//
  1139. return {
  1140. initialize: initialize,
  1141. // Navigation methods
  1142. slide: slide,
  1143. left: navigateLeft,
  1144. right: navigateRight,
  1145. up: navigateUp,
  1146. down: navigateDown,
  1147. prev: navigatePrev,
  1148. next: navigateNext,
  1149. prevFragment: previousFragment,
  1150. nextFragment: nextFragment,
  1151. // Deprecated aliases
  1152. navigateTo: slide,
  1153. navigateLeft: navigateLeft,
  1154. navigateRight: navigateRight,
  1155. navigateUp: navigateUp,
  1156. navigateDown: navigateDown,
  1157. navigatePrev: navigatePrev,
  1158. navigateNext: navigateNext,
  1159. // Toggles the overview mode on/off
  1160. toggleOverview: toggleOverview,
  1161. // Adds or removes all internal event listeners (such as keyboard)
  1162. addEventListeners: addEventListeners,
  1163. removeEventListeners: removeEventListeners,
  1164. // Returns the indices of the current, or specified, slide
  1165. getIndices: getIndices,
  1166. // Returns the previous slide element, may be null
  1167. getPreviousSlide: function() {
  1168. return previousSlide;
  1169. },
  1170. // Returns the current slide element
  1171. getCurrentSlide: function() {
  1172. return currentSlide;
  1173. },
  1174. // Helper method, retrieves query string as a key/value hash
  1175. getQueryHash: function() {
  1176. var query = {};
  1177. location.search.replace( /[A-Z0-9]+?=(\w*)/gi, function(a) {
  1178. query[ a.split( '=' ).shift() ] = a.split( '=' ).pop();
  1179. } );
  1180. return query;
  1181. },
  1182. // Forward event binding to the reveal DOM element
  1183. addEventListener: function( type, listener, useCapture ) {
  1184. if( 'addEventListener' in window ) {
  1185. ( dom.wrapper || document.querySelector( '.reveal' ) ).addEventListener( type, listener, useCapture );
  1186. }
  1187. },
  1188. removeEventListener: function( type, listener, useCapture ) {
  1189. if( 'addEventListener' in window ) {
  1190. ( dom.wrapper || document.querySelector( '.reveal' ) ).removeEventListener( type, listener, useCapture );
  1191. }
  1192. }
  1193. };
  1194. })();