| 1 |
var fep_delay = (function(){ |
| 2 |
var timer = 0; |
| 3 |
return function(callback, ms){ |
| 4 |
clearTimeout (timer); |
| 5 |
timer = setTimeout(callback, ms); |
| 6 |
}; |
| 7 |
})(); |
| 8 |
jQuery( document ).on( "keyup", "#fep-message-top", function() { |
| 9 |
fep_delay(function(){ |
| 10 |
jQuery('#fep-result').hide(); |
| 11 |
jQuery('#fep-message-top').addClass('fep-loading-gif'); |
| 12 |
var display_name=jQuery('#fep-message-top').val(); |
| 13 |
var data = { |
| 14 |
action: 'fep_autosuggestion_ajax', |
| 15 |
searchBy: display_name, |
| 16 |
token: fep_script.nonce |
| 17 |
}; |
| 18 |
|
| 19 |
jQuery.post(fep_script.ajaxurl, data, function(results) { |
| 20 |
jQuery('#fep-message-top').removeClass('fep-loading-gif'); |
| 21 |
jQuery('#fep-result').html(results); |
| 22 |
if ( results ){ |
| 23 |
jQuery('#fep-result').show(); |
| 24 |
} |
| 25 |
|
| 26 |
}); |
| 27 |
}, 1000 ); |
| 28 |
}); |
| 29 |
|
| 30 |
function fep_fill_autosuggestion(login, display) { |
| 31 |
|
| 32 |
jQuery('#fep-message-to').val( login ); |
| 33 |
jQuery('#fep-message-top').val( display ); |
| 34 |
jQuery('#fep-result').hide(); |
| 35 |
} |
| 36 |
|