לדלג לתוכן

מדיה ויקי:Gadget-rollBackSummary.js: הבדלים בין גרסאות בדף

מתוך צפונות ויקי
prevent double-booking: mark the links with specific class
ניסוי
שורה 11: שורה 11:
if ($( '.' + rollbackSummaryClass ).length ) return;
if ($( '.' + rollbackSummaryClass ).length ) return;
$( 'span.mw-rollback-link', content )
$( 'span.mw-rollback-link', content )
.append(hist ? ' | ' : '[')
.after(
.append(
$( '<a>', { href: '#', title: 'שחזור מהיר עם תקציר', text: 'תקציר' })
$( '<a>', { href: '#', 'class': rollbackSummaryClass, title: 'שחזור מהיר עם תקציר', text: 'תקציר' })
.addClass( 'mw-rollback-link ' + rollbackSummaryClass)
.click( function() {
.click( function() {
var summary = $.trim( prompt( 'אנא הזינו תקציר לשחזור') || '' );
var summary = $.trim( prompt( 'אנא הזינו תקציר לשחזור') || '' );
if ( summary )  
if ( summary ) // dirty trick: we do not call preventDefault, so after perverting the link, it will do its thing
$( this ).attr( 'href', $(this).siblings( 'a:first' ).attr( 'href' ) + '&summary=' + encodeURIComponent( summary ) );
$( this ).attr( 'href', $(this).siblings( 'a:first' ).attr( 'href' ) + '&summary=' + encodeURIComponent( summary ) );
}))
} )
.append( hist ? '' : ']' );
);
});
});

גרסה מ־16:59, 28 ביולי 2019

/*
 * Adds option to add summary to rollback revets.
 * Written by [[:he:User:Yonidebest]] based on [[:en:User:Ilmari Karonen]]'s script.
 * Translated to Hebrew by [[User:ברק שושני]]
 * Rewritten by [[User:קיפודנחש]]
 *
 */ 
mw.hook( 'wikipage.content' ).add( function( content ) {
	var hist = mw.util.getParamValue( 'action' ) == 'history',
		rollbackSummaryClass = 'rollback-summary-link';
	if ($( '.' + rollbackSummaryClass ).length ) return;
	$( 'span.mw-rollback-link', content )
		.after(
			$( '<a>', { href: '#', title: 'שחזור מהיר עם תקציר', text: 'תקציר' })
			.addClass( 'mw-rollback-link ' + rollbackSummaryClass)
			.click( function() {
				var summary = $.trim( prompt( 'אנא הזינו תקציר לשחזור') || '' );
				if ( summary ) // dirty trick: we do not call preventDefault, so after perverting the link, it will do its thing
					$( this ).attr( 'href', $(this).siblings( 'a:first' ).attr( 'href' ) + '&summary=' + encodeURIComponent( summary ) );
			} )
		);
});