MediaWiki:Gadget-MobileScript.js: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 31: Line 31:
}
}
}
}
});
/* 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);
});
});