MediaWiki:Common.js

From Phidgets Support
Revision as of 16:03, 29 July 2021 by Mparadis (talk | contribs)

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.
/**
 * Redirect User:Name/skin.js and skin.css to the current skin's pages
 * (unless the 'skin' page really exists)
 * @source: http://www.mediawiki.org/wiki/Snippets/Redirect_skin.js
 * @rev: 2
 */

if ( mw.config.get( 'wgArticleId' ) == 0 && mw.config.get( 'wgNamespaceNumber' ) == 2 ) {
        var titleParts = mw.config.get( 'wgPageName' ).split( '/' );
        // Make sure there was a part before and after the slash
        // And that the latter is 'skin.js' or 'skin.css'
        if ( titleParts.length == 2 ) {
                var userSkinPage = titleParts.shift() + '/' + mw.config.get( 'skin' );
                if ( titleParts.slice(-1) == 'skin.js' ) {
                        window.location.href = mw.util.wikiGetlink( userSkinPage + '.js' );
                } else if ( titleParts.slice(-1) == 'skin.css' ) {
                        window.location.href = mw.util.wikiGetlink( userSkinPage + '.css' );
                }
        }
}
 
// Book specific
var wgBookName = ( mw.config.get( 'wgPageName' ).split( '/', 1)[0] || '' ).split( ':', 2 ).join( ':' );
importStylesheet('MediaWiki:Common.css/' + wgBookName);
 
// Imported scripts
importScript('MediaWiki:Common.js/Relics.js');
importScript('MediaWiki:Common.js/ExtraTools.js');
importScript('MediaWiki:Common.js/CollapseElements.js');
importScript('MediaWiki:Common.js/NavigationTabs.js');
importScript('MediaWiki:Common.js/Displaytitle.js');
importScript('MediaWiki:Common.js/RandomBook.js');
importScript('MediaWiki:Common.js/Perbook.js');
importScript('MediaWiki:Common.js/tabs.js');
importScript('MediaWiki:Common.js/top.js');
importScript('MediaWiki:Common.js/review.js');
importScript('MediaWiki:Common.js/Categories.js');
importScript('MediaWiki:Common.js/use.js');
 
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) == 'Watchlist' ) {
	importScript('MediaWiki:Common.js/WatchlistNotice.js');
} else if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit', 'upload'] ) != -1 ) {
	importScript('MediaWiki:Common.js/Special_characters.js');
	importScript('MediaWiki:Common.js/Toolbox.js');
}
 
// Load sysop-specific JavaScript/CSS from [[MediaWiki:Common.js/Sysop.js]] and [[MediaWiki:Common.css/Sysop.css]]
if ( $.inArray( 'sysop', mw.config.get('wgUserGroups')) > -1 ) {
 importStylesheet('MediaWiki:Common.css/Sysop.css');
 if ( !window.disableSysopJS ) {
  $(function(){
   importScript('MediaWiki:Common.js/Sysop.js');
  });
 }
}

//jmap.js used to resize image maps   ///////////////////
mw.loader.load( '/docs/index.php?title=MediaWiki:jmap.js&action=raw&ctype=text/javascript' );

////  Custom Scripts  ///////////////////
mw.loader.load( '/docs/index.php?title=MediaWiki:Main_Page_JavaScript.js&action=raw&ctype=text/javascript' );

$('.ugcHeader').click(function () {
	var hed = $(this)[0];
	var con = $(this).next('.ugcContent')[0];
	if ($(this).children('span.ugcHeaderIcon').hasClass("down")) {
		$(this).children('span.ugcHeaderIcon').removeClass("down");
	}
	else {
		$(this).children('span.ugcHeaderIcon').addClass("down");
	}
	

	$(this).parent().find('.ugcContent').each(function (i, item) {
		if ($(item)[0] != con) {
			$(item).slideUp();
		}
	});

	$(this).parent().find('.ugcHeader').each(function (i, item) {
		if ($(item)[0] != hed) {
			$(item).children('span.ugcHeaderIcon').removeClass("down");
		}
	});

	$(this).next('.ugcContent').slideToggle();
	return false;
});

$('.ugcOpenAll').click(function () {

	$(this).parent().find('.ugcContent').each(function (i, item) {
		if ($(item)[0] != con) {
			$(item).slideDown();
		}
	});

	$(this).parent().find('.ugcHeader').each(function (i, item) {
		if ($(item)[0] != hed) {
			$(item).children('span.ugcHeaderIcon').addClass("down");
		}
	});

	return false;
});