jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/366570 )

Change subject: Live Preview: Cope with the edit summary being an OOjs UI widget
......................................................................


Live Preview: Cope with the edit summary being an OOjs UI widget

Bug: T171156
Change-Id: Idb9118421ffbd438dd7b018a8dbf8bb991036232
---
M resources/Resources.php
M resources/src/mediawiki.action/mediawiki.action.edit.preview.js
2 files changed, 15 insertions(+), 4 deletions(-)

Approvals:
  Bartosz Dziewoński: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/resources/Resources.php b/resources/Resources.php
index 45a90d1..a89fb42 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -1452,6 +1452,7 @@
                        'mediawiki.diff.styles',
                        'mediawiki.util',
                        'mediawiki.jqueryMsg',
+                       'oojs-ui-core',
                ],
                'messages' => [
                        // Keep the uses message keys in sync with 
EditPage#setHeaders
diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.preview.js 
b/resources/src/mediawiki.action/mediawiki.action.edit.preview.js
index 2b6fc9d..ec572af 100644
--- a/resources/src/mediawiki.action/mediawiki.action.edit.preview.js
+++ b/resources/src/mediawiki.action/mediawiki.action.edit.preview.js
@@ -3,12 +3,14 @@
  */
 ( function ( mw, $ ) {
 
+       var oojsuieditform;
+
        /**
         * @ignore
         * @param {jQuery.Event} e
         */
        function doLivePreview( e ) {
-               var isDiff, api, parseRequest, diffRequest, postData, 
copySelectors, section,
+               var isDiff, api, parseRequest, diffRequest, postData, 
copySelectors, section, summary,
                        $wikiPreview, $wikiDiff, $editform, $textbox, $summary, 
$copyElements, $spinner, $errorBox;
 
                isDiff = ( e.target.name === 'wpDiff' );
@@ -16,7 +18,13 @@
                $wikiDiff = $( '#wikiDiff' );
                $editform = $( '#editform' );
                $textbox = $editform.find( '#wpTextbox1' );
-               $summary = $editform.find( '#wpSummary' );
+
+               if ( oojsuieditform ) {
+                       summary = OO.ui.infuse( $( '#wpSummaryWidget' ) );
+               } else {
+                       $summary = $editform.find( '#wpSummary' );
+               }
+
                $spinner = $( '.mw-spinner-preview' );
                $errorBox = $( '.errorbox' );
                section = $editform.find( '[name="wpSection"]' ).val();
@@ -78,7 +86,7 @@
                        formatversion: 2,
                        action: 'parse',
                        title: mw.config.get( 'wgPageName' ),
-                       summary: $summary.textSelection( 'getContents' ),
+                       summary: oojsuieditform ? summary.getValue() : 
$summary.val(),
                        prop: ''
                };
 
@@ -281,6 +289,8 @@
        }
 
        $( function () {
+               oojsuieditform = $( '#editform' ).hasClass( 'mw-editform-ooui' 
);
+
                // Do not enable on user .js/.css pages, as there's no sane way 
of "previewing"
                // the scripts or styles without reloading the page.
                if ( $( '#mw-userjsyoucanpreview' ).length || $( 
'#mw-usercssyoucanpreview' ).length ) {
@@ -307,7 +317,7 @@
                }
 
                if ( !$( '.mw-summary-preview' ).length ) {
-                       $( '#wpSummary' ).after(
+                       $( oojsuieditform ? '#wpSummaryWidget' : '#wpSummary' 
).after(
                                $( '<div>' ).addClass( 'mw-summary-preview' )
                        );
                }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Idb9118421ffbd438dd7b018a8dbf8bb991036232
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com>
Gerrit-Reviewer: He7d3r <he7...@gmail.com>
Gerrit-Reviewer: Jack Phoenix <j...@countervandalism.net>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: TheDJ <hartman.w...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to