This script/stylesheet is for PERSONAL use only!
You are free to install this script/stylesheet for yourself, but it is not allowed to be used wiki-wide (e.g., in MediaWiki:ImportJS, MediaWiki:Common.js, MediaWiki:Common.css, MediaWiki:Fandomdesktop.js, MediaWiki:Fandomdesktop.css, or MediaWiki:FandomMobile.css), as it would violate Fandom's Terms of Use.
(See the customization policy)
CollapseGlobalNavButton is a script that adds a button to the global navigation to collapse it. The collapsed global navigation only shows the preferences dropdown and the notifications section. This script is compatible with the following:
Installation
Optionally, you may want to install the stylesheet too as the stylesheet is dynamically loaded. If you are using OldWikiaBar, you need to install another stylesheet called CollapseGlobalNavButton.css/compatibility.css.
Other script compatibility stylesheet
Extending
If you want to hook into the collapse/uncollapse event of this script, you can use the dev.cgnb.change hook or if you want to listen for when the collapsing animation is done you can use dev.cgnb.changeend. For example:
// This fires when the button is clicked
mw.hook('dev.cgnb.change').add(function(collapsed) {
// `collapsed` is the state of the global navigation - True if collapsed, false if not
// You can now use `collapsed`
});
// This fires when the collapsing animation is done
mw.hook('dev.cgnb.changeend').add(function(collapsed) {
// `collapsed` is the state of the global navigation - True if collapsed, false if not
// You can now use `collapsed`
});
There's also a loaded event called dev.cgnb.loaded:
mw.hook('dev.cgnb.loaded').add(function() {
// You can now click on the global navigation collapse button
});
If you just want a pure CSS class, you can use the body.global-navigation-collapsed class.
Future updates
- Integration with any scripts that modify the global navigation.
- Support for EmeraldGlobalNav.