X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/6c8f14c09105d0afa4c1574215c59b5021040e76..caeaf8dc94b5e3f75dc98ec92dc7b76049cdddb6:/wp-admin/js/user-suggest.js diff --git a/wp-admin/js/user-suggest.js b/wp-admin/js/user-suggest.js index 0bcfada4..0113ded0 100644 --- a/wp-admin/js/user-suggest.js +++ b/wp-admin/js/user-suggest.js @@ -1,13 +1,30 @@ -(function($) { - var id = 'undefined' !== typeof current_site_id ? '&site_id=' + current_site_id : ''; +/* global ajaxurl, current_site_id, isRtl */ + +(function( $ ) { + var id = ( typeof current_site_id !== 'undefined' ) ? '&site_id=' + current_site_id : ''; $(document).ready( function() { - $( '.wp-suggest-user' ).autocomplete({ - source: ajaxurl + '?action=autocomplete-user&autocomplete_type=add' + id, - delay: 500, - minLength: 2, - position: ( 'undefined' !== typeof isRtl && isRtl ) ? { my: 'right top', at: 'right bottom', offset: '0, -1' } : { offset: '0, -1' }, - open: function() { $(this).addClass('open'); }, - close: function() { $(this).removeClass('open'); } + var position = { offset: '0, -1' }; + if ( typeof isRtl !== 'undefined' && isRtl ) { + position.my = 'right top'; + position.at = 'right bottom'; + } + $( '.wp-suggest-user' ).each( function(){ + var $this = $( this ), + autocompleteType = ( typeof $this.data( 'autocompleteType' ) !== 'undefined' ) ? $this.data( 'autocompleteType' ) : 'add', + autocompleteField = ( typeof $this.data( 'autocompleteField' ) !== 'undefined' ) ? $this.data( 'autocompleteField' ) : 'user_login'; + + $this.autocomplete({ + source: ajaxurl + '?action=autocomplete-user&autocomplete_type=' + autocompleteType + '&autocomplete_field=' + autocompleteField + id, + delay: 500, + minLength: 2, + position: position, + open: function() { + $( this ).addClass( 'open' ); + }, + close: function() { + $( this ).removeClass( 'open' ); + } + }); }); }); -})(jQuery); \ No newline at end of file +})( jQuery );