PageRenderTime 58ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/README.md

https://gitlab.com/jforge/reveal.js
Markdown | 1014 lines | 711 code | 303 blank | 0 comment | 0 complexity | 639637146669111fd5036b59a39593a4 MD5 | raw file
  1. # reveal.js [![Build Status](https://travis-ci.org/hakimel/reveal.js.svg?branch=master)](https://travis-ci.org/hakimel/reveal.js)
  2. A framework for easily creating beautiful presentations using HTML. [Check out the live demo](http://lab.hakim.se/reveal-js/).
  3. reveal.js comes with a broad range of features including [nested slides](https://github.com/hakimel/reveal.js#markup), [Markdown contents](https://github.com/hakimel/reveal.js#markdown), [PDF export](https://github.com/hakimel/reveal.js#pdf-export), [speaker notes](https://github.com/hakimel/reveal.js#speaker-notes) and a [JavaScript API](https://github.com/hakimel/reveal.js#api). It's best viewed in a modern browser but [fallbacks](https://github.com/hakimel/reveal.js/wiki/Browser-Support) are available to make sure your presentation can still be viewed elsewhere.
  4. #### More reading:
  5. - [Installation](#installation): Step-by-step instructions for getting reveal.js running on your computer.
  6. - [Changelog](https://github.com/hakimel/reveal.js/releases): Up-to-date version history.
  7. - [Examples](https://github.com/hakimel/reveal.js/wiki/Example-Presentations): Presentations created with reveal.js, add your own!
  8. - [Browser Support](https://github.com/hakimel/reveal.js/wiki/Browser-Support): Explanation of browser support and fallbacks.
  9. - [Plugins](https://github.com/hakimel/reveal.js/wiki/Plugins,-Tools-and-Hardware): A list of plugins that can be used to extend reveal.js.
  10. ## Online Editor
  11. Presentations are written using HTML or Markdown but there's also an online editor for those of you who prefer a graphical interface. Give it a try at [http://slides.com](http://slides.com).
  12. ## Instructions
  13. ### Markup
  14. Markup hierarchy needs to be ``<div class="reveal"> <div class="slides"> <section>`` where the ``<section>`` represents one slide and can be repeated indefinitely. If you place multiple ``<section>``'s inside of another ``<section>`` they will be shown as vertical slides. The first of the vertical slides is the "root" of the others (at the top), and it will be included in the horizontal sequence. For example:
  15. ```html
  16. <div class="reveal">
  17. <div class="slides">
  18. <section>Single Horizontal Slide</section>
  19. <section>
  20. <section>Vertical Slide 1</section>
  21. <section>Vertical Slide 2</section>
  22. </section>
  23. </div>
  24. </div>
  25. ```
  26. ### Markdown
  27. It's possible to write your slides using Markdown. To enable Markdown, add the ```data-markdown``` attribute to your ```<section>``` elements and wrap the contents in a ```<script type="text/template">``` like the example below.
  28. This is based on [data-markdown](https://gist.github.com/1343518) from [Paul Irish](https://github.com/paulirish) modified to use [marked](https://github.com/chjj/marked) to support [Github Flavoured Markdown](https://help.github.com/articles/github-flavored-markdown). Sensitive to indentation (avoid mixing tabs and spaces) and line breaks (avoid consecutive breaks).
  29. ```html
  30. <section data-markdown>
  31. <script type="text/template">
  32. ## Page title
  33. A paragraph with some text and a [link](http://hakim.se).
  34. </script>
  35. </section>
  36. ```
  37. #### External Markdown
  38. You can write your content as a separate file and have reveal.js load it at runtime. Note the separator arguments which determine how slides are delimited in the external file. The ```data-charset``` attribute is optional and specifies which charset to use when loading the external file.
  39. When used locally, this feature requires that reveal.js [runs from a local web server](#full-setup).
  40. ```html
  41. <section data-markdown="example.md"
  42. data-separator="^\n\n\n"
  43. data-separator-vertical="^\n\n"
  44. data-separator-notes="^Note:"
  45. data-charset="iso-8859-15">
  46. </section>
  47. ```
  48. #### Element Attributes
  49. Special syntax (in html comment) is available for adding attributes to Markdown elements. This is useful for fragments, amongst other things.
  50. ```html
  51. <section data-markdown>
  52. <script type="text/template">
  53. - Item 1 <!-- .element: class="fragment" data-fragment-index="2" -->
  54. - Item 2 <!-- .element: class="fragment" data-fragment-index="1" -->
  55. </script>
  56. </section>
  57. ```
  58. #### Slide Attributes
  59. Special syntax (in html comment) is available for adding attributes to the slide `<section>` elements generated by your Markdown.
  60. ```html
  61. <section data-markdown>
  62. <script type="text/template">
  63. <!-- .slide: data-background="#ff0000" -->
  64. Markdown content
  65. </script>
  66. </section>
  67. ```
  68. ### Configuration
  69. At the end of your page you need to initialize reveal by running the following code. Note that all config values are optional and will default as specified below.
  70. ```javascript
  71. Reveal.initialize({
  72. // Display controls in the bottom right corner
  73. controls: true,
  74. // Display a presentation progress bar
  75. progress: true,
  76. // Display the page number of the current slide
  77. slideNumber: false,
  78. // Push each slide change to the browser history
  79. history: false,
  80. // Enable keyboard shortcuts for navigation
  81. keyboard: true,
  82. // Enable the slide overview mode
  83. overview: true,
  84. // Vertical centering of slides
  85. center: true,
  86. // Enables touch navigation on devices with touch input
  87. touch: true,
  88. // Loop the presentation
  89. loop: false,
  90. // Change the presentation direction to be RTL
  91. rtl: false,
  92. // Turns fragments on and off globally
  93. fragments: true,
  94. // Flags if the presentation is running in an embedded mode,
  95. // i.e. contained within a limited portion of the screen
  96. embedded: false,
  97. // Flags if we should show a help overlay when the questionmark
  98. // key is pressed
  99. help: true,
  100. // Number of milliseconds between automatically proceeding to the
  101. // next slide, disabled when set to 0, this value can be overwritten
  102. // by using a data-autoslide attribute on your slides
  103. autoSlide: 0,
  104. // Stop auto-sliding after user input
  105. autoSlideStoppable: true,
  106. // Enable slide navigation via mouse wheel
  107. mouseWheel: false,
  108. // Hides the address bar on mobile devices
  109. hideAddressBar: true,
  110. // Opens links in an iframe preview overlay
  111. previewLinks: false,
  112. // Transition style
  113. transition: 'default', // none/fade/slide/convex/concave/zoom
  114. // Transition speed
  115. transitionSpeed: 'default', // default/fast/slow
  116. // Transition style for full page slide backgrounds
  117. backgroundTransition: 'default', // none/fade/slide/convex/concave/zoom
  118. // Number of slides away from the current that are visible
  119. viewDistance: 3,
  120. // Parallax background image
  121. parallaxBackgroundImage: '', // e.g. "'https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg'"
  122. // Parallax background size
  123. parallaxBackgroundSize: '' // CSS syntax, e.g. "2100px 900px"
  124. });
  125. ```
  126. The configuration can be updated after initialization using the ```configure``` method:
  127. ```javascript
  128. // Turn autoSlide off
  129. Reveal.configure({ autoSlide: 0 });
  130. // Start auto-sliding every 5s
  131. Reveal.configure({ autoSlide: 5000 });
  132. ```
  133. ### Dependencies
  134. Reveal.js doesn't _rely_ on any third party scripts to work but a few optional libraries are included by default. These libraries are loaded as dependencies in the order they appear, for example:
  135. ```javascript
  136. Reveal.initialize({
  137. dependencies: [
  138. // Cross-browser shim that fully implements classList - https://github.com/eligrey/classList.js/
  139. { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
  140. // Interpret Markdown in <section> elements
  141. { src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
  142. { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
  143. // Syntax highlight for <code> elements
  144. { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
  145. // Zoom in and out with Alt+click
  146. { src: 'plugin/zoom-js/zoom.js', async: true },
  147. // Speaker notes
  148. { src: 'plugin/notes/notes.js', async: true },
  149. // Remote control your reveal.js presentation using a touch device
  150. { src: 'plugin/remotes/remotes.js', async: true },
  151. // MathJax
  152. { src: 'plugin/math/math.js', async: true }
  153. ]
  154. });
  155. ```
  156. You can add your own extensions using the same syntax. The following properties are available for each dependency object:
  157. - **src**: Path to the script to load
  158. - **async**: [optional] Flags if the script should load after reveal.js has started, defaults to false
  159. - **callback**: [optional] Function to execute when the script has loaded
  160. - **condition**: [optional] Function which must return true for the script to be loaded
  161. ### Ready Event
  162. A 'ready' event is fired when reveal.js has loaded all non-async dependencies and is ready to start navigating. To check if reveal.js is already 'ready' you can call `Reveal.isReady()`.
  163. ```javascript
  164. Reveal.addEventListener( 'ready', function( event ) {
  165. // event.currentSlide, event.indexh, event.indexv
  166. } );
  167. ```
  168. ### Presentation Size
  169. All presentations have a normal size, that is the resolution at which they are authored. The framework will automatically scale presentations uniformly based on this size to ensure that everything fits on any given display or viewport.
  170. See below for a list of configuration options related to sizing, including default values:
  171. ```javascript
  172. Reveal.initialize({
  173. ...
  174. // The "normal" size of the presentation, aspect ratio will be preserved
  175. // when the presentation is scaled to fit different resolutions. Can be
  176. // specified using percentage units.
  177. width: 960,
  178. height: 700,
  179. // Factor of the display size that should remain empty around the content
  180. margin: 0.1,
  181. // Bounds for smallest/largest possible scale to apply to content
  182. minScale: 0.2,
  183. maxScale: 1.5
  184. });
  185. ```
  186. ### Auto-sliding
  187. Presentations can be configure to progress through slides automatically, without any user input. To enable this you will need to tell the framework how many milliseconds it should wait between slides:
  188. ```javascript
  189. // Slide every five seconds
  190. Reveal.configure({
  191. autoSlide: 5000
  192. });
  193. ```
  194. When this is turned on a control element will appear that enables users to pause and resume auto-sliding. Alternatively, sliding can be paused or resumed by pressing »a« on the keyboard. Sliding is paused automatically as soon as the user starts navigating. You can disable these controls by specifying ```autoSlideStoppable: false``` in your reveal.js config.
  195. You can also override the slide duration for individual slides and fragments by using the ```data-autoslide``` attribute:
  196. ```html
  197. <section data-autoslide="2000">
  198. <p>After 2 seconds the first fragment will be shown.</p>
  199. <p class="fragment" data-autoslide="10000">After 10 seconds the next fragment will be shown.</p>
  200. <p class="fragment">Now, the fragment is displayed for 2 seconds before the next slide is shown.</p>
  201. </section>
  202. ```
  203. Whenever the auto-slide mode is resumed or paused the ```autoslideresumed``` and ```autoslidepaused``` events are fired.
  204. ### Keyboard Bindings
  205. If you're unhappy with any of the default keyboard bindings you can override them using the ```keyboard``` config option:
  206. ```javascript
  207. Reveal.configure({
  208. keyboard: {
  209. 13: 'next', // go to the next slide when the ENTER key is pressed
  210. 27: function() {}, // do something custom when ESC is pressed
  211. 32: null // don't do anything when SPACE is pressed (i.e. disable a reveal.js default binding)
  212. }
  213. });
  214. ```
  215. ### Lazy Loading
  216. When working on presentation with a lot of media or iframe content it's important to load lazily. Lazy loading means that reveal.js will only load content for the few slides nearest to the current slide. The number of slides that are preloaded is determined by the `viewDistance` configuration option.
  217. To enable lazy loading all you need to do is change your "src" attributes to "data-src" as shown below. This is supported for image, video, audio and iframe elements.
  218. ```html
  219. <section>
  220. <img data-src="image.png">
  221. <iframe data-src="http://slides.com"></iframe>
  222. <video>
  223. <source data-src="video.webm" type="video/webm" />
  224. <source data-src="video.mp4" type="video/mp4" />
  225. </video>
  226. </section>
  227. ```
  228. ### API
  229. The ``Reveal`` object exposes a JavaScript API for controlling navigation and reading state:
  230. ```javascript
  231. // Navigation
  232. Reveal.slide( indexh, indexv, indexf );
  233. Reveal.left();
  234. Reveal.right();
  235. Reveal.up();
  236. Reveal.down();
  237. Reveal.prev();
  238. Reveal.next();
  239. Reveal.prevFragment();
  240. Reveal.nextFragment();
  241. // Toggle presentation states, optionally pass true/false to force on/off
  242. Reveal.toggleOverview();
  243. Reveal.togglePause();
  244. Reveal.toggleAutoSlide();
  245. // Change a config value at runtime
  246. Reveal.configure({ controls: true });
  247. // Returns the present configuration options
  248. Reveal.getConfig();
  249. // Fetch the current scale of the presentation
  250. Reveal.getScale();
  251. // Retrieves the previous and current slide elements
  252. Reveal.getPreviousSlide();
  253. Reveal.getCurrentSlide();
  254. Reveal.getIndices(); // { h: 0, v: 0 } }
  255. Reveal.getProgress(); // 0-1
  256. Reveal.getTotalSlides();
  257. // State checks
  258. Reveal.isFirstSlide();
  259. Reveal.isLastSlide();
  260. Reveal.isOverview();
  261. Reveal.isPaused();
  262. Reveal.isAutoSliding();
  263. ```
  264. ### Slide Changed Event
  265. A 'slidechanged' event is fired each time the slide is changed (regardless of state). The event object holds the index values of the current slide as well as a reference to the previous and current slide HTML nodes.
  266. Some libraries, like MathJax (see [#226](https://github.com/hakimel/reveal.js/issues/226#issuecomment-10261609)), get confused by the transforms and display states of slides. Often times, this can be fixed by calling their update or render function from this callback.
  267. ```javascript
  268. Reveal.addEventListener( 'slidechanged', function( event ) {
  269. // event.previousSlide, event.currentSlide, event.indexh, event.indexv
  270. } );
  271. ```
  272. ### Presentation State
  273. The presentation's current state can be fetched by using the `getState` method. A state object contains all of the information required to put the presentation back as it was when `getState` was first called. Sort of like a snapshot. It's a simple object that can easily be stringified and persisted or sent over the wire.
  274. ```javascript
  275. Reveal.slide( 1 );
  276. // we're on slide 1
  277. var state = Reveal.getState();
  278. Reveal.slide( 3 );
  279. // we're on slide 3
  280. Reveal.setState( state );
  281. // we're back on slide 1
  282. ```
  283. ### Slide States
  284. If you set ``data-state="somestate"`` on a slide ``<section>``, "somestate" will be applied as a class on the document element when that slide is opened. This allows you to apply broad style changes to the page based on the active slide.
  285. Furthermore you can also listen to these changes in state via JavaScript:
  286. ```javascript
  287. Reveal.addEventListener( 'somestate', function() {
  288. // TODO: Sprinkle magic
  289. }, false );
  290. ```
  291. ### Slide Backgrounds
  292. Slides are contained within a limited portion of the screen by default to allow them to fit any display and scale uniformly. You can apply full page backgrounds outside of the slide area by adding a ```data-background``` attribute to your ```<section>``` elements. Four different types of backgrounds are supported: color, image, video and iframe. Below are a few examples.
  293. ```html
  294. <section data-background="#ff0000">
  295. <h2>All CSS color formats are supported, like rgba() or hsl().</h2>
  296. </section>
  297. <section data-background="http://example.com/image.png">
  298. <h2>This slide will have a full-size background image.</h2>
  299. </section>
  300. <section data-background="http://example.com/image.png" data-background-size="100px" data-background-repeat="repeat">
  301. <h2>This background image will be sized to 100px and repeated.</h2>
  302. </section>
  303. <section data-background-video="https://s3.amazonaws.com/static.slid.es/site/homepage/v1/homepage-video-editor.mp4,https://s3.amazonaws.com/static.slid.es/site/homepage/v1/homepage-video-editor.webm">
  304. <h2>Video. Multiple sources can be defined using a comma separated list.</h2>
  305. </section>
  306. <section data-background-iframe="https://slides.com">
  307. <h2>Embeds a web page as a background. Note that the page won't be interactive.</h2>
  308. </section>
  309. ```
  310. Backgrounds transition using a fade animation by default. This can be changed to a linear sliding transition by passing ```backgroundTransition: 'slide'``` to the ```Reveal.initialize()``` call. Alternatively you can set ```data-background-transition``` on any section with a background to override that specific transition.
  311. ### Parallax Background
  312. If you want to use a parallax scrolling background, set the two following config properties when initializing reveal.js (the third one is optional).
  313. ```javascript
  314. Reveal.initialize({
  315. // Parallax background image
  316. parallaxBackgroundImage: '', // e.g. "https://s3.amazonaws.com/hakim-static/reveal-js/reveal-parallax-1.jpg"
  317. // Parallax background size
  318. parallaxBackgroundSize: '', // CSS syntax, e.g. "2100px 900px" - currently only pixels are supported (don't use % or auto)
  319. // This slide transition gives best results:
  320. transition: 'slide'
  321. });
  322. ```
  323. Make sure that the background size is much bigger than screen size to allow for some scrolling. [View example](http://lab.hakim.se/reveal-js/?parallaxBackgroundImage=https%3A%2F%2Fs3.amazonaws.com%2Fhakim-static%2Freveal-js%2Freveal-parallax-1.jpg&parallaxBackgroundSize=2100px%20900px).
  324. ### Slide Transitions
  325. The global presentation transition is set using the ```transition``` config value. You can override the global transition for a specific slide by using the ```data-transition``` attribute:
  326. ```html
  327. <section data-transition="zoom">
  328. <h2>This slide will override the presentation transition and zoom!</h2>
  329. </section>
  330. <section data-transition-speed="fast">
  331. <h2>Choose from three transition speeds: default, fast or slow!</h2>
  332. </section>
  333. ```
  334. Note that this does not work with the page and cube transitions.
  335. ### Internal links
  336. It's easy to link between slides. The first example below targets the index of another slide whereas the second targets a slide with an ID attribute (```<section id="some-slide">```):
  337. ```html
  338. <a href="#/2/2">Link</a>
  339. <a href="#/some-slide">Link</a>
  340. ```
  341. You can also add relative navigation links, similar to the built in reveal.js controls, by appending one of the following classes on any element. Note that each element is automatically given an ```enabled``` class when it's a valid navigation route based on the current slide.
  342. ```html
  343. <a href="#" class="navigate-left">
  344. <a href="#" class="navigate-right">
  345. <a href="#" class="navigate-up">
  346. <a href="#" class="navigate-down">
  347. <a href="#" class="navigate-prev"> <!-- Previous vertical or horizontal slide -->
  348. <a href="#" class="navigate-next"> <!-- Next vertical or horizontal slide -->
  349. ```
  350. ### Fragments
  351. Fragments are used to highlight individual elements on a slide. Every element with the class ```fragment``` will be stepped through before moving on to the next slide. Here's an example: http://lab.hakim.se/reveal-js/#/fragments
  352. The default fragment style is to start out invisible and fade in. This style can be changed by appending a different class to the fragment:
  353. ```html
  354. <section>
  355. <p class="fragment grow">grow</p>
  356. <p class="fragment shrink">shrink</p>
  357. <p class="fragment roll-in">roll-in</p>
  358. <p class="fragment fade-out">fade-out</p>
  359. <p class="fragment current-visible">visible only once</p>
  360. <p class="fragment highlight-current-blue">blue only once</p>
  361. <p class="fragment highlight-red">highlight-red</p>
  362. <p class="fragment highlight-green">highlight-green</p>
  363. <p class="fragment highlight-blue">highlight-blue</p>
  364. </section>
  365. ```
  366. Multiple fragments can be applied to the same element sequentially by wrapping it, this will fade in the text on the first step and fade it back out on the second.
  367. ```html
  368. <section>
  369. <span class="fragment fade-in">
  370. <span class="fragment fade-out">I'll fade in, then out</span>
  371. </span>
  372. </section>
  373. ```
  374. The display order of fragments can be controlled using the ```data-fragment-index``` attribute.
  375. ```html
  376. <section>
  377. <p class="fragment" data-fragment-index="3">Appears last</p>
  378. <p class="fragment" data-fragment-index="1">Appears first</p>
  379. <p class="fragment" data-fragment-index="2">Appears second</p>
  380. </section>
  381. ```
  382. ### Fragment events
  383. When a slide fragment is either shown or hidden reveal.js will dispatch an event.
  384. Some libraries, like MathJax (see #505), get confused by the initially hidden fragment elements. Often times this can be fixed by calling their update or render function from this callback.
  385. ```javascript
  386. Reveal.addEventListener( 'fragmentshown', function( event ) {
  387. // event.fragment = the fragment DOM element
  388. } );
  389. Reveal.addEventListener( 'fragmenthidden', function( event ) {
  390. // event.fragment = the fragment DOM element
  391. } );
  392. ```
  393. ### Code syntax highlighting
  394. By default, Reveal is configured with [highlight.js](http://softwaremaniacs.org/soft/highlight/en/) for code syntax highlighting. Below is an example with clojure code that will be syntax highlighted. When the `data-trim` attribute is present surrounding whitespace is automatically removed.
  395. ```html
  396. <section>
  397. <pre><code data-trim>
  398. (def lazy-fib
  399. (concat
  400. [0 1]
  401. ((fn rfib [a b]
  402. (lazy-cons (+ a b) (rfib b (+ a b)))) 0 1)))
  403. </code></pre>
  404. </section>
  405. ```
  406. ### Slide number
  407. If you would like to display the page number of the current slide you can do so using the ```slideNumber``` configuration value.
  408. ```javascript
  409. Reveal.configure({ slideNumber: true });
  410. ```
  411. ### Overview mode
  412. Press "Esc" or "o" keys to toggle the overview mode on and off. While you're in this mode, you can still navigate between slides,
  413. as if you were at 1,000 feet above your presentation. The overview mode comes with a few API hooks:
  414. ```javascript
  415. Reveal.addEventListener( 'overviewshown', function( event ) { /* ... */ } );
  416. Reveal.addEventListener( 'overviewhidden', function( event ) { /* ... */ } );
  417. // Toggle the overview mode programmatically
  418. Reveal.toggleOverview();
  419. ```
  420. ### Fullscreen mode
  421. Just press »F« on your keyboard to show your presentation in fullscreen mode. Press the »ESC« key to exit fullscreen mode.
  422. ### Embedded media
  423. Embedded HTML5 `<video>`/`<audio>` and YouTube iframes are automatically paused when you navigate away from a slide. This can be disabled by decorating your element with a `data-ignore` attribute.
  424. Add `data-autoplay` to your media element if you want it to automatically start playing when the slide is shown:
  425. ```html
  426. <video data-autoplay src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"></video>
  427. ```
  428. Additionally the framework automatically pushes two [post messages](https://developer.mozilla.org/en-US/docs/Web/API/Window.postMessage) to all iframes, ```slide:start``` when the slide containing the iframe is made visible and ```slide:stop``` when it is hidden.
  429. ### Stretching elements
  430. Sometimes it's desirable to have an element, like an image or video, stretch to consume as much space as possible within a given slide. This can be done by adding the ```.stretch``` class to an element as seen below:
  431. ```html
  432. <section>
  433. <h2>This video will use up the remaining space on the slide</h2>
  434. <video class="stretch" src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"></video>
  435. </section>
  436. ```
  437. Limitations:
  438. - Only direct descendants of a slide section can be stretched
  439. - Only one descendant per slide section can be stretched
  440. ### postMessage API
  441. The framework has a built-in postMessage API that can be used when communicating with a presentation inside of another window. Here's an example showing how you'd make a reveal.js instance in the given window proceed to slide 2:
  442. ```javascript
  443. <window>.postMessage( JSON.stringify({ method: 'slide', args: [ 2 ] }), '*' );
  444. ```
  445. When reveal.js runs inside of an iframe it can optionally bubble all of its events to the parent. Bubbled events are stringified JSON with three fields: namespace, eventName and state. Here's how you subscribe to them from the parent window:
  446. ```javascript
  447. window.addEventListener( 'message', function( event ) {
  448. var data = JSON.parse( event.data );
  449. if( data.namespace === 'reveal' && data.eventName ='slidechanged' ) {
  450. // Slide changed, see data.state for slide number
  451. }
  452. } );
  453. ```
  454. This cross-window messaging can be toggled on or off using configuration flags.
  455. ```javascript
  456. Reveal.initialize({
  457. ...,
  458. // Exposes the reveal.js API through window.postMessage
  459. postMessage: true,
  460. // Dispatches all reveal.js events to the parent window through postMessage
  461. postMessageEvents: false
  462. });
  463. ```
  464. ## PDF Export
  465. Presentations can be exported to PDF via a special print stylesheet. This feature requires that you use [Google Chrome](http://google.com/chrome).
  466. Here's an example of an exported presentation that's been uploaded to SlideShare: http://www.slideshare.net/hakimel/revealjs-300.
  467. 1. Open your presentation with `print-pdf` included anywhere in the query string. This triggers the default index HTML to load the PDF print stylesheet ([css/print/pdf.css](https://github.com/hakimel/reveal.js/blob/master/css/print/pdf.css)). You can test this with [lab.hakim.se/reveal-js?print-pdf](http://lab.hakim.se/reveal-js?print-pdf).
  468. 2. Open the in-browser print dialog (CMD+P).
  469. 3. Change the **Destination** setting to **Save as PDF**.
  470. 4. Change the **Layout** to **Landscape**.
  471. 5. Change the **Margins** to **None**.
  472. 6. Click **Save**.
  473. ![Chrome Print Settings](https://s3.amazonaws.com/hakim-static/reveal-js/pdf-print-settings.png)
  474. ## Theming
  475. The framework comes with a few different themes included:
  476. - black: Black background, white text, blue links (default theme)
  477. - white: White background, black text, blue links
  478. - league: Gray background, white text, blue links (default theme for reveal.js < 3.0.0)
  479. - beige: Beige background, dark text, brown links
  480. - sky: Blue background, thin white text, blue links
  481. - night: Black background, thick white text, orange links
  482. - serif: Cappuccino background, gray text, brown links
  483. - simple: White background, black text, blue links
  484. - solarized: Cream-colored background, dark green text, blue links
  485. Each theme is available as a separate stylesheet. To change theme you will need to replace **black** below with your desired theme name in index.html:
  486. ```html
  487. <link rel="stylesheet" href="css/theme/black.css" id="theme">
  488. ```
  489. If you want to add a theme of your own see the instructions here: [/css/theme/README.md](https://github.com/hakimel/reveal.js/blob/master/css/theme/README.md).
  490. ## Speaker Notes
  491. reveal.js comes with a speaker notes plugin which can be used to present per-slide notes in a separate browser window. The notes window also gives you a preview of the next upcoming slide so it may be helpful even if you haven't written any notes. Press the 's' key on your keyboard to open the notes window.
  492. Notes are defined by appending an ```<aside>``` element to a slide as seen below. You can add the ```data-markdown``` attribute to the aside element if you prefer writing notes using Markdown.
  493. When used locally, this feature requires that reveal.js [runs from a local web server](#full-setup).
  494. ```html
  495. <section>
  496. <h2>Some Slide</h2>
  497. <aside class="notes">
  498. Oh hey, these are some notes. They'll be hidden in your presentation, but you can see them if you open the speaker notes window (hit 's' on your keyboard).
  499. </aside>
  500. </section>
  501. ```
  502. If you're using the external Markdown plugin, you can add notes with the help of a special delimiter:
  503. ```html
  504. <section data-markdown="example.md" data-separator="^\n\n\n" data-separator-vertical="^\n\n" data-separator-notes="^Note:"></section>
  505. # Title
  506. ## Sub-title
  507. Here is some content...
  508. Note:
  509. This will only display in the notes window.
  510. ```
  511. ## Server Side Speaker Notes
  512. In some cases it can be desirable to run notes on a separate device from the one you're presenting on. The Node.js-based notes plugin lets you do this using the same note definitions as its client side counterpart. Include the required scripts by adding the following dependencies:
  513. ```javascript
  514. Reveal.initialize({
  515. ...
  516. dependencies: [
  517. { src: 'socket.io/socket.io.js', async: true },
  518. { src: 'plugin/notes-server/client.js', async: true }
  519. ]
  520. });
  521. ```
  522. Then:
  523. 1. Install [Node.js](http://nodejs.org/)
  524. 2. Run ```npm install```
  525. 3. Run ```node plugin/notes-server```
  526. ## Multiplexing
  527. The multiplex plugin allows your audience to view the slides of the presentation you are controlling on their own phone, tablet or laptop. As the master presentation navigates the slides, all client presentations will update in real time. See a demo at [http://revealjs.jit.su/](http://revealjs.jit.su).
  528. The multiplex plugin needs the following 3 things to operate:
  529. 1. Master presentation that has control
  530. 2. Client presentations that follow the master
  531. 3. Socket.io server to broadcast events from the master to the clients
  532. More details:
  533. #### Master presentation
  534. Served from a static file server accessible (preferably) only to the presenter. This need only be on your (the presenter's) computer. (It's safer to run the master presentation from your own computer, so if the venue's Internet goes down it doesn't stop the show.) An example would be to execute the following commands in the directory of your master presentation:
  535. 1. ```npm install node-static```
  536. 2. ```static```
  537. If you want to use the speaker notes plugin with your master presentation then make sure you have the speaker notes plugin configured correctly along with the configuration shown below, then execute ```node plugin/notes-server``` in the directory of your master presentation. The configuration below will cause it to connect to the socket.io server as a master, as well as launch your speaker-notes/static-file server.
  538. You can then access your master presentation at ```http://localhost:1947```
  539. Example configuration:
  540. ```javascript
  541. Reveal.initialize({
  542. // other options...
  543. multiplex: {
  544. // Example values. To generate your own, see the socket.io server instructions.
  545. secret: '13652805320794272084', // Obtained from the socket.io server. Gives this (the master) control of the presentation
  546. id: '1ea875674b17ca76', // Obtained from socket.io server
  547. url: 'revealjs.jit.su:80' // Location of socket.io server
  548. },
  549. // Don't forget to add the dependencies
  550. dependencies: [
  551. { src: '//cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js', async: true },
  552. { src: 'plugin/multiplex/master.js', async: true },
  553. // and if you want speaker notes
  554. { src: 'plugin/notes-server/client.js', async: true }
  555. // other dependencies...
  556. ]
  557. });
  558. ```
  559. #### Client presentation
  560. Served from a publicly accessible static file server. Examples include: GitHub Pages, Amazon S3, Dreamhost, Akamai, etc. The more reliable, the better. Your audience can then access the client presentation via ```http://example.com/path/to/presentation/client/index.html```, with the configuration below causing them to connect to the socket.io server as clients.
  561. Example configuration:
  562. ```javascript
  563. Reveal.initialize({
  564. // other options...
  565. multiplex: {
  566. // Example values. To generate your own, see the socket.io server instructions.
  567. secret: null, // null so the clients do not have control of the master presentation
  568. id: '1ea875674b17ca76', // id, obtained from socket.io server
  569. url: 'revealjs.jit.su:80' // Location of socket.io server
  570. },
  571. // Don't forget to add the dependencies
  572. dependencies: [
  573. { src: '//cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js', async: true },
  574. { src: 'plugin/multiplex/client.js', async: true }
  575. // other dependencies...
  576. ]
  577. });
  578. ```
  579. #### Socket.io server
  580. Server that receives the slideChanged events from the master presentation and broadcasts them out to the connected client presentations. This needs to be publicly accessible. You can run your own socket.io server with the commands:
  581. 1. ```npm install```
  582. 2. ```node plugin/multiplex```
  583. Or you use the socket.io server at [http://revealjs.jit.su](http://revealjs.jit.su).
  584. You'll need to generate a unique secret and token pair for your master and client presentations. To do so, visit ```http://example.com/token```, where ```http://example.com``` is the location of your socket.io server. Or if you're going to use the socket.io server at [http://revealjs.jit.su](http://revealjs.jit.su), visit [http://revealjs.jit.su/token](http://revealjs.jit.su/token).
  585. You are very welcome to point your presentations at the Socket.io server running at [http://revealjs.jit.su](http://revealjs.jit.su), but availability and stability are not guaranteed. For anything mission critical I recommend you run your own server. It is simple to deploy to nodejitsu, heroku, your own environment, etc.
  586. ##### socket.io server as file static server
  587. The socket.io server can play the role of static file server for your client presentation, as in the example at [http://revealjs.jit.su](http://revealjs.jit.su). (Open [http://revealjs.jit.su](http://revealjs.jit.su) in two browsers. Navigate through the slides on one, and the other will update to match.)
  588. Example configuration:
  589. ```javascript
  590. Reveal.initialize({
  591. // other options...
  592. multiplex: {
  593. // Example values. To generate your own, see the socket.io server instructions.
  594. secret: null, // null so the clients do not have control of the master presentation
  595. id: '1ea875674b17ca76', // id, obtained from socket.io server
  596. url: 'example.com:80' // Location of your socket.io server
  597. },
  598. // Don't forget to add the dependencies
  599. dependencies: [
  600. { src: '//cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js', async: true },
  601. { src: 'plugin/multiplex/client.js', async: true }
  602. // other dependencies...
  603. ]
  604. ```
  605. It can also play the role of static file server for your master presentation and client presentations at the same time (as long as you don't want to use speaker notes). (Open [http://revealjs.jit.su](http://revealjs.jit.su) in two browsers. Navigate through the slides on one, and the other will update to match. Navigate through the slides on the second, and the first will update to match.) This is probably not desirable, because you don't want your audience to mess with your slides while you're presenting. ;)
  606. Example configuration:
  607. ```javascript
  608. Reveal.initialize({
  609. // other options...
  610. multiplex: {
  611. // Example values. To generate your own, see the socket.io server instructions.
  612. secret: '13652805320794272084', // Obtained from the socket.io server. Gives this (the master) control of the presentation
  613. id: '1ea875674b17ca76', // Obtained from socket.io server
  614. url: 'example.com:80' // Location of your socket.io server
  615. },
  616. // Don't forget to add the dependencies
  617. dependencies: [
  618. { src: '//cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js', async: true },
  619. { src: 'plugin/multiplex/master.js', async: true },
  620. { src: 'plugin/multiplex/client.js', async: true }
  621. // other dependencies...
  622. ]
  623. });
  624. ```
  625. ## Leap Motion
  626. The Leap Motion plugin lets you utilize your [Leap Motion](https://www.leapmotion.com/) device to control basic navigation of your presentation. The gestures currently supported are:
  627. ##### 1 to 2 fingers
  628. Pointer &mdash; Point to anything on screen. Move your finger past the device to expand the pointer.
  629. ##### 1 hand + 3 or more fingers (left/right/up/down)
  630. Navigate through your slides. See config options to invert movements.
  631. ##### 2 hands upwards
  632. Toggle the overview mode. Do it a second time to exit the overview.
  633. #### Config Options
  634. You can edit the following options:
  635. | Property | Default | Description
  636. | ----------------- |:-----------------:| :-------------
  637. | autoCenter | true | Center the pointer based on where you put your finger into the leap motions detection field.
  638. | gestureDelay | 500 | How long to delay between gestures in milliseconds.
  639. | naturalSwipe | true | Swipe as though you were touching a touch screen. Set to false to invert.
  640. | pointerColor | #00aaff | The color of the pointer.
  641. | pointerOpacity | 0.7 | The opacity of the pointer.
  642. | pointerSize | 15 | The minimum height and width of the pointer.
  643. | pointerTolerance | 120 | Bigger = slower pointer.
  644. Example configuration:
  645. ```js
  646. Reveal.initialize({
  647. // other options...
  648. leap: {
  649. naturalSwipe : false, // Invert swipe gestures
  650. pointerOpacity : 0.5, // Set pointer opacity to 0.5
  651. pointerColor : '#d80000' // Red pointer
  652. },
  653. dependencies: [
  654. { src: 'plugin/leap/leap.js', async: true }
  655. ]
  656. });
  657. ```
  658. ## MathJax
  659. If you want to display math equations in your presentation you can easily do so by including this plugin. The plugin is a very thin wrapper around the [MathJax](http://www.mathjax.org/) library. To use it you'll need to include it as a reveal.js dependency, [find our more about dependencies here](#dependencies).
  660. The plugin defaults to using [LaTeX](http://en.wikipedia.org/wiki/LaTeX) but that can be adjusted through the ```math``` configuration object. Note that MathJax is loaded from a remote server. If you want to use it offline you'll need to download a copy of the library and adjust the ```mathjax``` configuration value.
  661. Below is an example of how the plugin can be configured. If you don't intend to change these values you do not need to include the ```math``` config object at all.
  662. ```js
  663. Reveal.initialize({
  664. // other options ...
  665. math: {
  666. mathjax: 'http://cdn.mathjax.org/mathjax/latest/MathJax.js',
  667. config: 'TeX-AMS_HTML-full' // See http://docs.mathjax.org/en/latest/config-files.html
  668. },
  669. dependencies: [
  670. { src: 'plugin/math/math.js', async: true }
  671. ]
  672. });
  673. ```
  674. Read MathJax's documentation if you need [HTTPS delivery](http://docs.mathjax.org/en/latest/start.html#secure-access-to-the-cdn) or serving of [specific versions](http://docs.mathjax.org/en/latest/configuration.html#loading-mathjax-from-the-cdn) for stability.
  675. ## Installation
  676. The **basic setup** is for authoring presentations only. The **full setup** gives you access to all reveal.js features and plugins such as speaker notes as well as the development tasks needed to make changes to the source.
  677. ### Basic setup
  678. The core of reveal.js is very easy to install. You'll simply need to download a copy of this repository and open the index.html file directly in your browser.
  679. 1. Download the latest version of reveal.js from <https://github.com/hakimel/reveal.js/releases>
  680. 2. Unzip and replace the example contents in index.html with your own
  681. 3. Open index.html in a browser to view it
  682. ### Full setup
  683. Some reveal.js features, like external Markdown and speaker notes, require that presentations run from a local web server. The following instructions will set up such a server as well as all of the development tasks needed to make edits to the reveal.js source code.
  684. 1. Install [Node.js](http://nodejs.org/)
  685. 2. Install [Grunt](http://gruntjs.com/getting-started#installing-the-cli)
  686. 4. Clone the reveal.js repository
  687. ```sh
  688. $ git clone https://github.com/hakimel/reveal.js.git
  689. ```
  690. 5. Navigate to the reveal.js folder
  691. ```sh
  692. $ cd reveal.js
  693. ```
  694. 6. Install dependencies
  695. ```sh
  696. $ npm install
  697. ```
  698. 7. Serve the presentation and monitor source files for changes
  699. ```sh
  700. $ grunt serve
  701. ```
  702. 8. Open <http://localhost:8000> to view your presentation
  703. You can change the port by using `grunt serve --port 8001`.
  704. ### Folder Structure
  705. - **css/** Core styles without which the project does not function
  706. - **js/** Like above but for JavaScript
  707. - **plugin/** Components that have been developed as extensions to reveal.js
  708. - **lib/** All other third party assets (JavaScript, CSS, fonts)
  709. ## License
  710. MIT licensed
  711. Copyright (C) 2015 Hakim El Hattab, http://hakim.se