aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js/search.js
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2020-08-03 16:50:39 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2020-08-04 20:56:22 +0200
commit6eced42b7a40f5b0ea0489244583219d0ee2e7af (patch)
treec7244e50328a27c28579f9812a8cc2808f64e13a /apps/files/js/search.js
parent72b45f9546208c82e76ddb2ad7995f0485d99b18 (diff)
downloadnextcloud-server-6eced42b7a40f5b0ea0489244583219d0ee2e7af.tar.gz
nextcloud-server-6eced42b7a40f5b0ea0489244583219d0ee2e7af.zip
Remove outdated legacy search scripts
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files/js/search.js')
-rw-r--r--apps/files/js/search.js176
1 files changed, 0 insertions, 176 deletions
diff --git a/apps/files/js/search.js b/apps/files/js/search.js
deleted file mode 100644
index 66899c09150..00000000000
--- a/apps/files/js/search.js
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (c) 2014
- *
- * This file is licensed under the Affero General Public License version 3
- * or later.
- *
- * See the COPYING-README file.
- *
- */
-(function() {
-
- /**
- * Construct a new FileActions instance
- * @constructs Files
- */
- var Files = function() {
- this.initialize();
- };
- /**
- * @memberof OCA.Search
- */
- Files.prototype = {
-
- fileList: null,
-
- /**
- * Initialize the file search
- */
- initialize: function() {
-
- var self = this;
-
- this.fileAppLoaded = function() {
- return !!OCA.Files && !!OCA.Files.App;
- };
- function inFileList($row, result) {
- if (! self.fileAppLoaded()) {
- return false;
- }
- var dir = self.fileList.getCurrentDirectory().replace(/\/+$/,'');
- var resultDir = OC.dirname(result.path);
- return dir === resultDir && self.fileList.inList(result.name);
- }
- function updateLegacyMimetype(result) {
- // backward compatibility:
- if (!result.mime && result.mime_type) {
- result.mime = result.mime_type;
- }
- }
- function hideNoFilterResults() {
- var $nofilterresults = $('.nofilterresults');
- if ( ! $nofilterresults.hasClass('hidden') ) {
- $nofilterresults.addClass('hidden');
- }
- }
-
- this.renderFolderResult = function($row, result) {
- if (inFileList($row, result)) {
- return null;
- }
- hideNoFilterResults();
- /*render folder icon, show path beneath filename,
- show size and last modified date on the right */
- this.updateLegacyMimetype(result);
-
- var $pathDiv = $('<div class="path"></div>').text(result.path.substr(1, result.path.lastIndexOf("/")));
- $row.find('td.info div.name').after($pathDiv).text(result.name);
-
- $row.find('td.result a').attr('href', result.link);
- $row.find('td.icon').css('background-image', 'url(' + OC.MimeType.getIconUrl(result.mime) + ')');
- return $row;
- };
-
- this.renderFileResult = function($row, result) {
- if (inFileList($row, result)) {
- return null;
- }
- hideNoFilterResults();
- /*render preview icon, show path beneath filename,
- show size and last modified date on the right */
- this.updateLegacyMimetype(result);
-
- var $pathDiv = $('<div class="path"></div>').text(result.path.substr(1, result.path.lastIndexOf("/")));
- $row.find('td.info div.name').after($pathDiv).text(result.name);
-
- $row.find('td.result a').attr('href', result.link);
-
- if (self.fileAppLoaded()) {
- self.fileList.lazyLoadPreview({
- path: result.path,
- mime: result.mime,
- callback: function (url) {
- $row.find('td.icon').css('background-image', 'url(' + url + ')');
- }
- });
- } else {
- // FIXME how to get mime icon if not in files app
- var mimeicon = result.mime.replace('/', '-');
- $row.find('td.icon').css('background-image', 'url(' + OC.MimeType.getIconUrl(result.mime) + ')');
- var dir = OC.dirname(result.path);
- if (dir === '') {
- dir = '/';
- }
- $row.find('td.info a').attr('href',
- OC.generateUrl('/apps/files/?dir={dir}&scrollto={scrollto}', {dir: dir, scrollto: result.name})
- );
- }
- return $row;
- };
-
-
- this.handleFolderClick = function($row, result, event) {
- // open folder
- if (self.fileAppLoaded() && self.fileList.id === 'files') {
- self.fileList.changeDirectory(result.path);
- return false;
- } else {
- return true;
- }
- };
-
- this.handleFileClick = function($row, result, event) {
- if (self.fileAppLoaded() && self.fileList.id === 'files') {
- self.fileList.changeDirectory(OC.dirname(result.path));
- self.fileList.scrollTo(result.name);
- return false;
- } else {
- return true;
- }
- };
-
- this.updateLegacyMimetype = function (result) {
- // backward compatibility:
- if (!result.mime && result.mime_type) {
- result.mime = result.mime_type;
- }
- };
- this.setFileList = function (fileList) {
- this.fileList = fileList;
- };
-
- OC.Plugins.register('OCA.Search.Core', this);
- },
- attach: function(search) {
- var self = this;
- search.setFilter('files', function (query) {
- if (self.fileAppLoaded()) {
- self.fileList.setFilter(query);
- if (query.length > 1) {
- //search is not started until 500msec have passed
- window.setTimeout(function() {
- $('.nofilterresults').addClass('hidden');
- }, 500);
- }
- }
- });
-
- search.setRenderer('folder', this.renderFolderResult.bind(this));
- search.setRenderer('file', this.renderFileResult.bind(this));
- search.setRenderer('image', this.renderFileResult.bind(this));
- search.setRenderer('audio', this.renderFileResult.bind(this));
-
- search.setHandler('folder', this.handleFolderClick.bind(this));
- search.setHandler(['file', 'audio', 'image'], this.handleFileClick.bind(this));
-
- if (self.fileAppLoaded()) {
- // hide results when switching directory outside of search results
- $('#app-content').delegate('>div', 'changeDirectory', function() {
- search.clear();
- });
- }
- }
- };
- OCA.Search.Files = Files;
- OCA.Search.files = new Files();
-})();