Слайды на основе Reveal.js для презентации обучения детей в 2018-м году для конференции eKIDS в августе 2019-го
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

8131 lines
232KB

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