Expand TOC by default

This forum is for all Flare issues related to styles, stylesheets and XML.
Post Reply
siskamoens
Propeller Head
Posts: 85
Joined: Wed Mar 21, 2007 3:01 am
Location: Belgium
Contact:

Expand TOC by default

Post by siskamoens »

I have a very small project that opens with an introduction topic on the top level of my TOC. All other topics are arranged as child nodes under this intro topic.
When the help is launched, it opens the intro and leaves the TOC collapsed, so that you initially only see the intro in the TOC. I would however like to expand the TOC by default, so that the whole doc structure is visible immediately.
How can I do that?
Richard Ferrell
Propellus Maximus
Posts: 840
Joined: Mon May 01, 2006 10:11 am
Location: Inside California

Re: Expand TOC by default

Post by Richard Ferrell »

The TOC isn't expanded by default, but if your default topic is located in a lower level book, that book will be expanded when the help is opened, if Auto-Sync TOC is enabled.
Richard Ferrell

Certified Madcap Trainer
Image
siskamoens
Propeller Head
Posts: 85
Joined: Wed Mar 21, 2007 3:01 am
Location: Belgium
Contact:

Re: Expand TOC by default

Post by siskamoens »

Yeah, I thought of that as a workaround too. It's a pity though there's no real option to control the expand/collapse TOC for an online target. I think I'll submit a feature request for it.

Thanks, Richard.
lacastle
Propellus Maximus
Posts: 1028
Joined: Thu Apr 12, 2007 7:28 am
Location: Wilmington, DE
Contact:

Re: Expand TOC by default

Post by lacastle »

Another option I thought of was to not use any folders and just put all the "child" books on the first level. I think it would be ok considering how small you said the project was. Just clearly label the first topic as Introduction (and you can still make it open by default).
siskamoens
Propeller Head
Posts: 85
Joined: Wed Mar 21, 2007 3:01 am
Location: Belgium
Contact:

Re: Expand TOC by default

Post by siskamoens »

Problem is that I always create a top-level topic with a short intro and a mini-TOC proxy. So I can't place that on the same level as the child topics, because the mini-toc wouldn't contain any links.
jbkalla
Propeller Head
Posts: 57
Joined: Tue Nov 06, 2012 11:53 am
Location: Denver, CO, USA
Contact:

Re: Expand TOC by default

Post by jbkalla »

