diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2014-12-31 16:02:58 +0100 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2015-01-02 10:28:42 +0100 |
commit | 4fdd626f0a4b6667e3fd4c376399617df5866315 (patch) | |
tree | 93b79f6eaf3a21f55b9cff5f9d29a3f31ffe1e30 /apps/files/js/search.js | |
parent | b45d0f03fc57c861ddaec0e293d537eefab4c7d1 (diff) | |
download | nextcloud-server-4fdd626f0a4b6667e3fd4c376399617df5866315.tar.gz nextcloud-server-4fdd626f0a4b6667e3fd4c376399617df5866315.zip |
use correct visibilities
Diffstat (limited to 'apps/files/js/search.js')
-rw-r--r-- | apps/files/js/search.js | 212 |
1 files changed, 111 insertions, 101 deletions
diff --git a/apps/files/js/search.js b/apps/files/js/search.js index 75c5f22cab9..6f034f79f60 100644 --- a/apps/files/js/search.js +++ b/apps/files/js/search.js @@ -25,6 +25,117 @@ * Initialize the file search */ initialize: function() { + + var self = this; + + this.fileAppLoaded = function() { + return !!OCA.Files && !!OCA.Files.App; + }; + function inFileList($row, result) { + return self.fileAppLoaded() && OCA.Files.App.fileList.inList(result.name); + } + function updateLegacyMimetype(result){ + // backward compatibility: + if (!result.mime && result.mime_type) { + result.mime = result.mime_type; + } + } + + this.renderFolderResult = function($row, result) { + if (inFileList($row, result)) { + return null; + } + /*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); + $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.imagePath('core', 'filetypes/folder') + ')'); + return $row; + }; + + this.renderFileResult = function($row, result) { + if (inFileList($row, result)) { + return null; + } + /*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); + $row.find('td.info div.name').after($pathDiv).text(result.name); + + $row.find('td.result a').attr('href', result.link); + + if (self.fileAppLoaded()) { + OCA.Files.App.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.imagePath('core', 'filetypes/' + mimeicon) + ')'); + 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.renderAudioResult = function($row, result) { + /*render preview icon, show path beneath filename, + show size and last modified date on the right + show Artist and Album */ + $row = this.renderFileResult($row, result); + if ($row) { + $row.find('td.icon').css('background-image', 'url(' + OC.imagePath('core', 'filetypes/audio') + ')'); + } + return $row; + }; + + this.renderImageResult = function($row, result) { + /*render preview icon, show path beneath filename, + show size and last modified date on the right + show width and height */ + $row = this.renderFileResult($row, result); + if ($row && !self.fileAppLoaded()) { + $row.find('td.icon').css('background-image', 'url(' + OC.imagePath('core', 'filetypes/image') + ')'); + } + return $row; + }; + + + this.handleFolderClick = function($row, result, event) { + // open folder + if (self.fileAppLoaded()) { + OCA.Files.App.fileList.changeDirectory(result.path); + return false; + } else { + return true; + } + }; + + this.handleFileClick = function($row, result, event) { + if (self.fileAppLoaded()) { + OCA.Files.App.fileList.changeDirectory(OC.dirname(result.path)); + OCA.Files.App.fileList.scrollTo(result.name); + return false; + } else { + return true; + } + }; + OC.Plugins.register('OCA.Search', this); }, attach: function(search) { @@ -32,7 +143,6 @@ search.setFilter('files', function (query) { if (self.fileAppLoaded()) { OCA.Files.App.fileList.setFilter(query); - } }); @@ -43,106 +153,6 @@ search.setHandler('folder', this.handleFolderClick); search.setHandler(['file', 'audio', 'image'], this.handleFileClick); - }, - renderFolderResult: function($row, result) { - if (this.inFileList($row, result)) { - return null; - } - /*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); - $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.imagePath('core', 'filetypes/folder') + ')'); - return $row; - }, - renderFileResult: function($row, result) { - if (this.inFileList($row, result)) { - return null; - } - /*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); - $row.find('td.info div.name').after($pathDiv).text(result.name); - - $row.find('td.result a').attr('href', result.link); - - if (this.fileAppLoaded()) { - OCA.Files.App.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.imagePath('core', 'filetypes/' + mimeicon) + ')'); - 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; - }, - renderAudioResult: function($row, result) { - /*render preview icon, show path beneath filename, - show size and last modified date on the right - show Artist and Album */ - $row = this.renderFileResult($row, result); - if ($row) { - $row.find('td.icon').css('background-image', 'url(' + OC.imagePath('core', 'filetypes/audio') + ')'); - } - return $row; - }, - renderImageResult: function($row, result) { - /*render preview icon, show path beneath filename, - show size and last modified date on the right - show width and height */ - $row = this.renderFileResult($row, result); - if ($row && !this.fileAppLoaded()) { - $row.find('td.icon').css('background-image', 'url(' + OC.imagePath('core', 'filetypes/image') + ')'); - } - return $row; - }, - inFileList: function($row, result){ - return this.fileAppLoaded() && OCA.Files.App.fileList.inList(result.name); - }, - updateLegacyMimetype: function(result){ - // backward compatibility: - if (!result.mime && result.mime_type) { - result.mime = result.mime_type; - } - }, - handleFolderClick: function($row, result, event) { - // open folder - if (this.fileAppLoaded()) { - OCA.Files.App.fileList.changeDirectory(result.path); - return false; - } else { - return true; - } - }, - handleFileClick: function($row, result, event) { - if (this.fileAppLoaded()) { - OCA.Files.App.fileList.changeDirectory(OC.dirname(result.path)); - OCA.Files.App.fileList.scrollTo(result.name); - return false; - } else { - return true; - } - }, - fileAppLoaded: function() { - return !!OCA.Files && !!OCA.Files.App; } }; new Files(); |