Skip to content
Snippets Groups Projects
Commit a91f458f authored by Chris Hallberg's avatar Chris Hallberg
Browse files

Simplification of common.js.

parent 64cd98f1
No related merge requests found
...@@ -352,38 +352,36 @@ $(document).ready(function() { ...@@ -352,38 +352,36 @@ $(document).ready(function() {
}); });
// Search autocomplete // Search autocomplete
$('.autocomplete').each(function (i, element) { $('.autocomplete').autocomplete({
var op = $(element).autocomplete({ maxResults: 10,
maxResults: 10, loadingString: vufindString['loading']+'...',
loadingString: vufindString['loading']+'...', handler: function(query, cb) {
handler: function(query, cb) { var searcher = extractClassParams(this);
var searcher = extractClassParams(element); $.fn.autocomplete.ajax({
$.fn.autocomplete.ajax({ url: path + '/AJAX/JSON',
url: path + '/AJAX/JSON', data: {
data: { q:query,
q:query, method:'getACSuggestions',
method:'getACSuggestions', searcher:searcher['searcher'],
searcher:searcher['searcher'], type:searcher['type'] ? searcher['type'] : $(this).closest('.searchForm').find('.searchForm_type').val()
type:searcher['type'] ? searcher['type'] : $(element).closest('.searchForm').find('.searchForm_type').val() },
}, dataType:'json',
dataType:'json', success: function(json) {
success: function(json) { if (json.status == 'OK' && json.data.length > 0) {
if (json.status == 'OK' && json.data.length > 0) { var datums = [];
var datums = []; for (var i=0;i<json.data.length;i++) {
for (var i=0;i<json.data.length;i++) { datums.push({
datums.push({ val:json.data[i],
val:json.data[i], //href:'http://google.com/?q='+encodeURI(json.data[i]),
//href:'http://google.com/?q='+encodeURI(json.data[i]), });
});
}
cb(datums);
} else {
cb([]);
} }
cb(datums);
} else {
cb([]);
} }
}); }
} });
}); }
}); });
$('.searchForm_type').change(function() { $('.searchForm_type').change(function() {
var $lookfor = $(this).closest('.searchForm').find('.searchForm_lookfor[name]'); var $lookfor = $(this).closest('.searchForm').find('.searchForm_lookfor[name]');
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment