MediaWiki:Common.js: Difference between revisions

From Pikipedia, the Pikmin wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 18: Line 18:
}
}
});
});
/* Add autocollapse support to mw-collapsible */
function mwCollapsibleSetup($collapsibleContent) {
var $element, autoCollapseThreshold = 2;
$.each($collapsibleContent, function (index, element) {
$element = $(element);
if ($collapsibleContent.length >= autoCollapseThreshold && $element.hasClass('autocollapse'))
$element.data('mw-collapsible').collapse();
});
}
mw.hook('wikipage.collapsibleContent').add(mwCollapsibleSetup);

Revision as of 02:50, April 11, 2021

/* Any JavaScript here will be loaded for all users on every page load. */

/* Remove mobile title tags on desktop main page */
$(function() {
	if (mw.config.get('wgTitle') === 'Main Page') {
		$('div[id^="mf-"]').each(function(i, obj) {
			$(this).removeAttr('title');
		});
	}
});

/* Add subpages toolbox link on user pages */
$(function() {
	var title = mw.config.get('wgTitle');
	if (mw.config.get('wgCanonicalNamespace') === 'User' && !title.includes('/') && mw.config.get('skin') !== 'timeless') {
		var subpagesLink = '/Special:PrefixIndex/User:' + title + '/';
		mediaWiki.util.addPortletLink('p-tb', subpagesLink, 'User subpages', 't-subpages', 'Subpages of this page');
	}
});