MediaWiki:Gadget-ProjectSpecificLogos.js

From Wikiversity

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.
/**
 * @brief Project specific logos
 * 
 * @details
 * Changes the site logo according to the project (if exists),
 * otherwise keeps the default one.
 * 
 * @author [[meta:User:Vogone]]
 * 
 * @derived_from [[incubator:MediaWiki:Gadget-ProjectSpecificLogos.js]]
 */
 
/*global mediaWiki, jQuery */
/*jslint browser: true, plusplus: true, white: true */
/*jshint browser:true, laxbreak:false, plusplus:false, white:false, undef:true, unused:true */
 
( function ( mw, $ ) {
 
	'use strict';
 
	var projectLogos = {
		// customizable list
		'LT' : '5/5c/Wikiversity-logo-lt.svg/135px-Wikiversity-logo-lt.svg.png',
		'UK' : '3/37/Wikiversity-logo-uk.svg/135px-Wikiversity-logo-uk.svg.png',
		// end of customizable list
	};
 
	var commonsThumb = '//upload.wikimedia.org/wikipedia/commons/thumb/';
 
	var title = mw.config.get( 'wgCategories' );
	var projectLogo = projectLogos[title[0]] || false;
 
	$( function () {
 
		if ( projectLogo ) {
 
			$( '#p-logo' )
				.find( 'a' )
					.css( 'background', 'url("' + commonsThumb + projectLogo + '") center no-repeat' );
		}
 
	});
}( mediaWiki, jQuery ) );