I would love to see an option somewhere for the site builder to set the ToC to be expanded by default, with a ++ and -- icon on the page itself so the user can expand all / contract all if they want to.
SteveS
Senior Propellus Maximus
Posts: 2089
Joined: Tue Mar 07, 2006 5:06 pm
Location: Adelaide, far side of the world ( 34°56'0.78\"S 138°46'44.28\"E).
Contact:

Re: Expand TOC by default

Post by SteveS »

jbkalla wrote:I would love to see an option somewhere for the site builder to set the ToC to be expanded by default, with a ++ and -- icon on the page itself so the user can expand all / contract all if they want to.
Lodge bug and enhancement requests here
Image
Steve
Life's too short for bad coffee, bad chocolate, and bad red wine.
kathryngz
Propeller Head
Posts: 75
Joined: Wed May 14, 2014 11:31 am

Re: Expand TOC by default

Post by kathryngz »

Does anyone know if this functionality is available in Flare 10? I've looked but can't find it. But technically it has to be possible, because the book containing the startup topic is always expanded by default. I just want the whole TOC to be expanded by default (it's a very small TOC).
Kathy_123
Propeller Head
Posts: 39
Joined: Thu Oct 04, 2012 9:40 am

Re: Expand TOC by default

Post by Kathy_123 »

I'm looking for the answer about Flare 10 as well! I'd like the TOC book folders to default to expanded when the TOC opens.
Nita Beck
Senior Propellus Maximus
Posts: 3667
Joined: Thu Feb 02, 2006 9:57 am
Location: Pittsford, NY

Re: Expand TOC by default

Post by Nita Beck »

Kathy_123 wrote:I'm looking for the answer about Flare 10 as well! I'd like the TOC book folders to default to expanded when the TOC opens.
I don't think there is such an option. 'Least, I've never come across it...
Nita
Image
RETIRED, but still fond of all the Flare friends I've made. See you around now and then!
Mike Kelley
Propeller Head
Posts: 68
Joined: Fri Aug 22, 2014 12:24 pm

Re: Expand TOC by default

Post by Mike Kelley »

No, it is not a default feature in Flare. Yes, it is technically possible (via JavaScript). When I get less busy I'll try to see how much JS is needed to do this.
jeniv
Jr. Propeller Head
Posts: 2
Joined: Mon Mar 02, 2015 10:43 am

Re: Expand TOC by default

Post by jeniv »

Did you ever figure out the JavaScript needed to do this? I have the same requirement as everyone else - my TOC needs to be expanded when the project opens. It would seem that this is a pretty standard requirement for many folks.
GaryUK
Propeller Head
Posts: 58
Joined: Thu Aug 29, 2013 12:19 am
Location: Surrey UK

Re: Expand TOC by default

Post by GaryUK »

I figured out a workaround in JavaScript. I think the problem is that the elements don't actually exist in the HTML until you open up a book icon in a TOC. It must then go away and retrieve the related topics.

This code works by simulating a click on each top-level book. It runs when you double-click the Contents tab:

window.onload = function() {

// Open first level when double-click on TOC tab.
$("#TocTab").dblclick(function() {

var topNodes = document.getElementsByClassName("tree")[0].childNodes;

for (var i = 0, l = topNodes.length; i < l; i++) {
topNodes.click();
}
// Go back to home topic
window.location.assign('#');
});
}

Click the Edit button on the Toolbar tab of the skin and paste this code into it.

Hope this helps some people. It only opens the first level of topics, but with a bit more fiddling you could get it to open further levels.
GaryUK
Propeller Head
Posts: 58
Joined: Thu Aug 29, 2013 12:19 am
Location: Surrey UK

Re: Expand TOC by default

Post by GaryUK »

PS.

This does not work in Flare V11. To get it to work, the line where the click is simulated should be changed to:

topNodes.childNodes[0].click();
damadeo
Propeller Head
Posts: 10
Joined: Tue Nov 11, 2014 9:06 am

Re: Expand TOC by default

Post by damadeo »

I tried this and the change that makes it work in Flare 11. However, when I double-click on the Contents label, I get returned to the topic container. When I re-access the TOC, the first-level heads are expanded, as described.

But why is it shooting me out to the topic container first?
lizat
Sr. Propeller Head
Posts: 282
Joined: Sun Feb 01, 2009 3:49 am
Location: London, UK

Re: Expand TOC by default

Post by lizat »

Hi Madcaps,

Since I originally found this question time has moved on. I am still at 10.2 and the code provided above does not expand the TOC in the navigation pane. Does anyone have any other solutions - and does v12 offer this as a configurable setting?

thank you..................... liz
GaryUK
Propeller Head
Posts: 58
Joined: Thu Aug 29, 2013 12:19 am
Location: Surrey UK

Re: Expand TOC by default

Post by GaryUK »

Thanks, I hadn't noticed this had stopped working. For some reason, the click event on the TOC nodes has changed to a div inside the li node, so now you have to simulate the click on the div instead of the li element. I'm not sure when this happened. That's the thing with JavaScript; browser updates and Flare updates can stop things working. Still, it's better than not being able to open the TOC in one go.

For later versions, this should work:

window.onload = function() {
// Open first level when double-click on TOC tab.
$("#TocTab").dblclick(function() {

var topNodes = document.getElementsByClassName("tree")[0].childNodes;

for (var i = 0, l = topNodes.length; i < l; i++) {
ob=topNodes.firstChild;
ob.click();
}
window.location.assign('#');
});
}

Note, this only applies to tripane HTML5 and it works with Flare 12. If you already have the window.onload section in your code then don't add it again. This also applies to the last brace (})

@damadeo - I'm not sure why you're getting that. Mine seems fine. I'm not sure what you mean by having to re-access the TOC.
BrianBXYPRO
Propeller Head
Posts: 23
Joined: Tue May 03, 2016 12:04 pm
Location: Simi Valley, CA

Re: Expand TOC by default

Post by BrianBXYPRO »

Thanks, GaryUK, that worked great. However, I agree with jbkalla that there should be an option to expand the TOC by default. So, heading to the feature request page.
Brian
Flare ( :flare: ) v12, Windows 10
Post Reply