Gadget:PageTools.js
Ir para navegação
Ir para pesquisar
// Stop MediaWiki from automatically collapsing our tools.
mw.loader.using('skins.vector.legacy.js').then(function() {
if ($.collapsibleTabs) {
$.collapsibleTabs.calculateTabDistance = function() {
return Infinity;
};
}
});
// Move all previously hidden tools under the Edit dropdown.
$('#ca-history, #ca-watch, #ca-unwatch')
.prependTo('#p-cactions .menu')
.removeClass('collapsible');
// Let users show and hide navigation on mobile.
$('#p-NAVIGATION').click(function() {
$('#mw-panel .mw-portlet').toggleClass('shown');
});
$('#p-lang').appendTo('#right-navigation');
// Move the page tools to vertically align with the header.
setInterval(function() {
'use strict';
var isMobile = window.matchMedia &&
window.matchMedia('screen and (max-width: 720px)').matches;
var $title = $('#firstHeading');
var $content = $('#content');
var $navigation = $('#mw-panel');
var $buttons = $('#mw-head');
var headingTop = $title.position().top;
var headingBottom = headingTop + $title.height();
var buttonsTop = $buttons.position().top;
var currentMarginTop = Number($content.css('margin-top').slice(0, -2));
var currentMarginBottom = Number($navigation.css('margin-bottom').slice(0, -2));
var diff;
if (isMobile) {
diff = headingBottom - buttonsTop - 16;
$content.css('margin-top', (currentMarginTop - diff) + 'px');
$navigation.css('margin-bottom', (currentMarginBottom + diff) + 'px');
} else {
diff = headingTop - buttonsTop;
$content.css('margin-top', (currentMarginTop - diff) + 'px');
$navigation.css('margin-bottom', (currentMarginBottom + diff) + 'px');
}
}, 10);