MediaWiki:Gadget-RenameLink.js
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.
This user script seems to have a documentation page at MediaWiki:Gadget-RenameLink. |
/**
* @description
* Install a rename link for users who cannot move files
* Feel free to add more links that support usability
*
* Clicking this link will add the rename template with a valid reason
*
* Invoke automated jsHint-validation on save: A feature on Wikimedia Commons
* Interested? See [[c:MediaWiki:JSValidator.js]] or [[c:Help:JSValidator]].
*
* @dependencies
* the usual mediaWiki stuff (mediawiki.user, mediawiki.util)
* Gadget-AjaxQuickDelete.js (ext.gadget.AjaxQuickDelete)
*
* @autor [[User:Rillke]], 2012
* @revision: 05:25, 1 October 2019 (UTC)
*/
// <nowiki>
/* eslint indent:["error","tab",{"outerIIFEBody":0}] */
/* global jQuery:false, mediaWiki:false, AjaxQuickDelete:true*/
( function ( $, mw ) {
'use strict';
if ( mw.config.get( 'wgNamespaceNumber' ) !== 6 || !mw.config.get( 'wgUserName' ) || mw.config.get( 'wgIsRedirect' ) ) { return; }
var cats = mw.config.get( 'wgCategories' ),
usergroups = mw.config.get( 'wgUserGroups' ),
restriction = mw.config.get( 'wgRestrictionEdit' ),
userlang = mw.config.get( 'wgUserLanguage' ),
maincats = [ 'Media requiring renaming',
'Media renaming requests needing target',
'Incomplete media renaming requests' ];
// Category information not available (e.g. mobile) so do not add
if( !cats ) { return; }
if ( restriction && restriction.length && usergroups.indexOf( restriction[ 0 ] ) === -1 ) { return; }
// Translation to be replaced with MediaWiki-messages ASAP (MediaWiki:Vector-action-move)
var i18n = {
ar: 'نقل',
az: 'Adını dəyiş',
'be-tarask': 'Перайменаваць',
bn: 'স্থানান্তর',
ca: 'Canvia el nom',
cs: 'Přesunout',
de: 'Verschieben',
en: 'Move',
es: 'Trasladar',
fa: 'انتقال',
fr: 'Renommer',
gl: 'Mover',
hr: 'Premjesti',
it: 'Rinomina',
ja: '移動',
kk: 'Атауын өзгерту',
ko: '이동',
ml: 'തലക്കെട്ട് മാറ്റുക',
nl: 'Hernoemen',
pl: 'Przenieś',
pt: 'Mover',
ro: 'Redenumire',
ru: 'Переименовать',
sk: 'Premenovať',
sv: 'Flytta',
th: 'เปลี่ยนชื่อ (ย้าย)',
tr: 'Taşı',
uk: 'Перейменувати',
yue: '搬',
zh: '移動',
'zh-hans': '移动',
'zh-cn': '移动',
'zh-my': '移动',
'zh-sg': '移动',
'zh-hant': '移動',
'zh-tw': '移動',
'zh-hk': '移動',
'zh-mo': '移動'
},
i18nP = {
ar: 'جارٍ تحميل السكريبت',
az: 'Skript yüklənir',
'be-tarask': 'Загрузка скрыпта',
bn: 'স্ক্রিপ্ট লোড হচ্ছে',
ca: 'S’està carregant l’script',
cs: 'Nahrávám skript',
de: 'Programmcode laden',
en: 'Loading script',
es: 'Cargando la secuencia de órdenes',
fa: 'بارگیری اسکریپت',
fr: 'Chargement',
gl: 'Cargando o script',
hr: 'Učitavanje skripte',
id: 'Memuat skrip',
it: 'Caricamento script in corso',
ja: 'スクリプトの読み込み中',
kk: 'Скрипт жүктелуде',
ko: '스크립트 로딩 중',
ml: 'സ്ക്രിപ്റ്റ് തയ്യാറാക്കുന്നു.',
nl: 'Script laden',
pl: 'Ładowanie skryptu',
pt: 'Carregando script',
ro: 'Se încarcă scriptul',
ru: 'Загрузка скрипта',
sk: 'Skript sa načítava',
sv: 'Laddar skript',
th: 'กำลังโหลดสคริปต์',
tr: 'Betik yükleniyor',
uk: 'Завантаження скрипта',
yue: '喺度搞緊代碼……唔該等陣……',
zh: '載入腳本',
'zh-hans': '加载脚本',
'zh-cn': '加载脚本',
'zh-my': '加载脚本',
'zh-sg': '加载脚本',
'zh-hant': '載入腳本',
'zh-tw': '載入腳本',
'zh-hk': '載入腳本',
'zh-mo': '載入腳本',
};
function onClickToStart( e ) {
e.preventDefault();
// This calls directly into an internal method and thus has not yet loaded the required dependencies
mw.loader.using( ['jquery.ui'] ).then( function () {
AjaxQuickDelete.showProgress( i18nP[ userlang ] || i18nP[ userlang.split( '-' )[ 0 ] ] || i18nP.en );
} );
if ( !window.rRename ) { mw.loader.load( '/w/index.php?title=MediaWiki:RenameRequest.js&action=raw&ctype=text/javascript' ); }
mw.hook( 'aqd.renamerequest.run' ).fire( 'start' );
}
$( function () {
mw.hook( 'aqd.renamerequest.i18n' ).fire( i18n );
// Rename template
for ( var i = 0; i < maincats.length; i++ ) {
if ( cats.indexOf( maincats[ i ] ) !== -1 ) {
$( '#renameChange' ).show().find( 'a' ).on( 'click', onClickToStart );
return;
}
}
if ( usergroups.indexOf( 'sysop' ) + usergroups.indexOf( 'filemover' ) === -2 ) {
$( mw.util.addPortletLink( 'p-cactions', '#',
i18n[ userlang ] || i18n[ userlang.split( '-' )[ 0 ] ] || i18n.en,
'ca-rename', 'Request renaming this file.', 'm' ) )
.on( 'click', onClickToStart );
}
} );
}( jQuery, mediaWiki ) );
// </nowiki>