diff --git a/src/elements/markdown-top-nav.js b/src/elements/markdown-top-nav.js index d3c9a0b..76bb326 100644 --- a/src/elements/markdown-top-nav.js +++ b/src/elements/markdown-top-nav.js @@ -45,6 +45,20 @@ export class MarkdownTopNav { this.navtitle = (currentlinkindex > 0) && (currentlinkindex < window.markdownnav.links.length) ? window.markdownnav.links[currentlinkindex].title : ''; + //erase activenavitem class + let activenavitems = window.document.getElementsByClassName('activenavitem'); + for (let item of activenavitems) { item.classList.remove('activenavitem'); } + //make current link as class activenavitem + let currentnavitem = window.document.getElementById(currentlink); + if (currentnavitem) { + //set class - so it will have different color + currentnavitem.firstChild.classList.add('activenavitem'); + //show parent ul if hidden + if (currentnavitem.parentNode.className === 'w3-hide') { + //do open/hide as defined in markdownnav + if (window.bodylightnavopenhide) window.bodylightnavopenhide(currentnavitem.parentNode.previousSibling); + } + } } } diff --git a/src/elements/markdownnav.css b/src/elements/markdownnav.css index 4573084..4d24ce2 100644 --- a/src/elements/markdownnav.css +++ b/src/elements/markdownnav.css @@ -125,3 +125,6 @@ nav.vertical li li > a:after { content: '' } nav.vertical li li li > a:before { content: '\00a0\00a0\00a0\00a0\00a0\00a0\25a1\00a0' } nav.vertical li li li > a:after { content: '' } +.activenavitem { + background-color: #ffe69b; +} \ No newline at end of file diff --git a/src/elements/markdownnav.js b/src/elements/markdownnav.js index 933ed58..69decff 100644 --- a/src/elements/markdownnav.js +++ b/src/elements/markdownnav.js @@ -6,12 +6,13 @@ import {I18N} from 'aurelia-i18n'; import {HttpClient} from 'aurelia-fetch-client'; import {EventAggregator} from 'aurelia-event-aggregator'; -//global function +//global function to operate on translated markdown in navigation panel +//adds + or - and shows hides list under it window.bodylightnavopenhide = function(obj) { //set show/hide to //console.log('openhide()', obj); if (obj.nextSibling.className === 'w3-hide') { - obj.nextSibling.className = 'w3-show'; + obj.nextSibling.className = 'w3-animate-opacity'; obj.firstChild.className = 'fa fa-minus'; } else { obj.nextSibling.className = 'w3-hide'; @@ -49,7 +50,7 @@ export class Markdownnav { this.mdtoc = Markdownit({html: true}) .use(mk, {'throwOnError': true, 'errorColor': ' #cc0000'}) .use(iterator, 'url', 'link_open', function(tokens, idx) { - //detect link and token in MD + //detect links in list and create array of links used by other components let aIndex = tokens[idx].attrIndex('href'); if (aIndex < 0) { //tokens[idx].attrPush(['target', '_blank']); @@ -64,7 +65,16 @@ export class Markdownnav { }); this.navclass = (this.navstyle && this.navstyle.length > 0) ? this.navstyle : 'horizontal'; //adds rule to add a class to li item - this.mdtoc.renderer.rules.list_item_open = function(tokens, idx, options, env, slf) { return '