Merge pull request #16810 from owncloud/disable-search-if-not-implemented

Disable search field in case there is no search available to the curr…
This commit is contained in:
Thomas Müller 2015-06-09 23:49:25 +02:00
commit 5f4f7e69cf
2 changed files with 25 additions and 12 deletions

View File

@ -6,6 +6,7 @@
<?php print_unescaped($content['content']) ?> <?php print_unescaped($content['content']) ?>
</div> </div>
<?php } ?> <?php } ?>
<div id="searchresults" class="hidden"></div>
</div><!-- closing app-content --> </div><!-- closing app-content -->
<!-- config hints for javascript --> <!-- config hints for javascript -->

View File

@ -94,6 +94,9 @@
/** /**
* Do a search query and display the results * Do a search query and display the results
* @param {string} query the search query * @param {string} query the search query
* @param inApps
* @param page
* @param size
*/ */
this.search = function(query, inApps, page, size) { this.search = function(query, inApps, page, size) {
if (query) { if (query) {
@ -160,7 +163,8 @@
var summaryAndStatusHeight = 118; var summaryAndStatusHeight = 118;
function isStatusOffScreen() { function isStatusOffScreen() {
return $searchResults.position() && ($searchResults.position().top + summaryAndStatusHeight > window.innerHeight); return $searchResults.position() &&
($searchResults.position().top + summaryAndStatusHeight > window.innerHeight);
} }
function placeStatus() { function placeStatus() {
@ -252,10 +256,11 @@
* Event handler for when scrolling the list container. * Event handler for when scrolling the list container.
* This appends/renders the next page of entries when reaching the bottom. * This appends/renders the next page of entries when reaching the bottom.
*/ */
function onScroll(e) { function onScroll() {
if ($searchResults && lastQuery !== false && lastResults.length > 0) { if ($searchResults && lastQuery !== false && lastResults.length > 0) {
var resultsBottom = $searchResults.offset().top + $searchResults.height(); 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 ) { if ( resultsBottom < containerBottom * 1.2 ) {
self.search(lastQuery, lastInApps, lastPage + 1); self.search(lastQuery, lastInApps, lastPage + 1);
} }
@ -289,7 +294,7 @@
event.preventDefault(); event.preventDefault();
}); });
$searchBox.on('search', function (event) { $searchBox.on('search', function () {
if($searchBox.val() === '') { if($searchBox.val() === '') {
if(self.hasFilter(getCurrentApp())) { if(self.hasFilter(getCurrentApp())) {
self.getFilter(getCurrentApp())(''); self.getFilter(getCurrentApp())('');
@ -359,6 +364,14 @@
placeStatus(); placeStatus();
OC.Plugins.attach('OCA.Search', this); 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; OCA.Search = Search;
@ -366,19 +379,18 @@
$(document).ready(function() { $(document).ready(function() {
var $searchResults = $('#searchresults'); var $searchResults = $('#searchresults');
if ($searchResults.length) { if ($searchResults.length > 0) {
$searchResults.addClass('hidden'); $searchResults.addClass('hidden');
$('#app-content') $('#app-content')
.find('.viewcontainer').css('min-height', 'initial'); .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 { } else {
$searchResults = $('<div id="searchresults" class="hidden"/>'); _.defer(function() {
$('#app-content') OC.Search = new OCA.Search($('#searchbox'), $('#searchresults'));
.append($searchResults) });
.find('.viewcontainer').css('min-height', 'initial');
} }
$searchResults.load(OC.webroot + '/core/search/templates/part.results.html', function () {
OC.Search = new OCA.Search($('#searchbox'), $('#searchresults'));
});
}); });
/** /**