resources: Strip '$' and 'mw' from file closures
[lhc/web/wiklou.git] / resources / src / mediawiki.widgets / mw.widgets.CategoryMultiselectWidget.js
index b3bcc0d..54ddca7 100644 (file)
@@ -4,12 +4,12 @@
  * @copyright 2011-2015 MediaWiki Widgets Team and others; see AUTHORS.txt
  * @license The MIT License (MIT); see LICENSE.txt
  */
-( function ( $, mw ) {
+( function () {
        var hasOwn = Object.prototype.hasOwnProperty,
                NS_CATEGORY = mw.config.get( 'wgNamespaceIds' ).category;
 
        /**
-        * Category selector widget. Displays an OO.ui.CapsuleMultiselectWidget
+        * Category selector widget. Displays an OO.ui.MenuTagMultiselectWidget
         * and autocompletes with available categories.
         *
         *     mw.loader.using( 'mediawiki.widgets.CategoryMultiselectWidget', function () {
@@ -27,7 +27,7 @@
         *
         * @class mw.widgets.CategoryMultiselectWidget
         * @uses mw.Api
-        * @extends OO.ui.CapsuleMultiselectWidget
+        * @extends OO.ui.MenuTagMultiselectWidget
         * @mixins OO.ui.mixin.PendingElement
         *
         * @constructor
@@ -62,7 +62,7 @@
                OO.ui.mixin.PendingElement.call( this, $.extend( {}, config, { $pending: this.$handle } ) );
 
                // Event handler to call the autocomplete methods
-               this.$input.on( 'change input cut paste', OO.ui.debounce( this.updateMenuItems.bind( this ), 100 ) );
+               this.input.$input.on( 'change input cut paste', OO.ui.debounce( this.updateMenuItems.bind( this ), 100 ) );
 
                // Initialize
                this.api = config.api || new mw.Api();
@@ -71,7 +71,7 @@
 
        /* Setup */
 
-       OO.inheritClass( mw.widgets.CategoryMultiselectWidget, OO.ui.CapsuleMultiselectWidget );
+       OO.inheritClass( mw.widgets.CategoryMultiselectWidget, OO.ui.MenuTagMultiselectWidget );
        OO.mixinClass( mw.widgets.CategoryMultiselectWidget, OO.ui.mixin.PendingElement );
 
        /* Methods */
         */
        mw.widgets.CategoryMultiselectWidget.prototype.updateMenuItems = function () {
                this.getMenu().clearItems();
-               this.getNewMenuItems( this.$input.val() ).then( function ( items ) {
+               this.getNewMenuItems( this.input.$input.val() ).then( function ( items ) {
                        var existingItems, filteredItems,
                                menu = this.getMenu();
 
                        // Never show the menu if the input lost focus in the meantime
-                       if ( !this.$input.is( ':focus' ) ) {
+                       if ( !this.input.$input.is( ':focus' ) ) {
                                return;
                        }
 
        /**
         * @inheritdoc
         */
-       mw.widgets.CategoryMultiselectWidget.prototype.createItemWidget = function ( data ) {
+       mw.widgets.CategoryMultiselectWidget.prototype.createTagItemWidget = function ( data ) {
                var title = mw.Title.makeTitle( NS_CATEGORY, data );
-               if ( !title ) {
-                       return null;
-               }
-               return new mw.widgets.CategoryCapsuleItemWidget( {
+
+               return new mw.widgets.CategoryTagItemWidget( {
                        apiUrl: this.api.apiUrl || undefined,
                        title: title
                } );
         */
        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.
+               // #createItemWidget and CategoryTagItemWidget will do, otherwise we won't find duplicates.
                var title = mw.Title.makeTitle( NS_CATEGORY, data );
                if ( !title ) {
                        return null;
                                } ).done( function ( res ) {
                                        var categories = [];
 
-                                       $.each( res.query.pages, function ( index, page ) {
+                                       res.query.pages.forEach( function ( page ) {
                                                if ( !page.missing ) {
                                                        categories.push( page.title );
                                                }
                                } ).done( function ( res ) {
                                        var categories = [];
 
-                                       $.each( res.query.pages, function ( index, page ) {
+                                       res.query.pages.forEach( function ( page ) {
                                                if ( !page.missing && Array.isArray( page.categories ) ) {
                                                        categories.push.apply( categories, page.categories.map( function ( category ) {
                                                                return category.title;
                /** Search only parent categories */
                ParentCategories: 4
        };
-
-       // For backwards compatibility. See T161285.
-       mw.widgets.CategorySelector = mw.widgets.CategoryMultiselectWidget;
-}( jQuery, mediaWiki ) );
+}() );