MediaWiki:TextSizeModifier.js
Jump to navigation
Jump to search
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)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* SCRIPT FOR ENLARGING/REDUCING THE TEXT SIZE
*
* Instructions to install in your Wikisource subdomain:
*
* 1) in your MediaWiki:Common.js, add (and translate in your language) the following lines:
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:Base.js&action=raw&ctype=text/javascript');
mw.loader.load('//wikisource.org/w/index.php?title=MediaWiki:TextSizeModifier.js&action=raw&ctype=text/javascript');
self.ws_messages = {
'optlist': 'Display options',
'text_size': 'Text size:',
'enlarge_font': '+',
'reduce_font': '-',
'enlarge_font_tooltip': 'Enlarge the size of the text',
'reduce_font_tooltip': 'Reduce the size of the text'
}
* 2) Add a <div class="textBody"></div> around the text that you want to enlarge/reduce.
* Hint: you can add <div class="textBody"> directly in your header template
* (do not put the closing </div>, it is added by MediaWiki at the end of the page)
*
*
* originally written by User:Candalua for es.wikisource.org
*/
//default size 100% - range is between 50%-200%
fontSize = 100;
function enlargeFont() {
if (fontSize < 200) {
fontSize += 10;
$(".textBody").css("font-size", fontSize +"%");
}
}
function reduceFont() {
if (fontSize > 50) {
fontSize -= 10;
$(".textBody").css("font-size", fontSize +"%");
}
}
if (mw.config.get('wgNamespaceNumber') == 0) {
$(document).ready( function() {
get_optlist();
$('#optlist').append('<li id="text_size"></li>');
$('#text_size').append(ws_msg('text_size'));
$('#text_size').append(' <a href="javascript:void(0)" id="enlarge_font" onclick="enlargeFont()" title="' + ws_msg('enlarge_font_tooltip') + '">' + ws_msg('enlarge_font') + '</a>');
$('#text_size').append(' <a href="javascript:void(0)" id="reduce_font" onclick="reduceFont()" title="' + ws_msg('reduce_font_tooltip') + '">' + ws_msg('reduce_font') + '</a>');
//expand as default
$("#p-displayOptions").removeClass('collapsed').addClass('expanded')
$("#p-displayOptions > div.body").show();
});
}