Alex Monk has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/126977

Change subject: Add preference to disable leaving warning while editing
......................................................................

Add preference to disable leaving warning while editing

Bug: 51057
Change-Id: I511dd7fc4f61b0a20d0ad8bd4bc6662447236a5b
---
M includes/DefaultSettings.php
M includes/Preferences.php
M languages/i18n/en.json
M languages/i18n/qqq.json
M resources/src/mediawiki.action/mediawiki.action.edit.editWarning.js
5 files changed, 12 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/77/126977/1

diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 663098f..17b1514 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -4087,6 +4087,7 @@
        'underline' => 2,
        'uselivepreview' => 0,
        'usenewrc' => 0,
+       'warnonexit' => 1,
        'watchcreations' => 1,
        'watchdefault' => 1,
        'watchdeletion' => 0,
diff --git a/includes/Preferences.php b/includes/Preferences.php
index 6075623..0a8b8dc 100644
--- a/includes/Preferences.php
+++ b/includes/Preferences.php
@@ -786,6 +786,11 @@
                        'section' => 'editing/advancedediting',
                        'label-message' => 'tog-editondblclick',
                );
+               $defaultPreferences['warnonexit'] = array(
+                       'type' => 'toggle',
+                       'section' => 'editing/advancedediting',
+                       'label-message' => 'tog-warnonexit',
+               );
 
                if ( $wgAllowUserCssPrefs ) {
                        $defaultPreferences['editfont'] = array(
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 41c12b3..feb937c 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -13,6 +13,7 @@
     "tog-showtoolbar": "Show edit toolbar",
     "tog-editondblclick": "Edit pages on double click",
     "tog-editsectiononrightclick": "Enable section editing by right clicking 
on section titles",
+    "tog-warnonexit": "Warn when browsing away from the editor with unsaved 
changes",
     "tog-rememberpassword": "Remember my login on this browser (for a maximum 
of $1 {{PLURAL:$1|day|days}})",
     "tog-watchcreations": "Add pages I create and files I upload to my 
watchlist",
     "tog-watchdefault": "Add pages and files I edit to my watchlist",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index 3b3315f..10e0cb6 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -175,6 +175,7 @@
        "tog-showtoolbar": "{{Gender}}\n[[Special:Preferences]], tab 'Edit'. 
Offers user to show edit toolbar in page edit screen.\n\nThis is the toolbar: 
[[Image:Toolbar.png]]",
        "tog-editondblclick": "{{Gender}}\n[[Special:Preferences]], tab 'Edit'. 
Offers user to open edit page on double click.",
        "tog-editsectiononrightclick": "{{Gender}}\n[[Special:Preferences]], 
tab 'Edit'. Offers user to edit a section by clicking on a section title.",
+       "tog-warnonexit": "{{Gender}}\n[[Special:Preferences]], tab 'Edit'. 
Offers user to warn them if they try to browse away from the editing page if 
they have unsaved changes.",
        "tog-rememberpassword": "{{Gender}}\n[[Special:Preferences]], tab 'User 
profile', section 'Change password'. Offers user remember login 
details.\nParameters:\n* $1 - the number of days the login details are 
remembered\n{{Identical|Remember my login on this computer}}",
        "tog-watchcreations": "[[Special:Preferences]], tab 'Watchlist'. Offers 
user to add created pages to watchlist. {{Gender}}",
        "tog-watchdefault": "[[Special:Preferences]], tab 'Watchlist'. Offers 
user to add edited pages to watchlist. {{Gender}}",
diff --git 
a/resources/src/mediawiki.action/mediawiki.action.edit.editWarning.js 
b/resources/src/mediawiki.action/mediawiki.action.edit.editWarning.js
index f8448e6..79820a3 100644
--- a/resources/src/mediawiki.action/mediawiki.action.edit.editWarning.js
+++ b/resources/src/mediawiki.action/mediawiki.action.edit.editWarning.js
@@ -19,9 +19,12 @@
                                // Check if the current values of some form 
elements are the same as
                                // the original values
                                if (
-                                       mw.config.get( 'wgAction' ) === 
'submit' ||
+                                       mw.user.options.get( 'warnonexit' ) &&
+                                       (
+                                               mw.config.get( 'wgAction' ) === 
'submit' ||
                                                $( '#wpTextbox1' ).data( 
'origtext' ) !== $( '#wpTextbox1' ).val() ||
                                                $( '#wpSummary' ).data( 
'origtext' ) !== $( '#wpSummary' ).val()
+                                       )
                                ) {
                                        // Return our message
                                        retval = mw.msg( 'editwarning-warning' 
);

-- 
To view, visit https://gerrit.wikimedia.org/r/126977
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I511dd7fc4f61b0a20d0ad8bd4bc6662447236a5b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to