diff options
Diffstat (limited to 'apps/comments/src/search.js')
-rw-r--r-- | apps/comments/src/search.js | 101 |
1 files changed, 51 insertions, 50 deletions
diff --git a/apps/comments/src/search.js b/apps/comments/src/search.js index 8e0a35ff6ed..c62726d9082 100644 --- a/apps/comments/src/search.js +++ b/apps/comments/src/search.js @@ -1,3 +1,4 @@ +/* eslint-disable */ /* * Copyright (c) 2014 * @@ -8,15 +9,15 @@ * */ (function(OC, OCA, $) { - "use strict"; + 'use strict' /** * Construct a new FileActions instance * @constructs Files */ var Comment = function() { - this.initialize(); - }; + this.initialize() + } Comment.prototype = { @@ -27,25 +28,25 @@ */ initialize: function() { - var self = this; + var self = this this.fileAppLoaded = function() { - return !!OCA.Files && !!OCA.Files.App; - }; + return !!OCA.Files && !!OCA.Files.App + } function inFileList($row, result) { - return false; + return false - if (! self.fileAppLoaded()) { - return false; + 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); + var dir = self.fileList.getCurrentDirectory().replace(/\/+$/, '') + var resultDir = OC.dirname(result.path) + return dir === resultDir && self.fileList.inList(result.name) } function hideNoFilterResults() { - var $nofilterresults = $('.nofilterresults'); - if ( ! $nofilterresults.hasClass('hidden') ) { - $nofilterresults.addClass('hidden'); + var $nofilterresults = $('.nofilterresults') + if (!$nofilterresults.hasClass('hidden')) { + $nofilterresults.addClass('hidden') } } @@ -64,73 +65,73 @@ */ this.renderCommentResult = function($row, result) { if (inFileList($row, result)) { - return null; + return null } - hideNoFilterResults(); - /*render preview icon, show path beneath filename, + hideNoFilterResults() + /* render preview icon, show path beneath filename, show size and last modified date on the right */ - this.updateLegacyMimetype(result); + this.updateLegacyMimetype(result) - var $pathDiv = $('<div>').addClass('path').text(result.path); + var $pathDiv = $('<div>').addClass('path').text(result.path) - var $avatar = $('<div>'); + var $avatar = $('<div>') $avatar.addClass('avatar') .css('display', 'inline-block') .css('vertical-align', 'middle') - .css('margin', '0 5px 2px 3px'); + .css('margin', '0 5px 2px 3px') if (result.authorName) { - $avatar.avatar(result.authorId, 21, undefined, false, undefined, result.authorName); + $avatar.avatar(result.authorId, 21, undefined, false, undefined, result.authorName) } else { - $avatar.avatar(result.authorId, 21); + $avatar.avatar(result.authorId, 21) } - $row.find('td.info div.name').after($pathDiv).text(result.comment).prepend($('<span>').addClass('path').css('margin-right', '5px').text(result.authorName)).prepend($avatar); - $row.find('td.result a').attr('href', result.link); + $row.find('td.info div.name').after($pathDiv).text(result.comment).prepend($('<span>').addClass('path').css('margin-right', '5px').text(result.authorName)).prepend($avatar) + $row.find('td.result a').attr('href', result.link) $row.find('td.icon') .css('background-image', 'url(' + OC.imagePath('core', 'actions/comment') + ')') - .css('opacity', '.4'); - var dir = OC.dirname(result.path); + .css('opacity', '.4') + var dir = OC.dirname(result.path) // "result.path" does not include a leading "/", so "OC.dirname" // returns the path itself for files or folders in the root. if (dir === result.path) { - dir = '/'; + dir = '/' } $row.find('td.info a').attr('href', - OC.generateUrl('/apps/files/?dir={dir}&scrollto={scrollto}', {dir: dir, scrollto: result.fileName}) - ); + OC.generateUrl('/apps/files/?dir={dir}&scrollto={scrollto}', { dir: dir, scrollto: result.fileName }) + ) - return $row; - }; + return $row + } this.handleCommentClick = 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; + self.fileList.changeDirectory(OC.dirname(result.path)) + self.fileList.scrollTo(result.name) + return false } else { - return true; + return true } - }; + } - this.updateLegacyMimetype = function (result) { + this.updateLegacyMimetype = function(result) { // backward compatibility: if (!result.mime && result.mime_type) { - result.mime = result.mime_type; + result.mime = result.mime_type } - }; - this.setFileList = function (fileList) { - this.fileList = fileList; - }; + } + this.setFileList = function(fileList) { + this.fileList = fileList + } - OC.Plugins.register('OCA.Search.Core', this); + OC.Plugins.register('OCA.Search.Core', this) }, attach: function(search) { - search.setRenderer('comment', this.renderCommentResult.bind(this)); - search.setHandler('comment', this.handleCommentClick.bind(this)); + search.setRenderer('comment', this.renderCommentResult.bind(this)) + search.setHandler('comment', this.handleCommentClick.bind(this)) } - }; + } - OCA.Search.comment = new Comment(); -})(OC, OCA, $); + OCA.Search.comment = new Comment() +})(OC, OCA, $) |