Skip to content

Commit 6e6d86f

Browse files
author
Martino
committed
Version 1.0.3
Compatibility with Reveal 4
1 parent 5faa599 commit 6e6d86f

File tree

19 files changed

+1555
-6302
lines changed

19 files changed

+1555
-6302
lines changed

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Martijn De Jongh (Martino)
3+
Copyright (c) 2020 Martijn De Jongh (Martino)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

README.md

Lines changed: 106 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,81 @@
1-
# reveal.js-simplemenu
1+
# Simplemenu
22
A simple menu for [Reveal.js](https://revealjs.com)
33

4-
In Powerpoint you can make slides with a nice bottom- or top bar in which the active chapter is highlighted. This menu works in the same way, but automatically.
4+
[![Screenshot](screenshot.png)](https://martinomagnifico.github.io/reveal.js-simplemenu/demo.html)
55

6-
[Demo with bar on top](https://martinomagnifico.github.io/reveal.js-simplemenu/demo.html)
7-
or
8-
[Demo with bar on bottom](https://martinomagnifico.github.io/reveal.js-simplemenu/bottombar.html)
6+
In Powerpoint you can make slides with a nice bottom- or top bar in which ***the active menu item is highlighted***. This menu works in the same way, but automatically.
97

8+
[Demo with bar on top](https://martinomagnifico.github.io/reveal.js-simplemenu/demo.html)
109

10+
[Demo with bar on bottom](https://martinomagnifico.github.io/reveal.js-simplemenu/demo-bottom.html)
1111

12-
It's easy to set up, but expects a few things:
12+
[Demo with select by name](https://martinomagnifico.github.io/reveal.js-simplemenu/demo-name.html)
1313

14-
Chapters can only be top-level sections (horizontal) with, or without, nested sections (vertical).
14+
[Demo with auto-generated menu](https://martinomagnifico.github.io/reveal.js-simplemenu/demo-auto.html)
1515

16-
There has to be a:
16+
### What it does
17+
- Make menu items of your vertical stacks (top-level sections).
18+
- Moving to another vertical stack (by whatever navigation) will automatically update the current menu item.
19+
- Clicking an item in the menu will open the first section in the corresponding vertical stack.
20+
- Simplemenu can auto-generate the menu, using section names (ID's give ugly button names). See the option 'auto' in options
1721

18-
- Element with `class="menu"`.
19-
- Inside this menu, there have to be anchors with an href. These can point to either an ID of a first nested section, or to an ID of a top-level section when it has no children.
20-
- The top-level sections need a data attribute: `data-menu-title="chaptername"`.
21-
- Simplemenu checks if the href value of those links correspond to the data-menu-title attribute of the sections.
2222

23-
Simplemenu does not check if an ID has the same name as the data-attribute. Reveal.js handles clicks on (named) anchors of top-level sections with subsections only horizontally. That means if you have clicked through the slides of chapter 1, are now in chapter 2, and click on an anchor that points to the top-level section of chapter one, it will not 'scroll' to the top, but show the last viewed slide of chapter 1. That's why the ID's need to be on the first slide of their chapter, and that's why there is both an ID and a data-attribute. Another possibility would be to use only ID's and to check if there is a sibling or parent with an ID that is also in the menu, but this current version works well enough.
23+
It's easy to set up, but expects a few things:
2424

25+
- Menu items can only be top-level sections: regular horizontal slides or vertical stacks.
26+
- There has to be an element that will hold the links. By default this selector is the class `menu`. The selector can be changed in the Simplemenu options.
27+
- Inside this main menu, there have to be anchors with an href. These need to point to an ID of a top-level section. Reveal uses links with hashes to navigate, so the link has to be written like that: `href="#/firstchapter"`.
2528

2629

2730
## Installation
2831

2932
Copy the simplemenu folder to the plugins folder of the reveal.js folder, like this: `plugin/simplemenu`. Now add it to the dependencies of Reveal.js:
3033

3134

32-
```javascript
33-
Reveal.initialize({
34-
// ...
35-
dependencies: [
36-
// ...
37-
{ src: 'plugin/simplemenu/simplemenu.js' },
38-
// ...
39-
]
40-
});
35+
### JavaScript
36+
37+
The Simplemenu plugin has been rewritten for Reveal.js version 4.
38+
39+
If you want to use Simplemenu with an older version of Reveal, use the [1.0.2 version](https://github.com/Martinomagnifico/reveal.js-simplemenu/releases).
40+
41+
There are two JavaScript files for Simplemenu, a regular one, `simplemenu.js`, and a module one, `simplemenu.esm.js`. You only need one of them:
42+
43+
44+
#### Regular
45+
If you're not using ES modules, for example, to be able to run your presentation from the filesystem, you can add it like this:
46+
47+
```html
48+
<script type="text/javascript" src="dist/reveal.js"></script>
49+
<script src="plugin/simplemenu/simplemenu.js"></script>
50+
<script>
51+
Reveal.initialize({
52+
// ...
53+
plugins: [ Simplemenu ]
54+
});
55+
</script>
4156
```
4257

58+
#### As a module
59+
If you're using ES modules, you can add it like this:
60+
61+
```html
62+
<script type="module">
63+
// This will need a server
64+
import Reveal from './dist/reveal.esm.js';
65+
import Simplemenu from './plugin/simplemenu/simplemenu.js';
66+
Reveal.initialize({
67+
// ...
68+
plugins: [ Simplemenu ]
69+
});
70+
</script>
71+
```
72+
73+
Simplemenu also works in setups with multiple Reveal instances.
74+
4375

4476
## Setup
4577

46-
It is easy to set up your HTML structure for Simplemenu:
78+
It is easy to set up your HTML structure for Simplemenu. To keep the Simplemenu on every slide, put it outside of the `.slides`:
4779

4880
```html
4981
<div class="menubar">
@@ -55,24 +87,27 @@ It is easy to set up your HTML structure for Simplemenu:
5587
</ul>
5688
</div>
5789
<div class="slides">
58-
<section>
59-
<h1>Main title slide</h1>
60-
</section>
61-
<!-- Add data-attributes to the top-level sections -->
62-
<section data-menu-title="firstchapter">
63-
<!-- And an ID -->
64-
<section id="firstchapter">
90+
...
91+
</div>
92+
```
93+
94+
The top-level sections (that should be in the menu) need to have an ID:
95+
96+
```html
97+
<div class="slides">
98+
<section id="firstchapter" name="First chapter">
99+
<section>
65100
<h2>This is 1</h2>
66101
</section>
67102
<section>
68103
<h4>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</h4>
69104
</section>
70105
</section>
71-
<section id="secondchapter" data-menu-title="secondchapter">
106+
<section id="secondchapter" name="Second chapter">
72107
<h2>This is 2, no child slides</h2>
73108
</section>
74-
<section data-menu-title="thirdchapter">
75-
<section id="thirdchapter">
109+
<section id="thirdchapter" name="My third chapter">
110+
<section>
76111
<h2>This is 3</h2>
77112
</section>
78113
<section>
@@ -81,6 +116,26 @@ It is easy to set up your HTML structure for Simplemenu:
81116
</section>
82117
</div>
83118
```
119+
### The auto way
120+
121+
When using the `auto` option (see Configuration), you only need to add an empty menu, and give names to your sections.
122+
123+
```html
124+
<div class="menubar">
125+
<ul class="menu"></ul>
126+
</div>
127+
<div class="slides">
128+
<section name="Menu item one">
129+
//...
130+
</section>
131+
<section name="Menu item two">
132+
//...
133+
</section>
134+
<section name="Menu item three">
135+
//...
136+
</section>
137+
</div>
138+
```
84139

85140

86141
## Configuration
@@ -89,27 +144,30 @@ There are a few options that you can change from the Reveal.js options. The valu
89144

90145
```javascript
91146
Reveal.initialize({
92-
// ...
93-
simplemenu: {
94-
// Use menuselector to assign the menu items to be used. You might want to point
95-
// it to '.menu li a' for example. In that case the class of the a's will toggle,
96-
// not the class of the li's.
97-
menuselector: '.menu li',
98-
99-
// Use a specific class for the active state.
100-
activeclass: 'active'
101-
},
102-
dependencies: [
103-
// ...
104-
]
147+
// ...
148+
simplemenu: {
149+
menuclass: 'menu',
150+
activeclass: 'active',
151+
activeelement: 'li',
152+
selectby: 'id',
153+
auto: false
154+
},
155+
plugins: [ Simplemenu ]
105156
});
106157
```
158+
* **`menuclass`**: This option sets the classname of the menu.
159+
* **`activeclass`**: This option is the class an active menuitem gets.
160+
* **`activeelement`**: This option sets the element that gets the active class. Change it if you directly want to style the `a`, for example.
161+
* **`selectby`**: The selectby option finds the currently active vertical stack by this. By default, it selects by ID, but it can also be set to `name`. In that case, Simplemenu will compare the text content of your links to the name of the section.
162+
* **`auto`**: If set to true, the auto option will auto-generate a menu by the names of the sections.
163+
164+
107165

108166
## Like it?
109-
This is my first Github repo... let me know if you like it.
167+
If you like it, please star this repo.
110168

111169

112170
## License
113171
MIT licensed
114172

115-
Copyright (C) 2019 Martijn De Jongh (Martino)
173+
Copyright (C) 2020 Martijn De Jongh (Martino)

assets/css/theme/simplemenu.css

Lines changed: 0 additions & 48 deletions
This file was deleted.

assets/js/revealjs/plugin/simplemenu/simplemenu.js

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)