From 753b09d91db6e84ba3974cdb3f41ea9f36f29a6c Mon Sep 17 00:00:00 2001 From: Yuri Gor Date: Sat, 12 Jan 2019 18:30:09 +0300 Subject: [PATCH] unfold block and highlight link if it matches current page URL --- script.js | 19 +++++++++++++++++++ style.css | 15 +++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/script.js b/script.js index ef9d4b7..979ccde 100644 --- a/script.js +++ b/script.js @@ -43,6 +43,25 @@ jQuery(function() { evt.preventDefault(); return false; }); + // unfold block if it contans link to the current page + jQuery('.dokuwiki .folder').each(function(){ + var $a = jQuery(this); + var id = this.href.match(/#(.*)$/)[1]; + var $folderContent = jQuery(document.getElementById(id)); + + if ($folderContent.hasClass('hidden')) { + $folderContent.find('a').each(function(){ + var $current = jQuery(this); + var href = $current.attr('href'); + if(document.location.pathname == href || document.location.href == href){ + $folderContent.addClass('open').removeClass('hidden'); + $a.addClass('open').attr('title', folded_hide); + $current.parents('li').addClass('active'); + return false; + } + }); + } + }); }); function fold_unfold_all() { diff --git a/style.css b/style.css index 073b0ac..614dfd6 100644 --- a/style.css +++ b/style.css @@ -47,3 +47,18 @@ span.indicator { .folded.hidden { display: none; } .folder span.indicator { visibility: visible; } */ + +/* This classes used to mark currently loaded link in the foldable block */ +.folded.open li.active a { + color:#FFFFFF!important; + font-weight: bold; +} +.folded.open li.active a:before { + content: "\f0da"; + font: normal normal normal 36px/1 FontAwesome; + font-size: 36px; + color: #446e9b!important; + position: absolute; + right: -11px; + top: calc(~"50% - "18px); +} \ No newline at end of file