-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
259 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"use strict"; | ||
|
||
function Menu() { | ||
this.$toggle = document.getElementById('menu-toggle'); | ||
this.$menu = document.getElementById('menu'); | ||
|
||
this.$toggle.addEventListener('click', this.toggle.bind(this)); | ||
|
||
var tocItems = this.$menu.querySelectorAll('#menu-toc li'); | ||
for (var i = 0; i < tocItems.length; i++) { | ||
var $item = tocItems[i]; | ||
$item.addEventListener('click', function($item, event) { | ||
$item.classList.toggle('active'); | ||
event.stopPropagation(); | ||
}.bind(null, $item)); | ||
} | ||
|
||
var tocLinks = this.$menu.querySelectorAll('#menu-toc li > a'); | ||
for (var i = 0; i < tocLinks.length; i++) { | ||
var $link = tocLinks[i]; | ||
$link.addEventListener('click', function(event) { | ||
this.toggle(); | ||
event.stopPropagation(); | ||
}.bind(this)); | ||
} | ||
} | ||
|
||
Menu.prototype.toggle = function () { | ||
this.$menu.classList.toggle("active"); | ||
} | ||
|
||
function init() { | ||
var menu = new Menu(); | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', init); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
const Builder = require('./Builder'); | ||
const Toc = require('./Toc'); | ||
|
||
module.exports = class Menu extends Builder { | ||
build() { | ||
const toc = Toc.build(this.spec, true); | ||
const tocContainer = this.spec.doc.createElement('div'); | ||
tocContainer.setAttribute('id', 'menu-toc'); | ||
tocContainer.innerHTML = toc; | ||
|
||
const menuContainer = this.spec.doc.createElement('div'); | ||
menuContainer.setAttribute('id', 'menu'); | ||
menuContainer.appendChild(tocContainer); | ||
|
||
this.spec.doc.body.insertBefore(menuContainer, this.spec.doc.body.firstChild); | ||
|
||
const menuToggle = this.spec.doc.createElement('div'); | ||
menuToggle.setAttribute('id', 'menu-toggle'); | ||
menuToggle.textContent = '☰'; | ||
|
||
this.spec.doc.body.insertBefore(menuToggle, this.spec.doc.body.firstChild); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<pre class=metadata>oldToc: true</pre> | ||
<emu-intro> | ||
<h1>Intro</h1> | ||
<emu-intro> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters