summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Allen <dan@opendevise.com>2018-08-05 14:38:47 -0600
committerDan Allen <dan@opendevise.com>2018-08-05 23:06:36 +0000
commit9e272f11f5f149daa308e54a47e937e01ff9ccfd (patch)
tree29208c17f02fa88f68862bb8df1d0262bb17cff7
parent8b0e1a4e3ce7a055145f143237c9c9ee0a154197 (diff)
downloadalpine-antora-theme-9e272f11f5f149daa308e54a47e937e01ff9ccfd.tar.bz2
alpine-antora-theme-9e272f11f5f149daa308e54a47e937e01ff9ccfd.tar.xz
make text of text-only nav item with children clickable
-rw-r--r--preview-site-src/ui-model.yml2
-rw-r--r--src/js/01-navigation.js20
2 files changed, 20 insertions, 2 deletions
diff --git a/preview-site-src/ui-model.yml b/preview-site-src/ui-model.yml
index 20a364f..a227ca6 100644
--- a/preview-site-src/ui-model.yml
+++ b/preview-site-src/ui-model.yml
@@ -87,8 +87,6 @@ page:
url: '#liber-recusabo'
urlType: fragment
- content: Reference
- url: '#'
- urlType: fragment
items:
- content: Keyboard Shortcuts
url: '#'
diff --git a/src/js/01-navigation.js b/src/js/01-navigation.js
index 3272cf9..29e8e1e 100644
--- a/src/js/01-navigation.js
+++ b/src/js/01-navigation.js
@@ -28,6 +28,15 @@
menuState.expandedItems = getExpandedItems()
saveNavState()
})
+ var navItemSpan = findNextElement(btn, '.nav-text')
+ if (navItemSpan) {
+ navItemSpan.style.cursor = 'pointer'
+ navItemSpan.addEventListener('click', function () {
+ li.classList.toggle('is-active')
+ menuState.expandedItems = getExpandedItems()
+ saveNavState()
+ })
+ }
})
find('.nav-item', menuPanel).forEach(function (item, idx) {
@@ -143,4 +152,15 @@
function find (selector, from) {
return [].slice.call((from || document).querySelectorAll(selector))
}
+
+ function findNextElement (from, selector) {
+ var el
+ if ('nextElementSibling' in from) {
+ el = from.nextElementSibling
+ } else {
+ el = from
+ while ((el = el.nextSibling) && el.nodeType !== 1);
+ }
+ return el && selector ? el[el.matches ? 'matches' : 'msMatchesSelector'](selector) && el : el
+ }
})()