Слайды на основе Reveal.js для презентации обучения детей в 2018-м году для конференции eKIDS в августе 2019-го
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

8077 lines
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. </div>
  1750. </div>
  1751. <script>
  1752. /*!
  1753. * reveal.js
  1754. * http://revealjs.com
  1755. * MIT licensed
  1756. *
  1757. * Copyright (C) 2019 Hakim El Hattab, http://hakim.se
  1758. */
  1759. (function( root, factory ) {
  1760. if( typeof define === 'function' && define.amd ) {
  1761. // AMD. Register as an anonymous module.
  1762. define( function() {
  1763. root.Reveal = factory();
  1764. return root.Reveal;
  1765. } );
  1766. } else if( typeof exports === 'object' ) {
  1767. // Node. Does not work with strict CommonJS.
  1768. module.exports = factory();
  1769. } else {
  1770. // Browser globals.
  1771. root.Reveal = factory();
  1772. }
  1773. }( this, function() {
  1774. 'use strict';
  1775. var Reveal;
  1776. // The reveal.js version
  1777. var VERSION = '3.8.0';
  1778. var SLIDES_SELECTOR = '.slides section',
  1779. HORIZONTAL_SLIDES_SELECTOR = '.slides>section',
  1780. VERTICAL_SLIDES_SELECTOR = '.slides>section.present>section',
  1781. HOME_SLIDE_SELECTOR = '.slides>section:first-of-type',
  1782. UA = navigator.userAgent,
  1783. // Configuration defaults, can be overridden at initialization time
  1784. config = {
  1785. // The "normal" size of the presentation, aspect ratio will be preserved
  1786. // when the presentation is scaled to fit different resolutions
  1787. width: 960,
  1788. height: 700,
  1789. // Factor of the display size that should remain empty around the content
  1790. margin: 0.04,
  1791. // Bounds for smallest/largest possible scale to apply to content
  1792. minScale: 0.2,
  1793. maxScale: 2.0,
  1794. // Display presentation control arrows
  1795. controls: true,
  1796. // Help the user learn the controls by providing hints, for example by
  1797. // bouncing the down arrow when they first encounter a vertical slide
  1798. controlsTutorial: true,
  1799. // Determines where controls appear, "edges" or "bottom-right"
  1800. controlsLayout: 'bottom-right',
  1801. // Visibility rule for backwards navigation arrows; "faded", "hidden"
  1802. // or "visible"
  1803. controlsBackArrows: 'faded',
  1804. // Display a presentation progress bar
  1805. progress: true,
  1806. // Display the page number of the current slide
  1807. // - true: Show slide number
  1808. // - false: Hide slide number
  1809. //
  1810. // Can optionally be set as a string that specifies the number formatting:
  1811. // - "h.v": Horizontal . vertical slide number (default)
  1812. // - "h/v": Horizontal / vertical slide number
  1813. // - "c": Flattened slide number
  1814. // - "c/t": Flattened slide number / total slides
  1815. //
  1816. // Alternatively, you can provide a function that returns the slide
  1817. // number for the current slide. The function needs to return an array
  1818. // with one string [slideNumber] or three strings [n1,delimiter,n2].
  1819. // See #formatSlideNumber().
  1820. slideNumber: false,
  1821. // Can be used to limit the contexts in which the slide number appears
  1822. // - "all": Always show the slide number
  1823. // - "print": Only when printing to PDF
  1824. // - "speaker": Only in the speaker view
  1825. showSlideNumber: 'all',
  1826. // Use 1 based indexing for # links to match slide number (default is zero
  1827. // based)
  1828. hashOneBasedIndex: false,
  1829. // Add the current slide number to the URL hash so that reloading the
  1830. // page/copying the URL will return you to the same slide
  1831. hash: false,
  1832. // Push each slide change to the browser history. Implies `hash: true`
  1833. history: false,
  1834. // Enable keyboard shortcuts for navigation
  1835. keyboard: true,
  1836. // Optional function that blocks keyboard events when retuning false
  1837. keyboardCondition: null,
  1838. // Enable the slide overview mode
  1839. overview: true,
  1840. // Disables the default reveal.js slide layout so that you can use
  1841. // custom CSS layout
  1842. disableLayout: false,
  1843. // Vertical centering of slides
  1844. center: true,
  1845. // Enables touch navigation on devices with touch input
  1846. touch: true,
  1847. // Loop the presentation
  1848. loop: false,
  1849. // Change the presentation direction to be RTL
  1850. rtl: false,
  1851. // Changes the behavior of our navigation directions.
  1852. //
  1853. // "default"
  1854. // Left/right arrow keys step between horizontal slides, up/down
  1855. // arrow keys step between vertical slides. Space key steps through
  1856. // all slides (both horizontal and vertical).
  1857. //
  1858. // "linear"
  1859. // Removes the up/down arrows. Left/right arrows step through all
  1860. // slides (both horizontal and vertical).
  1861. //
  1862. // "grid"
  1863. // When this is enabled, stepping left/right from a vertical stack
  1864. // to an adjacent vertical stack will land you at the same vertical
  1865. // index.
  1866. //
  1867. // Consider a deck with six slides ordered in two vertical stacks:
  1868. // 1.1 2.1
  1869. // 1.2 2.2
  1870. // 1.3 2.3
  1871. //
  1872. // If you're on slide 1.3 and navigate right, you will normally move
  1873. // from 1.3 -> 2.1. If "grid" is used, the same navigation takes you
  1874. // from 1.3 -> 2.3.
  1875. navigationMode: 'default',
  1876. // Randomizes the order of slides each time the presentation loads
  1877. shuffle: false,
  1878. // Turns fragments on and off globally
  1879. fragments: true,
  1880. // Flags whether to include the current fragment in the URL,
  1881. // so that reloading brings you to the same fragment position
  1882. fragmentInURL: false,
  1883. // Flags if the presentation is running in an embedded mode,
  1884. // i.e. contained within a limited portion of the screen
  1885. embedded: false,
  1886. // Flags if we should show a help overlay when the question-mark
  1887. // key is pressed
  1888. help: true,
  1889. // Flags if it should be possible to pause the presentation (blackout)
  1890. pause: true,
  1891. // Flags if speaker notes should be visible to all viewers
  1892. showNotes: false,
  1893. // Global override for autolaying embedded media (video/audio/iframe)
  1894. // - null: Media will only autoplay if data-autoplay is present
  1895. // - true: All media will autoplay, regardless of individual setting
  1896. // - false: No media will autoplay, regardless of individual setting
  1897. autoPlayMedia: null,
  1898. // Global override for preloading lazy-loaded iframes
  1899. // - null: Iframes with data-src AND data-preload will be loaded when within
  1900. // the viewDistance, iframes with only data-src will be loaded when visible
  1901. // - true: All iframes with data-src will be loaded when within the viewDistance
  1902. // - false: All iframes with data-src will be loaded only when visible
  1903. preloadIframes: null,
  1904. // Controls automatic progression to the next slide
  1905. // - 0: Auto-sliding only happens if the data-autoslide HTML attribute
  1906. // is present on the current slide or fragment
  1907. // - 1+: All slides will progress automatically at the given interval
  1908. // - false: No auto-sliding, even if data-autoslide is present
  1909. autoSlide: 0,
  1910. // Stop auto-sliding after user input
  1911. autoSlideStoppable: true,
  1912. // Use this method for navigation when auto-sliding (defaults to navigateNext)
  1913. autoSlideMethod: null,
  1914. // Specify the average time in seconds that you think you will spend
  1915. // presenting each slide. This is used to show a pacing timer in the
  1916. // speaker view
  1917. defaultTiming: null,
  1918. // Enable slide navigation via mouse wheel
  1919. mouseWheel: false,
  1920. // Apply a 3D roll to links on hover
  1921. rollingLinks: false,
  1922. // Hides the address bar on mobile devices
  1923. hideAddressBar: true,
  1924. // Opens links in an iframe preview overlay
  1925. // Add `data-preview-link` and `data-preview-link="false"` to customise each link
  1926. // individually
  1927. previewLinks: false,
  1928. // Exposes the reveal.js API through window.postMessage
  1929. postMessage: true,
  1930. // Dispatches all reveal.js events to the parent window through postMessage
  1931. postMessageEvents: false,
  1932. // Focuses body when page changes visibility to ensure keyboard shortcuts work
  1933. focusBodyOnPageVisibilityChange: true,
  1934. // Transition style
  1935. transition: 'slide', // none/fade/slide/convex/concave/zoom
  1936. // Transition speed
  1937. transitionSpeed: 'default', // default/fast/slow
  1938. // Transition style for full page slide backgrounds
  1939. backgroundTransition: 'fade', // none/fade/slide/convex/concave/zoom
  1940. // Parallax background image
  1941. parallaxBackgroundImage: '', // CSS syntax, e.g. "a.jpg"
  1942. // Parallax background size
  1943. parallaxBackgroundSize: '', // CSS syntax, e.g. "3000px 2000px"
  1944. // Parallax background repeat
  1945. parallaxBackgroundRepeat: '', // repeat/repeat-x/repeat-y/no-repeat/initial/inherit
  1946. // Parallax background position
  1947. parallaxBackgroundPosition: '', // CSS syntax, e.g. "top left"
  1948. // Amount of pixels to move the parallax background per slide step
  1949. parallaxBackgroundHorizontal: null,
  1950. parallaxBackgroundVertical: null,
  1951. // The maximum number of pages a single slide can expand onto when printing
  1952. // to PDF, unlimited by default
  1953. pdfMaxPagesPerSlide: Number.POSITIVE_INFINITY,
  1954. // Prints each fragment on a separate slide
  1955. pdfSeparateFragments: true,
  1956. // Offset used to reduce the height of content within exported PDF pages.
  1957. // This exists to account for environment differences based on how you
  1958. // print to PDF. CLI printing options, like phantomjs and wkpdf, can end
  1959. // on precisely the total height of the document whereas in-browser
  1960. // printing has to end one pixel before.
  1961. pdfPageHeightOffset: -1,
  1962. // Number of slides away from the current that are visible
  1963. viewDistance: 3,
  1964. // The display mode that will be used to show slides
  1965. display: 'block',
  1966. // Hide cursor if inactive
  1967. hideInactiveCursor: true,
  1968. // Time before the cursor is hidden (in ms)
  1969. hideCursorTime: 5000,
  1970. // Script dependencies to load
  1971. dependencies: []
  1972. },
  1973. // Flags if Reveal.initialize() has been called
  1974. initialized = false,
  1975. // Flags if reveal.js is loaded (has dispatched the 'ready' event)
  1976. loaded = false,
  1977. // Flags if the overview mode is currently active
  1978. overview = false,
  1979. // Holds the dimensions of our overview slides, including margins
  1980. overviewSlideWidth = null,
  1981. overviewSlideHeight = null,
  1982. // The horizontal and vertical index of the currently active slide
  1983. indexh,
  1984. indexv,
  1985. // The previous and current slide HTML elements
  1986. previousSlide,
  1987. currentSlide,
  1988. previousBackground,
  1989. // Remember which directions that the user has navigated towards
  1990. hasNavigatedRight = false,
  1991. hasNavigatedDown = false,
  1992. // Slides may hold a data-state attribute which we pick up and apply
  1993. // as a class to the body. This list contains the combined state of
  1994. // all current slides.
  1995. state = [],
  1996. // The current scale of the presentation (see width/height config)
  1997. scale = 1,
  1998. // CSS transform that is currently applied to the slides container,
  1999. // split into two groups
  2000. slidesTransform = { layout: '', overview: '' },
  2001. // Cached references to DOM elements
  2002. dom = {},
  2003. // A list of registered reveal.js plugins
  2004. plugins = {},
  2005. // List of asynchronously loaded reveal.js dependencies
  2006. asyncDependencies = [],
  2007. // Features supported by the browser, see #checkCapabilities()
  2008. features = {},
  2009. // Client is a mobile device, see #checkCapabilities()
  2010. isMobileDevice,
  2011. // Client is a desktop Chrome, see #checkCapabilities()
  2012. isChrome,
  2013. // Throttles mouse wheel navigation
  2014. lastMouseWheelStep = 0,
  2015. // Delays updates to the URL due to a Chrome thumbnailer bug
  2016. writeURLTimeout = 0,
  2017. // Is the mouse pointer currently hidden from view
  2018. cursorHidden = false,
  2019. // Timeout used to determine when the cursor is inactive
  2020. cursorInactiveTimeout = 0,
  2021. // Flags if the interaction event listeners are bound
  2022. eventsAreBound = false,
  2023. // The current auto-slide duration
  2024. autoSlide = 0,
  2025. // Auto slide properties
  2026. autoSlidePlayer,
  2027. autoSlideTimeout = 0,
  2028. autoSlideStartTime = -1,
  2029. autoSlidePaused = false,
  2030. // Holds information about the currently ongoing touch input
  2031. touch = {
  2032. startX: 0,
  2033. startY: 0,
  2034. startCount: 0,
  2035. captured: false,
  2036. threshold: 40
  2037. },
  2038. // A key:value map of shortcut keyboard keys and descriptions of
  2039. // the actions they trigger, generated in #configure()
  2040. keyboardShortcuts = {},
  2041. // Holds custom key code mappings
  2042. registeredKeyBindings = {};
  2043. /**
  2044. * Starts up the presentation if the client is capable.
  2045. */
  2046. function initialize( options ) {
  2047. // Make sure we only initialize once
  2048. if( initialized === true ) return;
  2049. initialized = true;
  2050. checkCapabilities();
  2051. if( !features.transforms2d && !features.transforms3d ) {
  2052. document.body.setAttribute( 'class', 'no-transforms' );
  2053. // Since JS won't be running any further, we load all lazy
  2054. // loading elements upfront
  2055. var images = toArray( document.getElementsByTagName( 'img' ) ),
  2056. iframes = toArray( document.getElementsByTagName( 'iframe' ) );
  2057. var lazyLoadable = images.concat( iframes );
  2058. for( var i = 0, len = lazyLoadable.length; i < len; i++ ) {
  2059. var element = lazyLoadable[i];
  2060. if( element.getAttribute( 'data-src' ) ) {
  2061. element.setAttribute( 'src', element.getAttribute( 'data-src' ) );
  2062. element.removeAttribute( 'data-src' );
  2063. }
  2064. }
  2065. // If the browser doesn't support core features we won't be
  2066. // using JavaScript to control the presentation
  2067. return;
  2068. }
  2069. // Cache references to key DOM elements
  2070. dom.wrapper = document.querySelector( '.reveal' );
  2071. dom.slides = document.querySelector( '.reveal .slides' );
  2072. // Force a layout when the whole page, incl fonts, has loaded
  2073. window.addEventListener( 'load', layout, false );
  2074. var query = Reveal.getQueryHash();
  2075. // Do not accept new dependencies via query config to avoid
  2076. // the potential of malicious script injection
  2077. if( typeof query['dependencies'] !== 'undefined' ) delete query['dependencies'];
  2078. // Copy options over to our config object
  2079. extend( config, options );
  2080. extend( config, query );
  2081. // Hide the address bar in mobile browsers
  2082. hideAddressBar();
  2083. // Loads dependencies and continues to #start() once done
  2084. load();
  2085. }
  2086. /**
  2087. * Inspect the client to see what it's capable of, this
  2088. * should only happens once per runtime.
  2089. */
  2090. function checkCapabilities() {
  2091. isMobileDevice = /(iphone|ipod|ipad|android)/gi.test( UA );
  2092. isChrome = /chrome/i.test( UA ) && !/edge/i.test( UA );
  2093. var testElement = document.createElement( 'div' );
  2094. features.transforms3d = 'WebkitPerspective' in testElement.style ||
  2095. 'MozPerspective' in testElement.style ||
  2096. 'msPerspective' in testElement.style ||
  2097. 'OPerspective' in testElement.style ||
  2098. 'perspective' in testElement.style;
  2099. features.transforms2d = 'WebkitTransform' in testElement.style ||
  2100. 'MozTransform' in testElement.style ||
  2101. 'msTransform' in testElement.style ||
  2102. 'OTransform' in testElement.style ||
  2103. 'transform' in testElement.style;
  2104. features.requestAnimationFrameMethod = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
  2105. features.requestAnimationFrame = typeof features.requestAnimationFrameMethod === 'function';
  2106. features.canvas = !!document.createElement( 'canvas' ).getContext;
  2107. // Transitions in the overview are disabled in desktop and
  2108. // Safari due to lag
  2109. features.overviewTransitions = !/Version\/[\d\.]+.*Safari/.test( UA );
  2110. // Flags if we should use zoom instead of transform to scale
  2111. // up slides. Zoom produces crisper results but has a lot of
  2112. // xbrowser quirks so we only use it in whitelsited browsers.
  2113. features.zoom = 'zoom' in testElement.style && !isMobileDevice &&
  2114. ( isChrome || /Version\/[\d\.]+.*Safari/.test( UA ) );
  2115. }
  2116. /**
  2117. * Loads the dependencies of reveal.js. Dependencies are
  2118. * defined via the configuration option 'dependencies'
  2119. * and will be loaded prior to starting/binding reveal.js.
  2120. * Some dependencies may have an 'async' flag, if so they
  2121. * will load after reveal.js has been started up.
  2122. */
  2123. function load() {
  2124. var scripts = [],
  2125. scriptsToLoad = 0;
  2126. config.dependencies.forEach( function( s ) {
  2127. // Load if there's no condition or the condition is truthy
  2128. if( !s.condition || s.condition() ) {
  2129. if( s.async ) {
  2130. asyncDependencies.push( s );
  2131. }
  2132. else {
  2133. scripts.push( s );
  2134. }
  2135. }
  2136. } );
  2137. if( scripts.length ) {
  2138. scriptsToLoad = scripts.length;
  2139. // Load synchronous scripts
  2140. scripts.forEach( function( s ) {
  2141. loadScript( s.src, function() {
  2142. if( typeof s.callback === 'function' ) s.callback();
  2143. if( --scriptsToLoad === 0 ) {
  2144. initPlugins();
  2145. }
  2146. } );
  2147. } );
  2148. }
  2149. else {
  2150. initPlugins();
  2151. }
  2152. }
  2153. /**
  2154. * Initializes our plugins and waits for them to be ready
  2155. * before proceeding.
  2156. */
  2157. function initPlugins() {
  2158. var pluginsToInitialize = Object.keys( plugins ).length;
  2159. // If there are no plugins, skip this step
  2160. if( pluginsToInitialize === 0 ) {
  2161. loadAsyncDependencies();
  2162. }
  2163. // ... otherwise initialize plugins
  2164. else {
  2165. var afterPlugInitialized = function() {
  2166. if( --pluginsToInitialize === 0 ) {
  2167. loadAsyncDependencies();
  2168. }
  2169. };
  2170. for( var i in plugins ) {
  2171. var plugin = plugins[i];
  2172. // If the plugin has an 'init' method, invoke it
  2173. if( typeof plugin.init === 'function' ) {
  2174. var callback = plugin.init();
  2175. // If the plugin returned a Promise, wait for it
  2176. if( callback && typeof callback.then === 'function' ) {
  2177. callback.then( afterPlugInitialized );
  2178. }
  2179. else {
  2180. afterPlugInitialized();
  2181. }
  2182. }
  2183. else {
  2184. afterPlugInitialized();
  2185. }
  2186. }
  2187. }
  2188. }
  2189. /**
  2190. * Loads all async reveal.js dependencies.
  2191. */
  2192. function loadAsyncDependencies() {
  2193. if( asyncDependencies.length ) {
  2194. asyncDependencies.forEach( function( s ) {
  2195. loadScript( s.src, s.callback );
  2196. } );
  2197. }
  2198. start();
  2199. }
  2200. /**
  2201. * Loads a JavaScript file from the given URL and executes it.
  2202. *
  2203. * @param {string} url Address of the .js file to load
  2204. * @param {function} callback Method to invoke when the script
  2205. * has loaded and executed
  2206. */
  2207. function loadScript( url, callback ) {
  2208. var script = document.createElement( 'script' );
  2209. script.type = 'text/javascript';
  2210. script.async = false;
  2211. script.defer = false;
  2212. script.src = url;
  2213. if( callback ) {
  2214. // Success callback
  2215. script.onload = script.onreadystatechange = function( event ) {
  2216. if( event.type === "load" || (/loaded|complete/.test( script.readyState ) ) ) {
  2217. // Kill event listeners
  2218. script.onload = script.onreadystatechange = script.onerror = null;
  2219. callback();
  2220. }
  2221. };
  2222. // Error callback
  2223. script.onerror = function( err ) {
  2224. // Kill event listeners
  2225. script.onload = script.onreadystatechange = script.onerror = null;
  2226. callback( new Error( 'Failed loading script: ' + script.src + '\n' + err) );
  2227. };
  2228. }
  2229. // Append the script at the end of <head>
  2230. var head = document.querySelector( 'head' );
  2231. head.insertBefore( script, head.lastChild );
  2232. }
  2233. /**
  2234. * Starts up reveal.js by binding input events and navigating
  2235. * to the current URL deeplink if there is one.
  2236. */
  2237. function start() {
  2238. loaded = true;
  2239. // Make sure we've got all the DOM elements we need
  2240. setupDOM();
  2241. // Listen to messages posted to this window
  2242. setupPostMessage();
  2243. // Prevent the slides from being scrolled out of view
  2244. setupScrollPrevention();
  2245. // Resets all vertical slides so that only the first is visible
  2246. resetVerticalSlides();
  2247. // Updates the presentation to match the current configuration values
  2248. configure();
  2249. // Read the initial hash
  2250. readURL();
  2251. // Update all backgrounds
  2252. updateBackground( true );
  2253. // Notify listeners that the presentation is ready but use a 1ms
  2254. // timeout to ensure it's not fired synchronously after #initialize()
  2255. setTimeout( function() {
  2256. // Enable transitions now that we're loaded
  2257. dom.slides.classList.remove( 'no-transition' );
  2258. dom.wrapper.classList.add( 'ready' );
  2259. dispatchEvent( 'ready', {
  2260. 'indexh': indexh,
  2261. 'indexv': indexv,
  2262. 'currentSlide': currentSlide
  2263. } );
  2264. }, 1 );
  2265. // Special setup and config is required when printing to PDF
  2266. if( isPrintingPDF() ) {
  2267. removeEventListeners();
  2268. // The document needs to have loaded for the PDF layout
  2269. // measurements to be accurate
  2270. if( document.readyState === 'complete' ) {
  2271. setupPDF();
  2272. }
  2273. else {
  2274. window.addEventListener( 'load', setupPDF );
  2275. }
  2276. }
  2277. }
  2278. /**
  2279. * Finds and stores references to DOM elements which are
  2280. * required by the presentation. If a required element is
  2281. * not found, it is created.
  2282. */
  2283. function setupDOM() {
  2284. // Prevent transitions while we're loading
  2285. dom.slides.classList.add( 'no-transition' );
  2286. if( isMobileDevice ) {
  2287. dom.wrapper.classList.add( 'no-hover' );
  2288. }
  2289. else {
  2290. dom.wrapper.classList.remove( 'no-hover' );
  2291. }
  2292. if( /iphone/gi.test( UA ) ) {
  2293. dom.wrapper.classList.add( 'ua-iphone' );
  2294. }
  2295. else {
  2296. dom.wrapper.classList.remove( 'ua-iphone' );
  2297. }
  2298. // Background element
  2299. dom.background = createSingletonNode( dom.wrapper, 'div', 'backgrounds', null );
  2300. // Progress bar
  2301. dom.progress = createSingletonNode( dom.wrapper, 'div', 'progress', '<span></span>' );
  2302. dom.progressbar = dom.progress.querySelector( 'span' );
  2303. // Arrow controls
  2304. dom.controls = createSingletonNode( dom.wrapper, 'aside', 'controls',
  2305. '<button class="navigate-left" aria-label="previous slide"><div class="controls-arrow"></div></button>' +
  2306. '<button class="navigate-right" aria-label="next slide"><div class="controls-arrow"></div></button>' +
  2307. '<button class="navigate-up" aria-label="above slide"><div class="controls-arrow"></div></button>' +
  2308. '<button class="navigate-down" aria-label="below slide"><div class="controls-arrow"></div></button>' );
  2309. // Slide number
  2310. dom.slideNumber = createSingletonNode( dom.wrapper, 'div', 'slide-number', '' );
  2311. // Element containing notes that are visible to the audience
  2312. dom.speakerNotes = createSingletonNode( dom.wrapper, 'div', 'speaker-notes', null );
  2313. dom.speakerNotes.setAttribute( 'data-prevent-swipe', '' );
  2314. dom.speakerNotes.setAttribute( 'tabindex', '0' );
  2315. // Overlay graphic which is displayed during the paused mode
  2316. dom.pauseOverlay = createSingletonNode( dom.wrapper, 'div', 'pause-overlay', config.controls ? '<button class="resume-button">Resume presentation</button>' : null );
  2317. dom.wrapper.setAttribute( 'role', 'application' );
  2318. // There can be multiple instances of controls throughout the page
  2319. dom.controlsLeft = toArray( document.querySelectorAll( '.navigate-left' ) );
  2320. dom.controlsRight = toArray( document.querySelectorAll( '.navigate-right' ) );
  2321. dom.controlsUp = toArray( document.querySelectorAll( '.navigate-up' ) );
  2322. dom.controlsDown = toArray( document.querySelectorAll( '.navigate-down' ) );
  2323. dom.controlsPrev = toArray( document.querySelectorAll( '.navigate-prev' ) );
  2324. dom.controlsNext = toArray( document.querySelectorAll( '.navigate-next' ) );
  2325. // The right and down arrows in the standard reveal.js controls
  2326. dom.controlsRightArrow = dom.controls.querySelector( '.navigate-right' );
  2327. dom.controlsDownArrow = dom.controls.querySelector( '.navigate-down' );
  2328. dom.statusDiv = createStatusDiv();
  2329. }
  2330. /**
  2331. * Creates a hidden div with role aria-live to announce the
  2332. * current slide content. Hide the div off-screen to make it
  2333. * available only to Assistive Technologies.
  2334. *
  2335. * @return {HTMLElement}
  2336. */
  2337. function createStatusDiv() {
  2338. var statusDiv = document.getElementById( 'aria-status-div' );
  2339. if( !statusDiv ) {
  2340. statusDiv = document.createElement( 'div' );
  2341. statusDiv.style.position = 'absolute';
  2342. statusDiv.style.height = '1px';
  2343. statusDiv.style.width = '1px';
  2344. statusDiv.style.overflow = 'hidden';
  2345. statusDiv.style.clip = 'rect( 1px, 1px, 1px, 1px )';
  2346. statusDiv.setAttribute( 'id', 'aria-status-div' );
  2347. statusDiv.setAttribute( 'aria-live', 'polite' );
  2348. statusDiv.setAttribute( 'aria-atomic','true' );
  2349. dom.wrapper.appendChild( statusDiv );
  2350. }
  2351. return statusDiv;
  2352. }
  2353. /**
  2354. * Converts the given HTML element into a string of text
  2355. * that can be announced to a screen reader. Hidden
  2356. * elements are excluded.
  2357. */
  2358. function getStatusText( node ) {
  2359. var text = '';
  2360. // Text node
  2361. if( node.nodeType === 3 ) {
  2362. text += node.textContent;
  2363. }
  2364. // Element node
  2365. else if( node.nodeType === 1 ) {
  2366. var isAriaHidden = node.getAttribute( 'aria-hidden' );
  2367. var isDisplayHidden = window.getComputedStyle( node )['display'] === 'none';
  2368. if( isAriaHidden !== 'true' && !isDisplayHidden ) {
  2369. toArray( node.childNodes ).forEach( function( child ) {
  2370. text += getStatusText( child );
  2371. } );
  2372. }
  2373. }
  2374. return text;
  2375. }
  2376. /**
  2377. * Configures the presentation for printing to a static
  2378. * PDF.
  2379. */
  2380. function setupPDF() {
  2381. var slideSize = getComputedSlideSize( window.innerWidth, window.innerHeight );
  2382. // Dimensions of the PDF pages
  2383. var pageWidth = Math.floor( slideSize.width * ( 1 + config.margin ) ),
  2384. pageHeight = Math.floor( slideSize.height * ( 1 + config.margin ) );
  2385. // Dimensions of slides within the pages
  2386. var slideWidth = slideSize.width,
  2387. slideHeight = slideSize.height;
  2388. // Let the browser know what page size we want to print
  2389. injectStyleSheet( '@page{size:'+ pageWidth +'px '+ pageHeight +'px; margin: 0px;}' );
  2390. // Limit the size of certain elements to the dimensions of the slide
  2391. injectStyleSheet( '.reveal section>img, .reveal section>video, .reveal section>iframe{max-width: '+ slideWidth +'px; max-height:'+ slideHeight +'px}' );
  2392. document.body.classList.add( 'print-pdf' );
  2393. document.body.style.width = pageWidth + 'px';
  2394. document.body.style.height = pageHeight + 'px';
  2395. // Make sure stretch elements fit on slide
  2396. layoutSlideContents( slideWidth, slideHeight );
  2397. // Add each slide's index as attributes on itself, we need these
  2398. // indices to generate slide numbers below
  2399. toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).forEach( function( hslide, h ) {
  2400. hslide.setAttribute( 'data-index-h', h );
  2401. if( hslide.classList.contains( 'stack' ) ) {
  2402. toArray( hslide.querySelectorAll( 'section' ) ).forEach( function( vslide, v ) {
  2403. vslide.setAttribute( 'data-index-h', h );
  2404. vslide.setAttribute( 'data-index-v', v );
  2405. } );
  2406. }
  2407. } );
  2408. // Slide and slide background layout
  2409. toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) ).forEach( function( slide ) {
  2410. // Vertical stacks are not centred since their section
  2411. // children will be
  2412. if( slide.classList.contains( 'stack' ) === false ) {
  2413. // Center the slide inside of the page, giving the slide some margin
  2414. var left = ( pageWidth - slideWidth ) / 2,
  2415. top = ( pageHeight - slideHeight ) / 2;
  2416. var contentHeight = slide.scrollHeight;
  2417. var numberOfPages = Math.max( Math.ceil( contentHeight / pageHeight ), 1 );
  2418. // Adhere to configured pages per slide limit
  2419. numberOfPages = Math.min( numberOfPages, config.pdfMaxPagesPerSlide );
  2420. // Center slides vertically
  2421. if( numberOfPages === 1 && config.center || slide.classList.contains( 'center' ) ) {
  2422. top = Math.max( ( pageHeight - contentHeight ) / 2, 0 );
  2423. }
  2424. // Wrap the slide in a page element and hide its overflow
  2425. // so that no page ever flows onto another
  2426. var page = document.createElement( 'div' );
  2427. page.className = 'pdf-page';
  2428. page.style.height = ( ( pageHeight + config.pdfPageHeightOffset ) * numberOfPages ) + 'px';
  2429. slide.parentNode.insertBefore( page, slide );
  2430. page.appendChild( slide );
  2431. // Position the slide inside of the page
  2432. slide.style.left = left + 'px';
  2433. slide.style.top = top + 'px';
  2434. slide.style.width = slideWidth + 'px';
  2435. if( slide.slideBackgroundElement ) {
  2436. page.insertBefore( slide.slideBackgroundElement, slide );
  2437. }
  2438. // Inject notes if `showNotes` is enabled
  2439. if( config.showNotes ) {
  2440. // Are there notes for this slide?
  2441. var notes = getSlideNotes( slide );
  2442. if( notes ) {
  2443. var notesSpacing = 8;
  2444. var notesLayout = typeof config.showNotes === 'string' ? config.showNotes : 'inline';
  2445. var notesElement = document.createElement( 'div' );
  2446. notesElement.classList.add( 'speaker-notes' );
  2447. notesElement.classList.add( 'speaker-notes-pdf' );
  2448. notesElement.setAttribute( 'data-layout', notesLayout );
  2449. notesElement.innerHTML = notes;
  2450. if( notesLayout === 'separate-page' ) {
  2451. page.parentNode.insertBefore( notesElement, page.nextSibling );
  2452. }
  2453. else {
  2454. notesElement.style.left = notesSpacing + 'px';
  2455. notesElement.style.bottom = notesSpacing + 'px';
  2456. notesElement.style.width = ( pageWidth - notesSpacing*2 ) + 'px';
  2457. page.appendChild( notesElement );
  2458. }
  2459. }
  2460. }
  2461. // Inject slide numbers if `slideNumbers` are enabled
  2462. if( config.slideNumber && /all|print/i.test( config.showSlideNumber ) ) {
  2463. var slideNumberH = parseInt( slide.getAttribute( 'data-index-h' ), 10 ) + 1,
  2464. slideNumberV = parseInt( slide.getAttribute( 'data-index-v' ), 10 ) + 1;
  2465. var numberElement = document.createElement( 'div' );
  2466. numberElement.classList.add( 'slide-number' );
  2467. numberElement.classList.add( 'slide-number-pdf' );
  2468. numberElement.innerHTML = formatSlideNumber( slideNumberH, '.', slideNumberV );
  2469. page.appendChild( numberElement );
  2470. }
  2471. // Copy page and show fragments one after another
  2472. if( config.pdfSeparateFragments ) {
  2473. // Each fragment 'group' is an array containing one or more
  2474. // fragments. Multiple fragments that appear at the same time
  2475. // are part of the same group.
  2476. var fragmentGroups = sortFragments( page.querySelectorAll( '.fragment' ), true );
  2477. var previousFragmentStep;
  2478. var previousPage;
  2479. fragmentGroups.forEach( function( fragments ) {
  2480. // Remove 'current-fragment' from the previous group
  2481. if( previousFragmentStep ) {
  2482. previousFragmentStep.forEach( function( fragment ) {
  2483. fragment.classList.remove( 'current-fragment' );
  2484. } );
  2485. }
  2486. // Show the fragments for the current index
  2487. fragments.forEach( function( fragment ) {
  2488. fragment.classList.add( 'visible', 'current-fragment' );
  2489. } );
  2490. // Create a separate page for the current fragment state
  2491. var clonedPage = page.cloneNode( true );
  2492. page.parentNode.insertBefore( clonedPage, ( previousPage || page ).nextSibling );
  2493. previousFragmentStep = fragments;
  2494. previousPage = clonedPage;
  2495. } );
  2496. // Reset the first/original page so that all fragments are hidden
  2497. fragmentGroups.forEach( function( fragments ) {
  2498. fragments.forEach( function( fragment ) {
  2499. fragment.classList.remove( 'visible', 'current-fragment' );
  2500. } );
  2501. } );
  2502. }
  2503. // Show all fragments
  2504. else {
  2505. toArray( page.querySelectorAll( '.fragment:not(.fade-out)' ) ).forEach( function( fragment ) {
  2506. fragment.classList.add( 'visible' );
  2507. } );
  2508. }
  2509. }
  2510. } );
  2511. // Notify subscribers that the PDF layout is good to go
  2512. dispatchEvent( 'pdf-ready' );
  2513. }
  2514. /**
  2515. * This is an unfortunate necessity. Some actions – such as
  2516. * an input field being focused in an iframe or using the
  2517. * keyboard to expand text selection beyond the bounds of
  2518. * a slide – can trigger our content to be pushed out of view.
  2519. * This scrolling can not be prevented by hiding overflow in
  2520. * CSS (we already do) so we have to resort to repeatedly
  2521. * checking if the slides have been offset :(
  2522. */
  2523. function setupScrollPrevention() {
  2524. setInterval( function() {
  2525. if( dom.wrapper.scrollTop !== 0 || dom.wrapper.scrollLeft !== 0 ) {
  2526. dom.wrapper.scrollTop = 0;
  2527. dom.wrapper.scrollLeft = 0;
  2528. }
  2529. }, 1000 );
  2530. }
  2531. /**
  2532. * Creates an HTML element and returns a reference to it.
  2533. * If the element already exists the existing instance will
  2534. * be returned.
  2535. *
  2536. * @param {HTMLElement} container
  2537. * @param {string} tagname
  2538. * @param {string} classname
  2539. * @param {string} innerHTML
  2540. *
  2541. * @return {HTMLElement}
  2542. */
  2543. function createSingletonNode( container, tagname, classname, innerHTML ) {
  2544. // Find all nodes matching the description
  2545. var nodes = container.querySelectorAll( '.' + classname );
  2546. // Check all matches to find one which is a direct child of
  2547. // the specified container
  2548. for( var i = 0; i < nodes.length; i++ ) {
  2549. var testNode = nodes[i];
  2550. if( testNode.parentNode === container ) {
  2551. return testNode;
  2552. }
  2553. }
  2554. // If no node was found, create it now
  2555. var node = document.createElement( tagname );
  2556. node.className = classname;
  2557. if( typeof innerHTML === 'string' ) {
  2558. node.innerHTML = innerHTML;
  2559. }
  2560. container.appendChild( node );
  2561. return node;
  2562. }
  2563. /**
  2564. * Creates the slide background elements and appends them
  2565. * to the background container. One element is created per
  2566. * slide no matter if the given slide has visible background.
  2567. */
  2568. function createBackgrounds() {
  2569. var printMode = isPrintingPDF();
  2570. // Clear prior backgrounds
  2571. dom.background.innerHTML = '';
  2572. dom.background.classList.add( 'no-transition' );
  2573. // Iterate over all horizontal slides
  2574. toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).forEach( function( slideh ) {
  2575. var backgroundStack = createBackground( slideh, dom.background );
  2576. // Iterate over all vertical slides
  2577. toArray( slideh.querySelectorAll( 'section' ) ).forEach( function( slidev ) {
  2578. createBackground( slidev, backgroundStack );
  2579. backgroundStack.classList.add( 'stack' );
  2580. } );
  2581. } );
  2582. // Add parallax background if specified
  2583. if( config.parallaxBackgroundImage ) {
  2584. dom.background.style.backgroundImage = 'url("' + config.parallaxBackgroundImage + '")';
  2585. dom.background.style.backgroundSize = config.parallaxBackgroundSize;
  2586. dom.background.style.backgroundRepeat = config.parallaxBackgroundRepeat;
  2587. dom.background.style.backgroundPosition = config.parallaxBackgroundPosition;
  2588. // Make sure the below properties are set on the element - these properties are
  2589. // needed for proper transitions to be set on the element via CSS. To remove
  2590. // annoying background slide-in effect when the presentation starts, apply
  2591. // these properties after short time delay
  2592. setTimeout( function() {
  2593. dom.wrapper.classList.add( 'has-parallax-background' );
  2594. }, 1 );
  2595. }
  2596. else {
  2597. dom.background.style.backgroundImage = '';
  2598. dom.wrapper.classList.remove( 'has-parallax-background' );
  2599. }
  2600. }
  2601. /**
  2602. * Creates a background for the given slide.
  2603. *
  2604. * @param {HTMLElement} slide
  2605. * @param {HTMLElement} container The element that the background
  2606. * should be appended to
  2607. * @return {HTMLElement} New background div
  2608. */
  2609. function createBackground( slide, container ) {
  2610. // Main slide background element
  2611. var element = document.createElement( 'div' );
  2612. element.className = 'slide-background ' + slide.className.replace( /present|past|future/, '' );
  2613. // Inner background element that wraps images/videos/iframes
  2614. var contentElement = document.createElement( 'div' );
  2615. contentElement.className = 'slide-background-content';
  2616. element.appendChild( contentElement );
  2617. container.appendChild( element );
  2618. slide.slideBackgroundElement = element;
  2619. slide.slideBackgroundContentElement = contentElement;
  2620. // Syncs the background to reflect all current background settings
  2621. syncBackground( slide );
  2622. return element;
  2623. }
  2624. /**
  2625. * Renders all of the visual properties of a slide background
  2626. * based on the various background attributes.
  2627. *
  2628. * @param {HTMLElement} slide
  2629. */
  2630. function syncBackground( slide ) {
  2631. var element = slide.slideBackgroundElement,
  2632. contentElement = slide.slideBackgroundContentElement;
  2633. // Reset the prior background state in case this is not the
  2634. // initial sync
  2635. slide.classList.remove( 'has-dark-background' );
  2636. slide.classList.remove( 'has-light-background' );
  2637. element.removeAttribute( 'data-loaded' );
  2638. element.removeAttribute( 'data-background-hash' );
  2639. element.removeAttribute( 'data-background-size' );
  2640. element.removeAttribute( 'data-background-transition' );
  2641. element.style.backgroundColor = '';
  2642. contentElement.style.backgroundSize = '';
  2643. contentElement.style.backgroundRepeat = '';
  2644. contentElement.style.backgroundPosition = '';
  2645. contentElement.style.backgroundImage = '';
  2646. contentElement.style.opacity = '';
  2647. contentElement.innerHTML = '';
  2648. var data = {
  2649. background: slide.getAttribute( 'data-background' ),
  2650. backgroundSize: slide.getAttribute( 'data-background-size' ),
  2651. backgroundImage: slide.getAttribute( 'data-background-image' ),
  2652. backgroundVideo: slide.getAttribute( 'data-background-video' ),
  2653. backgroundIframe: slide.getAttribute( 'data-background-iframe' ),
  2654. backgroundColor: slide.getAttribute( 'data-background-color' ),
  2655. backgroundRepeat: slide.getAttribute( 'data-background-repeat' ),
  2656. backgroundPosition: slide.getAttribute( 'data-background-position' ),
  2657. backgroundTransition: slide.getAttribute( 'data-background-transition' ),
  2658. backgroundOpacity: slide.getAttribute( 'data-background-opacity' )
  2659. };
  2660. if( data.background ) {
  2661. // Auto-wrap image urls in url(...)
  2662. if( /^(http|file|\/\/)/gi.test( data.background ) || /\.(svg|png|jpg|jpeg|gif|bmp)([?#\s]|$)/gi.test( data.background ) ) {
  2663. slide.setAttribute( 'data-background-image', data.background );
  2664. }
  2665. else {
  2666. element.style.background = data.background;
  2667. }
  2668. }
  2669. // Create a hash for this combination of background settings.
  2670. // This is used to determine when two slide backgrounds are
  2671. // the same.
  2672. if( data.background || data.backgroundColor || data.backgroundImage || data.backgroundVideo || data.backgroundIframe ) {
  2673. element.setAttribute( 'data-background-hash', data.background +
  2674. data.backgroundSize +
  2675. data.backgroundImage +
  2676. data.backgroundVideo +
  2677. data.backgroundIframe +
  2678. data.backgroundColor +
  2679. data.backgroundRepeat +
  2680. data.backgroundPosition +
  2681. data.backgroundTransition +
  2682. data.backgroundOpacity );
  2683. }
  2684. // Additional and optional background properties
  2685. if( data.backgroundSize ) element.setAttribute( 'data-background-size', data.backgroundSize );
  2686. if( data.backgroundColor ) element.style.backgroundColor = data.backgroundColor;
  2687. if( data.backgroundTransition ) element.setAttribute( 'data-background-transition', data.backgroundTransition );
  2688. // Background image options are set on the content wrapper
  2689. if( data.backgroundSize ) contentElement.style.backgroundSize = data.backgroundSize;
  2690. if( data.backgroundRepeat ) contentElement.style.backgroundRepeat = data.backgroundRepeat;
  2691. if( data.backgroundPosition ) contentElement.style.backgroundPosition = data.backgroundPosition;
  2692. if( data.backgroundOpacity ) contentElement.style.opacity = data.backgroundOpacity;
  2693. // If this slide has a background color, we add a class that
  2694. // signals if it is light or dark. If the slide has no background
  2695. // color, no class will be added
  2696. var contrastColor = data.backgroundColor;
  2697. // If no bg color was found, check the computed background
  2698. if( !contrastColor ) {
  2699. var computedBackgroundStyle = window.getComputedStyle( element );
  2700. if( computedBackgroundStyle && computedBackgroundStyle.backgroundColor ) {
  2701. contrastColor = computedBackgroundStyle.backgroundColor;
  2702. }
  2703. }
  2704. if( contrastColor ) {
  2705. var rgb = colorToRgb( contrastColor );
  2706. // Ignore fully transparent backgrounds. Some browsers return
  2707. // rgba(0,0,0,0) when reading the computed background color of
  2708. // an element with no background
  2709. if( rgb && rgb.a !== 0 ) {
  2710. if( colorBrightness( contrastColor ) < 128 ) {
  2711. slide.classList.add( 'has-dark-background' );
  2712. }
  2713. else {
  2714. slide.classList.add( 'has-light-background' );
  2715. }
  2716. }
  2717. }
  2718. }
  2719. /**
  2720. * Registers a listener to postMessage events, this makes it
  2721. * possible to call all reveal.js API methods from another
  2722. * window. For example:
  2723. *
  2724. * revealWindow.postMessage( JSON.stringify({
  2725. * method: 'slide',
  2726. * args: [ 2 ]
  2727. * }), '*' );
  2728. */
  2729. function setupPostMessage() {
  2730. if( config.postMessage ) {
  2731. window.addEventListener( 'message', function ( event ) {
  2732. var data = event.data;
  2733. // Make sure we're dealing with JSON
  2734. if( typeof data === 'string' && data.charAt( 0 ) === '{' && data.charAt( data.length - 1 ) === '}' ) {
  2735. data = JSON.parse( data );
  2736. // Check if the requested method can be found
  2737. if( data.method && typeof Reveal[data.method] === 'function' ) {
  2738. Reveal[data.method].apply( Reveal, data.args );
  2739. }
  2740. }
  2741. }, false );
  2742. }
  2743. }
  2744. /**
  2745. * Applies the configuration settings from the config
  2746. * object. May be called multiple times.
  2747. *
  2748. * @param {object} options
  2749. */
  2750. function configure( options ) {
  2751. var oldTransition = config.transition;
  2752. // New config options may be passed when this method
  2753. // is invoked through the API after initialization
  2754. if( typeof options === 'object' ) extend( config, options );
  2755. // Abort if reveal.js hasn't finished loading, config
  2756. // changes will be applied automatically once loading
  2757. // finishes
  2758. if( loaded === false ) return;
  2759. var numberOfSlides = dom.wrapper.querySelectorAll( SLIDES_SELECTOR ).length;
  2760. // Remove the previously configured transition class
  2761. dom.wrapper.classList.remove( oldTransition );
  2762. // Force linear transition based on browser capabilities
  2763. if( features.transforms3d === false ) config.transition = 'linear';
  2764. dom.wrapper.classList.add( config.transition );
  2765. dom.wrapper.setAttribute( 'data-transition-speed', config.transitionSpeed );
  2766. dom.wrapper.setAttribute( 'data-background-transition', config.backgroundTransition );
  2767. dom.controls.style.display = config.controls ? 'block' : 'none';
  2768. dom.progress.style.display = config.progress ? 'block' : 'none';
  2769. dom.controls.setAttribute( 'data-controls-layout', config.controlsLayout );
  2770. dom.controls.setAttribute( 'data-controls-back-arrows', config.controlsBackArrows );
  2771. if( config.shuffle ) {
  2772. shuffle();
  2773. }
  2774. if( config.rtl ) {
  2775. dom.wrapper.classList.add( 'rtl' );
  2776. }
  2777. else {
  2778. dom.wrapper.classList.remove( 'rtl' );
  2779. }
  2780. if( config.center ) {
  2781. dom.wrapper.classList.add( 'center' );
  2782. }
  2783. else {
  2784. dom.wrapper.classList.remove( 'center' );
  2785. }
  2786. // Exit the paused mode if it was configured off
  2787. if( config.pause === false ) {
  2788. resume();
  2789. }
  2790. if( config.showNotes ) {
  2791. dom.speakerNotes.setAttribute( 'data-layout', typeof config.showNotes === 'string' ? config.showNotes : 'inline' );
  2792. }
  2793. if( config.mouseWheel ) {
  2794. document.addEventListener( 'DOMMouseScroll', onDocumentMouseScroll, false ); // FF
  2795. document.addEventListener( 'mousewheel', onDocumentMouseScroll, false );
  2796. }
  2797. else {
  2798. document.removeEventListener( 'DOMMouseScroll', onDocumentMouseScroll, false ); // FF
  2799. document.removeEventListener( 'mousewheel', onDocumentMouseScroll, false );
  2800. }
  2801. // Rolling 3D links
  2802. if( config.rollingLinks ) {
  2803. enableRollingLinks();
  2804. }
  2805. else {
  2806. disableRollingLinks();
  2807. }
  2808. // Auto-hide the mouse pointer when its inactive
  2809. if( config.hideInactiveCursor ) {
  2810. document.addEventListener( 'mousemove', onDocumentCursorActive, false );
  2811. document.addEventListener( 'mousedown', onDocumentCursorActive, false );
  2812. }
  2813. else {
  2814. showCursor();
  2815. document.removeEventListener( 'mousemove', onDocumentCursorActive, false );
  2816. document.removeEventListener( 'mousedown', onDocumentCursorActive, false );
  2817. }
  2818. // Iframe link previews
  2819. if( config.previewLinks ) {
  2820. enablePreviewLinks();
  2821. disablePreviewLinks( '[data-preview-link=false]' );
  2822. }
  2823. else {
  2824. disablePreviewLinks();
  2825. enablePreviewLinks( '[data-preview-link]:not([data-preview-link=false])' );
  2826. }
  2827. // Remove existing auto-slide controls
  2828. if( autoSlidePlayer ) {
  2829. autoSlidePlayer.destroy();
  2830. autoSlidePlayer = null;
  2831. }
  2832. // Generate auto-slide controls if needed
  2833. if( numberOfSlides > 1 && config.autoSlide && config.autoSlideStoppable && features.canvas && features.requestAnimationFrame ) {
  2834. autoSlidePlayer = new Playback( dom.wrapper, function() {
  2835. return Math.min( Math.max( ( Date.now() - autoSlideStartTime ) / autoSlide, 0 ), 1 );
  2836. } );
  2837. autoSlidePlayer.on( 'click', onAutoSlidePlayerClick );
  2838. autoSlidePaused = false;
  2839. }
  2840. // When fragments are turned off they should be visible
  2841. if( config.fragments === false ) {
  2842. toArray( dom.slides.querySelectorAll( '.fragment' ) ).forEach( function( element ) {
  2843. element.classList.add( 'visible' );
  2844. element.classList.remove( 'current-fragment' );
  2845. } );
  2846. }
  2847. // Slide numbers
  2848. var slideNumberDisplay = 'none';
  2849. if( config.slideNumber && !isPrintingPDF() ) {
  2850. if( config.showSlideNumber === 'all' ) {
  2851. slideNumberDisplay = 'block';
  2852. }
  2853. else if( config.showSlideNumber === 'speaker' && isSpeakerNotes() ) {
  2854. slideNumberDisplay = 'block';
  2855. }
  2856. }
  2857. dom.slideNumber.style.display = slideNumberDisplay;
  2858. // Add the navigation mode to the DOM so we can adjust styling
  2859. if( config.navigationMode !== 'default' ) {
  2860. dom.wrapper.setAttribute( 'data-navigation-mode', config.navigationMode );
  2861. }
  2862. else {
  2863. dom.wrapper.removeAttribute( 'data-navigation-mode' );
  2864. }
  2865. // Define our contextual list of keyboard shortcuts
  2866. if( config.navigationMode === 'linear' ) {
  2867. keyboardShortcuts['&#8594; , &#8595; , SPACE , N , L , J'] = 'Next slide';
  2868. keyboardShortcuts['&#8592; , &#8593; , P , H , K'] = 'Previous slide';
  2869. }
  2870. else {
  2871. keyboardShortcuts['N , SPACE'] = 'Next slide';
  2872. keyboardShortcuts['P'] = 'Previous slide';
  2873. keyboardShortcuts['&#8592; , H'] = 'Navigate left';
  2874. keyboardShortcuts['&#8594; , L'] = 'Navigate right';
  2875. keyboardShortcuts['&#8593; , K'] = 'Navigate up';
  2876. keyboardShortcuts['&#8595; , J'] = 'Navigate down';
  2877. }
  2878. keyboardShortcuts['Home , &#8984;/CTRL &#8592;'] = 'First slide';
  2879. keyboardShortcuts['End , &#8984;/CTRL &#8594;'] = 'Last slide';
  2880. keyboardShortcuts['B , .'] = 'Pause';
  2881. keyboardShortcuts['F'] = 'Fullscreen';
  2882. keyboardShortcuts['ESC, O'] = 'Slide overview';
  2883. sync();
  2884. }
  2885. /**
  2886. * Binds all event listeners.
  2887. */
  2888. function addEventListeners() {
  2889. eventsAreBound = true;
  2890. window.addEventListener( 'hashchange', onWindowHashChange, false );
  2891. window.addEventListener( 'resize', onWindowResize, false );
  2892. if( config.touch ) {
  2893. if( 'onpointerdown' in window ) {
  2894. // Use W3C pointer events
  2895. dom.wrapper.addEventListener( 'pointerdown', onPointerDown, false );
  2896. dom.wrapper.addEventListener( 'pointermove', onPointerMove, false );
  2897. dom.wrapper.addEventListener( 'pointerup', onPointerUp, false );
  2898. }
  2899. else if( window.navigator.msPointerEnabled ) {
  2900. // IE 10 uses prefixed version of pointer events
  2901. dom.wrapper.addEventListener( 'MSPointerDown', onPointerDown, false );
  2902. dom.wrapper.addEventListener( 'MSPointerMove', onPointerMove, false );
  2903. dom.wrapper.addEventListener( 'MSPointerUp', onPointerUp, false );
  2904. }
  2905. else {
  2906. // Fall back to touch events
  2907. dom.wrapper.addEventListener( 'touchstart', onTouchStart, false );
  2908. dom.wrapper.addEventListener( 'touchmove', onTouchMove, false );
  2909. dom.wrapper.addEventListener( 'touchend', onTouchEnd, false );
  2910. }
  2911. }
  2912. if( config.keyboard ) {
  2913. document.addEventListener( 'keydown', onDocumentKeyDown, false );
  2914. document.addEventListener( 'keypress', onDocumentKeyPress, false );
  2915. }
  2916. if( config.progress && dom.progress ) {
  2917. dom.progress.addEventListener( 'click', onProgressClicked, false );
  2918. }
  2919. dom.pauseOverlay.addEventListener( 'click', resume, false );
  2920. if( config.focusBodyOnPageVisibilityChange ) {
  2921. var visibilityChange;
  2922. if( 'hidden' in document ) {
  2923. visibilityChange = 'visibilitychange';
  2924. }
  2925. else if( 'msHidden' in document ) {
  2926. visibilityChange = 'msvisibilitychange';
  2927. }
  2928. else if( 'webkitHidden' in document ) {
  2929. visibilityChange = 'webkitvisibilitychange';
  2930. }
  2931. if( visibilityChange ) {
  2932. document.addEventListener( visibilityChange, onPageVisibilityChange, false );
  2933. }
  2934. }
  2935. // Listen to both touch and click events, in case the device
  2936. // supports both
  2937. var pointerEvents = [ 'touchstart', 'click' ];
  2938. // Only support touch for Android, fixes double navigations in
  2939. // stock browser
  2940. if( UA.match( /android/gi ) ) {
  2941. pointerEvents = [ 'touchstart' ];
  2942. }
  2943. pointerEvents.forEach( function( eventName ) {
  2944. dom.controlsLeft.forEach( function( el ) { el.addEventListener( eventName, onNavigateLeftClicked, false ); } );
  2945. dom.controlsRight.forEach( function( el ) { el.addEventListener( eventName, onNavigateRightClicked, false ); } );
  2946. dom.controlsUp.forEach( function( el ) { el.addEventListener( eventName, onNavigateUpClicked, false ); } );
  2947. dom.controlsDown.forEach( function( el ) { el.addEventListener( eventName, onNavigateDownClicked, false ); } );
  2948. dom.controlsPrev.forEach( function( el ) { el.addEventListener( eventName, onNavigatePrevClicked, false ); } );
  2949. dom.controlsNext.forEach( function( el ) { el.addEventListener( eventName, onNavigateNextClicked, false ); } );
  2950. } );
  2951. }
  2952. /**
  2953. * Unbinds all event listeners.
  2954. */
  2955. function removeEventListeners() {
  2956. eventsAreBound = false;
  2957. document.removeEventListener( 'keydown', onDocumentKeyDown, false );
  2958. document.removeEventListener( 'keypress', onDocumentKeyPress, false );
  2959. window.removeEventListener( 'hashchange', onWindowHashChange, false );
  2960. window.removeEventListener( 'resize', onWindowResize, false );
  2961. dom.wrapper.removeEventListener( 'pointerdown', onPointerDown, false );
  2962. dom.wrapper.removeEventListener( 'pointermove', onPointerMove, false );
  2963. dom.wrapper.removeEventListener( 'pointerup', onPointerUp, false );
  2964. dom.wrapper.removeEventListener( 'MSPointerDown', onPointerDown, false );
  2965. dom.wrapper.removeEventListener( 'MSPointerMove', onPointerMove, false );
  2966. dom.wrapper.removeEventListener( 'MSPointerUp', onPointerUp, false );
  2967. dom.wrapper.removeEventListener( 'touchstart', onTouchStart, false );
  2968. dom.wrapper.removeEventListener( 'touchmove', onTouchMove, false );
  2969. dom.wrapper.removeEventListener( 'touchend', onTouchEnd, false );
  2970. dom.pauseOverlay.removeEventListener( 'click', resume, false );
  2971. if ( config.progress && dom.progress ) {
  2972. dom.progress.removeEventListener( 'click', onProgressClicked, false );
  2973. }
  2974. [ 'touchstart', 'click' ].forEach( function( eventName ) {
  2975. dom.controlsLeft.forEach( function( el ) { el.removeEventListener( eventName, onNavigateLeftClicked, false ); } );
  2976. dom.controlsRight.forEach( function( el ) { el.removeEventListener( eventName, onNavigateRightClicked, false ); } );
  2977. dom.controlsUp.forEach( function( el ) { el.removeEventListener( eventName, onNavigateUpClicked, false ); } );
  2978. dom.controlsDown.forEach( function( el ) { el.removeEventListener( eventName, onNavigateDownClicked, false ); } );
  2979. dom.controlsPrev.forEach( function( el ) { el.removeEventListener( eventName, onNavigatePrevClicked, false ); } );
  2980. dom.controlsNext.forEach( function( el ) { el.removeEventListener( eventName, onNavigateNextClicked, false ); } );
  2981. } );
  2982. }
  2983. /**
  2984. * Registers a new plugin with this reveal.js instance.
  2985. *
  2986. * reveal.js waits for all regisered plugins to initialize
  2987. * before considering itself ready, as long as the plugin
  2988. * is registered before calling `Reveal.initialize()`.
  2989. */
  2990. function registerPlugin( id, plugin ) {
  2991. if( plugins[id] === undefined ) {
  2992. plugins[id] = plugin;
  2993. // If a plugin is registered after reveal.js is loaded,
  2994. // initialize it right away
  2995. if( loaded && typeof plugin.init === 'function' ) {
  2996. plugin.init();
  2997. }
  2998. }
  2999. else {
  3000. console.warn( 'reveal.js: "'+ id +'" plugin has already been registered' );
  3001. }
  3002. }
  3003. /**
  3004. * Checks if a specific plugin has been registered.
  3005. *
  3006. * @param {String} id Unique plugin identifier
  3007. */
  3008. function hasPlugin( id ) {
  3009. return !!plugins[id];
  3010. }
  3011. /**
  3012. * Returns the specific plugin instance, if a plugin
  3013. * with the given ID has been registered.
  3014. *
  3015. * @param {String} id Unique plugin identifier
  3016. */
  3017. function getPlugin( id ) {
  3018. return plugins[id];
  3019. }
  3020. /**
  3021. * Add a custom key binding with optional description to
  3022. * be added to the help screen.
  3023. */
  3024. function addKeyBinding( binding, callback ) {
  3025. if( typeof binding === 'object' && binding.keyCode ) {
  3026. registeredKeyBindings[binding.keyCode] = {
  3027. callback: callback,
  3028. key: binding.key,
  3029. description: binding.description
  3030. };
  3031. }
  3032. else {
  3033. registeredKeyBindings[binding] = {
  3034. callback: callback,
  3035. key: null,
  3036. description: null
  3037. };
  3038. }
  3039. }
  3040. /**
  3041. * Removes the specified custom key binding.
  3042. */
  3043. function removeKeyBinding( keyCode ) {
  3044. delete registeredKeyBindings[keyCode];
  3045. }
  3046. /**
  3047. * Extend object a with the properties of object b.
  3048. * If there's a conflict, object b takes precedence.
  3049. *
  3050. * @param {object} a
  3051. * @param {object} b
  3052. */
  3053. function extend( a, b ) {
  3054. for( var i in b ) {
  3055. a[ i ] = b[ i ];
  3056. }
  3057. return a;
  3058. }
  3059. /**
  3060. * Converts the target object to an array.
  3061. *
  3062. * @param {object} o
  3063. * @return {object[]}
  3064. */
  3065. function toArray( o ) {
  3066. return Array.prototype.slice.call( o );
  3067. }
  3068. /**
  3069. * Utility for deserializing a value.
  3070. *
  3071. * @param {*} value
  3072. * @return {*}
  3073. */
  3074. function deserialize( value ) {
  3075. if( typeof value === 'string' ) {
  3076. if( value === 'null' ) return null;
  3077. else if( value === 'true' ) return true;
  3078. else if( value === 'false' ) return false;
  3079. else if( value.match( /^-?[\d\.]+$/ ) ) return parseFloat( value );
  3080. }
  3081. return value;
  3082. }
  3083. /**
  3084. * Measures the distance in pixels between point a
  3085. * and point b.
  3086. *
  3087. * @param {object} a point with x/y properties
  3088. * @param {object} b point with x/y properties
  3089. *
  3090. * @return {number}
  3091. */
  3092. function distanceBetween( a, b ) {
  3093. var dx = a.x - b.x,
  3094. dy = a.y - b.y;
  3095. return Math.sqrt( dx*dx + dy*dy );
  3096. }
  3097. /**
  3098. * Applies a CSS transform to the target element.
  3099. *
  3100. * @param {HTMLElement} element
  3101. * @param {string} transform
  3102. */
  3103. function transformElement( element, transform ) {
  3104. element.style.WebkitTransform = transform;
  3105. element.style.MozTransform = transform;
  3106. element.style.msTransform = transform;
  3107. element.style.transform = transform;
  3108. }
  3109. /**
  3110. * Applies CSS transforms to the slides container. The container
  3111. * is transformed from two separate sources: layout and the overview
  3112. * mode.
  3113. *
  3114. * @param {object} transforms
  3115. */
  3116. function transformSlides( transforms ) {
  3117. // Pick up new transforms from arguments
  3118. if( typeof transforms.layout === 'string' ) slidesTransform.layout = transforms.layout;
  3119. if( typeof transforms.overview === 'string' ) slidesTransform.overview = transforms.overview;
  3120. // Apply the transforms to the slides container
  3121. if( slidesTransform.layout ) {
  3122. transformElement( dom.slides, slidesTransform.layout + ' ' + slidesTransform.overview );
  3123. }
  3124. else {
  3125. transformElement( dom.slides, slidesTransform.overview );
  3126. }
  3127. }
  3128. /**
  3129. * Injects the given CSS styles into the DOM.
  3130. *
  3131. * @param {string} value
  3132. */
  3133. function injectStyleSheet( value ) {
  3134. var tag = document.createElement( 'style' );
  3135. tag.type = 'text/css';
  3136. if( tag.styleSheet ) {
  3137. tag.styleSheet.cssText = value;
  3138. }
  3139. else {
  3140. tag.appendChild( document.createTextNode( value ) );
  3141. }
  3142. document.getElementsByTagName( 'head' )[0].appendChild( tag );
  3143. }
  3144. /**
  3145. * Find the closest parent that matches the given
  3146. * selector.
  3147. *
  3148. * @param {HTMLElement} target The child element
  3149. * @param {String} selector The CSS selector to match
  3150. * the parents against
  3151. *
  3152. * @return {HTMLElement} The matched parent or null
  3153. * if no matching parent was found
  3154. */
  3155. function closestParent( target, selector ) {
  3156. var parent = target.parentNode;
  3157. while( parent ) {
  3158. // There's some overhead doing this each time, we don't
  3159. // want to rewrite the element prototype but should still
  3160. // be enough to feature detect once at startup...
  3161. var matchesMethod = parent.matches || parent.matchesSelector || parent.msMatchesSelector;
  3162. // If we find a match, we're all set
  3163. if( matchesMethod && matchesMethod.call( parent, selector ) ) {
  3164. return parent;
  3165. }
  3166. // Keep searching
  3167. parent = parent.parentNode;
  3168. }
  3169. return null;
  3170. }
  3171. /**
  3172. * Converts various color input formats to an {r:0,g:0,b:0} object.
  3173. *
  3174. * @param {string} color The string representation of a color
  3175. * @example
  3176. * colorToRgb('#000');
  3177. * @example
  3178. * colorToRgb('#000000');
  3179. * @example
  3180. * colorToRgb('rgb(0,0,0)');
  3181. * @example
  3182. * colorToRgb('rgba(0,0,0)');
  3183. *
  3184. * @return {{r: number, g: number, b: number, [a]: number}|null}
  3185. */
  3186. function colorToRgb( color ) {
  3187. var hex3 = color.match( /^#([0-9a-f]{3})$/i );
  3188. if( hex3 && hex3[1] ) {
  3189. hex3 = hex3[1];
  3190. return {
  3191. r: parseInt( hex3.charAt( 0 ), 16 ) * 0x11,
  3192. g: parseInt( hex3.charAt( 1 ), 16 ) * 0x11,
  3193. b: parseInt( hex3.charAt( 2 ), 16 ) * 0x11
  3194. };
  3195. }
  3196. var hex6 = color.match( /^#([0-9a-f]{6})$/i );
  3197. if( hex6 && hex6[1] ) {
  3198. hex6 = hex6[1];
  3199. return {
  3200. r: parseInt( hex6.substr( 0, 2 ), 16 ),
  3201. g: parseInt( hex6.substr( 2, 2 ), 16 ),
  3202. b: parseInt( hex6.substr( 4, 2 ), 16 )
  3203. };
  3204. }
  3205. var rgb = color.match( /^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i );
  3206. if( rgb ) {
  3207. return {
  3208. r: parseInt( rgb[1], 10 ),
  3209. g: parseInt( rgb[2], 10 ),
  3210. b: parseInt( rgb[3], 10 )
  3211. };
  3212. }
  3213. var rgba = color.match( /^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\,\s*([\d]+|[\d]*.[\d]+)\s*\)$/i );
  3214. if( rgba ) {
  3215. return {
  3216. r: parseInt( rgba[1], 10 ),
  3217. g: parseInt( rgba[2], 10 ),
  3218. b: parseInt( rgba[3], 10 ),
  3219. a: parseFloat( rgba[4] )
  3220. };
  3221. }
  3222. return null;
  3223. }
  3224. /**
  3225. * Calculates brightness on a scale of 0-255.
  3226. *
  3227. * @param {string} color See colorToRgb for supported formats.
  3228. * @see {@link colorToRgb}
  3229. */
  3230. function colorBrightness( color ) {
  3231. if( typeof color === 'string' ) color = colorToRgb( color );
  3232. if( color ) {
  3233. return ( color.r * 299 + color.g * 587 + color.b * 114 ) / 1000;
  3234. }
  3235. return null;
  3236. }
  3237. /**
  3238. * Returns the remaining height within the parent of the
  3239. * target element.
  3240. *
  3241. * remaining height = [ configured parent height ] - [ current parent height ]
  3242. *
  3243. * @param {HTMLElement} element
  3244. * @param {number} [height]
  3245. */
  3246. function getRemainingHeight( element, height ) {
  3247. height = height || 0;
  3248. if( element ) {
  3249. var newHeight, oldHeight = element.style.height;
  3250. // Change the .stretch element height to 0 in order find the height of all
  3251. // the other elements
  3252. element.style.height = '0px';
  3253. // In Overview mode, the parent (.slide) height is set of 700px.
  3254. // Restore it temporarily to its natural height.
  3255. element.parentNode.style.height = 'auto';
  3256. newHeight = height - element.parentNode.offsetHeight;
  3257. // Restore the old height, just in case
  3258. element.style.height = oldHeight + 'px';
  3259. // Clear the parent (.slide) height. .removeProperty works in IE9+
  3260. element.parentNode.style.removeProperty('height');
  3261. return newHeight;
  3262. }
  3263. return height;
  3264. }
  3265. /**
  3266. * Checks if this instance is being used to print a PDF.
  3267. */
  3268. function isPrintingPDF() {
  3269. return ( /print-pdf/gi ).test( window.location.search );
  3270. }
  3271. /**
  3272. * Hides the address bar if we're on a mobile device.
  3273. */
  3274. function hideAddressBar() {
  3275. if( config.hideAddressBar && isMobileDevice ) {
  3276. // Events that should trigger the address bar to hide
  3277. window.addEventListener( 'load', removeAddressBar, false );
  3278. window.addEventListener( 'orientationchange', removeAddressBar, false );
  3279. }
  3280. }
  3281. /**
  3282. * Causes the address bar to hide on mobile devices,
  3283. * more vertical space ftw.
  3284. */
  3285. function removeAddressBar() {
  3286. setTimeout( function() {
  3287. window.scrollTo( 0, 1 );
  3288. }, 10 );
  3289. }
  3290. /**
  3291. * Dispatches an event of the specified type from the
  3292. * reveal DOM element.
  3293. */
  3294. function dispatchEvent( type, args ) {
  3295. var event = document.createEvent( 'HTMLEvents', 1, 2 );
  3296. event.initEvent( type, true, true );
  3297. extend( event, args );
  3298. dom.wrapper.dispatchEvent( event );
  3299. // If we're in an iframe, post each reveal.js event to the
  3300. // parent window. Used by the notes plugin
  3301. if( config.postMessageEvents && window.parent !== window.self ) {
  3302. window.parent.postMessage( JSON.stringify({ namespace: 'reveal', eventName: type, state: getState() }), '*' );
  3303. }
  3304. }
  3305. /**
  3306. * Wrap all links in 3D goodness.
  3307. */
  3308. function enableRollingLinks() {
  3309. if( features.transforms3d && !( 'msPerspective' in document.body.style ) ) {
  3310. var anchors = dom.wrapper.querySelectorAll( SLIDES_SELECTOR + ' a' );
  3311. for( var i = 0, len = anchors.length; i < len; i++ ) {
  3312. var anchor = anchors[i];
  3313. if( anchor.textContent && !anchor.querySelector( '*' ) && ( !anchor.className || !anchor.classList.contains( anchor, 'roll' ) ) ) {
  3314. var span = document.createElement('span');
  3315. span.setAttribute('data-title', anchor.text);
  3316. span.innerHTML = anchor.innerHTML;
  3317. anchor.classList.add( 'roll' );
  3318. anchor.innerHTML = '';
  3319. anchor.appendChild(span);
  3320. }
  3321. }
  3322. }
  3323. }
  3324. /**
  3325. * Unwrap all 3D links.
  3326. */
  3327. function disableRollingLinks() {
  3328. var anchors = dom.wrapper.querySelectorAll( SLIDES_SELECTOR + ' a.roll' );
  3329. for( var i = 0, len = anchors.length; i < len; i++ ) {
  3330. var anchor = anchors[i];
  3331. var span = anchor.querySelector( 'span' );
  3332. if( span ) {
  3333. anchor.classList.remove( 'roll' );
  3334. anchor.innerHTML = span.innerHTML;
  3335. }
  3336. }
  3337. }
  3338. /**
  3339. * Bind preview frame links.
  3340. *
  3341. * @param {string} [selector=a] - selector for anchors
  3342. */
  3343. function enablePreviewLinks( selector ) {
  3344. var anchors = toArray( document.querySelectorAll( selector ? selector : 'a' ) );
  3345. anchors.forEach( function( element ) {
  3346. if( /^(http|www)/gi.test( element.getAttribute( 'href' ) ) ) {
  3347. element.addEventListener( 'click', onPreviewLinkClicked, false );
  3348. }
  3349. } );
  3350. }
  3351. /**
  3352. * Unbind preview frame links.
  3353. */
  3354. function disablePreviewLinks( selector ) {
  3355. var anchors = toArray( document.querySelectorAll( selector ? selector : 'a' ) );
  3356. anchors.forEach( function( element ) {
  3357. if( /^(http|www)/gi.test( element.getAttribute( 'href' ) ) ) {
  3358. element.removeEventListener( 'click', onPreviewLinkClicked, false );
  3359. }
  3360. } );
  3361. }
  3362. /**
  3363. * Opens a preview window for the target URL.
  3364. *
  3365. * @param {string} url - url for preview iframe src
  3366. */
  3367. function showPreview( url ) {
  3368. closeOverlay();
  3369. dom.overlay = document.createElement( 'div' );
  3370. dom.overlay.classList.add( 'overlay' );
  3371. dom.overlay.classList.add( 'overlay-preview' );
  3372. dom.wrapper.appendChild( dom.overlay );
  3373. dom.overlay.innerHTML = [
  3374. '<header>',
  3375. '<a class="close" href="#"><span class="icon"></span></a>',
  3376. '<a class="external" href="'+ url +'" target="_blank"><span class="icon"></span></a>',
  3377. '</header>',
  3378. '<div class="spinner"></div>',
  3379. '<div class="viewport">',
  3380. '<iframe src="'+ url +'"></iframe>',
  3381. '<small class="viewport-inner">',
  3382. '<span class="x-frame-error">Unable to load iframe. This is likely due to the site\'s policy (x-frame-options).</span>',
  3383. '</small>',
  3384. '</div>'
  3385. ].join('');
  3386. dom.overlay.querySelector( 'iframe' ).addEventListener( 'load', function( event ) {
  3387. dom.overlay.classList.add( 'loaded' );
  3388. }, false );
  3389. dom.overlay.querySelector( '.close' ).addEventListener( 'click', function( event ) {
  3390. closeOverlay();
  3391. event.preventDefault();
  3392. }, false );
  3393. dom.overlay.querySelector( '.external' ).addEventListener( 'click', function( event ) {
  3394. closeOverlay();
  3395. }, false );
  3396. setTimeout( function() {
  3397. dom.overlay.classList.add( 'visible' );
  3398. }, 1 );
  3399. }
  3400. /**
  3401. * Open or close help overlay window.
  3402. *
  3403. * @param {Boolean} [override] Flag which overrides the
  3404. * toggle logic and forcibly sets the desired state. True means
  3405. * help is open, false means it's closed.
  3406. */
  3407. function toggleHelp( override ){
  3408. if( typeof override === 'boolean' ) {
  3409. override ? showHelp() : closeOverlay();
  3410. }
  3411. else {
  3412. if( dom.overlay ) {
  3413. closeOverlay();
  3414. }
  3415. else {
  3416. showHelp();
  3417. }
  3418. }
  3419. }
  3420. /**
  3421. * Opens an overlay window with help material.
  3422. */
  3423. function showHelp() {
  3424. if( config.help ) {
  3425. closeOverlay();
  3426. dom.overlay = document.createElement( 'div' );
  3427. dom.overlay.classList.add( 'overlay' );
  3428. dom.overlay.classList.add( 'overlay-help' );
  3429. dom.wrapper.appendChild( dom.overlay );
  3430. var html = '<p class="title">Keyboard Shortcuts</p><br/>';
  3431. html += '<table><th>KEY</th><th>ACTION</th>';
  3432. for( var key in keyboardShortcuts ) {
  3433. html += '<tr><td>' + key + '</td><td>' + keyboardShortcuts[ key ] + '</td></tr>';
  3434. }
  3435. // Add custom key bindings that have associated descriptions
  3436. for( var binding in registeredKeyBindings ) {
  3437. if( registeredKeyBindings[binding].key && registeredKeyBindings[binding].description ) {
  3438. html += '<tr><td>' + registeredKeyBindings[binding].key + '</td><td>' + registeredKeyBindings[binding].description + '</td></tr>';
  3439. }
  3440. }
  3441. html += '</table>';
  3442. dom.overlay.innerHTML = [
  3443. '<header>',
  3444. '<a class="close" href="#"><span class="icon"></span></a>',
  3445. '</header>',
  3446. '<div class="viewport">',
  3447. '<div class="viewport-inner">'+ html +'</div>',
  3448. '</div>'
  3449. ].join('');
  3450. dom.overlay.querySelector( '.close' ).addEventListener( 'click', function( event ) {
  3451. closeOverlay();
  3452. event.preventDefault();
  3453. }, false );
  3454. setTimeout( function() {
  3455. dom.overlay.classList.add( 'visible' );
  3456. }, 1 );
  3457. }
  3458. }
  3459. /**
  3460. * Closes any currently open overlay.
  3461. */
  3462. function closeOverlay() {
  3463. if( dom.overlay ) {
  3464. dom.overlay.parentNode.removeChild( dom.overlay );
  3465. dom.overlay = null;
  3466. }
  3467. }
  3468. /**
  3469. * Applies JavaScript-controlled layout rules to the
  3470. * presentation.
  3471. */
  3472. function layout() {
  3473. if( dom.wrapper && !isPrintingPDF() ) {
  3474. if( !config.disableLayout ) {
  3475. // On some mobile devices '100vh' is taller than the visible
  3476. // viewport which leads to part of the presentation being
  3477. // cut off. To work around this we define our own '--vh' custom
  3478. // property where 100x adds up to the correct height.
  3479. //
  3480. // https://css-tricks.com/the-trick-to-viewport-units-on-mobile/
  3481. if( isMobileDevice ) {
  3482. document.documentElement.style.setProperty( '--vh', ( window.innerHeight * 0.01 ) + 'px' );
  3483. }
  3484. var size = getComputedSlideSize();
  3485. var oldScale = scale;
  3486. // Layout the contents of the slides
  3487. layoutSlideContents( config.width, config.height );
  3488. dom.slides.style.width = size.width + 'px';
  3489. dom.slides.style.height = size.height + 'px';
  3490. // Determine scale of content to fit within available space
  3491. scale = Math.min( size.presentationWidth / size.width, size.presentationHeight / size.height );
  3492. // Respect max/min scale settings
  3493. scale = Math.max( scale, config.minScale );
  3494. scale = Math.min( scale, config.maxScale );
  3495. // Don't apply any scaling styles if scale is 1
  3496. if( scale === 1 ) {
  3497. dom.slides.style.zoom = '';
  3498. dom.slides.style.left = '';
  3499. dom.slides.style.top = '';
  3500. dom.slides.style.bottom = '';
  3501. dom.slides.style.right = '';
  3502. transformSlides( { layout: '' } );
  3503. }
  3504. else {
  3505. // Prefer zoom for scaling up so that content remains crisp.
  3506. // Don't use zoom to scale down since that can lead to shifts
  3507. // in text layout/line breaks.
  3508. if( scale > 1 && features.zoom ) {
  3509. dom.slides.style.zoom = scale;
  3510. dom.slides.style.left = '';
  3511. dom.slides.style.top = '';
  3512. dom.slides.style.bottom = '';
  3513. dom.slides.style.right = '';
  3514. transformSlides( { layout: '' } );
  3515. }
  3516. // Apply scale transform as a fallback
  3517. else {
  3518. dom.slides.style.zoom = '';
  3519. dom.slides.style.left = '50%';
  3520. dom.slides.style.top = '50%';
  3521. dom.slides.style.bottom = 'auto';
  3522. dom.slides.style.right = 'auto';
  3523. transformSlides( { layout: 'translate(-50%, -50%) scale('+ scale +')' } );
  3524. }
  3525. }
  3526. // Select all slides, vertical and horizontal
  3527. var slides = toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) );
  3528. for( var i = 0, len = slides.length; i < len; i++ ) {
  3529. var slide = slides[ i ];
  3530. // Don't bother updating invisible slides
  3531. if( slide.style.display === 'none' ) {
  3532. continue;
  3533. }
  3534. if( config.center || slide.classList.contains( 'center' ) ) {
  3535. // Vertical stacks are not centred since their section
  3536. // children will be
  3537. if( slide.classList.contains( 'stack' ) ) {
  3538. slide.style.top = 0;
  3539. }
  3540. else {
  3541. slide.style.top = Math.max( ( size.height - slide.scrollHeight ) / 2, 0 ) + 'px';
  3542. }
  3543. }
  3544. else {
  3545. slide.style.top = '';
  3546. }
  3547. }
  3548. if( oldScale !== scale ) {
  3549. dispatchEvent( 'resize', {
  3550. 'oldScale': oldScale,
  3551. 'scale': scale,
  3552. 'size': size
  3553. } );
  3554. }
  3555. }
  3556. updateProgress();
  3557. updateParallax();
  3558. if( isOverview() ) {
  3559. updateOverview();
  3560. }
  3561. }
  3562. }
  3563. /**
  3564. * Applies layout logic to the contents of all slides in
  3565. * the presentation.
  3566. *
  3567. * @param {string|number} width
  3568. * @param {string|number} height
  3569. */
  3570. function layoutSlideContents( width, height ) {
  3571. // Handle sizing of elements with the 'stretch' class
  3572. toArray( dom.slides.querySelectorAll( 'section > .stretch' ) ).forEach( function( element ) {
  3573. // Determine how much vertical space we can use
  3574. var remainingHeight = getRemainingHeight( element, height );
  3575. // Consider the aspect ratio of media elements
  3576. if( /(img|video)/gi.test( element.nodeName ) ) {
  3577. var nw = element.naturalWidth || element.videoWidth,
  3578. nh = element.naturalHeight || element.videoHeight;
  3579. var es = Math.min( width / nw, remainingHeight / nh );
  3580. element.style.width = ( nw * es ) + 'px';
  3581. element.style.height = ( nh * es ) + 'px';
  3582. }
  3583. else {
  3584. element.style.width = width + 'px';
  3585. element.style.height = remainingHeight + 'px';
  3586. }
  3587. } );
  3588. }
  3589. /**
  3590. * Calculates the computed pixel size of our slides. These
  3591. * values are based on the width and height configuration
  3592. * options.
  3593. *
  3594. * @param {number} [presentationWidth=dom.wrapper.offsetWidth]
  3595. * @param {number} [presentationHeight=dom.wrapper.offsetHeight]
  3596. */
  3597. function getComputedSlideSize( presentationWidth, presentationHeight ) {
  3598. var size = {
  3599. // Slide size
  3600. width: config.width,
  3601. height: config.height,
  3602. // Presentation size
  3603. presentationWidth: presentationWidth || dom.wrapper.offsetWidth,
  3604. presentationHeight: presentationHeight || dom.wrapper.offsetHeight
  3605. };
  3606. // Reduce available space by margin
  3607. size.presentationWidth -= ( size.presentationWidth * config.margin );
  3608. size.presentationHeight -= ( size.presentationHeight * config.margin );
  3609. // Slide width may be a percentage of available width
  3610. if( typeof size.width === 'string' && /%$/.test( size.width ) ) {
  3611. size.width = parseInt( size.width, 10 ) / 100 * size.presentationWidth;
  3612. }
  3613. // Slide height may be a percentage of available height
  3614. if( typeof size.height === 'string' && /%$/.test( size.height ) ) {
  3615. size.height = parseInt( size.height, 10 ) / 100 * size.presentationHeight;
  3616. }
  3617. return size;
  3618. }
  3619. /**
  3620. * Stores the vertical index of a stack so that the same
  3621. * vertical slide can be selected when navigating to and
  3622. * from the stack.
  3623. *
  3624. * @param {HTMLElement} stack The vertical stack element
  3625. * @param {string|number} [v=0] Index to memorize
  3626. */
  3627. function setPreviousVerticalIndex( stack, v ) {
  3628. if( typeof stack === 'object' && typeof stack.setAttribute === 'function' ) {
  3629. stack.setAttribute( 'data-previous-indexv', v || 0 );
  3630. }
  3631. }
  3632. /**
  3633. * Retrieves the vertical index which was stored using
  3634. * #setPreviousVerticalIndex() or 0 if no previous index
  3635. * exists.
  3636. *
  3637. * @param {HTMLElement} stack The vertical stack element
  3638. */
  3639. function getPreviousVerticalIndex( stack ) {
  3640. if( typeof stack === 'object' && typeof stack.setAttribute === 'function' && stack.classList.contains( 'stack' ) ) {
  3641. // Prefer manually defined start-indexv
  3642. var attributeName = stack.hasAttribute( 'data-start-indexv' ) ? 'data-start-indexv' : 'data-previous-indexv';
  3643. return parseInt( stack.getAttribute( attributeName ) || 0, 10 );
  3644. }
  3645. return 0;
  3646. }
  3647. /**
  3648. * Displays the overview of slides (quick nav) by scaling
  3649. * down and arranging all slide elements.
  3650. */
  3651. function activateOverview() {
  3652. // Only proceed if enabled in config
  3653. if( config.overview && !isOverview() ) {
  3654. overview = true;
  3655. dom.wrapper.classList.add( 'overview' );
  3656. dom.wrapper.classList.remove( 'overview-deactivating' );
  3657. if( features.overviewTransitions ) {
  3658. setTimeout( function() {
  3659. dom.wrapper.classList.add( 'overview-animated' );
  3660. }, 1 );
  3661. }
  3662. // Don't auto-slide while in overview mode
  3663. cancelAutoSlide();
  3664. // Move the backgrounds element into the slide container to
  3665. // that the same scaling is applied
  3666. dom.slides.appendChild( dom.background );
  3667. // Clicking on an overview slide navigates to it
  3668. toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) ).forEach( function( slide ) {
  3669. if( !slide.classList.contains( 'stack' ) ) {
  3670. slide.addEventListener( 'click', onOverviewSlideClicked, true );
  3671. }
  3672. } );
  3673. // Calculate slide sizes
  3674. var margin = 70;
  3675. var slideSize = getComputedSlideSize();
  3676. overviewSlideWidth = slideSize.width + margin;
  3677. overviewSlideHeight = slideSize.height + margin;
  3678. // Reverse in RTL mode
  3679. if( config.rtl ) {
  3680. overviewSlideWidth = -overviewSlideWidth;
  3681. }
  3682. updateSlidesVisibility();
  3683. layoutOverview();
  3684. updateOverview();
  3685. layout();
  3686. // Notify observers of the overview showing
  3687. dispatchEvent( 'overviewshown', {
  3688. 'indexh': indexh,
  3689. 'indexv': indexv,
  3690. 'currentSlide': currentSlide
  3691. } );
  3692. }
  3693. }
  3694. /**
  3695. * Uses CSS transforms to position all slides in a grid for
  3696. * display inside of the overview mode.
  3697. */
  3698. function layoutOverview() {
  3699. // Layout slides
  3700. toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).forEach( function( hslide, h ) {
  3701. hslide.setAttribute( 'data-index-h', h );
  3702. transformElement( hslide, 'translate3d(' + ( h * overviewSlideWidth ) + 'px, 0, 0)' );
  3703. if( hslide.classList.contains( 'stack' ) ) {
  3704. toArray( hslide.querySelectorAll( 'section' ) ).forEach( function( vslide, v ) {
  3705. vslide.setAttribute( 'data-index-h', h );
  3706. vslide.setAttribute( 'data-index-v', v );
  3707. transformElement( vslide, 'translate3d(0, ' + ( v * overviewSlideHeight ) + 'px, 0)' );
  3708. } );
  3709. }
  3710. } );
  3711. // Layout slide backgrounds
  3712. toArray( dom.background.childNodes ).forEach( function( hbackground, h ) {
  3713. transformElement( hbackground, 'translate3d(' + ( h * overviewSlideWidth ) + 'px, 0, 0)' );
  3714. toArray( hbackground.querySelectorAll( '.slide-background' ) ).forEach( function( vbackground, v ) {
  3715. transformElement( vbackground, 'translate3d(0, ' + ( v * overviewSlideHeight ) + 'px, 0)' );
  3716. } );
  3717. } );
  3718. }
  3719. /**
  3720. * Moves the overview viewport to the current slides.
  3721. * Called each time the current slide changes.
  3722. */
  3723. function updateOverview() {
  3724. var vmin = Math.min( window.innerWidth, window.innerHeight );
  3725. var scale = Math.max( vmin / 5, 150 ) / vmin;
  3726. transformSlides( {
  3727. overview: [
  3728. 'scale('+ scale +')',
  3729. 'translateX('+ ( -indexh * overviewSlideWidth ) +'px)',
  3730. 'translateY('+ ( -indexv * overviewSlideHeight ) +'px)'
  3731. ].join( ' ' )
  3732. } );
  3733. }
  3734. /**
  3735. * Exits the slide overview and enters the currently
  3736. * active slide.
  3737. */
  3738. function deactivateOverview() {
  3739. // Only proceed if enabled in config
  3740. if( config.overview ) {
  3741. overview = false;
  3742. dom.wrapper.classList.remove( 'overview' );
  3743. dom.wrapper.classList.remove( 'overview-animated' );
  3744. // Temporarily add a class so that transitions can do different things
  3745. // depending on whether they are exiting/entering overview, or just
  3746. // moving from slide to slide
  3747. dom.wrapper.classList.add( 'overview-deactivating' );
  3748. setTimeout( function () {
  3749. dom.wrapper.classList.remove( 'overview-deactivating' );
  3750. }, 1 );
  3751. // Move the background element back out
  3752. dom.wrapper.appendChild( dom.background );
  3753. // Clean up changes made to slides
  3754. toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) ).forEach( function( slide ) {
  3755. transformElement( slide, '' );
  3756. slide.removeEventListener( 'click', onOverviewSlideClicked, true );
  3757. } );
  3758. // Clean up changes made to backgrounds
  3759. toArray( dom.background.querySelectorAll( '.slide-background' ) ).forEach( function( background ) {
  3760. transformElement( background, '' );
  3761. } );
  3762. transformSlides( { overview: '' } );
  3763. slide( indexh, indexv );
  3764. layout();
  3765. cueAutoSlide();
  3766. // Notify observers of the overview hiding
  3767. dispatchEvent( 'overviewhidden', {
  3768. 'indexh': indexh,
  3769. 'indexv': indexv,
  3770. 'currentSlide': currentSlide
  3771. } );
  3772. }
  3773. }
  3774. /**
  3775. * Toggles the slide overview mode on and off.
  3776. *
  3777. * @param {Boolean} [override] Flag which overrides the
  3778. * toggle logic and forcibly sets the desired state. True means
  3779. * overview is open, false means it's closed.
  3780. */
  3781. function toggleOverview( override ) {
  3782. if( typeof override === 'boolean' ) {
  3783. override ? activateOverview() : deactivateOverview();
  3784. }
  3785. else {
  3786. isOverview() ? deactivateOverview() : activateOverview();
  3787. }
  3788. }
  3789. /**
  3790. * Checks if the overview is currently active.
  3791. *
  3792. * @return {Boolean} true if the overview is active,
  3793. * false otherwise
  3794. */
  3795. function isOverview() {
  3796. return overview;
  3797. }
  3798. /**
  3799. * Return a hash URL that will resolve to the current slide location.
  3800. */
  3801. function locationHash() {
  3802. var url = '/';
  3803. // Attempt to create a named link based on the slide's ID
  3804. var id = currentSlide ? currentSlide.getAttribute( 'id' ) : null;
  3805. if( id ) {
  3806. id = encodeURIComponent( id );
  3807. }
  3808. var indexf;
  3809. if( config.fragmentInURL ) {
  3810. indexf = getIndices().f;
  3811. }
  3812. // If the current slide has an ID, use that as a named link,
  3813. // but we don't support named links with a fragment index
  3814. if( typeof id === 'string' && id.length && indexf === undefined ) {
  3815. url = '/' + id;
  3816. }
  3817. // Otherwise use the /h/v index
  3818. else {
  3819. var hashIndexBase = config.hashOneBasedIndex ? 1 : 0;
  3820. if( indexh > 0 || indexv > 0 || indexf !== undefined ) url += indexh + hashIndexBase;
  3821. if( indexv > 0 || indexf !== undefined ) url += '/' + (indexv + hashIndexBase );
  3822. if( indexf !== undefined ) url += '/' + indexf;
  3823. }
  3824. return url;
  3825. }
  3826. /**
  3827. * Checks if the current or specified slide is vertical
  3828. * (nested within another slide).
  3829. *
  3830. * @param {HTMLElement} [slide=currentSlide] The slide to check
  3831. * orientation of
  3832. * @return {Boolean}
  3833. */
  3834. function isVerticalSlide( slide ) {
  3835. // Prefer slide argument, otherwise use current slide
  3836. slide = slide ? slide : currentSlide;
  3837. return slide && slide.parentNode && !!slide.parentNode.nodeName.match( /section/i );
  3838. }
  3839. /**
  3840. * Handling the fullscreen functionality via the fullscreen API
  3841. *
  3842. * @see http://fullscreen.spec.whatwg.org/
  3843. * @see https://developer.mozilla.org/en-US/docs/DOM/Using_fullscreen_mode
  3844. */
  3845. function enterFullscreen() {
  3846. var element = document.documentElement;
  3847. // Check which implementation is available
  3848. var requestMethod = element.requestFullscreen ||
  3849. element.webkitRequestFullscreen ||
  3850. element.webkitRequestFullScreen ||
  3851. element.mozRequestFullScreen ||
  3852. element.msRequestFullscreen;
  3853. if( requestMethod ) {
  3854. requestMethod.apply( element );
  3855. }
  3856. }
  3857. /**
  3858. * Shows the mouse pointer after it has been hidden with
  3859. * #hideCursor.
  3860. */
  3861. function showCursor() {
  3862. if( cursorHidden ) {
  3863. cursorHidden = false;
  3864. dom.wrapper.style.cursor = '';
  3865. }
  3866. }
  3867. /**
  3868. * Hides the mouse pointer when it's on top of the .reveal
  3869. * container.
  3870. */
  3871. function hideCursor() {
  3872. if( cursorHidden === false ) {
  3873. cursorHidden = true;
  3874. dom.wrapper.style.cursor = 'none';
  3875. }
  3876. }
  3877. /**
  3878. * Enters the paused mode which fades everything on screen to
  3879. * black.
  3880. */
  3881. function pause() {
  3882. if( config.pause ) {
  3883. var wasPaused = dom.wrapper.classList.contains( 'paused' );
  3884. cancelAutoSlide();
  3885. dom.wrapper.classList.add( 'paused' );
  3886. if( wasPaused === false ) {
  3887. dispatchEvent( 'paused' );
  3888. }
  3889. }
  3890. }
  3891. /**
  3892. * Exits from the paused mode.
  3893. */
  3894. function resume() {
  3895. var wasPaused = dom.wrapper.classList.contains( 'paused' );
  3896. dom.wrapper.classList.remove( 'paused' );
  3897. cueAutoSlide();
  3898. if( wasPaused ) {
  3899. dispatchEvent( 'resumed' );
  3900. }
  3901. }
  3902. /**
  3903. * Toggles the paused mode on and off.
  3904. */
  3905. function togglePause( override ) {
  3906. if( typeof override === 'boolean' ) {
  3907. override ? pause() : resume();
  3908. }
  3909. else {
  3910. isPaused() ? resume() : pause();
  3911. }
  3912. }
  3913. /**
  3914. * Checks if we are currently in the paused mode.
  3915. *
  3916. * @return {Boolean}
  3917. */
  3918. function isPaused() {
  3919. return dom.wrapper.classList.contains( 'paused' );
  3920. }
  3921. /**
  3922. * Toggles the auto slide mode on and off.
  3923. *
  3924. * @param {Boolean} [override] Flag which sets the desired state.
  3925. * True means autoplay starts, false means it stops.
  3926. */
  3927. function toggleAutoSlide( override ) {
  3928. if( typeof override === 'boolean' ) {
  3929. override ? resumeAutoSlide() : pauseAutoSlide();
  3930. }
  3931. else {
  3932. autoSlidePaused ? resumeAutoSlide() : pauseAutoSlide();
  3933. }
  3934. }
  3935. /**
  3936. * Checks if the auto slide mode is currently on.
  3937. *
  3938. * @return {Boolean}
  3939. */
  3940. function isAutoSliding() {
  3941. return !!( autoSlide && !autoSlidePaused );
  3942. }
  3943. /**
  3944. * Steps from the current point in the presentation to the
  3945. * slide which matches the specified horizontal and vertical
  3946. * indices.
  3947. *
  3948. * @param {number} [h=indexh] Horizontal index of the target slide
  3949. * @param {number} [v=indexv] Vertical index of the target slide
  3950. * @param {number} [f] Index of a fragment within the
  3951. * target slide to activate
  3952. * @param {number} [o] Origin for use in multimaster environments
  3953. */
  3954. function slide( h, v, f, o ) {
  3955. // Remember where we were at before
  3956. previousSlide = currentSlide;
  3957. // Query all horizontal slides in the deck
  3958. var horizontalSlides = dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR );
  3959. // Abort if there are no slides
  3960. if( horizontalSlides.length === 0 ) return;
  3961. // If no vertical index is specified and the upcoming slide is a
  3962. // stack, resume at its previous vertical index
  3963. if( v === undefined && !isOverview() ) {
  3964. v = getPreviousVerticalIndex( horizontalSlides[ h ] );
  3965. }
  3966. // If we were on a vertical stack, remember what vertical index
  3967. // it was on so we can resume at the same position when returning
  3968. if( previousSlide && previousSlide.parentNode && previousSlide.parentNode.classList.contains( 'stack' ) ) {
  3969. setPreviousVerticalIndex( previousSlide.parentNode, indexv );
  3970. }
  3971. // Remember the state before this slide
  3972. var stateBefore = state.concat();
  3973. // Reset the state array
  3974. state.length = 0;
  3975. var indexhBefore = indexh || 0,
  3976. indexvBefore = indexv || 0;
  3977. // Activate and transition to the new slide
  3978. indexh = updateSlides( HORIZONTAL_SLIDES_SELECTOR, h === undefined ? indexh : h );
  3979. indexv = updateSlides( VERTICAL_SLIDES_SELECTOR, v === undefined ? indexv : v );
  3980. // Update the visibility of slides now that the indices have changed
  3981. updateSlidesVisibility();
  3982. layout();
  3983. // Update the overview if it's currently active
  3984. if( isOverview() ) {
  3985. updateOverview();
  3986. }
  3987. // Find the current horizontal slide and any possible vertical slides
  3988. // within it
  3989. var currentHorizontalSlide = horizontalSlides[ indexh ],
  3990. currentVerticalSlides = currentHorizontalSlide.querySelectorAll( 'section' );
  3991. // Store references to the previous and current slides
  3992. currentSlide = currentVerticalSlides[ indexv ] || currentHorizontalSlide;
  3993. // Show fragment, if specified
  3994. if( typeof f !== 'undefined' ) {
  3995. navigateFragment( f );
  3996. }
  3997. // Dispatch an event if the slide changed
  3998. var slideChanged = ( indexh !== indexhBefore || indexv !== indexvBefore );
  3999. if (!slideChanged) {
  4000. // Ensure that the previous slide is never the same as the current
  4001. previousSlide = null;
  4002. }
  4003. // Solves an edge case where the previous slide maintains the
  4004. // 'present' class when navigating between adjacent vertical
  4005. // stacks
  4006. if( previousSlide && previousSlide !== currentSlide ) {
  4007. previousSlide.classList.remove( 'present' );
  4008. previousSlide.setAttribute( 'aria-hidden', 'true' );
  4009. // Reset all slides upon navigate to home
  4010. // Issue: #285
  4011. if ( dom.wrapper.querySelector( HOME_SLIDE_SELECTOR ).classList.contains( 'present' ) ) {
  4012. // Launch async task
  4013. setTimeout( function () {
  4014. var slides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.stack') ), i;
  4015. for( i in slides ) {
  4016. if( slides[i] ) {
  4017. // Reset stack
  4018. setPreviousVerticalIndex( slides[i], 0 );
  4019. }
  4020. }
  4021. }, 0 );
  4022. }
  4023. }
  4024. // Apply the new state
  4025. stateLoop: for( var i = 0, len = state.length; i < len; i++ ) {
  4026. // Check if this state existed on the previous slide. If it
  4027. // did, we will avoid adding it repeatedly
  4028. for( var j = 0; j < stateBefore.length; j++ ) {
  4029. if( stateBefore[j] === state[i] ) {
  4030. stateBefore.splice( j, 1 );
  4031. continue stateLoop;
  4032. }
  4033. }
  4034. document.documentElement.classList.add( state[i] );
  4035. // Dispatch custom event matching the state's name
  4036. dispatchEvent( state[i] );
  4037. }
  4038. // Clean up the remains of the previous state
  4039. while( stateBefore.length ) {
  4040. document.documentElement.classList.remove( stateBefore.pop() );
  4041. }
  4042. if( slideChanged ) {
  4043. dispatchEvent( 'slidechanged', {
  4044. 'indexh': indexh,
  4045. 'indexv': indexv,
  4046. 'previousSlide': previousSlide,
  4047. 'currentSlide': currentSlide,
  4048. 'origin': o
  4049. } );
  4050. }
  4051. // Handle embedded content
  4052. if( slideChanged || !previousSlide ) {
  4053. stopEmbeddedContent( previousSlide );
  4054. startEmbeddedContent( currentSlide );
  4055. }
  4056. // Announce the current slide contents, for screen readers
  4057. dom.statusDiv.textContent = getStatusText( currentSlide );
  4058. updateControls();
  4059. updateProgress();
  4060. updateBackground();
  4061. updateParallax();
  4062. updateSlideNumber();
  4063. updateNotes();
  4064. updateFragments();
  4065. // Update the URL hash
  4066. writeURL();
  4067. cueAutoSlide();
  4068. }
  4069. /**
  4070. * Syncs the presentation with the current DOM. Useful
  4071. * when new slides or control elements are added or when
  4072. * the configuration has changed.
  4073. */
  4074. function sync() {
  4075. // Subscribe to input
  4076. removeEventListeners();
  4077. addEventListeners();
  4078. // Force a layout to make sure the current config is accounted for
  4079. layout();
  4080. // Reflect the current autoSlide value
  4081. autoSlide = config.autoSlide;
  4082. // Start auto-sliding if it's enabled
  4083. cueAutoSlide();
  4084. // Re-create the slide backgrounds
  4085. createBackgrounds();
  4086. // Write the current hash to the URL
  4087. writeURL();
  4088. sortAllFragments();
  4089. updateControls();
  4090. updateProgress();
  4091. updateSlideNumber();
  4092. updateSlidesVisibility();
  4093. updateBackground( true );
  4094. updateNotesVisibility();
  4095. updateNotes();
  4096. formatEmbeddedContent();
  4097. // Start or stop embedded content depending on global config
  4098. if( config.autoPlayMedia === false ) {
  4099. stopEmbeddedContent( currentSlide, { unloadIframes: false } );
  4100. }
  4101. else {
  4102. startEmbeddedContent( currentSlide );
  4103. }
  4104. if( isOverview() ) {
  4105. layoutOverview();
  4106. }
  4107. }
  4108. /**
  4109. * Updates reveal.js to keep in sync with new slide attributes. For
  4110. * example, if you add a new `data-background-image` you can call
  4111. * this to have reveal.js render the new background image.
  4112. *
  4113. * Similar to #sync() but more efficient when you only need to
  4114. * refresh a specific slide.
  4115. *
  4116. * @param {HTMLElement} slide
  4117. */
  4118. function syncSlide( slide ) {
  4119. // Default to the current slide
  4120. slide = slide || currentSlide;
  4121. syncBackground( slide );
  4122. syncFragments( slide );
  4123. updateBackground();
  4124. updateNotes();
  4125. loadSlide( slide );
  4126. }
  4127. /**
  4128. * Formats the fragments on the given slide so that they have
  4129. * valid indices. Call this if fragments are changed in the DOM
  4130. * after reveal.js has already initialized.
  4131. *
  4132. * @param {HTMLElement} slide
  4133. * @return {Array} a list of the HTML fragments that were synced
  4134. */
  4135. function syncFragments( slide ) {
  4136. // Default to the current slide
  4137. slide = slide || currentSlide;
  4138. return sortFragments( slide.querySelectorAll( '.fragment' ) );
  4139. }
  4140. /**
  4141. * Resets all vertical slides so that only the first
  4142. * is visible.
  4143. */
  4144. function resetVerticalSlides() {
  4145. var horizontalSlides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
  4146. horizontalSlides.forEach( function( horizontalSlide ) {
  4147. var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) );
  4148. verticalSlides.forEach( function( verticalSlide, y ) {
  4149. if( y > 0 ) {
  4150. verticalSlide.classList.remove( 'present' );
  4151. verticalSlide.classList.remove( 'past' );
  4152. verticalSlide.classList.add( 'future' );
  4153. verticalSlide.setAttribute( 'aria-hidden', 'true' );
  4154. }
  4155. } );
  4156. } );
  4157. }
  4158. /**
  4159. * Sorts and formats all of fragments in the
  4160. * presentation.
  4161. */
  4162. function sortAllFragments() {
  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. sortFragments( verticalSlide.querySelectorAll( '.fragment' ) );
  4168. } );
  4169. if( verticalSlides.length === 0 ) sortFragments( horizontalSlide.querySelectorAll( '.fragment' ) );
  4170. } );
  4171. }
  4172. /**
  4173. * Randomly shuffles all slides in the deck.
  4174. */
  4175. function shuffle() {
  4176. var slides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
  4177. slides.forEach( function( slide ) {
  4178. // Insert this slide next to another random slide. This may
  4179. // cause the slide to insert before itself but that's fine.
  4180. dom.slides.insertBefore( slide, slides[ Math.floor( Math.random() * slides.length ) ] );
  4181. } );
  4182. }
  4183. /**
  4184. * Updates one dimension of slides by showing the slide
  4185. * with the specified index.
  4186. *
  4187. * @param {string} selector A CSS selector that will fetch
  4188. * the group of slides we are working with
  4189. * @param {number} index The index of the slide that should be
  4190. * shown
  4191. *
  4192. * @return {number} The index of the slide that is now shown,
  4193. * might differ from the passed in index if it was out of
  4194. * bounds.
  4195. */
  4196. function updateSlides( selector, index ) {
  4197. // Select all slides and convert the NodeList result to
  4198. // an array
  4199. var slides = toArray( dom.wrapper.querySelectorAll( selector ) ),
  4200. slidesLength = slides.length;
  4201. var printMode = isPrintingPDF();
  4202. if( slidesLength ) {
  4203. // Should the index loop?
  4204. if( config.loop ) {
  4205. index %= slidesLength;
  4206. if( index < 0 ) {
  4207. index = slidesLength + index;
  4208. }
  4209. }
  4210. // Enforce max and minimum index bounds
  4211. index = Math.max( Math.min( index, slidesLength - 1 ), 0 );
  4212. for( var i = 0; i < slidesLength; i++ ) {
  4213. var element = slides[i];
  4214. var reverse = config.rtl && !isVerticalSlide( element );
  4215. element.classList.remove( 'past' );
  4216. element.classList.remove( 'present' );
  4217. element.classList.remove( 'future' );
  4218. // http://www.w3.org/html/wg/drafts/html/master/editing.html#the-hidden-attribute
  4219. element.setAttribute( 'hidden', '' );
  4220. element.setAttribute( 'aria-hidden', 'true' );
  4221. // If this element contains vertical slides
  4222. if( element.querySelector( 'section' ) ) {
  4223. element.classList.add( 'stack' );
  4224. }
  4225. // If we're printing static slides, all slides are "present"
  4226. if( printMode ) {
  4227. element.classList.add( 'present' );
  4228. continue;
  4229. }
  4230. if( i < index ) {
  4231. // Any element previous to index is given the 'past' class
  4232. element.classList.add( reverse ? 'future' : 'past' );
  4233. if( config.fragments ) {
  4234. // Show all fragments in prior slides
  4235. toArray( element.querySelectorAll( '.fragment' ) ).forEach( function( fragment ) {
  4236. fragment.classList.add( 'visible' );
  4237. fragment.classList.remove( 'current-fragment' );
  4238. } );
  4239. }
  4240. }
  4241. else if( i > index ) {
  4242. // Any element subsequent to index is given the 'future' class
  4243. element.classList.add( reverse ? 'past' : 'future' );
  4244. if( config.fragments ) {
  4245. // Hide all fragments in future slides
  4246. toArray( element.querySelectorAll( '.fragment.visible' ) ).forEach( function( fragment ) {
  4247. fragment.classList.remove( 'visible' );
  4248. fragment.classList.remove( 'current-fragment' );
  4249. } );
  4250. }
  4251. }
  4252. }
  4253. // Mark the current slide as present
  4254. slides[index].classList.add( 'present' );
  4255. slides[index].removeAttribute( 'hidden' );
  4256. slides[index].removeAttribute( 'aria-hidden' );
  4257. // If this slide has a state associated with it, add it
  4258. // onto the current state of the deck
  4259. var slideState = slides[index].getAttribute( 'data-state' );
  4260. if( slideState ) {
  4261. state = state.concat( slideState.split( ' ' ) );
  4262. }
  4263. }
  4264. else {
  4265. // Since there are no slides we can't be anywhere beyond the
  4266. // zeroth index
  4267. index = 0;
  4268. }
  4269. return index;
  4270. }
  4271. /**
  4272. * Optimization method; hide all slides that are far away
  4273. * from the present slide.
  4274. */
  4275. function updateSlidesVisibility() {
  4276. // Select all slides and convert the NodeList result to
  4277. // an array
  4278. var horizontalSlides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ),
  4279. horizontalSlidesLength = horizontalSlides.length,
  4280. distanceX,
  4281. distanceY;
  4282. if( horizontalSlidesLength && typeof indexh !== 'undefined' ) {
  4283. // The number of steps away from the present slide that will
  4284. // be visible
  4285. var viewDistance = isOverview() ? 10 : config.viewDistance;
  4286. // Limit view distance on weaker devices
  4287. if( isMobileDevice ) {
  4288. viewDistance = isOverview() ? 6 : 2;
  4289. }
  4290. // All slides need to be visible when exporting to PDF
  4291. if( isPrintingPDF() ) {
  4292. viewDistance = Number.MAX_VALUE;
  4293. }
  4294. for( var x = 0; x < horizontalSlidesLength; x++ ) {
  4295. var horizontalSlide = horizontalSlides[x];
  4296. var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) ),
  4297. verticalSlidesLength = verticalSlides.length;
  4298. // Determine how far away this slide is from the present
  4299. distanceX = Math.abs( ( indexh || 0 ) - x ) || 0;
  4300. // If the presentation is looped, distance should measure
  4301. // 1 between the first and last slides
  4302. if( config.loop ) {
  4303. distanceX = Math.abs( ( ( indexh || 0 ) - x ) % ( horizontalSlidesLength - viewDistance ) ) || 0;
  4304. }
  4305. // Show the horizontal slide if it's within the view distance
  4306. if( distanceX < viewDistance ) {
  4307. loadSlide( horizontalSlide );
  4308. }
  4309. else {
  4310. unloadSlide( horizontalSlide );
  4311. }
  4312. if( verticalSlidesLength ) {
  4313. var oy = getPreviousVerticalIndex( horizontalSlide );
  4314. for( var y = 0; y < verticalSlidesLength; y++ ) {
  4315. var verticalSlide = verticalSlides[y];
  4316. distanceY = x === ( indexh || 0 ) ? Math.abs( ( indexv || 0 ) - y ) : Math.abs( y - oy );
  4317. if( distanceX + distanceY < viewDistance ) {
  4318. loadSlide( verticalSlide );
  4319. }
  4320. else {
  4321. unloadSlide( verticalSlide );
  4322. }
  4323. }
  4324. }
  4325. }
  4326. // Flag if there are ANY vertical slides, anywhere in the deck
  4327. if( dom.wrapper.querySelectorAll( '.slides>section>section' ).length ) {
  4328. dom.wrapper.classList.add( 'has-vertical-slides' );
  4329. }
  4330. else {
  4331. dom.wrapper.classList.remove( 'has-vertical-slides' );
  4332. }
  4333. // Flag if there are ANY horizontal slides, anywhere in the deck
  4334. if( dom.wrapper.querySelectorAll( '.slides>section' ).length > 1 ) {
  4335. dom.wrapper.classList.add( 'has-horizontal-slides' );
  4336. }
  4337. else {
  4338. dom.wrapper.classList.remove( 'has-horizontal-slides' );
  4339. }
  4340. }
  4341. }
  4342. /**
  4343. * Pick up notes from the current slide and display them
  4344. * to the viewer.
  4345. *
  4346. * @see {@link config.showNotes}
  4347. */
  4348. function updateNotes() {
  4349. if( config.showNotes && dom.speakerNotes && currentSlide && !isPrintingPDF() ) {
  4350. dom.speakerNotes.innerHTML = getSlideNotes() || '<span class="notes-placeholder">No notes on this slide.</span>';
  4351. }
  4352. }
  4353. /**
  4354. * Updates the visibility of the speaker notes sidebar that
  4355. * is used to share annotated slides. The notes sidebar is
  4356. * only visible if showNotes is true and there are notes on
  4357. * one or more slides in the deck.
  4358. */
  4359. function updateNotesVisibility() {
  4360. if( config.showNotes && hasNotes() ) {
  4361. dom.wrapper.classList.add( 'show-notes' );
  4362. }
  4363. else {
  4364. dom.wrapper.classList.remove( 'show-notes' );
  4365. }
  4366. }
  4367. /**
  4368. * Checks if there are speaker notes for ANY slide in the
  4369. * presentation.
  4370. */
  4371. function hasNotes() {
  4372. return dom.slides.querySelectorAll( '[data-notes], aside.notes' ).length > 0;
  4373. }
  4374. /**
  4375. * Updates the progress bar to reflect the current slide.
  4376. */
  4377. function updateProgress() {
  4378. // Update progress if enabled
  4379. if( config.progress && dom.progressbar ) {
  4380. dom.progressbar.style.width = getProgress() * dom.wrapper.offsetWidth + 'px';
  4381. }
  4382. }
  4383. /**
  4384. * Updates the slide number to match the current slide.
  4385. */
  4386. function updateSlideNumber() {
  4387. // Update slide number if enabled
  4388. if( config.slideNumber && dom.slideNumber ) {
  4389. var value;
  4390. var format = 'h.v';
  4391. if( typeof config.slideNumber === 'function' ) {
  4392. value = config.slideNumber();
  4393. }
  4394. else {
  4395. // Check if a custom number format is available
  4396. if( typeof config.slideNumber === 'string' ) {
  4397. format = config.slideNumber;
  4398. }
  4399. // If there are ONLY vertical slides in this deck, always use
  4400. // a flattened slide number
  4401. if( !/c/.test( format ) && dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ).length === 1 ) {
  4402. format = 'c';
  4403. }
  4404. value = [];
  4405. switch( format ) {
  4406. case 'c':
  4407. value.push( getSlidePastCount() + 1 );
  4408. break;
  4409. case 'c/t':
  4410. value.push( getSlidePastCount() + 1, '/', getTotalSlides() );
  4411. break;
  4412. case 'h/v':
  4413. value.push( indexh + 1 );
  4414. if( isVerticalSlide() ) value.push( '/', indexv + 1 );
  4415. break;
  4416. default:
  4417. value.push( indexh + 1 );
  4418. if( isVerticalSlide() ) value.push( '.', indexv + 1 );
  4419. }
  4420. }
  4421. dom.slideNumber.innerHTML = formatSlideNumber( value[0], value[1], value[2] );
  4422. }
  4423. }
  4424. /**
  4425. * Applies HTML formatting to a slide number before it's
  4426. * written to the DOM.
  4427. *
  4428. * @param {number} a Current slide
  4429. * @param {string} delimiter Character to separate slide numbers
  4430. * @param {(number|*)} b Total slides
  4431. * @return {string} HTML string fragment
  4432. */
  4433. function formatSlideNumber( a, delimiter, b ) {
  4434. var url = '#' + locationHash();
  4435. if( typeof b === 'number' && !isNaN( b ) ) {
  4436. return '<a href="' + url + '">' +
  4437. '<span class="slide-number-a">'+ a +'</span>' +
  4438. '<span class="slide-number-delimiter">'+ delimiter +'</span>' +
  4439. '<span class="slide-number-b">'+ b +'</span>' +
  4440. '</a>';
  4441. }
  4442. else {
  4443. return '<a href="' + url + '">' +
  4444. '<span class="slide-number-a">'+ a +'</span>' +
  4445. '</a>';
  4446. }
  4447. }
  4448. /**
  4449. * Updates the state of all control/navigation arrows.
  4450. */
  4451. function updateControls() {
  4452. var routes = availableRoutes();
  4453. var fragments = availableFragments();
  4454. // Remove the 'enabled' class from all directions
  4455. dom.controlsLeft.concat( dom.controlsRight )
  4456. .concat( dom.controlsUp )
  4457. .concat( dom.controlsDown )
  4458. .concat( dom.controlsPrev )
  4459. .concat( dom.controlsNext ).forEach( function( node ) {
  4460. node.classList.remove( 'enabled' );
  4461. node.classList.remove( 'fragmented' );
  4462. // Set 'disabled' attribute on all directions
  4463. node.setAttribute( 'disabled', 'disabled' );
  4464. } );
  4465. // Add the 'enabled' class to the available routes; remove 'disabled' attribute to enable buttons
  4466. if( routes.left ) dom.controlsLeft.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4467. if( routes.right ) dom.controlsRight.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4468. if( routes.up ) dom.controlsUp.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4469. if( routes.down ) dom.controlsDown.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4470. // Prev/next buttons
  4471. if( routes.left || routes.up ) dom.controlsPrev.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4472. if( routes.right || routes.down ) dom.controlsNext.forEach( function( el ) { el.classList.add( 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4473. // Highlight fragment directions
  4474. if( currentSlide ) {
  4475. // Always apply fragment decorator to prev/next buttons
  4476. if( fragments.prev ) dom.controlsPrev.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4477. if( fragments.next ) dom.controlsNext.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4478. // Apply fragment decorators to directional buttons based on
  4479. // what slide axis they are in
  4480. if( isVerticalSlide( currentSlide ) ) {
  4481. if( fragments.prev ) dom.controlsUp.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4482. if( fragments.next ) dom.controlsDown.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4483. }
  4484. else {
  4485. if( fragments.prev ) dom.controlsLeft.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4486. if( fragments.next ) dom.controlsRight.forEach( function( el ) { el.classList.add( 'fragmented', 'enabled' ); el.removeAttribute( 'disabled' ); } );
  4487. }
  4488. }
  4489. if( config.controlsTutorial ) {
  4490. // Highlight control arrows with an animation to ensure
  4491. // that the viewer knows how to navigate
  4492. if( !hasNavigatedDown && routes.down ) {
  4493. dom.controlsDownArrow.classList.add( 'highlight' );
  4494. }
  4495. else {
  4496. dom.controlsDownArrow.classList.remove( 'highlight' );
  4497. if( !hasNavigatedRight && routes.right && indexv === 0 ) {
  4498. dom.controlsRightArrow.classList.add( 'highlight' );
  4499. }
  4500. else {
  4501. dom.controlsRightArrow.classList.remove( 'highlight' );
  4502. }
  4503. }
  4504. }
  4505. }
  4506. /**
  4507. * Updates the background elements to reflect the current
  4508. * slide.
  4509. *
  4510. * @param {boolean} includeAll If true, the backgrounds of
  4511. * all vertical slides (not just the present) will be updated.
  4512. */
  4513. function updateBackground( includeAll ) {
  4514. var currentBackground = null;
  4515. // Reverse past/future classes when in RTL mode
  4516. var horizontalPast = config.rtl ? 'future' : 'past',
  4517. horizontalFuture = config.rtl ? 'past' : 'future';
  4518. // Update the classes of all backgrounds to match the
  4519. // states of their slides (past/present/future)
  4520. toArray( dom.background.childNodes ).forEach( function( backgroundh, h ) {
  4521. backgroundh.classList.remove( 'past' );
  4522. backgroundh.classList.remove( 'present' );
  4523. backgroundh.classList.remove( 'future' );
  4524. if( h < indexh ) {
  4525. backgroundh.classList.add( horizontalPast );
  4526. }
  4527. else if ( h > indexh ) {
  4528. backgroundh.classList.add( horizontalFuture );
  4529. }
  4530. else {
  4531. backgroundh.classList.add( 'present' );
  4532. // Store a reference to the current background element
  4533. currentBackground = backgroundh;
  4534. }
  4535. if( includeAll || h === indexh ) {
  4536. toArray( backgroundh.querySelectorAll( '.slide-background' ) ).forEach( function( backgroundv, v ) {
  4537. backgroundv.classList.remove( 'past' );
  4538. backgroundv.classList.remove( 'present' );
  4539. backgroundv.classList.remove( 'future' );
  4540. if( v < indexv ) {
  4541. backgroundv.classList.add( 'past' );
  4542. }
  4543. else if ( v > indexv ) {
  4544. backgroundv.classList.add( 'future' );
  4545. }
  4546. else {
  4547. backgroundv.classList.add( 'present' );
  4548. // Only if this is the present horizontal and vertical slide
  4549. if( h === indexh ) currentBackground = backgroundv;
  4550. }
  4551. } );
  4552. }
  4553. } );
  4554. // Stop content inside of previous backgrounds
  4555. if( previousBackground ) {
  4556. stopEmbeddedContent( previousBackground );
  4557. }
  4558. // Start content in the current background
  4559. if( currentBackground ) {
  4560. startEmbeddedContent( currentBackground );
  4561. var currentBackgroundContent = currentBackground.querySelector( '.slide-background-content' );
  4562. if( currentBackgroundContent ) {
  4563. var backgroundImageURL = currentBackgroundContent.style.backgroundImage || '';
  4564. // Restart GIFs (doesn't work in Firefox)
  4565. if( /\.gif/i.test( backgroundImageURL ) ) {
  4566. currentBackgroundContent.style.backgroundImage = '';
  4567. window.getComputedStyle( currentBackgroundContent ).opacity;
  4568. currentBackgroundContent.style.backgroundImage = backgroundImageURL;
  4569. }
  4570. }
  4571. // Don't transition between identical backgrounds. This
  4572. // prevents unwanted flicker.
  4573. var previousBackgroundHash = previousBackground ? previousBackground.getAttribute( 'data-background-hash' ) : null;
  4574. var currentBackgroundHash = currentBackground.getAttribute( 'data-background-hash' );
  4575. if( currentBackgroundHash && currentBackgroundHash === previousBackgroundHash && currentBackground !== previousBackground ) {
  4576. dom.background.classList.add( 'no-transition' );
  4577. }
  4578. previousBackground = currentBackground;
  4579. }
  4580. // If there's a background brightness flag for this slide,
  4581. // bubble it to the .reveal container
  4582. if( currentSlide ) {
  4583. [ 'has-light-background', 'has-dark-background' ].forEach( function( classToBubble ) {
  4584. if( currentSlide.classList.contains( classToBubble ) ) {
  4585. dom.wrapper.classList.add( classToBubble );
  4586. }
  4587. else {
  4588. dom.wrapper.classList.remove( classToBubble );
  4589. }
  4590. } );
  4591. }
  4592. // Allow the first background to apply without transition
  4593. setTimeout( function() {
  4594. dom.background.classList.remove( 'no-transition' );
  4595. }, 1 );
  4596. }
  4597. /**
  4598. * Updates the position of the parallax background based
  4599. * on the current slide index.
  4600. */
  4601. function updateParallax() {
  4602. if( config.parallaxBackgroundImage ) {
  4603. var horizontalSlides = dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ),
  4604. verticalSlides = dom.wrapper.querySelectorAll( VERTICAL_SLIDES_SELECTOR );
  4605. var backgroundSize = dom.background.style.backgroundSize.split( ' ' ),
  4606. backgroundWidth, backgroundHeight;
  4607. if( backgroundSize.length === 1 ) {
  4608. backgroundWidth = backgroundHeight = parseInt( backgroundSize[0], 10 );
  4609. }
  4610. else {
  4611. backgroundWidth = parseInt( backgroundSize[0], 10 );
  4612. backgroundHeight = parseInt( backgroundSize[1], 10 );
  4613. }
  4614. var slideWidth = dom.background.offsetWidth,
  4615. horizontalSlideCount = horizontalSlides.length,
  4616. horizontalOffsetMultiplier,
  4617. horizontalOffset;
  4618. if( typeof config.parallaxBackgroundHorizontal === 'number' ) {
  4619. horizontalOffsetMultiplier = config.parallaxBackgroundHorizontal;
  4620. }
  4621. else {
  4622. horizontalOffsetMultiplier = horizontalSlideCount > 1 ? ( backgroundWidth - slideWidth ) / ( horizontalSlideCount-1 ) : 0;
  4623. }
  4624. horizontalOffset = horizontalOffsetMultiplier * indexh * -1;
  4625. var slideHeight = dom.background.offsetHeight,
  4626. verticalSlideCount = verticalSlides.length,
  4627. verticalOffsetMultiplier,
  4628. verticalOffset;
  4629. if( typeof config.parallaxBackgroundVertical === 'number' ) {
  4630. verticalOffsetMultiplier = config.parallaxBackgroundVertical;
  4631. }
  4632. else {
  4633. verticalOffsetMultiplier = ( backgroundHeight - slideHeight ) / ( verticalSlideCount-1 );
  4634. }
  4635. verticalOffset = verticalSlideCount > 0 ? verticalOffsetMultiplier * indexv : 0;
  4636. dom.background.style.backgroundPosition = horizontalOffset + 'px ' + -verticalOffset + 'px';
  4637. }
  4638. }
  4639. /**
  4640. * Should the given element be preloaded?
  4641. * Decides based on local element attributes and global config.
  4642. *
  4643. * @param {HTMLElement} element
  4644. */
  4645. function shouldPreload( element ) {
  4646. // Prefer an explicit global preload setting
  4647. var preload = config.preloadIframes;
  4648. // If no global setting is available, fall back on the element's
  4649. // own preload setting
  4650. if( typeof preload !== 'boolean' ) {
  4651. preload = element.hasAttribute( 'data-preload' );
  4652. }
  4653. return preload;
  4654. }
  4655. /**
  4656. * Called when the given slide is within the configured view
  4657. * distance. Shows the slide element and loads any content
  4658. * that is set to load lazily (data-src).
  4659. *
  4660. * @param {HTMLElement} slide Slide to show
  4661. */
  4662. function loadSlide( slide, options ) {
  4663. options = options || {};
  4664. // Show the slide element
  4665. slide.style.display = config.display;
  4666. // Media elements with data-src attributes
  4667. toArray( slide.querySelectorAll( 'img[data-src], video[data-src], audio[data-src], iframe[data-src]' ) ).forEach( function( element ) {
  4668. if( element.tagName !== 'IFRAME' || shouldPreload( element ) ) {
  4669. element.setAttribute( 'src', element.getAttribute( 'data-src' ) );
  4670. element.setAttribute( 'data-lazy-loaded', '' );
  4671. element.removeAttribute( 'data-src' );
  4672. }
  4673. } );
  4674. // Media elements with <source> children
  4675. toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( media ) {
  4676. var sources = 0;
  4677. toArray( media.querySelectorAll( 'source[data-src]' ) ).forEach( function( source ) {
  4678. source.setAttribute( 'src', source.getAttribute( 'data-src' ) );
  4679. source.removeAttribute( 'data-src' );
  4680. source.setAttribute( 'data-lazy-loaded', '' );
  4681. sources += 1;
  4682. } );
  4683. // If we rewrote sources for this video/audio element, we need
  4684. // to manually tell it to load from its new origin
  4685. if( sources > 0 ) {
  4686. media.load();
  4687. }
  4688. } );
  4689. // Show the corresponding background element
  4690. var background = slide.slideBackgroundElement;
  4691. if( background ) {
  4692. background.style.display = 'block';
  4693. var backgroundContent = slide.slideBackgroundContentElement;
  4694. // If the background contains media, load it
  4695. if( background.hasAttribute( 'data-loaded' ) === false ) {
  4696. background.setAttribute( 'data-loaded', 'true' );
  4697. var backgroundImage = slide.getAttribute( 'data-background-image' ),
  4698. backgroundVideo = slide.getAttribute( 'data-background-video' ),
  4699. backgroundVideoLoop = slide.hasAttribute( 'data-background-video-loop' ),
  4700. backgroundVideoMuted = slide.hasAttribute( 'data-background-video-muted' ),
  4701. backgroundIframe = slide.getAttribute( 'data-background-iframe' );
  4702. // Images
  4703. if( backgroundImage ) {
  4704. backgroundContent.style.backgroundImage = 'url('+ encodeURI( backgroundImage ) +')';
  4705. }
  4706. // Videos
  4707. else if ( backgroundVideo && !isSpeakerNotes() ) {
  4708. var video = document.createElement( 'video' );
  4709. if( backgroundVideoLoop ) {
  4710. video.setAttribute( 'loop', '' );
  4711. }
  4712. if( backgroundVideoMuted ) {
  4713. video.muted = true;
  4714. }
  4715. // Inline video playback works (at least in Mobile Safari) as
  4716. // long as the video is muted and the `playsinline` attribute is
  4717. // present
  4718. if( isMobileDevice ) {
  4719. video.muted = true;
  4720. video.autoplay = true;
  4721. video.setAttribute( 'playsinline', '' );
  4722. }
  4723. // Support comma separated lists of video sources
  4724. backgroundVideo.split( ',' ).forEach( function( source ) {
  4725. video.innerHTML += '<source src="'+ source +'">';
  4726. } );
  4727. backgroundContent.appendChild( video );
  4728. }
  4729. // Iframes
  4730. else if( backgroundIframe && options.excludeIframes !== true ) {
  4731. var iframe = document.createElement( 'iframe' );
  4732. iframe.setAttribute( 'allowfullscreen', '' );
  4733. iframe.setAttribute( 'mozallowfullscreen', '' );
  4734. iframe.setAttribute( 'webkitallowfullscreen', '' );
  4735. // Only load autoplaying content when the slide is shown to
  4736. // avoid having it play in the background
  4737. if( /autoplay=(1|true|yes)/gi.test( backgroundIframe ) ) {
  4738. iframe.setAttribute( 'data-src', backgroundIframe );
  4739. }
  4740. else {
  4741. iframe.setAttribute( 'src', backgroundIframe );
  4742. }
  4743. iframe.style.width = '100%';
  4744. iframe.style.height = '100%';
  4745. iframe.style.maxHeight = '100%';
  4746. iframe.style.maxWidth = '100%';
  4747. backgroundContent.appendChild( iframe );
  4748. }
  4749. }
  4750. }
  4751. }
  4752. /**
  4753. * Unloads and hides the given slide. This is called when the
  4754. * slide is moved outside of the configured view distance.
  4755. *
  4756. * @param {HTMLElement} slide
  4757. */
  4758. function unloadSlide( slide ) {
  4759. // Hide the slide element
  4760. slide.style.display = 'none';
  4761. // Hide the corresponding background element
  4762. var background = getSlideBackground( slide );
  4763. if( background ) {
  4764. background.style.display = 'none';
  4765. }
  4766. // Reset lazy-loaded media elements with src attributes
  4767. toArray( slide.querySelectorAll( 'video[data-lazy-loaded][src], audio[data-lazy-loaded][src], iframe[data-lazy-loaded][src]' ) ).forEach( function( element ) {
  4768. element.setAttribute( 'data-src', element.getAttribute( 'src' ) );
  4769. element.removeAttribute( 'src' );
  4770. } );
  4771. // Reset lazy-loaded media elements with <source> children
  4772. toArray( slide.querySelectorAll( 'video[data-lazy-loaded] source[src], audio source[src]' ) ).forEach( function( source ) {
  4773. source.setAttribute( 'data-src', source.getAttribute( 'src' ) );
  4774. source.removeAttribute( 'src' );
  4775. } );
  4776. }
  4777. /**
  4778. * Determine what available routes there are for navigation.
  4779. *
  4780. * @return {{left: boolean, right: boolean, up: boolean, down: boolean}}
  4781. */
  4782. function availableRoutes() {
  4783. var horizontalSlides = dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ),
  4784. verticalSlides = dom.wrapper.querySelectorAll( VERTICAL_SLIDES_SELECTOR );
  4785. var routes = {
  4786. left: indexh > 0,
  4787. right: indexh < horizontalSlides.length - 1,
  4788. up: indexv > 0,
  4789. down: indexv < verticalSlides.length - 1
  4790. };
  4791. // Looped presentations can always be navigated as long as
  4792. // there are slides available
  4793. if( config.loop ) {
  4794. if( horizontalSlides.length > 1 ) {
  4795. routes.left = true;
  4796. routes.right = true;
  4797. }
  4798. if( verticalSlides.length > 1 ) {
  4799. routes.up = true;
  4800. routes.down = true;
  4801. }
  4802. }
  4803. // Reverse horizontal controls for rtl
  4804. if( config.rtl ) {
  4805. var left = routes.left;
  4806. routes.left = routes.right;
  4807. routes.right = left;
  4808. }
  4809. return routes;
  4810. }
  4811. /**
  4812. * Returns an object describing the available fragment
  4813. * directions.
  4814. *
  4815. * @return {{prev: boolean, next: boolean}}
  4816. */
  4817. function availableFragments() {
  4818. if( currentSlide && config.fragments ) {
  4819. var fragments = currentSlide.querySelectorAll( '.fragment' );
  4820. var hiddenFragments = currentSlide.querySelectorAll( '.fragment:not(.visible)' );
  4821. return {
  4822. prev: fragments.length - hiddenFragments.length > 0,
  4823. next: !!hiddenFragments.length
  4824. };
  4825. }
  4826. else {
  4827. return { prev: false, next: false };
  4828. }
  4829. }
  4830. /**
  4831. * Enforces origin-specific format rules for embedded media.
  4832. */
  4833. function formatEmbeddedContent() {
  4834. var _appendParamToIframeSource = function( sourceAttribute, sourceURL, param ) {
  4835. toArray( dom.slides.querySelectorAll( 'iframe['+ sourceAttribute +'*="'+ sourceURL +'"]' ) ).forEach( function( el ) {
  4836. var src = el.getAttribute( sourceAttribute );
  4837. if( src && src.indexOf( param ) === -1 ) {
  4838. el.setAttribute( sourceAttribute, src + ( !/\?/.test( src ) ? '?' : '&' ) + param );
  4839. }
  4840. });
  4841. };
  4842. // YouTube frames must include "?enablejsapi=1"
  4843. _appendParamToIframeSource( 'src', 'youtube.com/embed/', 'enablejsapi=1' );
  4844. _appendParamToIframeSource( 'data-src', 'youtube.com/embed/', 'enablejsapi=1' );
  4845. // Vimeo frames must include "?api=1"
  4846. _appendParamToIframeSource( 'src', 'player.vimeo.com/', 'api=1' );
  4847. _appendParamToIframeSource( 'data-src', 'player.vimeo.com/', 'api=1' );
  4848. }
  4849. /**
  4850. * Start playback of any embedded content inside of
  4851. * the given element.
  4852. *
  4853. * @param {HTMLElement} element
  4854. */
  4855. function startEmbeddedContent( element ) {
  4856. if( element && !isSpeakerNotes() ) {
  4857. // Restart GIFs
  4858. toArray( element.querySelectorAll( 'img[src$=".gif"]' ) ).forEach( function( el ) {
  4859. // Setting the same unchanged source like this was confirmed
  4860. // to work in Chrome, FF & Safari
  4861. el.setAttribute( 'src', el.getAttribute( 'src' ) );
  4862. } );
  4863. // HTML5 media elements
  4864. toArray( element.querySelectorAll( 'video, audio' ) ).forEach( function( el ) {
  4865. if( closestParent( el, '.fragment' ) && !closestParent( el, '.fragment.visible' ) ) {
  4866. return;
  4867. }
  4868. // Prefer an explicit global autoplay setting
  4869. var autoplay = config.autoPlayMedia;
  4870. // If no global setting is available, fall back on the element's
  4871. // own autoplay setting
  4872. if( typeof autoplay !== 'boolean' ) {
  4873. autoplay = el.hasAttribute( 'data-autoplay' ) || !!closestParent( el, '.slide-background' );
  4874. }
  4875. if( autoplay && typeof el.play === 'function' ) {
  4876. // If the media is ready, start playback
  4877. if( el.readyState > 1 ) {
  4878. startEmbeddedMedia( { target: el } );
  4879. }
  4880. // Mobile devices never fire a loaded event so instead
  4881. // of waiting, we initiate playback
  4882. else if( isMobileDevice ) {
  4883. var promise = el.play();
  4884. // If autoplay does not work, ensure that the controls are visible so
  4885. // that the viewer can start the media on their own
  4886. if( promise && typeof promise.catch === 'function' && el.controls === false ) {
  4887. promise.catch( function() {
  4888. el.controls = true;
  4889. // Once the video does start playing, hide the controls again
  4890. el.addEventListener( 'play', function() {
  4891. el.controls = false;
  4892. } );
  4893. } );
  4894. }
  4895. }
  4896. // If the media isn't loaded, wait before playing
  4897. else {
  4898. el.removeEventListener( 'loadeddata', startEmbeddedMedia ); // remove first to avoid dupes
  4899. el.addEventListener( 'loadeddata', startEmbeddedMedia );
  4900. }
  4901. }
  4902. } );
  4903. // Normal iframes
  4904. toArray( element.querySelectorAll( 'iframe[src]' ) ).forEach( function( el ) {
  4905. if( closestParent( el, '.fragment' ) && !closestParent( el, '.fragment.visible' ) ) {
  4906. return;
  4907. }
  4908. startEmbeddedIframe( { target: el } );
  4909. } );
  4910. // Lazy loading iframes
  4911. toArray( element.querySelectorAll( 'iframe[data-src]' ) ).forEach( function( el ) {
  4912. if( closestParent( el, '.fragment' ) && !closestParent( el, '.fragment.visible' ) ) {
  4913. return;
  4914. }
  4915. if( el.getAttribute( 'src' ) !== el.getAttribute( 'data-src' ) ) {
  4916. el.removeEventListener( 'load', startEmbeddedIframe ); // remove first to avoid dupes
  4917. el.addEventListener( 'load', startEmbeddedIframe );
  4918. el.setAttribute( 'src', el.getAttribute( 'data-src' ) );
  4919. }
  4920. } );
  4921. }
  4922. }
  4923. /**
  4924. * Starts playing an embedded video/audio element after
  4925. * it has finished loading.
  4926. *
  4927. * @param {object} event
  4928. */
  4929. function startEmbeddedMedia( event ) {
  4930. var isAttachedToDOM = !!closestParent( event.target, 'html' ),
  4931. isVisible = !!closestParent( event.target, '.present' );
  4932. if( isAttachedToDOM && isVisible ) {
  4933. event.target.currentTime = 0;
  4934. event.target.play();
  4935. }
  4936. event.target.removeEventListener( 'loadeddata', startEmbeddedMedia );
  4937. }
  4938. /**
  4939. * "Starts" the content of an embedded iframe using the
  4940. * postMessage API.
  4941. *
  4942. * @param {object} event
  4943. */
  4944. function startEmbeddedIframe( event ) {
  4945. var iframe = event.target;
  4946. if( iframe && iframe.contentWindow ) {
  4947. var isAttachedToDOM = !!closestParent( event.target, 'html' ),
  4948. isVisible = !!closestParent( event.target, '.present' );
  4949. if( isAttachedToDOM && isVisible ) {
  4950. // Prefer an explicit global autoplay setting
  4951. var autoplay = config.autoPlayMedia;
  4952. // If no global setting is available, fall back on the element's
  4953. // own autoplay setting
  4954. if( typeof autoplay !== 'boolean' ) {
  4955. autoplay = iframe.hasAttribute( 'data-autoplay' ) || !!closestParent( iframe, '.slide-background' );
  4956. }
  4957. // YouTube postMessage API
  4958. if( /youtube\.com\/embed\//.test( iframe.getAttribute( 'src' ) ) && autoplay ) {
  4959. iframe.contentWindow.postMessage( '{"event":"command","func":"playVideo","args":""}', '*' );
  4960. }
  4961. // Vimeo postMessage API
  4962. else if( /player\.vimeo\.com\//.test( iframe.getAttribute( 'src' ) ) && autoplay ) {
  4963. iframe.contentWindow.postMessage( '{"method":"play"}', '*' );
  4964. }
  4965. // Generic postMessage API
  4966. else {
  4967. iframe.contentWindow.postMessage( 'slide:start', '*' );
  4968. }
  4969. }
  4970. }
  4971. }
  4972. /**
  4973. * Stop playback of any embedded content inside of
  4974. * the targeted slide.
  4975. *
  4976. * @param {HTMLElement} element
  4977. */
  4978. function stopEmbeddedContent( element, options ) {
  4979. options = extend( {
  4980. // Defaults
  4981. unloadIframes: true
  4982. }, options || {} );
  4983. if( element && element.parentNode ) {
  4984. // HTML5 media elements
  4985. toArray( element.querySelectorAll( 'video, audio' ) ).forEach( function( el ) {
  4986. if( !el.hasAttribute( 'data-ignore' ) && typeof el.pause === 'function' ) {
  4987. el.setAttribute('data-paused-by-reveal', '');
  4988. el.pause();
  4989. }
  4990. } );
  4991. // Generic postMessage API for non-lazy loaded iframes
  4992. toArray( element.querySelectorAll( 'iframe' ) ).forEach( function( el ) {
  4993. if( el.contentWindow ) el.contentWindow.postMessage( 'slide:stop', '*' );
  4994. el.removeEventListener( 'load', startEmbeddedIframe );
  4995. });
  4996. // YouTube postMessage API
  4997. toArray( element.querySelectorAll( 'iframe[src*="youtube.com/embed/"]' ) ).forEach( function( el ) {
  4998. if( !el.hasAttribute( 'data-ignore' ) && el.contentWindow && typeof el.contentWindow.postMessage === 'function' ) {
  4999. el.contentWindow.postMessage( '{"event":"command","func":"pauseVideo","args":""}', '*' );
  5000. }
  5001. });
  5002. // Vimeo postMessage API
  5003. toArray( element.querySelectorAll( 'iframe[src*="player.vimeo.com/"]' ) ).forEach( function( el ) {
  5004. if( !el.hasAttribute( 'data-ignore' ) && el.contentWindow && typeof el.contentWindow.postMessage === 'function' ) {
  5005. el.contentWindow.postMessage( '{"method":"pause"}', '*' );
  5006. }
  5007. });
  5008. if( options.unloadIframes === true ) {
  5009. // Unload lazy-loaded iframes
  5010. toArray( element.querySelectorAll( 'iframe[data-src]' ) ).forEach( function( el ) {
  5011. // Only removing the src doesn't actually unload the frame
  5012. // in all browsers (Firefox) so we set it to blank first
  5013. el.setAttribute( 'src', 'about:blank' );
  5014. el.removeAttribute( 'src' );
  5015. } );
  5016. }
  5017. }
  5018. }
  5019. /**
  5020. * Returns the number of past slides. This can be used as a global
  5021. * flattened index for slides.
  5022. *
  5023. * @return {number} Past slide count
  5024. */
  5025. function getSlidePastCount() {
  5026. var horizontalSlides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
  5027. // The number of past slides
  5028. var pastCount = 0;
  5029. // Step through all slides and count the past ones
  5030. mainLoop: for( var i = 0; i < horizontalSlides.length; i++ ) {
  5031. var horizontalSlide = horizontalSlides[i];
  5032. var verticalSlides = toArray( horizontalSlide.querySelectorAll( 'section' ) );
  5033. for( var j = 0; j < verticalSlides.length; j++ ) {
  5034. // Stop as soon as we arrive at the present
  5035. if( verticalSlides[j].classList.contains( 'present' ) ) {
  5036. break mainLoop;
  5037. }
  5038. pastCount++;
  5039. }
  5040. // Stop as soon as we arrive at the present
  5041. if( horizontalSlide.classList.contains( 'present' ) ) {
  5042. break;
  5043. }
  5044. // Don't count the wrapping section for vertical slides
  5045. if( horizontalSlide.classList.contains( 'stack' ) === false ) {
  5046. pastCount++;
  5047. }
  5048. }
  5049. return pastCount;
  5050. }
  5051. /**
  5052. * Returns a value ranging from 0-1 that represents
  5053. * how far into the presentation we have navigated.
  5054. *
  5055. * @return {number}
  5056. */
  5057. function getProgress() {
  5058. // The number of past and total slides
  5059. var totalCount = getTotalSlides();
  5060. var pastCount = getSlidePastCount();
  5061. if( currentSlide ) {
  5062. var allFragments = currentSlide.querySelectorAll( '.fragment' );
  5063. // If there are fragments in the current slide those should be
  5064. // accounted for in the progress.
  5065. if( allFragments.length > 0 ) {
  5066. var visibleFragments = currentSlide.querySelectorAll( '.fragment.visible' );
  5067. // This value represents how big a portion of the slide progress
  5068. // that is made up by its fragments (0-1)
  5069. var fragmentWeight = 0.9;
  5070. // Add fragment progress to the past slide count
  5071. pastCount += ( visibleFragments.length / allFragments.length ) * fragmentWeight;
  5072. }
  5073. }
  5074. return Math.min( pastCount / ( totalCount - 1 ), 1 );
  5075. }
  5076. /**
  5077. * Checks if this presentation is running inside of the
  5078. * speaker notes window.
  5079. *
  5080. * @return {boolean}
  5081. */
  5082. function isSpeakerNotes() {
  5083. return !!window.location.search.match( /receiver/gi );
  5084. }
  5085. /**
  5086. * Reads the current URL (hash) and navigates accordingly.
  5087. */
  5088. function readURL() {
  5089. var hash = window.location.hash;
  5090. // Attempt to parse the hash as either an index or name
  5091. var bits = hash.slice( 2 ).split( '/' ),
  5092. name = hash.replace( /#|\//gi, '' );
  5093. // If the first bit is not fully numeric and there is a name we
  5094. // can assume that this is a named link
  5095. if( !/^[0-9]*$/.test( bits[0] ) && name.length ) {
  5096. var element;
  5097. // Ensure the named link is a valid HTML ID attribute
  5098. try {
  5099. element = document.getElementById( decodeURIComponent( name ) );
  5100. }
  5101. catch ( error ) { }
  5102. // Ensure that we're not already on a slide with the same name
  5103. var isSameNameAsCurrentSlide = currentSlide ? currentSlide.getAttribute( 'id' ) === name : false;
  5104. if( element ) {
  5105. // If the slide exists and is not the current slide...
  5106. if ( !isSameNameAsCurrentSlide ) {
  5107. // ...find the position of the named slide and navigate to it
  5108. var indices = Reveal.getIndices(element);
  5109. slide(indices.h, indices.v);
  5110. }
  5111. }
  5112. // If the slide doesn't exist, navigate to the current slide
  5113. else {
  5114. slide( indexh || 0, indexv || 0 );
  5115. }
  5116. }
  5117. else {
  5118. var hashIndexBase = config.hashOneBasedIndex ? 1 : 0;
  5119. // Read the index components of the hash
  5120. var h = ( parseInt( bits[0], 10 ) - hashIndexBase ) || 0,
  5121. v = ( parseInt( bits[1], 10 ) - hashIndexBase ) || 0,
  5122. f;
  5123. if( config.fragmentInURL ) {
  5124. f = parseInt( bits[2], 10 );
  5125. if( isNaN( f ) ) {
  5126. f = undefined;
  5127. }
  5128. }
  5129. if( h !== indexh || v !== indexv || f !== undefined ) {
  5130. slide( h, v, f );
  5131. }
  5132. }
  5133. }
  5134. /**
  5135. * Updates the page URL (hash) to reflect the current
  5136. * state.
  5137. *
  5138. * @param {number} delay The time in ms to wait before
  5139. * writing the hash
  5140. */
  5141. function writeURL( delay ) {
  5142. // Make sure there's never more than one timeout running
  5143. clearTimeout( writeURLTimeout );
  5144. // If a delay is specified, timeout this call
  5145. if( typeof delay === 'number' ) {
  5146. writeURLTimeout = setTimeout( writeURL, delay );
  5147. }
  5148. else if( currentSlide ) {
  5149. // If we're configured to push to history OR the history
  5150. // API is not avaialble.
  5151. if( config.history || !window.history ) {
  5152. window.location.hash = locationHash();
  5153. }
  5154. // If we're configured to reflect the current slide in the
  5155. // URL without pushing to history.
  5156. else if( config.hash ) {
  5157. window.history.replaceState( null, null, '#' + locationHash() );
  5158. }
  5159. // If history and hash are both disabled, a hash may still
  5160. // be added to the URL by clicking on a href with a hash
  5161. // target. Counter this by always removing the hash.
  5162. else {
  5163. window.history.replaceState( null, null, window.location.pathname + window.location.search );
  5164. }
  5165. }
  5166. }
  5167. /**
  5168. * Retrieves the h/v location and fragment of the current,
  5169. * or specified, slide.
  5170. *
  5171. * @param {HTMLElement} [slide] If specified, the returned
  5172. * index will be for this slide rather than the currently
  5173. * active one
  5174. *
  5175. * @return {{h: number, v: number, f: number}}
  5176. */
  5177. function getIndices( slide ) {
  5178. // By default, return the current indices
  5179. var h = indexh,
  5180. v = indexv,
  5181. f;
  5182. // If a slide is specified, return the indices of that slide
  5183. if( slide ) {
  5184. var isVertical = isVerticalSlide( slide );
  5185. var slideh = isVertical ? slide.parentNode : slide;
  5186. // Select all horizontal slides
  5187. var horizontalSlides = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
  5188. // Now that we know which the horizontal slide is, get its index
  5189. h = Math.max( horizontalSlides.indexOf( slideh ), 0 );
  5190. // Assume we're not vertical
  5191. v = undefined;
  5192. // If this is a vertical slide, grab the vertical index
  5193. if( isVertical ) {
  5194. v = Math.max( toArray( slide.parentNode.querySelectorAll( 'section' ) ).indexOf( slide ), 0 );
  5195. }
  5196. }
  5197. if( !slide && currentSlide ) {
  5198. var hasFragments = currentSlide.querySelectorAll( '.fragment' ).length > 0;
  5199. if( hasFragments ) {
  5200. var currentFragment = currentSlide.querySelector( '.current-fragment' );
  5201. if( currentFragment && currentFragment.hasAttribute( 'data-fragment-index' ) ) {
  5202. f = parseInt( currentFragment.getAttribute( 'data-fragment-index' ), 10 );
  5203. }
  5204. else {
  5205. f = currentSlide.querySelectorAll( '.fragment.visible' ).length - 1;
  5206. }
  5207. }
  5208. }
  5209. return { h: h, v: v, f: f };
  5210. }
  5211. /**
  5212. * Retrieves all slides in this presentation.
  5213. */
  5214. function getSlides() {
  5215. return toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR + ':not(.stack)' ));
  5216. }
  5217. /**
  5218. * Returns an array of objects where each object represents the
  5219. * attributes on its respective slide.
  5220. */
  5221. function getSlidesAttributes() {
  5222. return getSlides().map( function( slide ) {
  5223. var attributes = {};
  5224. for( var i = 0; i < slide.attributes.length; i++ ) {
  5225. var attribute = slide.attributes[ i ];
  5226. attributes[ attribute.name ] = attribute.value;
  5227. }
  5228. return attributes;
  5229. } );
  5230. }
  5231. /**
  5232. * Retrieves the total number of slides in this presentation.
  5233. *
  5234. * @return {number}
  5235. */
  5236. function getTotalSlides() {
  5237. return getSlides().length;
  5238. }
  5239. /**
  5240. * Returns the slide element matching the specified index.
  5241. *
  5242. * @return {HTMLElement}
  5243. */
  5244. function getSlide( x, y ) {
  5245. var horizontalSlide = dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR )[ x ];
  5246. var verticalSlides = horizontalSlide && horizontalSlide.querySelectorAll( 'section' );
  5247. if( verticalSlides && verticalSlides.length && typeof y === 'number' ) {
  5248. return verticalSlides ? verticalSlides[ y ] : undefined;
  5249. }
  5250. return horizontalSlide;
  5251. }
  5252. /**
  5253. * Returns the background element for the given slide.
  5254. * All slides, even the ones with no background properties
  5255. * defined, have a background element so as long as the
  5256. * index is valid an element will be returned.
  5257. *
  5258. * @param {mixed} x Horizontal background index OR a slide
  5259. * HTML element
  5260. * @param {number} y Vertical background index
  5261. * @return {(HTMLElement[]|*)}
  5262. */
  5263. function getSlideBackground( x, y ) {
  5264. var slide = typeof x === 'number' ? getSlide( x, y ) : x;
  5265. if( slide ) {
  5266. return slide.slideBackgroundElement;
  5267. }
  5268. return undefined;
  5269. }
  5270. /**
  5271. * Retrieves the speaker notes from a slide. Notes can be
  5272. * defined in two ways:
  5273. * 1. As a data-notes attribute on the slide <section>
  5274. * 2. As an <aside class="notes"> inside of the slide
  5275. *
  5276. * @param {HTMLElement} [slide=currentSlide]
  5277. * @return {(string|null)}
  5278. */
  5279. function getSlideNotes( slide ) {
  5280. // Default to the current slide
  5281. slide = slide || currentSlide;
  5282. // Notes can be specified via the data-notes attribute...
  5283. if( slide.hasAttribute( 'data-notes' ) ) {
  5284. return slide.getAttribute( 'data-notes' );
  5285. }
  5286. // ... or using an <aside class="notes"> element
  5287. var notesElement = slide.querySelector( 'aside.notes' );
  5288. if( notesElement ) {
  5289. return notesElement.innerHTML;
  5290. }
  5291. return null;
  5292. }
  5293. /**
  5294. * Retrieves the current state of the presentation as
  5295. * an object. This state can then be restored at any
  5296. * time.
  5297. *
  5298. * @return {{indexh: number, indexv: number, indexf: number, paused: boolean, overview: boolean}}
  5299. */
  5300. function getState() {
  5301. var indices = getIndices();
  5302. return {
  5303. indexh: indices.h,
  5304. indexv: indices.v,
  5305. indexf: indices.f,
  5306. paused: isPaused(),
  5307. overview: isOverview()
  5308. };
  5309. }
  5310. /**
  5311. * Restores the presentation to the given state.
  5312. *
  5313. * @param {object} state As generated by getState()
  5314. * @see {@link getState} generates the parameter `state`
  5315. */
  5316. function setState( state ) {
  5317. if( typeof state === 'object' ) {
  5318. slide( deserialize( state.indexh ), deserialize( state.indexv ), deserialize( state.indexf ) );
  5319. var pausedFlag = deserialize( state.paused ),
  5320. overviewFlag = deserialize( state.overview );
  5321. if( typeof pausedFlag === 'boolean' && pausedFlag !== isPaused() ) {
  5322. togglePause( pausedFlag );
  5323. }
  5324. if( typeof overviewFlag === 'boolean' && overviewFlag !== isOverview() ) {
  5325. toggleOverview( overviewFlag );
  5326. }
  5327. }
  5328. }
  5329. /**
  5330. * Return a sorted fragments list, ordered by an increasing
  5331. * "data-fragment-index" attribute.
  5332. *
  5333. * Fragments will be revealed in the order that they are returned by
  5334. * this function, so you can use the index attributes to control the
  5335. * order of fragment appearance.
  5336. *
  5337. * To maintain a sensible default fragment order, fragments are presumed
  5338. * to be passed in document order. This function adds a "fragment-index"
  5339. * attribute to each node if such an attribute is not already present,
  5340. * and sets that attribute to an integer value which is the position of
  5341. * the fragment within the fragments list.
  5342. *
  5343. * @param {object[]|*} fragments
  5344. * @param {boolean} grouped If true the returned array will contain
  5345. * nested arrays for all fragments with the same index
  5346. * @return {object[]} sorted Sorted array of fragments
  5347. */
  5348. function sortFragments( fragments, grouped ) {
  5349. fragments = toArray( fragments );
  5350. var ordered = [],
  5351. unordered = [],
  5352. sorted = [];
  5353. // Group ordered and unordered elements
  5354. fragments.forEach( function( fragment, i ) {
  5355. if( fragment.hasAttribute( 'data-fragment-index' ) ) {
  5356. var index = parseInt( fragment.getAttribute( 'data-fragment-index' ), 10 );
  5357. if( !ordered[index] ) {
  5358. ordered[index] = [];
  5359. }
  5360. ordered[index].push( fragment );
  5361. }
  5362. else {
  5363. unordered.push( [ fragment ] );
  5364. }
  5365. } );
  5366. // Append fragments without explicit indices in their
  5367. // DOM order
  5368. ordered = ordered.concat( unordered );
  5369. // Manually count the index up per group to ensure there
  5370. // are no gaps
  5371. var index = 0;
  5372. // Push all fragments in their sorted order to an array,
  5373. // this flattens the groups
  5374. ordered.forEach( function( group ) {
  5375. group.forEach( function( fragment ) {
  5376. sorted.push( fragment );
  5377. fragment.setAttribute( 'data-fragment-index', index );
  5378. } );
  5379. index ++;
  5380. } );
  5381. return grouped === true ? ordered : sorted;
  5382. }
  5383. /**
  5384. * Refreshes the fragments on the current slide so that they
  5385. * have the appropriate classes (.visible + .current-fragment).
  5386. *
  5387. * @param {number} [index] The index of the current fragment
  5388. * @param {array} [fragments] Array containing all fragments
  5389. * in the current slide
  5390. *
  5391. * @return {{shown: array, hidden: array}}
  5392. */
  5393. function updateFragments( index, fragments ) {
  5394. var changedFragments = {
  5395. shown: [],
  5396. hidden: []
  5397. };
  5398. if( currentSlide && config.fragments ) {
  5399. fragments = fragments || sortFragments( currentSlide.querySelectorAll( '.fragment' ) );
  5400. if( fragments.length ) {
  5401. if( typeof index !== 'number' ) {
  5402. var currentFragment = sortFragments( currentSlide.querySelectorAll( '.fragment.visible' ) ).pop();
  5403. if( currentFragment ) {
  5404. index = parseInt( currentFragment.getAttribute( 'data-fragment-index' ) || 0, 10 );
  5405. }
  5406. }
  5407. toArray( fragments ).forEach( function( el, i ) {
  5408. if( el.hasAttribute( 'data-fragment-index' ) ) {
  5409. i = parseInt( el.getAttribute( 'data-fragment-index' ), 10 );
  5410. }
  5411. // Visible fragments
  5412. if( i <= index ) {
  5413. if( !el.classList.contains( 'visible' ) ) changedFragments.shown.push( el );
  5414. el.classList.add( 'visible' );
  5415. el.classList.remove( 'current-fragment' );
  5416. // Announce the fragments one by one to the Screen Reader
  5417. dom.statusDiv.textContent = getStatusText( el );
  5418. if( i === index ) {
  5419. el.classList.add( 'current-fragment' );
  5420. startEmbeddedContent( el );
  5421. }
  5422. }
  5423. // Hidden fragments
  5424. else {
  5425. if( el.classList.contains( 'visible' ) ) changedFragments.hidden.push( el );
  5426. el.classList.remove( 'visible' );
  5427. el.classList.remove( 'current-fragment' );
  5428. }
  5429. } );
  5430. }
  5431. }
  5432. return changedFragments;
  5433. }
  5434. /**
  5435. * Navigate to the specified slide fragment.
  5436. *
  5437. * @param {?number} index The index of the fragment that
  5438. * should be shown, -1 means all are invisible
  5439. * @param {number} offset Integer offset to apply to the
  5440. * fragment index
  5441. *
  5442. * @return {boolean} true if a change was made in any
  5443. * fragments visibility as part of this call
  5444. */
  5445. function navigateFragment( index, offset ) {
  5446. if( currentSlide && config.fragments ) {
  5447. var fragments = sortFragments( currentSlide.querySelectorAll( '.fragment' ) );
  5448. if( fragments.length ) {
  5449. // If no index is specified, find the current
  5450. if( typeof index !== 'number' ) {
  5451. var lastVisibleFragment = sortFragments( currentSlide.querySelectorAll( '.fragment.visible' ) ).pop();
  5452. if( lastVisibleFragment ) {
  5453. index = parseInt( lastVisibleFragment.getAttribute( 'data-fragment-index' ) || 0, 10 );
  5454. }
  5455. else {
  5456. index = -1;
  5457. }
  5458. }
  5459. // If an offset is specified, apply it to the index
  5460. if( typeof offset === 'number' ) {
  5461. index += offset;
  5462. }
  5463. var changedFragments = updateFragments( index, fragments );
  5464. if( changedFragments.hidden.length ) {
  5465. dispatchEvent( 'fragmenthidden', { fragment: changedFragments.hidden[0], fragments: changedFragments.hidden } );
  5466. }
  5467. if( changedFragments.shown.length ) {
  5468. dispatchEvent( 'fragmentshown', { fragment: changedFragments.shown[0], fragments: changedFragments.shown } );
  5469. }
  5470. updateControls();
  5471. updateProgress();
  5472. if( config.fragmentInURL ) {
  5473. writeURL();
  5474. }
  5475. return !!( changedFragments.shown.length || changedFragments.hidden.length );
  5476. }
  5477. }
  5478. return false;
  5479. }
  5480. /**
  5481. * Navigate to the next slide fragment.
  5482. *
  5483. * @return {boolean} true if there was a next fragment,
  5484. * false otherwise
  5485. */
  5486. function nextFragment() {
  5487. return navigateFragment( null, 1 );
  5488. }
  5489. /**
  5490. * Navigate to the previous slide fragment.
  5491. *
  5492. * @return {boolean} true if there was a previous fragment,
  5493. * false otherwise
  5494. */
  5495. function previousFragment() {
  5496. return navigateFragment( null, -1 );
  5497. }
  5498. /**
  5499. * Cues a new automated slide if enabled in the config.
  5500. */
  5501. function cueAutoSlide() {
  5502. cancelAutoSlide();
  5503. if( currentSlide && config.autoSlide !== false ) {
  5504. var fragment = currentSlide.querySelector( '.current-fragment' );
  5505. // When the slide first appears there is no "current" fragment so
  5506. // we look for a data-autoslide timing on the first fragment
  5507. if( !fragment ) fragment = currentSlide.querySelector( '.fragment' );
  5508. var fragmentAutoSlide = fragment ? fragment.getAttribute( 'data-autoslide' ) : null;
  5509. var parentAutoSlide = currentSlide.parentNode ? currentSlide.parentNode.getAttribute( 'data-autoslide' ) : null;
  5510. var slideAutoSlide = currentSlide.getAttribute( 'data-autoslide' );
  5511. // Pick value in the following priority order:
  5512. // 1. Current fragment's data-autoslide
  5513. // 2. Current slide's data-autoslide
  5514. // 3. Parent slide's data-autoslide
  5515. // 4. Global autoSlide setting
  5516. if( fragmentAutoSlide ) {
  5517. autoSlide = parseInt( fragmentAutoSlide, 10 );
  5518. }
  5519. else if( slideAutoSlide ) {
  5520. autoSlide = parseInt( slideAutoSlide, 10 );
  5521. }
  5522. else if( parentAutoSlide ) {
  5523. autoSlide = parseInt( parentAutoSlide, 10 );
  5524. }
  5525. else {
  5526. autoSlide = config.autoSlide;
  5527. }
  5528. // If there are media elements with data-autoplay,
  5529. // automatically set the autoSlide duration to the
  5530. // length of that media. Not applicable if the slide
  5531. // is divided up into fragments.
  5532. // playbackRate is accounted for in the duration.
  5533. if( currentSlide.querySelectorAll( '.fragment' ).length === 0 ) {
  5534. toArray( currentSlide.querySelectorAll( 'video, audio' ) ).forEach( function( el ) {
  5535. if( el.hasAttribute( 'data-autoplay' ) ) {
  5536. if( autoSlide && (el.duration * 1000 / el.playbackRate ) > autoSlide ) {
  5537. autoSlide = ( el.duration * 1000 / el.playbackRate ) + 1000;
  5538. }
  5539. }
  5540. } );
  5541. }
  5542. // Cue the next auto-slide if:
  5543. // - There is an autoSlide value
  5544. // - Auto-sliding isn't paused by the user
  5545. // - The presentation isn't paused
  5546. // - The overview isn't active
  5547. // - The presentation isn't over
  5548. if( autoSlide && !autoSlidePaused && !isPaused() && !isOverview() && ( !Reveal.isLastSlide() || availableFragments().next || config.loop === true ) ) {
  5549. autoSlideTimeout = setTimeout( function() {
  5550. typeof config.autoSlideMethod === 'function' ? config.autoSlideMethod() : navigateNext();
  5551. cueAutoSlide();
  5552. }, autoSlide );
  5553. autoSlideStartTime = Date.now();
  5554. }
  5555. if( autoSlidePlayer ) {
  5556. autoSlidePlayer.setPlaying( autoSlideTimeout !== -1 );
  5557. }
  5558. }
  5559. }
  5560. /**
  5561. * Cancels any ongoing request to auto-slide.
  5562. */
  5563. function cancelAutoSlide() {
  5564. clearTimeout( autoSlideTimeout );
  5565. autoSlideTimeout = -1;
  5566. }
  5567. function pauseAutoSlide() {
  5568. if( autoSlide && !autoSlidePaused ) {
  5569. autoSlidePaused = true;
  5570. dispatchEvent( 'autoslidepaused' );
  5571. clearTimeout( autoSlideTimeout );
  5572. if( autoSlidePlayer ) {
  5573. autoSlidePlayer.setPlaying( false );
  5574. }
  5575. }
  5576. }
  5577. function resumeAutoSlide() {
  5578. if( autoSlide && autoSlidePaused ) {
  5579. autoSlidePaused = false;
  5580. dispatchEvent( 'autoslideresumed' );
  5581. cueAutoSlide();
  5582. }
  5583. }
  5584. function navigateLeft() {
  5585. // Reverse for RTL
  5586. if( config.rtl ) {
  5587. if( ( isOverview() || nextFragment() === false ) && availableRoutes().left ) {
  5588. slide( indexh + 1, config.navigationMode === 'grid' ? indexv : undefined );
  5589. }
  5590. }
  5591. // Normal navigation
  5592. else if( ( isOverview() || previousFragment() === false ) && availableRoutes().left ) {
  5593. slide( indexh - 1, config.navigationMode === 'grid' ? indexv : undefined );
  5594. }
  5595. }
  5596. function navigateRight() {
  5597. hasNavigatedRight = true;
  5598. // Reverse for RTL
  5599. if( config.rtl ) {
  5600. if( ( isOverview() || previousFragment() === false ) && availableRoutes().right ) {
  5601. slide( indexh - 1, config.navigationMode === 'grid' ? indexv : undefined );
  5602. }
  5603. }
  5604. // Normal navigation
  5605. else if( ( isOverview() || nextFragment() === false ) && availableRoutes().right ) {
  5606. slide( indexh + 1, config.navigationMode === 'grid' ? indexv : undefined );
  5607. }
  5608. }
  5609. function navigateUp() {
  5610. // Prioritize hiding fragments
  5611. if( ( isOverview() || previousFragment() === false ) && availableRoutes().up ) {
  5612. slide( indexh, indexv - 1 );
  5613. }
  5614. }
  5615. function navigateDown() {
  5616. hasNavigatedDown = true;
  5617. // Prioritize revealing fragments
  5618. if( ( isOverview() || nextFragment() === false ) && availableRoutes().down ) {
  5619. slide( indexh, indexv + 1 );
  5620. }
  5621. }
  5622. /**
  5623. * Navigates backwards, prioritized in the following order:
  5624. * 1) Previous fragment
  5625. * 2) Previous vertical slide
  5626. * 3) Previous horizontal slide
  5627. */
  5628. function navigatePrev() {
  5629. // Prioritize revealing fragments
  5630. if( previousFragment() === false ) {
  5631. if( availableRoutes().up ) {
  5632. navigateUp();
  5633. }
  5634. else {
  5635. // Fetch the previous horizontal slide, if there is one
  5636. var previousSlide;
  5637. if( config.rtl ) {
  5638. previousSlide = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.future' ) ).pop();
  5639. }
  5640. else {
  5641. previousSlide = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.past' ) ).pop();
  5642. }
  5643. if( previousSlide ) {
  5644. var v = ( previousSlide.querySelectorAll( 'section' ).length - 1 ) || undefined;
  5645. var h = indexh - 1;
  5646. slide( h, v );
  5647. }
  5648. }
  5649. }
  5650. }
  5651. /**
  5652. * The reverse of #navigatePrev().
  5653. */
  5654. function navigateNext() {
  5655. hasNavigatedRight = true;
  5656. hasNavigatedDown = true;
  5657. // Prioritize revealing fragments
  5658. if( nextFragment() === false ) {
  5659. var routes = availableRoutes();
  5660. // When looping is enabled `routes.down` is always available
  5661. // so we need a separate check for when we've reached the
  5662. // end of a stack and should move horizontally
  5663. if( routes.down && routes.right && config.loop && Reveal.isLastVerticalSlide( currentSlide ) ) {
  5664. routes.down = false;
  5665. }
  5666. if( routes.down ) {
  5667. navigateDown();
  5668. }
  5669. else if( config.rtl ) {
  5670. navigateLeft();
  5671. }
  5672. else {
  5673. navigateRight();
  5674. }
  5675. }
  5676. }
  5677. /**
  5678. * Checks if the target element prevents the triggering of
  5679. * swipe navigation.
  5680. */
  5681. function isSwipePrevented( target ) {
  5682. while( target && typeof target.hasAttribute === 'function' ) {
  5683. if( target.hasAttribute( 'data-prevent-swipe' ) ) return true;
  5684. target = target.parentNode;
  5685. }
  5686. return false;
  5687. }
  5688. // --------------------------------------------------------------------//
  5689. // ----------------------------- EVENTS -------------------------------//
  5690. // --------------------------------------------------------------------//
  5691. /**
  5692. * Called by all event handlers that are based on user
  5693. * input.
  5694. *
  5695. * @param {object} [event]
  5696. */
  5697. function onUserInput( event ) {
  5698. if( config.autoSlideStoppable ) {
  5699. pauseAutoSlide();
  5700. }
  5701. }
  5702. /**
  5703. * Called whenever there is mouse input at the document level
  5704. * to determine if the cursor is active or not.
  5705. *
  5706. * @param {object} event
  5707. */
  5708. function onDocumentCursorActive( event ) {
  5709. showCursor();
  5710. clearTimeout( cursorInactiveTimeout );
  5711. cursorInactiveTimeout = setTimeout( hideCursor, config.hideCursorTime );
  5712. }
  5713. /**
  5714. * Handler for the document level 'keypress' event.
  5715. *
  5716. * @param {object} event
  5717. */
  5718. function onDocumentKeyPress( event ) {
  5719. // Check if the pressed key is question mark
  5720. if( event.shiftKey && event.charCode === 63 ) {
  5721. toggleHelp();
  5722. }
  5723. }
  5724. /**
  5725. * Handler for the document level 'keydown' event.
  5726. *
  5727. * @param {object} event
  5728. */
  5729. function onDocumentKeyDown( event ) {
  5730. // If there's a condition specified and it returns false,
  5731. // ignore this event
  5732. if( typeof config.keyboardCondition === 'function' && config.keyboardCondition(event) === false ) {
  5733. return true;
  5734. }
  5735. // Shorthand
  5736. var keyCode = event.keyCode;
  5737. // Remember if auto-sliding was paused so we can toggle it
  5738. var autoSlideWasPaused = autoSlidePaused;
  5739. onUserInput( event );
  5740. // Is there a focused element that could be using the keyboard?
  5741. var activeElementIsCE = document.activeElement && document.activeElement.contentEditable !== 'inherit';
  5742. var activeElementIsInput = document.activeElement && document.activeElement.tagName && /input|textarea/i.test( document.activeElement.tagName );
  5743. var activeElementIsNotes = document.activeElement && document.activeElement.className && /speaker-notes/i.test( document.activeElement.className);
  5744. // Whitelist specific modified + keycode combinations
  5745. var prevSlideShortcut = event.shiftKey && event.keyCode === 32;
  5746. var firstSlideShortcut = ( event.metaKey || event.ctrlKey ) && keyCode === 37;
  5747. var lastSlideShortcut = ( event.metaKey || event.ctrlKey ) && keyCode === 39;
  5748. // Prevent all other events when a modifier is pressed
  5749. var unusedModifier = !prevSlideShortcut && !firstSlideShortcut && !lastSlideShortcut &&
  5750. ( event.shiftKey || event.altKey || event.ctrlKey || event.metaKey );
  5751. // Disregard the event if there's a focused element or a
  5752. // keyboard modifier key is present
  5753. if( activeElementIsCE || activeElementIsInput || activeElementIsNotes || unusedModifier ) return;
  5754. // While paused only allow resume keyboard events; 'b', 'v', '.'
  5755. var resumeKeyCodes = [66,86,190,191];
  5756. var key;
  5757. // Custom key bindings for togglePause should be able to resume
  5758. if( typeof config.keyboard === 'object' ) {
  5759. for( key in config.keyboard ) {
  5760. if( config.keyboard[key] === 'togglePause' ) {
  5761. resumeKeyCodes.push( parseInt( key, 10 ) );
  5762. }
  5763. }
  5764. }
  5765. if( isPaused() && resumeKeyCodes.indexOf( keyCode ) === -1 ) {
  5766. return false;
  5767. }
  5768. var triggered = false;
  5769. // 1. User defined key bindings
  5770. if( typeof config.keyboard === 'object' ) {
  5771. for( key in config.keyboard ) {
  5772. // Check if this binding matches the pressed key
  5773. if( parseInt( key, 10 ) === keyCode ) {
  5774. var value = config.keyboard[ key ];
  5775. // Callback function
  5776. if( typeof value === 'function' ) {
  5777. value.apply( null, [ event ] );
  5778. }
  5779. // String shortcuts to reveal.js API
  5780. else if( typeof value === 'string' && typeof Reveal[ value ] === 'function' ) {
  5781. Reveal[ value ].call();
  5782. }
  5783. triggered = true;
  5784. }
  5785. }
  5786. }
  5787. // 2. Registered custom key bindings
  5788. if( triggered === false ) {
  5789. for( key in registeredKeyBindings ) {
  5790. // Check if this binding matches the pressed key
  5791. if( parseInt( key, 10 ) === keyCode ) {
  5792. var action = registeredKeyBindings[ key ].callback;
  5793. // Callback function
  5794. if( typeof action === 'function' ) {
  5795. action.apply( null, [ event ] );
  5796. }
  5797. // String shortcuts to reveal.js API
  5798. else if( typeof action === 'string' && typeof Reveal[ action ] === 'function' ) {
  5799. Reveal[ action ].call();
  5800. }
  5801. triggered = true;
  5802. }
  5803. }
  5804. }
  5805. // 3. System defined key bindings
  5806. if( triggered === false ) {
  5807. // Assume true and try to prove false
  5808. triggered = true;
  5809. // P, PAGE UP
  5810. if( keyCode === 80 || keyCode === 33 ) {
  5811. navigatePrev();
  5812. }
  5813. // N, PAGE DOWN
  5814. else if( keyCode === 78 || keyCode === 34 ) {
  5815. navigateNext();
  5816. }
  5817. // H, LEFT
  5818. else if( keyCode === 72 || keyCode === 37 ) {
  5819. if( firstSlideShortcut ) {
  5820. slide( 0 );
  5821. }
  5822. else if( !isOverview() && config.navigationMode === 'linear' ) {
  5823. navigatePrev();
  5824. }
  5825. else {
  5826. navigateLeft();
  5827. }
  5828. }
  5829. // L, RIGHT
  5830. else if( keyCode === 76 || keyCode === 39 ) {
  5831. if( lastSlideShortcut ) {
  5832. slide( Number.MAX_VALUE );
  5833. }
  5834. else if( !isOverview() && config.navigationMode === 'linear' ) {
  5835. navigateNext();
  5836. }
  5837. else {
  5838. navigateRight();
  5839. }
  5840. }
  5841. // K, UP
  5842. else if( keyCode === 75 || keyCode === 38 ) {
  5843. if( !isOverview() && config.navigationMode === 'linear' ) {
  5844. navigatePrev();
  5845. }
  5846. else {
  5847. navigateUp();
  5848. }
  5849. }
  5850. // J, DOWN
  5851. else if( keyCode === 74 || keyCode === 40 ) {
  5852. if( !isOverview() && config.navigationMode === 'linear' ) {
  5853. navigateNext();
  5854. }
  5855. else {
  5856. navigateDown();
  5857. }
  5858. }
  5859. // HOME
  5860. else if( keyCode === 36 ) {
  5861. slide( 0 );
  5862. }
  5863. // END
  5864. else if( keyCode === 35 ) {
  5865. slide( Number.MAX_VALUE );
  5866. }
  5867. // SPACE
  5868. else if( keyCode === 32 ) {
  5869. if( isOverview() ) {
  5870. deactivateOverview();
  5871. }
  5872. if( event.shiftKey ) {
  5873. navigatePrev();
  5874. }
  5875. else {
  5876. navigateNext();
  5877. }
  5878. }
  5879. // TWO-SPOT, SEMICOLON, B, V, PERIOD, LOGITECH PRESENTER TOOLS "BLACK SCREEN" BUTTON
  5880. else if( keyCode === 58 || keyCode === 59 || keyCode === 66 || keyCode === 86 || keyCode === 190 || keyCode === 191 ) {
  5881. togglePause();
  5882. }
  5883. // F
  5884. else if( keyCode === 70 ) {
  5885. enterFullscreen();
  5886. }
  5887. // A
  5888. else if( keyCode === 65 ) {
  5889. if ( config.autoSlideStoppable ) {
  5890. toggleAutoSlide( autoSlideWasPaused );
  5891. }
  5892. }
  5893. else {
  5894. triggered = false;
  5895. }
  5896. }
  5897. // If the input resulted in a triggered action we should prevent
  5898. // the browsers default behavior
  5899. if( triggered ) {
  5900. event.preventDefault && event.preventDefault();
  5901. }
  5902. // ESC or O key
  5903. else if ( ( keyCode === 27 || keyCode === 79 ) && features.transforms3d ) {
  5904. if( dom.overlay ) {
  5905. closeOverlay();
  5906. }
  5907. else {
  5908. toggleOverview();
  5909. }
  5910. event.preventDefault && event.preventDefault();
  5911. }
  5912. // If auto-sliding is enabled we need to cue up
  5913. // another timeout
  5914. cueAutoSlide();
  5915. }
  5916. /**
  5917. * Handler for the 'touchstart' event, enables support for
  5918. * swipe and pinch gestures.
  5919. *
  5920. * @param {object} event
  5921. */
  5922. function onTouchStart( event ) {
  5923. if( isSwipePrevented( event.target ) ) return true;
  5924. touch.startX = event.touches[0].clientX;
  5925. touch.startY = event.touches[0].clientY;
  5926. touch.startCount = event.touches.length;
  5927. }
  5928. /**
  5929. * Handler for the 'touchmove' event.
  5930. *
  5931. * @param {object} event
  5932. */
  5933. function onTouchMove( event ) {
  5934. if( isSwipePrevented( event.target ) ) return true;
  5935. // Each touch should only trigger one action
  5936. if( !touch.captured ) {
  5937. onUserInput( event );
  5938. var currentX = event.touches[0].clientX;
  5939. var currentY = event.touches[0].clientY;
  5940. // There was only one touch point, look for a swipe
  5941. if( event.touches.length === 1 && touch.startCount !== 2 ) {
  5942. var deltaX = currentX - touch.startX,
  5943. deltaY = currentY - touch.startY;
  5944. if( deltaX > touch.threshold && Math.abs( deltaX ) > Math.abs( deltaY ) ) {
  5945. touch.captured = true;
  5946. navigateLeft();
  5947. }
  5948. else if( deltaX < -touch.threshold && Math.abs( deltaX ) > Math.abs( deltaY ) ) {
  5949. touch.captured = true;
  5950. navigateRight();
  5951. }
  5952. else if( deltaY > touch.threshold ) {
  5953. touch.captured = true;
  5954. navigateUp();
  5955. }
  5956. else if( deltaY < -touch.threshold ) {
  5957. touch.captured = true;
  5958. navigateDown();
  5959. }
  5960. // If we're embedded, only block touch events if they have
  5961. // triggered an action
  5962. if( config.embedded ) {
  5963. if( touch.captured || isVerticalSlide( currentSlide ) ) {
  5964. event.preventDefault();
  5965. }
  5966. }
  5967. // Not embedded? Block them all to avoid needless tossing
  5968. // around of the viewport in iOS
  5969. else {
  5970. event.preventDefault();
  5971. }
  5972. }
  5973. }
  5974. // There's a bug with swiping on some Android devices unless
  5975. // the default action is always prevented
  5976. else if( UA.match( /android/gi ) ) {
  5977. event.preventDefault();
  5978. }
  5979. }
  5980. /**
  5981. * Handler for the 'touchend' event.
  5982. *
  5983. * @param {object} event
  5984. */
  5985. function onTouchEnd( event ) {
  5986. touch.captured = false;
  5987. }
  5988. /**
  5989. * Convert pointer down to touch start.
  5990. *
  5991. * @param {object} event
  5992. */
  5993. function onPointerDown( event ) {
  5994. if( event.pointerType === event.MSPOINTER_TYPE_TOUCH || event.pointerType === "touch" ) {
  5995. event.touches = [{ clientX: event.clientX, clientY: event.clientY }];
  5996. onTouchStart( event );
  5997. }
  5998. }
  5999. /**
  6000. * Convert pointer move to touch move.
  6001. *
  6002. * @param {object} event
  6003. */
  6004. function onPointerMove( event ) {
  6005. if( event.pointerType === event.MSPOINTER_TYPE_TOUCH || event.pointerType === "touch" ) {
  6006. event.touches = [{ clientX: event.clientX, clientY: event.clientY }];
  6007. onTouchMove( event );
  6008. }
  6009. }
  6010. /**
  6011. * Convert pointer up to touch end.
  6012. *
  6013. * @param {object} event
  6014. */
  6015. function onPointerUp( event ) {
  6016. if( event.pointerType === event.MSPOINTER_TYPE_TOUCH || event.pointerType === "touch" ) {
  6017. event.touches = [{ clientX: event.clientX, clientY: event.clientY }];
  6018. onTouchEnd( event );
  6019. }
  6020. }
  6021. /**
  6022. * Handles mouse wheel scrolling, throttled to avoid skipping
  6023. * multiple slides.
  6024. *
  6025. * @param {object} event
  6026. */
  6027. function onDocumentMouseScroll( event ) {
  6028. if( Date.now() - lastMouseWheelStep > 600 ) {
  6029. lastMouseWheelStep = Date.now();
  6030. var delta = event.detail || -event.wheelDelta;
  6031. if( delta > 0 ) {
  6032. navigateNext();
  6033. }
  6034. else if( delta < 0 ) {
  6035. navigatePrev();
  6036. }
  6037. }
  6038. }
  6039. /**
  6040. * Clicking on the progress bar results in a navigation to the
  6041. * closest approximate horizontal slide using this equation:
  6042. *
  6043. * ( clickX / presentationWidth ) * numberOfSlides
  6044. *
  6045. * @param {object} event
  6046. */
  6047. function onProgressClicked( event ) {
  6048. onUserInput( event );
  6049. event.preventDefault();
  6050. var slidesTotal = toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).length;
  6051. var slideIndex = Math.floor( ( event.clientX / dom.wrapper.offsetWidth ) * slidesTotal );
  6052. if( config.rtl ) {
  6053. slideIndex = slidesTotal - slideIndex;
  6054. }
  6055. slide( slideIndex );
  6056. }
  6057. /**
  6058. * Event handler for navigation control buttons.
  6059. */
  6060. function onNavigateLeftClicked( event ) { event.preventDefault(); onUserInput(); config.navigationMode === 'linear' ? navigatePrev() : navigateLeft(); }
  6061. function onNavigateRightClicked( event ) { event.preventDefault(); onUserInput(); config.navigationMode === 'linear' ? navigateNext() : navigateRight(); }
  6062. function onNavigateUpClicked( event ) { event.preventDefault(); onUserInput(); navigateUp(); }
  6063. function onNavigateDownClicked( event ) { event.preventDefault(); onUserInput(); navigateDown(); }
  6064. function onNavigatePrevClicked( event ) { event.preventDefault(); onUserInput(); navigatePrev(); }
  6065. function onNavigateNextClicked( event ) { event.preventDefault(); onUserInput(); navigateNext(); }
  6066. /**
  6067. * Handler for the window level 'hashchange' event.
  6068. *
  6069. * @param {object} [event]
  6070. */
  6071. function onWindowHashChange( event ) {
  6072. readURL();
  6073. }
  6074. /**
  6075. * Handler for the window level 'resize' event.
  6076. *
  6077. * @param {object} [event]
  6078. */
  6079. function onWindowResize( event ) {
  6080. layout();
  6081. }
  6082. /**
  6083. * Handle for the window level 'visibilitychange' event.
  6084. *
  6085. * @param {object} [event]
  6086. */
  6087. function onPageVisibilityChange( event ) {
  6088. var isHidden = document.webkitHidden ||
  6089. document.msHidden ||
  6090. document.hidden;
  6091. // If, after clicking a link or similar and we're coming back,
  6092. // focus the document.body to ensure we can use keyboard shortcuts
  6093. if( isHidden === false && document.activeElement !== document.body ) {
  6094. // Not all elements support .blur() - SVGs among them.
  6095. if( typeof document.activeElement.blur === 'function' ) {
  6096. document.activeElement.blur();
  6097. }
  6098. document.body.focus();
  6099. }
  6100. }
  6101. /**
  6102. * Invoked when a slide is and we're in the overview.
  6103. *
  6104. * @param {object} event
  6105. */
  6106. function onOverviewSlideClicked( event ) {
  6107. // TODO There's a bug here where the event listeners are not
  6108. // removed after deactivating the overview.
  6109. if( eventsAreBound && isOverview() ) {
  6110. event.preventDefault();
  6111. var element = event.target;
  6112. while( element && !element.nodeName.match( /section/gi ) ) {
  6113. element = element.parentNode;
  6114. }
  6115. if( element && !element.classList.contains( 'disabled' ) ) {
  6116. deactivateOverview();
  6117. if( element.nodeName.match( /section/gi ) ) {
  6118. var h = parseInt( element.getAttribute( 'data-index-h' ), 10 ),
  6119. v = parseInt( element.getAttribute( 'data-index-v' ), 10 );
  6120. slide( h, v );
  6121. }
  6122. }
  6123. }
  6124. }
  6125. /**
  6126. * Handles clicks on links that are set to preview in the
  6127. * iframe overlay.
  6128. *
  6129. * @param {object} event
  6130. */
  6131. function onPreviewLinkClicked( event ) {
  6132. if( event.currentTarget && event.currentTarget.hasAttribute( 'href' ) ) {
  6133. var url = event.currentTarget.getAttribute( 'href' );
  6134. if( url ) {
  6135. showPreview( url );
  6136. event.preventDefault();
  6137. }
  6138. }
  6139. }
  6140. /**
  6141. * Handles click on the auto-sliding controls element.
  6142. *
  6143. * @param {object} [event]
  6144. */
  6145. function onAutoSlidePlayerClick( event ) {
  6146. // Replay
  6147. if( Reveal.isLastSlide() && config.loop === false ) {
  6148. slide( 0, 0 );
  6149. resumeAutoSlide();
  6150. }
  6151. // Resume
  6152. else if( autoSlidePaused ) {
  6153. resumeAutoSlide();
  6154. }
  6155. // Pause
  6156. else {
  6157. pauseAutoSlide();
  6158. }
  6159. }
  6160. // --------------------------------------------------------------------//
  6161. // ------------------------ PLAYBACK COMPONENT ------------------------//
  6162. // --------------------------------------------------------------------//
  6163. /**
  6164. * Constructor for the playback component, which displays
  6165. * play/pause/progress controls.
  6166. *
  6167. * @param {HTMLElement} container The component will append
  6168. * itself to this
  6169. * @param {function} progressCheck A method which will be
  6170. * called frequently to get the current progress on a range
  6171. * of 0-1
  6172. */
  6173. function Playback( container, progressCheck ) {
  6174. // Cosmetics
  6175. this.diameter = 100;
  6176. this.diameter2 = this.diameter/2;
  6177. this.thickness = 6;
  6178. // Flags if we are currently playing
  6179. this.playing = false;
  6180. // Current progress on a 0-1 range
  6181. this.progress = 0;
  6182. // Used to loop the animation smoothly
  6183. this.progressOffset = 1;
  6184. this.container = container;
  6185. this.progressCheck = progressCheck;
  6186. this.canvas = document.createElement( 'canvas' );
  6187. this.canvas.className = 'playback';
  6188. this.canvas.width = this.diameter;
  6189. this.canvas.height = this.diameter;
  6190. this.canvas.style.width = this.diameter2 + 'px';
  6191. this.canvas.style.height = this.diameter2 + 'px';
  6192. this.context = this.canvas.getContext( '2d' );
  6193. this.container.appendChild( this.canvas );
  6194. this.render();
  6195. }
  6196. /**
  6197. * @param value
  6198. */
  6199. Playback.prototype.setPlaying = function( value ) {
  6200. var wasPlaying = this.playing;
  6201. this.playing = value;
  6202. // Start repainting if we weren't already
  6203. if( !wasPlaying && this.playing ) {
  6204. this.animate();
  6205. }
  6206. else {
  6207. this.render();
  6208. }
  6209. };
  6210. Playback.prototype.animate = function() {
  6211. var progressBefore = this.progress;
  6212. this.progress = this.progressCheck();
  6213. // When we loop, offset the progress so that it eases
  6214. // smoothly rather than immediately resetting
  6215. if( progressBefore > 0.8 && this.progress < 0.2 ) {
  6216. this.progressOffset = this.progress;
  6217. }
  6218. this.render();
  6219. if( this.playing ) {
  6220. features.requestAnimationFrameMethod.call( window, this.animate.bind( this ) );
  6221. }
  6222. };
  6223. /**
  6224. * Renders the current progress and playback state.
  6225. */
  6226. Playback.prototype.render = function() {
  6227. var progress = this.playing ? this.progress : 0,
  6228. radius = ( this.diameter2 ) - this.thickness,
  6229. x = this.diameter2,
  6230. y = this.diameter2,
  6231. iconSize = 28;
  6232. // Ease towards 1
  6233. this.progressOffset += ( 1 - this.progressOffset ) * 0.1;
  6234. var endAngle = ( - Math.PI / 2 ) + ( progress * ( Math.PI * 2 ) );
  6235. var startAngle = ( - Math.PI / 2 ) + ( this.progressOffset * ( Math.PI * 2 ) );
  6236. this.context.save();
  6237. this.context.clearRect( 0, 0, this.diameter, this.diameter );
  6238. // Solid background color
  6239. this.context.beginPath();
  6240. this.context.arc( x, y, radius + 4, 0, Math.PI * 2, false );
  6241. this.context.fillStyle = 'rgba( 0, 0, 0, 0.4 )';
  6242. this.context.fill();
  6243. // Draw progress track
  6244. this.context.beginPath();
  6245. this.context.arc( x, y, radius, 0, Math.PI * 2, false );
  6246. this.context.lineWidth = this.thickness;
  6247. this.context.strokeStyle = 'rgba( 255, 255, 255, 0.2 )';
  6248. this.context.stroke();
  6249. if( this.playing ) {
  6250. // Draw progress on top of track
  6251. this.context.beginPath();
  6252. this.context.arc( x, y, radius, startAngle, endAngle, false );
  6253. this.context.lineWidth = this.thickness;
  6254. this.context.strokeStyle = '#fff';
  6255. this.context.stroke();
  6256. }
  6257. this.context.translate( x - ( iconSize / 2 ), y - ( iconSize / 2 ) );
  6258. // Draw play/pause icons
  6259. if( this.playing ) {
  6260. this.context.fillStyle = '#fff';
  6261. this.context.fillRect( 0, 0, iconSize / 2 - 4, iconSize );
  6262. this.context.fillRect( iconSize / 2 + 4, 0, iconSize / 2 - 4, iconSize );
  6263. }
  6264. else {
  6265. this.context.beginPath();
  6266. this.context.translate( 4, 0 );
  6267. this.context.moveTo( 0, 0 );
  6268. this.context.lineTo( iconSize - 4, iconSize / 2 );
  6269. this.context.lineTo( 0, iconSize );
  6270. this.context.fillStyle = '#fff';
  6271. this.context.fill();
  6272. }
  6273. this.context.restore();
  6274. };
  6275. Playback.prototype.on = function( type, listener ) {
  6276. this.canvas.addEventListener( type, listener, false );
  6277. };
  6278. Playback.prototype.off = function( type, listener ) {
  6279. this.canvas.removeEventListener( type, listener, false );
  6280. };
  6281. Playback.prototype.destroy = function() {
  6282. this.playing = false;
  6283. if( this.canvas.parentNode ) {
  6284. this.container.removeChild( this.canvas );
  6285. }
  6286. };
  6287. // --------------------------------------------------------------------//
  6288. // ------------------------------- API --------------------------------//
  6289. // --------------------------------------------------------------------//
  6290. Reveal = {
  6291. VERSION: VERSION,
  6292. initialize: initialize,
  6293. configure: configure,
  6294. sync: sync,
  6295. syncSlide: syncSlide,
  6296. syncFragments: syncFragments,
  6297. // Navigation methods
  6298. slide: slide,
  6299. left: navigateLeft,
  6300. right: navigateRight,
  6301. up: navigateUp,
  6302. down: navigateDown,
  6303. prev: navigatePrev,
  6304. next: navigateNext,
  6305. // Fragment methods
  6306. navigateFragment: navigateFragment,
  6307. prevFragment: previousFragment,
  6308. nextFragment: nextFragment,
  6309. // Deprecated aliases
  6310. navigateTo: slide,
  6311. navigateLeft: navigateLeft,
  6312. navigateRight: navigateRight,
  6313. navigateUp: navigateUp,
  6314. navigateDown: navigateDown,
  6315. navigatePrev: navigatePrev,
  6316. navigateNext: navigateNext,
  6317. // Forces an update in slide layout
  6318. layout: layout,
  6319. // Randomizes the order of slides
  6320. shuffle: shuffle,
  6321. // Returns an object with the available routes as booleans (left/right/top/bottom)
  6322. availableRoutes: availableRoutes,
  6323. // Returns an object with the available fragments as booleans (prev/next)
  6324. availableFragments: availableFragments,
  6325. // Toggles a help overlay with keyboard shortcuts
  6326. toggleHelp: toggleHelp,
  6327. // Toggles the overview mode on/off
  6328. toggleOverview: toggleOverview,
  6329. // Toggles the "black screen" mode on/off
  6330. togglePause: togglePause,
  6331. // Toggles the auto slide mode on/off
  6332. toggleAutoSlide: toggleAutoSlide,
  6333. // State checks
  6334. isOverview: isOverview,
  6335. isPaused: isPaused,
  6336. isAutoSliding: isAutoSliding,
  6337. isSpeakerNotes: isSpeakerNotes,
  6338. // Slide preloading
  6339. loadSlide: loadSlide,
  6340. unloadSlide: unloadSlide,
  6341. // Adds or removes all internal event listeners (such as keyboard)
  6342. addEventListeners: addEventListeners,
  6343. removeEventListeners: removeEventListeners,
  6344. // Facility for persisting and restoring the presentation state
  6345. getState: getState,
  6346. setState: setState,
  6347. // Presentation progress
  6348. getSlidePastCount: getSlidePastCount,
  6349. // Presentation progress on range of 0-1
  6350. getProgress: getProgress,
  6351. // Returns the indices of the current, or specified, slide
  6352. getIndices: getIndices,
  6353. // Returns an Array of all slides
  6354. getSlides: getSlides,
  6355. // Returns an Array of objects representing the attributes on
  6356. // the slides
  6357. getSlidesAttributes: getSlidesAttributes,
  6358. // Returns the total number of slides
  6359. getTotalSlides: getTotalSlides,
  6360. // Returns the slide element at the specified index
  6361. getSlide: getSlide,
  6362. // Returns the slide background element at the specified index
  6363. getSlideBackground: getSlideBackground,
  6364. // Returns the speaker notes string for a slide, or null
  6365. getSlideNotes: getSlideNotes,
  6366. // Returns the previous slide element, may be null
  6367. getPreviousSlide: function() {
  6368. return previousSlide;
  6369. },
  6370. // Returns the current slide element
  6371. getCurrentSlide: function() {
  6372. return currentSlide;
  6373. },
  6374. // Returns the current scale of the presentation content
  6375. getScale: function() {
  6376. return scale;
  6377. },
  6378. // Returns the current configuration object
  6379. getConfig: function() {
  6380. return config;
  6381. },
  6382. // Helper method, retrieves query string as a key/value hash
  6383. getQueryHash: function() {
  6384. var query = {};
  6385. location.search.replace( /[A-Z0-9]+?=([\w\.%-]*)/gi, function(a) {
  6386. query[ a.split( '=' ).shift() ] = a.split( '=' ).pop();
  6387. } );
  6388. // Basic deserialization
  6389. for( var i in query ) {
  6390. var value = query[ i ];
  6391. query[ i ] = deserialize( unescape( value ) );
  6392. }
  6393. return query;
  6394. },
  6395. // Returns the top-level DOM element
  6396. getRevealElement: function() {
  6397. return dom.wrapper || document.querySelector( '.reveal' );
  6398. },
  6399. // Returns a hash with all registered plugins
  6400. getPlugins: function() {
  6401. return plugins;
  6402. },
  6403. // Returns true if we're currently on the first slide
  6404. isFirstSlide: function() {
  6405. return ( indexh === 0 && indexv === 0 );
  6406. },
  6407. // Returns true if we're currently on the last slide
  6408. isLastSlide: function() {
  6409. if( currentSlide ) {
  6410. // Does this slide have a next sibling?
  6411. if( currentSlide.nextElementSibling ) return false;
  6412. // If it's vertical, does its parent have a next sibling?
  6413. if( isVerticalSlide( currentSlide ) && currentSlide.parentNode.nextElementSibling ) return false;
  6414. return true;
  6415. }
  6416. return false;
  6417. },
  6418. // Returns true if we're on the last slide in the current
  6419. // vertical stack
  6420. isLastVerticalSlide: function() {
  6421. if( currentSlide && isVerticalSlide( currentSlide ) ) {
  6422. // Does this slide have a next sibling?
  6423. if( currentSlide.nextElementSibling ) return false;
  6424. return true;
  6425. }
  6426. return false;
  6427. },
  6428. // Checks if reveal.js has been loaded and is ready for use
  6429. isReady: function() {
  6430. return loaded;
  6431. },
  6432. // Forward event binding to the reveal DOM element
  6433. addEventListener: function( type, listener, useCapture ) {
  6434. if( 'addEventListener' in window ) {
  6435. Reveal.getRevealElement().addEventListener( type, listener, useCapture );
  6436. }
  6437. },
  6438. removeEventListener: function( type, listener, useCapture ) {
  6439. if( 'addEventListener' in window ) {
  6440. Reveal.getRevealElement().removeEventListener( type, listener, useCapture );
  6441. }
  6442. },
  6443. // Adds/removes a custom key binding
  6444. addKeyBinding: addKeyBinding,
  6445. removeKeyBinding: removeKeyBinding,
  6446. // API for registering and retrieving plugins
  6447. registerPlugin: registerPlugin,
  6448. hasPlugin: hasPlugin,
  6449. getPlugin: getPlugin,
  6450. // Programmatically triggers a keyboard event
  6451. triggerKey: function( keyCode ) {
  6452. onDocumentKeyDown( { keyCode: keyCode } );
  6453. },
  6454. // Registers a new shortcut to include in the help overlay
  6455. registerKeyboardShortcut: function( key, value ) {
  6456. keyboardShortcuts[key] = value;
  6457. }
  6458. };
  6459. return Reveal;
  6460. }));
  6461. Reveal.initialize();
  6462. </script>
  6463. </body>
  6464. </html>