Слайды на основе 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.

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