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.
This commit is contained in:
Andrew Brown 2014-02-18 17:22:04 -08:00 committed by Jörn Friedrich Dreyer
parent 7a224f5762
commit 5dc2e73fe0
1 changed files with 9 additions and 28 deletions

View File

@ -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'));
};
};
};