MediaWiki:Gadget-MobileScript.js: Difference between revisions

m
no edit summary
No edit summary
mNo edit summary
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* Any JavaScript here will be loaded for users of the mobile site */
/* Any JavaScript here will be loaded for users of the mobile site */
/* Expand single talk section */
$(function() {
setTimeout(function() {
if ($('.ns-talk .collapsible-heading').length === 1)
$('.collapsible-heading:not(.open-block)').click();
}, 100);
});


/* Collapse boxes on smaller devices */
/* Collapse boxes on smaller devices */
Line 14: Line 22:
if (mw.config.get('skin') === 'timeless') {
if (mw.config.get('skin') === 'timeless') {
var optionsLink = '/Special:MobileOptions';
var optionsLink = '/Special:MobileOptions';
mediaWiki.util.addPortletLink('p-tb', optionsLink, 'Mobile options', 't-options', 'Options for the mobile site');
var optionsDesc = 'Settings for the mobile site';
mw.util.addPortletLink('p-tb', optionsLink, 'Mobile options', 't-options', optionsDesc);
}
}
});
});
Line 30: Line 39:
}
}
}
}
});
/* Adjust table of contents to fit with infobox */
$(function() {
var body = $('#bodyContent');
var infobox = $('.infobox');
if (infobox) {
    var maxWidth = Math.round(body.width() - infobox.outerWidth(true) - 10);
    $('head').append('<style type="text/css">.toc-mobile { max-width: ' + maxWidth + 'px; }</style>');
}
});
function tocResizer() {
var body = $('#bodyContent');
var infobox = $('.infobox');
var toc = $('.toc-mobile');
if (infobox && toc) {
    var maxWidth = Math.round(body.width() - infobox.outerWidth(true) - 10);
    toc.css('max-width', maxWidth);
}
}
$(window).resize(function() {
$(tocResizer);
});
});