Merge "widgets: Code quality and cleanup pass"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 22 Jul 2015 08:20:16 +0000 (08:20 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 22 Jul 2015 08:20:16 +0000 (08:20 +0000)
includes/widget/NamespaceInputWidget.php
includes/widget/TitleInputWidget.php
includes/widget/UserInputWidget.php
resources/src/mediawiki.widgets/mw.widgets.NamespaceInputWidget.js
resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js
resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js
resources/src/mediawiki.widgets/mw.widgets.UserInputWidget.js

index 69427c5..2d69ed7 100644 (file)
@@ -40,7 +40,6 @@ class NamespaceInputWidget extends \OOUI\Widget {
         */
        public function __construct( array $config = array() ) {
                // Configuration initialization
-
                $config = array_merge(
                        array(
                                'nameNamespace' => 'namespace',
index 37c9d9c..d3e2851 100644 (file)
@@ -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;
index 4147fca..e5663c3 100644 (file)
@@ -1,18 +1,17 @@
 <?php
 /**
- * MediaWiki Widgets \96 UserInputWidget class.
+ * MediaWiki Widgets  UserInputWidget class.
  *
  * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
  * @license The MIT License (MIT); see LICENSE.txt
  */
 namespace MediaWiki\Widget;
 
-use OOUI\TextInputWidget;
-
 /**
  * User input widget.
  */
-class UserInputWidget extends TextInputWidget {
+class UserInputWidget extends \OOUI\TextInputWidget {
+
        /**
         * @param array $config Configuration options
         */
index 0558c32..05e6f27 100644 (file)
@@ -25,7 +25,7 @@
         */
        mw.widgets.NamespaceInputWidget = function MwWidgetsNamespaceInputWidget( config ) {
                // Parent constructor
-               OO.ui.Widget.call( this, config );
+               mw.widgets.NamespaceInputWidget.parent.call( this, config );
 
                // Properties
                this.namespace = config.namespace;
                this.allValue = config.allValue;
 
                // Events
-               config.namespace.connect( this, { change: 'updateCheckboxesState' } );
+               this.namespace.connect( this, { change: 'updateCheckboxesState' } );
 
                // Initialization
                this.$element
                        .addClass( 'mw-widget-namespaceInputWidget' )
                        .append(
-                               config.namespace.$element,
-                               config.invert ? config.invert.$element : '',
-                               config.associated ? config.associated.$element : ''
+                               this.namespace.$element,
+                               this.invert ? this.invert.$element : '',
+                               this.associated ? this.associated.$element : ''
                        );
                this.updateCheckboxesState();
        };
 
-       /* Inheritance */
+       /* Setup */
 
        OO.inheritClass( mw.widgets.NamespaceInputWidget, OO.ui.Widget );
 
index e715361..bee5920 100644 (file)
@@ -5,6 +5,7 @@
  * @license The MIT License (MIT); see LICENSE.txt
  */
 ( function ( $, mw ) {
+
        /**
         * Creates an mw.widgets.TitleInputWidget object.
         *
@@ -30,7 +31,7 @@
                config = config || {};
 
                // Parent constructor
-               OO.ui.TextInputWidget.call( this, $.extend( {}, config, { autocomplete: false } ) );
+               mw.widgets.TitleInputWidget.parent.call( this, $.extend( {}, config, { autocomplete: false } ) );
 
                // Mixin constructors
                OO.ui.mixin.LookupElement.call( this, config );
                } );
        };
 
-       /* Inheritance */
+       /* Setup */
 
        OO.inheritClass( mw.widgets.TitleInputWidget, OO.ui.TextInputWidget );
-
        OO.mixinClass( mw.widgets.TitleInputWidget, OO.ui.mixin.LookupElement );
 
        /* Methods */
@@ -95,7 +95,7 @@
                this.setLookupsDisabled( true );
 
                // Parent method
-               retval = OO.ui.TextInputWidget.prototype.focus.apply( this, arguments );
+               retval = mw.widgets.TitleInputWidget.parent.prototype.focus.apply( this, arguments );
 
                this.setLookupsDisabled( false );
 
         * Get lookup cache item from server response data.
         *
         * @method
-        * @param {Mixed} data Response from server
+        * @param {Mixed} response Response from server
         */
-       mw.widgets.TitleInputWidget.prototype.getLookupCacheDataFromResponse = function ( data ) {
-               return data.query || {};
+       mw.widgets.TitleInputWidget.prototype.getLookupCacheDataFromResponse = function ( response ) {
+               return response.query || {};
        };
 
        /**
index 6623aa7..ec0c935 100644 (file)
@@ -45,9 +45,9 @@
                }, config );
 
                // Parent constructor
-               OO.ui.MenuOptionWidget.call( this, config );
+               mw.widgets.TitleOptionWidget.parent.call( this, config );
 
-               // Intialization
+               // Initialization
                this.$label.wrap( '<a>' );
                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 );
 
index 903660a..d540877 100644 (file)
@@ -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 );
                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 );
 
         * 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 || {};
        };
 
        /**
         */
        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