FANDOM


m (Better double run protection, element caching, jQueryfying, change 320 to 330 because it was looking weird for me on 320)
m (It's not #WikiaPage's width that matters)
Line 30: Line 30:
 
});
 
});
 
} else {
 
} else {
$wrapper.animate({ width: ($('#WikiaPage').width() - 330) + 'px' }, 'slow', null, function() {
+
$wrapper.animate({ width: ($('.WikiaPageContentWrapper').width() - 330) + 'px' }, 'slow', null, function() {
 
$rail.fadeToggle();
 
$rail.fadeToggle();
 
});
 
});

Revision as of 07:09, July 15, 2017

/**
 * Name:        ToggleSideBar
 * Author:      KockaAdmiralac <1405223@gmail.com>
 * Description: Adds a button for toggling the side bar
 */
(function() {
    var $rail = $('#WikiaRail'),
        $wrapper = $('#WikiaMainContent');
    if(!$rail.exists() || window.ToggleSideBarLoaded) {
        return;
    }
    window.ToggleSideBarLoaded = true;
    if(typeof window.dev === 'undefined' || typeof window.dev.i18n === 'undefined') {
        // Importing I18n-js library
        importArticle({ type: 'script', article: 'u:dev:MediaWiki:I18n-js/code.js' });
    }
    mw.hook('dev.i18n').add(function(i18no) {
        i18no.loadMessages('ToggleSideBar').done(function(i18n) {
            i18n.useUserLang();
            $('<a>', {
                'class': 'wds-button wds-is-squished wds-is-secondary',
                id: 'toggle-side-bar-button',
                text: i18n.msg('toggle').escape()
            })
                .appendTo(window.ToggleSideBarSelector || '.page-header__contribution-buttons')
                .click(function() {
                    if($rail.css('display') === 'block') {
                        $rail.fadeToggle('slow', null, function() {
                            $wrapper.animate({ width: '100%' }, 'slow');
                        });
                    } else {
                        $wrapper.animate({ width: ($('.WikiaPageContentWrapper').width() - 330) + 'px' }, 'slow', null, function() {
                            $rail.fadeToggle();
                        });
                    }
                });
            mw.hook('ToggleSideBar.loaded').fire();
        });
    });
})();
Community content is available under CC-BY-SA unless otherwise noted.