adzm / reveal.js-menu

Slide out menu for reveal.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reveal.js-menu

A slideout menu plugin for Reveal.js to quickly jump to any slide by title. Also optionally change the theme and set the default transition. Check out the live demo

Installation

Bower

Download and install the package in your project:

bower install reveal.js-menu

Add the plugin to the dependencies in your presentation, as below.

Reveal.initialize({
	// ...
	
	dependencies: [
		// ... 
	  
		{ src: 'bower_components/reveal.js-menu/menu.js' }
	]
});

Manual

Copy this repository into the plugins folder of your reveal.js presentation, ie plugins/menu.

Add the plugin to the dependencies in your presentation, as below.

Reveal.initialize({
	// ...
	
	dependencies: [
		// ... 
	  
		{ src: 'plugin/menu/menu.js' }
	]
});

Configuration

You can configure the menu for your presentation by providing a menu option in the reveal.js initialization options. Note that all config values are optional and will default as specified below.

Reveal.initialize({
	// ...

	menu: {
		// Specifies which side of the presentation the menu will 
		// be shown. Use 'left' or 'right'.
		side: 'left',

		// Add slide numbers to the titles in the slide list.
		// Use 'true' or format string (same as reveal.js slide numbers)
		numbers: false,

		// Hide slides from the menu that do not have a title.
		// Set to 'true' to only list slides with titles.
		hideMissingTitles: false,

		// Add markers to the slide titles to indicate the 
		// progress through the presentation
		markers: false,

		// Specify custom panels to be included in the menu, by
		// providing an array of objects with 'title', 'icon'
		// properties, and either a 'src' or 'content' property.
		custom: false,

		// Specifies the themes that will be available in the themes
		// menu panel. Set to 'false' to hide themes panel.
		themes: [
			{ name: 'Black', theme: 'css/theme/black.css' },
			{ name: 'White', theme: 'css/theme/white.css' },
			{ name: 'League', theme: 'css/theme/league.css' },
			{ name: 'Sky', theme: 'css/theme/sky.css' },
			{ name: 'Beige', theme: 'css/theme/beige.css' },
			{ name: 'Simple', theme: 'css/theme/simple.css' },
			{ name: 'Serif', theme: 'css/theme/serif.css' },
			{ name: 'Blood', theme: 'css/theme/blood.css' },
			{ name: 'Night', theme: 'css/theme/night.css' },
			{ name: 'Moon', theme: 'css/theme/moon.css' },
			{ name: 'Solarized', theme: 'css/theme/solarized.css' }
		],

		// Specifies if the transitions menu panel will be shown.
		transitions: true,

		// Adds a menu button to the slides to open the menu panel.
		// Set to 'false' to hide the button.
		openButton: true,

		// If 'true' allows the slide number in the presentation to
		// open the menu panel. The reveal.js slideNumber option must 
		// be displayed for this to take effect
		openSlideNumber: false,

		// If true allows the user to open and navigate the menu using
		// the keyboard. Standard keyboard interaction with reveal
		// will be disabled while the menu is open.
		keyboard: true
	},

});

Slide Titles

The slide titles used in the menu can be supplied explicitly or are taken directly from the presentation, using the following rules...

1. The section's data-menu-title attribute.

If the slide's section element contains a data-menu-title attribute this will be used for the slide title in the menu. For example...

<section data-menu-title="Custom Menu Title">
	<h1>Title</h1>
	<p>...</p>
</section>
2. Any element with the class menu-title.

If the slide's section contains an element with the class menu-title then the element's text will be used for the title. The first such element found will be used if there are more than one. Note the element need not be displayed to be used. For example...

<section>
	<h1>Title</h1>
	<span class="menu-title" style="display: none">Custom Menu Title</span>
	<p>...</p>
</section>
3. The first heading found

If not explicitly specified (as above), the title will be taken from the first heading element found in the slide. For example...

<section>
	<h3>This will be the slide title in the menu</h3>
	<h1>Title</h1>
	<p>...</p>
</section>
4. No title is provided

If no title can be found using the above methods, a default title incorporating the slide number will be used. For example, the following would result in a slide title in the format of 'Slide 12'...

<section>
	<p>...</p>
</section>

If the hideMissingTitles option is set to true, however, the slide will not listed in the menu.

Custom Menu Panels

Additional custom panels can be added the menu using the custom option.

Reveal.initialize({
	// ...

	menu: {
		// ...

		custom: [
			{ title: 'Links', icon: '<i class="fa fa-external-link">', src: 'links.html' },
			{ title: 'About', icon: '<i class="fa fa-info">', content: '<p>This slidedeck is created with reveal.js</p>' }
		]
	}
});

title and icon are used for the toolbar buttons at the top of the menu. There are two approaches you can use to provide content for the panels...

  • Provide html in content and this will be added to the custom panel.
  • You can also provide a URL in src to load html from another file.
Custom slide menu items

You can provide menu items in your custom panels using the following format. This allows you to define your own navigation links for your presentation.

<h1>Links</h1>
<ul class="slide-menu-items">
	<li class="slide-menu-item"><a href="#/transitions">Transitions</a></li>
	<li class="slide-menu-item"><a href="#/13">Code highlighting</a></li>
</ul>

You are not limited to linking to presentation slides. You can provide any link you wish.

<h1>External Links</h1>
<ul class="slide-menu-items">
	<li class="slide-menu-item"><a href="https://github.com/denehyg/reveal.js-menu" target="_blank">Reveal.js-menu</a></li>
	<li class="slide-menu-item"><a href="https://github.com/hakimel/reveal.js" target="_blank">Reveal.js</a></li>
</ul>

Using menu items enables keyboard navigation of your links as with the other panels. However, you don't have to use menu items for your links. You can simply provide standard links and unordered lists in your html. Notice you can provide your custom menu items mixed with other html if you wish.

License

MIT licensed

Copyright (C) 2015 Greg Denehy

About

Slide out menu for reveal.js

License:MIT License


Languages

Language:JavaScript 80.2%Language:CSS 19.8%