User:ChiemgauN/common.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
/**
 * Install a rotatelink
 * This piece of script is jshint-valid
 * Maintainer: [[User:Rillke]]
 */
/*global $:false, mw:false, importScriptURI:false */
$(document).ready(function () {
	'use strict';
	if (6 !== mw.config.get('wgNamespaceNumber') || mw.user.anonymous() || 'object' === typeof window.rRot) { 
		return; 
	}
	var ext = mw.config.get('wgPageName').slice(mw.config.get('wgPageName').lastIndexOf('.')+1).toLowerCase();
	if (-1 !== $.inArray( ext, ['ogg', 'oga', 'mid'] )) { 
		return; 
	}
	if (	(-1 !== $.inArray( 'Images requiring rotation', mw.config.get('wgCategories') )) || 
		(-1 !== $.inArray( 'Images requiring rotation by bot', mw.config.get('wgCategories') ))   ) { 
			return;
	}
	if ($.isArray(window.rotateFileTypes) && (-1 === $.inArray( ext, window.rotateFileTypes ))) { 
		return; 
	}
	var $fileinfo = $('.fileInfo');
	if ($fileinfo.length < 1) { 
		return; 
	}
	var i18n = {
		'ca': 'demana girar-la',
		'cs': 'vyžádat otočení',
		'da': 'Anmod om rotation',
		'de': 'Bild drehen',
		'en': 'request rotation',
		'es': 'solicitud de rotación',
		'fr': 'faire pivoter',
		'it': 'richiedi rotazione',
		'mk': 'побарај свртување',
		'pl': 'Obróć grafikę',
		'pt': 'Solicitar rotação',
		'ro': 'Cerere de rotaţie',
		'sv': 'Begär rotation',
		'zh': '请求旋转', // also correct for zh-hans, zh-cn, zh-my, zh-sg
		'zh-hant': '請求旋轉',
		'zh-hk': '請求旋轉',
		'zh-mo': '請求旋轉',
		'zh-tw': '請求旋轉'
	};
	$('.fileInfo').append( '; ', $('<a>', { href: '#', style: 'white-space:nowrap; display:inline-block;', title: 'Request a (permanent) correction of the rotation if the thumbnails display in the wrong orientation. Please try to purge the server\'s and client\'s cache before if this file is an upload before middle of October 2011.' }).append(
		'(', $('<img>', { src: '//upload.wikimedia.org/wikipedia/commons/7/70/Silk_arrow_rotate_clockwise.png' }), i18n[mw.config.get('wgUserLanguage')] || i18n[mw.config.get('wgUserLanguage').split('-')[0]] || i18n.en, ')'
	).click(function (e) {
		e.preventDefault();
		if (window.rRot) {
			$(document).triggerHandler('rotaterequest', ['start']);
		} else {
			$(document).bind('scriptLoaded', function (evt, d, e) {
				if (d && 'rotaterequest' === d) { $(document).triggerHandler('rotaterequest', ['start']); }
			});
			window.importScriptURI(mw.config.get( 'wgServer' ) + mw.config.get( 'wgScript' ) + '?title=' + mw.util.wikiUrlencode('MediaWiki:RotateRequest.js') + '&action=raw&ctype=text/javascript&dummy=5');
		}
	}) );
});