Close option at the end of a drop-down

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
btompkins
Propeller Head
Posts: 11
Joined: Fri Mar 11, 2016 6:40 am

Close option at the end of a drop-down

Post by btompkins »

I am wondering if there is a way to give a reader the option to close a drop-down at the bottom of the drop-down so they don't have to scroll back to the top? I'm writing a tutorial that has a few drop-down sections, so I might like to have the option for a reader to click "Close" (or something similar) at the bottom to collapse the section they're in before they move to the next section. Any ideas?

Thanks!
Rene Severens
Sr. Propeller Head
Posts: 210
Joined: Mon Sep 19, 2011 2:06 am
Location: Netherlands - Zoetermeer
Contact:

Re: Close option at the end of a drop-down

Post by Rene Severens »

Hi,

I thought I had seen this before, entered by someone else:

Create a "drowdownclose.js" with the next lines and store it in the resource folder (for example in a new created folder named "Scripts")

$(document).ready(function(){
$(".dropDownBody").append("<a href='javascript:void(0);' class='dropDownClose'>(Close)</a>").click(function() {
$(this).parents(".dropDown").find(".dropDownHotspot").click();
});
});

and in the <head> section of the master page add this:

<script src="../Scripts/dropdown.js">
</script>

And this works, BUT ... (and that is why I would like to respond on this) ... it has a slight side-effect: If clicked ANYWHERE in the opened dropdown, the dropdown is closed.

So why show a hyperlink (Close) ? Maybe the script can be changed so it actually works only when clicked the hyperlnk? I am not a script genius...

Greetings,
Rene Severens
"The numbers are strange today; they somehow do not seem to add up."
NorthEast
Master Propellus Maximus
Posts: 6426
Joined: Mon Mar 05, 2007 8:33 am

Re: Close option at the end of a drop-down

Post by NorthEast »

Yep, I posted a reply, but deleted it because it had a few problems, which I didn't have time to fix properly at the time.

You could try this instead, which seems to work for me (even with nested dropdowns) in a HTML5 target:

Code: Select all

$(document).ready(function(){
		$(".dropDownBody").append("<a href='javascript:void(0);' class='dropDownClose'>(Close)</a>");
		$(".dropDownClose").click(function() {
			$(this).parent().prev(".dropDownHead").children(".dropDownHotspot").click();
		});
});
You can change the (Close) text in the script, and format it by adding a.dropDownClose {} to your CSS.

The script adds a (Close) link to every .dropDownBody, and if you click on (Close) then it will click the corresponding .dropDownHotspot link.
Rene Severens
Sr. Propeller Head
Posts: 210
Joined: Mon Sep 19, 2011 2:06 am
Location: Netherlands - Zoetermeer
Contact:

Re: Close option at the end of a drop-down

Post by Rene Severens »

Hi Dave,

Thanks!

This works perfect!

Thank you very much!

Rene Severens
"The numbers are strange today; they somehow do not seem to add up."
NorthEast
Master Propellus Maximus
Posts: 6426
Joined: Mon Mar 05, 2007 8:33 am

Re: Close option at the end of a drop-down

Post by NorthEast »

I've posted a solution for adding a close link to both dropdowns and togglers:
viewtopic.php?f=12&t=28079
btompkins
Propeller Head
Posts: 11
Joined: Fri Mar 11, 2016 6:40 am

Re: Close option at the end of a drop-down

Post by btompkins »

Thanks Dave and Rene! I followed these steps and got the Close link in my drop-downs!
Post Reply