MediaWiki:Minerva.js: Difference between revisions
From Halopedia, the Halo wiki
(Created page with "→All JavaScript here will be loaded for users of the MinervaNeue skin: →Multi-navbox title: $(function() { $('.navbox-header + section + .navbox-header > .mw-headlin...") |
mNo edit summary |
||
(10 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
/* | /* Any JavaScript here will be loaded for users of the Minerva skin */ | ||
/* | /* Clean-up Unicode search bar */ | ||
$(function() { | $(function() { | ||
$('. | $('body').on('submit', '.overlay .search-box', function() { | ||
$('.overlay .search').val($('.overlay .search').val().replace(/[‘’]/g, "'").replace(/[“”]/g, '"')); | |||
}); | |||
}); | }); | ||
/* Collapse navbox section by default */ | |||
$(function() { | |||
setTimeout(function() { | |||
if ($(window).width() >= 720 && $('.navbox-heading.open-block').length) | |||
$('.navbox-heading').click(); | |||
}, 100); | |||
}); | |||
/* Halopedia: Custom menu */ | |||
$.when(mw.loader.using('mediawiki.util'), $.ready).then(function() { | |||
var rcStyleClasses = ['mw-ui-icon', 'mw-ui-icon-before', 'mw-ui-icon-minerva-recentChanges']; | |||
var rcNode = mw.util.addPortletLink('p-navigation', '/Special:RecentChanges', 'Recent changes').getElementsByTagName('a')[0]; | |||
rcStyleClasses.map(function(x) { rcNode.classList.add(x) }); | |||
var menu = 'p-personal'; | |||
if (mw.config.get('wgUserId')) { | |||
menu = document.getElementById('p-interaction') ? 'p-interaction' : 'p-navigation'; | |||
if (document.getElementById('pt-preferences')) { | |||
var prefStyleClasses = ['mw-ui-icon', 'mw-ui-icon-before', 'mw-ui-icon-wikimedia-userAvatar-base20']; | |||
var prefNode = mw.util.addPortletLink('pt-preferences', '/Special:Preferences', 'Preferences').getElementsByTagName('a')[0]; | |||
prefStyleClasses.map(function(x) { prefNode.classList.add(x) }); | |||
} | |||
} | |||
mw.util.addPortletLink(menu, '/Category:Video_games', 'Games').getElementsByTagName('a')[0]; | |||
mw.util.addPortletLink(menu, '/Category:Products', 'Other media').getElementsByTagName('a')[0]; | |||
mw.util.addPortletLink(menu, '/Category:Gameplay', 'Gameplay').getElementsByTagName('a')[0]; | |||
mw.util.addPortletLink(menu, '/Category:Universe_and_lore', 'The universe').getElementsByTagName('a')[0]; | |||
mw.util.addPortletLink(menu, '/Archive:Main', 'Halopedia Archive').getElementsByTagName('a')[0]; | |||
} ); |
Latest revision as of 21:44, December 18, 2023
/* Any JavaScript here will be loaded for users of the Minerva skin */
/* Clean-up Unicode search bar */
$(function() {
$('body').on('submit', '.overlay .search-box', function() {
$('.overlay .search').val($('.overlay .search').val().replace(/[‘’]/g, "'").replace(/[“”]/g, '"'));
});
});
/* Collapse navbox section by default */
$(function() {
setTimeout(function() {
if ($(window).width() >= 720 && $('.navbox-heading.open-block').length)
$('.navbox-heading').click();
}, 100);
});
/* Halopedia: Custom menu */
$.when(mw.loader.using('mediawiki.util'), $.ready).then(function() {
var rcStyleClasses = ['mw-ui-icon', 'mw-ui-icon-before', 'mw-ui-icon-minerva-recentChanges'];
var rcNode = mw.util.addPortletLink('p-navigation', '/Special:RecentChanges', 'Recent changes').getElementsByTagName('a')[0];
rcStyleClasses.map(function(x) { rcNode.classList.add(x) });
var menu = 'p-personal';
if (mw.config.get('wgUserId')) {
menu = document.getElementById('p-interaction') ? 'p-interaction' : 'p-navigation';
if (document.getElementById('pt-preferences')) {
var prefStyleClasses = ['mw-ui-icon', 'mw-ui-icon-before', 'mw-ui-icon-wikimedia-userAvatar-base20'];
var prefNode = mw.util.addPortletLink('pt-preferences', '/Special:Preferences', 'Preferences').getElementsByTagName('a')[0];
prefStyleClasses.map(function(x) { prefNode.classList.add(x) });
}
}
mw.util.addPortletLink(menu, '/Category:Video_games', 'Games').getElementsByTagName('a')[0];
mw.util.addPortletLink(menu, '/Category:Products', 'Other media').getElementsByTagName('a')[0];
mw.util.addPortletLink(menu, '/Category:Gameplay', 'Gameplay').getElementsByTagName('a')[0];
mw.util.addPortletLink(menu, '/Category:Universe_and_lore', 'The universe').getElementsByTagName('a')[0];
mw.util.addPortletLink(menu, '/Archive:Main', 'Halopedia Archive').getElementsByTagName('a')[0];
} );