Jforrester has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/366872 )

Change subject: [WIP] EditPage: Remove legacy non-OOUI render mode
......................................................................

[WIP] EditPage: Remove legacy non-OOUI render mode

Change-Id: I2b468c8b846db015b5a1e3d2500abb8ea252c442
---
M includes/DefaultSettings.php
M includes/EditPage.php
M resources/src/mediawiki.action/mediawiki.action.edit.js
M resources/src/mediawiki.action/mediawiki.action.edit.preview.js
M resources/src/mediawiki.action/mediawiki.action.edit.styles.css
5 files changed, 72 insertions(+), 189 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/72/366872/1

diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index f35715e..6d0b252 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -3219,14 +3219,6 @@
 $wgUseMediaWikiUIEverywhere = false;
 
 /**
- * Temporary variable that determines whether the EditPage class should use 
OOjs UI or not.
- * This will be removed later and OOjs UI will become the only option.
- *
- * @since 1.29
- */
-$wgOOUIEditPage = true;
-
-/**
  * Whether to label the store-to-database-and-show-to-others button in the 
editor
  * as "Save page"/"Save changes" if false (the default) or, if true, instead as
  * "Publish page"/"Publish changes".
diff --git a/includes/EditPage.php b/includes/EditPage.php
index 973327b..deb212e 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -414,11 +414,6 @@
        private $isOldRev = false;
 
        /**
-        * @var bool Whether OOUI should be enabled here
-        */
-       private $oouiEnabled = false;
-
-       /**
         * @param Article $article
         */
        public function __construct( Article $article ) {
@@ -431,8 +426,6 @@
 
                $handler = ContentHandler::getForModelID( $this->contentModel );
                $this->contentFormat = $handler->getDefaultFormat();
-
-               $this->oouiEnabled = $this->context->getConfig()->get( 
'OOUIEditPage' );
        }
 
        /**
@@ -481,14 +474,6 @@
                } else {
                        return $this->mContextTitle;
                }
-       }
-
-       /**
-        * Check if the edit page is using OOUI controls
-        * @return bool
-        */
-       public function isOouiEnabled() {
-               return $this->oouiEnabled;
        }
 
        /**
@@ -857,9 +842,6 @@
         */
        public function importFormData( &$request ) {
                global $wgContLang, $wgUser;
-
-               # Allow users to change the mode for testing
-               $this->oouiEnabled = $request->getFuzzyBool( 'ooui', 
$this->oouiEnabled );
 
                # Section edit can come from either the form or a link
                $this->section = $request->getVal( 'wpSection', 
$request->getVal( 'section' ) );
@@ -2667,7 +2649,7 @@
                $wgOut->addHTML( Html::openElement(
                        'form',
                        [
-                               'class' => $this->oouiEnabled ? 
'mw-editform-ooui' : 'mw-editform-legacy',
+                               'class' => 'mw-editform-ooui',
                                'id' => self::EDITFORM_ID,
                                'name' => self::EDITFORM_ID,
                                'method' => 'post',
@@ -2767,13 +2749,8 @@
                $wgOut->addHTML( Html::hidden( 'format', $this->contentFormat ) 
);
                $wgOut->addHTML( Html::hidden( 'model', $this->contentModel ) );
 
-               // Preserve &ooui=1 / &ooui=0 from URL parameters after 
submitting the page for preview
-               $wgOut->addHTML( Html::hidden( 'ooui', $this->oouiEnabled ? '1' 
: '0' ) );
-
                // following functions will need OOUI, enable it only once; 
here.
-               if ( $this->oouiEnabled ) {
-                       $wgOut->enableOOUI();
-               }
+               $wgOut->enableOOUI();
 
                if ( $this->section == 'new' ) {
                        $this->showSummaryInput( true, $this->summary );
@@ -3173,19 +3150,11 @@
                }
 
                $labelText = $this->context->msg( $isSubjectPreview ? 'subject' 
: 'summary' )->parse();
-               if ( $this->oouiEnabled ) {
-                       $wgOut->addHTML( $this->getSummaryInputOOUI(
-                               $summary,
-                               $labelText,
-                               [ 'class' => $summaryClass ]
-                       ) );
-               } else {
-                       list( $label, $input ) = $this->getSummaryInput(
-                               $summary,
-                               $labelText,
-                               [ 'class' => $summaryClass ]
-                       );
-                       $wgOut->addHTML( "{$label} {$input}" );
+               $wgOut->addHTML( $this->getSummaryInputOOUI(
+                       $summary,
+                       $labelText,
+                       [ 'class' => $summaryClass ]
+               ) );
                }
        }
 
@@ -3596,19 +3565,11 @@
                        $wgOut->addHTML( $this->getSummaryPreview( false, 
$this->summary ) );
                }
 
-               if ( $this->oouiEnabled ) {
-                       $checkboxes = $this->getCheckboxesOOUI(
-                               $tabindex,
-                               [ 'minor' => $this->minoredit, 'watch' => 
$this->watchthis ]
-                       );
-                       $checkboxesHTML = new OOUI\HorizontalLayout( [ 'items' 
=> $checkboxes ] );
-               } else {
-                       $checkboxes = $this->getCheckboxes(
-                               $tabindex,
-                               [ 'minor' => $this->minoredit, 'watch' => 
$this->watchthis ]
-                       );
-                       $checkboxesHTML = implode( $checkboxes, "\n" );
-               }
+               $checkboxes = $this->getCheckboxesOOUI(
+                       $tabindex,
+                       [ 'minor' => $this->minoredit, 'watch' => 
$this->watchthis ]
+               );
+               $checkboxesHTML = new OOUI\HorizontalLayout( [ 'items' => 
$checkboxes ] );
 
                $wgOut->addHTML( "<div class='editCheckboxes'>" . 
$checkboxesHTML . "</div>\n" );
 
@@ -3698,23 +3659,14 @@
                } elseif ( $this->getContextTitle()->isRedirect() ) {
                        $cancelParams['redirect'] = 'no';
                }
-               if ( $this->oouiEnabled ) {
-                       return new OOUI\ButtonWidget( [
-                               'id' => 'mw-editform-cancel',
-                               'href' => $this->getContextTitle()->getLinkUrl( 
$cancelParams ),
-                               'label' => new OOUI\HtmlSnippet( 
$this->context->msg( 'cancel' )->parse() ),
-                               'framed' => false,
-                               'infusable' => true,
-                               'flags' => 'destructive',
-                       ] );
-               } else {
-                       return 
MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink(
-                               $this->getContextTitle(),
-                               new HtmlArmor( $this->context->msg( 'cancel' 
)->parse() ),
-                               Html::buttonAttributes( [ 'id' => 
'mw-editform-cancel' ], [ 'mw-ui-quiet' ] ),
-                               $cancelParams
-                       );
-               }
+               return new OOUI\ButtonWidget( [
+                       'id' => 'mw-editform-cancel',
+                       'href' => $this->getContextTitle()->getLinkUrl( 
$cancelParams ),
+                       'label' => new OOUI\HtmlSnippet( $this->context->msg( 
'cancel' )->parse() ),
+                       'framed' => false,
+                       'infusable' => true,
+                       'flags' => 'destructive',
+               ] );
        }
 
        /**
@@ -4353,68 +4305,48 @@
                        'tabindex' => ++$tabindex,
                ] + Linker::tooltipAndAccesskeyAttribs( 'save' );
 
-               if ( $this->oouiEnabled ) {
-                       $saveConfig = OOUI\Element::configFromHtmlAttributes( 
$attribs );
-                       $buttons['save'] = new OOUI\ButtonInputWidget( [
-                               'id' => 'wpSaveWidget',
-                               'inputId' => 'wpSave',
-                               // Support: IE 6 – Use <input>, otherwise it 
can't distinguish which button was clicked
-                               'useInputTag' => true,
-                               'flags' => [ 'constructive', 'primary' ],
-                               'label' => $buttonLabel,
-                               'infusable' => true,
-                               'type' => 'submit',
-                       ] + $saveConfig );
-               } else {
-                       $buttons['save'] = Html::submitButton(
-                               $buttonLabel,
-                               $attribs + [ 'id' => 'wpSave' ],
-                               [ 'mw-ui-progressive' ]
-                       );
-               }
+               $saveConfig = OOUI\Element::configFromHtmlAttributes( $attribs 
);
+               $buttons['save'] = new OOUI\ButtonInputWidget( [
+                       'id' => 'wpSaveWidget',
+                       'inputId' => 'wpSave',
+                       // Support: IE 6 – Use <input>, otherwise it can't 
distinguish which button was clicked
+                       'useInputTag' => true,
+                       'flags' => [ 'constructive', 'primary' ],
+                       'label' => $buttonLabel,
+                       'infusable' => true,
+                       'type' => 'submit',
+               ] + $saveConfig );
 
                $attribs = [
                        'name' => 'wpPreview',
                        'tabindex' => ++$tabindex,
                ] + Linker::tooltipAndAccesskeyAttribs( 'preview' );
-               if ( $this->oouiEnabled ) {
-                       $previewConfig = 
OOUI\Element::configFromHtmlAttributes( $attribs );
-                       $buttons['preview'] = new OOUI\ButtonInputWidget( [
-                               'id' => 'wpPreviewWidget',
-                               'inputId' => 'wpPreview',
-                               // Support: IE 6 – Use <input>, otherwise it 
can't distinguish which button was clicked
-                               'useInputTag' => true,
-                               'label' => $this->context->msg( 'showpreview' 
)->text(),
-                               'infusable' => true,
-                               'type' => 'submit'
-                       ] + $previewConfig );
-               } else {
-                       $buttons['preview'] = Html::submitButton(
-                               $this->context->msg( 'showpreview' )->text(),
-                               $attribs + [ 'id' => 'wpPreview' ]
-                       );
-               }
+
+               $previewConfig = OOUI\Element::configFromHtmlAttributes( 
$attribs );
+               $buttons['preview'] = new OOUI\ButtonInputWidget( [
+                       'id' => 'wpPreviewWidget',
+                       'inputId' => 'wpPreview',
+                       // Support: IE 6 – Use <input>, otherwise it can't 
distinguish which button was clicked
+                       'useInputTag' => true,
+                       'label' => $this->context->msg( 'showpreview' )->text(),
+                       'infusable' => true,
+                       'type' => 'submit'
+               ] + $previewConfig );
+
                $attribs = [
                        'name' => 'wpDiff',
                        'tabindex' => ++$tabindex,
                ] + Linker::tooltipAndAccesskeyAttribs( 'diff' );
-               if ( $this->oouiEnabled ) {
-                       $diffConfig = OOUI\Element::configFromHtmlAttributes( 
$attribs );
-                       $buttons['diff'] = new OOUI\ButtonInputWidget( [
-                               'id' => 'wpDiffWidget',
-                               'inputId' => 'wpDiff',
-                               // Support: IE 6 – Use <input>, otherwise it 
can't distinguish which button was clicked
-                               'useInputTag' => true,
-                               'label' => $this->context->msg( 'showdiff' 
)->text(),
-                               'infusable' => true,
-                               'type' => 'submit',
-                       ] + $diffConfig );
-               } else {
-                       $buttons['diff'] = Html::submitButton(
-                               $this->context->msg( 'showdiff' )->text(),
-                               $attribs + [ 'id' => 'wpDiff' ]
-                       );
-               }
+               $diffConfig = OOUI\Element::configFromHtmlAttributes( $attribs 
);
+               $buttons['diff'] = new OOUI\ButtonInputWidget( [
+                       'id' => 'wpDiffWidget',
+                       'inputId' => 'wpDiff',
+                       // Support: IE 6 – Use <input>, otherwise it can't 
distinguish which button was clicked
+                       'useInputTag' => true,
+                       'label' => $this->context->msg( 'showdiff' )->text(),
+                       'infusable' => true,
+                       'type' => 'submit',
+               ] + $diffConfig );
 
                // Avoid PHP 7.1 warning of passing $this by reference
                $editPage = $this;
diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.js 
b/resources/src/mediawiki.action/mediawiki.action.edit.js
index 5b81017..8f68f39 100644
--- a/resources/src/mediawiki.action/mediawiki.action.edit.js
+++ b/resources/src/mediawiki.action/mediawiki.action.edit.js
@@ -19,23 +19,18 @@
        $( function () {
                var editBox, scrollTop, $editForm;
 
-               if ( $( '#editform' ).hasClass( 'mw-editform-ooui' ) ) {
-                       mw.loader.using( 'oojs-ui-core' ).then( function () {
-                               var wpSummary = OO.ui.infuse( $( 
'#wpSummaryWidget' ) );
+               mw.loader.using( 'oojs-ui-core' ).then( function () {
+                       var wpSummary = OO.ui.infuse( $( '#wpSummaryWidget' ) );
 
-                               // Restore appropriate modifier keys for the 
accesskey in the 'title' attribute
-                               // TODO: This should be an OOjs UI feature, or 
somehow happen automatically after infusing.
-                               wpSummary.$input.updateTooltipAccessKeys();
+                       // Restore appropriate modifier keys for the accesskey 
in the 'title' attribute
+                       // TODO: This should be an OOjs UI feature, or somehow 
happen automatically after infusing.
+                       wpSummary.$input.updateTooltipAccessKeys();
 
-                               // Show a byte-counter to users with how many 
bytes are left for their edit summary.
-                               // TODO: This looks a bit weird, as there is no 
unit in the UI, just numbers; showing
-                               // 'bytes' confused users in testing, and 
showing 'chars' would be a lie. See T42035.
-                               mw.widgets.visibleByteLimit( wpSummary, 255 );
-                       } );
-               } else {
-                       // Make sure edit summary does not exceed byte limit
-                       $( '#wpSummary' ).byteLimit( 255 );
-               }
+                       // Show a byte-counter to users with how many bytes are 
left for their edit summary.
+                       // TODO: This looks a bit weird, as there is no unit in 
the UI, just numbers; showing
+                       // 'bytes' confused users in testing, and showing 
'chars' would be a lie. See T42035.
+                       mw.widgets.visibleByteLimit( wpSummary, 255 );
+               } );
 
                // Restore the edit box scroll state following a preview 
operation,
                // and set up a form submission handler to remember this state.
diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.preview.js 
b/resources/src/mediawiki.action/mediawiki.action.edit.preview.js
index 2b6fc9d..545c13e 100644
--- a/resources/src/mediawiki.action/mediawiki.action.edit.preview.js
+++ b/resources/src/mediawiki.action/mediawiki.action.edit.preview.js
@@ -307,9 +307,14 @@
                }
 
                if ( !$( '.mw-summary-preview' ).length ) {
-                       $( '#wpSummary' ).after(
-                               $( '<div>' ).addClass( 'mw-summary-preview' )
-                       );
+                       if ( oojsuieditform ) {
+                               var summary = OO.ui.infuse( $( 
'#wpSummaryWidget' ) );
+                               summary.setValue( 'asc' );
+                       } else {
+                               $( '#wpSummary' ).after(
+                                       $( '<div>' ).addClass( 
'mw-summary-preview' )
+                               );
+                       }
                }
 
                if ( !document.getElementById( 'wikiDiff' ) && 
document.getElementById( 'wikiPreview' ) ) {
diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.styles.css 
b/resources/src/mediawiki.action/mediawiki.action.edit.styles.css
index 093a26d..cc8f04b 100644
--- a/resources/src/mediawiki.action/mediawiki.action.edit.styles.css
+++ b/resources/src/mediawiki.action/mediawiki.action.edit.styles.css
@@ -25,53 +25,12 @@
        font-size: 0.9em;
 }
 
-.mw-editform-ooui #wpSummaryWidget,
-.mw-editform-legacy #wpSummary {
+.mw-editform-ooui #wpSummaryWidget {
        display: block;
        width: 80%;
        margin-bottom: 1em;
 }
 
-/* Adjustments to edit form elements (only when $wgOOUIEditPage is false) */
-.mw-editform-legacy .editCheckboxes {
-       margin-bottom: 1em;
-}
-
-.mw-editform-legacy .editCheckboxes input:first-child {
-       margin-left: 0;
-}
-
-.mw-editform-legacy .cancelLink {
-       margin-left: 0.5em;
-}
-
-.mw-editform-legacy input#wpSummary {
-       background-color: #fff;
-       color: #000;
-       margin-top: 0;
-       padding: 0.625em 0.546875em 0.546875em;
-       border: 1px solid #a2a9b1;
-       border-radius: 2px;
-       box-shadow: inset 0 0 0 1px #fff;
-       font-family: inherit;
-       font-size: inherit;
-       -webkit-transition: border-color 200ms cubic-bezier( 0.39, 0.575, 
0.565, 1 ), box-shadow 200ms cubic-bezier( 0.39, 0.575, 0.565, 1 );
-       -moz-transition: border-color 200ms cubic-bezier( 0.39, 0.575, 0.565, 1 
), box-shadow 200ms cubic-bezier( 0.39, 0.575, 0.565, 1 );
-       transition: border-color 200ms cubic-bezier( 0.39, 0.575, 0.565, 1 ), 
box-shadow 200ms cubic-bezier( 0.39, 0.575, 0.565, 1 );
-}
-
-.mw-editform-legacy input#wpSummary:focus,
-.mw-editform-legacy input#wpSummary:active {
-       outline: 0;
-       border-color: #36c;
-       box-shadow: inset 0 0 0 1px #36c;
-}
-
-.mw-editform-legacy .editButtons input:first-child {
-       margin-left: 0.1em;
-}
-
-/* Adjustments to edit form elements (only when $wgOOUIEditPage is true) */
 .mw-editform-ooui #editpage-copywarn {
        line-height: 1.26;
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2b468c8b846db015b5a1e3d2500abb8ea252c442
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Jforrester <jforres...@wikimedia.org>

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

Reply via email to