Show folders in the results of drive search
This commit is contained in:
parent
29b7c2c295
commit
9b8fed55e9
@ -514,6 +514,40 @@ define([
|
|||||||
data: exp.getFileData(l)
|
data: exp.getFileData(l)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// find folders
|
||||||
|
var resFolders = [];
|
||||||
|
var findFoldersRec = function (folder, path) {
|
||||||
|
for (var key in folder) {
|
||||||
|
if (isFolder(folder[key])) {
|
||||||
|
if (isSharedFolder(folder[key])) {
|
||||||
|
// var name = getSharedFolderData(folder[key]).title || "";
|
||||||
|
// if (name.toLowerCase().indexOf(lValue) !== -1) {
|
||||||
|
// resFolders.push(path.concat([key, ROOT]));
|
||||||
|
// }
|
||||||
|
findFoldersRec(folder[key], path.concat([key, ROOT]));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (key.toLowerCase().indexOf(lValue) !== -1) {
|
||||||
|
resFolders.push({
|
||||||
|
id: null,
|
||||||
|
paths: [path.concat(key)],
|
||||||
|
data: {
|
||||||
|
title: key
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
findFoldersRec(folder[key], path.concat(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
findFoldersRec(files[ROOT], [ROOT]);
|
||||||
|
resFolders = resFolders.sort(function (a, b) {
|
||||||
|
return a.data.title.toLowerCase() > b.data.title.toLowerCase();
|
||||||
|
});
|
||||||
|
ret = resFolders.concat(ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
exp.getRecentPads = function () {
|
exp.getRecentPads = function () {
|
||||||
|
|||||||
@ -2610,6 +2610,7 @@ define([
|
|||||||
var displaySearch = function ($list, value) {
|
var displaySearch = function ($list, value) {
|
||||||
var filesList = manager.search(value);
|
var filesList = manager.search(value);
|
||||||
filesList.forEach(function (r) {
|
filesList.forEach(function (r) {
|
||||||
|
// if r.id === null, then it's a folder, not a file
|
||||||
r.paths.forEach(function (path) {
|
r.paths.forEach(function (path) {
|
||||||
if (!r.inSharedFolder &&
|
if (!r.inSharedFolder &&
|
||||||
APP.hideDuplicateOwned && manager.isDuplicateOwned(path)) { return; }
|
APP.hideDuplicateOwned && manager.isDuplicateOwned(path)) { return; }
|
||||||
@ -2617,25 +2618,27 @@ define([
|
|||||||
var parsed = Hash.parsePadUrl(href);
|
var parsed = Hash.parsePadUrl(href);
|
||||||
var $table = $('<table>');
|
var $table = $('<table>');
|
||||||
var $icon = $('<td>', {'rowspan': '3', 'class': 'cp-app-drive-search-icon'})
|
var $icon = $('<td>', {'rowspan': '3', 'class': 'cp-app-drive-search-icon'})
|
||||||
.append(getFileIcon(r.id));
|
.append(r.id ? getFileIcon(r.id) : $folderIcon.clone());
|
||||||
var $title = $('<td>', {
|
var $title = $('<td>', {
|
||||||
'class': 'cp-app-drive-search-col1 cp-app-drive-search-title'
|
'class': 'cp-app-drive-search-col1 cp-app-drive-search-title'
|
||||||
}).text(r.data.title)
|
}).text(r.data.title);
|
||||||
.click(function () {
|
if (r.id) {
|
||||||
openFile(null, r.data.href);
|
$title.click(function () {
|
||||||
});
|
openFile(null, r.data.href);
|
||||||
|
});
|
||||||
|
}
|
||||||
var $typeName = $('<td>', {'class': 'cp-app-drive-search-label2'})
|
var $typeName = $('<td>', {'class': 'cp-app-drive-search-label2'})
|
||||||
.text(Messages.fm_type);
|
.text(Messages.fm_type);
|
||||||
var $type = $('<td>', {'class': 'cp-app-drive-search-col2'})
|
var $type = $('<td>', {'class': 'cp-app-drive-search-col2'})
|
||||||
.text(Messages.type[parsed.type] || parsed.type);
|
.text(r.id ? Messages.type[parsed.type] || parsed.type : Messages.fm_folder);
|
||||||
var $atimeName = $('<td>', {'class': 'cp-app-drive-search-label2'})
|
var $atimeName = $('<td>', {'class': 'cp-app-drive-search-label2'})
|
||||||
.text(Messages.fm_lastAccess);
|
.text(r.id ? Messages.fm_lastAccess : "");
|
||||||
var $atime = $('<td>', {'class': 'cp-app-drive-search-col2'})
|
var $atime = $('<td>', {'class': 'cp-app-drive-search-col2'})
|
||||||
.text(new Date(r.data.atime).toLocaleString());
|
.text(r.id ? new Date(r.data.atime).toLocaleString() : "");
|
||||||
var $ctimeName = $('<td>', {'class': 'cp-app-drive-search-label2'})
|
var $ctimeName = $('<td>', {'class': 'cp-app-drive-search-label2'})
|
||||||
.text(Messages.fm_creation);
|
.text(r.id ? Messages.fm_creation : "");
|
||||||
var $ctime = $('<td>', {'class': 'cp-app-drive-search-col2'})
|
var $ctime = $('<td>', {'class': 'cp-app-drive-search-col2'})
|
||||||
.text(new Date(r.data.ctime).toLocaleString());
|
.text(r.id ? new Date(r.data.ctime).toLocaleString() : "");
|
||||||
if (manager.isPathIn(path, ['hrefArray'])) {
|
if (manager.isPathIn(path, ['hrefArray'])) {
|
||||||
path.pop();
|
path.pop();
|
||||||
path.push(r.data.title);
|
path.push(r.data.title);
|
||||||
@ -2646,23 +2649,33 @@ define([
|
|||||||
createTitle($path, path, true);
|
createTitle($path, path, true);
|
||||||
var parentPath = path.slice();
|
var parentPath = path.slice();
|
||||||
var $a;
|
var $a;
|
||||||
if (parentPath) {
|
if (r.id) {
|
||||||
$a = $('<a>').text(Messages.fm_openParent).click(function (e) {
|
if (parentPath) {
|
||||||
|
$a = $('<a>').text(Messages.fm_openParent).click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (manager.isInTrashRoot(parentPath)) { parentPath = [TRASH]; }
|
||||||
|
else { parentPath.pop(); }
|
||||||
|
APP.selectedFiles = [r.id];
|
||||||
|
APP.displayDirectory(parentPath);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$a = $('<a>').text(Messages.fm_OpenFolder || "Open folder").click(function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (manager.isInTrashRoot(parentPath)) { parentPath = [TRASH]; }
|
APP.displayDirectory(path);
|
||||||
else { parentPath.pop(); }
|
|
||||||
APP.selectedFiles = [r.id];
|
|
||||||
APP.displayDirectory(parentPath);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var $openDir = $('<td>', {'class': 'cp-app-drive-search-opendir'}).append($a);
|
var $openDir = $('<td>', {'class': 'cp-app-drive-search-opendir'}).append($a);
|
||||||
|
|
||||||
$('<a>').text(Messages.fc_prop).click(function () {
|
if (r.id) {
|
||||||
APP.getProperties(r.id, function (e, $prop) {
|
$('<a>').text(Messages.fc_prop).click(function () {
|
||||||
if (e) { return void logError(e); }
|
APP.getProperties(r.id, function (e, $prop) {
|
||||||
UI.alert($prop[0], undefined, true);
|
if (e) { return void logError(e); }
|
||||||
});
|
UI.alert($prop[0], undefined, true);
|
||||||
}).appendTo($openDir);
|
});
|
||||||
|
}).appendTo($openDir);
|
||||||
|
}
|
||||||
|
|
||||||
// rows 1-3
|
// rows 1-3
|
||||||
$('<tr>').append($icon).append($title).append($typeName).append($type).appendTo($table);
|
$('<tr>').append($icon).append($title).append($typeName).append($type).appendTo($table);
|
||||||
@ -3208,7 +3221,7 @@ define([
|
|||||||
placeholder: Messages.fm_searchPlaceholder
|
placeholder: Messages.fm_searchPlaceholder
|
||||||
}).keyup(function (e) {
|
}).keyup(function (e) {
|
||||||
if (search.to) { window.clearTimeout(search.to); }
|
if (search.to) { window.clearTimeout(search.to); }
|
||||||
if ([38, 39, 40, 41].indexOf(e.which) !== -1) {
|
if ([37, 38, 39, 40].indexOf(e.which) !== -1) {
|
||||||
if (!$input.val()) {
|
if (!$input.val()) {
|
||||||
$input.blur();
|
$input.blur();
|
||||||
$content.focus();
|
$content.focus();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user