Слайды на основе Reveal.js для презентации обучения детей в 2018-м году для конференции eKIDS в августе 2019-го
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

8099 satır
231KB

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  6. <style>
  7. /* reset.css */
  8. /* http://meyerweb.com/eric/tools/css/reset/
  9. v4.0 | 20180602
  10. License: none (public domain)
  11. */
  12. html, body, div, span, applet, object, iframe,
  13. h1, h2, h3, h4, h5, h6, p, blockquote, pre,
  14. a, abbr, acronym, address, big, cite, code,
  15. del, dfn, em, img, ins, kbd, q, s, samp,
  16. small, strike, strong, sub, sup, tt, var,
  17. b, u, i, center,
  18. dl, dt, dd, ol, ul, li,
  19. fieldset, form, label, legend,
  20. table, caption, tbody, tfoot, thead, tr, th, td,
  21. article, aside, canvas, details, embed,
  22. figure, figcaption, footer, header, hgroup,
  23. main, menu, nav, output, ruby, section, summary,
  24. time, mark, audio, video {
  25. margin: 0;
  26. padding: 0;
  27. border: 0;
  28. font-size: 100%;
  29. font: inherit;
  30. vertical-align: baseline;
  31. }
  32. /* HTML5 display-role reset for older browsers */
  33. article, aside, details, figcaption, figure,
  34. footer, header, hgroup, main, menu, nav, section {
  35. display: block;
  36. }
  37. /*!
  38. * reveal.js
  39. * http://revealjs.com
  40. * MIT licensed
  41. *
  42. * Copyright (C) 2019 Hakim El Hattab, http://hakim.se
  43. */
  44. /*********************************************
  45. * GLOBAL STYLES
  46. *********************************************/
  47. html {
  48. width: 100%;
  49. height: 100%;
  50. height: 100vh;
  51. height: calc( var(--vh, 1vh) * 100);
  52. overflow: hidden; }
  53. body {
  54. height: 100%;
  55. overflow: hidden;
  56. position: relative;
  57. line-height: 1;
  58. margin: 0;
  59. background-color: #fff;
  60. color: #000; }
  61. /*********************************************
  62. * VIEW FRAGMENTS
  63. *********************************************/
  64. .reveal .slides section .fragment {
  65. opacity: 0;
  66. visibility: hidden;
  67. transition: all .2s ease; }
  68. .reveal .slides section .fragment.visible {
  69. opacity: 1;
  70. visibility: inherit; }
  71. .reveal .slides section .fragment.grow {
  72. opacity: 1;
  73. visibility: inherit; }
  74. .reveal .slides section .fragment.grow.visible {
  75. -webkit-transform: scale(1.3);
  76. transform: scale(1.3); }
  77. .reveal .slides section .fragment.shrink {
  78. opacity: 1;
  79. visibility: inherit; }
  80. .reveal .slides section .fragment.shrink.visible {
  81. -webkit-transform: scale(0.7);
  82. transform: scale(0.7); }
  83. .reveal .slides section .fragment.zoom-in {
  84. -webkit-transform: scale(0.1);
  85. transform: scale(0.1); }
  86. .reveal .slides section .fragment.zoom-in.visible {
  87. -webkit-transform: none;
  88. transform: none; }
  89. .reveal .slides section .fragment.fade-out {
  90. opacity: 1;
  91. visibility: inherit; }
  92. .reveal .slides section .fragment.fade-out.visible {
  93. opacity: 0;
  94. visibility: hidden; }
  95. .reveal .slides section .fragment.semi-fade-out {
  96. opacity: 1;
  97. visibility: inherit; }
  98. .reveal .slides section .fragment.semi-fade-out.visible {
  99. opacity: 0.5;
  100. visibility: inherit; }
  101. .reveal .slides section .fragment.strike {
  102. opacity: 1;
  103. visibility: inherit; }
  104. .reveal .slides section .fragment.strike.visible {
  105. text-decoration: line-through; }
  106. .reveal .slides section .fragment.fade-up {
  107. -webkit-transform: translate(0, 20%);
  108. transform: translate(0, 20%); }
  109. .reveal .slides section .fragment.fade-up.visible {
  110. -webkit-transform: translate(0, 0);
  111. transform: translate(0, 0); }
  112. .reveal .slides section .fragment.fade-down {
  113. -webkit-transform: translate(0, -20%);
  114. transform: translate(0, -20%); }
  115. .reveal .slides section .fragment.fade-down.visible {
  116. -webkit-transform: translate(0, 0);
  117. transform: translate(0, 0); }
  118. .reveal .slides section .fragment.fade-right {
  119. -webkit-transform: translate(-20%, 0);
  120. transform: translate(-20%, 0); }
  121. .reveal .slides section .fragment.fade-right.visible {
  122. -webkit-transform: translate(0, 0);
  123. transform: translate(0, 0); }
  124. .reveal .slides section .fragment.fade-left {
  125. -webkit-transform: translate(20%, 0);
  126. transform: translate(20%, 0); }
  127. .reveal .slides section .fragment.fade-left.visible {
  128. -webkit-transform: translate(0, 0);
  129. transform: translate(0, 0); }
  130. .reveal .slides section .fragment.fade-in-then-out,
  131. .reveal .slides section .fragment.current-visible {
  132. opacity: 0;
  133. visibility: hidden; }
  134. .reveal .slides section .fragment.fade-in-then-out.current-fragment,
  135. .reveal .slides section .fragment.current-visible.current-fragment {
  136. opacity: 1;
  137. visibility: inherit; }
  138. .reveal .slides section .fragment.fade-in-then-semi-out {
  139. opacity: 0;
  140. visibility: hidden; }
  141. .reveal .slides section .fragment.fade-in-then-semi-out.visible {
  142. opacity: 0.5;
  143. visibility: inherit; }
  144. .reveal .slides section .fragment.fade-in-then-semi-out.current-fragment {
  145. opacity: 1;
  146. visibility: inherit; }
  147. .reveal .slides section .fragment.highlight-red,
  148. .reveal .slides section .fragment.highlight-current-red,
  149. .reveal .slides section .fragment.highlight-green,
  150. .reveal .slides section .fragment.highlight-current-green,
  151. .reveal .slides section .fragment.highlight-blue,
  152. .reveal .slides section .fragment.highlight-current-blue {
  153. opacity: 1;
  154. visibility: inherit; }
  155. .reveal .slides section .fragment.highlight-red.visible {
  156. color: #ff2c2d; }
  157. .reveal .slides section .fragment.highlight-green.visible {
  158. color: #17ff2e; }
  159. .reveal .slides section .fragment.highlight-blue.visible {
  160. color: #1b91ff; }
  161. .reveal .slides section .fragment.highlight-current-red.current-fragment {
  162. color: #ff2c2d; }
  163. .reveal .slides section .fragment.highlight-current-green.current-fragment {
  164. color: #17ff2e; }
  165. .reveal .slides section .fragment.highlight-current-blue.current-fragment {
  166. color: #1b91ff; }
  167. /*********************************************
  168. * DEFAULT ELEMENT STYLES
  169. *********************************************/
  170. /* Fixes issue in Chrome where italic fonts did not appear when printing to PDF */
  171. .reveal:after {
  172. content: '';
  173. font-style: italic; }
  174. .reveal iframe {
  175. z-index: 1; }
  176. /** Prevents layering issues in certain browser/transition combinations */
  177. .reveal a {
  178. position: relative; }
  179. .reveal .stretch {
  180. max-width: none;
  181. max-height: none; }
  182. .reveal pre.stretch code {
  183. height: 100%;
  184. max-height: 100%;
  185. box-sizing: border-box; }
  186. /*********************************************
  187. * CONTROLS
  188. *********************************************/
  189. @-webkit-keyframes bounce-right {
  190. 0%, 10%, 25%, 40%, 50% {
  191. -webkit-transform: translateX(0);
  192. transform: translateX(0); }
  193. 20% {
  194. -webkit-transform: translateX(10px);
  195. transform: translateX(10px); }
  196. 30% {
  197. -webkit-transform: translateX(-5px);
  198. transform: translateX(-5px); } }
  199. @keyframes bounce-right {
  200. 0%, 10%, 25%, 40%, 50% {
  201. -webkit-transform: translateX(0);
  202. transform: translateX(0); }
  203. 20% {
  204. -webkit-transform: translateX(10px);
  205. transform: translateX(10px); }
  206. 30% {
  207. -webkit-transform: translateX(-5px);
  208. transform: translateX(-5px); } }
  209. @-webkit-keyframes bounce-down {
  210. 0%, 10%, 25%, 40%, 50% {
  211. -webkit-transform: translateY(0);
  212. transform: translateY(0); }
  213. 20% {
  214. -webkit-transform: translateY(10px);
  215. transform: translateY(10px); }
  216. 30% {
  217. -webkit-transform: translateY(-5px);
  218. transform: translateY(-5px); } }
  219. @keyframes bounce-down {
  220. 0%, 10%, 25%, 40%, 50% {
  221. -webkit-transform: translateY(0);
  222. transform: translateY(0); }
  223. 20% {
  224. -webkit-transform: translateY(10px);
  225. transform: translateY(10px); }
  226. 30% {
  227. -webkit-transform: translateY(-5px);
  228. transform: translateY(-5px); } }
  229. .reveal .controls {
  230. display: none;
  231. position: absolute;
  232. top: auto;
  233. bottom: 12px;
  234. right: 12px;
  235. left: auto;
  236. z-index: 1;
  237. color: #000;
  238. pointer-events: none;
  239. font-size: 10px; }
  240. .reveal .controls button {
  241. position: absolute;
  242. padding: 0;
  243. background-color: transparent;
  244. border: 0;
  245. outline: 0;
  246. cursor: pointer;
  247. color: currentColor;
  248. -webkit-transform: scale(0.9999);
  249. transform: scale(0.9999);
  250. transition: color 0.2s ease, opacity 0.2s ease, -webkit-transform 0.2s ease;
  251. transition: color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
  252. z-index: 2;
  253. pointer-events: auto;
  254. font-size: inherit;
  255. visibility: hidden;
  256. opacity: 0;
  257. -webkit-appearance: none;
  258. -webkit-tap-highlight-color: rgba(0, 0, 0, 0); }
  259. .reveal .controls .controls-arrow:before,
  260. .reveal .controls .controls-arrow:after {
  261. content: '';
  262. position: absolute;
  263. top: 0;
  264. left: 0;
  265. width: 2.6em;
  266. height: 0.5em;
  267. border-radius: 0.25em;
  268. background-color: currentColor;
  269. transition: all 0.15s ease, background-color 0.8s ease;
  270. -webkit-transform-origin: 0.2em 50%;
  271. transform-origin: 0.2em 50%;
  272. will-change: transform; }
  273. .reveal .controls .controls-arrow {
  274. position: relative;
  275. width: 3.6em;
  276. height: 3.6em; }
  277. .reveal .controls .controls-arrow:before {
  278. -webkit-transform: translateX(0.5em) translateY(1.55em) rotate(45deg);
  279. transform: translateX(0.5em) translateY(1.55em) rotate(45deg); }
  280. .reveal .controls .controls-arrow:after {
  281. -webkit-transform: translateX(0.5em) translateY(1.55em) rotate(-45deg);
  282. transform: translateX(0.5em) translateY(1.55em) rotate(-45deg); }
  283. .reveal .controls .controls-arrow:hover:before {
  284. -webkit-transform: translateX(0.5em) translateY(1.55em) rotate(40deg);
  285. transform: translateX(0.5em) translateY(1.55em) rotate(40deg); }
  286. .reveal .controls .controls-arrow:hover:after {
  287. -webkit-transform: translateX(0.5em) translateY(1.55em) rotate(-40deg);
  288. transform: translateX(0.5em) translateY(1.55em) rotate(-40deg); }
  289. .reveal .controls .controls-arrow:active:before {
  290. -webkit-transform: translateX(0.5em) translateY(1.55em) rotate(36deg);
  291. transform: translateX(0.5em) translateY(1.55em) rotate(36deg); }
  292. .reveal .controls .controls-arrow:active:after {
  293. -webkit-transform: translateX(0.5em) translateY(1.55em) rotate(-36deg);
  294. transform: translateX(0.5em) translateY(1.55em) rotate(-36deg); }
  295. .reveal .controls .navigate-left {
  296. right: 6.4em;
  297. bottom: 3.2em;
  298. -webkit-transform: translateX(-10px);
  299. transform: translateX(-10px); }
  300. .reveal .controls .navigate-right {
  301. right: 0;
  302. bottom: 3.2em;
  303. -webkit-transform: translateX(10px);
  304. transform: translateX(10px); }
  305. .reveal .controls .navigate-right .controls-arrow {
  306. -webkit-transform: rotate(180deg);
  307. transform: rotate(180deg); }
  308. .reveal .controls .navigate-right.highlight {
  309. -webkit-animation: bounce-right 2s 50 both ease-out;
  310. animation: bounce-right 2s 50 both ease-out; }
  311. .reveal .controls .navigate-up {
  312. right: 3.2em;
  313. bottom: 6.4em;
  314. -webkit-transform: translateY(-10px);
  315. transform: translateY(-10px); }
  316. .reveal .controls .navigate-up .controls-arrow {
  317. -webkit-transform: rotate(90deg);
  318. transform: rotate(90deg); }
  319. .reveal .controls .navigate-down {
  320. right: 3.2em;
  321. bottom: 0;
  322. -webkit-transform: translateY(10px);
  323. transform: translateY(10px); }
  324. .reveal .controls .navigate-down .controls-arrow {
  325. -webkit-transform: rotate(-90deg);
  326. transform: rotate(-90deg); }
  327. .reveal .controls .navigate-down.highlight {
  328. -webkit-animation: bounce-down 2s 50 both ease-out;
  329. animation: bounce-down 2s 50 both ease-out; }
  330. .reveal .controls[data-controls-back-arrows="faded"] .navigate-left.enabled,
  331. .reveal .controls[data-controls-back-arrows="faded"] .navigate-up.enabled {
  332. opacity: 0.3; }
  333. .reveal .controls[data-controls-back-arrows="faded"] .navigate-left.enabled:hover,
  334. .reveal .controls[data-controls-back-arrows="faded"] .navigate-up.enabled:hover {
  335. opacity: 1; }
  336. .reveal .controls[data-controls-back-arrows="hidden"] .navigate-left.enabled,
  337. .reveal .controls[data-controls-back-arrows="hidden"] .navigate-up.enabled {
  338. opacity: 0;
  339. visibility: hidden; }
  340. .reveal .controls .enabled {
  341. visibility: visible;
  342. opacity: 0.9;
  343. cursor: pointer;
  344. -webkit-transform: none;
  345. transform: none; }
  346. .reveal .controls .enabled.fragmented {
  347. opacity: 0.5; }
  348. .reveal .controls .enabled:hover,
  349. .reveal .controls .enabled.fragmented:hover {
  350. opacity: 1; }
  351. .reveal[data-navigation-mode="linear"].has-horizontal-slides .navigate-up,
  352. .reveal[data-navigation-mode="linear"].has-horizontal-slides .navigate-down {
  353. display: none; }
  354. .reveal[data-navigation-mode="linear"].has-horizontal-slides .navigate-left,
  355. .reveal:not(.has-vertical-slides) .controls .navigate-left {
  356. bottom: 1.4em;
  357. right: 5.5em; }
  358. .reveal[data-navigation-mode="linear"].has-horizontal-slides .navigate-right,
  359. .reveal:not(.has-vertical-slides) .controls .navigate-right {
  360. bottom: 1.4em;
  361. right: 0.5em; }
  362. .reveal:not(.has-horizontal-slides) .controls .navigate-up {
  363. right: 1.4em;
  364. bottom: 5em; }
  365. .reveal:not(.has-horizontal-slides) .controls .navigate-down {
  366. right: 1.4em;
  367. bottom: 0.5em; }
  368. .reveal.has-dark-background .controls {
  369. color: #fff; }
  370. .reveal.has-light-background .controls {
  371. color: #000; }
  372. .reveal.no-hover .controls .controls-arrow:hover:before,
  373. .reveal.no-hover .controls .controls-arrow:active:before {
  374. -webkit-transform: translateX(0.5em) translateY(1.55em) rotate(45deg);
  375. transform: translateX(0.5em) translateY(1.55em) rotate(45deg); }
  376. .reveal.no-hover .controls .controls-arrow:hover:after,
  377. .reveal.no-hover .controls .controls-arrow:active:after {
  378. -webkit-transform: translateX(0.5em) translateY(1.55em) rotate(-45deg);
  379. transform: translateX(0.5em) translateY(1.55em) rotate(-45deg); }
  380. @media screen and (min-width: 500px) {
  381. .reveal .controls[data-controls-layout="edges"] {
  382. top: 0;
  383. right: 0;
  384. bottom: 0;
  385. left: 0; }
  386. .reveal .controls[data-controls-layout="edges"] .navigate-left,
  387. .reveal .controls[data-controls-layout="edges"] .navigate-right,
  388. .reveal .controls[data-controls-layout="edges"] .navigate-up,
  389. .reveal .controls[data-controls-layout="edges"] .navigate-down {
  390. bottom: auto;
  391. right: auto; }
  392. .reveal .controls[data-controls-layout="edges"] .navigate-left {
  393. top: 50%;
  394. left: 8px;
  395. margin-top: -1.8em; }
  396. .reveal .controls[data-controls-layout="edges"] .navigate-right {
  397. top: 50%;
  398. right: 8px;
  399. margin-top: -1.8em; }
  400. .reveal .controls[data-controls-layout="edges"] .navigate-up {
  401. top: 8px;
  402. left: 50%;
  403. margin-left: -1.8em; }
  404. .reveal .controls[data-controls-layout="edges"] .navigate-down {
  405. bottom: 8px;
  406. left: 50%;
  407. margin-left: -1.8em; } }
  408. /*********************************************
  409. * PROGRESS BAR
  410. *********************************************/
  411. .reveal .progress {
  412. position: absolute;
  413. display: none;
  414. height: 3px;
  415. width: 100%;
  416. bottom: 0;
  417. left: 0;
  418. z-index: 10;
  419. background-color: rgba(0, 0, 0, 0.2);
  420. color: #fff; }
  421. .reveal .progress:after {
  422. content: '';
  423. display: block;
  424. position: absolute;
  425. height: 10px;
  426. width: 100%;
  427. top: -10px; }
  428. .reveal .progress span {
  429. display: block;
  430. height: 100%;
  431. width: 0px;
  432. background-color: currentColor;
  433. transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
  434. /*********************************************
  435. * SLIDE NUMBER
  436. *********************************************/
  437. .reveal .slide-number {
  438. position: absolute;
  439. display: block;
  440. right: 8px;
  441. bottom: 8px;
  442. z-index: 31;
  443. font-family: Helvetica, sans-serif;
  444. font-size: 12px;
  445. line-height: 1;
  446. color: #fff;
  447. background-color: rgba(0, 0, 0, 0.4);
  448. padding: 5px; }
  449. .reveal .slide-number a {
  450. color: currentColor; }
  451. .reveal .slide-number-delimiter {
  452. margin: 0 3px; }
  453. /*********************************************
  454. * SLIDES
  455. *********************************************/
  456. .reveal {
  457. position: relative;
  458. width: 100%;
  459. height: 100%;
  460. overflow: hidden;
  461. -ms-touch-action: pinch-zoom;
  462. touch-action: pinch-zoom; }
  463. .reveal .slides {
  464. position: absolute;
  465. width: 100%;
  466. height: 100%;
  467. top: 0;
  468. right: 0;
  469. bottom: 0;
  470. left: 0;
  471. margin: auto;
  472. pointer-events: none;
  473. overflow: visible;
  474. z-index: 1;
  475. text-align: center;
  476. -webkit-perspective: 600px;
  477. perspective: 600px;
  478. -webkit-perspective-origin: 50% 40%;
  479. perspective-origin: 50% 40%; }
  480. .reveal .slides > section {
  481. -webkit-perspective: 600px;
  482. perspective: 600px; }
  483. .reveal .slides > section,
  484. .reveal .slides > section > section {
  485. display: none;
  486. position: absolute;
  487. width: 100%;
  488. padding: 20px 0px;
  489. pointer-events: auto;
  490. z-index: 10;
  491. -webkit-transform-style: flat;
  492. transform-style: flat;
  493. transition: -webkit-transform-origin 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), -webkit-transform 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), visibility 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), opacity 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
  494. transition: transform-origin 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), transform 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), visibility 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), opacity 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
  495. /* Global transition speed settings */
  496. .reveal[data-transition-speed="fast"] .slides section {
  497. transition-duration: 400ms; }
  498. .reveal[data-transition-speed="slow"] .slides section {
  499. transition-duration: 1200ms; }
  500. /* Slide-specific transition speed overrides */
  501. .reveal .slides section[data-transition-speed="fast"] {
  502. transition-duration: 400ms; }
  503. .reveal .slides section[data-transition-speed="slow"] {
  504. transition-duration: 1200ms; }
  505. .reveal .slides > section.stack {
  506. padding-top: 0;
  507. padding-bottom: 0;
  508. pointer-events: none;
  509. height: 100%; }
  510. .reveal .slides > section.present,
  511. .reveal .slides > section > section.present {
  512. display: block;
  513. z-index: 11;
  514. opacity: 1; }
  515. .reveal .slides > section:empty,
  516. .reveal .slides > section > section:empty,
  517. .reveal .slides > section[data-background-interactive],
  518. .reveal .slides > section > section[data-background-interactive] {
  519. pointer-events: none; }
  520. .reveal.center,
  521. .reveal.center .slides,
  522. .reveal.center .slides section {
  523. min-height: 0 !important; }
  524. /* Don't allow interaction with invisible slides */
  525. .reveal .slides > section.future,
  526. .reveal .slides > section > section.future,
  527. .reveal .slides > section.past,
  528. .reveal .slides > section > section.past {
  529. pointer-events: none; }
  530. .reveal.overview .slides > section,
  531. .reveal.overview .slides > section > section {
  532. pointer-events: auto; }
  533. .reveal .slides > section.past,
  534. .reveal .slides > section.future,
  535. .reveal .slides > section > section.past,
  536. .reveal .slides > section > section.future {
  537. opacity: 0; }
  538. /*********************************************
  539. * Mixins for readability of transitions
  540. *********************************************/
  541. /*********************************************
  542. * SLIDE TRANSITION
  543. * Aliased 'linear' for backwards compatibility
  544. *********************************************/
  545. .reveal.slide section {
  546. -webkit-backface-visibility: hidden;
  547. backface-visibility: hidden; }
  548. .reveal .slides > section[data-transition=slide].past,
  549. .reveal .slides > section[data-transition~=slide-out].past,
  550. .reveal.slide .slides > section:not([data-transition]).past {
  551. -webkit-transform: translate(-150%, 0);
  552. transform: translate(-150%, 0); }
  553. .reveal .slides > section[data-transition=slide].future,
  554. .reveal .slides > section[data-transition~=slide-in].future,
  555. .reveal.slide .slides > section:not([data-transition]).future {
  556. -webkit-transform: translate(150%, 0);
  557. transform: translate(150%, 0); }
  558. .reveal .slides > section > section[data-transition=slide].past,
  559. .reveal .slides > section > section[data-transition~=slide-out].past,
  560. .reveal.slide .slides > section > section:not([data-transition]).past {
  561. -webkit-transform: translate(0, -150%);
  562. transform: translate(0, -150%); }
  563. .reveal .slides > section > section[data-transition=slide].future,
  564. .reveal .slides > section > section[data-transition~=slide-in].future,
  565. .reveal.slide .slides > section > section:not([data-transition]).future {
  566. -webkit-transform: translate(0, 150%);
  567. transform: translate(0, 150%); }
  568. .reveal.linear section {
  569. -webkit-backface-visibility: hidden;
  570. backface-visibility: hidden; }
  571. .reveal .slides > section[data-transition=linear].past,
  572. .reveal .slides > section[data-transition~=linear-out].past,
  573. .reveal.linear .slides > section:not([data-transition]).past {
  574. -webkit-transform: translate(-150%, 0);
  575. transform: translate(-150%, 0); }
  576. .reveal .slides > section[data-transition=linear].future,
  577. .reveal .slides > section[data-transition~=linear-in].future,
  578. .reveal.linear .slides > section:not([data-transition]).future {
  579. -webkit-transform: translate(150%, 0);
  580. transform: translate(150%, 0); }
  581. .reveal .slides > section > section[data-transition=linear].past,
  582. .reveal .slides > section > section[data-transition~=linear-out].past,
  583. .reveal.linear .slides > section > section:not([data-transition]).past {
  584. -webkit-transform: translate(0, -150%);
  585. transform: translate(0, -150%); }
  586. .reveal .slides > section > section[data-transition=linear].future,
  587. .reveal .slides > section > section[data-transition~=linear-in].future,
  588. .reveal.linear .slides > section > section:not([data-transition]).future {
  589. -webkit-transform: translate(0, 150%);
  590. transform: translate(0, 150%); }
  591. /*********************************************
  592. * CONVEX TRANSITION
  593. * Aliased 'default' for backwards compatibility
  594. *********************************************/
  595. .reveal .slides section[data-transition=default].stack,
  596. .reveal.default .slides section.stack {
  597. -webkit-transform-style: preserve-3d;
  598. transform-style: preserve-3d; }
  599. .reveal .slides > section[data-transition=default].past,
  600. .reveal .slides > section[data-transition~=default-out].past,
  601. .reveal.default .slides > section:not([data-transition]).past {
  602. -webkit-transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0);
  603. transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0); }
  604. .reveal .slides > section[data-transition=default].future,
  605. .reveal .slides > section[data-transition~=default-in].future,
  606. .reveal.default .slides > section:not([data-transition]).future {
  607. -webkit-transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0);
  608. transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0); }
  609. .reveal .slides > section > section[data-transition=default].past,
  610. .reveal .slides > section > section[data-transition~=default-out].past,
  611. .reveal.default .slides > section > section:not([data-transition]).past {
  612. -webkit-transform: translate3d(0, -300px, 0) rotateX(70deg) translate3d(0, -300px, 0);
  613. transform: translate3d(0, -300px, 0) rotateX(70deg) translate3d(0, -300px, 0); }
  614. .reveal .slides > section > section[data-transition=default].future,
  615. .reveal .slides > section > section[data-transition~=default-in].future,
  616. .reveal.default .slides > section > section:not([data-transition]).future {
  617. -webkit-transform: translate3d(0, 300px, 0) rotateX(-70deg) translate3d(0, 300px, 0);
  618. transform: translate3d(0, 300px, 0) rotateX(-70deg) translate3d(0, 300px, 0); }
  619. .reveal .slides section[data-transition=convex].stack,
  620. .reveal.convex .slides section.stack {
  621. -webkit-transform-style: preserve-3d;
  622. transform-style: preserve-3d; }
  623. .reveal .slides > section[data-transition=convex].past,
  624. .reveal .slides > section[data-transition~=convex-out].past,
  625. .reveal.convex .slides > section:not([data-transition]).past {
  626. -webkit-transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0);
  627. transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0); }
  628. .reveal .slides > section[data-transition=convex].future,
  629. .reveal .slides > section[data-transition~=convex-in].future,
  630. .reveal.convex .slides > section:not([data-transition]).future {
  631. -webkit-transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0);
  632. transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0); }
  633. .reveal .slides > section > section[data-transition=convex].past,
  634. .reveal .slides > section > section[data-transition~=convex-out].past,
  635. .reveal.convex .slides > section > section:not([data-transition]).past {
  636. -webkit-transform: translate3d(0, -300px, 0) rotateX(70deg) translate3d(0, -300px, 0);
  637. transform: translate3d(0, -300px, 0) rotateX(70deg) translate3d(0, -300px, 0); }
  638. .reveal .slides > section > section[data-transition=convex].future,
  639. .reveal .slides > section > section[data-transition~=convex-in].future,
  640. .reveal.convex .slides > section > section:not([data-transition]).future {
  641. -webkit-transform: translate3d(0, 300px, 0) rotateX(-70deg) translate3d(0, 300px, 0);
  642. transform: translate3d(0, 300px, 0) rotateX(-70deg) translate3d(0, 300px, 0); }
  643. /*********************************************
  644. * CONCAVE TRANSITION
  645. *********************************************/
  646. .reveal .slides section[data-transition=concave].stack,
  647. .reveal.concave .slides section.stack {
  648. -webkit-transform-style: preserve-3d;
  649. transform-style: preserve-3d; }
  650. .reveal .slides > section[data-transition=concave].past,
  651. .reveal .slides > section[data-transition~=concave-out].past,
  652. .reveal.concave .slides > section:not([data-transition]).past {
  653. -webkit-transform: translate3d(-100%, 0, 0) rotateY(90deg) translate3d(-100%, 0, 0);
  654. transform: translate3d(-100%, 0, 0) rotateY(90deg) translate3d(-100%, 0, 0); }
  655. .reveal .slides > section[data-transition=concave].future,
  656. .reveal .slides > section[data-transition~=concave-in].future,
  657. .reveal.concave .slides > section:not([data-transition]).future {
  658. -webkit-transform: translate3d(100%, 0, 0) rotateY(-90deg) translate3d(100%, 0, 0);
  659. transform: translate3d(100%, 0, 0) rotateY(-90deg) translate3d(100%, 0, 0); }
  660. .reveal .slides > section > section[data-transition=concave].past,
  661. .reveal .slides > section > section[data-transition~=concave-out].past,
  662. .reveal.concave .slides > section > section:not([data-transition]).past {
  663. -webkit-transform: translate3d(0, -80%, 0) rotateX(-70deg) translate3d(0, -80%, 0);
  664. transform: translate3d(0, -80%, 0) rotateX(-70deg) translate3d(0, -80%, 0); }
  665. .reveal .slides > section > section[data-transition=concave].future,
  666. .reveal .slides > section > section[data-transition~=concave-in].future,
  667. .reveal.concave .slides > section > section:not([data-transition]).future {
  668. -webkit-transform: translate3d(0, 80%, 0) rotateX(70deg) translate3d(0, 80%, 0);
  669. transform: translate3d(0, 80%, 0) rotateX(70deg) translate3d(0, 80%, 0); }
  670. /*********************************************
  671. * ZOOM TRANSITION
  672. *********************************************/
  673. .reveal .slides section[data-transition=zoom],
  674. .reveal.zoom .slides section:not([data-transition]) {
  675. transition-timing-function: ease; }
  676. .reveal .slides > section[data-transition=zoom].past,
  677. .reveal .slides > section[data-transition~=zoom-out].past,
  678. .reveal.zoom .slides > section:not([data-transition]).past {
  679. visibility: hidden;
  680. -webkit-transform: scale(16);
  681. transform: scale(16); }
  682. .reveal .slides > section[data-transition=zoom].future,
  683. .reveal .slides > section[data-transition~=zoom-in].future,
  684. .reveal.zoom .slides > section:not([data-transition]).future {
  685. visibility: hidden;
  686. -webkit-transform: scale(0.2);
  687. transform: scale(0.2); }
  688. .reveal .slides > section > section[data-transition=zoom].past,
  689. .reveal .slides > section > section[data-transition~=zoom-out].past,
  690. .reveal.zoom .slides > section > section:not([data-transition]).past {
  691. -webkit-transform: scale(16);
  692. transform: scale(16); }
  693. .reveal .slides > section > section[data-transition=zoom].future,
  694. .reveal .slides > section > section[data-transition~=zoom-in].future,
  695. .reveal.zoom .slides > section > section:not([data-transition]).future {
  696. -webkit-transform: scale(0.2);
  697. transform: scale(0.2); }
  698. /*********************************************
  699. * CUBE TRANSITION
  700. *
  701. * WARNING:
  702. * this is deprecated and will be removed in a
  703. * future version.
  704. *********************************************/
  705. .reveal.cube .slides {
  706. -webkit-perspective: 1300px;
  707. perspective: 1300px; }
  708. .reveal.cube .slides section {
  709. padding: 30px;
  710. min-height: 700px;
  711. -webkit-backface-visibility: hidden;
  712. backface-visibility: hidden;
  713. box-sizing: border-box;
  714. -webkit-transform-style: preserve-3d;
  715. transform-style: preserve-3d; }
  716. .reveal.center.cube .slides section {
  717. min-height: 0; }
  718. .reveal.cube .slides section:not(.stack):before {
  719. content: '';
  720. position: absolute;
  721. display: block;
  722. width: 100%;
  723. height: 100%;
  724. left: 0;
  725. top: 0;
  726. background: rgba(0, 0, 0, 0.1);
  727. border-radius: 4px;
  728. -webkit-transform: translateZ(-20px);
  729. transform: translateZ(-20px); }
  730. .reveal.cube .slides section:not(.stack):after {
  731. content: '';
  732. position: absolute;
  733. display: block;
  734. width: 90%;
  735. height: 30px;
  736. left: 5%;
  737. bottom: 0;
  738. background: none;
  739. z-index: 1;
  740. border-radius: 4px;
  741. box-shadow: 0px 95px 25px rgba(0, 0, 0, 0.2);
  742. -webkit-transform: translateZ(-90px) rotateX(65deg);
  743. transform: translateZ(-90px) rotateX(65deg); }
  744. .reveal.cube .slides > section.stack {
  745. padding: 0;
  746. background: none; }
  747. .reveal.cube .slides > section.past {
  748. -webkit-transform-origin: 100% 0%;
  749. transform-origin: 100% 0%;
  750. -webkit-transform: translate3d(-100%, 0, 0) rotateY(-90deg);
  751. transform: translate3d(-100%, 0, 0) rotateY(-90deg); }
  752. .reveal.cube .slides > section.future {
  753. -webkit-transform-origin: 0% 0%;
  754. transform-origin: 0% 0%;
  755. -webkit-transform: translate3d(100%, 0, 0) rotateY(90deg);
  756. transform: translate3d(100%, 0, 0) rotateY(90deg); }
  757. .reveal.cube .slides > section > section.past {
  758. -webkit-transform-origin: 0% 100%;
  759. transform-origin: 0% 100%;
  760. -webkit-transform: translate3d(0, -100%, 0) rotateX(90deg);
  761. transform: translate3d(0, -100%, 0) rotateX(90deg); }
  762. .reveal.cube .slides > section > section.future {
  763. -webkit-transform-origin: 0% 0%;
  764. transform-origin: 0% 0%;
  765. -webkit-transform: translate3d(0, 100%, 0) rotateX(-90deg);
  766. transform: translate3d(0, 100%, 0) rotateX(-90deg); }
  767. /*********************************************
  768. * PAGE TRANSITION
  769. *
  770. * WARNING:
  771. * this is deprecated and will be removed in a
  772. * future version.
  773. *********************************************/
  774. .reveal.page .slides {
  775. -webkit-perspective-origin: 0% 50%;
  776. perspective-origin: 0% 50%;
  777. -webkit-perspective: 3000px;
  778. perspective: 3000px; }
  779. .reveal.page .slides section {
  780. padding: 30px;
  781. min-height: 700px;
  782. box-sizing: border-box;
  783. -webkit-transform-style: preserve-3d;
  784. transform-style: preserve-3d; }
  785. .reveal.page .slides section.past {
  786. z-index: 12; }
  787. .reveal.page .slides section:not(.stack):before {
  788. content: '';
  789. position: absolute;
  790. display: block;
  791. width: 100%;
  792. height: 100%;
  793. left: 0;
  794. top: 0;
  795. background: rgba(0, 0, 0, 0.1);
  796. -webkit-transform: translateZ(-20px);
  797. transform: translateZ(-20px); }
  798. .reveal.page .slides section:not(.stack):after {
  799. content: '';
  800. position: absolute;
  801. display: block;
  802. width: 90%;
  803. height: 30px;
  804. left: 5%;
  805. bottom: 0;
  806. background: none;
  807. z-index: 1;
  808. border-radius: 4px;
  809. box-shadow: 0px 95px 25px rgba(0, 0, 0, 0.2);
  810. -webkit-transform: translateZ(-90px) rotateX(65deg); }
  811. .reveal.page .slides > section.stack {
  812. padding: 0;
  813. background: none; }
  814. .reveal.page .slides > section.past {
  815. -webkit-transform-origin: 0% 0%;
  816. transform-origin: 0% 0%;
  817. -webkit-transform: translate3d(-40%, 0, 0) rotateY(-80deg);
  818. transform: translate3d(-40%, 0, 0) rotateY(-80deg); }
  819. .reveal.page .slides > section.future {
  820. -webkit-transform-origin: 100% 0%;
  821. transform-origin: 100% 0%;
  822. -webkit-transform: translate3d(0, 0, 0);
  823. transform: translate3d(0, 0, 0); }
  824. .reveal.page .slides > section > section.past {
  825. -webkit-transform-origin: 0% 0%;
  826. transform-origin: 0% 0%;
  827. -webkit-transform: translate3d(0, -40%, 0) rotateX(80deg);
  828. transform: translate3d(0, -40%, 0) rotateX(80deg); }
  829. .reveal.page .slides > section > section.future {
  830. -webkit-transform-origin: 0% 100%;
  831. transform-origin: 0% 100%;
  832. -webkit-transform: translate3d(0, 0, 0);
  833. transform: translate3d(0, 0, 0); }
  834. /*********************************************
  835. * FADE TRANSITION
  836. *********************************************/
  837. .reveal .slides section[data-transition=fade],
  838. .reveal.fade .slides section:not([data-transition]),
  839. .reveal.fade .slides > section > section:not([data-transition]) {
  840. -webkit-transform: none;
  841. transform: none;
  842. transition: opacity 0.5s; }
  843. .reveal.fade.overview .slides section,
  844. .reveal.fade.overview .slides > section > section {
  845. transition: none; }
  846. /*********************************************
  847. * NO TRANSITION
  848. *********************************************/
  849. .reveal .slides section[data-transition=none],
  850. .reveal.none .slides section:not([data-transition]) {
  851. -webkit-transform: none;
  852. transform: none;
  853. transition: none; }
  854. /*********************************************
  855. * PAUSED MODE
  856. *********************************************/
  857. .reveal .pause-overlay {
  858. position: absolute;
  859. top: 0;
  860. left: 0;
  861. width: 100%;
  862. height: 100%;
  863. background: black;
  864. visibility: hidden;
  865. opacity: 0;
  866. z-index: 100;
  867. transition: all 1s ease; }
  868. .reveal .pause-overlay .resume-button {
  869. position: absolute;
  870. bottom: 20px;
  871. right: 20px;
  872. color: #ccc;
  873. border-radius: 2px;
  874. padding: 6px 14px;
  875. border: 2px solid #ccc;
  876. font-size: 16px;
  877. background: transparent;
  878. cursor: pointer; }
  879. .reveal .pause-overlay .resume-button:hover {
  880. color: #fff;
  881. border-color: #fff; }
  882. .reveal.paused .pause-overlay {
  883. visibility: visible;
  884. opacity: 1; }
  885. /*********************************************
  886. * FALLBACK
  887. *********************************************/
  888. .no-transforms {
  889. overflow-y: auto; }
  890. .no-transforms .reveal {
  891. overflow: visible; }
  892. .no-transforms .reveal .slides {
  893. position: relative;
  894. width: 80%;
  895. max-width: 1280px;
  896. height: auto;
  897. top: 0;
  898. margin: 0 auto;
  899. text-align: center; }
  900. .no-transforms .reveal .controls,
  901. .no-transforms .reveal .progress {
  902. display: none; }
  903. .no-transforms .reveal .slides section {
  904. display: block;
  905. opacity: 1;
  906. position: relative;
  907. height: auto;
  908. min-height: 0;
  909. top: 0;
  910. left: 0;
  911. margin: 10vh 0;
  912. margin: 70px 0;
  913. -webkit-transform: none;
  914. transform: none; }
  915. .reveal .no-transition,
  916. .reveal .no-transition * {
  917. transition: none !important; }
  918. /*********************************************
  919. * PER-SLIDE BACKGROUNDS
  920. *********************************************/
  921. .reveal .backgrounds {
  922. position: absolute;
  923. width: 100%;
  924. height: 100%;
  925. top: 0;
  926. left: 0;
  927. -webkit-perspective: 600px;
  928. perspective: 600px; }
  929. .reveal .slide-background {
  930. display: none;
  931. position: absolute;
  932. width: 100%;
  933. height: 100%;
  934. opacity: 0;
  935. visibility: hidden;
  936. overflow: hidden;
  937. background-color: rgba(0, 0, 0, 0);
  938. transition: all 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
  939. .reveal .slide-background-content {
  940. position: absolute;
  941. width: 100%;
  942. height: 100%;
  943. background-position: 50% 50%;
  944. background-repeat: no-repeat;
  945. background-size: cover; }
  946. .reveal .slide-background.stack {
  947. display: block; }
  948. .reveal .slide-background.present {
  949. opacity: 1;
  950. visibility: visible;
  951. z-index: 2; }
  952. .print-pdf .reveal .slide-background {
  953. opacity: 1 !important;
  954. visibility: visible !important; }
  955. /* Video backgrounds */
  956. .reveal .slide-background video {
  957. position: absolute;
  958. width: 100%;
  959. height: 100%;
  960. max-width: none;
  961. max-height: none;
  962. top: 0;
  963. left: 0;
  964. -o-object-fit: cover;
  965. object-fit: cover; }
  966. .reveal .slide-background[data-background-size="contain"] video {
  967. -o-object-fit: contain;
  968. object-fit: contain; }
  969. /* Immediate transition style */
  970. .reveal[data-background-transition=none] > .backgrounds .slide-background,
  971. .reveal > .backgrounds .slide-background[data-background-transition=none] {
  972. transition: none; }
  973. /* Slide */
  974. .reveal[data-background-transition=slide] > .backgrounds .slide-background,
  975. .reveal > .backgrounds .slide-background[data-background-transition=slide] {
  976. opacity: 1;
  977. -webkit-backface-visibility: hidden;
  978. backface-visibility: hidden; }
  979. .reveal[data-background-transition=slide] > .backgrounds .slide-background.past,
  980. .reveal > .backgrounds .slide-background.past[data-background-transition=slide] {
  981. -webkit-transform: translate(-100%, 0);
  982. transform: translate(-100%, 0); }
  983. .reveal[data-background-transition=slide] > .backgrounds .slide-background.future,
  984. .reveal > .backgrounds .slide-background.future[data-background-transition=slide] {
  985. -webkit-transform: translate(100%, 0);
  986. transform: translate(100%, 0); }
  987. .reveal[data-background-transition=slide] > .backgrounds .slide-background > .slide-background.past,
  988. .reveal > .backgrounds .slide-background > .slide-background.past[data-background-transition=slide] {
  989. -webkit-transform: translate(0, -100%);
  990. transform: translate(0, -100%); }
  991. .reveal[data-background-transition=slide] > .backgrounds .slide-background > .slide-background.future,
  992. .reveal > .backgrounds .slide-background > .slide-background.future[data-background-transition=slide] {
  993. -webkit-transform: translate(0, 100%);
  994. transform: translate(0, 100%); }
  995. /* Convex */
  996. .reveal[data-background-transition=convex] > .backgrounds .slide-background.past,
  997. .reveal > .backgrounds .slide-background.past[data-background-transition=convex] {
  998. opacity: 0;
  999. -webkit-transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0);
  1000. transform: translate3d(-100%, 0, 0) rotateY(-90deg) translate3d(-100%, 0, 0); }
  1001. .reveal[data-background-transition=convex] > .backgrounds .slide-background.future,
  1002. .reveal > .backgrounds .slide-background.future[data-background-transition=convex] {
  1003. opacity: 0;
  1004. -webkit-transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0);
  1005. transform: translate3d(100%, 0, 0) rotateY(90deg) translate3d(100%, 0, 0); }
  1006. .reveal[data-background-transition=convex] > .backgrounds .slide-background > .slide-background.past,
  1007. .reveal > .backgrounds .slide-background > .slide-background.past[data-background-transition=convex] {
  1008. opacity: 0;
  1009. -webkit-transform: translate3d(0, -100%, 0) rotateX(90deg) translate3d(0, -100%, 0);
  1010. transform: translate3d(0, -100%, 0) rotateX(90deg) translate3d(0, -100%, 0); }
  1011. .reveal[data-background-transition=convex] > .backgrounds .slide-background > .slide-background.future,
  1012. .reveal > .backgrounds .slide-background > .slide-background.future[data-background-transition=convex] {
  1013. opacity: 0;
  1014. -webkit-transform: translate3d(0, 100%, 0) rotateX(-90deg) translate3d(0, 100%, 0);
  1015. transform: translate3d(0, 100%, 0) rotateX(-90deg) translate3d(0, 100%, 0); }
  1016. /* Concave */
  1017. .reveal[data-background-transition=concave] > .backgrounds .slide-background.past,
  1018. .reveal > .backgrounds .slide-background.past[data-background-transition=concave] {
  1019. opacity: 0;
  1020. -webkit-transform: translate3d(-100%, 0, 0) rotateY(90deg) translate3d(-100%, 0, 0);
  1021. transform: translate3d(-100%, 0, 0) rotateY(90deg) translate3d(-100%, 0, 0); }
  1022. .reveal[data-background-transition=concave] > .backgrounds .slide-background.future,
  1023. .reveal > .backgrounds .slide-background.future[data-background-transition=concave] {
  1024. opacity: 0;
  1025. -webkit-transform: translate3d(100%, 0, 0) rotateY(-90deg) translate3d(100%, 0, 0);
  1026. transform: translate3d(100%, 0, 0) rotateY(-90deg) translate3d(100%, 0, 0); }
  1027. .reveal[data-background-transition=concave] > .backgrounds .slide-background > .slide-background.past,
  1028. .reveal > .backgrounds .slide-background > .slide-background.past[data-background-transition=concave] {
  1029. opacity: 0;
  1030. -webkit-transform: translate3d(0, -100%, 0) rotateX(-90deg) translate3d(0, -100%, 0);
  1031. transform: translate3d(0, -100%, 0) rotateX(-90deg) translate3d(0, -100%, 0); }
  1032. .reveal[data-background-transition=concave] > .backgrounds .slide-background > .slide-background.future,
  1033. .reveal > .backgrounds .slide-background > .slide-background.future[data-background-transition=concave] {
  1034. opacity: 0;
  1035. -webkit-transform: translate3d(0, 100%, 0) rotateX(90deg) translate3d(0, 100%, 0);
  1036. transform: translate3d(0, 100%, 0) rotateX(90deg) translate3d(0, 100%, 0); }
  1037. /* Zoom */
  1038. .reveal[data-background-transition=zoom] > .backgrounds .slide-background,
  1039. .reveal > .backgrounds .slide-background[data-background-transition=zoom] {
  1040. transition-timing-function: ease; }
  1041. .reveal[data-background-transition=zoom] > .backgrounds .slide-background.past,
  1042. .reveal > .backgrounds .slide-background.past[data-background-transition=zoom] {
  1043. opacity: 0;
  1044. visibility: hidden;
  1045. -webkit-transform: scale(16);
  1046. transform: scale(16); }
  1047. .reveal[data-background-transition=zoom] > .backgrounds .slide-background.future,
  1048. .reveal > .backgrounds .slide-background.future[data-background-transition=zoom] {
  1049. opacity: 0;
  1050. visibility: hidden;
  1051. -webkit-transform: scale(0.2);
  1052. transform: scale(0.2); }
  1053. .reveal[data-background-transition=zoom] > .backgrounds .slide-background > .slide-background.past,
  1054. .reveal > .backgrounds .slide-background > .slide-background.past[data-background-transition=zoom] {
  1055. opacity: 0;
  1056. visibility: hidden;
  1057. -webkit-transform: scale(16);
  1058. transform: scale(16); }
  1059. .reveal[data-background-transition=zoom] > .backgrounds .slide-background > .slide-background.future,
  1060. .reveal > .backgrounds .slide-background > .slide-background.future[data-background-transition=zoom] {
  1061. opacity: 0;
  1062. visibility: hidden;
  1063. -webkit-transform: scale(0.2);
  1064. transform: scale(0.2); }
  1065. /* Global transition speed settings */
  1066. .reveal[data-transition-speed="fast"] > .backgrounds .slide-background {
  1067. transition-duration: 400ms; }
  1068. .reveal[data-transition-speed="slow"] > .backgrounds .slide-background {
  1069. transition-duration: 1200ms; }
  1070. /*********************************************
  1071. * OVERVIEW
  1072. *********************************************/
  1073. .reveal.overview {
  1074. -webkit-perspective-origin: 50% 50%;
  1075. perspective-origin: 50% 50%;
  1076. -webkit-perspective: 700px;
  1077. perspective: 700px; }
  1078. .reveal.overview .slides {
  1079. -moz-transform-style: preserve-3d; }
  1080. .reveal.overview .slides section {
  1081. height: 100%;
  1082. top: 0 !important;
  1083. opacity: 1 !important;
  1084. overflow: hidden;
  1085. visibility: visible !important;
  1086. cursor: pointer;
  1087. box-sizing: border-box; }
  1088. .reveal.overview .slides section:hover,
  1089. .reveal.overview .slides section.present {
  1090. outline: 10px solid rgba(150, 150, 150, 0.4);
  1091. outline-offset: 10px; }
  1092. .reveal.overview .slides section .fragment {
  1093. opacity: 1;
  1094. transition: none; }
  1095. .reveal.overview .slides section:after,
  1096. .reveal.overview .slides section:before {
  1097. display: none !important; }
  1098. .reveal.overview .slides > section.stack {
  1099. padding: 0;
  1100. top: 0 !important;
  1101. background: none;
  1102. outline: none;
  1103. overflow: visible; }
  1104. .reveal.overview .backgrounds {
  1105. -webkit-perspective: inherit;
  1106. perspective: inherit;
  1107. -moz-transform-style: preserve-3d; }
  1108. .reveal.overview .backgrounds .slide-background {
  1109. opacity: 1;
  1110. visibility: visible;
  1111. outline: 10px solid rgba(150, 150, 150, 0.1);
  1112. outline-offset: 10px; }
  1113. .reveal.overview .backgrounds .slide-background.stack {
  1114. overflow: visible; }
  1115. .reveal.overview .slides section,
  1116. .reveal.overview-deactivating .slides section {
  1117. transition: none; }
  1118. .reveal.overview .backgrounds .slide-background,
  1119. .reveal.overview-deactivating .backgrounds .slide-background {
  1120. transition: none; }
  1121. /*********************************************
  1122. * RTL SUPPORT
  1123. *********************************************/
  1124. .reveal.rtl .slides,
  1125. .reveal.rtl .slides h1,
  1126. .reveal.rtl .slides h2,
  1127. .reveal.rtl .slides h3,
  1128. .reveal.rtl .slides h4,
  1129. .reveal.rtl .slides h5,
  1130. .reveal.rtl .slides h6 {
  1131. direction: rtl;
  1132. font-family: sans-serif; }
  1133. .reveal.rtl pre,
  1134. .reveal.rtl code {
  1135. direction: ltr; }
  1136. .reveal.rtl ol,
  1137. .reveal.rtl ul {
  1138. text-align: right; }
  1139. .reveal.rtl .progress span {
  1140. float: right; }
  1141. /*********************************************
  1142. * PARALLAX BACKGROUND
  1143. *********************************************/
  1144. .reveal.has-parallax-background .backgrounds {
  1145. transition: all 0.8s ease; }
  1146. /* Global transition speed settings */
  1147. .reveal.has-parallax-background[data-transition-speed="fast"] .backgrounds {
  1148. transition-duration: 400ms; }
  1149. .reveal.has-parallax-background[data-transition-speed="slow"] .backgrounds {
  1150. transition-duration: 1200ms; }
  1151. /*********************************************
  1152. * OVERLAY FOR LINK PREVIEWS AND HELP
  1153. *********************************************/
  1154. .reveal > .overlay {
  1155. position: absolute;
  1156. top: 0;
  1157. left: 0;
  1158. width: 100%;
  1159. height: 100%;
  1160. z-index: 1000;
  1161. background: rgba(0, 0, 0, 0.9);
  1162. opacity: 0;
  1163. visibility: hidden;
  1164. transition: all 0.3s ease; }
  1165. .reveal > .overlay.visible {
  1166. opacity: 1;
  1167. visibility: visible; }
  1168. .reveal > .overlay .spinner {
  1169. position: absolute;
  1170. display: block;
  1171. top: 50%;
  1172. left: 50%;
  1173. width: 32px;
  1174. height: 32px;
  1175. margin: -16px 0 0 -16px;
  1176. z-index: 10;
  1177. background-image: url(data:image/gif;base64,R0lGODlhIAAgAPMAAJmZmf%2F%2F%2F6%2Bvr8nJybW1tcDAwOjo6Nvb26ioqKOjo7Ozs%2FLy8vz8%2FAAAAAAAAAAAACH%2FC05FVFNDQVBFMi4wAwEAAAAh%2FhpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh%2BQQJCgAAACwAAAAAIAAgAAAE5xDISWlhperN52JLhSSdRgwVo1ICQZRUsiwHpTJT4iowNS8vyW2icCF6k8HMMBkCEDskxTBDAZwuAkkqIfxIQyhBQBFvAQSDITM5VDW6XNE4KagNh6Bgwe60smQUB3d4Rz1ZBApnFASDd0hihh12BkE9kjAJVlycXIg7CQIFA6SlnJ87paqbSKiKoqusnbMdmDC2tXQlkUhziYtyWTxIfy6BE8WJt5YJvpJivxNaGmLHT0VnOgSYf0dZXS7APdpB309RnHOG5gDqXGLDaC457D1zZ%2FV%2FnmOM82XiHRLYKhKP1oZmADdEAAAh%2BQQJCgAAACwAAAAAIAAgAAAE6hDISWlZpOrNp1lGNRSdRpDUolIGw5RUYhhHukqFu8DsrEyqnWThGvAmhVlteBvojpTDDBUEIFwMFBRAmBkSgOrBFZogCASwBDEY%2FCZSg7GSE0gSCjQBMVG023xWBhklAnoEdhQEfyNqMIcKjhRsjEdnezB%2BA4k8gTwJhFuiW4dokXiloUepBAp5qaKpp6%2BHo7aWW54wl7obvEe0kRuoplCGepwSx2jJvqHEmGt6whJpGpfJCHmOoNHKaHx61WiSR92E4lbFoq%2BB6QDtuetcaBPnW6%2BO7wDHpIiK9SaVK5GgV543tzjgGcghAgAh%2BQQJCgAAACwAAAAAIAAgAAAE7hDISSkxpOrN5zFHNWRdhSiVoVLHspRUMoyUakyEe8PTPCATW9A14E0UvuAKMNAZKYUZCiBMuBakSQKG8G2FzUWox2AUtAQFcBKlVQoLgQReZhQlCIJesQXI5B0CBnUMOxMCenoCfTCEWBsJColTMANldx15BGs8B5wlCZ9Po6OJkwmRpnqkqnuSrayqfKmqpLajoiW5HJq7FL1Gr2mMMcKUMIiJgIemy7xZtJsTmsM4xHiKv5KMCXqfyUCJEonXPN2rAOIAmsfB3uPoAK%2B%2BG%2Bw48edZPK%2BM6hLJpQg484enXIdQFSS1u6UhksENEQAAIfkECQoAAAAsAAAAACAAIAAABOcQyEmpGKLqzWcZRVUQnZYg1aBSh2GUVEIQ2aQOE%2BG%2BcD4ntpWkZQj1JIiZIogDFFyHI0UxQwFugMSOFIPJftfVAEoZLBbcLEFhlQiqGp1Vd140AUklUN3eCA51C1EWMzMCezCBBmkxVIVHBWd3HHl9JQOIJSdSnJ0TDKChCwUJjoWMPaGqDKannasMo6WnM562R5YluZRwur0wpgqZE7NKUm%2BFNRPIhjBJxKZteWuIBMN4zRMIVIhffcgojwCF117i4nlLnY5ztRLsnOk%2BaV%2BoJY7V7m76PdkS4trKcdg0Zc0tTcKkRAAAIfkECQoAAAAsAAAAACAAIAAABO4QyEkpKqjqzScpRaVkXZWQEximw1BSCUEIlDohrft6cpKCk5xid5MNJTaAIkekKGQkWyKHkvhKsR7ARmitkAYDYRIbUQRQjWBwJRzChi9CRlBcY1UN4g0%2FVNB0AlcvcAYHRyZPdEQFYV8ccwR5HWxEJ02YmRMLnJ1xCYp0Y5idpQuhopmmC2KgojKasUQDk5BNAwwMOh2RtRq5uQuPZKGIJQIGwAwGf6I0JXMpC8C7kXWDBINFMxS4DKMAWVWAGYsAdNqW5uaRxkSKJOZKaU3tPOBZ4DuK2LATgJhkPJMgTwKCdFjyPHEnKxFCDhEAACH5BAkKAAAALAAAAAAgACAAAATzEMhJaVKp6s2nIkolIJ2WkBShpkVRWqqQrhLSEu9MZJKK9y1ZrqYK9WiClmvoUaF8gIQSNeF1Er4MNFn4SRSDARWroAIETg1iVwuHjYB1kYc1mwruwXKC9gmsJXliGxc%2BXiUCby9ydh1sOSdMkpMTBpaXBzsfhoc5l58Gm5yToAaZhaOUqjkDgCWNHAULCwOLaTmzswadEqggQwgHuQsHIoZCHQMMQgQGubVEcxOPFAcMDAYUA85eWARmfSRQCdcMe0zeP1AAygwLlJtPNAAL19DARdPzBOWSm1brJBi45soRAWQAAkrQIykShQ9wVhHCwCQCACH5BAkKAAAALAAAAAAgACAAAATrEMhJaVKp6s2nIkqFZF2VIBWhUsJaTokqUCoBq%2BE71SRQeyqUToLA7VxF0JDyIQh%2FMVVPMt1ECZlfcjZJ9mIKoaTl1MRIl5o4CUKXOwmyrCInCKqcWtvadL2SYhyASyNDJ0uIiRMDjI0Fd30%2FiI2UA5GSS5UDj2l6NoqgOgN4gksEBgYFf0FDqKgHnyZ9OX8HrgYHdHpcHQULXAS2qKpENRg7eAMLC7kTBaixUYFkKAzWAAnLC7FLVxLWDBLKCwaKTULgEwbLA4hJtOkSBNqITT3xEgfLpBtzE%2FjiuL04RGEBgwWhShRgQExHBAAh%2BQQJCgAAACwAAAAAIAAgAAAE7xDISWlSqerNpyJKhWRdlSAVoVLCWk6JKlAqAavhO9UkUHsqlE6CwO1cRdCQ8iEIfzFVTzLdRAmZX3I2SfZiCqGk5dTESJeaOAlClzsJsqwiJwiqnFrb2nS9kmIcgEsjQydLiIlHehhpejaIjzh9eomSjZR%2BipslWIRLAgMDOR2DOqKogTB9pCUJBagDBXR6XB0EBkIIsaRsGGMMAxoDBgYHTKJiUYEGDAzHC9EACcUGkIgFzgwZ0QsSBcXHiQvOwgDdEwfFs0sDzt4S6BK4xYjkDOzn0unFeBzOBijIm1Dgmg5YFQwsCMjp1oJ8LyIAACH5BAkKAAAALAAAAAAgACAAAATwEMhJaVKp6s2nIkqFZF2VIBWhUsJaTokqUCoBq%2BE71SRQeyqUToLA7VxF0JDyIQh%2FMVVPMt1ECZlfcjZJ9mIKoaTl1MRIl5o4CUKXOwmyrCInCKqcWtvadL2SYhyASyNDJ0uIiUd6GGl6NoiPOH16iZKNlH6KmyWFOggHhEEvAwwMA0N9GBsEC6amhnVcEwavDAazGwIDaH1ipaYLBUTCGgQDA8NdHz0FpqgTBwsLqAbWAAnIA4FWKdMLGdYGEgraigbT0OITBcg5QwPT4xLrROZL6AuQAPUS7bxLpoWidY0JtxLHKhwwMJBTHgPKdEQAACH5BAkKAAAALAAAAAAgACAAAATrEMhJaVKp6s2nIkqFZF2VIBWhUsJaTokqUCoBq%2BE71SRQeyqUToLA7VxF0JDyIQh%2FMVVPMt1ECZlfcjZJ9mIKoaTl1MRIl5o4CUKXOwmyrCInCKqcWtvadL2SYhyASyNDJ0uIiUd6GAULDJCRiXo1CpGXDJOUjY%2BYip9DhToJA4RBLwMLCwVDfRgbBAaqqoZ1XBMHswsHtxtFaH1iqaoGNgAIxRpbFAgfPQSqpbgGBqUD1wBXeCYp1AYZ19JJOYgH1KwA4UBvQwXUBxPqVD9L3sbp2BNk2xvvFPJd%2BMFCN6HAAIKgNggY0KtEBAAh%2BQQJCgAAACwAAAAAIAAgAAAE6BDISWlSqerNpyJKhWRdlSAVoVLCWk6JKlAqAavhO9UkUHsqlE6CwO1cRdCQ8iEIfzFVTzLdRAmZX3I2SfYIDMaAFdTESJeaEDAIMxYFqrOUaNW4E4ObYcCXaiBVEgULe0NJaxxtYksjh2NLkZISgDgJhHthkpU4mW6blRiYmZOlh4JWkDqILwUGBnE6TYEbCgevr0N1gH4At7gHiRpFaLNrrq8HNgAJA70AWxQIH1%2BvsYMDAzZQPC9VCNkDWUhGkuE5PxJNwiUK4UfLzOlD4WvzAHaoG9nxPi5d%2BjYUqfAhhykOFwJWiAAAIfkECQoAAAAsAAAAACAAIAAABPAQyElpUqnqzaciSoVkXVUMFaFSwlpOCcMYlErAavhOMnNLNo8KsZsMZItJEIDIFSkLGQoQTNhIsFehRww2CQLKF0tYGKYSg%2BygsZIuNqJksKgbfgIGepNo2cIUB3V1B3IvNiBYNQaDSTtfhhx0CwVPI0UJe0%2Bbm4g5VgcGoqOcnjmjqDSdnhgEoamcsZuXO1aWQy8KAwOAuTYYGwi7w5h%2BKr0SJ8MFihpNbx%2B4Erq7BYBuzsdiH1jCAzoSfl0rVirNbRXlBBlLX%2BBP0XJLAPGzTkAuAOqb0WT5AH7OcdCm5B8TgRwSRKIHQtaLCwg1RAAAOwAAAAAAAAAAAA%3D%3D);
  1178. visibility: visible;
  1179. opacity: 0.6;
  1180. transition: all 0.3s ease; }
  1181. .reveal > .overlay header {
  1182. position: absolute;
  1183. left: 0;
  1184. top: 0;
  1185. width: 100%;
  1186. height: 40px;
  1187. z-index: 2;
  1188. border-bottom: 1px solid #222; }
  1189. .reveal > .overlay header a {
  1190. display: inline-block;
  1191. width: 40px;
  1192. height: 40px;
  1193. line-height: 36px;
  1194. padding: 0 10px;
  1195. float: right;
  1196. opacity: 0.6;
  1197. box-sizing: border-box; }
  1198. .reveal > .overlay header a:hover {
  1199. opacity: 1; }
  1200. .reveal > .overlay header a .icon {
  1201. display: inline-block;
  1202. width: 20px;
  1203. height: 20px;
  1204. background-position: 50% 50%;
  1205. background-size: 100%;
  1206. background-repeat: no-repeat; }
  1207. .reveal > .overlay header a.close .icon {
  1208. background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABkklEQVRYR8WX4VHDMAxG6wnoJrABZQPYBCaBTWAD2g1gE5gg6OOsXuxIlr40d81dfrSJ9V4c2VLK7spHuTJ/5wpM07QXuXc5X0opX2tEJcadjHuV80li/FgxTIEK/5QBCICBD6xEhSMGHgQPgBgLiYVAB1dpSqKDawxTohFw4JSEA3clzgIBPCURwE2JucBR7rhPJJv5OpJwDX+SfDjgx1wACQeJG1aChP9K/IMmdZ8DtESV1WyP3Bt4MwM6sj4NMxMYiqUWHQu4KYA/SYkIjOsm3BXYWMKFDwU2khjCQ4ELJUJ4SmClRArOCmSXGuKma0fYD5CbzHxFpCSGAhfAVSSUGDUk2BWZaff2g6GE15BsBQ9nwmpIGDiyHQddwNTMKkbZaf9fajXQca1EX44puJZUsnY0ObGmITE3GVLCbEhQUjGVt146j6oasWN+49Vph2w1pZ5EansNZqKBm1txbU57iRRcZ86RWMDdWtBJUHBHwoQPi1GV+JCbntmvok7iTX4/Up9mgyTc/FJYDTcndgH/AA5A/CHsyEkVAAAAAElFTkSuQmCC); }
  1209. .reveal > .overlay header a.external .icon {
  1210. background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAcElEQVRYR+2WSQoAIQwEzf8f7XiOMkUQxUPlGkM3hVmiQfQR9GYnH1SsAQlI4DiBqkCMoNb9y2e90IAEJPAcgdznU9+engMaeJ7Azh5Y1U67gAho4DqBqmB1buAf0MB1AlVBek83ZPkmJMGc1wAR+AAqod/B97TRpQAAAABJRU5ErkJggg==); }
  1211. .reveal > .overlay .viewport {
  1212. position: absolute;
  1213. display: -webkit-box;
  1214. display: -ms-flexbox;
  1215. display: flex;
  1216. top: 40px;
  1217. right: 0;
  1218. bottom: 0;
  1219. left: 0; }
  1220. .reveal > .overlay.overlay-preview .viewport iframe {
  1221. width: 100%;
  1222. height: 100%;
  1223. max-width: 100%;
  1224. max-height: 100%;
  1225. border: 0;
  1226. opacity: 0;
  1227. visibility: hidden;
  1228. transition: all 0.3s ease; }
  1229. .reveal > .overlay.overlay-preview.loaded .viewport iframe {
  1230. opacity: 1;
  1231. visibility: visible; }
  1232. .reveal > .overlay.overlay-preview.loaded .viewport-inner {
  1233. position: absolute;
  1234. z-index: -1;
  1235. left: 0;
  1236. top: 45%;
  1237. width: 100%;
  1238. text-align: center;
  1239. letter-spacing: normal; }
  1240. .reveal > .overlay.overlay-preview .x-frame-error {
  1241. opacity: 0;
  1242. transition: opacity 0.3s ease 0.3s; }
  1243. .reveal > .overlay.overlay-preview.loaded .x-frame-error {
  1244. opacity: 1; }
  1245. .reveal > .overlay.overlay-preview.loaded .spinner {
  1246. opacity: 0;
  1247. visibility: hidden;
  1248. -webkit-transform: scale(0.2);
  1249. transform: scale(0.2); }
  1250. .reveal > .overlay.overlay-help .viewport {
  1251. overflow: auto;
  1252. color: #fff; }
  1253. .reveal > .overlay.overlay-help .viewport .viewport-inner {
  1254. width: 600px;
  1255. margin: auto;
  1256. padding: 20px 20px 80px 20px;
  1257. text-align: center;
  1258. letter-spacing: normal; }
  1259. .reveal > .overlay.overlay-help .viewport .viewport-inner .title {
  1260. font-size: 20px; }
  1261. .reveal > .overlay.overlay-help .viewport .viewport-inner table {
  1262. border: 1px solid #fff;
  1263. border-collapse: collapse;
  1264. font-size: 16px; }
  1265. .reveal > .overlay.overlay-help .viewport .viewport-inner table th,
  1266. .reveal > .overlay.overlay-help .viewport .viewport-inner table td {
  1267. width: 200px;
  1268. padding: 14px;
  1269. border: 1px solid #fff;
  1270. vertical-align: middle; }
  1271. .reveal > .overlay.overlay-help .viewport .viewport-inner table th {
  1272. padding-top: 20px;
  1273. padding-bottom: 20px; }
  1274. /*********************************************
  1275. * PLAYBACK COMPONENT
  1276. *********************************************/
  1277. .reveal .playback {
  1278. position: absolute;
  1279. left: 15px;
  1280. bottom: 20px;
  1281. z-index: 30;
  1282. cursor: pointer;
  1283. transition: all 400ms ease;
  1284. -webkit-tap-highlight-color: rgba(0, 0, 0, 0); }
  1285. .reveal.overview .playback {
  1286. opacity: 0;
  1287. visibility: hidden; }
  1288. /*********************************************
  1289. * CODE HIGHLGIHTING
  1290. *********************************************/
  1291. .reveal .hljs table {
  1292. margin: initial; }
  1293. .reveal .hljs-ln-code,
  1294. .reveal .hljs-ln-numbers {
  1295. padding: 0;
  1296. border: 0; }
  1297. .reveal .hljs-ln-numbers {
  1298. opacity: 0.6;
  1299. padding-right: 0.75em;
  1300. text-align: right;
  1301. vertical-align: top; }
  1302. .reveal .hljs[data-line-numbers]:not([data-line-numbers=""]) tr:not(.highlight-line) {
  1303. opacity: 0.4; }
  1304. /*********************************************
  1305. * ROLLING LINKS
  1306. *********************************************/
  1307. .reveal .roll {
  1308. display: inline-block;
  1309. line-height: 1.2;
  1310. overflow: hidden;
  1311. vertical-align: top;
  1312. -webkit-perspective: 400px;
  1313. perspective: 400px;
  1314. -webkit-perspective-origin: 50% 50%;
  1315. perspective-origin: 50% 50%; }
  1316. .reveal .roll:hover {
  1317. background: none;
  1318. text-shadow: none; }
  1319. .reveal .roll span {
  1320. display: block;
  1321. position: relative;
  1322. padding: 0 2px;
  1323. pointer-events: none;
  1324. transition: all 400ms ease;
  1325. -webkit-transform-origin: 50% 0%;
  1326. transform-origin: 50% 0%;
  1327. -webkit-transform-style: preserve-3d;
  1328. transform-style: preserve-3d;
  1329. -webkit-backface-visibility: hidden;
  1330. backface-visibility: hidden; }
  1331. .reveal .roll:hover span {
  1332. background: rgba(0, 0, 0, 0.5);
  1333. -webkit-transform: translate3d(0px, 0px, -45px) rotateX(90deg);
  1334. transform: translate3d(0px, 0px, -45px) rotateX(90deg); }
  1335. .reveal .roll span:after {
  1336. content: attr(data-title);
  1337. display: block;
  1338. position: absolute;
  1339. left: 0;
  1340. top: 0;
  1341. padding: 0 2px;
  1342. -webkit-backface-visibility: hidden;
  1343. backface-visibility: hidden;
  1344. -webkit-transform-origin: 50% 0%;
  1345. transform-origin: 50% 0%;
  1346. -webkit-transform: translate3d(0px, 110%, 0px) rotateX(-90deg);
  1347. transform: translate3d(0px, 110%, 0px) rotateX(-90deg); }
  1348. /*********************************************
  1349. * SPEAKER NOTES
  1350. *********************************************/
  1351. .reveal aside.notes {
  1352. display: none; }
  1353. .reveal .speaker-notes {
  1354. display: none;
  1355. position: absolute;
  1356. width: 33.3333333333%;
  1357. height: 100%;
  1358. top: 0;
  1359. left: 100%;
  1360. padding: 14px 18px 14px 18px;
  1361. z-index: 1;
  1362. font-size: 18px;
  1363. line-height: 1.4;
  1364. border: 1px solid rgba(0, 0, 0, 0.05);
  1365. color: #222;
  1366. background-color: #f5f5f5;
  1367. overflow: auto;
  1368. box-sizing: border-box;
  1369. text-align: left;
  1370. font-family: Helvetica, sans-serif;
  1371. -webkit-overflow-scrolling: touch; }
  1372. .reveal .speaker-notes .notes-placeholder {
  1373. color: #ccc;
  1374. font-style: italic; }
  1375. .reveal .speaker-notes:focus {
  1376. outline: none; }
  1377. .reveal .speaker-notes:before {
  1378. content: 'Speaker notes';
  1379. display: block;
  1380. margin-bottom: 10px;
  1381. opacity: 0.5; }
  1382. .reveal.show-notes {
  1383. max-width: 75%;
  1384. overflow: visible; }
  1385. .reveal.show-notes .speaker-notes {
  1386. display: block; }
  1387. @media screen and (min-width: 1600px) {
  1388. .reveal .speaker-notes {
  1389. font-size: 20px; } }
  1390. @media screen and (max-width: 1024px) {
  1391. .reveal.show-notes {
  1392. border-left: 0;
  1393. max-width: none;
  1394. max-height: 70%;
  1395. max-height: 70vh;
  1396. overflow: visible; }
  1397. .reveal.show-notes .speaker-notes {
  1398. top: 100%;
  1399. left: 0;
  1400. width: 100%;
  1401. height: 42.8571428571%;
  1402. height: 30vh;
  1403. border: 0; } }
  1404. @media screen and (max-width: 600px) {
  1405. .reveal.show-notes {
  1406. max-height: 60%;
  1407. max-height: 60vh; }
  1408. .reveal.show-notes .speaker-notes {
  1409. top: 100%;
  1410. height: 66.6666666667%;
  1411. height: 40vh; }
  1412. .reveal .speaker-notes {
  1413. font-size: 14px; } }
  1414. /*********************************************
  1415. * ZOOM PLUGIN
  1416. *********************************************/
  1417. .zoomed .reveal *,
  1418. .zoomed .reveal *:before,
  1419. .zoomed .reveal *:after {
  1420. -webkit-backface-visibility: visible !important;
  1421. backface-visibility: visible !important; }
  1422. .zoomed .reveal .progress,
  1423. .zoomed .reveal .controls {
  1424. opacity: 0; }
  1425. .zoomed .reveal .roll span {
  1426. background: none; }
  1427. .zoomed .reveal .roll span:after {
  1428. visibility: hidden; }
  1429. /**
  1430. * White theme for reveal.js. This is the opposite of the 'black' theme.
  1431. *
  1432. * By Hakim El Hattab, http://hakim.se
  1433. */
  1434. /*@import url(../../lib/font/source-sans-pro/source-sans-pro.css);*/
  1435. section.has-dark-background, section.has-dark-background h1, section.has-dark-background h2, section.has-dark-background h3, section.has-dark-background h4, section.has-dark-background h5, section.has-dark-background h6 {
  1436. color: #fff; }
  1437. /*********************************************
  1438. * GLOBAL STYLES
  1439. *********************************************/
  1440. body {
  1441. background: #fff;
  1442. background-color: #fff; }
  1443. .reveal {
  1444. font-family: "Source Sans Pro", Helvetica, sans-serif;
  1445. font-size: 42px;
  1446. font-weight: normal;
  1447. color: #222; }
  1448. ::selection {
  1449. color: #fff;
  1450. background: #98bdef;
  1451. text-shadow: none; }
  1452. ::-moz-selection {
  1453. color: #fff;
  1454. background: #98bdef;
  1455. text-shadow: none; }
  1456. .reveal .slides section,
  1457. .reveal .slides section > section {
  1458. line-height: 1.3;
  1459. font-weight: inherit; }
  1460. /*********************************************
  1461. * HEADERS
  1462. *********************************************/
  1463. .reveal h1,
  1464. .reveal h2,
  1465. .reveal h3,
  1466. .reveal h4,
  1467. .reveal h5,
  1468. .reveal h6 {
  1469. margin: 0 0 20px 0;
  1470. color: #222;
  1471. font-family: "Source Sans Pro", Helvetica, sans-serif;
  1472. font-weight: 600;
  1473. line-height: 1.2;
  1474. letter-spacing: normal;
  1475. text-transform: uppercase;
  1476. text-shadow: none;
  1477. word-wrap: break-word; }
  1478. .reveal h1 {
  1479. font-size: 2.5em; }
  1480. .reveal h2 {
  1481. font-size: 1.6em; }
  1482. .reveal h3 {
  1483. font-size: 1.3em; }
  1484. .reveal h4 {
  1485. font-size: 1em; }
  1486. .reveal h1 {
  1487. text-shadow: none; }
  1488. /*********************************************
  1489. * OTHER
  1490. *********************************************/
  1491. .reveal p {
  1492. margin: 20px 0;
  1493. line-height: 1.3; }
  1494. /* Ensure certain elements are never larger than the slide itself */
  1495. .reveal img,
  1496. .reveal video,
  1497. .reveal iframe {
  1498. max-width: 95%;
  1499. max-height: 95%; }
  1500. .reveal strong,
  1501. .reveal b {
  1502. font-weight: bold; }
  1503. .reveal em {
  1504. font-style: italic; }
  1505. .reveal ol,
  1506. .reveal dl,
  1507. .reveal ul {
  1508. display: inline-block;
  1509. text-align: left;
  1510. margin: 0 0 0 1em; }
  1511. .reveal ol {
  1512. list-style-type: decimal; }
  1513. .reveal ul {
  1514. list-style-type: disc; }
  1515. .reveal ul ul {
  1516. list-style-type: square; }
  1517. .reveal ul ul ul {
  1518. list-style-type: circle; }
  1519. .reveal ul ul,
  1520. .reveal ul ol,
  1521. .reveal ol ol,
  1522. .reveal ol ul {
  1523. display: block;
  1524. margin-left: 40px; }
  1525. .reveal dt {
  1526. font-weight: bold; }
  1527. .reveal dd {
  1528. margin-left: 40px; }
  1529. .reveal blockquote {
  1530. display: block;
  1531. position: relative;
  1532. width: 70%;
  1533. margin: 20px auto;
  1534. padding: 5px;
  1535. font-style: italic;
  1536. background: rgba(255, 255, 255, 0.05);
  1537. box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2); }
  1538. .reveal blockquote p:first-child,
  1539. .reveal blockquote p:last-child {
  1540. display: inline-block; }
  1541. .reveal q {
  1542. font-style: italic; }
  1543. .reveal pre {
  1544. display: block;
  1545. position: relative;
  1546. width: 90%;
  1547. margin: 20px auto;
  1548. text-align: left;
  1549. font-size: 0.55em;
  1550. font-family: monospace;
  1551. line-height: 1.2em;
  1552. word-wrap: break-word;
  1553. box-shadow: 0px 5px 15px rgba(0, 0, 0, 0.15); }
  1554. .reveal code {
  1555. font-family: monospace;
  1556. text-transform: none; }
  1557. .reveal pre code {
  1558. display: block;
  1559. padding: 5px;
  1560. overflow: auto;
  1561. max-height: 400px;
  1562. word-wrap: normal; }
  1563. .reveal table {
  1564. margin: auto;
  1565. border-collapse: collapse;
  1566. border-spacing: 0; }
  1567. .reveal table th {
  1568. font-weight: bold; }
  1569. .reveal table th,
  1570. .reveal table td {
  1571. text-align: left;
  1572. padding: 0.2em 0.5em 0.2em 0.5em;
  1573. border-bottom: 1px solid; }
  1574. .reveal table th[align="center"],
  1575. .reveal table td[align="center"] {
  1576. text-align: center; }
  1577. .reveal table th[align="right"],
  1578. .reveal table td[align="right"] {
  1579. text-align: right; }
  1580. .reveal table tbody tr:last-child th,
  1581. .reveal table tbody tr:last-child td {
  1582. border-bottom: none; }
  1583. .reveal sup {
  1584. vertical-align: super;
  1585. font-size: smaller; }
  1586. .reveal sub {
  1587. vertical-align: sub;
  1588. font-size: smaller; }
  1589. .reveal small {
  1590. display: inline-block;
  1591. font-size: 0.6em;
  1592. line-height: 1.2em;
  1593. vertical-align: top; }
  1594. .reveal small * {
  1595. vertical-align: top; }
  1596. /*********************************************
  1597. * LINKS
  1598. *********************************************/
  1599. .reveal a {
  1600. color: #2a76dd;
  1601. text-decoration: none;
  1602. -webkit-transition: color .15s ease;
  1603. -moz-transition: color .15s ease;
  1604. transition: color .15s ease; }
  1605. .reveal a:hover {
  1606. color: #6ca0e8;
  1607. text-shadow: none;
  1608. border: none; }
  1609. .reveal .roll span:after {
  1610. color: #fff;
  1611. background: #1a53a1; }
  1612. /*********************************************
  1613. * IMAGES
  1614. *********************************************/
  1615. .reveal section img {
  1616. margin: 15px 0px;
  1617. background: rgba(255, 255, 255, 0.12);
  1618. border: 4px solid #222;
  1619. box-shadow: 0 0 10px rgba(0, 0, 0, 0.15); }
  1620. .reveal section img.plain {
  1621. border: 0;
  1622. box-shadow: none; }
  1623. .reveal a img {
  1624. -webkit-transition: all .15s linear;
  1625. -moz-transition: all .15s linear;
  1626. transition: all .15s linear; }
  1627. .reveal a:hover img {
  1628. background: rgba(255, 255, 255, 0.2);
  1629. border-color: #2a76dd;
  1630. box-shadow: 0 0 20px rgba(0, 0, 0, 0.55); }
  1631. /*********************************************
  1632. * NAVIGATION CONTROLS
  1633. *********************************************/
  1634. .reveal .controls {
  1635. color: #2a76dd; }
  1636. /*********************************************
  1637. * PROGRESS BAR
  1638. *********************************************/
  1639. .reveal .progress {
  1640. background: rgba(0, 0, 0, 0.2);
  1641. color: #2a76dd; }
  1642. .reveal .progress span {
  1643. -webkit-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
  1644. -moz-transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
  1645. transition: width 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); }
  1646. /*********************************************
  1647. * PRINT BACKGROUND
  1648. *********************************************/
  1649. @media print {
  1650. .backgrounds {
  1651. background-color: #fff; } }
  1652. </style>
  1653. <title>Обучение детей программированию</title>
  1654. </head>
  1655. <body>
  1656. <div class="reveal">
  1657. <div class="slides">
  1658. <section data-background-image="bg-01.png" data-background-opacity="0.3">
  1659. <h2>Обучение детей программированию</h2>
  1660. <br>
  1661. Капелько Михаил
  1662. <br>
  1663. 2019
  1664. </section>
  1665. <section data-background-image="myself.png" data-background-opacity="0.4" data-background-size="50%" data-background-position="left">
  1666. О себе
  1667. </section>
  1668. <section data-background-image="bg-03.jpg" data-background-opacity="0.4">
  1669. Социальная ответственность
  1670. </section>
  1671. <section data-background-image="bg-04.jpg" data-background-opacity="0.4">
  1672. Группы
  1673. </section>
  1674. <section data-background-image="bg-05.jpg" data-background-opacity="0.4">
  1675. По субботам
  1676. </section>
  1677. <section data-background-image="bg-06.jpg" data-background-opacity="0.4">
  1678. Первый раз
  1679. </section>
  1680. <section data-background-image="bg-07.jpg" data-background-opacity="0.4">
  1681. Второй раз
  1682. </section>
  1683. <section data-background-image="bg-08.jpg" data-background-opacity="0.4">
  1684. За 1 час
  1685. </section>
  1686. <section data-background-image="game-01.png" data-background-opacity="0.4">
  1687. 16 карт
  1688. </section>
  1689. <section data-background-image="game-02.png" data-background-opacity="0.4">
  1690. Начало
  1691. </section>
  1692. <section data-background-image="game-03.png" data-background-opacity="0.4">
  1693. Пара
  1694. </section>
  1695. <section data-background-image="game-02.png" data-background-opacity="0.4">
  1696. Разные
  1697. </section>
  1698. <section data-background-image="game-04.png" data-background-opacity="0.4">
  1699. Совпадают
  1700. </section>
  1701. <section data-background-image="game-05.png" data-background-opacity="0.4">
  1702. Убираем
  1703. </section>
  1704. <section data-background-image="goal.png" data-background-opacity="0.4" data-background-size="50%">
  1705. Цель
  1706. </section>
  1707. <section data-background-image="mechanics.jpg" data-background-opacity="0.4">
  1708. Основная механика
  1709. </section>
  1710. <section data-background-image="scratch.gif" data-background-opacity="0.4">
  1711. Инструмент
  1712. </section>
  1713. <section data-background-image="pc-off.jpg" data-background-opacity="0.4">
  1714. Первое занятие
  1715. </section>
  1716. <section data-background-image="welcome-circle.jpg" data-background-opacity="0.4">
  1717. Круг
  1718. </section>
  1719. <section data-background-image="welcome-01.jpg" data-background-opacity="0.4">
  1720. Знакомство
  1721. </section>
  1722. <section data-background-image="welcome-02.jpg" data-background-opacity="0.4">
  1723. Общее пространство
  1724. </section>
  1725. <section data-background-image="welcome-03.png" data-background-opacity="0.4" data-background-size="50%">
  1726. Равенство
  1727. </section>
  1728. <section data-background-image="welcome-04.jpg" data-background-opacity="0.4">
  1729. Внимание
  1730. </section>
  1731. <section data-background-image="welcome-05.jpg" data-background-opacity="0.4">
  1732. Обратная связь
  1733. </section>
  1734. <section data-background-image="welcome-06.png" data-background-opacity="0.4">
  1735. Веселье
  1736. </section>
  1737. <section data-background-image="cards.jpg" data-background-opacity="0.4">
  1738. Игра в карты
  1739. </section>
  1740. <section data-background-image="algorithm.jpg" data-background-opacity="0.4">
  1741. Понятие алгоритма
  1742. </section>
  1743. <section data-background-image="game-01.png" data-background-opacity="0.4">
  1744. Алгоритм игры
  1745. </section>
  1746. <section data-background-image="analysis.jpg" data-background-opacity="0.4">
  1747. Анализ занятия
  1748. </section>
  1749. <section data-background-image="lesson-01.jpg" data-background-opacity="0.4">
  1750. Второе занятие
  1751. <br>
  1752. <br>
  1753. Кто что сделал
  1754. </section>
  1755. <section data-background-image="lesson-02.jpg" data-background-opacity="0.4">
  1756. Составление требований
  1757. </section>
  1758. <section data-background-image="grid-4x4.png" data-background-opacity="0.4">
  1759. Третье занятие
  1760. <br>
  1761. <br>
  1762. Сетка элементов
  1763. </section>
  1764. <section data-background-image="распутье.jpg" data-background-opacity="0.4">
  1765. Распутье
  1766. </section>
  1767. </div>
  1768. </div>
  1769. <script>
  1770. /*!
  1771. * reveal.js
  1772. * http://revealjs.com
  1773. * MIT licensed
  1774. *
  1775. * Copyright (C) 2019 Hakim El Hattab, http://hakim.se
  1776. */
  1777. (function( root, factory ) {
  1778. if( typeof define === 'function' && define.amd ) {
  1779. // AMD. Register as an anonymous module.
  1780. define( function() {
  1781. root.Reveal = factory();
  1782. return root.Reveal;
  1783. } );
  1784. } else if( typeof exports === 'object' ) {
  1785. // Node. Does not work with strict CommonJS.
  1786. module.exports = factory();
  1787. } else {
  1788. // Browser globals.
  1789. root.Reveal = factory();
  1790. }
  1791. }( this, function() {
  1792. 'use strict';
  1793. var Reveal;
  1794. // The reveal.js version
  1795. var VERSION = '3.8.0';
  1796. var SLIDES_SELECTOR = '.slides section',
  1797. HORIZONTAL_SLIDES_SELECTOR = '.slides>section',
  1798. VERTICAL_SLIDES_SELECTOR = '.slides>section.present>section',
  1799. HOME_SLIDE_SELECTOR = '.slides>section:first-of-type',
  1800. UA = navigator.userAgent,
  1801. // Configuration defaults, can be overridden at initialization time
  1802. config = {
  1803. // The "normal" size of the presentation, aspect ratio will be preserved
  1804. // when the presentation is scaled to fit different resolutions
  1805. width: 960,
  1806. height: 700,
  1807. // Factor of the display size that should remain empty around the content
  1808. margin: 0.04,
  1809. // Bounds for smallest/largest possible scale to apply to content
  1810. minScale: 0.2,
  1811. maxScale: 2.0,
  1812. // Display presentation control arrows
  1813. controls: true,
  1814. // Help the user learn the controls by providing hints, for example by
  1815. // bouncing the down arrow when they first encounter a vertical slide
  1816. controlsTutorial: true,
  1817. // Determines where controls appear, "edges" or "bottom-right"
  1818. controlsLayout: 'bottom-right',
  1819. // Visibility rule for backwards navigation arrows; "faded", "hidden"
  1820. // or "visible"
  1821. controlsBackArrows: 'faded',
  1822. // Display a presentation progress bar
  1823. progress: true,
  1824. // Display the page number of the current slide
  1825. // - true: Show slide number
  1826. // - false: Hide slide number
  1827. //
  1828. // Can optionally be set as a string that specifies the number formatting:
  1829. // - "h.v": Horizontal . vertical slide number (default)
  1830. // - "h/v": Horizontal / vertical slide number
  1831. // - "c": Flattened slide number
  1832. // - "c/t": Flattened slide number / total slides
  1833. //
  1834. // Alternatively, you can provide a function that returns the slide
  1835. // number for the current slide. The function needs to return an array
  1836. // with one string [slideNumber] or three strings [n1,delimiter,n2].
  1837. // See #formatSlideNumber().
  1838. slideNumber: false,
  1839. // Can be used to limit the contexts in which the slide number appears
  1840. // - "all": Always show the slide number
  1841. // - "print": Only when printing to PDF
  1842. // - "speaker": Only in the speaker view
  1843. showSlideNumber: 'all',
  1844. // Use 1 based indexing for # links to match slide number (default is zero
  1845. // based)
  1846. hashOneBasedIndex: false,
  1847. // Add the current slide number to the URL hash so that reloading the
  1848. // page/copying the URL will return you to the same slide
  1849. hash: false,
  1850. // Push each slide change to the browser history. Implies `hash: true`
  1851. history: false,
  1852. // Enable keyboard shortcuts for navigation
  1853. keyboard: true,
  1854. // Optional function that blocks keyboard events when retuning false
  1855. keyboardCondition: null,
  1856. // Enable the slide overview mode
  1857. overview: true,
  1858. // Disables the default reveal.js slide layout so that you can use
  1859. // custom CSS layout
  1860. disableLayout: false,
  1861. // Vertical centering of slides
  1862. center: true,
  1863. // Enables touch navigation on devices with touch input
  1864. touch: true,
  1865. // Loop the presentation
  1866. loop: false,
  1867. // Change the presentation direction to be RTL
  1868. rtl: false,
  1869. // Changes the behavior of our navigation directions.
  1870. //
  1871. // "default"
  1872. // Left/right arrow keys step between horizontal slides, up/down
  1873. // arrow keys step between vertical slides. Space key steps through
  1874. // all slides (both horizontal and vertical).
  1875. //
  1876. // "linear"
  1877. // Removes the up/down arrows. Left/right arrows step through all
  1878. // slides (both horizontal and vertical).
  1879. //
  1880. // "grid"
  1881. // When this is enabled, stepping left/right from a vertical stack
  1882. // to an adjacent vertical stack will land you at the same vertical
  1883. // index.
  1884. //
  1885. // Consider a deck with six slides ordered in two vertical stacks:
  1886. // 1.1 2.1
  1887. // 1.2 2.2
  1888. // 1.3 2.3
  1889. //
  1890. // If you're on slide 1.3 and navigate right, you will normally move
  1891. // from 1.3 -> 2.1. If "grid" is used, the same navigation takes you
  1892. // from 1.3 -> 2.3.
  1893. navigationMode: 'default',
  1894. // Randomizes the order of slides each time the presentation loads
  1895. shuffle: false,
  1896. // Turns fragments on and off globally
  1897. fragments: true,
  1898. // Flags whether to include the current fragment in the URL,
  1899. // so that reloading brings you to the same fragment position
  1900. fragmentInURL: false,
  1901. // Flags if the presentation is running in an embedded mode,
  1902. // i.e. contained within a limited portion of the screen
  1903. embedded: false,
  1904. // Flags if we should show a help overlay when the question-mark
  1905. // key is pressed
  1906. help: true,
  1907. // Flags if it should be possible to pause the presentation (blackout)
  1908. pause: true,
  1909. // Flags if speaker notes should be visible to all viewers
  1910. showNotes: false,
  1911. // Global override for autolaying embedded media (video/audio/iframe)
  1912. // - null: Media will only autoplay if data-autoplay is present
  1913. // - true: All media will autoplay, regardless of individual setting
  1914. // - false: No media will autoplay, regardless of individual setting
  1915. autoPlayMedia: null,
  1916. // Global override for preloading lazy-loaded iframes
  1917. // - null: Iframes with data-src AND data-preload will be loaded when within
  1918. // the viewDistance, iframes with only data-src will be loaded when visible
  1919. // - true: All iframes with data-src will be loaded when within the viewDistance
  1920. // - false: All iframes with data-src will be loaded only when visible
  1921. preloadIframes: null,
  1922. // Controls automatic progression to the next slide
  1923. // - 0: Auto-sliding only happens if the data-autoslide HTML attribute
  1924. // is present on the current slide or fragment
  1925. // - 1+: All slides will progress automatically at the given interval
  1926. // - false: No auto-sliding, even if data-autoslide is present
  1927. autoSlide: 0,
  1928. // Stop auto-sliding after user input
  1929. autoSlideStoppable: true,
  1930. // Use this method for navigation when auto-sliding (defaults to navigateNext)
  1931. autoSlideMethod: null,
  1932. // Specify the average time in seconds that you think you will spend
  1933. // presenting each slide. This is used to show a pacing timer in the
  1934. // speaker view
  1935. defaultTiming: null,
  1936. // Enable slide navigation via mouse wheel
  1937. mouseWheel: false,
  1938. // Apply a 3D roll to links on hover
  1939. rollingLinks: false,
  1940. // Hides the address bar on mobile devices
  1941. hideAddressBar: true,
  1942. // Opens links in an iframe preview overlay
  1943. // Add `data-preview-link` and `data-preview-link="false"` to customise each link
  1944. // individually
  1945. previewLinks: false,
  1946. // Exposes the reveal.js API through window.postMessage
  1947. postMessage: true,
  1948. // Dispatches all reveal.js events to the parent window through postMessage
  1949. postMessageEvents: false,
  1950. // Focuses body when page changes visibility to ensure keyboard shortcuts work
  1951. focusBodyOnPageVisibilityChange: true,
  1952. // Transition style
  1953. transition: 'slide', // none/fade/slide/convex/concave/zoom
  1954. // Transition speed
  1955. transitionSpeed: 'default', // default/fast/slow
  1956. // Transition style for full page slide backgrounds
  1957. backgroundTransition: 'fade', // none/fade/slide/convex/concave/zoom
  1958. // Parallax background image
  1959. parallaxBackgroundImage: '', // CSS syntax, e.g. "a.jpg"
  1960. // Parallax background size
  1961. parallaxBackgroundSize: '', // CSS syntax, e.g. "3000px 2000px"
  1962. // Parallax background repeat
  1963. parallaxBackgroundRepeat: '', // repeat/repeat-x/repeat-y/no-repeat/initial/inherit
  1964. // Parallax background position
  1965. parallaxBackgroundPosition: '', // CSS syntax, e.g. "top left"
  1966. // Amount of pixels to move the parallax background per slide step
  1967. parallaxBackgroundHorizontal: null,
  1968. parallaxBackgroundVertical: null,
  1969. // The maximum number of pages a single slide can expand onto when printing
  1970. // to PDF, unlimited by default
  1971. pdfMaxPagesPerSlide: Number.POSITIVE_INFINITY,
  1972. // Prints each fragment on a separate slide
  1973. pdfSeparateFragments: true,
  1974. // Offset used to reduce the height of content within exported PDF pages.
  1975. // This exists to account for environment differences based on how you
  1976. // print to PDF. CLI printing options, like phantomjs and wkpdf, can end
  1977. // on precisely the total height of the document whereas in-browser
  1978. // printing has to end one pixel before.
  1979. pdfPageHeightOffset: -1,
  1980. // Number of slides away from the current that are visible
  1981. viewDistance: 3,
  1982. // The display mode that will be used to show slides
  1983. display: 'block',
  1984. // Hide cursor if inactive
  1985. hideInactiveCursor: true,
  1986. // Time before the cursor is hidden (in ms)
  1987. hideCursorTime: 5000,
  1988. // Script dependencies to load
  1989. dependencies: []
  1990. },
  1991. // Flags if Reveal.initialize() has been called
  1992. initialized = false,
  1993. // Flags if reveal.js is loaded (has dispatched the 'ready' event)
  1994. loaded = false,
  1995. // Flags if the overview mode is currently active
  1996. overview = false,
  1997. // Holds the dimensions of our overview slides, including margins
  1998. overviewSlideWidth = null,
  1999. overviewSlideHeight = null,
  2000. // The horizontal and vertical index of the currently active slide
  2001. indexh,
  2002. indexv,
  2003. // The previous and current slide HTML elements
  2004. previousSlide,
  2005. currentSlide,
  2006. previousBackground,
  2007. // Remember which directions that the user has navigated towards
  2008. hasNavigatedRight = false,
  2009. hasNavigatedDown = false,
  2010. // Slides may hold a data-state attribute which we pick up and apply
  2011. // as a class to the body. This list contains the combined state of
  2012. // all current slides.
  2013. state = [],
  2014. // The current scale of the presentation (see width/height config)
  2015. scale = 1,
  2016. // CSS transform that is currently applied to the slides container,
  2017. // split into two groups
  2018. slidesTransform = { layout: '', overview: '' },
  2019. // Cached references to DOM elements
  2020. dom = {},
  2021. // A list of registered reveal.js plugins
  2022. plugins = {},
  2023. // List of asynchronously loaded reveal.js dependencies
  2024. asyncDependencies = [],
  2025. // Features supported by the browser, see #checkCapabilities()
  2026. features = {},
  2027. // Client is a mobile device, see #checkCapabilities()
  2028. isMobileDevice,
  2029. // Client is a desktop Chrome, see #checkCapabilities()
  2030. isChrome,
  2031. // Throttles mouse wheel navigation
  2032. lastMouseWheelStep = 0,
  2033. // Delays updates to the URL due to a Chrome thumbnailer bug
  2034. writeURLTimeout = 0,
  2035. // Is the mouse pointer currently hidden from view
  2036. cursorHidden = false,
  2037. // Timeout used to determine when the cursor is inactive
  2038. cursorInactiveTimeout = 0,
  2039. // Flags if the interaction event listeners are bound
  2040. eventsAreBound = false,
  2041. // The current auto-slide duration
  2042. autoSlide = 0,
  2043. // Auto slide properties
  2044. autoSlidePlayer,
  2045. autoSlideTimeout = 0,
  2046. autoSlideStartTime = -1,
  2047. autoSlidePaused = false,
  2048. // Holds information about the currently ongoing touch input
  2049. touch = {
  2050. startX: 0,
  2051. startY: 0,
  2052. startCount: 0,
  2053. captured: false,
  2054. threshold: 40
  2055. },
  2056. // A key:value map of shortcut keyboard keys and descriptions of
  2057. // the actions they trigger, generated in #configure()
  2058. keyboardShortcuts = {},
  2059. // Holds custom key code mappings
  2060. registeredKeyBindings = {};
  2061. /**
  2062. * Starts up the presentation if the client is capable.
  2063. */
  2064. function initialize( options ) {
  2065. // Make sure we only initialize once
  2066. if( initialized === true ) return;
  2067. initialized = true;
  2068. checkCapabilities();
  2069. if( !features.transforms2d && !features.transforms3d ) {
  2070. document.body.setAttribute( 'class', 'no-transforms' );
  2071. // Since JS won't be running any further, we load all lazy
  2072. // loading elements upfront
  2073. var images = toArray( document.getElementsByTagName( 'img' ) ),
  2074. iframes = toArray( document.getElementsByTagName( 'iframe' ) );
  2075. var lazyLoadable = images.concat( iframes );
  2076. for( var i = 0, len = lazyLoadable.length; i < len; i++ ) {
  2077. var element = lazyLoadable[i];
  2078. if( element.getAttribute( 'data-src' ) ) {
  2079. element.setAttribute( 'src', element.getAttribute( 'data-src' ) );
  2080. element.removeAttribute( 'data-src' );
  2081. }
  2082. }
  2083. // If the browser doesn't support core features we won't be
  2084. // using JavaScript to control the presentation
  2085. return;
  2086. }
  2087. // Cache references to key DOM elements
  2088. dom.wrapper = document.querySelector( '.reveal' );
  2089. dom.slides = document.querySelector( '.reveal .slides' );
  2090. // Force a layout when the whole page, incl fonts, has loaded
  2091. window.addEventListener( 'load', layout, false );
  2092. var query = Reveal.getQueryHash();
  2093. // Do not accept new dependencies via query config to avoid
  2094. // the potential of malicious script injection
  2095. if( typeof query['dependencies'] !== 'undefined' ) delete query['dependencies'];
  2096. // Copy options over to our config object
  2097. extend( config, options );
  2098. extend( config, query );
  2099. // Hide the address bar in mobile browsers
  2100. hideAddressBar();
  2101. // Loads dependencies and continues to #start() once done
  2102. load();
  2103. }
  2104. /**
  2105. * Inspect the client to see what it's capable of, this
  2106. * should only happens once per runtime.
  2107. */
  2108. function checkCapabilities() {
  2109. isMobileDevice = /(iphone|ipod|ipad|android)/gi.test( UA );
  2110. isChrome = /chrome/i.test( UA ) && !/edge/i.test( UA );
  2111. var testElement = document.createElement( 'div' );
  2112. features.transforms3d = 'WebkitPerspective' in testElement.style ||
  2113. 'MozPerspective' in testElement.style ||
  2114. 'msPerspective' in testElement.style ||
  2115. 'OPerspective' in testElement.style ||
  2116. 'perspective' in testElement.style;
  2117. features.transforms2d = 'WebkitTransform' in testElement.style ||
  2118. 'MozTransform' in testElement.style ||
  2119. 'msTransform' in testElement.style ||
  2120. 'OTransform' in testElement.style ||
  2121. 'transform' in testElement.style;
  2122. features.requestAnimationFrameMethod = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
  2123. features.requestAnimationFrame = typeof features.requestAnimationFrameMethod === 'function';
  2124. features.canvas = !!document.createElement( 'canvas' ).getContext;
  2125. // Transitions in the overview are disabled in desktop and
  2126. // Safari due to lag
  2127. features.overviewTransitions = !/Version\/[\d\.]+.*Safari/.test( UA );
  2128. // Flags if we should use zoom instead of transform to scale
  2129. // up slides. Zoom produces crisper results but has a lot of
  2130. // xbrowser quirks so we only use it in whitelsited browsers.
  2131. features.zoom = 'zoom' in testElement.style && !isMobileDevice &&
  2132. ( isChrome || /Version\/[\d\.]+.*Safari/.test( UA ) );
  2133. }
  2134. /**
  2135. * Loads the dependencies of reveal.js. Dependencies are
  2136. * defined via the configuration option 'dependencies'
  2137. * and will be loaded prior to starting/binding reveal.js.
  2138. * Some dependencies may have an 'async' flag, if so they
  2139. * will load after reveal.js has been started up.
  2140. */
  2141. function load() {
  2142. var scripts = [],
  2143. scriptsToLoad = 0;
  2144. config.dependencies.forEach( function( s ) {
  2145. // Load if there's no condition or the condition is truthy
  2146. if( !s.condition || s.condition() ) {
  2147. if( s.async ) {
  2148. asyncDependencies.push( s );
  2149. }
  2150. else {
  2151. scripts.push( s );
  2152. }
  2153. }
  2154. } );
  2155. if( scripts.length ) {
  2156. scriptsToLoad = scripts.length;
  2157. // Load synchronous scripts
  2158. scripts.forEach( function( s ) {
  2159. loadScript( s.src, function() {
  2160. if( typeof s.callback === 'function' ) s.callback();
  2161. if( --scriptsToLoad === 0 ) {
  2162. initPlugins();
  2163. }
  2164. } );
  2165. } );
  2166. }
  2167. else {
  2168. initPlugins();
  2169. }
  2170. }
  2171. /**
  2172. * Initializes our plugins and waits for them to be ready
  2173. * before proceeding.
  2174. */
  2175. function initPlugins() {
  2176. var pluginsToInitialize = Object.keys( plugins ).length;
  2177. // If there are no plugins, skip this step
  2178. if( pluginsToInitialize === 0 ) {
  2179. loadAsyncDependencies();
  2180. }
  2181. // ... otherwise initialize plugins
  2182. else {
  2183. var afterPlugInitialized = function() {
  2184. if( --pluginsToInitialize === 0 ) {
  2185. loadAsyncDependencies();
  2186. }
  2187. };
  2188. for( var i in plugins ) {
  2189. var plugin = plugins[i];
  2190. // If the plugin has an 'init' method, invoke it
  2191. if( typeof plugin.init === 'function' ) {
  2192. var callback = plugin.init();
  2193. // If the plugin returned a Promise, wait for it
  2194. if( callback && typeof callback.then === 'function' ) {
  2195. callback.then( afterPlugInitialized );
  2196. }
  2197. else {
  2198. afterPlugInitialized();
  2199. }
  2200. }
  2201. else {
  2202. afterPlugInitialized();
  2203. }
  2204. }
  2205. }
  2206. }
  2207. /**
  2208. * Loads all async reveal.js dependencies.
  2209. */
  2210. function loadAsyncDependencies() {
  2211. if( asyncDependencies.length ) {
  2212. asyncDependencies.forEach( function( s ) {
  2213. loadScript( s.src, s.callback );
  2214. } );
  2215. }
  2216. start();
  2217. }
  2218. /**
  2219. * Loads a JavaScript file from the given URL and executes it.
  2220. *
  2221. * @param {string} url Address of the .js file to load
  2222. * @param {function} callback Method to invoke when the script
  2223. * has loaded and executed
  2224. */
  2225. function loadScript( url, callback ) {
  2226. var script = document.createElement( 'script' );
  2227. script.type = 'text/javascript';
  2228. script.async = false;
  2229. script.defer = false;
  2230. script.src = url;
  2231. if( callback ) {
  2232. // Success callback
  2233. script.onload = script.onreadystatechange = function( event ) {
  2234. if( event.type === "load" || (/loaded|complete/.test( script.readyState ) ) ) {
  2235. // Kill event listeners
  2236. script.onload = script.onreadystatechange = script.onerror = null;
  2237. callback();
  2238. }
  2239. };
  2240. // Error callback
  2241. script.onerror = function( err ) {
  2242. // Kill event listeners
  2243. script.onload = script.onreadystatechange = script.onerror = null;
  2244. callback( new Error( 'Failed loading script: ' + script.src + '\n' + err) );
  2245. };
  2246. }
  2247. // Append the script at the end of <head>
  2248. var head = document.querySelector( 'head' );
  2249. head.insertBefore( script, head.lastChild );
  2250. }
  2251. /**
  2252. * Starts up reveal.js by binding input events and navigating
  2253. * to the current URL deeplink if there is one.
  2254. */
  2255. function start() {
  2256. loaded = true;
  2257. // Make sure we've got all the DOM elements we need
  2258. setupDOM();
  2259. // Listen to messages posted to this window
  2260. setupPostMessage();
  2261. // Prevent the slides from being scrolled out of view
  2262. setupScrollPrevention();
  2263. // Resets all vertical slides so that only the first is visible
  2264. resetVerticalSlides();
  2265. // Updates the presentation to match the current configuration values
  2266. configure();
  2267. // Read the initial hash
  2268. readURL();
  2269. // Update all backgrounds
  2270. updateBackground( true );
  2271. // Notify listeners that the presentation is ready but use a 1ms
  2272. // timeout to ensure it's not fired synchronously after #initialize()
  2273. setTimeout( function() {
  2274. // Enable transitions now that we're loaded
  2275. dom.slides.classList.remove( 'no-transition' );
  2276. dom.wrapper.classList.add( 'ready' );
  2277. dispatchEvent( 'ready', {
  2278. 'indexh': indexh,
  2279. 'indexv': indexv,
  2280. 'currentSlide': currentSlide
  2281. } );
  2282. }, 1 );
  2283. // Special setup and config is required when printing to PDF
  2284. if( isPrintingPDF() ) {
  2285. removeEventListeners();
  2286. // The document needs to have loaded for the PDF layout
  2287. // measurements to be accurate
  2288. if( document.readyState === 'complete' ) {
  2289. setupPDF();
  2290. }
  2291. else {
  2292. window.addEventListener( 'load', setupPDF );
  2293. }
  2294. }
  2295. }
  2296. /**
  2297. * Finds and stores references to DOM elements which are
  2298. * required by the presentation. If a required element is
  2299. * not found, it is created.
  2300. */
  2301. function setupDOM() {
  2302. // Prevent transitions while we're loading
  2303. dom.slides.classList.add( 'no-transition' );
  2304. if( isMobileDevice ) {
  2305. dom.wrapper.classList.add( 'no-hover' );
  2306. }
  2307. else {
  2308. dom.wrapper.classList.remove( 'no-hover' );
  2309. }
  2310. if( /iphone/gi.test( UA ) ) {
  2311. dom.wrapper.classList.add( 'ua-iphone' );
  2312. }
  2313. else {
  2314. dom.wrapper.classList.remove( 'ua-iphone' );
  2315. }
  2316. // Background element
  2317. dom.background = createSingletonNode( dom.wrapper, 'div', 'backgrounds', null );
  2318. // Progress bar
  2319. dom.progress = createSingletonNode( dom.wrapper, 'div', 'progress', '<span></span>' );
  2320. dom.progressbar = dom.progress.querySelector( 'span' );
  2321. // Arrow controls
  2322. dom.controls = createSingletonNode( dom.wrapper, 'aside', 'controls',
  2323. '<button class="navigate-left" aria-label="previous slide"><div class="controls-arrow"></div></button>' +
  2324. '<button class="navigate-right" aria-label="next slide"><div class="controls-arrow"></div></button>' +
  2325. '<button class="navigate-up" aria-label="above slide"><div class="controls-arrow"></div></button>' +
  2326. '<button class="navigate-down" aria-label="below slide"><div class="controls-arrow"></div></button>' );
  2327. // Slide number
  2328. dom.slideNumber = createSingletonNode( dom.wrapper, 'div', 'slide-number', '' );
  2329. // Element containing notes that are visible to the audience
  2330. dom.speakerNotes = createSingletonNode( dom.wrapper, 'div', 'speaker-notes', null );
  2331. dom.speakerNotes.setAttribute( 'data-prevent-swipe', '' );
  2332. dom.speakerNotes.setAttribute( 'tabindex', '0' );
  2333. // Overlay graphic which is displayed during the paused mode
  2334. dom.pauseOverlay = createSingletonNode( dom.wrapper, 'div', 'pause-overlay', config.controls ? '<button class="resume-button">Resume presentation</button>' : null );
  2335. dom.wrapper.setAttribute( 'role', 'application' );
  2336. // There can be multiple instances of controls throughout the page
  2337. dom.controlsLeft = toArray( document.querySelectorAll( '.navigate-left' ) );
  2338. dom.controlsRight = toArray( document.querySelectorAll( '.navigate-right' ) );
  2339. dom.controlsUp = toArray( document.querySelectorAll( '.navigate-up' ) );
  2340. dom.controlsDown = toArray( document.querySelectorAll( '.navigate-down' ) );
  2341. dom.controlsPrev = toArray( document.querySelectorAll( '.navigate-prev' ) );
  2342. dom.controlsNext = toArray( document.querySelectorAll( '.navigate-next' ) );
  2343. // The right and down arrows in the standard reveal.js controls
  2344. dom.controlsRightArrow = dom.controls.querySelector( '.navigate-right' );
  2345. dom.controlsDownArrow = dom.controls.querySelector( '.navigate-down' );
  2346. dom.statusDiv = createStatusDiv();
  2347. }
  2348. /**
  2349. * Creates a hidden div with role aria-live to announce the
  2350. * current slide content. Hide the div off-screen to make it
  2351. * available only to Assistive Technologies.
  2352. *
  2353. * @return {HTMLElement}
  2354. */
  2355. function createStatusDiv() {
  2356. var statusDiv = document.getElementById( 'aria-status-div' );
  2357. if( !statusDiv ) {
  2358. statusDiv = document.createElement( 'div' );
  2359. statusDiv.style.position = 'absolute';
  2360. statusDiv.style.height = '1px';
  2361. statusDiv.style.width = '1px';
  2362. statusDiv.style.overflow = 'hidden';
  2363. statusDiv.style.clip = 'rect( 1px, 1px, 1px, 1px )';
  2364. statusDiv.setAttribute( 'id', 'aria-status-div' );
  2365. statusDiv.setAttribute( 'aria-live', 'polite' );
  2366. statusDiv.setAttribute( 'aria-atomic','true' );
  2367. dom.wrapper.appendChild( statusDiv );
  2368. }
  2369. return statusDiv;
  2370. }
  2371. /**
  2372. * Converts the given HTML element into a string of text
  2373. * that can be announced to a screen reader. Hidden
  2374. * elements are excluded.
  2375. */
  2376. function getStatusText( node ) {
  2377. var text = '';
  2378. // Text node
  2379. if( node.nodeType === 3 ) {
  2380. text += node.textContent;
  2381. }
  2382. // Element node
  2383. else if( node.nodeType === 1 ) {
  2384. var isAriaHidden = node.getAttribute( 'aria-hidden' );
  2385. var isDisplayHidden = window.getComputedStyle( node )['display'] === 'none';
  2386. if( isAriaHidden !== 'true' && !isDisplayHidden ) {
  2387. toArray( node.childNodes ).forEach( function( child ) {
  2388. text += getStatusText( child );
  2389. } );
  2390. }
  2391. }
  2392. return text;
  2393. }
  2394. /**
  2395. * Configures the presentation for printing to a static
  2396. * PDF.
  2397. */
  2398. function setupPDF() {
  2399. var slideSize = getComputedSlideSize( window.innerWidth, window.innerHeight );
  2400. // Dimensions of the PDF pages
  2401. var pageWidth = Math.floor( slideSize.width * ( 1 + config.margin ) ),
  2402. pageHeight = Math.floor( slideSize.height * ( 1 + config.margin ) );
  2403. // Dimensions of slides within the pages
  2404. var slideWidth = slideSize.width,
  2405. slideHeight = slideSize.height;
  2406. // Let the browser know what page size we want to print
  2407. injectStyleSheet( '@page{size:'+ pageWidth +'px '+ pageHeight +'px; margin: 0px;}' );
  2408. // Limit the size of certain elements to the dimensions of the slide
  2409. injectStyleSheet( '.reveal section>img, .reveal section>video, .reveal section>iframe{max-width: '+ slideWidth +'px; max-height:'+ slideHeight +'px}' );
  2410. document.body.classList.add( 'print-pdf' );
  2411. document.body.style.width = pageWidth + 'px';
  2412. document.body.style.height = pageHeight + 'px';
  2413. // Make sure stretch elements fit on slide
  2414. layoutSlideContents( slideWidth, slideHeight );
  2415. // Add each slide's index as attributes on itself, we need these
  2416. // indices to generate slide numbers below
  2417. toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).forEach( function( hslide, h ) {
  2418. hslide.setAttribute( 'data-index-h', h );
  2419. if( hslide.classList.contains( 'stack' ) ) {
  2420. toArray( hslide.querySelectorAll( 'section' ) ).forEach( function( vslide, v ) {
  2421. vslide.setAttribute( 'data-index-h', h );
  2422. vslide.setAttribute( 'data-index-v', v );
  2423. } );
  2424. }
  2425. } );
  2426. // Slide and slide background layout
  2427. toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) ).forEach( function( slide ) {
  2428. // Vertical stacks are not centred since their section
  2429. // children will be
  2430. if( slide.classList.contains( 'stack' ) === false ) {
  2431. // Center the slide inside of the page, giving the slide some margin
  2432. var left = ( pageWidth - slideWidth ) / 2,
  2433. top = ( pageHeight - slideHeight ) / 2;
  2434. var contentHeight = slide.scrollHeight;
  2435. var numberOfPages = Math.max( Math.ceil( contentHeight / pageHeight ), 1 );
  2436. // Adhere to configured pages per slide limit
  2437. numberOfPages = Math.min( numberOfPages, config.pdfMaxPagesPerSlide );
  2438. // Center slides vertically
  2439. if( numberOfPages === 1 && config.center || slide.classList.contains( 'center' ) ) {
  2440. top = Math.max( ( pageHeight - contentHeight ) / 2, 0 );
  2441. }
  2442. // Wrap the slide in a page element and hide its overflow
  2443. // so that no page ever flows onto another
  2444. var page = document.createElement( 'div' );
  2445. page.className = 'pdf-page';
  2446. page.style.height = ( ( pageHeight + config.pdfPageHeightOffset ) * numberOfPages ) + 'px';
  2447. slide.parentNode.insertBefore( page, slide );
  2448. page.appendChild( slide );
  2449. // Position the slide inside of the page
  2450. slide.style.left = left + 'px';
  2451. slide.style.top = top + 'px';
  2452. slide.style.width = slideWidth + 'px';
  2453. if( slide.slideBackgroundElement ) {
  2454. page.insertBefore( slide.slideBackgroundElement, slide );
  2455. }
  2456. // Inject notes if `showNotes` is enabled
  2457. if( config.showNotes ) {
  2458. // Are there notes for this slide?
  2459. var notes = getSlideNotes( slide );
  2460. if( notes ) {
  2461. var notesSpacing = 8;
  2462. var notesLayout = typeof config.showNotes === 'string' ? config.showNotes : 'inline';
  2463. var notesElement = document.createElement( 'div' );
  2464. notesElement.classList.add( 'speaker-notes' );
  2465. notesElement.classList.add( 'speaker-notes-pdf' );
  2466. notesElement.setAttribute( 'data-layout', notesLayout );
  2467. notesElement.innerHTML = notes;
  2468. if( notesLayout === 'separate-page' ) {
  2469. page.parentNode.insertBefore( notesElement, page.nextSibling );
  2470. }
  2471. else {
  2472. notesElement.style.left = notesSpacing + 'px';
  2473. notesElement.style.bottom = notesSpacing + 'px';
  2474. notesElement.style.width = ( pageWidth - notesSpacing*2 ) + 'px';
  2475. page.appendChild( notesElement );
  2476. }
  2477. }
  2478. }
  2479. // Inject slide numbers if `slideNumbers` are enabled
  2480. if( config.slideNumber && /all|print/i.test( config.showSlideNumber ) ) {
  2481. var slideNumberH = parseInt( slide.getAttribute( 'data-index-h' ), 10 ) + 1,
  2482. slideNumberV = parseInt( slide.getAttribute( 'data-index-v' ), 10 ) + 1;
  2483. var numberElement = document.createElement( 'div' );
  2484. numberElement.classList.add( 'slide-number' );
  2485. numberElement.classList.add( 'slide-number-pdf' );
  2486. numberElement.innerHTML = formatSlideNumber( slideNumberH, '.', slideNumberV );
  2487. page.appendChild( numberElement );
  2488. }
  2489. // Copy page and show fragments one after another
  2490. if( config.pdfSeparateFragments ) {
  2491. // Each fragment 'group' is an array containing one or more
  2492. // fragments. Multiple fragments that appear at the same time
  2493. // are part of the same group.
  2494. var fragmentGroups = sortFragments( page.querySelectorAll( '.fragment' ), true );
  2495. var previousFragmentStep;
  2496. var previousPage;
  2497. fragmentGroups.forEach( function( fragments ) {
  2498. // Remove 'current-fragment' from the previous group
  2499. if( previousFragmentStep ) {
  2500. previousFragmentStep.forEach( function( fragment ) {
  2501. fragment.classList.remove( 'current-fragment' );
  2502. } );
  2503. }
  2504. // Show the fragments for the current index
  2505. fragments.forEach( function( fragment ) {
  2506. fragment.classList.add( 'visible', 'current-fragment' );
  2507. } );
  2508. // Create a separate page for the current fragment state
  2509. var clonedPage = page.cloneNode( true );
  2510. page.parentNode.insertBefore( clonedPage, ( previousPage || page ).nextSibling );
  2511. previousFragmentStep = fragments;
  2512. previousPage = clonedPage;
  2513. } );
  2514. // Reset the first/original page so that all fragments are hidden
  2515. fragmentGroups.forEach( function( fragments ) {
  2516. fragments.forEach( function( fragment ) {
  2517. fragment.classList.remove( 'visible', 'current-fragment' );
  2518. } );
  2519. } );
  2520. }
  2521. // Show all fragments
  2522. else {
  2523. toArray( page.querySelectorAll( '.fragment:not(.fade-out)' ) ).forEach( function( fragment ) {
  2524. fragment.classList.add( 'visible' );
  2525. } );
  2526. }
  2527. }
  2528. } );
  2529. // Notify subscribers that the PDF layout is good to go
  2530. dispatchEvent( 'pdf-ready' );
  2531. }
  2532. /**
  2533. * This is an unfortunate necessity. Some actions – such as
  2534. * an input field being focused in an iframe or using the
  2535. * keyboard to expand text selection beyond the bounds of
  2536. * a slide – can trigger our content to be pushed out of view.
  2537. * This scrolling can not be prevented by hiding overflow in
  2538. * CSS (we already do) so we have to resort to repeatedly
  2539. * checking if the slides have been offset :(
  2540. */
  2541. function setupScrollPrevention() {
  2542. setInterval( function() {
  2543. if( dom.wrapper.scrollTop !== 0 || dom.wrapper.scrollLeft !== 0 ) {
  2544. dom.wrapper.scrollTop = 0;
  2545. dom.wrapper.scrollLeft = 0;
  2546. }
  2547. }, 1000 );
  2548. }
  2549. /**
  2550. * Creates an HTML element and returns a reference to it.
  2551. * If the element already exists the existing instance will
  2552. * be returned.
  2553. *
  2554. * @param {HTMLElement} container
  2555. * @param {string} tagname
  2556. * @param {string} classname
  2557. * @param {string} innerHTML
  2558. *
  2559. * @return {HTMLElement}
  2560. */
  2561. function createSingletonNode( container, tagname, classname, innerHTML ) {
  2562. // Find all nodes matching the description
  2563. var nodes = container.querySelectorAll( '.' + classname );
  2564. // Check all matches to find one which is a direct child of
  2565. // the specified container
  2566. for( var i = 0; i < nodes.length; i++ ) {
  2567. var testNode = nodes[i];
  2568. if( testNode.parentNode === container ) {
  2569. return testNode;
  2570. }
  2571. }
  2572. // If no node was found, create it now
  2573. var node = document.createElement( tagname );
  2574. node.className = classname;
  2575. if( typeof innerHTML === 'string' ) {
  2576. node.innerHTML = innerHTML;
  2577. }
  2578. container.appendChild( node );
  2579. return node;
  2580. }
  2581. /**
  2582. * Creates the slide background elements and appends them
  2583. * to the background container. One element is created per
  2584. * slide no matter if the given slide has visible background.
  2585. */
  2586. function createBackgrounds() {
  2587. var printMode = isPrintingPDF();
  2588. // Clear prior backgrounds
  2589. dom.background.innerHTML = '';
  2590. dom.background.classList.add( 'no-transition' );
  2591. // Iterate over all horizontal slides
  2592. toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).forEach( function( slideh ) {
  2593. var backgroundStack = createBackground( slideh, dom.background );
  2594. // Iterate over all vertical slides
  2595. toArray( slideh.querySelectorAll( 'section' ) ).forEach( function( slidev ) {
  2596. createBackground( slidev, backgroundStack );
  2597. backgroundStack.classList.add( 'stack' );
  2598. } );
  2599. } );
  2600. // Add parallax background if specified
  2601. if( config.parallaxBackgroundImage ) {
  2602. dom.background.style.backgroundImage = 'url("' + config.parallaxBackgroundImage + '")';
  2603. dom.background.style.backgroundSize = config.parallaxBackgroundSize;
  2604. dom.background.style.backgroundRepeat = config.parallaxBackgroundRepeat;
  2605. dom.background.style.backgroundPosition = config.parallaxBackgroundPosition;
  2606. // Make sure the below properties are set on the element - these properties are
  2607. // needed for proper transitions to be set on the element via CSS. To remove
  2608. // annoying background slide-in effect when the presentation starts, apply
  2609. // these properties after short time delay
  2610. setTimeout( function() {
  2611. dom.wrapper.classList.add( 'has-parallax-background' );
  2612. }, 1 );
  2613. }
  2614. else {
  2615. dom.background.style.backgroundImage = '';
  2616. dom.wrapper.classList.remove( 'has-parallax-background' );
  2617. }
  2618. }
  2619. /**
  2620. * Creates a background for the given slide.
  2621. *
  2622. * @param {HTMLElement} slide
  2623. * @param {HTMLElement} container The element that the background
  2624. * should be appended to
  2625. * @return {HTMLElement} New background div
  2626. */
  2627. function createBackground( slide, container ) {
  2628. // Main slide background element
  2629. var element = document.createElement( 'div' );
  2630. element.className = 'slide-background ' + slide.className.replace( /present|past|future/, '' );
  2631. // Inner background element that wraps images/videos/iframes
  2632. var contentElement = document.createElement( 'div' );
  2633. contentElement.className = 'slide-background-content';
  2634. element.appendChild( contentElement );
  2635. container.appendChild( element );
  2636. slide.slideBackgroundElement = element;
  2637. slide.slideBackgroundContentElement = contentElement;
  2638. // Syncs the background to reflect all current background settings
  2639. syncBackground( slide );
  2640. return element;
  2641. }
  2642. /**
  2643. * Renders all of the visual properties of a slide background
  2644. * based on the various background attributes.
  2645. *
  2646. * @param {HTMLElement} slide
  2647. */
  2648. function syncBackground( slide ) {
  2649. var element = slide.slideBackgroundElement,
  2650. contentElement = slide.slideBackgroundContentElement;
  2651. // Reset the prior background state in case this is not the
  2652. // initial sync
  2653. slide.classList.remove( 'has-dark-background' );
  2654. slide.classList.remove( 'has-light-background' );
  2655. element.removeAttribute( 'data-loaded' );
  2656. element.removeAttribute( 'data-background-hash' );
  2657. element.removeAttribute( 'data-background-size' );
  2658. element.removeAttribute( 'data-background-transition' );
  2659. element.style.backgroundColor = '';
  2660. contentElement.style.backgroundSize = '';
  2661. contentElement.style.backgroundRepeat = '';
  2662. contentElement.style.backgroundPosition = '';
  2663. contentElement.style.backgroundImage = '';
  2664. contentElement.style.opacity = '';
  2665. contentElement.innerHTML = '';
  2666. var data = {
  2667. background: slide.getAttribute( 'data-background' ),
  2668. backgroundSize: slide.getAttribute( 'data-background-size' ),
  2669. backgroundImage: slide.getAttribute( 'data-background-image' ),
  2670. backgroundVideo: slide.getAttribute( 'data-background-video' ),
  2671. backgroundIframe: slide.getAttribute( 'data-background-iframe' ),
  2672. backgroundColor: slide.getAttribute( 'data-background-color' ),
  2673. backgroundRepeat: slide.getAttribute( 'data-background-repeat' ),
  2674. backgroundPosition: slide.getAttribute( 'data-background-position' ),
  2675. backgroundTransition: slide.getAttribute( 'data-background-transition' ),
  2676. backgroundOpacity: slide.getAttribute( 'data-background-opacity' )
  2677. };
  2678. if( data.background ) {
  2679. // Auto-wrap image urls in url(...)
  2680. if( /^(http|file|\/\/)/gi.test( data.background ) || /\.(svg|png|jpg|jpeg|gif|bmp)([?#\s]|$)/gi.test( data.background ) ) {
  2681. slide.setAttribute( 'data-background-image', data.background );
  2682. }
  2683. else {
  2684. element.style.background = data.background;
  2685. }
  2686. }
  2687. // Create a hash for this combination of background settings.
  2688. // This is used to determine when two slide backgrounds are
  2689. // the same.
  2690. if( data.background || data.backgroundColor || data.backgroundImage || data.backgroundVideo || data.backgroundIframe ) {
  2691. element.setAttribute( 'data-background-hash', data.background +
  2692. data.backgroundSize +
  2693. data.backgroundImage +
  2694. data.backgroundVideo +
  2695. data.backgroundIframe +
  2696. data.backgroundColor +
  2697. data.backgroundRepeat +
  2698. data.backgroundPosition +
  2699. data.backgroundTransition +
  2700. data.backgroundOpacity );
  2701. }
  2702. // Additional and optional background properties
  2703. if( data.backgroundSize ) element.setAttribute( 'data-background-size', data.backgroundSize );
  2704. if( data.backgroundColor ) element.style.backgroundColor = data.backgroundColor;
  2705. if( data.backgroundTransition ) element.setAttribute( 'data-background-transition', data.backgroundTransition );
  2706. // Background image options are set on the content wrapper
  2707. if( data.backgroundSize ) contentElement.style.backgroundSize = data.backgroundSize;
  2708. if( data.backgroundRepeat ) contentElement.style.backgroundRepeat = data.backgroundRepeat;
  2709. if( data.backgroundPosition ) contentElement.style.backgroundPosition = data.backgroundPosition;
  2710. if( data.backgroundOpacity ) contentElement.style.opacity = data.backgroundOpacity;
  2711. // If this slide has a background color, we add a class that
  2712. // signals if it is light or dark. If the slide has no background
  2713. // color, no class will be added
  2714. var contrastColor = data.backgroundColor;
  2715. // If no bg color was found, check the computed background
  2716. if( !contrastColor ) {
  2717. var computedBackgroundStyle = window.getComputedStyle( element );
  2718. if( computedBackgroundStyle && computedBackgroundStyle.backgroundColor ) {
  2719. contrastColor = computedBackgroundStyle.backgroundColor;
  2720. }
  2721. }
  2722. if( contrastColor ) {
  2723. var rgb = colorToRgb( contrastColor );
  2724. // Ignore fully transparent backgrounds. Some browsers return
  2725. // rgba(0,0,0,0) when reading the computed background color of
  2726. // an element with no background
  2727. if( rgb && rgb.a !== 0 ) {
  2728. if( colorBrightness( contrastColor ) < 128 ) {
  2729. slide.classList.add( 'has-dark-background' );
  2730. }
  2731. else {
  2732. slide.classList.add( 'has-light-background' );
  2733. }
  2734. }
  2735. }
  2736. }
  2737. /**
  2738. * Registers a listener to postMessage events, this makes it
  2739. * possible to call all reveal.js API methods from another
  2740. * window. For example:
  2741. *
  2742. * revealWindow.postMessage( JSON.stringify({
  2743. * method: 'slide',
  2744. * args: [ 2 ]
  2745. * }), '*' );
  2746. */
  2747. function setupPostMessage() {
  2748. if( config.postMessage ) {
  2749. window.addEventListener( 'message', function ( event ) {
  2750. var data = event.data;
  2751. // Make sure we're dealing with JSON
  2752. if( typeof data === 'string' && data.charAt( 0 ) === '{' && data.charAt( data.length - 1 ) === '}' ) {
  2753. data = JSON.parse( data );
  2754. // Check if the requested method can be found
  2755. if( data.method && typeof Reveal[data.method] === 'function' ) {
  2756. Reveal[data.method].apply( Reveal, data.args );
  2757. }
  2758. }
  2759. }, false );
  2760. }
  2761. }
  2762. /**
  2763. * Applies the configuration settings from the config
  2764. * object. May be called multiple times.
  2765. *
  2766. * @param {object} options
  2767. */
  2768. function configure( options ) {
  2769. var oldTransition = config.transition;
  2770. // New config options may be passed when this method
  2771. // is invoked through the API after initialization
  2772. if( typeof options === 'object' ) extend( config, options );
  2773. // Abort if reveal.js hasn't finished loading, config
  2774. // changes will be applied automatically once loading
  2775. // finishes
  2776. if( loaded === false ) return;
  2777. var numberOfSlides = dom.wrapper.querySelectorAll( SLIDES_SELECTOR ).length;
  2778. // Remove the previously configured transition class
  2779. dom.wrapper.classList.remove( oldTransition );
  2780. // Force linear transition based on browser capabilities
  2781. if( features.transforms3d === false ) config.transition = 'linear';
  2782. dom.wrapper.classList.add( config.transition );
  2783. dom.wrapper.setAttribute( 'data-transition-speed', config.transitionSpeed );
  2784. dom.wrapper.setAttribute( 'data-background-transition', config.backgroundTransition );
  2785. dom.controls.style.display = config.controls ? 'block' : 'none';
  2786. dom.progress.style.display = config.progress ? 'block' : 'none';
  2787. dom.controls.setAttribute( 'data-controls-layout', config.controlsLayout );
  2788. dom.controls.setAttribute( 'data-controls-back-arrows', config.controlsBackArrows );
  2789. if( config.shuffle ) {
  2790. shuffle();
  2791. }
  2792. if( config.rtl ) {
  2793. dom.wrapper.classList.add( 'rtl' );
  2794. }
  2795. else {
  2796. dom.wrapper.classList.remove( 'rtl' );
  2797. }
  2798. if( config.center ) {
  2799. dom.wrapper.classList.add( 'center' );
  2800. }
  2801. else {
  2802. dom.wrapper.classList.remove( 'center' );
  2803. }
  2804. // Exit the paused mode if it was configured off
  2805. if( config.pause === false ) {
  2806. resume();
  2807. }
  2808. if( config.showNotes ) {
  2809. dom.speakerNotes.setAttribute( 'data-layout', typeof config.showNotes === 'string' ? config.showNotes : 'inline' );
  2810. }
  2811. if( config.mouseWheel ) {
  2812. document.addEventListener( 'DOMMouseScroll', onDocumentMouseScroll, false ); // FF
  2813. document.addEventListener( 'mousewheel', onDocumentMouseScroll, false );
  2814. }
  2815. else {
  2816. document.removeEventListener( 'DOMMouseScroll', onDocumentMouseScroll, false ); // FF
  2817. document.removeEventListener( 'mousewheel', onDocumentMouseScroll, false );
  2818. }
  2819. // Rolling 3D links
  2820. if( config.rollingLinks ) {
  2821. enableRollingLinks();
  2822. }
  2823. else {
  2824. disableRollingLinks();
  2825. }
  2826. // Auto-hide the mouse pointer when its inactive
  2827. if( config.hideInactiveCursor ) {
  2828. document.addEventListener( 'mousemove', onDocumentCursorActive, false );
  2829. document.addEventListener( 'mousedown', onDocumentCursorActive, false );
  2830. }
  2831. else {
  2832. showCursor();
  2833. document.removeEventListener( 'mousemove', onDocumentCursorActive, false );
  2834. document.removeEventListener( 'mousedown', onDocumentCursorActive, false );
  2835. }
  2836. // Iframe link previews
  2837. if( config.previewLinks ) {
  2838. enablePreviewLinks();
  2839. disablePreviewLinks( '[data-preview-link=false]' );
  2840. }
  2841. else {
  2842. disablePreviewLinks();
  2843. enablePreviewLinks( '[data-preview-link]:not([data-preview-link=false])' );
  2844. }
  2845. // Remove existing auto-slide controls
  2846. if( autoSlidePlayer ) {
  2847. autoSlidePlayer.destroy();
  2848. autoSlidePlayer = null;
  2849. }
  2850. // Generate auto-slide controls if needed
  2851. if( numberOfSlides > 1 && config.autoSlide && config.autoSlideStoppable && features.canvas && features.requestAnimationFrame ) {
  2852. autoSlidePlayer = new Playback( dom.wrapper, function() {
  2853. return Math.min( Math.max( ( Date.now() - autoSlideStartTime ) / autoSlide, 0 ), 1 );
  2854. } );
  2855. autoSlidePlayer.on( 'click', onAutoSlidePlayerClick );
  2856. autoSlidePaused = false;
  2857. }
  2858. // When fragments are turned off they should be visible
  2859. if( config.fragments === false ) {
  2860. toArray( dom.slides.querySelectorAll( '.fragment' ) ).forEach( function( element ) {
  2861. element.classList.add( 'visible' );
  2862. element.classList.remove( 'current-fragment' );
  2863. } );
  2864. }
  2865. // Slide numbers
  2866. var slideNumberDisplay = 'none';
  2867. if( config.slideNumber && !isPrintingPDF() ) {
  2868. if( config.showSlideNumber === 'all' ) {
  2869. slideNumberDisplay = 'block';
  2870. }
  2871. else if( config.showSlideNumber === 'speaker' && isSpeakerNotes() ) {
  2872. slideNumberDisplay = 'block';
  2873. }
  2874. }
  2875. dom.slideNumber.style.display = slideNumberDisplay;
  2876. // Add the navigation mode to the DOM so we can adjust styling
  2877. if( config.navigationMode !== 'default' ) {
  2878. dom.wrapper.setAttribute( 'data-navigation-mode', config.navigationMode );
  2879. }
  2880. else {
  2881. dom.wrapper.removeAttribute( 'data-navigation-mode' );
  2882. }
  2883. // Define our contextual list of keyboard shortcuts
  2884. if( config.navigationMode === 'linear' ) {
  2885. keyboardShortcuts['&#8594; , &#8595; , SPACE , N , L , J'] = 'Next slide';
  2886. keyboardShortcuts['&#8592; , &#8593; , P , H , K'] = 'Previous slide';
  2887. }
  2888. else {
  2889. keyboardShortcuts['N , SPACE'] = 'Next slide';
  2890. keyboardShortcuts['P'] = 'Previous slide';
  2891. keyboardShortcuts['&#8592; , H'] = 'Navigate left';
  2892. keyboardShortcuts['&#8594; , L'] = 'Navigate right';
  2893. keyboardShortcuts['&#8593; , K'] = 'Navigate up';
  2894. keyboardShortcuts['&#8595; , J'] = 'Navigate down';
  2895. }
  2896. keyboardShortcuts['Home , &#8984;/CTRL &#8592;'] = 'First slide';
  2897. keyboardShortcuts['End , &#8984;/CTRL &#8594;'] = 'Last slide';
  2898. keyboardShortcuts['B , .'] = 'Pause';
  2899. keyboardShortcuts['F'] = 'Fullscreen';
  2900. keyboardShortcuts['ESC, O'] = 'Slide overview';
  2901. sync();
  2902. }
  2903. /**
  2904. * Binds all event listeners.
  2905. */
  2906. function addEventListeners() {
  2907. eventsAreBound = true;
  2908. window.addEventListener( 'hashchange', onWindowHashChange, false );
  2909. window.addEventListener( 'resize', onWindowResize, false );
  2910. if( config.touch ) {
  2911. if( 'onpointerdown' in window ) {
  2912. // Use W3C pointer events
  2913. dom.wrapper.addEventListener( 'pointerdown', onPointerDown, false );
  2914. dom.wrapper.addEventListener( 'pointermove', onPointerMove, false );
  2915. dom.wrapper.addEventListener( 'pointerup', onPointerUp, false );
  2916. }
  2917. else if( window.navigator.msPointerEnabled ) {
  2918. // IE 10 uses prefixed version of pointer events
  2919. dom.wrapper.addEventListener( 'MSPointerDown', onPointerDown, false );
  2920. dom.wrapper.addEventListener( 'MSPointerMove', onPointerMove, false );
  2921. dom.wrapper.addEventListener( 'MSPointerUp', onPointerUp, false );
  2922. }
  2923. else {
  2924. // Fall back to touch events
  2925. dom.wrapper.addEventListener( 'touchstart', onTouchStart, false );
  2926. dom.wrapper.addEventListener( 'touchmove', onTouchMove, false );
  2927. dom.wrapper.addEventListener( 'touchend', onTouchEnd, false );
  2928. }
  2929. }
  2930. if( config.keyboard ) {
  2931. document.addEventListener( 'keydown', onDocumentKeyDown, false );
  2932. document.addEventListener( 'keypress', onDocumentKeyPress, false );
  2933. }
  2934. if( config.progress && dom.progress ) {
  2935. dom.progress.addEventListener( 'click', onProgressClicked, false );
  2936. }
  2937. dom.pauseOverlay.addEventListener( 'click', resume, false );
  2938. if( config.focusBodyOnPageVisibilityChange ) {
  2939. var visibilityChange;
  2940. if( 'hidden' in document ) {
  2941. visibilityChange = 'visibilitychange';
  2942. }
  2943. else if( 'msHidden' in document ) {
  2944. visibilityChange = 'msvisibilitychange';
  2945. }
  2946. else if( 'webkitHidden' in document ) {
  2947. visibilityChange = 'webkitvisibilitychange';
  2948. }
  2949. if( visibilityChange ) {
  2950. document.addEventListener( visibilityChange, onPageVisibilityChange, false );
  2951. }
  2952. }
  2953. // Listen to both touch and click events, in case the device
  2954. // supports both
  2955. var pointerEvents = [ 'touchstart', 'click' ];
  2956. // Only support touch for Android, fixes double navigations in
  2957. // stock browser
  2958. if( UA.match( /android/gi ) ) {
  2959. pointerEvents = [ 'touchstart' ];
  2960. }
  2961. pointerEvents.forEach( function( eventName ) {
  2962. dom.controlsLeft.forEach( function( el ) { el.addEventListener( eventName, onNavigateLeftClicked, false ); } );
  2963. dom.controlsRight.forEach( function( el ) { el.addEventListener( eventName, onNavigateRightClicked, false ); } );
  2964. dom.controlsUp.forEach( function( el ) { el.addEventListener( eventName, onNavigateUpClicked, false ); } );
  2965. dom.controlsDown.forEach( function( el ) { el.addEventListener( eventName, onNavigateDownClicked, false ); } );
  2966. dom.controlsPrev.forEach( function( el ) { el.addEventListener( eventName, onNavigatePrevClicked, false ); } );
  2967. dom.controlsNext.forEach( function( el ) { el.addEventListener( eventName, onNavigateNextClicked, false ); } );
  2968. } );
  2969. }
  2970. /**
  2971. * Unbinds all event listeners.
  2972. */
  2973. function removeEventListeners() {
  2974. eventsAreBound = false;
  2975. document.removeEventListener( 'keydown', onDocumentKeyDown, false );
  2976. document.removeEventListener( 'keypress', onDocumentKeyPress, false );
  2977. window.removeEventListener( 'hashchange', onWindowHashChange, false );
  2978. window.removeEventListener( 'resize', onWindowResize, false );
  2979. dom.wrapper.removeEventListener( 'pointerdown', onPointerDown, false );
  2980. dom.wrapper.removeEventListener( 'pointermove', onPointerMove, false );
  2981. dom.wrapper.removeEventListener( 'pointerup', onPointerUp, false );
  2982. dom.wrapper.removeEventListener( 'MSPointerDown', onPointerDown, false );
  2983. dom.wrapper.removeEventListener( 'MSPointerMove', onPointerMove, false );
  2984. dom.wrapper.removeEventListener( 'MSPointerUp', onPointerUp, false );
  2985. dom.wrapper.removeEventListener( 'touchstart', onTouchStart, false );
  2986. dom.wrapper.removeEventListener( 'touchmove', onTouchMove, false );
  2987. dom.wrapper.removeEventListener( 'touchend', onTouchEnd, false );
  2988. dom.pauseOverlay.removeEventListener( 'click', resume, false );
  2989. if ( config.progress && dom.progress ) {
  2990. dom.progress.removeEventListener( 'click', onProgressClicked, false );
  2991. }
  2992. [ 'touchstart', 'click' ].forEach( function( eventName ) {
  2993. dom.controlsLeft.forEach( function( el ) { el.removeEventListener( eventName, onNavigateLeftClicked, false ); } );
  2994. dom.controlsRight.forEach( function( el ) { el.removeEventListener( eventName, onNavigateRightClicked, false ); } );
  2995. dom.controlsUp.forEach( function( el ) { el.removeEventListener( eventName, onNavigateUpClicked, false ); } );
  2996. dom.controlsDown.forEach( function( el ) { el.removeEventListener( eventName, onNavigateDownClicked, false ); } );
  2997. dom.controlsPrev.forEach( function( el ) { el.removeEventListener( eventName, onNavigatePrevClicked, false ); } );
  2998. dom.controlsNext.forEach( function( el ) { el.removeEventListener( eventName, onNavigateNextClicked, false ); } );
  2999. } );
  3000. }
  3001. /**
  3002. * Registers a new plugin with this reveal.js instance.
  3003. *
  3004. * reveal.js waits for all regisered plugins to initialize
  3005. * before considering itself ready, as long as the plugin
  3006. * is registered before calling `Reveal.initialize()`.
  3007. */
  3008. function registerPlugin( id, plugin ) {
  3009. if( plugins[id] === undefined ) {
  3010. plugins[id] = plugin;
  3011. // If a plugin is registered after reveal.js is loaded,
  3012. // initialize it right away
  3013. if( loaded && typeof plugin.init === 'function' ) {
  3014. plugin.init();
  3015. }
  3016. }
  3017. else {
  3018. console.warn( 'reveal.js: "'+ id +'" plugin has already been registered' );
  3019. }
  3020. }
  3021. /**
  3022. * Checks if a specific plugin has been registered.
  3023. *
  3024. * @param {String} id Unique plugin identifier
  3025. */
  3026. function hasPlugin( id ) {
  3027. return !!plugins[id];
  3028. }
  3029. /**
  3030. * Returns the specific plugin instance, if a plugin
  3031. * with the given ID has been registered.
  3032. *
  3033. * @param {String} id Unique plugin identifier
  3034. */
  3035. function getPlugin( id ) {
  3036. return plugins[id];
  3037. }
  3038. /**
  3039. * Add a custom key binding with optional description to
  3040. * be added to the help screen.
  3041. */
  3042. function addKeyBinding( binding, callback ) {
  3043. if( typeof binding === 'object' && binding.keyCode ) {
  3044. registeredKeyBindings[binding.keyCode] = {
  3045. callback: callback,
  3046. key: binding.key,
  3047. description: binding.description
  3048. };
  3049. }
  3050. else {
  3051. registeredKeyBindings[binding] = {
  3052. callback: callback,
  3053. key: null,
  3054. description: null
  3055. };
  3056. }
  3057. }
  3058. /**
  3059. * Removes the specified custom key binding.
  3060. */
  3061. function removeKeyBinding( keyCode ) {
  3062. delete registeredKeyBindings[keyCode];
  3063. }
  3064. /**
  3065. * Extend object a with the properties of object b.
  3066. * If there's a conflict, object b takes precedence.
  3067. *
  3068. * @param {object} a
  3069. * @param {object} b
  3070. */
  3071. function extend( a, b ) {
  3072. for( var i in b ) {
  3073. a[ i ] = b[ i ];
  3074. }
  3075. return a;
  3076. }
  3077. /**
  3078. * Converts the target object to an array.
  3079. *
  3080. * @param {object} o
  3081. * @return {object[]}
  3082. */
  3083. function toArray( o ) {
  3084. return Array.prototype.slice.call( o );
  3085. }
  3086. /**
  3087. * Utility for deserializing a value.
  3088. *
  3089. * @param {*} value
  3090. * @return {*}
  3091. */
  3092. function deserialize( value ) {
  3093. if( typeof value === 'string' ) {
  3094. if( value === 'null' ) return null;
  3095. else if( value === 'true' ) return true;
  3096. else if( value === 'false' ) return false;
  3097. else if( value.match( /^-?[\d\.]+$/ ) ) return parseFloat( value );
  3098. }
  3099. return value;
  3100. }
  3101. /**
  3102. * Measures the distance in pixels between point a
  3103. * and point b.
  3104. *
  3105. * @param {object} a point with x/y properties
  3106. * @param {object} b point with x/y properties
  3107. *
  3108. * @return {number}
  3109. */
  3110. function distanceBetween( a, b ) {
  3111. var dx = a.x - b.x,
  3112. dy = a.y - b.y;
  3113. return Math.sqrt( dx*dx + dy*dy );
  3114. }
  3115. /**
  3116. * Applies a CSS transform to the target element.
  3117. *
  3118. * @param {HTMLElement} element
  3119. * @param {string} transform
  3120. */
  3121. function transformElement( element, transform ) {
  3122. element.style.WebkitTransform = transform;
  3123. element.style.MozTransform = transform;
  3124. element.style.msTransform = transform;
  3125. element.style.transform = transform;
  3126. }
  3127. /**
  3128. * Applies CSS transforms to the slides container. The container
  3129. * is transformed from two separate sources: layout and the overview
  3130. * mode.
  3131. *
  3132. * @param {object} transforms
  3133. */
  3134. function transformSlides( transforms ) {
  3135. // Pick up new transforms from arguments
  3136. if( typeof transforms.layout === 'string' ) slidesTransform.layout = transforms.layout;
  3137. if( typeof transforms.overview === 'string' ) slidesTransform.overview = transforms.overview;
  3138. // Apply the transforms to the slides container
  3139. if( slidesTransform.layout ) {
  3140. transformElement( dom.slides, slidesTransform.layout + ' ' + slidesTransform.overview );
  3141. }
  3142. else {
  3143. transformElement( dom.slides, slidesTransform.overview );
  3144. }
  3145. }
  3146. /**
  3147. * Injects the given CSS styles into the DOM.
  3148. *
  3149. * @param {string} value
  3150. */
  3151. function injectStyleSheet( value ) {
  3152. var tag = document.createElement( 'style' );
  3153. tag.type = 'text/css';
  3154. if( tag.styleSheet ) {
  3155. tag.styleSheet.cssText = value;
  3156. }
  3157. else {
  3158. tag.appendChild( document.createTextNode( value ) );
  3159. }
  3160. document.getElementsByTagName( 'head' )[0].appendChild( tag );
  3161. }
  3162. /**
  3163. * Find the closest parent that matches the given
  3164. * selector.
  3165. *
  3166. * @param {HTMLElement} target The child element
  3167. * @param {String} selector The CSS selector to match
  3168. * the parents against
  3169. *
  3170. * @return {HTMLElement} The matched parent or null
  3171. * if no matching parent was found
  3172. */
  3173. function closestParent( target, selector ) {
  3174. var parent = target.parentNode;
  3175. while( parent ) {
  3176. // There's some overhead doing this each time, we don't
  3177. // want to rewrite the element prototype but should still
  3178. // be enough to feature detect once at startup...
  3179. var matchesMethod = parent.matches || parent.matchesSelector || parent.msMatchesSelector;
  3180. // If we find a match, we're all set
  3181. if( matchesMethod && matchesMethod.call( parent, selector ) ) {
  3182. return parent;
  3183. }
  3184. // Keep searching
  3185. parent = parent.parentNode;
  3186. }
  3187. return null;
  3188. }
  3189. /**
  3190. * Converts various color input formats to an {r:0,g:0,b:0} object.
  3191. *
  3192. * @param {string} color The string representation of a color
  3193. * @example
  3194. * colorToRgb('#000');
  3195. * @example
  3196. * colorToRgb('#000000');
  3197. * @example
  3198. * colorToRgb('rgb(0,0,0)');
  3199. * @example
  3200. * colorToRgb('rgba(0,0,0)');
  3201. *
  3202. * @return {{r: number, g: number, b: number, [a]: number}|null}
  3203. */
  3204. function colorToRgb( color ) {
  3205. var hex3 = color.match( /^#([0-9a-f]{3})$/i );
  3206. if( hex3 && hex3[1] ) {
  3207. hex3 = hex3[1];
  3208. return {
  3209. r: parseInt( hex3.charAt( 0 ), 16 ) * 0x11,
  3210. g: parseInt( hex3.charAt( 1 ), 16 ) * 0x11,
  3211. b: parseInt( hex3.charAt( 2 ), 16 ) * 0x11
  3212. };
  3213. }
  3214. var hex6 = color.match( /^#([0-9a-f]{6})$/i );
  3215. if( hex6 && hex6[1] ) {
  3216. hex6 = hex6[1];
  3217. return {
  3218. r: parseInt( hex6.substr( 0, 2 ), 16 ),
  3219. g: parseInt( hex6.substr( 2, 2 ), 16 ),
  3220. b: parseInt( hex6.substr( 4, 2 ), 16 )
  3221. };
  3222. }
  3223. var rgb = color.match( /^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i );
  3224. if( rgb ) {
  3225. return {
  3226. r: parseInt( rgb[1], 10 ),
  3227. g: parseInt( rgb[2], 10 ),
  3228. b: parseInt( rgb[3], 10 )
  3229. };
  3230. }
  3231. var rgba = color.match( /^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\,\s*([\d]+|[\d]*.[\d]+)\s*\)$/i );
  3232. if( rgba ) {
  3233. return {
  3234. r: parseInt( rgba[1], 10 ),
  3235. g: parseInt( rgba[2], 10 ),
  3236. b: parseInt( rgba[3], 10 ),
  3237. a: parseFloat( rgba[4] )
  3238. };
  3239. }
  3240. return null;
  3241. }
  3242. /**
  3243. * Calculates brightness on a scale of 0-255.
  3244. *
  3245. * @param {string} color See colorToRgb for supported formats.
  3246. * @see {@link colorToRgb}
  3247. */
  3248. function colorBrightness( color ) {
  3249. if( typeof color === 'string' ) color = colorToRgb( color );
  3250. if( color ) {
  3251. return ( color.r * 299 + color.g * 587 + color.b * 114 ) / 1000;
  3252. }
  3253. return null;
  3254. }
  3255. /**
  3256. * Returns the remaining height within the parent of the
  3257. * target element.
  3258. *
  3259. * remaining height = [ configured parent height ] - [ current parent height ]
  3260. *
  3261. * @param {HTMLElement} element
  3262. * @param {number} [height]
  3263. */
  3264. function getRemainingHeight( element, height ) {
  3265. height = height || 0;
  3266. if( element ) {
  3267. var newHeight, oldHeight = element.style.height;
  3268. // Change the .stretch element height to 0 in order find the height of all
  3269. // the other elements
  3270. element.style.height = '0px';
  3271. // In Overview mode, the parent (.slide) height is set of 700px.
  3272. // Restore it temporarily to its natural height.
  3273. element.parentNode.style.height = 'auto';
  3274. newHeight = height - element.parentNode.offsetHeight;
  3275. // Restore the old height, just in case
  3276. element.style.height = oldHeight + 'px';
  3277. // Clear the parent (.slide) height. .removeProperty works in IE9+
  3278. element.parentNode.style.removeProperty('height');
  3279. return newHeight;
  3280. }
  3281. return height;
  3282. }
  3283. /**
  3284. * Checks if this instance is being used to print a PDF.
  3285. */
  3286. function isPrintingPDF() {
  3287. return ( /print-pdf/gi ).test( window.location.search );
  3288. }
  3289. /**
  3290. * Hides the address bar if we're on a mobile device.
  3291. */
  3292. function hideAddressBar() {
  3293. if( config.hideAddressBar && isMobileDevice ) {
  3294. // Events that should trigger the address bar to hide
  3295. window.addEventListener( 'load', removeAddressBar, false );
  3296. window.addEventListener( 'orientationchange', removeAddressBar, false );
  3297. }
  3298. }
  3299. /**
  3300. * Causes the address bar to hide on mobile devices,
  3301. * more vertical space ftw.
  3302. */
  3303. function removeAddressBar() {
  3304. setTimeout( function() {
  3305. window.scrollTo( 0, 1 );
  3306. }, 10 );
  3307. }
  3308. /**
  3309. * Dispatches an event of the specified type from the
  3310. * reveal DOM element.
  3311. */
  3312. function dispatchEvent( type, args ) {
  3313. var event = document.createEvent( 'HTMLEvents', 1, 2 );
  3314. event.initEvent( type, true, true );
  3315. extend( event, args );
  3316. dom.wrapper.dispatchEvent( event );
  3317. // If we're in an iframe, post each reveal.js event to the
  3318. // parent window. Used by the notes plugin
  3319. if( config.postMessageEvents && window.parent !== window.self ) {
  3320. window.parent.postMessage( JSON.stringify({ namespace: 'reveal', eventName: type, state: getState() }), '*' );
  3321. }
  3322. }
  3323. /**
  3324. * Wrap all links in 3D goodness.
  3325. */
  3326. function enableRollingLinks() {
  3327. if( features.transforms3d && !( 'msPerspective' in document.body.style ) ) {
  3328. var anchors = dom.wrapper.querySelectorAll( SLIDES_SELECTOR + ' a' );
  3329. for( var i = 0, len = anchors.length; i < len; i++ ) {
  3330. var anchor = anchors[i];
  3331. if( anchor.textContent && !anchor.querySelector( '*' ) && ( !anchor.className || !anchor.classList.contains( anchor, 'roll' ) ) ) {
  3332. var span = document.createElement('span');
  3333. span.setAttribute('data-title', anchor.text);
  3334. span.innerHTML = anchor.innerHTML;
  3335. anchor.classList.add( 'roll' );
  3336. anchor.innerHTML = '';
  3337. anchor.appendChild(span);
  3338. }
  3339. }
  3340. }
  3341. }
  3342. /**
  3343. * Unwrap all 3D links.
  3344. */
  3345. function disableRollingLinks() {
  3346. var anchors = dom.wrapper.querySelectorAll( SLIDES_SELECTOR + ' a.roll' );
  3347. for( var i = 0, len = anchors.length; i < len; i++ ) {
  3348. var anchor = anchors[i];
  3349. var span = anchor.querySelector( 'span' );
  3350. if( span ) {
  3351. anchor.classList.remove( 'roll' );
  3352. anchor.innerHTML = span.innerHTML;
  3353. }
  3354. }
  3355. }
  3356. /**
  3357. * Bind preview frame links.
  3358. *
  3359. * @param {string} [selector=a] - selector for anchors
  3360. */
  3361. function enablePreviewLinks( selector ) {
  3362. var anchors = toArray( document.querySelectorAll( selector ? selector : 'a' ) );
  3363. anchors.forEach( function( element ) {
  3364. if( /^(http|www)/gi.test( element.getAttribute( 'href' ) ) ) {
  3365. element.addEventListener( 'click', onPreviewLinkClicked, false );
  3366. }
  3367. } );
  3368. }
  3369. /**
  3370. * Unbind preview frame links.
  3371. */
  3372. function disablePreviewLinks( selector ) {
  3373. var anchors = toArray( document.querySelectorAll( selector ? selector : 'a' ) );
  3374. anchors.forEach( function( element ) {
  3375. if( /^(http|www)/gi.test( element.getAttribute( 'href' ) ) ) {
  3376. element.removeEventListener( 'click', onPreviewLinkClicked, false );
  3377. }
  3378. } );
  3379. }
  3380. /**
  3381. * Opens a preview window for the target URL.
  3382. *
  3383. * @param {string} url - url for preview iframe src
  3384. */
  3385. function showPreview( url ) {
  3386. closeOverlay();
  3387. dom.overlay = document.createElement( 'div' );
  3388. dom.overlay.classList.add( 'overlay' );
  3389. dom.overlay.classList.add( 'overlay-preview' );
  3390. dom.wrapper.appendChild( dom.overlay );
  3391. dom.overlay.innerHTML = [
  3392. '<header>',
  3393. '<a class="close" href="#"><span class="icon"></span></a>',
  3394. '<a class="external" href="'+ url +'" target="_blank"><span class="icon"></span></a>',
  3395. '</header>',
  3396. '<div class="spinner"></div>',
  3397. '<div class="viewport">',
  3398. '<iframe src="'+ url +'"></iframe>',
  3399. '<small class="viewport-inner">',
  3400. '<span class="x-frame-error">Unable to load iframe. This is likely due to the site\'s policy (x-frame-options).</span>',
  3401. '</small>',
  3402. '</div>'
  3403. ].join('');
  3404. dom.overlay.querySelector( 'iframe' ).addEventListener( 'load', function( event ) {
  3405. dom.overlay.classList.add( 'loaded' );
  3406. }, false );
  3407. dom.overlay.querySelector( '.close' ).addEventListener( 'click', function( event ) {
  3408. closeOverlay();
  3409. event.preventDefault();
  3410. }, false );
  3411. dom.overlay.querySelector( '.external' ).addEventListener( 'click', function( event ) {
  3412. closeOverlay();
  3413. }, false );
  3414. setTimeout( function() {
  3415. dom.overlay.classList.add( 'visible' );
  3416. }, 1 );
  3417. }
  3418. /**
  3419. * Open or close help overlay window.
  3420. *
  3421. * @param {Boolean} [override] Flag which overrides the
  3422. * toggle logic and forcibly sets the desired state. True means
  3423. * help is open, false means it's closed.
  3424. */
  3425. function toggleHelp( override ){
  3426. if( typeof override === 'boolean' ) {
  3427. override ? showHelp() : closeOverlay();
  3428. }
  3429. else {
  3430. if( dom.overlay ) {
  3431. closeOverlay();
  3432. }
  3433. else {
  3434. showHelp();
  3435. }
  3436. }
  3437. }
  3438. /**
  3439. * Opens an overlay window with help material.
  3440. */
  3441. function showHelp() {
  3442. if( config.help ) {
  3443. closeOverlay();
  3444. dom.overlay = document.createElement( 'div' );
  3445. dom.overlay.classList.add( 'overlay' );
  3446. dom.overlay.classList.add( 'overlay-help' );
  3447. dom.wrapper.appendChild( dom.overlay );
  3448. var html = '<p class="title">Keyboard Shortcuts</p><br/>';
  3449. html += '<table><th>KEY</th><th>ACTION</th>';
  3450. for( var key in keyboardShortcuts ) {
  3451. html += '<tr><td>' + key + '</td><td>' + keyboardShortcuts[ key ] + '</td></tr>';
  3452. }
  3453. // Add custom key bindings that have associated descriptions
  3454. for( var binding in registeredKeyBindings ) {
  3455. if( registeredKeyBindings[binding].key && registeredKeyBindings[binding].description ) {
  3456. html += '<tr><td>' + registeredKeyBindings[binding].key + '</td><td>' + registeredKeyBindings[binding].description + '</td></tr>';
  3457. }
  3458. }
  3459. html += '</table>';
  3460. dom.overlay.innerHTML = [
  3461. '<header>',
  3462. '<a class="close" href="#"><span class="icon"></span></a>',
  3463. '</header>',
  3464. '<div class="viewport">',
  3465. '<div class="viewport-inner">'+ html +'</div>',
  3466. '</div>'
  3467. ].join('');
  3468. dom.overlay.querySelector( '.close' ).addEventListener( 'click', function( event ) {
  3469. closeOverlay();
  3470. event.preventDefault();
  3471. }, false );
  3472. setTimeout( function() {
  3473. dom.overlay.classList.add( 'visible' );
  3474. }, 1 );
  3475. }
  3476. }
  3477. /**
  3478. * Closes any currently open overlay.
  3479. */
  3480. function closeOverlay() {
  3481. if( dom.overlay ) {
  3482. dom.overlay.parentNode.removeChild( dom.overlay );
  3483. dom.overlay = null;
  3484. }
  3485. }
  3486. /**
  3487. * Applies JavaScript-controlled layout rules to the
  3488. * presentation.
  3489. */
  3490. function layout() {
  3491. if( dom.wrapper && !isPrintingPDF() ) {
  3492. if( !config.disableLayout ) {
  3493. // On some mobile devices '100vh' is taller than the visible
  3494. // viewport which leads to part of the presentation being
  3495. // cut off. To work around this we define our own '--vh' custom
  3496. // property where 100x adds up to the correct height.
  3497. //
  3498. // https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
  3499. if( isMobileDevice ) {
  3500. document.documentElement.style.setProperty( '--vh', ( window.innerHeight * 0.01 ) + 'px' );
  3501. }
  3502. var size = getComputedSlideSize();
  3503. var oldScale = scale;
  3504. // Layout the contents of the slides
  3505. layoutSlideContents( config.width, config.height );
  3506. dom.slides.style.width = size.width + 'px';
  3507. dom.slides.style.height = size.height + 'px';
  3508. // Determine scale of content to fit within available space
  3509. scale = Math.min( size.presentationWidth / size.width, size.presentationHeight / size.height );
  3510. // Respect max/min scale settings
  3511. scale = Math.max( scale, config.minScale );
  3512. scale = Math.min( scale, config.maxScale );
  3513. // Don't apply any scaling styles if scale is 1
  3514. if( scale === 1 ) {
  3515. dom.slides.style.zoom = '';
  3516. dom.slides.style.left = '';
  3517. dom.slides.style.top = '';
  3518. dom.slides.style.bottom = '';
  3519. dom.slides.style.right = '';
  3520. transformSlides( { layout: '' } );
  3521. }
  3522. else {
  3523. // Prefer zoom for scaling up so that content remains crisp.
  3524. // Don't use zoom to scale down since that can lead to shifts
  3525. // in text layout/line breaks.
  3526. if( scale > 1 && features.zoom ) {
  3527. dom.slides.style.zoom = scale;
  3528. dom.slides.style.left = '';
  3529. dom.slides.style.top = '';
  3530. dom.slides.style.bottom = '';
  3531. dom.slides.style.right = '';
  3532. transformSlides( { layout: '' } );
  3533. }
  3534. // Apply scale transform as a fallback
  3535. else {
  3536. dom.slides.style.zoom = '';
  3537. dom.slides.style.left = '50%';
  3538. dom.slides.style.top = '50%';
  3539. dom.slides.style.bottom = 'auto';
  3540. dom.slides.style.right = 'auto';
  3541. transformSlides( { layout: 'translate(-50%, -50%) scale('+ scale +')' } );
  3542. }
  3543. }
  3544. // Select all slides, vertical and horizontal
  3545. var slides = toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) );
  3546. for( var i = 0, len = slides.length; i < len; i++ ) {
  3547. var slide = slides[ i ];
  3548. // Don't bother updating invisible slides
  3549. if( slide.style.display === 'none' ) {
  3550. continue;
  3551. }
  3552. if( config.center || slide.classList.contains( 'center' ) ) {
  3553. // Vertical stacks are not centred since their section
  3554. // children will be
  3555. if( slide.classList.contains( 'stack' ) ) {
  3556. slide.style.top = 0;
  3557. }
  3558. else {
  3559. slide.style.top = Math.max( ( size.height - slide.scrollHeight ) / 2, 0 ) + 'px';
  3560. }
  3561. }
  3562. else {
  3563. slide.style.top = '';
  3564. }
  3565. }
  3566. if( oldScale !== scale ) {
  3567. dispatchEvent( 'resize', {
  3568. 'oldScale': oldScale,
  3569. 'scale': scale,
  3570. 'size': size
  3571. } );
  3572. }
  3573. }
  3574. updateProgress();
  3575. updateParallax();
  3576. if( isOverview() ) {
  3577. updateOverview();
  3578. }
  3579. }
  3580. }
  3581. /**
  3582. * Applies layout logic to the contents of all slides in
  3583. * the presentation.
  3584. *
  3585. * @param {string|number} width
  3586. * @param {string|number} height
  3587. */
  3588. function layoutSlideContents( width, height ) {
  3589. // Handle sizing of elements with the 'stretch' class
  3590. toArray( dom.slides.querySelectorAll( 'section > .stretch' ) ).forEach( function( element ) {
  3591. // Determine how much vertical space we can use
  3592. var remainingHeight = getRemainingHeight( element, height );
  3593. // Consider the aspect ratio of media elements
  3594. if( /(img|video)/gi.test( element.nodeName ) ) {
  3595. var nw = element.naturalWidth || element.videoWidth,
  3596. nh = element.naturalHeight || element.videoHeight;
  3597. var es = Math.min( width / nw, remainingHeight / nh );
  3598. element.style.width = ( nw * es ) + 'px';
  3599. element.style.height = ( nh * es ) + 'px';
  3600. }
  3601. else {
  3602. element.style.width = width + 'px';
  3603. element.style.height = remainingHeight + 'px';
  3604. }
  3605. } );
  3606. }
  3607. /**
  3608. * Calculates the computed pixel size of our slides. These
  3609. * values are based on the width and height configuration
  3610. * options.
  3611. *
  3612. * @param {number} [presentationWidth=dom.wrapper.offsetWidth]
  3613. * @param {number} [presentationHeight=dom.wrapper.offsetHeight]
  3614. */
  3615. function getComputedSlideSize( presentationWidth, presentationHeight ) {
  3616. var size = {
  3617. // Slide size
  3618. width: config.width,
  3619. height: config.height,
  3620. // Presentation size
  3621. presentationWidth: presentationWidth || dom.wrapper.offsetWidth,
  3622. presentationHeight: presentationHeight || dom.wrapper.offsetHeight
  3623. };
  3624. // Reduce available space by margin
  3625. size.presentationWidth -= ( size.presentationWidth * config.margin );
  3626. size.presentationHeight -= ( size.presentationHeight * config.margin );
  3627. // Slide width may be a percentage of available width
  3628. if( typeof size.width === 'string' && /%$/.test( size.width ) ) {
  3629. size.width = parseInt( size.width, 10 ) / 100 * size.presentationWidth;
  3630. }
  3631. // Slide height may be a percentage of available height
  3632. if( typeof size.height === 'string' && /%$/.test( size.height ) ) {
  3633. size.height = parseInt( size.height, 10 ) / 100 * size.presentationHeight;
  3634. }
  3635. return size;
  3636. }
  3637. /**
  3638. * Stores the vertical index of a stack so that the same
  3639. * vertical slide can be selected when navigating to and
  3640. * from the stack.
  3641. *
  3642. * @param {HTMLElement} stack The vertical stack element
  3643. * @param {string|number} [v=0] Index to memorize
  3644. */
  3645. function setPreviousVerticalIndex( stack, v ) {
  3646. if( typeof stack === 'object' && typeof stack.setAttribute === 'function' ) {
  3647. stack.setAttribute( 'data-previous-indexv', v || 0 );
  3648. }
  3649. }
  3650. /**
  3651. * Retrieves the vertical index which was stored using
  3652. * #setPreviousVerticalIndex() or 0 if no previous index
  3653. * exists.
  3654. *
  3655. * @param {HTMLElement} stack The vertical stack element
  3656. */
  3657. function getPreviousVerticalIndex( stack ) {
  3658. if( typeof stack === 'object' && typeof stack.setAttribute === 'function' && stack.classList.contains( 'stack' ) ) {
  3659. // Prefer manually defined start-indexv
  3660. var attributeName = stack.hasAttribute( 'data-start-indexv' ) ? 'data-start-indexv' : 'data-previous-indexv';
  3661. return parseInt( stack.getAttribute( attributeName ) || 0, 10 );
  3662. }
  3663. return 0;
  3664. }
  3665. /**
  3666. * Displays the overview of slides (quick nav) by scaling
  3667. * down and arranging all slide elements.
  3668. */
  3669. function activateOverview() {
  3670. // Only proceed if enabled in config
  3671. if( config.overview && !isOverview() ) {
  3672. overview = true;
  3673. dom.wrapper.classList.add( 'overview' );
  3674. dom.wrapper.classList.remove( 'overview-deactivating' );
  3675. if( features.overviewTransitions ) {
  3676. setTimeout( function() {
  3677. dom.wrapper.classList.add( 'overview-animated' );
  3678. }, 1 );
  3679. }
  3680. // Don't auto-slide while in overview mode
  3681. cancelAutoSlide();
  3682. // Move the backgrounds element into the slide container to
  3683. // that the same scaling is applied
  3684. dom.slides.appendChild( dom.background );
  3685. // Clicking on an overview slide navigates to it
  3686. toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) ).forEach( function( slide ) {
  3687. if( !slide.classList.contains( 'stack' ) ) {
  3688. slide.addEventListener( 'click', onOverviewSlideClicked, true );
  3689. }
  3690. } );
  3691. // Calculate slide sizes
  3692. var margin = 70;
  3693. var slideSize = getComputedSlideSize();
  3694. overviewSlideWidth = slideSize.width + margin;
  3695. overviewSlideHeight = slideSize.height + margin;
  3696. // Reverse in RTL mode
  3697. if( config.rtl ) {
  3698. overviewSlideWidth = -overviewSlideWidth;
  3699. }
  3700. updateSlidesVisibility();
  3701. layoutOverview();
  3702. updateOverview();
  3703. layout();
  3704. // Notify observers of the overview showing
  3705. dispatchEvent( 'overviewshown', {
  3706. 'indexh': indexh,
  3707. 'indexv': indexv,
  3708. 'currentSlide': currentSlide
  3709. } );
  3710. }
  3711. }
  3712. /**
  3713. * Uses CSS transforms to position all slides in a grid for
  3714. * display inside of the overview mode.
  3715. */
  3716. function layoutOverview() {
  3717. // Layout slides
  3718. toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).forEach( function( hslide, h ) {
  3719. hslide.setAttribute( 'data-index-h', h );
  3720. transformElement( hslide, 'translate3d(' + ( h * overviewSlideWidth ) + 'px, 0, 0)' );
  3721. if( hslide.classList.contains( 'stack' ) ) {
  3722. toArray( hslide.querySelectorAll( 'section' ) ).forEach( function( vslide, v ) {
  3723. vslide.setAttribute( 'data-index-h', h );
  3724. vslide.setAttribute( 'data-index-v', v );
  3725. transformElement( vslide, 'translate3d(0, ' + ( v * overviewSlideHeight ) + 'px, 0)' );
  3726. } );
  3727. }
  3728. } );
  3729. // Layout slide backgrounds
  3730. toArray( dom.background.childNodes ).forEach( function( hbackground, h ) {
  3731. transformElement( hbackground, 'translate3d(' + ( h * overviewSlideWidth ) + 'px, 0, 0)' );
  3732. toArray( hbackground.querySelectorAll( '.slide-background' ) ).forEach( function( vbackground, v ) {
  3733. transformElement( vbackground, 'translate3d(0, ' + ( v * overviewSlideHeight ) + 'px, 0)' );
  3734. } );
  3735. } );
  3736. }
  3737. /**
  3738. * Moves the overview viewport to the current slides.
  3739. * Called each time the current slide changes.
  3740. */
  3741. function updateOverview() {
  3742. var vmin = Math.min( window.innerWidth, window.innerHeight );
  3743. var scale = Math.max( vmin / 5, 150 ) / vmin;
  3744. transformSlides( {
  3745. overview: [
  3746. 'scale('+ scale +')',
  3747. 'translateX('+ ( -indexh * overviewSlideWidth ) +'px)',
  3748. 'translateY('+ ( -indexv * overviewSlideHeight ) +'px)'
  3749. ].join( ' ' )
  3750. } );
  3751. }
  3752. /**
  3753. * Exits the slide overview and enters the currently
  3754. * active slide.
  3755. */
  3756. function deactivateOverview() {
  3757. // Only proceed if enabled in config
  3758. if( config.overview ) {
  3759. overview = false;
  3760. dom.wrapper.classList.remove( 'overview' );
  3761. dom.wrapper.classList.remove( 'overview-animated' );
  3762. // Temporarily add a class so that transitions can do different things
  3763. // depending on whether they are exiting/entering overview, or just
  3764. // moving from slide to slide
  3765. dom.wrapper.classList.add( 'overview-deactivating' );
  3766. setTimeout( function () {
  3767. dom.wrapper.classList.remove( 'overview-deactivating' );
  3768. }, 1 );
  3769. // Move the background element back out
  3770. dom.wrapper.appendChild( dom.background );
  3771. // Clean up changes made to slides
  3772. toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) ).forEach( function( slide ) {
  3773. transformElement( slide, '' );
  3774. slide.removeEventListener( 'click', onOverviewSlideClicked, true );
  3775. } );
  3776. // Clean up changes made to backgrounds
  3777. toArray( dom.background.querySelectorAll( '.slide-background' ) ).forEach( function( background ) {
  3778. transformElement( background, '' );
  3779. } );
  3780. transformSlides( { overview: '' } );
  3781. slide( indexh, indexv );
  3782. layout();
  3783. cueAutoSlide();
  3784. // Notify observers of the overview hiding
  3785. dispatchEvent( 'overviewhidden', {
  3786. 'indexh': indexh,
  3787. 'indexv': indexv,
  3788. 'currentSlide': currentSlide
  3789. } );
  3790. }
  3791. }
  3792. /**
  3793. * Toggles the slide overview mode on and off.
  3794. *
  3795. * @param {Boolean} [override] Flag which overrides the
  3796. * toggle logic and forcibly sets the desired state. True means
  3797. * overview is open, false means it's closed.
  3798. */
  3799. function toggleOverview( override ) {
  3800. if( typeof override === 'boolean' ) {
  3801. override ? activateOverview() : deactivateOverview();
  3802. }
  3803. else {
  3804. isOverview() ? deactivateOverview() : activateOverview();
  3805. }
  3806. }
  3807. /**
  3808. * Checks if the overview is currently active.
  3809. *
  3810. * @return {Boolean} true if the overview is active,
  3811. * false otherwise
  3812. */
  3813. function isOverview() {
  3814. return overview;
  3815. }
  3816. /**
  3817. * Return a hash URL that will resolve to the current slide location.
  3818. */
  3819. function locationHash() {
  3820. var url = '/';
  3821. // Attempt to create a named link based on the slide's ID
  3822. var id = currentSlide ? currentSlide.getAttribute( 'id' ) : null;
  3823. if( id ) {
  3824. id = encodeURIComponent( id );
  3825. }
  3826. var indexf;
  3827. if( config.fragmentInURL ) {
  3828. indexf = getIndices().f;
  3829. }
  3830. // If the current slide has an ID, use that as a named link,
  3831. // but we don't support named links with a fragment index
  3832. if( typeof id === 'string' && id.length && indexf === undefined ) {
  3833. url = '/' + id;
  3834. }
  3835. // Otherwise use the /h/v index
  3836. else {
  3837. var hashIndexBase = config.hashOneBasedIndex ? 1 : 0;
  3838. if( indexh > 0 || indexv > 0 || indexf !== undefined ) url += indexh + hashIndexBase;
  3839. if( indexv > 0 || indexf !== undefined ) url += '/' + (indexv + hashIndexBase );
  3840. if( indexf !== undefined ) url += '/' + indexf;
  3841. }
  3842. return url;
  3843. }
  3844. /**
  3845. * Checks if the current or specified slide is vertical
  3846. * (nested within another slide).
  3847. *
  3848. * @param {HTMLElement} [slide=currentSlide] The slide to check
  3849. * orientation of
  3850. * @return {Boolean}
  3851. */
  3852. function isVerticalSlide( slide ) {
  3853. // Prefer slide argument, otherwise use current slide
  3854. slide = slide ? slide : currentSlide;
  3855. return slide && slide.parentNode && !!slide.parentNode.nodeName.match( /section/i );
  3856. }
  3857. /**
  3858. * Handling the fullscreen functionality via the fullscreen API
  3859. *
  3860. * @see http://fullscreen.spec.whatwg.org/
  3861. * @see https://developer.mozilla.org/en-US/docs/DOM/Using_fullscreen_mode
  3862. */
  3863. function enterFullscreen() {
  3864. var element = document.documentElement;
  3865. // Check which implementation is available
  3866. var requestMethod = element.requestFullscreen ||
  3867. element.webkitRequestFullscreen ||
  3868. element.webkitRequestFullScreen ||
  3869. element.mozRequestFullScreen ||
  3870. element.msRequestFullscreen;
  3871. if( requestMethod ) {
  3872. requestMethod.apply( element );
  3873. }
  3874. }
  3875. /**
  3876. * Shows the mouse pointer after it has been hidden with
  3877. * #hideCursor.
  3878. */
  3879. function showCursor() {
  3880. if( cursorHidden ) {
  3881. cursorHidden = false;
  3882. dom.wrapper.style.cursor = '';
  3883. }
  3884. }
  3885. /**
  3886. * Hides the mouse pointer when it's on top of the .reveal
  3887. * container.
  3888. */
  3889. function hideCursor() {
  3890. if( cursorHidden === false ) {
  3891. cursorHidden = true;
  3892. dom.wrapper.style.cursor = 'none';
  3893. }
  3894. }
  3895. /**
  3896. * Enters the paused mode which fades everything on screen to
  3897. * black.
  3898. */
  3899. function pause() {
  3900. if( config.pause ) {
  3901. var wasPaused = dom.wrapper.classList.contains( 'paused' );
  3902. cancelAutoSlide();
  3903. dom.wrapper.classList.add( 'paused' );
  3904. if( wasPaused === false ) {
  3905. dispatchEvent( 'paused' );
  3906. }
  3907. }
  3908. }
  3909. /**
  3910. * Exits from the paused mode.
  3911. */
  3912. function resume() {
  3913. var wasPaused = dom.wrapper.classList.contains( 'paused' );
  3914. dom.wrapper.classList.remove( 'paused' );
  3915. cueAutoSlide();
  3916. if( wasPaused ) {
  3917. dispatchEvent( 'resumed' );
  3918. }
  3919. }
  3920. /**
  3921. * Toggles the paused mode on and off.
  3922. */
  3923. function togglePause( override ) {
  3924. if( typeof override === 'boolean' ) {
  3925. override ? pause() : resume();
  3926. }
  3927. else {
  3928. isPaused() ? resume() : pause();
  3929. }
  3930. }
  3931. /**
  3932. * Checks if we are currently in the paused mode.
  3933. *
  3934. * @return {Boolean}
  3935. */
  3936. function isPaused() {
  3937. return dom.wrapper.classList.contains( 'paused' );
  3938. }
  3939. /**
  3940. * Toggles the auto slide mode on and off.
  3941. *
  3942. * @param {Boolean} [override] Flag which sets the desired state.
  3943. * True means autoplay starts, false means it stops.
  3944. */
  3945. function toggleAutoSlide( override ) {
  3946. if( typeof override === 'boolean' ) {
  3947. override ? resumeAutoSlide() : pauseAutoSlide();
  3948. }
  3949. else {
  3950. autoSlidePaused ? resumeAutoSlide() : pauseAutoSlide();
  3951. }
  3952. }
  3953. /**
  3954. * Checks if the auto slide mode is currently on.
  3955. *
  3956. * @return {Boolean}
  3957. */
  3958. function isAutoSliding() {
  3959. return !!( autoSlide && !autoSlidePaused );
  3960. }
  3961. /**
  3962. * Steps from the current point in the presentation to the
  3963. * slide which matches the specified horizontal and vertical
  3964. * indices.
  3965. *
  3966. * @param {number} [h=indexh] Horizontal index of the target slide
  3967. * @param {number} [v=indexv] Vertical index of the target slide
  3968. * @param {number} [f] Index of a fragment within the
  3969. * target slide to activate
  3970. * @param {number} [o] Origin for use in multimaster environments
  3971. */
  3972. function slide( h, v, f, o ) {
  3973. // Remember where we were at before
  3974. previousSlide = currentSlide;
  3975. // Query all horizontal slides in the deck
  3976. var horizontalSlides = dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR );
  3977. // Abort if there are no slides
  3978. if( horizontalSlides.length === 0 ) return;
  3979. // If no vertical index is specified and the upcoming slide is a
  3980. // stack, resume at its previous vertical index
  3981. if( v === undefined && !isOverview() ) {
  3982. v = getPreviousVerticalIndex( horizontalSlides[ h ] );
  3983. }
  3984. // If we were on a vertical stack, remember what vertical index
  3985. // it was on so we can resume at the same position when returning
  3986. if( previousSlide && previousSlide.parentNode && previousSlide.parentNode.classList.contains( 'stack' ) ) {
  3987. setPreviousVerticalIndex( previousSlide.parentNode, indexv );
  3988. }
  3989. // Remember the state before this slide
  3990. var stateBefore = state.concat();
  3991. // Reset the state array
  3992. state.length = 0;
  3993. var indexhBefore = indexh || 0,
  3994. indexvBefore = indexv || 0;
  3995. // Activate and transition to the new slide
  3996. indexh = updateSlides( HORIZONTAL_SLIDES_SELECTOR, h === undefined ? indexh : h );
  3997. indexv = updateSlides( VERTICAL_SLIDES_SELECTOR, v === undefined ? indexv : v );
  3998. // Update the visibility of slides now that the indices have changed
  3999. updateSlidesVisibility();
  4000. layout();
  4001. // Update the overview if it's currently active
  4002. if( isOverview() ) {
  4003. updateOverview();
  4004. }
  4005. // Find the current horizontal slide and any possible vertical slides
  4006. // within it
  4007. var currentHorizontalSlide = horizontalSlides[ indexh ],
  4008. currentVerticalSlides = currentHorizontalSlide.querySelectorAll( 'section' );
  4009. // Store references to the previous and current slides
  4010. currentSlide = currentVerticalSlides[ indexv ] || currentHorizontalSlide;
  4011. // Show fragment, if specified
  4012. if( typeof f !== 'undefined' ) {
  4013. navigateFragment( f );
  4014. }
  4015. // Dispatch an event if the slide changed
  4016. var slideChanged = ( indexh !== indexhBefore || indexv !== indexvBefore );
  4017. if (!slideChanged) {
  4018. // Ensure that the previous slide is never the same as the current
  4019. previousSlide = null;
  4020. }
  4021. // Solves an edge case where the previous slide maintains the
  4022. // 'present' class when navigating between adjacent vertical
  4023. // stacks
  4024. if( previousSlide && previousSlide !== currentSlide ) {
  4025. previousSlide.classList.remove( 'present' );
  4026. previousSlide.setAttribute( 'aria-hidden', 'true' );
  4027. // Reset all slides upon navigate to home
  4028. // Issue: #285
  4029. if ( dom.wrapper.querySelector( HOME_SLIDE_SELECTOR ).classList.contains( 'present' ) ) {
  4030. // Launch async task
  4031. setTimeout( function () {
  4032. var slides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.stack') ), i;
  4033. for( i in slides ) {
  4034. if( slides[i] ) {
  4035. // Reset stack
  4036. setPreviousVerticalIndex( slides[i], 0 );
  4037. }
  4038. }
  4039. }, 0 );
  4040. }
  4041. }
  4042. // Apply the new state
  4043. stateLoop: for( var i = 0, len = state.length; i < len; i++ ) {
  4044. // Check if this state existed on the previous slide. If it
  4045. // did, we will avoid adding it repeatedly
  4046. for( var j = 0; j < stateBefore.length; j++ ) {
  4047. if( stateBefore[j] === state[i] ) {
  4048. stateBefore.splice( j, 1 );
  4049. continue stateLoop;
  4050. }
  4051. }
  4052. document.documentElement.classList.add( state[i] );
  4053. // Dispatch custom event matching the state's name
  4054. dispatchEvent( state[i] );
  4055. }
  4056. // Clean up the remains of the previous state
  4057. while( stateBefore.length ) {
  4058. document.documentElement.classList.remove( stateBefore.pop() );
  4059. }
  4060. if( slideChanged ) {
  4061. dispatchEvent( 'slidechanged', {
  4062. 'indexh': indexh,
  4063. 'indexv': indexv,
  4064. 'previousSlide': previousSlide,
  4065. 'currentSlide': currentSlide,
  4066. 'origin': o
  4067. } );
  4068. }
  4069. // Handle embedded content
  4070. if( slideChanged || !previousSlide ) {
  4071. stopEmbeddedContent( previousSlide );
  4072. startEmbeddedContent( currentSlide );
  4073. }
  4074. // Announce the current slide contents, for screen readers
  4075. dom.statusDiv.textContent = getStatusText( currentSlide );
  4076. updateControls();
  4077. updateProgress();
  4078. updateBackground();
  4079. updateParallax();
  4080. updateSlideNumber();
  4081. updateNotes();
  4082. updateFragments();
  4083. // Update the URL hash
  4084. writeURL();
  4085. cueAutoSlide();
  4086. }
  4087. /**
  4088. * Syncs the presentation with the current DOM. Useful
  4089. * when new slides or control elements are added or when
  4090. * the configuration has changed.
  4091. */
  4092. function sync() {
  4093. // Subscribe to input
  4094. removeEventListeners();
  4095. addEventListeners();
  4096. // Force a layout to make sure the current config is accounted for
  4097. layout();
  4098. // Reflect the current autoSlide value
  4099. autoSlide = config.autoSlide;
  4100. // Start auto-sliding if it's enabled
  4101. cueAutoSlide();
  4102. // Re-create the slide backgrounds
  4103. createBackgrounds();
  4104. // Write the current hash to the URL
  4105. writeURL();
  4106. sortAllFragments();
  4107. updateControls();
  4108. updateProgress();
  4109. updateSlideNumber();
  4110. updateSlidesVisibility();
  4111. updateBackground( true );
  4112. updateNotesVisibility();
  4113. updateNotes();
  4114. formatEmbeddedContent();
  4115. // Start or stop embedded content depending on global config
  4116. if( config.autoPlayMedia === false ) {
  4117. stopEmbeddedContent( currentSlide, { unloadIframes: false } );
  4118. }
  4119. else {
  4120. startEmbeddedContent( currentSlide );
  4121. }
  4122. if( isOverview() ) {
  4123. layoutOverview();
  4124. }
  4125. }
  4126. /**
  4127. * Updates reveal.js to keep in sync with new slide attributes. For
  4128. * example, if you add a new `data-background-image` you can call
  4129. * this to have reveal.js render the new background image.
  4130. *
  4131. * Similar to #sync() but more efficient when you only need to
  4132. * refresh a specific slide.
  4133. *
  4134. * @param {HTMLElement} slide
  4135. */
  4136. function syncSlide( slide ) {
  4137. // Default to the current slide
  4138. slide = slide || currentSlide;
  4139. syncBackground( slide );
  4140. syncFragments( slide );
  4141. updateBackground();
  4142. updateNotes();
  4143. loadSlide( slide );
  4144. }
  4145. /**
  4146. * Formats the fragments on the given slide so that they have
  4147. * valid indices. Call this if fragments are changed in the DOM
  4148. * after reveal.js has already initialized.
  4149. *
  4150. * @param {HTMLElement} slide
  4151. * @return {Array} a list of the HTML fragments that were synced
  4152. */
  4153. function syncFragments( slide ) {
  4154. // Default to the current slide
  4155. slide = slide || currentSlide;
  4156. return sortFragments( slide.querySelectorAll( '.fragment' ) );
  4157. }
  4158. /**
  4159. * Resets all vertical slides so that only the first
  4160. * is visible.
  4161. */
  4162. function resetVerticalSlides() {
  4163. var horizontalSlides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
  4164. horizontalSlides.forEach( function( horizontalSlide ) {
  4165. var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) );
  4166. verticalSlides.forEach( function( verticalSlide, y ) {
  4167. if( y > 0 ) {
  4168. verticalSlide.classList.remove( 'present' );
  4169. verticalSlide.classList.remove( 'past' );
  4170. verticalSlide.classList.add( 'future' );
  4171. verticalSlide.setAttribute( 'aria-hidden', 'true' );
  4172. }
  4173. } );
  4174. } );
  4175. }
  4176. /**
  4177. * Sorts and formats all of fragments in the
  4178. * presentation.
  4179. */
  4180. function sortAllFragments() {
  4181. var horizontalSlides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
  4182. horizontalSlides.forEach( function( horizontalSlide ) {
  4183. var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) );
  4184. verticalSlides.forEach( function( verticalSlide, y ) {
  4185. sortFragments( verticalSlide.querySelectorAll( '.fragment' ) );
  4186. } );
  4187. if( verticalSlides.length === 0 ) sortFragments( horizontalSlide.querySelectorAll( '.fragment' ) );
  4188. } );
  4189. }
  4190. /**
  4191. * Randomly shuffles all slides in the deck.
  4192. */
  4193. function shuffle() {
  4194. var slides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
  4195. slides.forEach( function( slide ) {
  4196. // Insert this slide next to another random slide. This may
  4197. // cause the slide to insert before itself but that's fine.
  4198. dom.slides.insertBefore( slide, slides[ Math.floor( Math.random() * slides.length ) ] );
  4199. } );
  4200. }
  4201. /**
  4202. * Updates one dimension of slides by showing the slide
  4203. * with the specified index.
  4204. *
  4205. * @param {string} selector A CSS selector that will fetch
  4206. * the group of slides we are working with
  4207. * @param {number} index The index of the slide that should be
  4208. * shown
  4209. *
  4210. * @return {number} The index of the slide that is now shown,
  4211. * might differ from the passed in index if it was out of
  4212. * bounds.
  4213. */
  4214. function updateSlides( selector, index ) {
  4215. // Select all slides and convert the NodeList result to
  4216. // an array
  4217. var slides = toArray( dom.wrapper.querySelectorAll( selector ) ),
  4218. slidesLength = slides.length;
  4219. var printMode = isPrintingPDF();
  4220. if( slidesLength ) {
  4221. // Should the index loop?
  4222. if( config.loop ) {
  4223. index %= slidesLength;
  4224. if( index < 0 ) {
  4225. index = slidesLength + index;
  4226. }
  4227. }
  4228. // Enforce max and minimum index bounds
  4229. index = Math.max( Math.min( index, slidesLength - 1 ), 0 );
  4230. for( var i = 0; i < slidesLength; i++ ) {
  4231. var element = slides[i];
  4232. var reverse = config.rtl && !isVerticalSlide( element );
  4233. element.classList.remove( 'past' );
  4234. element.classList.remove( 'present' );
  4235. element.classList.remove( 'future' );
  4236. // http://www.w3.org/html/wg/drafts/html/master/editing.html#the-hidden-attribute
  4237. element.setAttribute( 'hidden', '' );
  4238. element.setAttribute( 'aria-hidden', 'true' );
  4239. // If this element contains vertical slides
  4240. if( element.querySelector( 'section' ) ) {
  4241. element.classList.add( 'stack' );
  4242. }
  4243. // If we're printing static slides, all slides are "present"
  4244. if( printMode ) {
  4245. element.classList.add( 'present' );
  4246. continue;
  4247. }
  4248. if( i < index ) {
  4249. // Any element previous to index is given the 'past' class
  4250. element.classList.add( reverse ? 'future' : 'past' );
  4251. if( config.fragments ) {
  4252. // Show all fragments in prior slides
  4253. toArray( element.querySelectorAll( '.fragment' ) ).forEach( function( fragment ) {
  4254. fragment.classList.add( 'visible' );
  4255. fragment.classList.remove( 'current-fragment' );
  4256. } );
  4257. }
  4258. }
  4259. else if( i > index ) {
  4260. // Any element subsequent to index is given the 'future' class
  4261. element.classList.add( reverse ? 'past' : 'future' );
  4262. if( config.fragments ) {
  4263. // Hide all fragments in future slides
  4264. toArray( element.querySelectorAll( '.fragment.visible' ) ).forEach( function( fragment ) {
  4265. fragment.classList.remove( 'visible' );
  4266. fragment.classList.remove( 'current-fragment' );
  4267. } );
  4268. }
  4269. }
  4270. }
  4271. // Mark the current slide as present
  4272. slides[index].classList.add( 'present' );
  4273. slides[index].removeAttribute( 'hidden' );
  4274. slides[index].removeAttribute( 'aria-hidden' );
  4275. // If this slide has a state associated with it, add it
  4276. // onto the current state of the deck
  4277. var slideState = slides[index].getAttribute( 'data-state' );
  4278. if( slideState ) {
  4279. state = state.concat( slideState.split( ' ' ) );
  4280. }
  4281. }
  4282. else {
  4283. // Since there are no slides we can't be anywhere beyond the
  4284. // zeroth index
  4285. index = 0;
  4286. }
  4287. return index;
  4288. }
  4289. /**
  4290. * Optimization method; hide all slides that are far away
  4291. * from the present slide.
  4292. */
  4293. function updateSlidesVisibility() {
  4294. // Select all slides and convert the NodeList result to
  4295. // an array
  4296. var horizontalSlides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ),
  4297. horizontalSlidesLength = horizontalSlides.length,
  4298. distanceX,
  4299. distanceY;
  4300. if( horizontalSlidesLength && typeof indexh !== 'undefined' ) {
  4301. // The number of steps away from the present slide that will
  4302. // be visible
  4303. var viewDistance = isOverview() ? 10 : config.viewDistance;
  4304. // Limit view distance on weaker devices
  4305. if( isMobileDevice ) {
  4306. viewDistance = isOverview() ? 6 : 2;
  4307. }
  4308. // All slides need to be visible when exporting to PDF
  4309. if( isPrintingPDF() ) {
  4310. viewDistance = Number.MAX_VALUE;
  4311. }
  4312. for( var x = 0; x < horizontalSlidesLength; x++ ) {
  4313. var horizontalSlide = horizontalSlides[x];
  4314. var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) ),
  4315. verticalSlidesLength = verticalSlides.length;
  4316. // Determine how far away this slide is from the present
  4317. distanceX = Math.abs( ( indexh || 0 ) - x ) || 0;
  4318. // If the presentation is looped, distance should measure
  4319. // 1 between the first and last slides
  4320. if( config.loop ) {
  4321. distanceX = Math.abs( ( ( indexh || 0 ) - x ) % ( horizontalSlidesLength - viewDistance ) ) || 0;
  4322. }
  4323. // Show the horizontal slide if it's within the view distance
  4324. if( distanceX < viewDistance ) {
  4325. loadSlide( horizontalSlide );
  4326. }
  4327. else {
  4328. unloadSlide( horizontalSlide );
  4329. }
  4330. if( verticalSlidesLength ) {
  4331. var oy = getPreviousVerticalIndex( horizontalSlide );
  4332. for( var y = 0; y < verticalSlidesLength; y++ ) {
  4333. var verticalSlide = verticalSlides[y];
  4334. distanceY = x === ( indexh || 0 ) ? Math.abs( ( indexv || 0 ) - y ) : Math.abs( y - oy );
  4335. if( distanceX + distanceY < viewDistance ) {
  4336. loadSlide( verticalSlide );
  4337. }
  4338. else {
  4339. unloadSlide( verticalSlide );
  4340. }
  4341. }
  4342. }
  4343. }
  4344. // Flag if there are ANY vertical slides, anywhere in the deck
  4345. if( dom.wrapper.querySelectorAll( '.slides>section>section' ).length ) {
  4346. dom.wrapper.classList.add( 'has-vertical-slides' );
  4347. }
  4348. else {
  4349. dom.wrapper.classList.remove( 'has-vertical-slides' );
  4350. }
  4351. // Flag if there are ANY horizontal slides, anywhere in the deck
  4352. if( dom.wrapper.querySelectorAll( '.slides>section' ).length > 1 ) {
  4353. dom.wrapper.classList.add( 'has-horizontal-slides' );
  4354. }
  4355. else {
  4356. dom.wrapper.classList.remove( 'has-horizontal-slides' );
  4357. }
  4358. }
  4359. }
  4360. /**
  4361. * Pick up notes from the current slide and display them
  4362. * to the viewer.
  4363. *
  4364. * @see {@link config.showNotes}
  4365. */
  4366. function updateNotes() {
  4367. if( config.showNotes && dom.speakerNotes && currentSlide && !isPrintingPDF() ) {
  4368. dom.speakerNotes.innerHTML = getSlideNotes() || '<span class="notes-placeholder">No notes on this slide.</span>';
  4369. }
  4370. }
  4371. /**
  4372. * Updates the visibility of the speaker notes sidebar that
  4373. * is used to share annotated slides. The notes sidebar is
  4374. * only visible if showNotes is true and there are notes on
  4375. * one or more slides in the deck.
  4376. */
  4377. function updateNotesVisibility() {
  4378. if( config.showNotes && hasNotes() ) {
  4379. dom.wrapper.classList.add( 'show-notes' );
  4380. }
  4381. else {
  4382. dom.wrapper.classList.remove( 'show-notes' );
  4383. }
  4384. }
  4385. /**
  4386. * Checks if there are speaker notes for ANY slide in the
  4387. * presentation.
  4388. */
  4389. function hasNotes() {
  4390. return dom.slides.querySelectorAll( '[data-notes], aside.notes' ).length > 0;
  4391. }
  4392. /**
  4393. * Updates the progress bar to reflect the current slide.
  4394. */
  4395. function updateProgress() {
  4396. // Update progress if enabled
  4397. if( config.progress && dom.progressbar ) {
  4398. dom.progressbar.style.width = getProgress() * dom.wrapper.offsetWidth + 'px';
  4399. }
  4400. }
  4401. /**
  4402. * Updates the slide number to match the current slide.
  4403. */
  4404. function updateSlideNumber() {
  4405. // Update slide number if enabled
  4406. if( config.slideNumber && dom.slideNumber ) {
  4407. var value;
  4408. var format = 'h.v';
  4409. if( typeof config.slideNumber === 'function' ) {
  4410. value = config.slideNumber();
  4411. }
  4412. else {
  4413. // Check if a custom number format is available
  4414. if( typeof config.slideNumber === 'string' ) {
  4415. format = config.slideNumber;
  4416. }
  4417. // If there are ONLY vertical slides in this deck, always use
  4418. // a flattened slide number
  4419. if( !/c/.test( format ) && dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ).length === 1 ) {
  4420. format = 'c';
  4421. }
  4422. value = [];
  4423. switch( format ) {
  4424. case 'c':
  4425. value.push( getSlidePastCount() + 1 );
  4426. break;
  4427. case 'c/t':
  4428. value.push( getSlidePastCount() + 1, '/', getTotalSlides() );
  4429. break;
  4430. case 'h/v':
  4431. value.push( indexh + 1 );
  4432. if( isVerticalSlide() ) value.push( '/', indexv + 1 );
  4433. break;
  4434. default:
  4435. value.push( indexh + 1 );
  4436. if( isVerticalSlide() ) value.push( '.', indexv + 1 );
  4437. }
  4438. }
  4439. dom.slideNumber.innerHTML = formatSlideNumber( value[0], value[1], value[2] );
  4440. }
  4441. }
  4442. /**
  4443. * Applies HTML formatting to a slide number before it's
  4444. * written to the DOM.
  4445. *
  4446. * @param {number} a Current slide
  4447. * @param {string} delimiter Character to separate slide numbers
  4448. * @param {(number|*)} b Total slides
  4449. * @return {string} HTML string fragment
  4450. */
  4451. function formatSlideNumber( a, delimiter, b ) {
  4452. var url = '#' + locationHash();
  4453. if( typeof b === 'number' && !isNaN( b ) ) {
  4454. return '<a href="' + url + '">' +
  4455. '<span class="slide-number-a">'+ a +'</span>' +
  4456. '<span class="slide-number-delimiter">'+ delimiter +'</span>' +
  4457. '<span class="slide-number-b">'+ b +'</span>' +
  4458. '</a>';
  4459. }
  4460. else {
  4461. return '<a href="' + url + '">' +
  4462. '<span class="slide-number-a">'+ a +'</span>' +
  4463. '</a>';
  4464. }
  4465. }
  4466. /**
  4467. * Updates the state of all control/navigation arrows.
  4468. */
  4469. function updateControls() {
  4470. var routes = availableRoutes();
  4471. var fragments = availableFragments();
  4472. // Remove the 'enabled' class from all directions
  4473. dom.controlsLeft.concat( dom.controlsRight )
  4474. .concat( dom.controlsUp )
  4475. .concat( dom.controlsDown )
  4476. .concat( dom.controlsPrev )
  4477. .concat( dom.controlsNext ).forEach( function( node ) {
  4478. node.classList.remove( 'enabled' );
  4479. node.classList.remove( 'fragmented' );
  4480. // Set 'disabled' attribute on all directions
  4481. node.setAttribute( 'disabled', 'disabled' );
  4482. } );
  4483. // Add the 'enabled' class to the available routes; remove 'disabled' attribute to enable buttons
  4484. if( routes.left ) dom.controlsLeft.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4485. if( routes.right ) dom.controlsRight.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4486. if( routes.up ) dom.controlsUp.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4487. if( routes.down ) dom.controlsDown.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4488. // Prev/next buttons
  4489. if( routes.left || routes.up ) dom.controlsPrev.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4490. if( routes.right || routes.down ) dom.controlsNext.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4491. // Highlight fragment directions
  4492. if( currentSlide ) {
  4493. // Always apply fragment decorator to prev/next buttons
  4494. if( fragments.prev ) dom.controlsPrev.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4495. if( fragments.next ) dom.controlsNext.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4496. // Apply fragment decorators to directional buttons based on
  4497. // what slide axis they are in
  4498. if( isVerticalSlide( currentSlide ) ) {
  4499. if( fragments.prev ) dom.controlsUp.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4500. if( fragments.next ) dom.controlsDown.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4501. }
  4502. else {
  4503. if( fragments.prev ) dom.controlsLeft.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4504. if( fragments.next ) dom.controlsRight.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4505. }
  4506. }
  4507. if( config.controlsTutorial ) {
  4508. // Highlight control arrows with an animation to ensure
  4509. // that the viewer knows how to navigate
  4510. if( !hasNavigatedDown && routes.down ) {
  4511. dom.controlsDownArrow.classList.add( 'highlight' );
  4512. }
  4513. else {
  4514. dom.controlsDownArrow.classList.remove( 'highlight' );
  4515. if( !hasNavigatedRight && routes.right && indexv === 0 ) {
  4516. dom.controlsRightArrow.classList.add( 'highlight' );
  4517. }
  4518. else {
  4519. dom.controlsRightArrow.classList.remove( 'highlight' );
  4520. }
  4521. }
  4522. }
  4523. }
  4524. /**
  4525. * Updates the background elements to reflect the current
  4526. * slide.
  4527. *
  4528. * @param {boolean} includeAll If true, the backgrounds of
  4529. * all vertical slides (not just the present) will be updated.
  4530. */
  4531. function updateBackground( includeAll ) {
  4532. var currentBackground = null;
  4533. // Reverse past/future classes when in RTL mode
  4534. var horizontalPast = config.rtl ? 'future' : 'past',
  4535. horizontalFuture = config.rtl ? 'past' : 'future';
  4536. // Update the classes of all backgrounds to match the
  4537. // states of their slides (past/present/future)
  4538. toArray( dom.background.childNodes ).forEach( function( backgroundh, h ) {
  4539. backgroundh.classList.remove( 'past' );
  4540. backgroundh.classList.remove( 'present' );
  4541. backgroundh.classList.remove( 'future' );
  4542. if( h < indexh ) {
  4543. backgroundh.classList.add( horizontalPast );
  4544. }
  4545. else if ( h > indexh ) {
  4546. backgroundh.classList.add( horizontalFuture );
  4547. }
  4548. else {
  4549. backgroundh.classList.add( 'present' );
  4550. // Store a reference to the current background element
  4551. currentBackground = backgroundh;
  4552. }
  4553. if( includeAll || h === indexh ) {
  4554. toArray( backgroundh.querySelectorAll( '.slide-background' ) ).forEach( function( backgroundv, v ) {
  4555. backgroundv.classList.remove( 'past' );
  4556. backgroundv.classList.remove( 'present' );
  4557. backgroundv.classList.remove( 'future' );
  4558. if( v < indexv ) {
  4559. backgroundv.classList.add( 'past' );
  4560. }
  4561. else if ( v > indexv ) {
  4562. backgroundv.classList.add( 'future' );
  4563. }
  4564. else {
  4565. backgroundv.classList.add( 'present' );
  4566. // Only if this is the present horizontal and vertical slide
  4567. if( h === indexh ) currentBackground = backgroundv;
  4568. }
  4569. } );
  4570. }
  4571. } );
  4572. // Stop content inside of previous backgrounds
  4573. if( previousBackground ) {
  4574. stopEmbeddedContent( previousBackground );
  4575. }
  4576. // Start content in the current background
  4577. if( currentBackground ) {
  4578. startEmbeddedContent( currentBackground );
  4579. var currentBackgroundContent = currentBackground.querySelector( '.slide-background-content' );
  4580. if( currentBackgroundContent ) {
  4581. var backgroundImageURL = currentBackgroundContent.style.backgroundImage || '';
  4582. // Restart GIFs (doesn't work in Firefox)
  4583. if( /\.gif/i.test( backgroundImageURL ) ) {
  4584. currentBackgroundContent.style.backgroundImage = '';
  4585. window.getComputedStyle( currentBackgroundContent ).opacity;
  4586. currentBackgroundContent.style.backgroundImage = backgroundImageURL;
  4587. }
  4588. }
  4589. // Don't transition between identical backgrounds. This
  4590. // prevents unwanted flicker.
  4591. var previousBackgroundHash = previousBackground ? previousBackground.getAttribute( 'data-background-hash' ) : null;
  4592. var currentBackgroundHash = currentBackground.getAttribute( 'data-background-hash' );
  4593. if( currentBackgroundHash && currentBackgroundHash === previousBackgroundHash && currentBackground !== previousBackground ) {
  4594. dom.background.classList.add( 'no-transition' );
  4595. }
  4596. previousBackground = currentBackground;
  4597. }
  4598. // If there's a background brightness flag for this slide,
  4599. // bubble it to the .reveal container
  4600. if( currentSlide ) {
  4601. [ 'has-light-background', 'has-dark-background' ].forEach( function( classToBubble ) {
  4602. if( currentSlide.classList.contains( classToBubble ) ) {
  4603. dom.wrapper.classList.add( classToBubble );
  4604. }
  4605. else {
  4606. dom.wrapper.classList.remove( classToBubble );
  4607. }
  4608. } );
  4609. }
  4610. // Allow the first background to apply without transition
  4611. setTimeout( function() {
  4612. dom.background.classList.remove( 'no-transition' );
  4613. }, 1 );
  4614. }
  4615. /**
  4616. * Updates the position of the parallax background based
  4617. * on the current slide index.
  4618. */
  4619. function updateParallax() {
  4620. if( config.parallaxBackgroundImage ) {
  4621. var horizontalSlides = dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ),
  4622. verticalSlides = dom.wrapper.querySelectorAll( VERTICAL_SLIDES_SELECTOR );
  4623. var backgroundSize = dom.background.style.backgroundSize.split( ' ' ),
  4624. backgroundWidth, backgroundHeight;
  4625. if( backgroundSize.length === 1 ) {
  4626. backgroundWidth = backgroundHeight = parseInt( backgroundSize[0], 10 );
  4627. }
  4628. else {
  4629. backgroundWidth = parseInt( backgroundSize[0], 10 );
  4630. backgroundHeight = parseInt( backgroundSize[1], 10 );
  4631. }
  4632. var slideWidth = dom.background.offsetWidth,
  4633. horizontalSlideCount = horizontalSlides.length,
  4634. horizontalOffsetMultiplier,
  4635. horizontalOffset;
  4636. if( typeof config.parallaxBackgroundHorizontal === 'number' ) {
  4637. horizontalOffsetMultiplier = config.parallaxBackgroundHorizontal;
  4638. }
  4639. else {
  4640. horizontalOffsetMultiplier = horizontalSlideCount > 1 ? ( backgroundWidth - slideWidth ) / ( horizontalSlideCount-1 ) : 0;
  4641. }
  4642. horizontalOffset = horizontalOffsetMultiplier * indexh * -1;
  4643. var slideHeight = dom.background.offsetHeight,
  4644. verticalSlideCount = verticalSlides.length,
  4645. verticalOffsetMultiplier,
  4646. verticalOffset;
  4647. if( typeof config.parallaxBackgroundVertical === 'number' ) {
  4648. verticalOffsetMultiplier = config.parallaxBackgroundVertical;
  4649. }
  4650. else {
  4651. verticalOffsetMultiplier = ( backgroundHeight - slideHeight ) / ( verticalSlideCount-1 );
  4652. }
  4653. verticalOffset = verticalSlideCount > 0 ? verticalOffsetMultiplier * indexv : 0;
  4654. dom.background.style.backgroundPosition = horizontalOffset + 'px ' + -verticalOffset + 'px';
  4655. }
  4656. }
  4657. /**
  4658. * Should the given element be preloaded?
  4659. * Decides based on local element attributes and global config.
  4660. *
  4661. * @param {HTMLElement} element
  4662. */
  4663. function shouldPreload( element ) {
  4664. // Prefer an explicit global preload setting
  4665. var preload = config.preloadIframes;
  4666. // If no global setting is available, fall back on the element's
  4667. // own preload setting
  4668. if( typeof preload !== 'boolean' ) {
  4669. preload = element.hasAttribute( 'data-preload' );
  4670. }
  4671. return preload;
  4672. }
  4673. /**
  4674. * Called when the given slide is within the configured view
  4675. * distance. Shows the slide element and loads any content
  4676. * that is set to load lazily (data-src).
  4677. *
  4678. * @param {HTMLElement} slide Slide to show
  4679. */
  4680. function loadSlide( slide, options ) {
  4681. options = options || {};
  4682. // Show the slide element
  4683. slide.style.display = config.display;
  4684. // Media elements with data-src attributes
  4685. toArray( slide.querySelectorAll( 'img[data-src], video[data-src], audio[data-src], iframe[data-src]' ) ).forEach( function( element ) {
  4686. if( element.tagName !== 'IFRAME' || shouldPreload( element ) ) {
  4687. element.setAttribute( 'src', element.getAttribute( 'data-src' ) );
  4688. element.setAttribute( 'data-lazy-loaded', '' );
  4689. element.removeAttribute( 'data-src' );
  4690. }
  4691. } );
  4692. // Media elements with <source> children
  4693. toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( media ) {
  4694. var sources = 0;
  4695. toArray( media.querySelectorAll( 'source[data-src]' ) ).forEach( function( source ) {
  4696. source.setAttribute( 'src', source.getAttribute( 'data-src' ) );
  4697. source.removeAttribute( 'data-src' );
  4698. source.setAttribute( 'data-lazy-loaded', '' );
  4699. sources += 1;
  4700. } );
  4701. // If we rewrote sources for this video/audio element, we need
  4702. // to manually tell it to load from its new origin
  4703. if( sources > 0 ) {
  4704. media.load();
  4705. }
  4706. } );
  4707. // Show the corresponding background element
  4708. var background = slide.slideBackgroundElement;
  4709. if( background ) {
  4710. background.style.display = 'block';
  4711. var backgroundContent = slide.slideBackgroundContentElement;
  4712. // If the background contains media, load it
  4713. if( background.hasAttribute( 'data-loaded' ) === false ) {
  4714. background.setAttribute( 'data-loaded', 'true' );
  4715. var backgroundImage = slide.getAttribute( 'data-background-image' ),
  4716. backgroundVideo = slide.getAttribute( 'data-background-video' ),
  4717. backgroundVideoLoop = slide.hasAttribute( 'data-background-video-loop' ),
  4718. backgroundVideoMuted = slide.hasAttribute( 'data-background-video-muted' ),
  4719. backgroundIframe = slide.getAttribute( 'data-background-iframe' );
  4720. // Images
  4721. if( backgroundImage ) {
  4722. backgroundContent.style.backgroundImage = 'url('+ encodeURI( backgroundImage ) +')';
  4723. }
  4724. // Videos
  4725. else if ( backgroundVideo && !isSpeakerNotes() ) {
  4726. var video = document.createElement( 'video' );
  4727. if( backgroundVideoLoop ) {
  4728. video.setAttribute( 'loop', '' );
  4729. }
  4730. if( backgroundVideoMuted ) {
  4731. video.muted = true;
  4732. }
  4733. // Inline video playback works (at least in Mobile Safari) as
  4734. // long as the video is muted and the `playsinline` attribute is
  4735. // present
  4736. if( isMobileDevice ) {
  4737. video.muted = true;
  4738. video.autoplay = true;
  4739. video.setAttribute( 'playsinline', '' );
  4740. }
  4741. // Support comma separated lists of video sources
  4742. backgroundVideo.split( ',' ).forEach( function( source ) {
  4743. video.innerHTML += '<source src="'+ source +'">';
  4744. } );
  4745. backgroundContent.appendChild( video );
  4746. }
  4747. // Iframes
  4748. else if( backgroundIframe && options.excludeIframes !== true ) {
  4749. var iframe = document.createElement( 'iframe' );
  4750. iframe.setAttribute( 'allowfullscreen', '' );
  4751. iframe.setAttribute( 'mozallowfullscreen', '' );
  4752. iframe.setAttribute( 'webkitallowfullscreen', '' );
  4753. // Only load autoplaying content when the slide is shown to
  4754. // avoid having it play in the background
  4755. if( /autoplay=(1|true|yes)/gi.test( backgroundIframe ) ) {
  4756. iframe.setAttribute( 'data-src', backgroundIframe );
  4757. }
  4758. else {
  4759. iframe.setAttribute( 'src', backgroundIframe );
  4760. }
  4761. iframe.style.width = '100%';
  4762. iframe.style.height = '100%';
  4763. iframe.style.maxHeight = '100%';
  4764. iframe.style.maxWidth = '100%';
  4765. backgroundContent.appendChild( iframe );
  4766. }
  4767. }
  4768. }
  4769. }
  4770. /**
  4771. * Unloads and hides the given slide. This is called when the
  4772. * slide is moved outside of the configured view distance.
  4773. *
  4774. * @param {HTMLElement} slide
  4775. */
  4776. function unloadSlide( slide ) {
  4777. // Hide the slide element
  4778. slide.style.display = 'none';
  4779. // Hide the corresponding background element
  4780. var background = getSlideBackground( slide );
  4781. if( background ) {
  4782. background.style.display = 'none';
  4783. }
  4784. // Reset lazy-loaded media elements with src attributes
  4785. toArray( slide.querySelectorAll( 'video[data-lazy-loaded][src], audio[data-lazy-loaded][src], iframe[data-lazy-loaded][src]' ) ).forEach( function( element ) {
  4786. element.setAttribute( 'data-src', element.getAttribute( 'src' ) );
  4787. element.removeAttribute( 'src' );
  4788. } );
  4789. // Reset lazy-loaded media elements with <source> children
  4790. toArray( slide.querySelectorAll( 'video[data-lazy-loaded] source[src], audio source[src]' ) ).forEach( function( source ) {
  4791. source.setAttribute( 'data-src', source.getAttribute( 'src' ) );
  4792. source.removeAttribute( 'src' );
  4793. } );
  4794. }
  4795. /**
  4796. * Determine what available routes there are for navigation.
  4797. *
  4798. * @return {{left: boolean, right: boolean, up: boolean, down: boolean}}
  4799. */
  4800. function availableRoutes() {
  4801. var horizontalSlides = dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ),
  4802. verticalSlides = dom.wrapper.querySelectorAll( VERTICAL_SLIDES_SELECTOR );
  4803. var routes = {
  4804. left: indexh > 0,
  4805. right: indexh < horizontalSlides.length - 1,
  4806. up: indexv > 0,
  4807. down: indexv < verticalSlides.length - 1
  4808. };
  4809. // Looped presentations can always be navigated as long as
  4810. // there are slides available
  4811. if( config.loop ) {
  4812. if( horizontalSlides.length > 1 ) {
  4813. routes.left = true;
  4814. routes.right = true;
  4815. }
  4816. if( verticalSlides.length > 1 ) {
  4817. routes.up = true;
  4818. routes.down = true;
  4819. }
  4820. }
  4821. // Reverse horizontal controls for rtl
  4822. if( config.rtl ) {
  4823. var left = routes.left;
  4824. routes.left = routes.right;
  4825. routes.right = left;
  4826. }
  4827. return routes;
  4828. }
  4829. /**
  4830. * Returns an object describing the available fragment
  4831. * directions.
  4832. *
  4833. * @return {{prev: boolean, next: boolean}}
  4834. */
  4835. function availableFragments() {
  4836. if( currentSlide && config.fragments ) {
  4837. var fragments = currentSlide.querySelectorAll( '.fragment' );
  4838. var hiddenFragments = currentSlide.querySelectorAll( '.fragment:not(.visible)' );
  4839. return {
  4840. prev: fragments.length - hiddenFragments.length > 0,
  4841. next: !!hiddenFragments.length
  4842. };
  4843. }
  4844. else {
  4845. return { prev: false, next: false };
  4846. }
  4847. }
  4848. /**
  4849. * Enforces origin-specific format rules for embedded media.
  4850. */
  4851. function formatEmbeddedContent() {
  4852. var _appendParamToIframeSource = function( sourceAttribute, sourceURL, param ) {
  4853. toArray( dom.slides.querySelectorAll( 'iframe['+ sourceAttribute +'*="'+ sourceURL +'"]' ) ).forEach( function( el ) {
  4854. var src = el.getAttribute( sourceAttribute );
  4855. if( src && src.indexOf( param ) === -1 ) {
  4856. el.setAttribute( sourceAttribute, src + ( !/\?/.test( src ) ? '?' : '&' ) + param );
  4857. }
  4858. });
  4859. };
  4860. // YouTube frames must include "?enablejsapi=1"
  4861. _appendParamToIframeSource( 'src', 'youtube.com/embed/', 'enablejsapi=1' );
  4862. _appendParamToIframeSource( 'data-src', 'youtube.com/embed/', 'enablejsapi=1' );
  4863. // Vimeo frames must include "?api=1"
  4864. _appendParamToIframeSource( 'src', 'player.vimeo.com/', 'api=1' );
  4865. _appendParamToIframeSource( 'data-src', 'player.vimeo.com/', 'api=1' );
  4866. }
  4867. /**
  4868. * Start playback of any embedded content inside of
  4869. * the given element.
  4870. *
  4871. * @param {HTMLElement} element
  4872. */
  4873. function startEmbeddedContent( element ) {
  4874. if( element && !isSpeakerNotes() ) {
  4875. // Restart GIFs
  4876. toArray( element.querySelectorAll( 'img[src$=".gif"]' ) ).forEach( function( el ) {
  4877. // Setting the same unchanged source like this was confirmed
  4878. // to work in Chrome, FF & Safari
  4879. el.setAttribute( 'src', el.getAttribute( 'src' ) );
  4880. } );
  4881. // HTML5 media elements
  4882. toArray( element.querySelectorAll( 'video, audio' ) ).forEach( function( el ) {
  4883. if( closestParent( el, '.fragment' ) && !closestParent( el, '.fragment.visible' ) ) {
  4884. return;
  4885. }
  4886. // Prefer an explicit global autoplay setting
  4887. var autoplay = config.autoPlayMedia;
  4888. // If no global setting is available, fall back on the element's
  4889. // own autoplay setting
  4890. if( typeof autoplay !== 'boolean' ) {
  4891. autoplay = el.hasAttribute( 'data-autoplay' ) || !!closestParent( el, '.slide-background' );
  4892. }
  4893. if( autoplay && typeof el.play === 'function' ) {
  4894. // If the media is ready, start playback
  4895. if( el.readyState > 1 ) {
  4896. startEmbeddedMedia( { target: el } );
  4897. }
  4898. // Mobile devices never fire a loaded event so instead
  4899. // of waiting, we initiate playback
  4900. else if( isMobileDevice ) {
  4901. var promise = el.play();
  4902. // If autoplay does not work, ensure that the controls are visible so
  4903. // that the viewer can start the media on their own
  4904. if( promise && typeof promise.catch === 'function' && el.controls === false ) {
  4905. promise.catch( function() {
  4906. el.controls = true;
  4907. // Once the video does start playing, hide the controls again
  4908. el.addEventListener( 'play', function() {
  4909. el.controls = false;
  4910. } );
  4911. } );
  4912. }
  4913. }
  4914. // If the media isn't loaded, wait before playing
  4915. else {
  4916. el.removeEventListener( 'loadeddata', startEmbeddedMedia ); // remove first to avoid dupes
  4917. el.addEventListener( 'loadeddata', startEmbeddedMedia );
  4918. }
  4919. }
  4920. } );
  4921. // Normal iframes
  4922. toArray( element.querySelectorAll( 'iframe[src]' ) ).forEach( function( el ) {
  4923. if( closestParent( el, '.fragment' ) && !closestParent( el, '.fragment.visible' ) ) {
  4924. return;
  4925. }
  4926. startEmbeddedIframe( { target: el } );
  4927. } );
  4928. // Lazy loading iframes
  4929. toArray( element.querySelectorAll( 'iframe[data-src]' ) ).forEach( function( el ) {
  4930. if( closestParent( el, '.fragment' ) && !closestParent( el, '.fragment.visible' ) ) {
  4931. return;
  4932. }
  4933. if( el.getAttribute( 'src' ) !== el.getAttribute( 'data-src' ) ) {
  4934. el.removeEventListener( 'load', startEmbeddedIframe ); // remove first to avoid dupes
  4935. el.addEventListener( 'load', startEmbeddedIframe );
  4936. el.setAttribute( 'src', el.getAttribute( 'data-src' ) );
  4937. }
  4938. } );
  4939. }
  4940. }
  4941. /**
  4942. * Starts playing an embedded video/audio element after
  4943. * it has finished loading.
  4944. *
  4945. * @param {object} event
  4946. */
  4947. function startEmbeddedMedia( event ) {
  4948. var isAttachedToDOM = !!closestParent( event.target, 'html' ),
  4949. isVisible = !!closestParent( event.target, '.present' );
  4950. if( isAttachedToDOM && isVisible ) {
  4951. event.target.currentTime = 0;
  4952. event.target.play();
  4953. }
  4954. event.target.removeEventListener( 'loadeddata', startEmbeddedMedia );
  4955. }
  4956. /**
  4957. * "Starts" the content of an embedded iframe using the
  4958. * postMessage API.
  4959. *
  4960. * @param {object} event
  4961. */
  4962. function startEmbeddedIframe( event ) {
  4963. var iframe = event.target;
  4964. if( iframe && iframe.contentWindow ) {
  4965. var isAttachedToDOM = !!closestParent( event.target, 'html' ),
  4966. isVisible = !!closestParent( event.target, '.present' );
  4967. if( isAttachedToDOM && isVisible ) {
  4968. // Prefer an explicit global autoplay setting
  4969. var autoplay = config.autoPlayMedia;
  4970. // If no global setting is available, fall back on the element's
  4971. // own autoplay setting
  4972. if( typeof autoplay !== 'boolean' ) {
  4973. autoplay = iframe.hasAttribute( 'data-autoplay' ) || !!closestParent( iframe, '.slide-background' );
  4974. }
  4975. // YouTube postMessage API
  4976. if( /youtube\.com\/embed\//.test( iframe.getAttribute( 'src' ) ) && autoplay ) {
  4977. iframe.contentWindow.postMessage( '{"event":"command","func":"playVideo","args":""}', '*' );
  4978. }
  4979. // Vimeo postMessage API
  4980. else if( /player\.vimeo\.com\//.test( iframe.getAttribute( 'src' ) ) && autoplay ) {
  4981. iframe.contentWindow.postMessage( '{"method":"play"}', '*' );
  4982. }
  4983. // Generic postMessage API
  4984. else {
  4985. iframe.contentWindow.postMessage( 'slide:start', '*' );
  4986. }
  4987. }
  4988. }
  4989. }
  4990. /**
  4991. * Stop playback of any embedded content inside of
  4992. * the targeted slide.
  4993. *
  4994. * @param {HTMLElement} element
  4995. */
  4996. function stopEmbeddedContent( element, options ) {
  4997. options = extend( {
  4998. // Defaults
  4999. unloadIframes: true
  5000. }, options || {} );
  5001. if( element && element.parentNode ) {
  5002. // HTML5 media elements
  5003. toArray( element.querySelectorAll( 'video, audio' ) ).forEach( function( el ) {
  5004. if( !el.hasAttribute( 'data-ignore' ) && typeof el.pause === 'function' ) {
  5005. el.setAttribute('data-paused-by-reveal', '');
  5006. el.pause();
  5007. }
  5008. } );
  5009. // Generic postMessage API for non-lazy loaded iframes
  5010. toArray( element.querySelectorAll( 'iframe' ) ).forEach( function( el ) {
  5011. if( el.contentWindow ) el.contentWindow.postMessage( 'slide:stop', '*' );
  5012. el.removeEventListener( 'load', startEmbeddedIframe );
  5013. });
  5014. // YouTube postMessage API
  5015. toArray( element.querySelectorAll( 'iframe[src*="youtube.com/embed/"]' ) ).forEach( function( el ) {
  5016. if( !el.hasAttribute( 'data-ignore' ) && el.contentWindow && typeof el.contentWindow.postMessage === 'function' ) {
  5017. el.contentWindow.postMessage( '{"event":"command","func":"pauseVideo","args":""}', '*' );
  5018. }
  5019. });
  5020. // Vimeo postMessage API
  5021. toArray( element.querySelectorAll( 'iframe[src*="player.vimeo.com/"]' ) ).forEach( function( el ) {
  5022. if( !el.hasAttribute( 'data-ignore' ) && el.contentWindow && typeof el.contentWindow.postMessage === 'function' ) {
  5023. el.contentWindow.postMessage( '{"method":"pause"}', '*' );
  5024. }
  5025. });
  5026. if( options.unloadIframes === true ) {
  5027. // Unload lazy-loaded iframes
  5028. toArray( element.querySelectorAll( 'iframe[data-src]' ) ).forEach( function( el ) {
  5029. // Only removing the src doesn't actually unload the frame
  5030. // in all browsers (Firefox) so we set it to blank first
  5031. el.setAttribute( 'src', 'about:blank' );
  5032. el.removeAttribute( 'src' );
  5033. } );
  5034. }
  5035. }
  5036. }
  5037. /**
  5038. * Returns the number of past slides. This can be used as a global
  5039. * flattened index for slides.
  5040. *
  5041. * @return {number} Past slide count
  5042. */
  5043. function getSlidePastCount() {
  5044. var horizontalSlides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
  5045. // The number of past slides
  5046. var pastCount = 0;
  5047. // Step through all slides and count the past ones
  5048. mainLoop: for( var i = 0; i < horizontalSlides.length; i++ ) {
  5049. var horizontalSlide = horizontalSlides[i];
  5050. var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) );
  5051. for( var j = 0; j < verticalSlides.length; j++ ) {
  5052. // Stop as soon as we arrive at the present
  5053. if( verticalSlides[j].classList.contains( 'present' ) ) {
  5054. break mainLoop;
  5055. }
  5056. pastCount++;
  5057. }
  5058. // Stop as soon as we arrive at the present
  5059. if( horizontalSlide.classList.contains( 'present' ) ) {
  5060. break;
  5061. }
  5062. // Don't count the wrapping section for vertical slides
  5063. if( horizontalSlide.classList.contains( 'stack' ) === false ) {
  5064. pastCount++;
  5065. }
  5066. }
  5067. return pastCount;
  5068. }
  5069. /**
  5070. * Returns a value ranging from 0-1 that represents
  5071. * how far into the presentation we have navigated.
  5072. *
  5073. * @return {number}
  5074. */
  5075. function getProgress() {
  5076. // The number of past and total slides
  5077. var totalCount = getTotalSlides();
  5078. var pastCount = getSlidePastCount();
  5079. if( currentSlide ) {
  5080. var allFragments = currentSlide.querySelectorAll( '.fragment' );
  5081. // If there are fragments in the current slide those should be
  5082. // accounted for in the progress.
  5083. if( allFragments.length > 0 ) {
  5084. var visibleFragments = currentSlide.querySelectorAll( '.fragment.visible' );
  5085. // This value represents how big a portion of the slide progress
  5086. // that is made up by its fragments (0-1)
  5087. var fragmentWeight = 0.9;
  5088. // Add fragment progress to the past slide count
  5089. pastCount += ( visibleFragments.length / allFragments.length ) * fragmentWeight;
  5090. }
  5091. }
  5092. return Math.min( pastCount / ( totalCount - 1 ), 1 );
  5093. }
  5094. /**
  5095. * Checks if this presentation is running inside of the
  5096. * speaker notes window.
  5097. *
  5098. * @return {boolean}
  5099. */
  5100. function isSpeakerNotes() {
  5101. return !!window.location.search.match( /receiver/gi );
  5102. }
  5103. /**
  5104. * Reads the current URL (hash) and navigates accordingly.
  5105. */
  5106. function readURL() {
  5107. var hash = window.location.hash;
  5108. // Attempt to parse the hash as either an index or name
  5109. var bits = hash.slice( 2 ).split( '/' ),
  5110. name = hash.replace( /#|\//gi, '' );
  5111. // If the first bit is not fully numeric and there is a name we
  5112. // can assume that this is a named link
  5113. if( !/^[0-9]*$/.test( bits[0] ) && name.length ) {
  5114. var element;
  5115. // Ensure the named link is a valid HTML ID attribute
  5116. try {
  5117. element = document.getElementById( decodeURIComponent( name ) );
  5118. }
  5119. catch ( error ) { }
  5120. // Ensure that we're not already on a slide with the same name
  5121. var isSameNameAsCurrentSlide = currentSlide ? currentSlide.getAttribute( 'id' ) === name : false;
  5122. if( element ) {
  5123. // If the slide exists and is not the current slide...
  5124. if ( !isSameNameAsCurrentSlide ) {
  5125. // ...find the position of the named slide and navigate to it
  5126. var indices = Reveal.getIndices(element);
  5127. slide(indices.h, indices.v);
  5128. }
  5129. }
  5130. // If the slide doesn't exist, navigate to the current slide
  5131. else {
  5132. slide( indexh || 0, indexv || 0 );
  5133. }
  5134. }
  5135. else {
  5136. var hashIndexBase = config.hashOneBasedIndex ? 1 : 0;
  5137. // Read the index components of the hash
  5138. var h = ( parseInt( bits[0], 10 ) - hashIndexBase ) || 0,
  5139. v = ( parseInt( bits[1], 10 ) - hashIndexBase ) || 0,
  5140. f;
  5141. if( config.fragmentInURL ) {
  5142. f = parseInt( bits[2], 10 );
  5143. if( isNaN( f ) ) {
  5144. f = undefined;
  5145. }
  5146. }
  5147. if( h !== indexh || v !== indexv || f !== undefined ) {
  5148. slide( h, v, f );
  5149. }
  5150. }
  5151. }
  5152. /**
  5153. * Updates the page URL (hash) to reflect the current
  5154. * state.
  5155. *
  5156. * @param {number} delay The time in ms to wait before
  5157. * writing the hash
  5158. */
  5159. function writeURL( delay ) {
  5160. // Make sure there's never more than one timeout running
  5161. clearTimeout( writeURLTimeout );
  5162. // If a delay is specified, timeout this call
  5163. if( typeof delay === 'number' ) {
  5164. writeURLTimeout = setTimeout( writeURL, delay );
  5165. }
  5166. else if( currentSlide ) {
  5167. // If we're configured to push to history OR the history
  5168. // API is not avaialble.
  5169. if( config.history || !window.history ) {
  5170. window.location.hash = locationHash();
  5171. }
  5172. // If we're configured to reflect the current slide in the
  5173. // URL without pushing to history.
  5174. else if( config.hash ) {
  5175. window.history.replaceState( null, null, '#' + locationHash() );
  5176. }
  5177. // If history and hash are both disabled, a hash may still
  5178. // be added to the URL by clicking on a href with a hash
  5179. // target. Counter this by always removing the hash.
  5180. else {
  5181. window.history.replaceState( null, null, window.location.pathname + window.location.search );
  5182. }
  5183. }
  5184. }
  5185. /**
  5186. * Retrieves the h/v location and fragment of the current,
  5187. * or specified, slide.
  5188. *
  5189. * @param {HTMLElement} [slide] If specified, the returned
  5190. * index will be for this slide rather than the currently
  5191. * active one
  5192. *
  5193. * @return {{h: number, v: number, f: number}}
  5194. */
  5195. function getIndices( slide ) {
  5196. // By default, return the current indices
  5197. var h = indexh,
  5198. v = indexv,
  5199. f;
  5200. // If a slide is specified, return the indices of that slide
  5201. if( slide ) {
  5202. var isVertical = isVerticalSlide( slide );
  5203. var slideh = isVertical ? slide.parentNode : slide;
  5204. // Select all horizontal slides
  5205. var horizontalSlides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
  5206. // Now that we know which the horizontal slide is, get its index
  5207. h = Math.max( horizontalSlides.indexOf( slideh ), 0 );
  5208. // Assume we're not vertical
  5209. v = undefined;
  5210. // If this is a vertical slide, grab the vertical index
  5211. if( isVertical ) {
  5212. v = Math.max( toArray( slide.parentNode.querySelectorAll( 'section' ) ).indexOf( slide ), 0 );
  5213. }
  5214. }
  5215. if( !slide && currentSlide ) {
  5216. var hasFragments = currentSlide.querySelectorAll( '.fragment' ).length > 0;
  5217. if( hasFragments ) {
  5218. var currentFragment = currentSlide.querySelector( '.current-fragment' );
  5219. if( currentFragment && currentFragment.hasAttribute( 'data-fragment-index' ) ) {
  5220. f = parseInt( currentFragment.getAttribute( 'data-fragment-index' ), 10 );
  5221. }
  5222. else {
  5223. f = currentSlide.querySelectorAll( '.fragment.visible' ).length - 1;
  5224. }
  5225. }
  5226. }
  5227. return { h: h, v: v, f: f };
  5228. }
  5229. /**
  5230. * Retrieves all slides in this presentation.
  5231. */
  5232. function getSlides() {
  5233. return toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR + ':not(.stack)' ));
  5234. }
  5235. /**
  5236. * Returns an array of objects where each object represents the
  5237. * attributes on its respective slide.
  5238. */
  5239. function getSlidesAttributes() {
  5240. return getSlides().map( function( slide ) {
  5241. var attributes = {};
  5242. for( var i = 0; i < slide.attributes.length; i++ ) {
  5243. var attribute = slide.attributes[ i ];
  5244. attributes[ attribute.name ] = attribute.value;
  5245. }
  5246. return attributes;
  5247. } );
  5248. }
  5249. /**
  5250. * Retrieves the total number of slides in this presentation.
  5251. *
  5252. * @return {number}
  5253. */
  5254. function getTotalSlides() {
  5255. return getSlides().length;
  5256. }
  5257. /**
  5258. * Returns the slide element matching the specified index.
  5259. *
  5260. * @return {HTMLElement}
  5261. */
  5262. function getSlide( x, y ) {
  5263. var horizontalSlide = dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR )[ x ];
  5264. var verticalSlides = horizontalSlide && horizontalSlide.querySelectorAll( 'section' );
  5265. if( verticalSlides && verticalSlides.length && typeof y === 'number' ) {
  5266. return verticalSlides ? verticalSlides[ y ] : undefined;
  5267. }
  5268. return horizontalSlide;
  5269. }
  5270. /**
  5271. * Returns the background element for the given slide.
  5272. * All slides, even the ones with no background properties
  5273. * defined, have a background element so as long as the
  5274. * index is valid an element will be returned.
  5275. *
  5276. * @param {mixed} x Horizontal background index OR a slide
  5277. * HTML element
  5278. * @param {number} y Vertical background index
  5279. * @return {(HTMLElement[]|*)}
  5280. */
  5281. function getSlideBackground( x, y ) {
  5282. var slide = typeof x === 'number' ? getSlide( x, y ) : x;
  5283. if( slide ) {
  5284. return slide.slideBackgroundElement;
  5285. }
  5286. return undefined;
  5287. }
  5288. /**
  5289. * Retrieves the speaker notes from a slide. Notes can be
  5290. * defined in two ways:
  5291. * 1. As a data-notes attribute on the slide <section>
  5292. * 2. As an <aside class="notes"> inside of the slide
  5293. *
  5294. * @param {HTMLElement} [slide=currentSlide]
  5295. * @return {(string|null)}
  5296. */
  5297. function getSlideNotes( slide ) {
  5298. // Default to the current slide
  5299. slide = slide || currentSlide;
  5300. // Notes can be specified via the data-notes attribute...
  5301. if( slide.hasAttribute( 'data-notes' ) ) {
  5302. return slide.getAttribute( 'data-notes' );
  5303. }
  5304. // ... or using an <aside class="notes"> element
  5305. var notesElement = slide.querySelector( 'aside.notes' );
  5306. if( notesElement ) {
  5307. return notesElement.innerHTML;
  5308. }
  5309. return null;
  5310. }
  5311. /**
  5312. * Retrieves the current state of the presentation as
  5313. * an object. This state can then be restored at any
  5314. * time.
  5315. *
  5316. * @return {{indexh: number, indexv: number, indexf: number, paused: boolean, overview: boolean}}
  5317. */
  5318. function getState() {
  5319. var indices = getIndices();
  5320. return {
  5321. indexh: indices.h,
  5322. indexv: indices.v,
  5323. indexf: indices.f,
  5324. paused: isPaused(),
  5325. overview: isOverview()
  5326. };
  5327. }
  5328. /**
  5329. * Restores the presentation to the given state.
  5330. *
  5331. * @param {object} state As generated by getState()
  5332. * @see {@link getState} generates the parameter `state`
  5333. */
  5334. function setState( state ) {
  5335. if( typeof state === 'object' ) {
  5336. slide( deserialize( state.indexh ), deserialize( state.indexv ), deserialize( state.indexf ) );
  5337. var pausedFlag = deserialize( state.paused ),
  5338. overviewFlag = deserialize( state.overview );
  5339. if( typeof pausedFlag === 'boolean' && pausedFlag !== isPaused() ) {
  5340. togglePause( pausedFlag );
  5341. }
  5342. if( typeof overviewFlag === 'boolean' && overviewFlag !== isOverview() ) {
  5343. toggleOverview( overviewFlag );
  5344. }
  5345. }
  5346. }
  5347. /**
  5348. * Return a sorted fragments list, ordered by an increasing
  5349. * "data-fragment-index" attribute.
  5350. *
  5351. * Fragments will be revealed in the order that they are returned by
  5352. * this function, so you can use the index attributes to control the
  5353. * order of fragment appearance.
  5354. *
  5355. * To maintain a sensible default fragment order, fragments are presumed
  5356. * to be passed in document order. This function adds a "fragment-index"
  5357. * attribute to each node if such an attribute is not already present,
  5358. * and sets that attribute to an integer value which is the position of
  5359. * the fragment within the fragments list.
  5360. *
  5361. * @param {object[]|*} fragments
  5362. * @param {boolean} grouped If true the returned array will contain
  5363. * nested arrays for all fragments with the same index
  5364. * @return {object[]} sorted Sorted array of fragments
  5365. */
  5366. function sortFragments( fragments, grouped ) {
  5367. fragments = toArray( fragments );
  5368. var ordered = [],
  5369. unordered = [],
  5370. sorted = [];
  5371. // Group ordered and unordered elements
  5372. fragments.forEach( function( fragment, i ) {
  5373. if( fragment.hasAttribute( 'data-fragment-index' ) ) {
  5374. var index = parseInt( fragment.getAttribute( 'data-fragment-index' ), 10 );
  5375. if( !ordered[index] ) {
  5376. ordered[index] = [];
  5377. }
  5378. ordered[index].push( fragment );
  5379. }
  5380. else {
  5381. unordered.push( [ fragment ] );
  5382. }
  5383. } );
  5384. // Append fragments without explicit indices in their
  5385. // DOM order
  5386. ordered = ordered.concat( unordered );
  5387. // Manually count the index up per group to ensure there
  5388. // are no gaps
  5389. var index = 0;
  5390. // Push all fragments in their sorted order to an array,
  5391. // this flattens the groups
  5392. ordered.forEach( function( group ) {
  5393. group.forEach( function( fragment ) {
  5394. sorted.push( fragment );
  5395. fragment.setAttribute( 'data-fragment-index', index );
  5396. } );
  5397. index ++;
  5398. } );
  5399. return grouped === true ? ordered : sorted;
  5400. }
  5401. /**
  5402. * Refreshes the fragments on the current slide so that they
  5403. * have the appropriate classes (.visible + .current-fragment).
  5404. *
  5405. * @param {number} [index] The index of the current fragment
  5406. * @param {array} [fragments] Array containing all fragments
  5407. * in the current slide
  5408. *
  5409. * @return {{shown: array, hidden: array}}
  5410. */
  5411. function updateFragments( index, fragments ) {
  5412. var changedFragments = {
  5413. shown: [],
  5414. hidden: []
  5415. };
  5416. if( currentSlide && config.fragments ) {
  5417. fragments = fragments || sortFragments( currentSlide.querySelectorAll( '.fragment' ) );
  5418. if( fragments.length ) {
  5419. if( typeof index !== 'number' ) {
  5420. var currentFragment = sortFragments( currentSlide.querySelectorAll( '.fragment.visible' ) ).pop();
  5421. if( currentFragment ) {
  5422. index = parseInt( currentFragment.getAttribute( 'data-fragment-index' ) || 0, 10 );
  5423. }
  5424. }
  5425. toArray( fragments ).forEach( function( el, i ) {
  5426. if( el.hasAttribute( 'data-fragment-index' ) ) {
  5427. i = parseInt( el.getAttribute( 'data-fragment-index' ), 10 );
  5428. }
  5429. // Visible fragments
  5430. if( i <= index ) {
  5431. if( !el.classList.contains( 'visible' ) ) changedFragments.shown.push( el );
  5432. el.classList.add( 'visible' );
  5433. el.classList.remove( 'current-fragment' );
  5434. // Announce the fragments one by one to the Screen Reader
  5435. dom.statusDiv.textContent = getStatusText( el );
  5436. if( i === index ) {
  5437. el.classList.add( 'current-fragment' );
  5438. startEmbeddedContent( el );
  5439. }
  5440. }
  5441. // Hidden fragments
  5442. else {
  5443. if( el.classList.contains( 'visible' ) ) changedFragments.hidden.push( el );
  5444. el.classList.remove( 'visible' );
  5445. el.classList.remove( 'current-fragment' );
  5446. }
  5447. } );
  5448. }
  5449. }
  5450. return changedFragments;
  5451. }
  5452. /**
  5453. * Navigate to the specified slide fragment.
  5454. *
  5455. * @param {?number} index The index of the fragment that
  5456. * should be shown, -1 means all are invisible
  5457. * @param {number} offset Integer offset to apply to the
  5458. * fragment index
  5459. *
  5460. * @return {boolean} true if a change was made in any
  5461. * fragments visibility as part of this call
  5462. */
  5463. function navigateFragment( index, offset ) {
  5464. if( currentSlide && config.fragments ) {
  5465. var fragments = sortFragments( currentSlide.querySelectorAll( '.fragment' ) );
  5466. if( fragments.length ) {
  5467. // If no index is specified, find the current
  5468. if( typeof index !== 'number' ) {
  5469. var lastVisibleFragment = sortFragments( currentSlide.querySelectorAll( '.fragment.visible' ) ).pop();
  5470. if( lastVisibleFragment ) {
  5471. index = parseInt( lastVisibleFragment.getAttribute( 'data-fragment-index' ) || 0, 10 );
  5472. }
  5473. else {
  5474. index = -1;
  5475. }
  5476. }
  5477. // If an offset is specified, apply it to the index
  5478. if( typeof offset === 'number' ) {
  5479. index += offset;
  5480. }
  5481. var changedFragments = updateFragments( index, fragments );
  5482. if( changedFragments.hidden.length ) {
  5483. dispatchEvent( 'fragmenthidden', { fragment: changedFragments.hidden[0], fragments: changedFragments.hidden } );
  5484. }
  5485. if( changedFragments.shown.length ) {
  5486. dispatchEvent( 'fragmentshown', { fragment: changedFragments.shown[0], fragments: changedFragments.shown } );
  5487. }
  5488. updateControls();
  5489. updateProgress();
  5490. if( config.fragmentInURL ) {
  5491. writeURL();
  5492. }
  5493. return !!( changedFragments.shown.length || changedFragments.hidden.length );
  5494. }
  5495. }
  5496. return false;
  5497. }
  5498. /**
  5499. * Navigate to the next slide fragment.
  5500. *
  5501. * @return {boolean} true if there was a next fragment,
  5502. * false otherwise
  5503. */
  5504. function nextFragment() {
  5505. return navigateFragment( null, 1 );
  5506. }
  5507. /**
  5508. * Navigate to the previous slide fragment.
  5509. *
  5510. * @return {boolean} true if there was a previous fragment,
  5511. * false otherwise
  5512. */
  5513. function previousFragment() {
  5514. return navigateFragment( null, -1 );
  5515. }
  5516. /**
  5517. * Cues a new automated slide if enabled in the config.
  5518. */
  5519. function cueAutoSlide() {
  5520. cancelAutoSlide();
  5521. if( currentSlide && config.autoSlide !== false ) {
  5522. var fragment = currentSlide.querySelector( '.current-fragment' );
  5523. // When the slide first appears there is no "current" fragment so
  5524. // we look for a data-autoslide timing on the first fragment
  5525. if( !fragment ) fragment = currentSlide.querySelector( '.fragment' );
  5526. var fragmentAutoSlide = fragment ? fragment.getAttribute( 'data-autoslide' ) : null;
  5527. var parentAutoSlide = currentSlide.parentNode ? currentSlide.parentNode.getAttribute( 'data-autoslide' ) : null;
  5528. var slideAutoSlide = currentSlide.getAttribute( 'data-autoslide' );
  5529. // Pick value in the following priority order:
  5530. // 1. Current fragment's data-autoslide
  5531. // 2. Current slide's data-autoslide
  5532. // 3. Parent slide's data-autoslide
  5533. // 4. Global autoSlide setting
  5534. if( fragmentAutoSlide ) {
  5535. autoSlide = parseInt( fragmentAutoSlide, 10 );
  5536. }
  5537. else if( slideAutoSlide ) {
  5538. autoSlide = parseInt( slideAutoSlide, 10 );
  5539. }
  5540. else if( parentAutoSlide ) {
  5541. autoSlide = parseInt( parentAutoSlide, 10 );
  5542. }
  5543. else {
  5544. autoSlide = config.autoSlide;
  5545. }
  5546. // If there are media elements with data-autoplay,
  5547. // automatically set the autoSlide duration to the
  5548. // length of that media. Not applicable if the slide
  5549. // is divided up into fragments.
  5550. // playbackRate is accounted for in the duration.
  5551. if( currentSlide.querySelectorAll( '.fragment' ).length === 0 ) {
  5552. toArray( currentSlide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) {
  5553. if( el.hasAttribute( 'data-autoplay' ) ) {
  5554. if( autoSlide && (el.duration * 1000 / el.playbackRate ) > autoSlide ) {
  5555. autoSlide = ( el.duration * 1000 / el.playbackRate ) + 1000;
  5556. }
  5557. }
  5558. } );
  5559. }
  5560. // Cue the next auto-slide if:
  5561. // - There is an autoSlide value
  5562. // - Auto-sliding isn't paused by the user
  5563. // - The presentation isn't paused
  5564. // - The overview isn't active
  5565. // - The presentation isn't over
  5566. if( autoSlide && !autoSlidePaused && !isPaused() && !isOverview() && ( !Reveal.isLastSlide() || availableFragments().next || config.loop === true ) ) {
  5567. autoSlideTimeout = setTimeout( function() {
  5568. typeof config.autoSlideMethod === 'function' ? config.autoSlideMethod() : navigateNext();
  5569. cueAutoSlide();
  5570. }, autoSlide );
  5571. autoSlideStartTime = Date.now();
  5572. }
  5573. if( autoSlidePlayer ) {
  5574. autoSlidePlayer.setPlaying( autoSlideTimeout !== -1 );
  5575. }
  5576. }
  5577. }
  5578. /**
  5579. * Cancels any ongoing request to auto-slide.
  5580. */
  5581. function cancelAutoSlide() {
  5582. clearTimeout( autoSlideTimeout );
  5583. autoSlideTimeout = -1;
  5584. }
  5585. function pauseAutoSlide() {
  5586. if( autoSlide && !autoSlidePaused ) {
  5587. autoSlidePaused = true;
  5588. dispatchEvent( 'autoslidepaused' );
  5589. clearTimeout( autoSlideTimeout );
  5590. if( autoSlidePlayer ) {
  5591. autoSlidePlayer.setPlaying( false );
  5592. }
  5593. }
  5594. }
  5595. function resumeAutoSlide() {
  5596. if( autoSlide && autoSlidePaused ) {
  5597. autoSlidePaused = false;
  5598. dispatchEvent( 'autoslideresumed' );
  5599. cueAutoSlide();
  5600. }
  5601. }
  5602. function navigateLeft() {
  5603. // Reverse for RTL
  5604. if( config.rtl ) {
  5605. if( ( isOverview() || nextFragment() === false ) && availableRoutes().left ) {
  5606. slide( indexh + 1, config.navigationMode === 'grid' ? indexv : undefined );
  5607. }
  5608. }
  5609. // Normal navigation
  5610. else if( ( isOverview() || previousFragment() === false ) && availableRoutes().left ) {
  5611. slide( indexh - 1, config.navigationMode === 'grid' ? indexv : undefined );
  5612. }
  5613. }
  5614. function navigateRight() {
  5615. hasNavigatedRight = true;
  5616. // Reverse for RTL
  5617. if( config.rtl ) {
  5618. if( ( isOverview() || previousFragment() === false ) && availableRoutes().right ) {
  5619. slide( indexh - 1, config.navigationMode === 'grid' ? indexv : undefined );
  5620. }
  5621. }
  5622. // Normal navigation
  5623. else if( ( isOverview() || nextFragment() === false ) && availableRoutes().right ) {
  5624. slide( indexh + 1, config.navigationMode === 'grid' ? indexv : undefined );
  5625. }
  5626. }
  5627. function navigateUp() {
  5628. // Prioritize hiding fragments
  5629. if( ( isOverview() || previousFragment() === false ) && availableRoutes().up ) {
  5630. slide( indexh, indexv - 1 );
  5631. }
  5632. }
  5633. function navigateDown() {
  5634. hasNavigatedDown = true;
  5635. // Prioritize revealing fragments
  5636. if( ( isOverview() || nextFragment() === false ) && availableRoutes().down ) {
  5637. slide( indexh, indexv + 1 );
  5638. }
  5639. }
  5640. /**
  5641. * Navigates backwards, prioritized in the following order:
  5642. * 1) Previous fragment
  5643. * 2) Previous vertical slide
  5644. * 3) Previous horizontal slide
  5645. */
  5646. function navigatePrev() {
  5647. // Prioritize revealing fragments
  5648. if( previousFragment() === false ) {
  5649. if( availableRoutes().up ) {
  5650. navigateUp();
  5651. }
  5652. else {
  5653. // Fetch the previous horizontal slide, if there is one
  5654. var previousSlide;
  5655. if( config.rtl ) {
  5656. previousSlide = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.future' ) ).pop();
  5657. }
  5658. else {
  5659. previousSlide = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.past' ) ).pop();
  5660. }
  5661. if( previousSlide ) {
  5662. var v = ( previousSlide.querySelectorAll( 'section' ).length - 1 ) || undefined;
  5663. var h = indexh - 1;
  5664. slide( h, v );
  5665. }
  5666. }
  5667. }
  5668. }
  5669. /**
  5670. * The reverse of #navigatePrev().
  5671. */
  5672. function navigateNext() {
  5673. hasNavigatedRight = true;
  5674. hasNavigatedDown = true;
  5675. // Prioritize revealing fragments
  5676. if( nextFragment() === false ) {
  5677. var routes = availableRoutes();
  5678. // When looping is enabled `routes.down` is always available
  5679. // so we need a separate check for when we've reached the
  5680. // end of a stack and should move horizontally
  5681. if( routes.down && routes.right && config.loop && Reveal.isLastVerticalSlide( currentSlide ) ) {
  5682. routes.down = false;
  5683. }
  5684. if( routes.down ) {
  5685. navigateDown();
  5686. }
  5687. else if( config.rtl ) {
  5688. navigateLeft();
  5689. }
  5690. else {
  5691. navigateRight();
  5692. }
  5693. }
  5694. }
  5695. /**
  5696. * Checks if the target element prevents the triggering of
  5697. * swipe navigation.
  5698. */
  5699. function isSwipePrevented( target ) {
  5700. while( target && typeof target.hasAttribute === 'function' ) {
  5701. if( target.hasAttribute( 'data-prevent-swipe' ) ) return true;
  5702. target = target.parentNode;
  5703. }
  5704. return false;
  5705. }
  5706. // --------------------------------------------------------------------//
  5707. // ----------------------------- EVENTS -------------------------------//
  5708. // --------------------------------------------------------------------//
  5709. /**
  5710. * Called by all event handlers that are based on user
  5711. * input.
  5712. *
  5713. * @param {object} [event]
  5714. */
  5715. function onUserInput( event ) {
  5716. if( config.autoSlideStoppable ) {
  5717. pauseAutoSlide();
  5718. }
  5719. }
  5720. /**
  5721. * Called whenever there is mouse input at the document level
  5722. * to determine if the cursor is active or not.
  5723. *
  5724. * @param {object} event
  5725. */
  5726. function onDocumentCursorActive( event ) {
  5727. showCursor();
  5728. clearTimeout( cursorInactiveTimeout );
  5729. cursorInactiveTimeout = setTimeout( hideCursor, config.hideCursorTime );
  5730. }
  5731. /**
  5732. * Handler for the document level 'keypress' event.
  5733. *
  5734. * @param {object} event
  5735. */
  5736. function onDocumentKeyPress( event ) {
  5737. // Check if the pressed key is question mark
  5738. if( event.shiftKey && event.charCode === 63 ) {
  5739. toggleHelp();
  5740. }
  5741. }
  5742. /**
  5743. * Handler for the document level 'keydown' event.
  5744. *
  5745. * @param {object} event
  5746. */
  5747. function onDocumentKeyDown( event ) {
  5748. // If there's a condition specified and it returns false,
  5749. // ignore this event
  5750. if( typeof config.keyboardCondition === 'function' && config.keyboardCondition(event) === false ) {
  5751. return true;
  5752. }
  5753. // Shorthand
  5754. var keyCode = event.keyCode;
  5755. // Remember if auto-sliding was paused so we can toggle it
  5756. var autoSlideWasPaused = autoSlidePaused;
  5757. onUserInput( event );
  5758. // Is there a focused element that could be using the keyboard?
  5759. var activeElementIsCE = document.activeElement && document.activeElement.contentEditable !== 'inherit';
  5760. var activeElementIsInput = document.activeElement && document.activeElement.tagName && /input|textarea/i.test( document.activeElement.tagName );
  5761. var activeElementIsNotes = document.activeElement && document.activeElement.className && /speaker-notes/i.test( document.activeElement.className);
  5762. // Whitelist specific modified + keycode combinations
  5763. var prevSlideShortcut = event.shiftKey && event.keyCode === 32;
  5764. var firstSlideShortcut = ( event.metaKey || event.ctrlKey ) && keyCode === 37;
  5765. var lastSlideShortcut = ( event.metaKey || event.ctrlKey ) && keyCode === 39;
  5766. // Prevent all other events when a modifier is pressed
  5767. var unusedModifier = !prevSlideShortcut && !firstSlideShortcut && !lastSlideShortcut &&
  5768. ( event.shiftKey || event.altKey || event.ctrlKey || event.metaKey );
  5769. // Disregard the event if there's a focused element or a
  5770. // keyboard modifier key is present
  5771. if( activeElementIsCE || activeElementIsInput || activeElementIsNotes || unusedModifier ) return;
  5772. // While paused only allow resume keyboard events; 'b', 'v', '.'
  5773. var resumeKeyCodes = [66,86,190,191];
  5774. var key;
  5775. // Custom key bindings for togglePause should be able to resume
  5776. if( typeof config.keyboard === 'object' ) {
  5777. for( key in config.keyboard ) {
  5778. if( config.keyboard[key] === 'togglePause' ) {
  5779. resumeKeyCodes.push( parseInt( key, 10 ) );
  5780. }
  5781. }
  5782. }
  5783. if( isPaused() && resumeKeyCodes.indexOf( keyCode ) === -1 ) {
  5784. return false;
  5785. }
  5786. var triggered = false;
  5787. // 1. User defined key bindings
  5788. if( typeof config.keyboard === 'object' ) {
  5789. for( key in config.keyboard ) {
  5790. // Check if this binding matches the pressed key
  5791. if( parseInt( key, 10 ) === keyCode ) {
  5792. var value = config.keyboard[ key ];
  5793. // Callback function
  5794. if( typeof value === 'function' ) {
  5795. value.apply( null, [ event ] );
  5796. }
  5797. // String shortcuts to reveal.js API
  5798. else if( typeof value === 'string' && typeof Reveal[ value ] === 'function' ) {
  5799. Reveal[ value ].call();
  5800. }
  5801. triggered = true;
  5802. }
  5803. }
  5804. }
  5805. // 2. Registered custom key bindings
  5806. if( triggered === false ) {
  5807. for( key in registeredKeyBindings ) {
  5808. // Check if this binding matches the pressed key
  5809. if( parseInt( key, 10 ) === keyCode ) {
  5810. var action = registeredKeyBindings[ key ].callback;
  5811. // Callback function
  5812. if( typeof action === 'function' ) {
  5813. action.apply( null, [ event ] );
  5814. }
  5815. // String shortcuts to reveal.js API
  5816. else if( typeof action === 'string' && typeof Reveal[ action ] === 'function' ) {
  5817. Reveal[ action ].call();
  5818. }
  5819. triggered = true;
  5820. }
  5821. }
  5822. }
  5823. // 3. System defined key bindings
  5824. if( triggered === false ) {
  5825. // Assume true and try to prove false
  5826. triggered = true;
  5827. // P, PAGE UP
  5828. if( keyCode === 80 || keyCode === 33 ) {
  5829. navigatePrev();
  5830. }
  5831. // N, PAGE DOWN
  5832. else if( keyCode === 78 || keyCode === 34 ) {
  5833. navigateNext();
  5834. }
  5835. // H, LEFT
  5836. else if( keyCode === 72 || keyCode === 37 ) {
  5837. if( firstSlideShortcut ) {
  5838. slide( 0 );
  5839. }
  5840. else if( !isOverview() && config.navigationMode === 'linear' ) {
  5841. navigatePrev();
  5842. }
  5843. else {
  5844. navigateLeft();
  5845. }
  5846. }
  5847. // L, RIGHT
  5848. else if( keyCode === 76 || keyCode === 39 ) {
  5849. if( lastSlideShortcut ) {
  5850. slide( Number.MAX_VALUE );
  5851. }
  5852. else if( !isOverview() && config.navigationMode === 'linear' ) {
  5853. navigateNext();
  5854. }
  5855. else {
  5856. navigateRight();
  5857. }
  5858. }
  5859. // K, UP
  5860. else if( keyCode === 75 || keyCode === 38 ) {
  5861. if( !isOverview() && config.navigationMode === 'linear' ) {
  5862. navigatePrev();
  5863. }
  5864. else {
  5865. navigateUp();
  5866. }
  5867. }
  5868. // J, DOWN
  5869. else if( keyCode === 74 || keyCode === 40 ) {
  5870. if( !isOverview() && config.navigationMode === 'linear' ) {
  5871. navigateNext();
  5872. }
  5873. else {
  5874. navigateDown();
  5875. }
  5876. }
  5877. // HOME
  5878. else if( keyCode === 36 ) {
  5879. slide( 0 );
  5880. }
  5881. // END
  5882. else if( keyCode === 35 ) {
  5883. slide( Number.MAX_VALUE );
  5884. }
  5885. // SPACE
  5886. else if( keyCode === 32 ) {
  5887. if( isOverview() ) {
  5888. deactivateOverview();
  5889. }
  5890. if( event.shiftKey ) {
  5891. navigatePrev();
  5892. }
  5893. else {
  5894. navigateNext();
  5895. }
  5896. }
  5897. // TWO-SPOT, SEMICOLON, B, V, PERIOD, LOGITECH PRESENTER TOOLS "BLACK SCREEN" BUTTON
  5898. else if( keyCode === 58 || keyCode === 59 || keyCode === 66 || keyCode === 86 || keyCode === 190 || keyCode === 191 ) {
  5899. togglePause();
  5900. }
  5901. // F
  5902. else if( keyCode === 70 ) {
  5903. enterFullscreen();
  5904. }
  5905. // A
  5906. else if( keyCode === 65 ) {
  5907. if ( config.autoSlideStoppable ) {
  5908. toggleAutoSlide( autoSlideWasPaused );
  5909. }
  5910. }
  5911. else {
  5912. triggered = false;
  5913. }
  5914. }
  5915. // If the input resulted in a triggered action we should prevent
  5916. // the browsers default behavior
  5917. if( triggered ) {
  5918. event.preventDefault && event.preventDefault();
  5919. }
  5920. // ESC or O key
  5921. else if ( ( keyCode === 27 || keyCode === 79 ) && features.transforms3d ) {
  5922. if( dom.overlay ) {
  5923. closeOverlay();
  5924. }
  5925. else {
  5926. toggleOverview();
  5927. }
  5928. event.preventDefault && event.preventDefault();
  5929. }
  5930. // If auto-sliding is enabled we need to cue up
  5931. // another timeout
  5932. cueAutoSlide();
  5933. }
  5934. /**
  5935. * Handler for the 'touchstart' event, enables support for
  5936. * swipe and pinch gestures.
  5937. *
  5938. * @param {object} event
  5939. */
  5940. function onTouchStart( event ) {
  5941. if( isSwipePrevented( event.target ) ) return true;
  5942. touch.startX = event.touches[0].clientX;
  5943. touch.startY = event.touches[0].clientY;
  5944. touch.startCount = event.touches.length;
  5945. }
  5946. /**
  5947. * Handler for the 'touchmove' event.
  5948. *
  5949. * @param {object} event
  5950. */
  5951. function onTouchMove( event ) {
  5952. if( isSwipePrevented( event.target ) ) return true;
  5953. // Each touch should only trigger one action
  5954. if( !touch.captured ) {
  5955. onUserInput( event );
  5956. var currentX = event.touches[0].clientX;
  5957. var currentY = event.touches[0].clientY;
  5958. // There was only one touch point, look for a swipe
  5959. if( event.touches.length === 1 && touch.startCount !== 2 ) {
  5960. var deltaX = currentX - touch.startX,
  5961. deltaY = currentY - touch.startY;
  5962. if( deltaX > touch.threshold && Math.abs( deltaX ) > Math.abs( deltaY ) ) {
  5963. touch.captured = true;
  5964. navigateLeft();
  5965. }
  5966. else if( deltaX < -touch.threshold && Math.abs( deltaX ) > Math.abs( deltaY ) ) {
  5967. touch.captured = true;
  5968. navigateRight();
  5969. }
  5970. else if( deltaY > touch.threshold ) {
  5971. touch.captured = true;
  5972. navigateUp();
  5973. }
  5974. else if( deltaY < -touch.threshold ) {
  5975. touch.captured = true;
  5976. navigateDown();
  5977. }
  5978. // If we're embedded, only block touch events if they have
  5979. // triggered an action
  5980. if( config.embedded ) {
  5981. if( touch.captured || isVerticalSlide( currentSlide ) ) {
  5982. event.preventDefault();
  5983. }
  5984. }
  5985. // Not embedded? Block them all to avoid needless tossing
  5986. // around of the viewport in iOS
  5987. else {
  5988. event.preventDefault();
  5989. }
  5990. }
  5991. }
  5992. // There's a bug with swiping on some Android devices unless
  5993. // the default action is always prevented
  5994. else if( UA.match( /android/gi ) ) {
  5995. event.preventDefault();
  5996. }
  5997. }
  5998. /**
  5999. * Handler for the 'touchend' event.
  6000. *
  6001. * @param {object} event
  6002. */
  6003. function onTouchEnd( event ) {
  6004. touch.captured = false;
  6005. }
  6006. /**
  6007. * Convert pointer down to touch start.
  6008. *
  6009. * @param {object} event
  6010. */
  6011. function onPointerDown( event ) {
  6012. if( event.pointerType === event.MSPOINTER_TYPE_TOUCH || event.pointerType === "touch" ) {
  6013. event.touches = [{ clientX: event.clientX, clientY: event.clientY }];
  6014. onTouchStart( event );
  6015. }
  6016. }
  6017. /**
  6018. * Convert pointer move to touch move.
  6019. *
  6020. * @param {object} event
  6021. */
  6022. function onPointerMove( event ) {
  6023. if( event.pointerType === event.MSPOINTER_TYPE_TOUCH || event.pointerType === "touch" ) {
  6024. event.touches = [{ clientX: event.clientX, clientY: event.clientY }];
  6025. onTouchMove( event );
  6026. }
  6027. }
  6028. /**
  6029. * Convert pointer up to touch end.
  6030. *
  6031. * @param {object} event
  6032. */
  6033. function onPointerUp( event ) {
  6034. if( event.pointerType === event.MSPOINTER_TYPE_TOUCH || event.pointerType === "touch" ) {
  6035. event.touches = [{ clientX: event.clientX, clientY: event.clientY }];
  6036. onTouchEnd( event );
  6037. }
  6038. }
  6039. /**
  6040. * Handles mouse wheel scrolling, throttled to avoid skipping
  6041. * multiple slides.
  6042. *
  6043. * @param {object} event
  6044. */
  6045. function onDocumentMouseScroll( event ) {
  6046. if( Date.now() - lastMouseWheelStep > 600 ) {
  6047. lastMouseWheelStep = Date.now();
  6048. var delta = event.detail || -event.wheelDelta;
  6049. if( delta > 0 ) {
  6050. navigateNext();
  6051. }
  6052. else if( delta < 0 ) {
  6053. navigatePrev();
  6054. }
  6055. }
  6056. }
  6057. /**
  6058. * Clicking on the progress bar results in a navigation to the
  6059. * closest approximate horizontal slide using this equation:
  6060. *
  6061. * ( clickX / presentationWidth ) * numberOfSlides
  6062. *
  6063. * @param {object} event
  6064. */
  6065. function onProgressClicked( event ) {
  6066. onUserInput( event );
  6067. event.preventDefault();
  6068. var slidesTotal = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).length;
  6069. var slideIndex = Math.floor( ( event.clientX / dom.wrapper.offsetWidth ) * slidesTotal );
  6070. if( config.rtl ) {
  6071. slideIndex = slidesTotal - slideIndex;
  6072. }
  6073. slide( slideIndex );
  6074. }
  6075. /**
  6076. * Event handler for navigation control buttons.
  6077. */
  6078. function onNavigateLeftClicked( event ) { event.preventDefault(); onUserInput(); config.navigationMode === 'linear' ? navigatePrev() : navigateLeft(); }
  6079. function onNavigateRightClicked( event ) { event.preventDefault(); onUserInput(); config.navigationMode === 'linear' ? navigateNext() : navigateRight(); }
  6080. function onNavigateUpClicked( event ) { event.preventDefault(); onUserInput(); navigateUp(); }
  6081. function onNavigateDownClicked( event ) { event.preventDefault(); onUserInput(); navigateDown(); }
  6082. function onNavigatePrevClicked( event ) { event.preventDefault(); onUserInput(); navigatePrev(); }
  6083. function onNavigateNextClicked( event ) { event.preventDefault(); onUserInput(); navigateNext(); }
  6084. /**
  6085. * Handler for the window level 'hashchange' event.
  6086. *
  6087. * @param {object} [event]
  6088. */
  6089. function onWindowHashChange( event ) {
  6090. readURL();
  6091. }
  6092. /**
  6093. * Handler for the window level 'resize' event.
  6094. *
  6095. * @param {object} [event]
  6096. */
  6097. function onWindowResize( event ) {
  6098. layout();
  6099. }
  6100. /**
  6101. * Handle for the window level 'visibilitychange' event.
  6102. *
  6103. * @param {object} [event]
  6104. */
  6105. function onPageVisibilityChange( event ) {
  6106. var isHidden = document.webkitHidden ||
  6107. document.msHidden ||
  6108. document.hidden;
  6109. // If, after clicking a link or similar and we're coming back,
  6110. // focus the document.body to ensure we can use keyboard shortcuts
  6111. if( isHidden === false && document.activeElement !== document.body ) {
  6112. // Not all elements support .blur() - SVGs among them.
  6113. if( typeof document.activeElement.blur === 'function' ) {
  6114. document.activeElement.blur();
  6115. }
  6116. document.body.focus();
  6117. }
  6118. }
  6119. /**
  6120. * Invoked when a slide is and we're in the overview.
  6121. *
  6122. * @param {object} event
  6123. */
  6124. function onOverviewSlideClicked( event ) {
  6125. // TODO There's a bug here where the event listeners are not
  6126. // removed after deactivating the overview.
  6127. if( eventsAreBound && isOverview() ) {
  6128. event.preventDefault();
  6129. var element = event.target;
  6130. while( element && !element.nodeName.match( /section/gi ) ) {
  6131. element = element.parentNode;
  6132. }
  6133. if( element && !element.classList.contains( 'disabled' ) ) {
  6134. deactivateOverview();
  6135. if( element.nodeName.match( /section/gi ) ) {
  6136. var h = parseInt( element.getAttribute( 'data-index-h' ), 10 ),
  6137. v = parseInt( element.getAttribute( 'data-index-v' ), 10 );
  6138. slide( h, v );
  6139. }
  6140. }
  6141. }
  6142. }
  6143. /**
  6144. * Handles clicks on links that are set to preview in the
  6145. * iframe overlay.
  6146. *
  6147. * @param {object} event
  6148. */
  6149. function onPreviewLinkClicked( event ) {
  6150. if( event.currentTarget && event.currentTarget.hasAttribute( 'href' ) ) {
  6151. var url = event.currentTarget.getAttribute( 'href' );
  6152. if( url ) {
  6153. showPreview( url );
  6154. event.preventDefault();
  6155. }
  6156. }
  6157. }
  6158. /**
  6159. * Handles click on the auto-sliding controls element.
  6160. *
  6161. * @param {object} [event]
  6162. */
  6163. function onAutoSlidePlayerClick( event ) {
  6164. // Replay
  6165. if( Reveal.isLastSlide() && config.loop === false ) {
  6166. slide( 0, 0 );
  6167. resumeAutoSlide();
  6168. }
  6169. // Resume
  6170. else if( autoSlidePaused ) {
  6171. resumeAutoSlide();
  6172. }
  6173. // Pause
  6174. else {
  6175. pauseAutoSlide();
  6176. }
  6177. }
  6178. // --------------------------------------------------------------------//
  6179. // ------------------------ PLAYBACK COMPONENT ------------------------//
  6180. // --------------------------------------------------------------------//
  6181. /**
  6182. * Constructor for the playback component, which displays
  6183. * play/pause/progress controls.
  6184. *
  6185. * @param {HTMLElement} container The component will append
  6186. * itself to this
  6187. * @param {function} progressCheck A method which will be
  6188. * called frequently to get the current progress on a range
  6189. * of 0-1
  6190. */
  6191. function Playback( container, progressCheck ) {
  6192. // Cosmetics
  6193. this.diameter = 100;
  6194. this.diameter2 = this.diameter/2;
  6195. this.thickness = 6;
  6196. // Flags if we are currently playing
  6197. this.playing = false;
  6198. // Current progress on a 0-1 range
  6199. this.progress = 0;
  6200. // Used to loop the animation smoothly
  6201. this.progressOffset = 1;
  6202. this.container = container;
  6203. this.progressCheck = progressCheck;
  6204. this.canvas = document.createElement( 'canvas' );
  6205. this.canvas.className = 'playback';
  6206. this.canvas.width = this.diameter;
  6207. this.canvas.height = this.diameter;
  6208. this.canvas.style.width = this.diameter2 + 'px';
  6209. this.canvas.style.height = this.diameter2 + 'px';
  6210. this.context = this.canvas.getContext( '2d' );
  6211. this.container.appendChild( this.canvas );
  6212. this.render();
  6213. }
  6214. /**
  6215. * @param value
  6216. */
  6217. Playback.prototype.setPlaying = function( value ) {
  6218. var wasPlaying = this.playing;
  6219. this.playing = value;
  6220. // Start repainting if we weren't already
  6221. if( !wasPlaying && this.playing ) {
  6222. this.animate();
  6223. }
  6224. else {
  6225. this.render();
  6226. }
  6227. };
  6228. Playback.prototype.animate = function() {
  6229. var progressBefore = this.progress;
  6230. this.progress = this.progressCheck();
  6231. // When we loop, offset the progress so that it eases
  6232. // smoothly rather than immediately resetting
  6233. if( progressBefore > 0.8 && this.progress < 0.2 ) {
  6234. this.progressOffset = this.progress;
  6235. }
  6236. this.render();
  6237. if( this.playing ) {
  6238. features.requestAnimationFrameMethod.call( window, this.animate.bind( this ) );
  6239. }
  6240. };
  6241. /**
  6242. * Renders the current progress and playback state.
  6243. */
  6244. Playback.prototype.render = function() {
  6245. var progress = this.playing ? this.progress : 0,
  6246. radius = ( this.diameter2 ) - this.thickness,
  6247. x = this.diameter2,
  6248. y = this.diameter2,
  6249. iconSize = 28;
  6250. // Ease towards 1
  6251. this.progressOffset += ( 1 - this.progressOffset ) * 0.1;
  6252. var endAngle = ( - Math.PI / 2 ) + ( progress * ( Math.PI * 2 ) );
  6253. var startAngle = ( - Math.PI / 2 ) + ( this.progressOffset * ( Math.PI * 2 ) );
  6254. this.context.save();
  6255. this.context.clearRect( 0, 0, this.diameter, this.diameter );
  6256. // Solid background color
  6257. this.context.beginPath();
  6258. this.context.arc( x, y, radius + 4, 0, Math.PI * 2, false );
  6259. this.context.fillStyle = 'rgba( 0, 0, 0, 0.4 )';
  6260. this.context.fill();
  6261. // Draw progress track
  6262. this.context.beginPath();
  6263. this.context.arc( x, y, radius, 0, Math.PI * 2, false );
  6264. this.context.lineWidth = this.thickness;
  6265. this.context.strokeStyle = 'rgba( 255, 255, 255, 0.2 )';
  6266. this.context.stroke();
  6267. if( this.playing ) {
  6268. // Draw progress on top of track
  6269. this.context.beginPath();
  6270. this.context.arc( x, y, radius, startAngle, endAngle, false );
  6271. this.context.lineWidth = this.thickness;
  6272. this.context.strokeStyle = '#fff';
  6273. this.context.stroke();
  6274. }
  6275. this.context.translate( x - ( iconSize / 2 ), y - ( iconSize / 2 ) );
  6276. // Draw play/pause icons
  6277. if( this.playing ) {
  6278. this.context.fillStyle = '#fff';
  6279. this.context.fillRect( 0, 0, iconSize / 2 - 4, iconSize );
  6280. this.context.fillRect( iconSize / 2 + 4, 0, iconSize / 2 - 4, iconSize );
  6281. }
  6282. else {
  6283. this.context.beginPath();
  6284. this.context.translate( 4, 0 );
  6285. this.context.moveTo( 0, 0 );
  6286. this.context.lineTo( iconSize - 4, iconSize / 2 );
  6287. this.context.lineTo( 0, iconSize );
  6288. this.context.fillStyle = '#fff';
  6289. this.context.fill();
  6290. }
  6291. this.context.restore();
  6292. };
  6293. Playback.prototype.on = function( type, listener ) {
  6294. this.canvas.addEventListener( type, listener, false );
  6295. };
  6296. Playback.prototype.off = function( type, listener ) {
  6297. this.canvas.removeEventListener( type, listener, false );
  6298. };
  6299. Playback.prototype.destroy = function() {
  6300. this.playing = false;
  6301. if( this.canvas.parentNode ) {
  6302. this.container.removeChild( this.canvas );
  6303. }
  6304. };
  6305. // --------------------------------------------------------------------//
  6306. // ------------------------------- API --------------------------------//
  6307. // --------------------------------------------------------------------//
  6308. Reveal = {
  6309. VERSION: VERSION,
  6310. initialize: initialize,
  6311. configure: configure,
  6312. sync: sync,
  6313. syncSlide: syncSlide,
  6314. syncFragments: syncFragments,
  6315. // Navigation methods
  6316. slide: slide,
  6317. left: navigateLeft,
  6318. right: navigateRight,
  6319. up: navigateUp,
  6320. down: navigateDown,
  6321. prev: navigatePrev,
  6322. next: navigateNext,
  6323. // Fragment methods
  6324. navigateFragment: navigateFragment,
  6325. prevFragment: previousFragment,
  6326. nextFragment: nextFragment,
  6327. // Deprecated aliases
  6328. navigateTo: slide,
  6329. navigateLeft: navigateLeft,
  6330. navigateRight: navigateRight,
  6331. navigateUp: navigateUp,
  6332. navigateDown: navigateDown,
  6333. navigatePrev: navigatePrev,
  6334. navigateNext: navigateNext,
  6335. // Forces an update in slide layout
  6336. layout: layout,
  6337. // Randomizes the order of slides
  6338. shuffle: shuffle,
  6339. // Returns an object with the available routes as booleans (left/right/top/bottom)
  6340. availableRoutes: availableRoutes,
  6341. // Returns an object with the available fragments as booleans (prev/next)
  6342. availableFragments: availableFragments,
  6343. // Toggles a help overlay with keyboard shortcuts
  6344. toggleHelp: toggleHelp,
  6345. // Toggles the overview mode on/off
  6346. toggleOverview: toggleOverview,
  6347. // Toggles the "black screen" mode on/off
  6348. togglePause: togglePause,
  6349. // Toggles the auto slide mode on/off
  6350. toggleAutoSlide: toggleAutoSlide,
  6351. // State checks
  6352. isOverview: isOverview,
  6353. isPaused: isPaused,
  6354. isAutoSliding: isAutoSliding,
  6355. isSpeakerNotes: isSpeakerNotes,
  6356. // Slide preloading
  6357. loadSlide: loadSlide,
  6358. unloadSlide: unloadSlide,
  6359. // Adds or removes all internal event listeners (such as keyboard)
  6360. addEventListeners: addEventListeners,
  6361. removeEventListeners: removeEventListeners,
  6362. // Facility for persisting and restoring the presentation state
  6363. getState: getState,
  6364. setState: setState,
  6365. // Presentation progress
  6366. getSlidePastCount: getSlidePastCount,
  6367. // Presentation progress on range of 0-1
  6368. getProgress: getProgress,
  6369. // Returns the indices of the current, or specified, slide
  6370. getIndices: getIndices,
  6371. // Returns an Array of all slides
  6372. getSlides: getSlides,
  6373. // Returns an Array of objects representing the attributes on
  6374. // the slides
  6375. getSlidesAttributes: getSlidesAttributes,
  6376. // Returns the total number of slides
  6377. getTotalSlides: getTotalSlides,
  6378. // Returns the slide element at the specified index
  6379. getSlide: getSlide,
  6380. // Returns the slide background element at the specified index
  6381. getSlideBackground: getSlideBackground,
  6382. // Returns the speaker notes string for a slide, or null
  6383. getSlideNotes: getSlideNotes,
  6384. // Returns the previous slide element, may be null
  6385. getPreviousSlide: function() {
  6386. return previousSlide;
  6387. },
  6388. // Returns the current slide element
  6389. getCurrentSlide: function() {
  6390. return currentSlide;
  6391. },
  6392. // Returns the current scale of the presentation content
  6393. getScale: function() {
  6394. return scale;
  6395. },
  6396. // Returns the current configuration object
  6397. getConfig: function() {
  6398. return config;
  6399. },
  6400. // Helper method, retrieves query string as a key/value hash
  6401. getQueryHash: function() {
  6402. var query = {};
  6403. location.search.replace( /[A-Z0-9]+?=([\w\.%-]*)/gi, function(a) {
  6404. query[ a.split( '=' ).shift() ] = a.split( '=' ).pop();
  6405. } );
  6406. // Basic deserialization
  6407. for( var i in query ) {
  6408. var value = query[ i ];
  6409. query[ i ] = deserialize( unescape( value ) );
  6410. }
  6411. return query;
  6412. },
  6413. // Returns the top-level DOM element
  6414. getRevealElement: function() {
  6415. return dom.wrapper || document.querySelector( '.reveal' );
  6416. },
  6417. // Returns a hash with all registered plugins
  6418. getPlugins: function() {
  6419. return plugins;
  6420. },
  6421. // Returns true if we're currently on the first slide
  6422. isFirstSlide: function() {
  6423. return ( indexh === 0 && indexv === 0 );
  6424. },
  6425. // Returns true if we're currently on the last slide
  6426. isLastSlide: function() {
  6427. if( currentSlide ) {
  6428. // Does this slide have a next sibling?
  6429. if( currentSlide.nextElementSibling ) return false;
  6430. // If it's vertical, does its parent have a next sibling?
  6431. if( isVerticalSlide( currentSlide ) && currentSlide.parentNode.nextElementSibling ) return false;
  6432. return true;
  6433. }
  6434. return false;
  6435. },
  6436. // Returns true if we're on the last slide in the current
  6437. // vertical stack
  6438. isLastVerticalSlide: function() {
  6439. if( currentSlide && isVerticalSlide( currentSlide ) ) {
  6440. // Does this slide have a next sibling?
  6441. if( currentSlide.nextElementSibling ) return false;
  6442. return true;
  6443. }
  6444. return false;
  6445. },
  6446. // Checks if reveal.js has been loaded and is ready for use
  6447. isReady: function() {
  6448. return loaded;
  6449. },
  6450. // Forward event binding to the reveal DOM element
  6451. addEventListener: function( type, listener, useCapture ) {
  6452. if( 'addEventListener' in window ) {
  6453. Reveal.getRevealElement().addEventListener( type, listener, useCapture );
  6454. }
  6455. },
  6456. removeEventListener: function( type, listener, useCapture ) {
  6457. if( 'addEventListener' in window ) {
  6458. Reveal.getRevealElement().removeEventListener( type, listener, useCapture );
  6459. }
  6460. },
  6461. // Adds/removes a custom key binding
  6462. addKeyBinding: addKeyBinding,
  6463. removeKeyBinding: removeKeyBinding,
  6464. // API for registering and retrieving plugins
  6465. registerPlugin: registerPlugin,
  6466. hasPlugin: hasPlugin,
  6467. getPlugin: getPlugin,
  6468. // Programmatically triggers a keyboard event
  6469. triggerKey: function( keyCode ) {
  6470. onDocumentKeyDown( { keyCode: keyCode } );
  6471. },
  6472. // Registers a new shortcut to include in the help overlay
  6473. registerKeyboardShortcut: function( key, value ) {
  6474. keyboardShortcuts[key] = value;
  6475. }
  6476. };
  6477. return Reveal;
  6478. }));
  6479. Reveal.initialize();
  6480. </script>
  6481. </body>
  6482. </html>