MediaWiki:Mobile.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.
/* Mobile Menu */
var timer = setInterval(function() {
if ($('.menu ul:first').length) {
//console.log("mobile menu exists");
clearInterval(timer);
$.get('/customizations/mobilemenu.htm', function(data){
$('.menu ul:first').after(data);
});
$(".menu").find(".level2").hide(); // hide level2 until level1 is clicked
$(".level1").click(function(event){
$(this).find(".level2").slideToggle(500);
}); // if level1 is clicked, dropdown level2
}
}, 100); // check every 100ms
/* Tooltip */
$(".popup").click(function () {
var $title = $(this).find(".title");
if (!$title.length) {
$(this).append('<span class="title">' + $(this).attr("title") + '</span>');
} else {
$title.remove();
}
});
// Creates action=raw links for JS or CSS gadgets
// Useful for mw.loader.load, which doesn't accept page titles
function rawPageLink( pageName ) {
return mw.config.get( 'wgServer' ) + mw.config.get( 'wgScript' ) + '?title=' + mw.util.wikiUrlencode(pageName) + '&action=raw&ctype=text/javascript';
}
// Overwriting deprecated functions that don't have an exact followup but can be easily mapped:
window.importScript = function ( page ) {
if ( typeof page === 'string' && page.length ) {
mw.loader.load( rawPageLink( page ) );
}
};