From f0f90ef4d00545ef0bae5e6f6e500b4944cc2148 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Wed, 22 Jul 2015 02:01:16 +0200 Subject: [PATCH] widgets: Code quality and cleanup pass Fixing typos, enforcing coding conventions from OOUI, renaming parameters, formatting code. Change-Id: I92dc28c8ac3d6c00e40ad48d76730deb29edefec --- includes/widget/NamespaceInputWidget.php | 1 - includes/widget/TitleInputWidget.php | 4 +--- includes/widget/UserInputWidget.php | 7 +++---- .../mw.widgets.NamespaceInputWidget.js | 12 ++++++------ .../mw.widgets.TitleInputWidget.js | 14 +++++++------- .../mw.widgets.TitleOptionWidget.js | 6 +++--- .../mw.widgets.UserInputWidget.js | 19 +++++++++---------- 7 files changed, 29 insertions(+), 34 deletions(-) diff --git a/includes/widget/NamespaceInputWidget.php b/includes/widget/NamespaceInputWidget.php index 69427c502e..2d69ed7c31 100644 --- a/includes/widget/NamespaceInputWidget.php +++ b/includes/widget/NamespaceInputWidget.php @@ -40,7 +40,6 @@ class NamespaceInputWidget extends \OOUI\Widget { */ public function __construct( array $config = array() ) { // Configuration initialization - $config = array_merge( array( 'nameNamespace' => 'namespace', diff --git a/includes/widget/TitleInputWidget.php b/includes/widget/TitleInputWidget.php index 37c9d9c4b9..d3e2851982 100644 --- a/includes/widget/TitleInputWidget.php +++ b/includes/widget/TitleInputWidget.php @@ -7,12 +7,10 @@ */ namespace MediaWiki\Widget; -use OOUI\TextInputWidget; - /** * Title input widget. */ -class TitleInputWidget extends TextInputWidget { +class TitleInputWidget extends \OOUI\TextInputWidget { protected $namespace = null; protected $relative = null; diff --git a/includes/widget/UserInputWidget.php b/includes/widget/UserInputWidget.php index 4147fca525..e5663c31d7 100644 --- a/includes/widget/UserInputWidget.php +++ b/includes/widget/UserInputWidget.php @@ -1,18 +1,17 @@ ' ); this.$link = this.$label.parent(); this.$link.attr( 'href', config.href ); @@ -75,7 +75,7 @@ } }; - /* Inheritance */ + /* Setup */ OO.inheritClass( mw.widgets.TitleOptionWidget, OO.ui.MenuOptionWidget ); diff --git a/resources/src/mediawiki.widgets/mw.widgets.UserInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.UserInputWidget.js index 903660af0d..d540877a0b 100644 --- a/resources/src/mediawiki.widgets/mw.widgets.UserInputWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.UserInputWidget.js @@ -5,6 +5,7 @@ * @license The MIT License (MIT); see LICENSE.txt */ ( function ( $, mw ) { + /** * Creates a mw.widgets.UserInputWidget object. * @@ -21,7 +22,7 @@ config = config || {}; // Parent constructor - OO.ui.TextInputWidget.call( this, $.extend( {}, config, { autocomplete: false } ) ); + mw.widgets.UserInputWidget.parent.call( this, $.extend( {}, config, { autocomplete: false } ) ); // Mixin constructors OO.ui.mixin.LookupElement.call( this, config ); @@ -34,10 +35,9 @@ this.lookupMenu.$element.addClass( 'mw-widget-userInputWidget-menu' ); }; - /* Inheritance */ + /* Setup */ OO.inheritClass( mw.widgets.UserInputWidget, OO.ui.TextInputWidget ); - OO.mixinClass( mw.widgets.UserInputWidget, OO.ui.mixin.LookupElement ); /* Methods */ @@ -62,7 +62,7 @@ this.setLookupsDisabled( true ); // Parent method - retval = OO.ui.TextInputWidget.prototype.focus.apply( this, arguments ); + retval = mw.widgets.UserInputWidget.parent.prototype.focus.apply( this, arguments ); this.setLookupsDisabled( false ); @@ -89,10 +89,10 @@ * Get lookup cache item from server response data. * * @method - * @param {Mixed} data Response from server + * @param {Mixed} response Response from server */ - mw.widgets.UserInputWidget.prototype.getLookupCacheDataFromResponse = function ( data ) { - return data.query || {}; + mw.widgets.UserInputWidget.prototype.getLookupCacheDataFromResponse = function ( response ) { + return response.query.allusers || {}; }; /** @@ -103,11 +103,10 @@ */ mw.widgets.UserInputWidget.prototype.getLookupMenuOptionsFromData = function ( data ) { var len, i, user, - users = data.allusers, items = []; - for ( i = 0, len = users.length; i < len; i++ ) { - user = users[i] || {}; + for ( i = 0, len = data.length; i < len; i++ ) { + user = data[i] || {}; items.push( new OO.ui.MenuOptionWidget( { label: user.name, data: user.name -- 2.20.1