Announcement

Collapse
No announcement yet.

Collapso 4

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Collapso 4

    Hi,

    Does anyone know if its possible to edit this so that it keeps open on the current expanded view, i.e. if I click on household > Scourers, it stays on household > etc. At the moment it refreshes when it moves pages...

    I was wondering if I could use a variable, i.e. vCollapsoCurrent with which I could store the current expanded menu and then every time the page refreshes it would look at that and open it up?

    Thanks,
    Paul.

    #2
    I looked at this and gave up as it would take a lot of work. Perhaps someone else with a lot of time on their hands...
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Hi Norman,

      I just got it working (literally just now so havent tested it fully)... I did it like this, using a cookie as below. Not tested yet with things like cookie blocker etc...

      I started by thinking maybe I could divide the main function up into subsections, and then depending upon a given value (i.e. from the cookie) as it builds it, it would open the correct section. I found this was easier!!

      Need to think about how quickly it loads etc, but it _seems_ to be ok and also might make it so that it is a session only cookie and also make it so that it does subsub as well.

      Its on anything-goes.co.uk if you want to see it. (This might not work, as I forgot to check for null in the cookie (i.e. not used, so don't run the extra script to open it up automatically). Will do this tomorrow.

      Paul.

      P.S. Off to bed now it works .




      in Collapso-4.js

      Code:
      function getCookieVal (offset) {
      	  var endstr = document.cookie.indexOf (";", offset);
      	  if (endstr == -1)
      		endstr = document.cookie.length;
      	  return unescape(document.cookie.substring(offset, endstr));
      	}
      
      function GetCookie (name) {
      	  var arg = name + "=";
      	  var alen = arg.length;
      	  var clen = document.cookie.length;
      	  var i = 0;
      	  while (i < clen) {
      		var j = i + alen;
      		if (document.cookie.substring(i, j) == arg)
      		  return getCookieVal (j);
      		i = document.cookie.indexOf(" ", i) + 1;
      		if (i == 0) break; 
      	  }
      	  return null;
      	}
      	
      function SetCookie (name, value) {
      	  var argv = SetCookie.arguments;
      	  var argc = SetCookie.arguments.length;
      	  var expires = (argc > 2) ? argv[2] : null;
      	  var path = (argc > 3) ? argv[3] : null;
      	  var domain = (argc > 4) ? argv[4] : null;
      	  var secure = (argc > 5) ? argv[5] : false;
      	  document.cookie = name + "=" + escape (value) +
      		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
      		((path == null) ? "" : ("; path=" + path)) +
      		((domain == null) ? "" : ("; domain=" + domain)) +
      		((secure == true) ? "; secure" : "");
      	}
      and in the showsubmenu function, added a bit to set the cookie:

      Code:
      function showSubMenu(n){
        //collapse currently displayed submenu
        SetCookie("anything-goes.co.uk_MenuValue", n);
        if (autocollapse && (menuState >= 0))
          {
          // collapse submenu
          document.getElementById("Header" + menuState).className = "hideObject";
          // hide heading
          document.getElementById("SubMenu" + menuState).className = "hideObject";
          // show Menu item
          document.getElementById("Item" + menuState).className = "showObject";
          }
        // turn off Menu item
        document.getElementById("Item" + n).className = "hideObject";
        // turn on Menu header
        document.getElementById("Header" + n).className = "showObject";
        // expand submenu
        document.getElementById("SubMenu" + n).className = "showObject";
        menuState = n;
      }
      then all I needed to do was edit the menu calling bit in act_primary (etc.) so that after the menu is built, it runs the showsubroutine for the given value in the cookie:

      Code:
       <script language=Javascript1.2>
        <!--
        document.write(YahooSections(section_tree));
        //--> 
        </script>
        <script>
          showSubMenu(GetCookie("anything-goes.co.uk_MenuValue"));
        </script>
      Last edited by PaulGrimshaw; 09-Mar-2006, 12:28 AM. Reason: Just Realised

      Comment

      Working...
      X