Skip to content

Commit

Permalink
Merge pull request #10385 from nextcloud/search-init-fix
Browse files Browse the repository at this point in the history
Fix search on public pages
  • Loading branch information
MorrisJobke authored Jul 25, 2018
2 parents a5d163a + a1d7d60 commit ebeaa37
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
7 changes: 5 additions & 2 deletions core/search/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@
var self = this;

if (typeof searchCallback !== 'function') {
throw 'searchCallback must be a function';
throw new Error('searchCallback must be a function');
}
if (typeof resetCallback !== 'function') {
throw 'resetCallback must be a function';
throw new Error('resetCallback must be a function');
}
if (!document.getElementById('searchbox')) {
throw new Error('searchBox not available');
}

this.searchCallback = searchCallback;
Expand Down
21 changes: 11 additions & 10 deletions core/search/js/searchprovider.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,26 +413,27 @@

$(document).ready(function() {
var $searchResults = $('#searchresults');
if ($searchResults.length > 0) {
var $searchBox = $('#searchbox');
if ($searchResults.length > 0 && $searchBox.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.Core(
$('#searchbox'),
$('#searchresults')
$searchBox,
$searchResults
);
}
);
} else {
// check again later
_.defer(function() {
OC.Search = new OCA.Search.Core(
$('#searchbox'),
$('#searchresults')
);
if ($searchResults.length > 0 && $searchBox.length > 0) {
OC.Search = new OCA.Search.Core(
$searchBox,
$searchResults
);
}
});
}
});
Expand Down

0 comments on commit ebeaa37

Please sign in to comment.