blob: cb5ec31cd313e43ecef06f2701c40c64b5c12c99 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
OC.search.catagorizeResults=function(results){
var types={};
for(var i=0;i<results.length;i++){
var type=results[i].type;
if(!types[type]){
types[type]=[];
}
types[type].push(results[i]);
}
return types;
}
OC.search.hide=function(){
$('#searchresults').hide();
if($('#searchbox').val().length>2){
$('#searchbox').val('');
};
}
OC.search.showResults=function(results){
if(!OC.search.showResults.loaded){
var parent=$('<div/>');
$('body').append(parent);
parent.load(OC.filePath('search','templates','part.results.php'),function(){
OC.search.showResults.loaded=true;
$('#searchresults').click(function(event){
event.stopPropagation();
});
$(window).click(function(event){
OC.search.hide();
});
OC.search.showResults(results);
});
}else{
var types=OC.search.catagorizeResults(results);
$('#searchresults').show();
$('#searchresults tr.result').remove();
for(var name in types){
var type=types[name];
if(type.length>0){
var row=$('#searchresults tr.template').clone();
row.removeClass('template');
row.addClass('result');
row.children('td.type').text(name);
row.find('td.result a').attr('href',type[0].link);
row.find('td.result div.name').text(type[0].name);
row.find('td.result div.text').text(type[0].text);
if(OC.search.customResults[name]){//give plugins the ability to customize the entries in here
OC.search.customResults[name](row,type[0]);
}
$('#searchresults tbody').append(row);
for(var i=1;i<type.length;i++){
var row=$('#searchresults tr.template').clone();
row.removeClass('template');
row.addClass('result');
row.find('td.result a').attr('href',type[i].link);
row.find('td.result div.name').text(type[i].name);
row.find('td.result div.text').text(type[i].text);
if(OC.search.customResults[name]){//give plugins the ability to customize the entries in here
OC.search.customResults[name](row,type[i]);
}
$('#searchresults tbody').append(row);
}
}
}
}
}
OC.search.showResults.loaded=false;
|