Слайды на основе Reveal.js для презентации обучения детей в 2018-м году для конференции eKIDS в августе 2019-го
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

7979 строки
228KB

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