').addClass('icon-search'));
- var error = t('core', 'No search results in other folders for {tag}{filter}{endtag}', { filter: lastQuery });
- $status.append($('
').html(error.replace('{tag}', '').replace('{endtag}', '')));
- } else {
- $status.removeClass('emptycontent').addClass('status summary');
- $status.text(n('core','{count} search result in another folder','{count} search results in other folders', count,{ count: count }));
- $status.html('' + n( 'core', '{count} search result in another folder', '{count} search results in other folders', count, { count: count } ) + '');
- }
- }
-
- function renderCurrent() {
- var result = $searchResults.find('tr.result')[currentResult];
- if (result) {
- var $result = $(result);
- var currentOffset = $(window).scrollTop();
- $(window).animate(
- {
- // Scrolling to the top of the new result
- scrollTop:
- currentOffset +
- $result.offset().top -
- $result.height() * 2
- },
- {
- duration: 100
- }
- );
- $searchResults.find('tr.result.current').removeClass('current');
- $result.addClass('current');
- }
- }
- this.hideResults = function() {
- $searchResults.addClass('hidden');
- $searchResults.find('tr.result').remove();
- lastQuery = false;
- };
-
- this.clear = function() {
- self.hideResults();
- if (self.hasFilter(getCurrentApp())) {
- self.getFilter(getCurrentApp())('');
- }
- $searchBox.val('');
- $searchBox.blur();
- };
-
- /**
- * Event handler for when scrolling the list container.
- * This appends/renders the next page of entries when reaching the bottom.
- */
- function onScroll() {
- if (
- $searchResults &&
- lastQuery !== false &&
- lastResults.length > 0
- ) {
- if ($(window).scrollTop() + $(window).height() > $searchResults.height() - 300) {
- self.search(lastQuery, lastInApps, lastPage + 1);
- }
- placeStatus();
- }
- }
-
- $(window).on('scroll', _.bind(onScroll, this)); // For desktop browser
- $("body").on('scroll', _.bind(onScroll, this)); // For mobile browser
-
- /**
- * scrolls the search results to the top
- */
- function scrollToResults() {
- setTimeout(function() {
- if (isStatusOffScreen()) {
- var newScrollTop = $(window).prop('scrollHeight') - $searchResults.height();
- console.log('scrolling to ' + newScrollTop);
- $(window).animate(
- {
- scrollTop: newScrollTop
- },
- {
- duration: 100,
- complete: function() {
- scrollToResults();
- }
- }
- );
- }
- }, 150);
- }
-
- $searchBox.keyup(function(event) {
- if (event.keyCode === 13) {
- //enter
- if (currentResult > -1) {
- var result = $searchResults.find('tr.result a')[currentResult];
- window.location = $(result).attr('href');
- }
- } else if (event.keyCode === 38) {
- //up
- if (currentResult > 0) {
- currentResult--;
- renderCurrent();
- }
- } else if (event.keyCode === 40) {
- //down
- if (lastResults.length > currentResult + 1) {
- currentResult++;
- renderCurrent();
- }
- }
- });
-
- $searchResults.on('click', 'tr.result', function(event) {
- var $row = $(this);
- var item = $row.data('result');
- if (self.hasHandler(item.type)) {
- var result = self.getHandler(item.type)($row, item, event);
- $searchBox.val('');
- if (self.hasFilter(getCurrentApp())) {
- self.getFilter(getCurrentApp())('');
- }
- self.hideResults();
- return result;
- }
- });
- $searchResults.on('click', '#status', function(event) {
- event.preventDefault();
- scrollToResults();
- return false;
- });
- placeStatus();
-
- OC.Plugins.attach('OCA.Search.Core', this);
-
- // Finally use default Search registration
- return new OCA.Search(
- // Search handler
- function(query) {
- if (lastQuery !== query) {
- currentResult = -1;
- if (query.length > 1) {
- self.search(query);
- } else {
- self.hideResults();
- }
- if (self.hasFilter(getCurrentApp())) {
- self.getFilter(getCurrentApp())(query);
- }
- }
- },
- // Reset handler
- function() {
- if ($searchBox.val() === '') {
- if (self.hasFilter(getCurrentApp())) {
- self.getFilter(getCurrentApp())('');
- }
- self.hideResults();
- }
- }
- );
- }
- };
- OCA.Search.Core = Search;
-})();
-
-window.addEventListener('DOMContentLoaded', function() {
- var $searchResults = $('#searchresults');
- var $searchBox = $('#searchbox');
- if ($searchResults.length > 0 && $searchBox.length > 0) {
- $searchResults.addClass('hidden');
- $searchResults.html('
\n' +
- '
');
- OC.Search = new OCA.Search.Core(
- $searchBox,
- $searchResults
- );
- } else {
- // check again later
- _.defer(function() {
- if ($searchResults.length > 0 && $searchBox.length > 0) {
- OC.Search = new OCA.Search.Core(
- $searchBox,
- $searchResults
- );
- }
- });
- }
-});
-
-/**
- * @deprecated use get/setRenderer() instead
- */
-OC.search.customResults = {};
-/**
- * @deprecated use get/setRenderer() instead
- */
-OC.search.resultTypes = {};
diff --git a/core/src/OC/index.js b/core/src/OC/index.js
index 61de15516c..036e640be3 100644
--- a/core/src/OC/index.js
+++ b/core/src/OC/index.js
@@ -103,7 +103,6 @@ import msg from './msg'
import Notification from './notification'
import PasswordConfirmation from './password-confirmation'
import Plugins from './plugins'
-import search from './search'
import { theme } from './theme'
import Util from './util'
import { debug } from './debug'
@@ -249,7 +248,6 @@ export default {
Notification,
PasswordConfirmation,
Plugins,
- search,
theme,
Util,
debug,
diff --git a/core/src/OC/search.js b/core/src/OC/search.js
deleted file mode 100644
index 281907a06a..0000000000
--- a/core/src/OC/search.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * @copyright 2019 Christoph Wurst
- *
- * @author 2019 Christoph Wurst
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-import OC from './index'
-
-/**
- * Do a search query and display the results
- * @param {string} query the search query
- */
-const search = function(query) {
- OC.Search.search(query, null, 0, 30)
-}
-
-/**
- * @namespace OC.search
- */
-search.customResults = {}
-/**
- * @deprecated use get/setFormatter() instead
- */
-search.resultTypes = {}
-
-export default search
diff --git a/core/src/unified-search.js b/core/src/unified-search.js
index ba975d7856..c6d835836b 100644
--- a/core/src/unified-search.js
+++ b/core/src/unified-search.js
@@ -32,6 +32,18 @@ __webpack_nonce__ = btoa(getRequestToken())
// eslint-disable-next-line camelcase
__webpack_public_path__ = generateFilePath('core', '', 'js/')
+// TODO: remove with nc22
+if (!OCA.Search) {
+ class Search {
+
+ constructor() {
+ console.warn('OCA.Search is deprecated. Please use the unified search API instead')
+ }
+
+ }
+ OCA.Search = Search
+}
+
Vue.mixin({
methods: {
t,
diff --git a/lib/private/legacy/OC_Template.php b/lib/private/legacy/OC_Template.php
index 32d185d25f..18a15ad1d4 100644
--- a/lib/private/legacy/OC_Template.php
+++ b/lib/private/legacy/OC_Template.php
@@ -115,9 +115,6 @@ class OC_Template extends \OC\Template\Base {
OC_Util::addTranslations('core', null, true);
if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
- OC_Util::addStyle('search', 'results');
- OC_Util::addScript('search', 'search', true);
- OC_Util::addScript('search', 'searchprovider');
OC_Util::addScript('merged-template-prepend', null, true);
OC_Util::addScript('dist/files_client', null, true);
OC_Util::addScript('dist/files_fileinfo', null, true);