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

Change subject: TranslateEditButtons: Migrate to OOjs UI
......................................................................


TranslateEditButtons: Migrate to OOjs UI

Added OOjs UI buttons to TranslateEditAddons::buttonHack()
when using OOUI to be consistent with the rest of the buttons.

Change-Id: I63c3a3115f8c77d45c976f062a7248f5a4bc88cb
---
M TranslateEditAddons.php
1 file changed, 38 insertions(+), 13 deletions(-)

Approvals:
  jenkins-bot: Verified
  Nikerabbit: Checked; Looks good to me, approved



diff --git a/TranslateEditAddons.php b/TranslateEditAddons.php
index 1a5a445..9bb2b97 100644
--- a/TranslateEditAddons.php
+++ b/TranslateEditAddons.php
@@ -107,21 +107,33 @@
                }
 
                $context = $editpage->getArticle()->getContext();
+               $useOoui = method_exists( $editpage, 'isOouiEnabled' ) && 
$editpage->isOouiEnabled();
 
                if ( $handle->isDoc() ) {
                        $langCode = $context->getLanguage()->getCode();
                        $name = TranslateUtils::getLanguageName( 
$handle->getCode(), $langCode );
-                       $accessKey = $context->msg( 'accesskey-save' )->plain();
-                       $temp = [
+                       $attribs = [
                                'id' => 'wpSave',
                                'name' => 'wpSave',
-                               'type' => 'submit',
                                'tabindex' => ++$tabindex,
-                               'value' => $context->msg( 'translate-save', 
$name )->text(),
-                               'accesskey' => $accessKey,
-                               'title' => $context->msg( 'tooltip-save' 
)->text() . ' [' . $accessKey . ']',
-                       ];
-                       $buttons['save'] = Xml::element( 'input', $temp, '' );
+                       ] + Linker::tooltipAndAccesskeyAttribs( 'save' );
+
+                       if ( $useOoui ) {
+                               $saveConfig = 
OOUI\Element::configFromHtmlAttributes( $attribs );
+                               $buttons['save'] = new OOUI\ButtonInputWidget( [
+                                       // Support: IE 6 – Use <input>, 
otherwise it can't distinguish which button was clicked
+                                       'useInputTag' => true,
+                                       'flags' => [ 'constructive', 'primary' 
],
+                                       'label' => $context->msg( 
'translate-save', $name )->text(),
+                                       'type' => 'submit',
+                               ] + $saveConfig );
+                       } else {
+                               $buttons['save'] = Html::submitButton(
+                                       $context->msg( 'translate-save', $name 
)->text(),
+                                       $attribs,
+                                       [ 'mw-ui-progressive' ]
+                               );
+                       }
                }
 
                try {
@@ -130,17 +142,30 @@
                        return true;
                }
 
-               $temp = [
+               $attribs = [
                        'id' => 'wpSupport',
                        'name' => 'wpSupport',
                        'type' => 'button',
                        'tabindex' => ++$tabindex,
-                       'value' => $context->msg( 'translate-js-support' 
)->text(),
                        'title' => $context->msg( 'translate-js-support-title' 
)->text(),
-                       'data-load-url' => $supportUrl,
-                       'onclick' => "window.open( 
jQuery(this).attr('data-load-url') );",
                ];
-               $buttons['ask'] = Html::element( 'input', $temp, '' );
+
+               if ( $useOoui ) {
+                       $attribs += [
+                               'label' => $context->msg( 
'translate-js-support' )->text(),
+                               'href' => $supportUrl,
+                               'target' => '_blank',
+                       ];
+                       $saveConfig = OOUI\Element::configFromHtmlAttributes( 
$attribs );
+                       $buttons['ask'] = new OOUI\ButtonWidget( $saveConfig );
+               } else {
+                       $attribs += [
+                               'value' => $context->msg( 
'translate-js-support' )->text(),
+                               'data-load-url' => $supportUrl,
+                               'onclick' => "window.open( $( this ).data( 
'load-url' ) );",
+                       ];
+                       $buttons['ask'] = Html::element( 'input', $attribs );
+               }
 
                return true;
        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I63c3a3115f8c77d45c976f062a7248f5a4bc88cb
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Tacsipacsi <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Gergő Tisza <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Tacsipacsi <[email protected]>
Gerrit-Reviewer: VolkerE <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to