diff options
| author | Dan Allen <dan@opendevise.com> | 2018-08-05 14:38:47 -0600 |
|---|---|---|
| committer | Dan Allen <dan@opendevise.com> | 2018-08-05 23:06:36 +0000 |
| commit | 9e272f11f5f149daa308e54a47e937e01ff9ccfd (patch) | |
| tree | 29208c17f02fa88f68862bb8df1d0262bb17cff7 /src | |
| parent | 8b0e1a4e3ce7a055145f143237c9c9ee0a154197 (diff) | |
| download | alpine-antora-theme-9e272f11f5f149daa308e54a47e937e01ff9ccfd.tar.bz2 alpine-antora-theme-9e272f11f5f149daa308e54a47e937e01ff9ccfd.tar.xz | |
make text of text-only nav item with children clickable
Diffstat (limited to 'src')
| -rw-r--r-- | src/js/01-navigation.js | 20 |
1 files changed, 20 insertions, 0 deletions
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 + } })() |
