MediaWiki:Gadget-EditSummary.js

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

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* <nowiki>
 *
 * EditSummary.js
 *
 * @author [[User:Ricordisamoa]]
*/
/* global mw, $, OO, wb */
$( function () {
	if( !mw.config.exists( 'wbEntityId' ) ) {
		return;
	}
	mw.loader.using( [ 'wikibase.api.RepoApi', 'oojs-ui' ], function () {
		var textInput = new OO.ui.TextInputWidget( {
			maxLength: 250,
			placeholder: 'edit summary here'
		} ),
		summary = '',
		oldPost = wb.api.RepoApi.prototype._post;

		textInput.on( 'change', function () {
			summary = textInput.getValue().trim();
		} );

		textInput.$element
		.insertBefore( '.wikibase-entitytermsview-entitytermsforlanguagelistview-toggler' );

		wb.api.RepoApi.prototype._post = function ( params ) {
			if ( params.summary === undefined && summary !== '' ) {
				params.summary = summary;
			}
			return oldPost.call( this, params );
		};
	} );
} );