Collapsible Div

Collapsible Div

Hello,
I'm trying to implement a collapsible sidebar. I got a script for this and its working fine.
But the side bar is expanded at the page load and  I need the div to be collapsed at the page load.
How can I fix this ?

Here is the custom.js code
  1. $(document).ready(function () {
  2.     var f = true;
  3.     var g = true;
  4.     var h = true;

  5.     var i = {
  6.         handles: 'e',
  7.         minWidth: 70,
  8.         maxWidth: 70,
  9.         resize: function (a, b) {
  10.             var w = $(this).width() + 10;
  11.             $("#content").css("marginLeft", w + "px").parent().css("marginLeft", "-" + w + "px");
  12.             windowResize();
  13.             
  14.         }
  15.     };
  16.     $("#sidebar").resizable(i);
  17.     var j = $("<a/>", {
  18.         id: 'stoggle',
  19.         css: {
  20.             top: (($("body").height() + $(window).scrollTop() - 63) / 2) + "px"
  21.         }
  22.     });
  23.     $("#sidebar").append(j);
  24.     $("#stoggle").toggle(function () {
  25.         var w = $("#sidebar").width();
  26.         $("#sidebar").css("width", 0).resizable("destroy").data("width", w);
  27.         $(this).addClass("active").css("right", 0).wrap($("<div/>", {
  28.             css: {
  29.                 display: 'block',
  30.                 'font-size': '0.1px',
  31.                 position: 'absolute',
  32.                 zIndex: '9999',
  33.                 height: '100%',
  34.                 right: '0px',
  35.                 top: '0',
  36.                 width: '6px'
  37.             }
  38.         }));
  39.         $("#content").css("marginLeft", "10px").parent().css("marginLeft", "-10px");
  40.         $("#sbcont").hide();
  41.         return false
  42.     }, function () {
  43.         var w = parseFloat($("#sidebar").data("width"));
  44.         $("#stoggle").css("right", "0px").unwrap();
  45.         $("#sidebar").resizable(i).css("width", w + "px");
  46.         $(this).removeClass("active");
  47.         var a = $("#sidebar").width();
  48.         $("#content").css("marginLeft", (a + 10) + "px").parent().css("marginLeft", "-" + (a + 10) + "px");
  49.         $("#sbcont").show();
  50.         return false
  51.     });
  52.     windowResize();
  53.     $(window).bind("resize", windowResize);
  54.     $("#content").resize(windowResize);
  55.     if (!h) {
  56.         var n = $(window),
  57.             bodyHeight = $("body").height();
  58.         n.bind("scroll", function () {
  59.             var a = n.scrollTop();
  60.             if (a + $("body").height() < $("#wrapper").height()) $("#stoggle").stop().animate({
  61.                 top: a + (bodyHeight - 63) / 2
  62.             });
  63.             else $("#stoggle").stop().animate({
  64.                 top: a - $("#footer").outerHeight() + (bodyHeight - 63) / 2
  65.             })
  66.         })
  67.     }
  68.     $('a.minibutton').bind({
  69.         mousedown: function () {
  70.             $(this).addClass('mousedown')
  71.         },
  72.         blur: function () {
  73.             $(this).removeClass('mousedown')
  74.         },
  75.         mouseup: function () {
  76.             $(this).removeClass('mousedown')
  77.         }
  78.     });
  79.     $("#tooltip").live("mouseover", function () {
  80.         $(this).remove()
  81.     });
  82.     
  83. });

  84. function windowResize() {
  85.     var a = $("#wrapper"),
  86.         wrapheight = $("#wrapper").height(),
  87.         contheight = $("#page-body .container").height(),
  88.         sbcontHeight = $("#sbcont").outerHeight();
  89.     if (contheight < sbcontHeight) contheight = sbcontHeight;
  90.     if ($("body").height() >= contheight + $("#footer").outerHeight()) {
  91.         var b = $("body").height() - $("#footer").outerHeight();
  92.         a.css("min-height", b);
  93.         $("#sidebar").css({
  94.             "min-height": b
  95.         })
  96.     } else $("#sidebar").css({
  97.         "min-height": contheight
  98.     });
  99. }

Thanks.
Matt
    • Topic Participants

    • matt