1 (function($) { |
1 /* global ajaxurl, current_site_id, isRtl */ |
2 var id = 'undefined' !== typeof current_site_id ? '&site_id=' + current_site_id : ''; |
2 |
|
3 (function( $ ) { |
|
4 var id = ( typeof current_site_id !== 'undefined' ) ? '&site_id=' + current_site_id : ''; |
3 $(document).ready( function() { |
5 $(document).ready( function() { |
4 $( '.wp-suggest-user' ).autocomplete({ |
6 var position = { offset: '0, -1' }; |
5 source: ajaxurl + '?action=autocomplete-user&autocomplete_type=add' + id, |
7 if ( typeof isRtl !== 'undefined' && isRtl ) { |
6 delay: 500, |
8 position.my = 'right top'; |
7 minLength: 2, |
9 position.at = 'right bottom'; |
8 position: ( 'undefined' !== typeof isRtl && isRtl ) ? { my: 'right top', at: 'right bottom', offset: '0, -1' } : { offset: '0, -1' }, |
10 } |
9 open: function() { $(this).addClass('open'); }, |
11 $( '.wp-suggest-user' ).each( function(){ |
10 close: function() { $(this).removeClass('open'); } |
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 }); |
11 }); |
28 }); |
12 }); |
29 }); |
13 })(jQuery); |
30 })( jQuery ); |