User:Psl631/common.js: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 8:
 
/* Make so I can choose custom roll back summary instead of de fault */
/**
$( function() {
* Ajax Undo links
$( '.mw-rollback-link > a' ).on( 'click', function(event) {
*
var $rollback = $( '#rollback-summary' );
* Adds an Ajax undo link next to the normal undo link on page histories
* and on diff pages
if ( $( this ).parent().is( $rollback.parent() ) ) {
* Based on [[User:Abelmoschus Esculentus/AjaxRollback.js]]
$rollback.toggle();
*/
} else {
//<nowiki>
$rollback.remove();
//<nowiki>
//Modified from [[User:BenjaminWillJS/AjaxRollback.js]]
var name = decodeURIComponent( $( this ).prev().prop( 'href' ).match( /&from=(.+)&token/ )[1].replace( /\+/g, ' ' ) );
jQuery(document).ready(function ($) {
$rollback = $( '<div id="rollback-summary">' ).append(
function SetAjaxRollback() {
$( '<input type="text">' ).addClass( 'mw-ui-input rollback-text' ).prop( { maxlength: 250, spellcheck: true } ).val(
$( 'span.mw-rollback-link > a' ).onclick( 'click', function(evente) {
'Revert consecutive edits by [[Special:Contribs/' + name + '|' + name + ']] ([[User talk:' + name + '|talk]])'
e.preventDefault();
),
var $rblink = $(this);
$( '<input type="button">' ).addClass( 'mw-ui-button mw-ui-constructive rollback-submit-button' ).val( 'Rollback' )
var href = this.getElementsByTagName('a')[0].href;
).insertAfter( this );
this.innerHTML = '<img src="https://upload.wikimedia.org/wikipedia/commons/d/de/Ajax-loader.gif" style="vertical-align: baseline;" height="15" width="15" border="0" alt="Rollingback..." />';
}
$.ajax({
url: href,
// This puts the cursor at the end of the text
success: function() {
var $text = $rollback.find( '.rollback-text' );
$rblink.text(function (i, val) {return val + '[reverted]';});
var summary = $text.val();
)},
$text.focus().val( '' ).val( summary );
$( error: function() {
event.preventDefault();
$rblink.text(function (i, val) {return val + '[rollback failed]';});
} );
}
});
$( '#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() );
mw.loader.using(['mediawiki.util', 'mediawiki.api', 'mediawiki.Title', 'mediawiki.RegExp'], function() {
} );
SetAjaxRollback();
} );
// Allow rollback to be submitted by pressing enter while focused on the input field
} );
$( '#mw-content-text' ).on( 'keypress', '.rollback-text', function( e ) {
//</nowiki>
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' ) && !$( '#rollback-summary' ).has( e.target ).length ) {
$( '#rollback-summary' ).hide();
}
} );
} );
 
$( document ).ready( function() {
"use strict";
215

edits