User:RERM/vector.js

/* _____________________________________________________________________________ * |                                                                             | * |                    === WARNING: GLOBAL GADGET FILE ===                      | * |                 Changes to this page affect many users. | * | Please discuss changes on the talk page or on WT:Gadget before editing. | * |_____________________________________________________________________________| * * Imported from revision 365211954 as of 2010-06-01 from User:Nihiltres/nothingthree.js * It has had some modification from that version to isolate it within the script collection and further improve it. * * Collapses/expands the sidebar of the Vector skin, see User:Nihiltres/nothingthree */ nothingthreeSidebarSubset = { settings: {sidebarCollapsed: false, sidebarAnimationDuration: 400}, cookie: { set: function (value) { var date, expires; date = new Date; date.setTime(date.getTime + (365 * 864E5)); expires = "; expires=" + date.toGMTString; document.cookie = "sidebarCollapsed=" + value + expires + "; path=/"; },       get: function  { var nameEQ, ca, i, c;           nameEQ = "sidebarCollapsed="; ca = document.cookie.split(';'); for (i = 0; i < ca.length;i++) { c = ca[i]; while (c.charAt(0) === ' ') {c = c.substring(1, c.length);} if (c.indexOf(nameEQ) === 0) {return c.substring(nameEQ.length, c.length);} }           return null; }},   collapse: function (sidebarAnimationDuration) { if ($.browser.msie) {$("#mw-panel").animate({left: "-10em"}, {duration: sidebarAnimationDuration, complete: function {document.getElementById("mw-panel").style.visibility = "hidden";}});} else {$("#mw-panel").animate({opacity: 0, left: "-10em"}, {duration: sidebarAnimationDuration, complete: function {document.getElementById("mw-panel").style.visibility = "hidden";}});} $("#content, #mw-head-base, #footer").animate({marginLeft: 0}, {duration: sidebarAnimationDuration, complete: function {document.getElementById("content").style.backgroundImage = "none";}}); $("#left-navigation").animate({left: "1em"}, {duration: sidebarAnimationDuration}); nothingthreeSidebarSubset.cookie.set("collapsed"); nothingthreeSidebarSubset.settings.sidebarCollapsed = true; },   expand: function (sidebarAnimationDuration) { $("#mw-panel").css({"visibility": ""}); if ($.browser.msie) {$("#mw-panel").animate({left: "-0.01em"}, {duration: sidebarAnimationDuration, complete: function {$("#mw-panel").css("left", "0em");}});} else {$("#mw-panel").animate({opacity: 1, left: 0}, {duration: sidebarAnimationDuration});} document.getElementById("content").style.backgroundImage = ""; $("#content, #mw-head-base, #footer").animate({marginLeft: "10em"}, {duration: sidebarAnimationDuration}); $("#left-navigation").animate({left: "10em"}, {duration: sidebarAnimationDuration}); nothingthreeSidebarSubset.cookie.set("expanded"); nothingthreeSidebarSubset.settings.sidebarCollapsed = false; },   toggle: function  { if (nothingthreeSidebarSubset.settings.sidebarCollapsed) {nothingthreeSidebarSubset.expand(nothingthreeSidebarSubset.settings.sidebarAnimationDuration);} else {nothingthreeSidebarSubset.collapse(nothingthreeSidebarSubset.settings.sidebarAnimationDuration);} },   toggleTab: function  { if ($("#ca-sidebar").length > 0) {return;} $("#p-personal").before($('Toggle sidebar').click(nothingthreeSidebarSubset.toggle)); $("#mw-panel").css("top", "190px"); },   remember: function  { if (nothingthreeSidebarSubset.cookie.get == "collapsed") {nothingthreeSidebarSubset.collapse(0);} } }; if (skin === "vector") { $(function {        nothingthreeSidebarSubset.toggleTab;        nothingthreeSidebarSubset.remember;    }); }