2 Replies Latest reply on Jun 18, 2009 2:19 AM by Mark Pud

    Auto expand drop downs - extended to nested drop downs

    Mark Pud

      Hi all,

       

      I have been looking today at Peter Grainge's script for auto-expanding a drop down text section when called from a link (ref http://www.grainge.org/pages/authoring/autoexpand/auto_expand_method_2.htm)

       

      I first of all can confirm that this works in RH8, although the script calls two standard "kadov" functions which have been replaced, but Adobe were kind enough to handle instances of these being called, and direct them to the new non-kadov scripts instead. But the following section can be updated

       

      from:

      function openlink(){y=window.location.hash.substring(1);
      if (!y) return; 
      x=document.getElementById(y);
      kadovTextPopupOnLoad(x);
      kadovTextPopup(x);
      }
      

      to:

      function openlink(){
      y=window.location.hash.substring(1);
      if (!y) return; 
      x=document.getElementById(y);
      TextPopupOnLoad(x);
      TextPopup(x);
      }
      

      ...to remove the Kadov refs.

       

      What I wanted to do with this was to have a way of opening up drop down text that is nested within other drop down text sections on the page. To achieve this I've modified the function as follows:

      function openlink()
      {
       substr=window.location.hash.substring(1);
       posn=substr.indexOf("#"); //finds if there is more than one #
       if (posn == -1)
        {
         y = substr;
        }
       while (posn > -1)
        {
        var temp = new Array();
        temp = substr.split('#'); //splits the URL #ID variables into array items
        y = temp[0];
        z = temp[1];
        v = temp[2];
        posn = posn-1;
        };
       if (!y) return; 
       x=document.getElementById(y);
       TextPopupOnLoad(x);
       TextPopup(x);
       if (!z) return;
       w=document.getElementById(z);
       TextPopupOnLoad(w);
       TextPopup(w);
       if (!v) return;
       u=document.getElementById(v);
       TextPopupOnLoad(u);
       TextPopup(u);
      }
      

      What this allows is for a link to call the page and define up to 3 levels of nested drop downs to be opened, identifying them via their ID's, e.g.

      page.htm#id1#id2#id3
      

      This works nicely in my initial testing, and I wanted to share it here for feedback and suggestions for improvement etc.. I'm not certain my code design is the most efficient, but it does the job!

       

      The only downside is that using this script causes the "twisties" images to dissapear! If someone can figure out how to save the twisties from extinction that would be very much appreciated!! I'm guessing it's to do with the function "TextPopUpOnLoad", if I compare this with "TextPopUp" I can see that the latter has some code for dealing with the twistie images....

       

      Thanks,

       

      Mark

       

      Message was edited by: Mark Pud - "insert raw html" option is horrible, changed to "highlight java"..