Page MenuHomeWickedGov Phorge

mediawiki.action.edit.editWarning.js
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

mediawiki.action.edit.editWarning.js

/*
* Javascript for module editWarning
*/
( function () {
'use strict';
$( () => {
const $textBox = $( '#wpTextbox1' );
const $summary = $( '#wpSummary' );
const $both = $textBox.add( $summary );
// Check if EditWarning is enabled and if we need it
if ( !mw.user.options.get( 'useeditwarning' ) ) {
return true;
}
// Save the original value of the text fields
$both.each( ( index, element ) => {
const $element = $( element );
$element.data( 'origtext', $element.textSelection( 'getContents' ) );
} );
// This registers an event with the name "beforeunload.editwarning", which allows others to
// turn the confirmation off with `$( window ).off( 'beforeunload.editwarning' );`.
const allowCloseWindow = mw.confirmCloseWindow( {
test: function () {
// When the action is submit we're solving a conflict. Everything is a pending change there.
return mw.config.get( 'wgAction' ) === 'submit' ||
// We use .textSelection, because editors might not have updated the form yet.
$textBox.data( 'origtext' ) !== $textBox.textSelection( 'getContents' ) ||
$summary.data( 'origtext' ) !== $summary.textSelection( 'getContents' );
},
namespace: 'editwarning'
} );
// Add form submission handler
$( '#editform' ).on( 'submit', () => {
allowCloseWindow.release();
} );
} );
}() );

File Metadata

Mime Type
text/plain
Expires
Wed, Aug 19, 09:19 (2 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0a/f9/2692f63e1bede7ab92bc5d0226d4
Default Alt Text
mediawiki.action.edit.editWarning.js (1 KB)

Event Timeline