I made it in a very strange way... here is the demo with TOC highlight
http://uvakin.neocities.org/heeg.html
I put some code zoomin.js
/*
Find the first child DOM node of a widget that has the class "tc-title"
*/
function parentTag(node) {
return node.parentNode;
}
function findTitleDomNode(widget,targetClass) {
targetClass = targetClass || "tc-title";
var domNode = widget.findFirstDomNode();
if(domNode.querySelector('.tc-title') != null ){
var ttitle=domNode.querySelector('.tc-title').textContent.replace(
/^\s+|\s+$/mg,'');
document.title=ttitle;
var elements = document.querySelectorAll('ol a,ol ol a,ol button,ol ol
button') ;
for (var i = 0; i < elements.length; i++) {
elements[i].style.color = 'inherit';
parentTag(elements[i]).style.backgroundColor = '';
parentTag(parentTag(elements[i])).style.backgroundColor = '';
if( elements[i].textContent.replace(/^\s+|\s+$/mg,'')==ttitle){elements[i].
style.color = '#ff8400';
if(
parentTag(elements[i]).tagName=="LI"){parentTag(elements[i]).style.backgroundColor
= 'rgba(0, 0, 0, 0.1)';} ;
if( parentTag(parentTag(elements[i])).tagName=="LI"){parentTag(parentTag
(elements[i])).style.backgroundColor = 'rgba(0, 0, 0, 0.1)';} ;
} ;
}
}
if(domNode && domNode.querySelector) {
return domNode.querySelector("." + targetClass);
}
return null;
}
понедельник, 9 ноября 2015 г., 19:13:01 UTC+3 пользователь Tobias Beer
написал:
> Hi Siniy-Kit,
>
>
>> is it possible to make menu with highlight items?
>>
>
> With the current ways of how the toc works, I don't think it is, as the
> recursion steps work entirely independently and there is no "after-render"
> dom manipulation that would find a "current tiddler" and then make sure
> that its parent items get highlighted (and are expanded).
>
> On the other hand, I don't think the current implementation allows to
> defer the toc rendering until after the "currently active branch" has been
> properly identified, as its iterations render items independently, as
> already said.
>
> So, this begs for a new / different approach to implementing a table of
> contents, one that does away with nested-macro+template-magic.
>
> Best wishes,
>
> — tb
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/13499590-664d-4727-96ef-21d155d7eced%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.