WordPress.org

Make WordPress Core

Ticket #43270: 43270.patch

File 43270.patch, 1.9 KB (added by timhavinga, 4 years ago)
  • src/wp-admin/js/user-suggest.js

     
    11/* global ajaxurl, current_site_id, isRtl */
     2/**
     3 * Suggests users in a multisite environment.
     4 *
     5 * For input fields where the admin can select a user based on email or
     6 * username, this script shows an autocompletion menu for these inputs. Should
     7 * only be used in a multisite environment. Only users in the currently active
     8 * site are shown.
     9 *
     10 * @since 3.4.0
     11 */
    212
    313(function( $ ) {
    414        var id = ( typeof current_site_id !== 'undefined' ) ? '&site_id=' + current_site_id : '';
     
    818                        position.my = 'right top';
    919                        position.at = 'right bottom';
    1020                }
     21
     22                /**
     23                 * Adds an autocomplete function to input fields marked with the class
     24                 * 'wp-suggest-user'. A minimum of two characters is required to trigger
     25                 * the suggestions.
     26                 * The autocompletion menu is shown at the left bottom of the input
     27                 * field. On RTL installations, it is shown at the right top.
     28                 * Adds the class 'open' to the input field when the autocompletion menu
     29                 * is shown.
     30                 *
     31                 * Does a backend call to retrieve the users.
     32                 *
     33                 * Optional data-attributes:
     34                 * - data-autocomplete-type (add, search)
     35                 *   The action that is going to be performed: search for existing users
     36                 *   or add a new one. Default: add
     37                 * - data-autocomplete-field (user_login, user_email)
     38                 *   The field that is returned as the value for the suggestion.
     39                 *   Default: user_login
     40                 *
     41                 * @see wp-admin/includes/admin-actions.php:wp_ajax_autocomplete_user()
     42                 */
    1143                $( '.wp-suggest-user' ).each( function(){
    1244                        var $this = $( this ),
    1345                                autocompleteType = ( typeof $this.data( 'autocompleteType' ) !== 'undefined' ) ? $this.data( 'autocompleteType' ) : 'add',