Edit warning should get value from editors
authorDerk-Jan Hartman <hartman.wiki@gmail.com>
Thu, 27 Mar 2014 23:33:23 +0000 (00:33 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Mon, 28 Jul 2014 19:59:18 +0000 (19:59 +0000)
Editwarning needs to make sure that any editor that uses something
other than wpTextbox1 to keep the value of the form, is able to write
this into the form before we are allowed to leave the page.

This is already supported by the textSelection api, so use that to
retrieve the value instead of plain .val()

Bug: 61117
Change-Id: I24d7096929c4eed36376ef9089d7f1b72a0b6682

resources/Resources.php
resources/src/mediawiki.action/mediawiki.action.edit.editWarning.js

index deaa802..942b332 100644 (file)
@@ -1052,6 +1052,7 @@ return array(
        'mediawiki.action.edit.editWarning' => array(
                'scripts' => 'resources/src/mediawiki.action/mediawiki.action.edit.editWarning.js',
                'dependencies' => array(
+                       'jquery.textSelection',
                        'mediawiki.jqueryMsg'
                ),
                'messages' => array(
index dcd2b0b..b565440 100644 (file)
@@ -24,8 +24,8 @@
                                // the original values
                                if (
                                        mw.config.get( 'wgAction' ) === 'submit' ||
-                                               $wpTextbox1.data( 'origtext' ) !== $wpTextbox1.val() ||
-                                               $wpSummary.data( 'origtext' ) !== $wpSummary.val()
+                                               $wpTextbox1.data( 'origtext' ) !== $wpTextbox1.textSelection( 'getContents' ) ||
+                                               $wpSummary.data( 'origtext' ) !== $wpSummary.textSelection( 'getContents' )
                                ) {
                                        // Return our message
                                        retval = mw.msg( 'editwarning-warning' );