Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unfold block and highlight link if it matches current page URL #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
15 changes: 15 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}