MediaWiki:Gadget-GlobalScript.js

/* Any JavaScript here will be loaded for all skins on both desktop and mobile */

/* Fix media negative margin bug for wide galleries */ $(function {	$('.gallerybox audio').each(function(i, obj) { if ($(this).parent.css('margin-top') < '15px') $(this).parent.css('margin', '15px auto'); }); });

/* 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);

/* Add disclaimer and URL to copied article text for newbies */ $(function {	if (mw.config.get('wgAction') === 'view' && mw.config.get('wgNamespaceNumber') === 0 && !mw.config.get('wgUserGroups').includes('autoconfirmed')) {		$('#mw-content-text').on('copy', function(e) { var text = window.getSelection.toString; if (text.length > 100) { var notice1 = 'The above text is from the Super Mario Wiki and is available under a Creative Commons license.'; var notice2 = 'Attribution must be provided through a list of authors or a link back to the original article.'; var articlePath = mw.config.get('wgArticlePath').replace('$1', encodeURIComponent(mw.config.get('wgPageName'))); var url = mw.config.get('wgServer') + articlePath; text = text.concat('\n\n' + notice1 + ' ' + notice2 + ' Source: ' + url); e.originalEvent.clipboardData.setData('text/plain', text); e.preventDefault; }		});	} });