Side navigation: how to get dropdowns to open on page load?

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
bleebs
Propeller Head
Posts: 23
Joined: Tue May 12, 2009 6:26 pm
Location: Melbourne, Downunder

Side navigation: how to get dropdowns to open on page load?

Post by bleebs »

Has anyone accomplished this with side navigation yet? I've been trying out the methods on older posts but nothing's worked for me yet.
I'm not sure if that's to do with Flare 2019, the side nav target, or, heaven forbid(!), the fact that I just suck at scripting... :shock:

TIA!
Some humans would do anything to see if it was possible to do it. If you put a large switch in some cave somewhere, with a sign on it saying 'End-of-the-World Switch. PLEASE DO NOT TOUCH', the paint wouldn't even have time to dry.
Sir Terry Pratchett
zappy0
Propeller Head
Posts: 54
Joined: Fri Mar 25, 2016 2:19 pm

Re: Side navigation: how to get dropdowns to open on page lo

Post by zappy0 »

Do you mean dropdowns created with <MadCap:dropDown> </MadCap:dropDown>? If yes, you can control the open/close default by applying style via script. However, it seems the drop-downs do not have unique IDs (maybe there is a way to assign them). So, to force all of the drop-down lists open for a specific page, I used a Body Onload script:

<body onload="var divs = document.getElementsByTagName('div'); for (var i = 0; i < divs.length; i++) {divs.style.display = 'block'};">

However, this doesn't set the drop-down icon to open so there is more work needed to get that part working.
bleebs
Propeller Head
Posts: 23
Joined: Tue May 12, 2009 6:26 pm
Location: Melbourne, Downunder

Re: Side navigation: how to get dropdowns to open on page lo

Post by bleebs »

Thanks zappy, but have you got that working in sidenav? Flare is tripping any content out of my body tag and replacing it with the "web" class.
Some humans would do anything to see if it was possible to do it. If you put a large switch in some cave somewhere, with a sign on it saying 'End-of-the-World Switch. PLEASE DO NOT TOUCH', the paint wouldn't even have time to dry.
Sir Terry Pratchett
zappy0
Propeller Head
Posts: 54
Joined: Fri Mar 25, 2016 2:19 pm

Re: Side navigation: how to get dropdowns to open on page lo

Post by zappy0 »

No. I was using tripane and I apologize for missing the significance of the side navigation. Even worse, my proposed solution has stopped working for me in tripane and my attempts to find a solution in side nav have also failed. While I can get a script embedded and run it, it seems like something is loaded after that and sets the drop-down div back to display: none.
NorthEast
Master Propellus Maximus
Posts: 6426
Joined: Mon Mar 05, 2007 8:33 am

Re: Side navigation: how to get dropdowns to open on page lo

Post by NorthEast »

MadCap's scripts will add an inline display style on the dropdown body; e.g.
<div class="MCDropDownBody dropDownBody" id="xxx" style="display: none;">

So I'd guess your script is running before MadCap's scripts - it needs to run after them.

Unfortunately, I don't think there's an event to tell you when MadCap's scripts have finished.
There is a "loaded" event for MadCap's menus, so maybe use that to delay your script from running.
See: http://kb.madcapsoftware.com/Content/Mi ... _Menus.htm
zappy0
Propeller Head
Posts: 54
Joined: Fri Mar 25, 2016 2:19 pm

Re: Side navigation: how to get dropdowns to open on page lo

Post by zappy0 »

Dave Lee's solution worked for me using an HTML5 - Side Navigation skin (every Flare project I have has a Dave Lee solution in it).

My first script set every DIV to display = 'block'; but that ended up destroying the rest of the navigation. There are many Div elements. So, per Dave's comment, I decided to use document.getElementsByClassName('MCDropDownBody') to identify just the drop-down body text.

To my amazement, Flare includes the <script> tags I have in the <head> of my topic. I suppose with Side Nav it reloads the entire page when I navigate. Thus, adding this to a page appears to work:

<head><title>Favorites Manager Overview</title>
<script src="https://ajax.googleapis.com/ajax/libs/j ... "></script>
<script>
$(document).ready(function(){
$("ul.navigation").on("loaded", function () {
var divs = document.getElementsByClassName('MCDropDownBody');
for (var i = 0; i != divs.length; i++) {
divs.style.display = 'block';
};
});
});
</script>
</head>

However, I've not been able to figure out how to change the open / close image to default to open.

Tested on Chrome, Firefox and Edge.
bleebs
Propeller Head
Posts: 23
Joined: Tue May 12, 2009 6:26 pm
Location: Melbourne, Downunder

Re: Side navigation: how to get dropdowns to open on page lo

Post by bleebs »

This is brilliant zappy and Dave, thanks so much! Working beautifully now.

Also my open/close icon is switching. I'm using an icon font.

For reference, I've put my code at the end of the document, not the head, with various other scripts that I've pinched :oops: , and it all still works.

Code: Select all

<script src="scripts/jquery.tablesorter.js">
		</script>
		<script src="scripts/jquery.stickytableheaders.js">
		</script>
		<script>
			$(document).ready(function()
			{
			$("table").tablesorter();
			$("table").stickyTableHeaders();
			$("ul.navigation").on("loaded", function () {
			var divs = document.getElementsByClassName('MCDropDownBody');
			for (var i = 0; i != divs.length; i++) {
			divs[i].style.display = 'block';
			};
			});
			}
			);
		</script>
    </body>
</html>
Some humans would do anything to see if it was possible to do it. If you put a large switch in some cave somewhere, with a sign on it saying 'End-of-the-World Switch. PLEASE DO NOT TOUCH', the paint wouldn't even have time to dry.
Sir Terry Pratchett
Post Reply