Revision e4971398
Von Sven Schöling vor fast 9 Jahren hinzugefügt
js/kivi.QuickSearch.js | ||
---|---|---|
1 | 1 |
namespace('kivi', function(k){ |
2 |
'use strict'; |
|
2 | 3 |
k.QuickSearch = function($real, options) { |
3 | 4 |
if ($real.data("quick_search")) |
4 | 5 |
return $real.data("quick_search"); |
... | ... | |
13 | 14 |
|
14 | 15 |
function send_query(action, term, id, success) { |
15 | 16 |
var data = { module: o.module }; |
16 |
if (term != undefined) data.term = term; |
|
17 |
if (id != undefined) data.id = id; |
|
17 |
if (term !== undefined) data.term = term;
|
|
18 |
if (id !== undefined) data.id = id;
|
|
18 | 19 |
$.ajax($.extend(o, { |
19 | 20 |
url: 'controller.pl?action=TopQuickSearch/' + action, |
20 | 21 |
dataType: "json", |
... | ... | |
29 | 30 |
|
30 | 31 |
$real.autocomplete({ |
31 | 32 |
source: function(req, rsp) { |
32 |
send_query('query_autocomplete', req.term, undefined, function (data){ rsp(data) }); |
|
33 |
send_query('query_autocomplete', req.term, undefined, function (data){ rsp(data); });
|
|
33 | 34 |
}, |
34 | 35 |
select: function(event, ui) { |
35 | 36 |
send_query('select_autocomplete', undefined, ui.item.id, kivi.eval_json_result); |
... | ... | |
37 | 38 |
}); |
38 | 39 |
$real.keydown(function(event){ |
39 | 40 |
if (event.which == KEY.ENTER) { |
40 |
if ($real.val() != '') { |
|
41 |
if ($real.val() !== '') {
|
|
41 | 42 |
submit_search($real.val()); |
42 | 43 |
} |
43 | 44 |
} |
44 | 45 |
}); |
45 | 46 |
|
46 | 47 |
$real.data('quick_search', {}); |
47 |
} |
|
48 |
};
|
|
48 | 49 |
}); |
49 | 50 |
|
50 | 51 |
$(function(){ |
51 | 52 |
$('input[id^=top-quick-search]').each(function(_,e){ |
52 |
kivi.QuickSearch($(e), { module: $(e).attr('module') }) |
|
53 |
}) |
|
54 |
}) |
|
53 |
kivi.QuickSearch($(e), { module: $(e).attr('module') }); |
|
54 |
}); |
|
55 |
}); |
Auch abrufbar als: Unified diff
TopQuickSearch: javascript jshint