]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/user-suggest.js
WordPress 4.4.2-scripts
[autoinstalls/wordpress.git] / wp-admin / js / user-suggest.js
1 /* global ajaxurl, current_site_id, isRtl */
2
3 (function( $ ) {
4         var id = ( typeof current_site_id !== 'undefined' ) ? '&site_id=' + current_site_id : '';
5         $(document).ready( function() {
6                 var position = { offset: '0, -1' };
7                 if ( typeof isRtl !== 'undefined' && isRtl ) {
8                         position.my = 'right top';
9                         position.at = 'right bottom';
10                 }
11                 $( '.wp-suggest-user' ).each( function(){
12                         var $this = $( this ),
13                                 autocompleteType = ( typeof $this.data( 'autocompleteType' ) !== 'undefined' ) ? $this.data( 'autocompleteType' ) : 'add',
14                                 autocompleteField = ( typeof $this.data( 'autocompleteField' ) !== 'undefined' ) ? $this.data( 'autocompleteField' ) : 'user_login';
15
16                         $this.autocomplete({
17                                 source:    ajaxurl + '?action=autocomplete-user&autocomplete_type=' + autocompleteType + '&autocomplete_field=' + autocompleteField + id,
18                                 delay:     500,
19                                 minLength: 2,
20                                 position:  position,
21                                 open: function() {
22                                         $( this ).addClass( 'open' );
23                                 },
24                                 close: function() {
25                                         $( this ).removeClass( 'open' );
26                                 }
27                         });
28                 });
29         });
30 })( jQuery );