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
- $(document).ready(function () {
- var f = true;
- var g = true;
- var h = true;
- var i = {
- handles: 'e',
- minWidth: 70,
- maxWidth: 70,
- resize: function (a, b) {
- var w = $(this).width() + 10;
- $("#content").css("marginLeft", w + "px").parent().css("marginLeft", "-" + w + "px");
- windowResize();
-
- }
- };
- $("#sidebar").resizable(i);
-
- var j = $("<a/>", {
- id: 'stoggle',
- css: {
- top: (($("body").height() + $(window).scrollTop() - 63) / 2) + "px"
- }
- });
- $("#sidebar").append(j);
- $("#stoggle").toggle(function () {
- var w = $("#sidebar").width();
- $("#sidebar").css("width", 0).resizable("destroy").data("width", w);
- $(this).addClass("active").css("right", 0).wrap($("<div/>", {
- css: {
- display: 'block',
- 'font-size': '0.1px',
- position: 'absolute',
- zIndex: '9999',
- height: '100%',
- right: '0px',
- top: '0',
- width: '6px'
- }
- }));
- $("#content").css("marginLeft", "10px").parent().css("marginLeft", "-10px");
- $("#sbcont").hide();
- return false
- }, function () {
- var w = parseFloat($("#sidebar").data("width"));
- $("#stoggle").css("right", "0px").unwrap();
- $("#sidebar").resizable(i).css("width", w + "px");
- $(this).removeClass("active");
- var a = $("#sidebar").width();
- $("#content").css("marginLeft", (a + 10) + "px").parent().css("marginLeft", "-" + (a + 10) + "px");
- $("#sbcont").show();
- return false
- });
- windowResize();
- $(window).bind("resize", windowResize);
- $("#content").resize(windowResize);
- if (!h) {
- var n = $(window),
- bodyHeight = $("body").height();
- n.bind("scroll", function () {
- var a = n.scrollTop();
- if (a + $("body").height() < $("#wrapper").height()) $("#stoggle").stop().animate({
- top: a + (bodyHeight - 63) / 2
- });
- else $("#stoggle").stop().animate({
- top: a - $("#footer").outerHeight() + (bodyHeight - 63) / 2
- })
- })
- }
- $('a.minibutton').bind({
- mousedown: function () {
- $(this).addClass('mousedown')
- },
- blur: function () {
- $(this).removeClass('mousedown')
- },
- mouseup: function () {
- $(this).removeClass('mousedown')
- }
- });
- $("#tooltip").live("mouseover", function () {
- $(this).remove()
- });
-
- });
- function windowResize() {
- var a = $("#wrapper"),
- wrapheight = $("#wrapper").height(),
- contheight = $("#page-body .container").height(),
- sbcontHeight = $("#sbcont").outerHeight();
- if (contheight < sbcontHeight) contheight = sbcontHeight;
- if ($("body").height() >= contheight + $("#footer").outerHeight()) {
- var b = $("body").height() - $("#footer").outerHeight();
- a.css("min-height", b);
- $("#sidebar").css({
- "min-height": b
- })
- } else $("#sidebar").css({
- "min-height": contheight
- });
- }
Thanks.
Matt