Sbisson has uploaded a new change for review.

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

Change subject: Don't ask for confirmation to leave the page when there is no 
unsaved modifications.
......................................................................

Don't ask for confirmation to leave the page when
there is no unsaved modifications.

IE8 does not support placeholder. It is simulated
using the value attribute. Before leaving the page,
a script compares the value of each textfield with
its default value to know if there is modifications.

With this change, a textfield is assumed to be
modified if its value is different than its
default value and different than its placeholder
attribute.

Bug: T95909
Change-Id: Ieedc5a1fbbfe18b7c6f60092ed6a2ab790c9be9d
---
M modules/engine/misc/mw-ui.enhance.js
1 file changed, 8 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/56/204056/1

diff --git a/modules/engine/misc/mw-ui.enhance.js 
b/modules/engine/misc/mw-ui.enhance.js
index 3da4e70..43fdec3 100644
--- a/modules/engine/misc/mw-ui.enhance.js
+++ b/modules/engine/misc/mw-ui.enhance.js
@@ -429,10 +429,16 @@
         */
        var _oldOnBeforeUnload = window.onbeforeunload;
        window.onbeforeunload = function () {
-               var uncommitted;
+               var uncommitted,
+                       hasValue, currentValue, defaultValue, placeholderText;
 
                $( 'input, textarea' ).filter( '.mw-ui-input:visible' ).each( 
function () {
-                       if ( $.trim( this.value ) && this.value !== 
this.defaultValue ) {
+                       hasValue = !!$.trim( this.value );
+                       currentValue = this.value;
+                       defaultValue = this.defaultValue;
+                       placeholderText = $( this ).attr( 'placeholder' );
+
+                       if ( hasValue && currentValue !== defaultValue && 
currentValue !== placeholderText ) {
                                uncommitted = true;
                                return false;
                        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieedc5a1fbbfe18b7c6f60092ed6a2ab790c9be9d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Sbisson <sbis...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to