use correct visibilities

This commit is contained in:
Jörn Friedrich Dreyer 2014-12-31 16:02:58 +01:00
parent b45d0f03fc
commit 4fdd626f0a
1 changed files with 111 additions and 101 deletions

View File

@ -25,27 +25,24 @@
* Initialize the file search
*/
initialize: function() {
OC.Plugins.register('OCA.Search', this);
},
attach: function(search) {
var self = this;
search.setFilter('files', function (query) {
if (self.fileAppLoaded()) {
OCA.Files.App.fileList.setFilter(query);
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;
}
}
});
search.setRenderer('folder', this.renderFolderResult);
search.setRenderer('file', this.renderFileResult);
search.setRenderer('audio', this.renderAudioResult);
search.setRenderer('image', this.renderImageResult);
search.setHandler('folder', this.handleFolderClick);
search.setHandler(['file', 'audio', 'image'], this.handleFileClick);
},
renderFolderResult: function($row, result) {
if (this.inFileList($row, result)) {
this.renderFolderResult = function($row, result) {
if (inFileList($row, result)) {
return null;
}
/*render folder icon, show path beneath filename,
@ -58,9 +55,10 @@
$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)) {
};
this.renderFileResult = function($row, result) {
if (inFileList($row, result)) {
return null;
}
/*render preview icon, show path beneath filename,
@ -72,7 +70,7 @@
$row.find('td.result a').attr('href', result.link);
if (this.fileAppLoaded()) {
if (self.fileAppLoaded()) {
OCA.Files.App.fileList.lazyLoadPreview({
path: result.path,
mime: result.mime,
@ -93,8 +91,9 @@
);
}
return $row;
},
renderAudioResult: function($row, result) {
};
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 */
@ -103,46 +102,57 @@
$row.find('td.icon').css('background-image', 'url(' + OC.imagePath('core', 'filetypes/audio') + ')');
}
return $row;
},
renderImageResult: function($row, result) {
};
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 && !this.fileAppLoaded()) {
if ($row && !self.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) {
};
this.handleFolderClick = function($row, result, event) {
// open folder
if (this.fileAppLoaded()) {
if (self.fileAppLoaded()) {
OCA.Files.App.fileList.changeDirectory(result.path);
return false;
} else {
return true;
}
},
handleFileClick: function($row, result, event) {
if (this.fileAppLoaded()) {
};
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);
},
fileAppLoaded: function() {
return !!OCA.Files && !!OCA.Files.App;
attach: function(search) {
var self = this;
search.setFilter('files', function (query) {
if (self.fileAppLoaded()) {
OCA.Files.App.fileList.setFilter(query);
}
});
search.setRenderer('folder', this.renderFolderResult);
search.setRenderer('file', this.renderFileResult);
search.setRenderer('audio', this.renderAudioResult);
search.setRenderer('image', this.renderImageResult);
search.setHandler('folder', this.handleFolderClick);
search.setHandler(['file', 'audio', 'image'], this.handleFileClick);
}
};
new Files();