Skip to main content
Known Participant
March 17, 2011
Answered

Wrap TOC text in RH8?

  • March 17, 2011
  • 1 reply
  • 1668 views

Hi guys,

I found an old post from 2006 that talks about some funky workaround to force topic titles to wrap in the TOC in webhelp;

http://forums.adobe.com/message/378004#378004

Not being a scripter myself, I was kind of hoping there was an easier way than messing with the js file as described in that post.  Any chance anyone knows a better way?

Chris

    This topic has been closed for replies.
    Correct answer Willam van Weelden

    Hi,

    I want to give it one last try. Please email me at contact [at] wvanweelden [dot] eu and I can send you a modified file that works in my projects.

    Greet,

    Willam


    I send the modified whthost.js file and that worked. The modified file can now be downloaded on my site via the link in the previous post.

    Greet,

    Willam

    1 reply

    Willam van Weelden
    Inspiring
    March 17, 2011

    Hi,

    Not that I can think of. But you can just igonre the discussion and follow the three steps in the last post. For the nobr-tags, just do a find and replace on "<nobr>" and "</nobr>" and replace them with nothing.

    Also note that the whthost.js is overwritten every time you generate your project. You best make a copy of the modified file and paste it in your output.

    Greet,

    Willam

    KoprivaAuthor
    Known Participant
    March 17, 2011

    wow - thanks William!

    Both those things are good to know!

    Chris

    Willam van Weelden
    Inspiring
    March 21, 2011

    Wow - SOOOOO CLOSE!

    The topic wrapping is working great - but I have three quick tweaks I need to make:

    1. Can I get the wrapped text to left align under the first line?  You can see in the image below that the second line wraps under the topic image, rather than the first line.  I tried to remove the topic image, but the skin editor doesn't let me leave that option blank.  I thought I'd get sneaky and use a "white space" image - but that had the same wrapping issue.
    2. Can I wrap the BOOK text too, like the topic text?  (Is it elsewhere in the whthost file?)
    3. Less important - is the a way to bold or otherwise highlight the currently selected topic?

    This is what I'm trying to accomplish:

    This is where I'm at:


    Hi,

    I did a little fidgeting and this is what I found:

    - Do NOT simply delete all nobr-tags. The script uses these tags to make the TOC work. Removing them will (partly) break your TOC! Please ignore my comment in the previous post!

      1. You can. This however also means that if you the TOC is small enough, a line with a single word can be wrapped. To get this, open whthost.js and replace the function writeAnItem with the following code:

    function writeAnItem(nIdx)
    {
        var sTarget=_textToHtml_nonbsp(getTopicTarget(nIdx));
        var sIcon=getItemIcon(nIdx,0);
        if(sIcon=="")
        {
            var nItemType=getItemType(nIdx);
            if(nItemType&2)
                sIcon=getItemImage(nIdx,false);
            else
                sIcon=getItemImage(nIdx,true);
        }
        sIcon=_textToHtml_nonbsp(sIcon);
        var sName=_textToHtml(getItemName(nIdx));
       
        var sHTML="<p style=\"margin-left: 15px; text-indent: -15px;\">"+
                  "<img alt=\""+sAltString+"\" src=\""+sIcon+"\" border=0 align=\"absmiddle\"> "+
                  "<a id=\""+getItemId(nIdx)+"\" onfocus =\"markItem("+nIdx+");\" onclick=\"markItem("+nIdx+");\""
                 
        var sAltString="";
        if(nItemType&2)
            sAltString="Pagina";
        else
            sAltString="Remote pagina";
        if(sTarget!="")
            sHTML+="target=\""+sTarget+"\" ";
        sHTML+="href=\""+_textToHtml_nonbsp(getItemURL(nIdx))+"\" title=\""+sName+"\">"+sName.replace(/( )/g, " ")+"</a></p>";
        return sHTML;
    }

    Note: the margin left and the text-indent should be as wide as your image and any white space you want for the second line. In this case, my image was 13px width, so I set the margin to 15px.

    In your case, I can imagine you don't want images for topics at all. In that case, simply remove the text "<img alt=\""+sAltString+"\" src=\""+sIcon+"\" border=0 align=\"absmiddle\">" and the style attribute from the paragragh in the above function.

    2. Probably, but that's gonna be a real pain. Simple deleting all nobr-tags as I said in a previous post will break the TOC. Getting your wish done, will require some more serious rewriting of the script. I don't have the time to play around with that now, sorry.

    3. Yes, that also requires some scripting. See http://www.wvanweelden.eu/robohelp/webhelp/skinwebhelp/highlight_toc. You will need the JS fontWeight option.

    Greet,

    Willam