User:Dennis J au/vector.js
Appearance
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
window.popupStructure = 'lite';
/**
* Add an experimental fontsizer applet to the Tools menu.
*
* @dependencies: mediawiki.cookie
* @source: [[User:Edokter/FontSizer.js]] / [[User:Edokter/FontSizer.css]]
* @revision 3.1
* @author: Edokter ([[User:Edokter]])
**/
/* Load dependencies (remove when loading through ResourceLoader) */
/*importStylesheetURI( '//en.wikipedia.org/w/index.php?title=User:Edokter/FontSizer.css&action=raw&ctype=text/css' ); */
mw.loader.using( 'mediawiki.cookie', function() {
/* Begin of mw.loader.using callback */
$( document ).ready( function() {
var fontsizerButtons =
'<li id="t-fontsizer">' +
'<input type="submit" id="t-fontsizer-minus" name="minus" title="Decrease fontsize [alt--]" accesskey="-" value="−">' +
'<input type="submit" id="t-fontsizer-reset" name="reset" title="Reset fontsize [alt-0]" accesskey="0" value="100%">' +
'<input type="submit" id="t-fontsizer-plus" name="plus" title="Increase fontsize [alt-+]" accesskey="+" value="+">' +
'</li>';
var bodyStyle = document.getElementsByTagName( 'body' )[0].style;
function getSize() {
return parseInt( bodyStyle.fontSize.replace( '%', '' ) );
}
function setSize( size ) {
bodyStyle.fontSize = size == 100 ? '' : size + '%';
mw.cookie.set( 'fontSizer.size', size == 100 ? null : size, { expires: 30, path: '/' } );
$( '#t-fontsizer-reset' ).attr( 'value', size + '%' );
}
/* Initialize */
$( '#p-tb' ).find( 'ul' ).prepend( fontsizerButtons );
var cookie = mw.cookie.get( 'fontSizer.size' );
if ( cookie ) {
setSize( cookie );
}
$( '#t-fontsizer-minus' ).click( function() {
var newSize = getSize();
if ( !newSize ) {
newSize = 100;
}
if ( newSize > 50 ) {
newSize <= 100 ? newSize -= 5 : newSize -= 10;
}
setSize( newSize );
});
$( '#t-fontsizer-plus' ).click( function() {
var newSize = getSize();
if ( !newSize ) {
newSize = 100;
}
if ( newSize < 200 ) {
newSize < 100 ? newSize += 5 : newSize += 10;
}
setSize(newSize);
});
$( '#t-fontsizer-reset' ).click( function() {
setSize( 100 );
});
});
/* End of mw.loader.using callback */
} );
/* DO NOT ADD CODE BELOW THIS LINE */