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

bower install reveal.js-menu

Reveal.initialize({
// ...

dependencies: [
// ...

]
});


### npm

npm install --save reveal.js-menu

Reveal.initialize({
// ...

dependencies: [
// ...

]
});


### Manual

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

Reveal.initialize({
// ...

dependencies: [
// ...

]
});


## 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({
// ...

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

// Specifies the width of the menu.
// Can be one of the following:
// 'normal', 'wide', 'third', 'half', 'full', or
// any valid css length value
width: 'normal',

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

// Specifies which slide elements will be used for generating
// the slide titles in the menu. The default selects the first
// heading element found in the slide, but you can specify any
// valid css selector and the text from the first matching
// element will be used.
// Note: that a section data-menu-title attribute or an element
// with a menu-title class will take precedence over this option
titleSelector: 'h1, h2, h3, h4, h5, h6',

// If slides do not have a matching title, attempt to use the
// start of the text content as the title instead
useTextContentForMissingTitles: false,

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

// Adds markers to the slide titles to indicate the
// progress through the presentation. Set to 'false'
// to hide the markers.
markers: true,

// 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 'true' to show the themes menu panel
// with the default themes list. Alternatively, provide an
// array to specify the themes to make available in the
// themes menu panel, for example...
// [
//     { name: 'Black', theme: 'css/theme/black.css' },
//     { name: 'White', theme: 'css/theme/white.css' },
//     { name: 'League', theme: 'css/theme/league.css' }
// ]
themes: false,

// Specifies the path to the default theme files. If your
// presentation uses a different path to the standard reveal
// layout then you need to provide this option, but only
// when 'themes' is set to 'true'. If you provide your own
// list of themes or 'themes' is set to 'false' the
// 'themesPath' option is ignored.
themesPath: 'css/theme/',

// Specifies if the transitions menu panel will be shown.
// Set to 'true' to show the transitions menu panel with
// the default transitions list. Alternatively, provide an
// array to specify the transitions to make available in
// the transitions panel, for example...
transitions: false,

// 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,

// Normally the menu will close on user actions such as
// selecting a menu item, or clicking the presentation area.
// If 'true', the sticky option will leave the menu open
// until it is explicitly closed, that is, using the close
// button or pressing the ESC or m key (when the keyboard
// interaction option is enabled).
sticky: false,

// If 'true' standard menu items will be automatically opened
// when navigating using the keyboard. Note: this only takes
// effect when both the 'keyboard' and 'sticky' options are enabled.
autoOpen: true,

// If 'true' the menu will not be created until it is explicitly
// requested by calling RevealMenu.init(). Note this will delay
// the creation of all menu panels, including custom panels, and
delayInit: false,

// If 'true' the menu will be shown when the menu is initialised.
openOnInit: false,

// font-awesome library the 'loadIcons' option can be set to false
// and the menu will not attempt to load the font-awesome library.
},

});


### Themes Stylesheet

If you are using the themes panel you need to ensure the theme stylesheet in the presentation uses the id="theme" attribute. For example…

<link rel="stylesheet" href="css/theme/black.css" id="theme">


## 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>
<p>...</p>
</section>

###### 3. The first heading found or a custom element selector

The titleSelector option can be used to customise the elements that will be used to generate the slide titles in the menu. The default option selects 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>


Any valid CSS selector should work but note the selector will only be applied to elements contained within the slide section. You could use the 'h1' selector to only use level 1 headings or 'p' to use the first paragraph element. For example, titleSelector: 'p.lead' would be used like this…

<section>
<h1>Title</h1>
<p>...</p>
</section>


Using titleSelector: '' will ignore all elements and no title will be provided, unless the slide section contains a data-menu-title attribute or an element with the menu-title class.

###### 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 be listed in the menu.

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

Reveal.initialize({
// ...

// ...

custom: [
{ 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…

• You can provide a URL in src to load html from another file.
• Alternatively, you can provide html in content and this will be added to the custom panel.

<h1>Links</h1>
</ul>


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

<h1>External Links</h1>
</ul>


Reveal.addEventListener( 'menu-ready', function( event ) {
} );


## API

The RevealMenu object exposes a JavaScript API for controlling the menu:

FunctionDescription
toggle(event)Toggles the open state of the menu, ie open if it is closed, and close if it is open
closeMenu(event, force)Closes the menu. To force the menu to close (ie when sticky option is true) call closeMenu(null, true)
init()Initialises the menu if it has not already been initialised. Used in conjunction with the delayInit option