summaryrefslogtreecommitdiffstats
path: root/core/search
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-07-25 12:20:46 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-07-25 12:20:46 +0200
commita1d7d60685b45a85611d3ea1c78b61215c900f13 (patch)
tree22743f14bb44441cc23c62935dc69dda9e4849fc /core/search
parentfb77ff9da432f5cf304a67a538ed497ee437c155 (diff)
downloadnextcloud-server-a1d7d60685b45a85611d3ea1c78b61215c900f13.tar.gz
nextcloud-server-a1d7d60685b45a85611d3ea1c78b61215c900f13.zip
Fix search on public pages
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'core/search')
-rw-r--r--core/search/js/search.js7
-rw-r--r--core/search/js/searchprovider.js21
2 files changed, 16 insertions, 12 deletions
diff --git a/core/search/js/search.js b/core/search/js/search.js
index 461c963c471..167d7c7a53d 100644
--- a/core/search/js/search.js
+++ b/core/search/js/search.js
@@ -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;
diff --git a/core/search/js/searchprovider.js b/core/search/js/searchprovider.js
index 4a484050385..f5a499fab60 100644
--- a/core/search/js/searchprovider.js
+++ b/core/search/js/searchprovider.js
@@ -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
+ );
+ }
});
}
});