function formatProfile(profile) {
var data = $.tmpl('quickMinifiche', profile);
- data.find('a').popWin(840, 600).click(function() { $popup.hide(); });
- data.click(data.find('a').click());
+ data.find('a').popWin(840, 600).click(function() {
+ $popup.hide();
+ });
return data;
}
function doUpdatePopup()
{
var quick = $(this).val();
- if (disabled) {
+ if (query !== null) {
+ query.abort();
+ }
+ if (disabled || quick.length < 3) {
+ previous = quick;
$popup.hide();
return true;
}
$popup.show();
return true;
}
- if (query !== null) {
- query.abort();
- query = null;
- }
query = $.xapi(url, $.extend({ 'quick': quick }, args), function(data) {
query = null;
$popup.empty();
- if (data.profile_count > 10) {
+ if (data.profile_count > 10 || data.profile_count < 0) {
$popup.hide();
return;
}
setTimeout(function() {
updatePopup = doUpdatePopup;
if (pending) {
- updatePopup();
+ updatePopup.call($this.get(0));
}
pending = false;
}, 500);
$page->trigError('Malformed search query');
return PL_BAD_REQUEST;
}
+ if (strlen(trim($payload['quick'])) < 3) {
+ $page->jsonAssign('profile_count', -1);
+ $page->jsonAssign('profiles', array());
+ return PL_JSON;
+ }
Env::set('quick', $payload['quick']);
foreach (array('with_soundex', 'exact') as $key) {
if (isset($payload[$key])) {