FANDOM


This is the talk page for discussing improvements to the ToggleSideBar page.

Permanently toggle

When you reload the page or go to a different page, the sidebar returns. You have to toggle it each time, which is irritating.

Would it be possible to make it toggle the sidebar until you actually click the button again?[Template fetch failed for https://community.fandom.com/wiki/Template:papi?action=raw] 02:27, September 11, 2016 (UTC)

Yes, enter
#WikiaRail { display: none; }
#WikiaMainContent { width: 100%; }
into your CSS. -- Cube-shaped garbage can 21:39, September 12, 2016 (UTC)
Thanks, but that’s not what I want to do. I want the button to disable the sidebar, but I want to be able to enable it again when I press the button again.[Template fetch failed for https://community.fandom.com/wiki/Template:papi?action=raw] 21:40, September 12, 2016 (UTC)
Maybe set it with a cookie?
$(function() {
    var i18n = {
        /* Add translations here */
        en: "Toggle side bar",
        es: "Mostrar/ocultar la barra lateral",
        sr: "Прикажи/сакриј бочну траку",
        'sr-el': "Prikaži/sakrij bočnu traku"
        /* Stop adding translations here */
    }, lang = mw.config.get('wgUserLanguage');
 
    if($("#WikiaRail").length === 0 || $("#ToggleSideBarButton").length > 0) {
        return;
    }
    $("#WikiHeader .buttons").append(mw.html.element("button", {
        class: "wikia-menu-button secondary",
        id: "ToggleSideBarButton"
    }, (i18n[lang] || i18n[lang.split("-")[0]] || i18n.en)));
    $("#ToggleSideBarButton").click(function() {
        if($("#WikiaRail").css("display") === "block") {
            $("#WikiaRail").fadeToggle("slow", null, function() {
                $("#WikiaMainContent").animate({width: "100%"}, "slow");
            });
            document.cookie = 'sidebartoggled=1;expires=Fri, 01 Jan 2038 03:00:00 GMT';
        } else {
            $("#WikiaMainContent").animate({width: ($("#WikiaPage").width() - 320) + "px"}, "slow", null, function() {
                $("#WikiaRail").fadeToggle();
            });
            document.cookie = 'sidebartoggled=0;expires=Fri, 01 Jan 2038 03:00:00 GMT';
        }
    });
    var m = document.cookie.match(/sidebartoggled=(\d)/);
    if (m && m[1] == '1')
        $("#ToggleSideBarButton").click();
});
-- Dorumin 20:09, September 13, 2016 (UTC)


Thanks! My only issue about this is that it loads the sidebar for a second before it disappears and the page size increases.
This doesn’t happen when I permanently hide it with the code KockaAdmiralac suggested. I don’t know if a solution for this is possible, though.[Template fetch failed for https://community.fandom.com/wiki/Template:papi?action=raw] 07:52, September 14, 2016 (UTC)
I'm late for the party but my code doesn't hide it permanently. It can be unhidden with the button, unless you use !important in it. That's the solution I've been using long before I've published this script to Dev Wiki, at least. -- Cube-shaped garbage can 20:18, September 25, 2016 (UTC)
Community content is available under CC-BY-SA unless otherwise noted.

Fandom may earn an affiliate commission on sales made from links on this page.

Stream the best stories.

Fandom may earn an affiliate commission on sales made from links on this page.

Get Disney+