Browse Source

Simplify client-side result customization

The issue was that search results from other providers (contacts,
calendar, etc.) were unformatted, like 'event' or 'contact', while the
built-in event types (folder, file, etc.) were being modified by custom
result functions to something like 'Files' or 'Folders'. The fix is to
capitalize and translate all result types by default. Custom formatting
is still allowed (and example documentation has been added) but the
built-in result formatters where now unnecessary and were removed.
remotes/origin/ldap_group_count
Andrew Brown 13 years ago
committed by Jörn Friedrich Dreyer
parent
commit
5dc2e73fe0
  1. 37
      search/js/result.js

37
search/js/result.js

@ -64,7 +64,8 @@ OC.search.showResults=function(results){
row.data('index',index);
if (i === 0){
row.children('td.type').text(typeid);
var typeName = typeid.charAt(0).toUpperCase() + typeid.slice(1);
row.children('td.type').text(t('lib', typeName));
}
row.find('td.result div.name').text(type[i].name);
row.find('td.result div.text').text(type[i].text);
@ -86,7 +87,12 @@ OC.search.showResults=function(results){
}
index++;
//give plugins the ability to customize the entries in here
/**
* Give plugins the ability to customize the search results. For example:
* OC.search.customResults.file = function (row, item){
* if(item.name.search('.json') >= 0) ...
* };
*/
if(OC.search.customResults[typeid]){
OC.search.customResults[typeid](row, type[i]);
}
@ -109,29 +115,4 @@ OC.search.renderCurrent=function(){
$('#searchresults tr.result').removeClass('current');
$(result).addClass('current');
}
};
//
// customize search results, currently replaces a technical type with a more human friendly version
// TODO implement search result renderers instead of changing results after adding them to the DOM
//
OC.search.customResults.file = function (row, item) {
if(row.children('td.type').text() === 'file') {
row.children('td.type').text(t('lib','Files'));
};
};
OC.search.customResults.folder = function (row, item) {
if(row.children('td.type').text() === 'folder') {
row.children('td.type').text(t('lib','Folders'));
};
};
OC.search.customResults.image = function (row, item) {
if(row.children('td.type').text() === 'image') {
row.children('td.type').text(t('lib','Images'));
};
};
OC.search.customResults.audio = function (row, item) {
if(row.children('td.type').text() === 'audio') {
row.children('td.type').text(t('lib','Audio'));
};
};
};
Loading…
Cancel
Save