Jeroen De Dauw has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/381522 )

Change subject: Pass RTL config to the widgets
......................................................................

Pass RTL config to the widgets

This is for https://phabricator.wikimedia.org/T175826

Does not work for the ArbitraryWordInput widgets yet. There appears to be a bug
in OO JS UI here. We are passing the info in the config. Presumably the
TagMultiselectWidget does not pass it to the right bunch of mixed in code.

Yay for rampant inheritance/mixing that makes finding stuff ulrta derp. And
bonus points for all the widegst in one file, which makes searching in a scope
so much easier.

Change-Id: I6c889e519474e96dcc6f89e6979a72a811a2c9c5
---
M AdvancedSearch.hooks.php
M modules/ext.advancedSearch.init.js
M modules/ui/ext.advancedSearch.ImageDimensionInput.js
3 files changed, 29 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/AdvancedSearch 
refs/changes/22/381522/1

diff --git a/AdvancedSearch.hooks.php b/AdvancedSearch.hooks.php
index eb2146d..41b097c 100644
--- a/AdvancedSearch.hooks.php
+++ b/AdvancedSearch.hooks.php
@@ -36,7 +36,16 @@
                                ( new MimeTypeConfigurator( 
MediaWikiServices::getInstance()->getMimeAnalyzer() ) )
                                        ->getMimeTypes( 
$special->getConfig()->get( 'FileExtensions' ) )
                        );
-                       $special->getOutput()->addJsConfigVars( 
'advancedSearch.tooltips', TooltipGenerator::generateToolTips() );
+
+                       $special->getOutput()->addJsConfigVars(
+                               'advancedSearch.tooltips',
+                               TooltipGenerator::generateToolTips()
+                       );
+
+                       $special->getOutput()->addJsConfigVars(
+                               'advancedSearch.languageDirection',
+                               $special->getLanguage()->getDir()
+                       );
                }
        }
 
diff --git a/modules/ext.advancedSearch.init.js 
b/modules/ext.advancedSearch.init.js
index 48a4291..cab21dd 100644
--- a/modules/ext.advancedSearch.init.js
+++ b/modules/ext.advancedSearch.init.js
@@ -156,7 +156,7 @@
                        init: function () {
                                return new 
mw.libs.advancedSearch.ui.ArbitraryWordInput(
                                        state,
-                                       { optionId: 'phrase' }
+                                       newWidgetConfig( 'phrase' )
                                );
                        }
                },
@@ -181,7 +181,7 @@
                        init: function () {
                                return new 
mw.libs.advancedSearch.ui.ArbitraryWordInput(
                                        state,
-                                       { optionId: 'or' }
+                                       newWidgetConfig( 'or' )
                                );
                        }
                },
@@ -210,7 +210,7 @@
                        init: function () {
                                return new 
mw.libs.advancedSearch.ui.TemplateSearch(
                                        state,
-                                       { optionId: 'hastemplate' }
+                                       newWidgetConfig( 'hastemplate' )
                                );
                        },
                        customEventHandling: true
@@ -250,10 +250,7 @@
                                return new 
mw.libs.advancedSearch.ui.FileTypeSelection(
                                        state,
                                        new 
mw.libs.advancedSearch.dm.FileTypeOptionProvider( mw.config.get( 
'advancedSearch.mimeTypes' ) ),
-                                       {
-                                               optionId: 'filetype',
-                                               name: 
'advancedSearchOption-filetype'
-                                       }
+                                       newWidgetConfig( 'filetype' )
                                );
                        },
                        requiredNamespace: 6
@@ -269,9 +266,7 @@
                        init: function () {
                                return new 
mw.libs.advancedSearch.ui.ImageDimensionInput(
                                        state,
-                                       {
-                                               optionId: 'filew'
-                                       }
+                                       newWidgetConfig( 'filew' )
                                );
                        },
                        layout: createOptionalFieldLayout
@@ -287,9 +282,7 @@
                        init: function () {
                                return new 
mw.libs.advancedSearch.ui.ImageDimensionInput(
                                        state,
-                                       {
-                                               optionId: 'fileh'
-                                       }
+                                       newWidgetConfig( 'fileh' )
                                );
                        },
                        layout: createOptionalFieldLayout
@@ -304,6 +297,17 @@
                // neartitle:…
                // morelike:…
        ];
+
+       function newWidgetConfig( optionId, options ) {
+               return $.extend(
+                       {
+                               optionId: optionId,
+                               id: 'advancedSearchOption-' + optionId,
+                               dir: mw.config.get( 
'advancedSearch.languageDirection' )
+                       },
+                       options
+               );
+       }
 
        /**
         * @return {string[]}
@@ -347,10 +351,7 @@
                        function () {
                                return new mw.libs.advancedSearch.ui.TextInput(
                                        state,
-                                       {
-                                               id: 'advancedSearchOption-' + 
option.id,
-                                               optionId: option.id
-                                       }
+                                       newWidgetConfig( option.id )
                                );
                        };
 
diff --git a/modules/ui/ext.advancedSearch.ImageDimensionInput.js 
b/modules/ui/ext.advancedSearch.ImageDimensionInput.js
index 20e04a3..ecb8af3 100644
--- a/modules/ui/ext.advancedSearch.ImageDimensionInput.js
+++ b/modules/ui/ext.advancedSearch.ImageDimensionInput.js
@@ -35,7 +35,7 @@
                        ],
                        value: '>'
                } );
-               this.valueInput = new OO.ui.TextInputWidget( { label: 'px' } );
+               this.valueInput = new OO.ui.TextInputWidget( { label: 'px', 
dir: config.dir } );
 
                this.operatorInput.connect( this, { change: 'onInputChange' } );
                this.valueInput.connect( this, { change: 'onInputChange' } );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c889e519474e96dcc6f89e6979a72a811a2c9c5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/AdvancedSearch
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com>

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

Reply via email to