13 Replies Latest reply on Mar 23, 2011 10:21 AM by Kopriva

    Wrap TOC text in RH8?

    Kopriva

      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

        • 1. Re: Wrap TOC text in RH8?
          Willam van Weelden Adobe Community Professional & MVP

          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

          • 2. Re: Wrap TOC text in RH8?
            Kopriva Level 1

            wow - thanks William!

             

            Both those things are good to know!

             

            Chris

            • 3. Re: Wrap TOC text in RH8?
              Kopriva Level 1

              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:

               

              toc1.jpg

               

              This is where I'm at:

               

              toc2.jpg

              • 4. Re: Wrap TOC text in RH8?
                Willam van Weelden Adobe Community Professional & MVP

                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

                • 5. Re: Wrap TOC text in RH8?
                  Kopriva Level 1

                  William,

                   

                  Thanks for all of your work.

                   

                  I know you've probably put way too much time into this, but I had a problem with your code in #1 above.  I copied it into whthost, but now when book links are all dead (although I can switch topics WITHIN a book).

                   

                  To be clear, I'm assuming I still want to edit the function writebookitems and remove the width property from tocwritefixedwidth as well, correct?  I've actually tried it both ways - this way and simply copying your code above into a fresh whthost - and it still seems to break.

                   

                  Sorry to be such a pain.

                   

                  Chris

                  • 6. Re: Wrap TOC text in RH8?
                    Willam van Weelden Adobe Community Professional & MVP

                    Hi,

                     

                    Did you remove the old function writeAnItem? Having two functions with the same name will break the script, so first delete the existing function and then add the modified function.

                     

                    As for the second, that would be the way to go.

                     

                    Greet,

                     

                    Willam

                    • 7. Re: Wrap TOC text in RH8?
                      Kopriva Level 1

                      William,

                       

                      I did delete the original writeanitem code.  I even had one of our developers try to help me, and it seems that we remove the <nobr> tags in that writeanitem function at all - even if we copy your code (which doesn't have the <nobr> tags in it) - then we can click and open a book, and we can click a topic - but once we click a topic, the BOOK links die.  Is that not happening when you try this code?

                       

                      Chris

                      • 8. Re: Wrap TOC text in RH8?
                        Willam van Weelden Adobe Community Professional & MVP

                        Guess I didn't try that . Seriously, this is a bit of a pain. Removing the nobr-tags and modifying some functions here and there is quite bothersome. I devised an easier method that should do exactly what you want. See http://www.wvanweelden.eu/robohelp/webhelp/skinwebhelp/wraptoc

                         

                        I tested this with sevaral RH8 projects, but if it doesn't work for you, please post back.

                         

                        Greet,

                         

                        Willam

                        • 9. Re: Wrap TOC text in RH8?
                          Kopriva Level 1

                          William,

                           

                          Well, I give up.  Your instructions were detailed and easy to follow.  I tried them TWICE.  Both times the TOC gave me an error in page message and didn't load at all.  The second time I even skipped the last part about moving the text 16px just to see if I could get the darn thing to wrap.  Still wouldn't load (just showed blank/empty TOC pane).

                           

                          And it is an RH8 project, and the line numbers were spot-on.

                           

                          Forget it - I appreciate all the time you've spent.

                           

                          I'll just have to wait until Adobe decides to add the functionality to RH.

                           

                          Chris

                          • 10. Re: Wrap TOC text in RH8?
                            Willam van Weelden Adobe Community Professional & MVP

                            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

                            • 11. Re: Wrap TOC text in RH8?
                              Willam van Weelden Adobe Community Professional & MVP

                              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

                              • 12. Re: Wrap TOC text in RH8?
                                Captiv8r Adobe Community Professional & MVP

                                Hi there

                                 

                                Kopriva wrote:

                                 

                                I'll just have to wait until Adobe decides to add the functionality to RH.

                                 

                                That isn't likely to happen if they are unaware of the need. You really should consider submitting a Wish Form to ask about it so it's on their radar. Link to the wish form is in my sig.

                                 

                                Cheers... Rick

                                 

                                Helpful and Handy Links

                                RoboHelp Wish Form/Bug Reporting Form

                                Begin learning RoboHelp HTML 7, 8 or 9 within the day!

                                Adobe Certified RoboHelp HTML Training

                                SorcerStone Blog

                                RoboHelp eBooks

                                • 13. Re: Wrap TOC text in RH8?
                                  Kopriva Level 1

                                  Thanks Rick.

                                   

                                  Done.