');
-
- // do the actual search query
- $.getJSON(OC.generateUrl('core/search'), {query:query, inApps:inApps, page:page, size:size }, function(results) {
- lastResults = results;
- if (page === 1) {
- showResults(results);
- } else {
- addResults(results);
- }
- });
- }, 500);
- }
- };
-
- //TODO should be a core method, see https://github.com/owncloud/core/issues/12557
- function getCurrentApp() {
- var content = document.getElementById('content');
- if (content) {
- var classList = document.getElementById('content').className.split(/\s+/);
- for (var i = 0; i < classList.length; i++) {
- if (classList[i].indexOf('app-') === 0) {
- return classList[i].substr(4);
- }
- }
- }
- return false;
- }
-
- var $status = $searchResults.find('#status');
- // summaryAndStatusHeight is a constant
- var summaryAndStatusHeight = 118;
-
- function isStatusOffScreen() {
- return $searchResults.position() &&
- ($searchResults.position().top + summaryAndStatusHeight > window.innerHeight);
- }
-
- function placeStatus() {
- if (isStatusOffScreen()) {
- $status.addClass('fixed');
- } else {
- $status.removeClass('fixed');
- }
+ if (typeof searchCallback !== 'function') {
+ throw 'searchCallback must be a function';
}
- function showResults(results) {
- lastResults = results;
- $searchResults.find('tr.result').remove();
- $searchResults.removeClass('hidden');
- addResults(results);
+ if (typeof resetCallback !== 'function') {
+ throw 'resetCallback must be a function';
}
- function addResults(results) {
- var $template = $searchResults.find('tr.template');
- jQuery.each(results, function (i, result) {
- var $row = $template.clone();
- $row.removeClass('template');
- $row.addClass('result');
-
- $row.data('result', result);
-
- // generic results only have four attributes
- $row.find('td.info div.name').text(result.name);
- $row.find('td.info a').attr('href', result.link);
- /**
- * Give plugins the ability to customize the search results. see result.js for examples
- */
- if (self.hasRenderer(result.type)) {
- $row = self.getRenderer(result.type)($row, result);
- } else {
- // for backward compatibility add text div
- $row.find('td.info div.name').addClass('result');
- $row.find('td.result div.name').after('');
- $row.find('td.result div.text').text(result.name);
- if (OC.search.customResults && OC.search.customResults[result.type]) {
- OC.search.customResults[result.type]($row, result);
- }
- }
- if ($row) {
- $searchResults.find('tbody').append($row);
- }
- });
- var count = $searchResults.find('tr.result').length;
- $status.data('count', count);
- if (count === 0) {
- $status.addClass('emptycontent').removeClass('status');
- $status.html('');
- $status.append($('{{item.longtext}}
\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t{{item.text}}\n\t\t\t{{item.longtext}}
\n\t\t\n\t{{t('settings', 'Default quota :')}}
\n\t\t\t\t\t\n\t\t\t{{ t('settings', 'View in store')}} ↗\n\n\t\t\t{{ t('settings', 'Visit website') }} ↗\n\t\t\t{{ t('settings', 'Report a bug') }} ↗\n\n\t\t\t{{ t('settings', 'User documentation') }} ↗\n\t\t\t{{ t('settings', 'Admin documentation') }} ↗\n\t\t\t{{ t('settings', 'Developer documentation') }} ↗\n\t\t
\n\n\t\t