Adobe RoboHelp: Expand selected Drop-downs by default
In a previous post I have shown you how to expand all drop-downs by default when the page is loaded. Recently I was asked whether it is possible to expand only select drop-downs when the page load. Most certainly! But it requires a little more work from the author.
To expand only select drop-downs, you need to change the ehlpdhtm.js file and you need to specify which drop-downs should be expanded.
Note: I tested this method on RoboHelp 10 only, but it should work for older versions as well.
Specify the drop-downs to expand
- Find the drop-down that you want to expand by default.
- Select the drop-down and switch to HTML mode.
- Add the text data-expanded to the code of the drop-down between
<?rh-dropdown_start and ?>
.
- Save the topic.
- Repeat step 1 – 4 for every drop-down you want to expand on load.
When you have set up all your drop-downs, generate the project.
Setting the script up
For a CHM, you need to modify the ehlpdhtm.js of the project root. For WebHelp, you need to modify the ehlpdhtm.js file in the output folder. Follow these steps to make drop-downs and expandspots show by default.
Open the file in a text editor and find:
CCSSP.RegisterEventHandler( window, "onload", "TextPopupOnLoad(\"" + el.id +"\");" );
- Line 2357 for RoboHelp 7.
- Line 2498 for RoboHelp 8.
- Line 2497 for RoboHelp 9.
- Line 2650 for RoboHelp 10.
Add a new line after the found line and add the following code on the new line you created:
if(el.getAttribute('data-expanded') == null) {//Attribute not set, don't expand by default CCSSP.RegisterEventHandler( window, "onload", "TextPopupOnLoad(\"" + el.id +"\");" ); } else { CCSSP.RegisterEventHandler( window, "onload", "TextPopup(\"" + el.id +"\");" ); }
Save the script.
When a page loads, all drop-downs you have set up will automatically expand. Don’t forget to change the script every time you generate. (You can also change the seed ehlpdhtm.js file in %RH install dir%/RoboHTML so that the changes will automatically be included every time you generate. Make a backup before changing a seed file though.)