diff options
author | Andrew Brown <andrew@casabrown.com> | 2014-02-18 17:22:04 -0800 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-06-05 19:23:44 +0200 |
commit | 5dc2e73fe08189833c0398117916b752b0f730d6 (patch) | |
tree | dfaab3201836852f48899ee1132d43dced7af32e /search | |
parent | 7a224f57626f684415b5f45660bd21ec7ebafe72 (diff) | |
download | nextcloud-server-5dc2e73fe08189833c0398117916b752b0f730d6.tar.gz nextcloud-server-5dc2e73fe08189833c0398117916b752b0f730d6.zip |
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.
Diffstat (limited to 'search')
-rw-r--r-- | search/js/result.js | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/search/js/result.js b/search/js/result.js index d2d68145304..b300f90f4c2 100644 --- a/search/js/result.js +++ b/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')); - }; -}; +};
\ No newline at end of file |