5
|
1 |
/* global ajaxurl, current_site_id, isRtl */ |
|
2 |
|
|
3 |
(function( $ ) { |
|
4 |
var id = ( typeof current_site_id !== 'undefined' ) ? '&site_id=' + current_site_id : ''; |
0
|
5 |
$(document).ready( function() { |
5
|
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 |
}); |
0
|
28 |
}); |
|
29 |
}); |
5
|
30 |
})( jQuery ); |