diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-06-09 23:49:25 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-06-09 23:49:25 +0200 |
commit | 5f4f7e69cf401219287d1a07924e59c00fe834c0 (patch) | |
tree | c702cb66d686de92a34553216e7dcf9941c40461 /core | |
parent | b9c7b5575a7d230ee6aa5e2f314d18661d3828be (diff) | |
parent | e882f5e930214fd42703954b84d9f4bafa9278a4 (diff) | |
download | nextcloud-server-5f4f7e69cf401219287d1a07924e59c00fe834c0.tar.gz nextcloud-server-5f4f7e69cf401219287d1a07924e59c00fe834c0.zip |
Merge pull request #16810 from owncloud/disable-search-if-not-implemented
Disable search field in case there is no search available to the curr…
Diffstat (limited to 'core')
-rw-r--r-- | core/search/js/search.js | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/core/search/js/search.js b/core/search/js/search.js index cb3c3bcf7d7..bc67eb0e154 100644 --- a/core/search/js/search.js +++ b/core/search/js/search.js @@ -94,6 +94,9 @@ /** * Do a search query and display the results * @param {string} query the search query + * @param inApps + * @param page + * @param size */ this.search = function(query, inApps, page, size) { if (query) { @@ -160,7 +163,8 @@ var summaryAndStatusHeight = 118; function isStatusOffScreen() { - return $searchResults.position() && ($searchResults.position().top + summaryAndStatusHeight > window.innerHeight); + return $searchResults.position() && + ($searchResults.position().top + summaryAndStatusHeight > window.innerHeight); } function placeStatus() { @@ -252,10 +256,11 @@ * Event handler for when scrolling the list container. * This appends/renders the next page of entries when reaching the bottom. */ - function onScroll(e) { + function onScroll() { if ($searchResults && lastQuery !== false && lastResults.length > 0) { var resultsBottom = $searchResults.offset().top + $searchResults.height(); - var containerBottom = $searchResults.offsetParent().offset().top + $searchResults.offsetParent().height(); + var containerBottom = $searchResults.offsetParent().offset().top + + $searchResults.offsetParent().height(); if ( resultsBottom < containerBottom * 1.2 ) { self.search(lastQuery, lastInApps, lastPage + 1); } @@ -289,7 +294,7 @@ event.preventDefault(); }); - $searchBox.on('search', function (event) { + $searchBox.on('search', function () { if($searchBox.val() === '') { if(self.hasFilter(getCurrentApp())) { self.getFilter(getCurrentApp())(''); @@ -359,6 +364,14 @@ placeStatus(); OC.Plugins.attach('OCA.Search', this); + + // hide search file if search is not enabled + if(self.hasFilter(getCurrentApp())) { + return; + } + if ($searchResults.length === 0) { + $searchBox.hide(); + } } }; OCA.Search = Search; @@ -366,19 +379,18 @@ $(document).ready(function() { var $searchResults = $('#searchresults'); - if ($searchResults.length) { + if ($searchResults.length > 0) { $searchResults.addClass('hidden'); $('#app-content') .find('.viewcontainer').css('min-height', 'initial'); + $searchResults.load(OC.webroot + '/core/search/templates/part.results.html', function () { + OC.Search = new OCA.Search($('#searchbox'), $('#searchresults')); + }); } else { - $searchResults = $('<div id="searchresults" class="hidden"/>'); - $('#app-content') - .append($searchResults) - .find('.viewcontainer').css('min-height', 'initial'); + _.defer(function() { + OC.Search = new OCA.Search($('#searchbox'), $('#searchresults')); + }); } - $searchResults.load(OC.webroot + '/core/search/templates/part.results.html', function () { - OC.Search = new OCA.Search($('#searchbox'), $('#searchresults')); - }); }); /** |