jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/375944 )
Change subject: Extracted functions in form initialization code ...................................................................... Extracted functions in form initialization code Change-Id: Ida21865af65d88919879097876e861a97a537635 --- M modules/ext.advancedSearch.init.js 1 file changed, 37 insertions(+), 23 deletions(-) Approvals: jenkins-bot: Verified Kai Nissen (WMDE): Looks good to me, approved diff --git a/modules/ext.advancedSearch.init.js b/modules/ext.advancedSearch.init.js index b4a2def..284d02a 100644 --- a/modules/ext.advancedSearch.init.js +++ b/modules/ext.advancedSearch.init.js @@ -340,23 +340,44 @@ $searchField.val( mw.util.getParamValue( 'advancedSearchOption-original' ) ); - advancedOptions.forEach( function ( option ) { - if ( option.enabled && !option.enabled() ) { - return; - } + function createWidget( option ) { + var initializationFunction = option.init || + function () { + return new mw.libs.advancedSearch.ui.TextInput( + state, + { + id: 'advancedSearchOption-' + option.id, + optionId: option.id + } + ); + }; - var paramName = 'advancedSearchOption-' + option.id; - - var widgetInit = option.init || function () { - return new mw.libs.advancedSearch.ui.TextInput( state, { - id: paramName, - optionId: option.id - } ); - }, - widget = widgetInit(); + var widget = initializationFunction(); if ( !option.customEventHandling ) { widget.on( 'change', createMultiSelectChangeHandler( option.id ) ); + } + + return widget; + } + + function createLayout( option, widget ) { + if ( option.layout ) { + return option.layout( widget, option ); + } + + return new OO.ui.FieldLayout( + widget, + { + label: mw.msg( 'advancedsearch-field-' + option.id ), + align: 'right' + } + ); + } + + advancedOptions.forEach( function ( option ) { + if ( option.enabled && !option.enabled() ) { + return; } if ( !optionSets[ option.group ] ) { @@ -365,16 +386,9 @@ } ); } - var layout; - if ( option.layout ) { - layout = option.layout( widget, option ); - } else { - layout = new OO.ui.FieldLayout( widget, { - label: mw.msg( 'advancedsearch-field-' + option.id ), - align: 'right' - } ); - } - optionSets[ option.group ].addItems( [ layout ] ); + optionSets[ option.group ].addItems( [ + createLayout( option, createWidget( option ) ) + ] ); } ); var $allOptions = $( '<div>' ).prop( { 'class': 'mw-advancedSearch-fieldContainer' } ); -- To view, visit https://gerrit.wikimedia.org/r/375944 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ida21865af65d88919879097876e861a97a537635 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/AdvancedSearch Gerrit-Branch: master Gerrit-Owner: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Andrew-WMDE <andrew.kos...@wikimedia.de> Gerrit-Reviewer: Gabriel Birke <gabriel.bi...@wikimedia.de> Gerrit-Reviewer: Kai Nissen (WMDE) <kai.nis...@wikimedia.de> Gerrit-Reviewer: Pablo Grass (WMDE) <pablo.gr...@wikimedia.de> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: WMDE-Fisch <christoph.jau...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits