VOOZH about

URL: https://minecraft.wiki/w/MediaWiki:Gadget-editableRollback.js

⇱ MediaWiki:Gadget-editableRollback.js – Minecraft Wiki


MediaWiki:Gadget-editableRollback.js

From Minecraft Wiki
Jump to navigation Jump to search
In other languages

Note: After saving, you have to bypass your browser's cache to see the changes.

Google Chrome, Firefox, Microsoft Edge, and Safari: Hold down the key and click the Reload toolbar button.
For details and instructions about other browsers, see Wikipedia:Bypass your cache.

// jshint jquery:true, esversion:5
/* globals require, module, mediaWiki, mw, OO */
'use strict';
$(function(){
mw.hook('wikipage.content').add(function($content){
$content.find('.mw-rollback-link > a').after($('<span>').addClass('edit-rollback').prop('title','Edit rollback summary'));
});
$('#mw-content-text').on('click','.edit-rollback',function(){
var$rollback=$('#rollback-summary');
if($(this).parent().is($rollback.parent())){
$rollback.toggle();
}else{
$rollback.remove();
varname=decodeURIComponent($(this).prev().prop('href').match(/&from=(.+)&token/)[1].replace(/\+/g,' '));
$rollback=$('<div id="rollback-summary" class="cdx-text-input">').append(
$('<input type="text">').addClass('cdx-text-input__input rollback-text').prop({maxlength:mw.config.get('wgCommentCodePointLimit'),spellcheck:true}).val(
'Revert edits by [[Special:Contribs/'+name+'|'+name+']] ([[User talk:'+name+'|talk]]) '
),
$('<input type="button">').addClass('cdx-button rollback-submit-button').val('Rollback')
).insertAfter(this);
}
// This puts the cursor at the end of the text
var$text=$rollback.find('.rollback-text');
varsummary=$text.val();
$text.focus().val('').val(summary);
});
$('#mw-content-text').on('click','.rollback-submit-button',function(){
var$link=$(this).closest('.mw-rollback-link');
window.location=$link.find('a').prop('href')+'&summary='+encodeURIComponent($link.find('.rollback-text').val());
});
// Allow rollback to be submitted by pressing enter while focused on the input field
$('#mw-content-text').on('keypress','.rollback-text',function(e){
if(e.which!==13){
return;
}
e.preventDefault();
$('.rollback-submit-button').click();
});
// Close rollback if clicked anywhere else
$(window).click(function(e){
if(!$(e.target).is('#rollback-summary, .edit-rollback')&&!$('#rollback-summary').has(e.target).length){
$('#rollback-summary').hide();
}
});
});
Retrieved from "https://minecraft.wiki/w/MediaWiki:Gadget-editableRollback.js?oldid=3375882"

Navigation menu