Merge "Fix sessionfailure i18n message during authentication"
[lhc/web/wiklou.git] / resources / src / mediawiki.widgets / mw.widgets.CategoryMultiselectWidget.js
index ccc5c9d..b3bcc0d 100644 (file)
@@ -5,7 +5,8 @@
  * @license The MIT License (MIT); see LICENSE.txt
  */
 ( function ( $, mw ) {
-       var NS_CATEGORY = mw.config.get( 'wgNamespaceIds' ).category;
+       var hasOwn = Object.prototype.hasOwnProperty,
+               NS_CATEGORY = mw.config.get( 'wgNamespaceIds' ).category;
 
        /**
         * Category selector widget. Displays an OO.ui.CapsuleMultiselectWidget
                        promises = [],
                        deferred = $.Deferred();
 
-               if ( $.trim( input ) === '' ) {
+               if ( input.trim() === '' ) {
                        deferred.resolve( [] );
                        return deferred.promise();
                }
        /**
         * @inheritdoc
         */
-       mw.widgets.CategoryMultiselectWidget.prototype.getItemFromData = function ( data ) {
+       mw.widgets.CategoryMultiselectWidget.prototype.findItemFromData = function ( data ) {
                // This is a bit of a hack... We have to canonicalize the data in the same way that
                // #createItemWidget and CategoryCapsuleItemWidget will do, otherwise we won't find duplicates.
                var title = mw.Title.makeTitle( NS_CATEGORY, data );
                if ( !title ) {
                        return null;
                }
-               return OO.ui.mixin.GroupElement.prototype.getItemFromData.call( this, title.getMainText() );
+               return OO.ui.mixin.GroupElement.prototype.findItemFromData.call( this, title.getMainText() );
        };
 
        /**
                        cacheKey = input + searchType.toString();
 
                // Check cache
-               if ( this.searchCache[ cacheKey ] !== undefined ) {
+               if ( hasOwn.call( this.searchCache, cacheKey ) ) {
                        return this.searchCache[ cacheKey ];
                }
 
                                        var categories = [];
 
                                        $.each( res.query.pages, function ( index, page ) {
-                                               if ( !page.missing && $.isArray( page.categories ) ) {
+                                               if ( !page.missing && Array.isArray( page.categories ) ) {
                                                        categories.push.apply( categories, page.categories.map( function ( category ) {
                                                                return category.title;
                                                        } ) );
                /** Search for existing categories with the exact title */
                Exists: 2,
 
-               /** Search only subcategories  */
+               /** Search only subcategories */
                SubCategories: 3,
 
                /** Search only parent categories */