* (bug 44525) mediawiki.jqueryMsg can now parse (whitelisted) HTML elements and attributes.
* (bug 33454) Language::sprintfDate now has a timezone parameter, and supports
the "eIOPTZ" formatting characters.
+* EditWarning: A warning is shown when an editor leaves the edit form without
+ saving (enabled by default, users can opt-out via the 'useeditwarning'
+ preference). This feature was moved from the Vector extension, and is now part
+ of core for all skins. Take care when upgrading that you don't use an older
+ version of the Vector extension as this feature may conflict.
=== Bug fixes in 1.22 ===
'watchlisthidepatrolled' => 0,
'watchmoves' => 0,
'wllimit' => 250,
+ 'useeditwarning' => 1,
);
/** An array of preferences to not show for the user */
if ( $wgUser->getOption( 'uselivepreview', false ) ) {
$wgOut->addModules( 'mediawiki.action.edit.preview' );
}
+
+ if ( $wgUser->getOption( 'useeditwarning', false ) ) {
+ $wgOut->addModules( 'mediawiki.action.edit.editWarning' );
+ }
+
// Bug #19334: textarea jumps when editing articles in IE8
$wgOut->addStyle( 'common/IE80Fixes.css', 'screen', 'IE 8' );
'section' => 'editing/advancedediting',
'label-message' => 'tog-uselivepreview',
);
+
+ $defaultPreferences['useeditwarning'] = array(
+ 'type' => 'toggle',
+ 'section' => 'editing/advancedediting',
+ 'label-message' => 'tog-useeditwarning',
+ );
+
}
/**
'tog-showhiddencats' => 'Show hidden categories',
'tog-noconvertlink' => 'Disable link title conversion', # only translate this message to other languages if you have to change it
'tog-norollbackdiff' => 'Omit diff after performing a rollback',
+'tog-useeditwarning' => 'Warn me when I leave an edit page with unsaved changes',
'underline-always' => 'Always',
'underline-never' => 'Never',
'content-failed-to-parse' => 'Failed to parse $2 content for $1 model: $3',
'invalid-content-data' => 'Invalid content data',
'content-not-allowed-here' => '"$1" content is not allowed on page [[$2]]',
+'editwarning-warning' => 'Leaving this page may cause you to lose any changes you have made.
+If you are logged in, you can disable this warning in the "Editing" section of your preferences.',
# Content models
'content-model-wikitext' => 'wikitext',
{{Gender}}
{{Identical|Browser default}}',
+'tog-useeditwarning' => 'Caption of the editwarning preference, displayed on the right side of the checkbox',
# Font style option in Special:Preferences
'editfont-style' => 'Used in [[Special:Preferences]], tab Editing. {{Gender}}',
'content-not-allowed-here' => 'Error message indicating that the desired content model is not supported in given localtion.
* $1 - the human readable name of the content model: {{msg-mw|Content-model-wikitext}}, {{msg-mw|Content-model-javascript}}, {{msg-mw|Content-model-css}} or {{msg-mw|Content-model-text}}
* $2 - the title of the page in question',
+'editwarning-warning' => 'Warning message that is displayed when a user moves to an other page without saving his changes',
# Content models
'content-model-wikitext' => 'Name for the wikitext content model, used when decribing what type of content a page contains.
'tog-showhiddencats',
'tog-noconvertlink',
'tog-norollbackdiff',
+ 'tog-useeditwarning',
),
'underline' => array(
'underline-always',
'content-failed-to-parse',
'invalid-content-data',
'content-not-allowed-here',
+ 'editwarning-warning',
),
'contentmodels' => array(
'content-model-wikitext',
'mediawiki.action.view.rightClickEdit' => array(
'scripts' => 'resources/mediawiki.action/mediawiki.action.view.rightClickEdit.js',
),
+ 'mediawiki.action.edit.editWarning' => array(
+ 'scripts' => 'resources/mediawiki.action/mediawiki.action.edit.editWarning.js',
+ 'messages' => array(
+ 'editwarning-warning',
+ ),
+ ),
// Alias for backwards compatibility
'mediawiki.action.watch.ajax' => array(
'dependencies' => 'mediawiki.page.watch.ajax'
--- /dev/null
+/*
+ * Javascript for module editWarning
+ */
+( function ( mw, $ ) {
+ $( document ).ready( function () {
+ // Check if EditWarning is enabled and if we need it
+ if ( $( '#wpTextbox1' ).length === 0 ) {
+ return true;
+ }
+ // Get the original values of some form elements
+ $( '#wpTextbox1, #wpSummary' ).each( function () {
+ $( this ).data( 'origtext', $( this ).val() );
+ });
+ var savedWindowOnBeforeUnload;
+ $( window )
+ .on( 'beforeunload.editwarning', function () {
+ var retval;
+
+ // Check if the current values of some form elements are the same as
+ // the original values
+ if (
+ mw.config.get( 'wgAction' ) === 'submit' ||
+ $( '#wpTextbox1' ).data( 'origtext' ) !== $( '#wpTextbox1' ).val() ||
+ $( '#wpSummary' ).data( 'origtext' ) !== $( '#wpSummary' ).val()
+ ) {
+ // Return our message
+ retval = mw.msg( 'editwarning-warning' );
+ }
+
+ // Unset the onbeforeunload handler so we don't break page caching in Firefox
+ savedWindowOnBeforeUnload = window.onbeforeunload;
+ window.onbeforeunload = null;
+ if ( retval !== undefined ) {
+ // ...but if the user chooses not to leave the page, we need to rebind it
+ setTimeout( function () {
+ window.onbeforeunload = savedWindowOnBeforeUnload;
+ }, 1 );
+ return retval;
+ }
+ } )
+ .on( 'pageshow.editwarning', function () {
+ // Re-add onbeforeunload handler
+ if ( !window.onbeforeunload ) {
+ window.onbeforeunload = savedWindowOnBeforeUnload;
+ }
+ } );
+
+ // Add form submission handler
+ $( '#editform' ).submit( function () {
+ // Unbind our handlers
+ $( window ).off( '.editwarning' );
+ } );
+ } );
+
+}( mediaWiki, jQuery ) );
+