| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
( function () { |
| 5 |
'use strict'; |
| 6 |
|
| 7 |
$( () => { |
| 8 |
const $textBox = $( '#wpTextbox1' ); |
| 9 |
const $summary = $( '#wpSummary' ); |
| 10 |
const $both = $textBox.add( $summary ); |
| 11 |
|
| 12 |
|
| 13 |
if ( !mw.user.options.get( 'useeditwarning' ) ) { |
| 14 |
return true; |
| 15 |
} |
| 16 |
|
| 17 |
|
| 18 |
$both.each( ( index, element ) => { |
| 19 |
const $element = $( element ); |
| 20 |
$element.data( 'origtext', $element.textSelection( 'getContents' ) ); |
| 21 |
} ); |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
const allowCloseWindow = mw.confirmCloseWindow( { |
| 26 |
test: function () { |
| 27 |
|
| 28 |
return mw.config.get( 'wgAction' ) === 'submit' || |
| 29 |
|
| 30 |
$textBox.data( 'origtext' ) !== $textBox.textSelection( 'getContents' ) || |
| 31 |
$summary.data( 'origtext' ) !== $summary.textSelection( 'getContents' ); |
| 32 |
}, |
| 33 |
|
| 34 |
namespace: 'editwarning' |
| 35 |
} ); |
| 36 |
|
| 37 |
|
| 38 |
$( '#editform' ).on( 'submit', () => { |
| 39 |
allowCloseWindow.release(); |
| 40 |
} ); |
| 41 |
} ); |
| 42 |
|
| 43 |
}() ); |