Alex Monk has uploaded a new change for review.

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

Change subject: Trigger a custom event on #wpTextbox1 when we need to get the 
latest wikitext out of it
......................................................................

Trigger a custom event on #wpTextbox1 when we need to get the latest wikitext 
out of it

To allow prompting gadgets like wikEd to update it with the latest value.

Bug: T135747
Change-Id: Ie353cf547dea6c100c5f01ab56c9b415be1ffdb8
---
M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
M modules/ve-mw/init/ve.init.mw.ArticleTargetLoader.js
2 files changed, 9 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/44/295444/1

diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js 
b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
index d465750..99f41e4 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
@@ -541,8 +541,9 @@
                },
 
                activateVe: function () {
-                       var wikitext = $( '#wpTextbox1' ).val(),
-                               wikitextModified = wikitext !== initialWikitext;
+                       var wikitext;
+                       $( '#wpTextbox1' ).trigger( 've-require-latest' );
+                       wikitext = $( '#wpTextbox1' ).val();
 
                        // Close any open jQuery.UI dialogs (e.g. WikiEditor's 
find and replace)
                        if ( $.fn.dialog ) {
@@ -551,7 +552,10 @@
 
                        if (
                                mw.config.get( 'wgAction' ) === 'submit' ||
-                               ( mw.config.get( 'wgAction' ) === 'edit' && 
wikitextModified ) ||
+                               (
+                                       mw.config.get( 'wgAction' ) === 'edit' 
&&
+                                       wikitext !== initialWikitext
+                               ) ||
                                // switching from section editing must prompt 
because we can't
                                // keep changes from that (yet?)
                                $( 'input[name=wpSection]' ).val()
@@ -709,6 +713,7 @@
                        urlSaysHideWelcome = 'hidewelcomedialog' in new mw.Uri( 
location.href ).query;
 
                if ( uri.query.action === 'edit' && $( '#wpTextbox1' ).length ) 
{
+                       $( '#wpTextbox1' ).trigger( 've-require-latest' );
                        initialWikitext = $( '#wpTextbox1' ).val();
                }
 
diff --git a/modules/ve-mw/init/ve.init.mw.ArticleTargetLoader.js 
b/modules/ve-mw/init/ve.init.mw.ArticleTargetLoader.js
index ecbd5e4..e2675a6 100644
--- a/modules/ve-mw/init/ve.init.mw.ArticleTargetLoader.js
+++ b/modules/ve-mw/init/ve.init.mw.ArticleTargetLoader.js
@@ -135,6 +135,7 @@
                        } );
 
                        if ( conf.fullRestbaseUrl || conf.restbaseUrl ) {
+                               $( '#wpTextbox1' ).trigger( 've-require-latest' 
);
                                ve.track( 'trace.restbaseLoad.enter' );
                                if (
                                        conf.fullRestbaseUrl &&

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie353cf547dea6c100c5f01ab56c9b415be1ffdb8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <kren...@gmail.com>

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

Reply via email to