You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

31 lines
1.0 KiB

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