/* $Id: toggle-r-sidebar.js, v 1.0 2008/09/03 21:37:21 quiptime Exp $ */ if (Drupal.jsEnabled) { var toggleHeight, mainWidth; var COOKIE_NAME = 'ToggleSB'; function getToggleHeight() { var toggleH = $("#wrapper").height() - $("#header").height() - 6; toggleHeight = toggleH + "px"; } function setToggleHeight() { getToggleHeight(); $("#toggle").height(toggleHeight); } function getMainWidth() { mainWidth = $(".main").width(); mainWidth = mainWidth + 19; } function setMainWidth() { getMainWidth(); $("#toggle").css("left", mainWidth); } function manageCookie() { if ( $(".main").hasClass("main-big") ) { $.cookie(COOKIE_NAME, 'collapsed', { expires: 30, path: '/' }); } else { $.cookie(COOKIE_NAME, null, { path: '/' }); } } function getCookieInfo() { if ($.cookie(COOKIE_NAME) == "collapsed") { toggleSidebar(); } } function toggleSidebar() { $("#sidebar-right").toggle(); $("#toggle").toggleClass("toggle-highlight"); $("#sidebar-right").toggleClass("collapsed"); $(".main").toggleClass("main-normal").toggleClass("main-big"); manageCookie(); setMainWidth(); } getCookieInfo(); setMainWidth(); setToggleHeight(); $(window).resize( function() { setMainWidth(); setToggleHeight(); } ); $("#toggle").mousemove( function(e) { $("#toggle-arrow").css("left", e.pageX).css("top", e.pageY); } ); $("#toggle").click( function() { toggleSidebar(); setToggleHeight(); setMainWidth(); } ); $("#toggle").mouseover( function() { $("#toggle-arrow").toggle(); } ); $("#toggle").mouseout( function() { $("#toggle-arrow").toggle(); } ); }