|
|
@ -234,9 +234,9 @@ define([
|
|
|
|
return LS;
|
|
|
|
return LS;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var getViewModeClass = function () {
|
|
|
|
var getViewModeClass = function (forceList) {
|
|
|
|
var mode = APP.store[LS_VIEWMODE];
|
|
|
|
var mode = APP.store[LS_VIEWMODE];
|
|
|
|
if (mode === 'list') { return 'cp-app-drive-content-list'; }
|
|
|
|
if (mode === 'list' || forceList) { return 'cp-app-drive-content-list'; }
|
|
|
|
return 'cp-app-drive-content-grid';
|
|
|
|
return 'cp-app-drive-content-grid';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var getViewMode = function () {
|
|
|
|
var getViewMode = function () {
|
|
|
@ -3234,18 +3234,26 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
$searchIcon.clone().appendTo($div);
|
|
|
|
$searchIcon.clone().appendTo($div);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var $spinnerContainer = $(h('div.cp-app-drive-search-spinner'));
|
|
|
|
|
|
|
|
var spinner = UI.makeSpinner($spinnerContainer);
|
|
|
|
var $input = APP.Search.$input = $('<input>', {
|
|
|
|
var $input = APP.Search.$input = $('<input>', {
|
|
|
|
id: 'cp-app-drive-search-input',
|
|
|
|
id: 'cp-app-drive-search-input',
|
|
|
|
|
|
|
|
placeholder: Messages.fm_searchName,
|
|
|
|
type: 'text',
|
|
|
|
type: 'text',
|
|
|
|
draggable: false,
|
|
|
|
draggable: false,
|
|
|
|
tabindex: 1,
|
|
|
|
tabindex: 1,
|
|
|
|
}).keyup(function (e) {
|
|
|
|
}).keyup(function (e) {
|
|
|
|
|
|
|
|
var lastValue = search.value;
|
|
|
|
|
|
|
|
search.value = $input.val().trim();
|
|
|
|
|
|
|
|
if (lastValue === search.value) { return; }
|
|
|
|
|
|
|
|
|
|
|
|
if (search.to) { window.clearTimeout(search.to); }
|
|
|
|
if (search.to) { window.clearTimeout(search.to); }
|
|
|
|
if ($input.val().trim() === "") {
|
|
|
|
if (search.value === "") {
|
|
|
|
search.cursor = 0;
|
|
|
|
search.cursor = 0;
|
|
|
|
APP.displayDirectory([SEARCH]);
|
|
|
|
APP.displayDirectory([SEARCH]);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
spinner.spin();
|
|
|
|
if (e.which === 13) {
|
|
|
|
if (e.which === 13) {
|
|
|
|
var newLocation = [SEARCH, $input.val()];
|
|
|
|
var newLocation = [SEARCH, $input.val()];
|
|
|
|
search.cursor = $input[0].selectionStart;
|
|
|
|
search.cursor = $input[0].selectionStart;
|
|
|
@ -3290,73 +3298,89 @@ define([
|
|
|
|
$div.append(cancel);
|
|
|
|
$div.append(cancel);
|
|
|
|
|
|
|
|
|
|
|
|
$list.append($div);
|
|
|
|
$list.append($div);
|
|
|
|
|
|
|
|
$spinnerContainer.appendTo($list);
|
|
|
|
setTimeout(function () {
|
|
|
|
setTimeout(function () {
|
|
|
|
$input.focus();
|
|
|
|
$input.focus();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$list.closest('#cp-app-drive-content-folder').addClass('cp-app-drive-content-list');
|
|
|
|
if (typeof(value) === "string" && value.trim()) {
|
|
|
|
var filesList = manager.search(value);
|
|
|
|
spinner.spin();
|
|
|
|
var sortable = {};
|
|
|
|
} else {
|
|
|
|
var sortableFolders = [];
|
|
|
|
return;
|
|
|
|
filesList.forEach(function (r) {
|
|
|
|
}
|
|
|
|
// if r.id === null, then it's a folder, not a file
|
|
|
|
|
|
|
|
r.paths.forEach(function (path) {
|
|
|
|
setTimeout(function () {
|
|
|
|
if (!r.inSharedFolder &&
|
|
|
|
//$list.closest('#cp-app-drive-content-folder').addClass('cp-app-drive-content-list');
|
|
|
|
APP.hideDuplicateOwned && manager.isDuplicateOwned(path)) { return; }
|
|
|
|
var filesList = manager.search(value);
|
|
|
|
var _path = path.slice();
|
|
|
|
if (!filesList.length) {
|
|
|
|
var key = path.pop();
|
|
|
|
Messages.fm_noResult = "No result found"; // XXX
|
|
|
|
var root = manager.find(path);
|
|
|
|
$list.append(h('div.cp-app-drive-search-noresult', Messages.fm_noResult));
|
|
|
|
var obj = {
|
|
|
|
spinner.hide();
|
|
|
|
path: path,
|
|
|
|
return;
|
|
|
|
_path: _path,
|
|
|
|
|
|
|
|
key: key,
|
|
|
|
|
|
|
|
root: root,
|
|
|
|
|
|
|
|
data: r.data
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
if (manager.isFolder(root[key])) {
|
|
|
|
|
|
|
|
sortableFolders.push(obj);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sortable[root[key]] = obj;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
var _folders = sortElements(true, [ROOT], sortableFolders, null, !getSortFolderDesc(), true);
|
|
|
|
|
|
|
|
var sortableKeys = Object.keys(sortable).map(Number);
|
|
|
|
|
|
|
|
var _files = sortElements(false, [ROOT], sortableKeys, APP.store[SORT_FILE_BY], !getSortFileDesc(), true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var addEl = function (obj, folder) {
|
|
|
|
|
|
|
|
var $element = createElement(obj.path, obj.key, obj.root, folder);
|
|
|
|
|
|
|
|
$element.addClass('cp-app-drive-element-notrash cp-app-drive-search-result');
|
|
|
|
|
|
|
|
$element.off('contextmenu');
|
|
|
|
|
|
|
|
$element.contextmenu(openContextMenu('default'));
|
|
|
|
|
|
|
|
$element.data('context', 'default');
|
|
|
|
|
|
|
|
if (folder) {
|
|
|
|
|
|
|
|
$element.find('.cp-app-drive-element-list').css({
|
|
|
|
|
|
|
|
visibility: 'hidden'
|
|
|
|
|
|
|
|
}).text('');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (manager.isPathIn(obj._path, ['hrefArray'])) {
|
|
|
|
|
|
|
|
obj._path.pop();
|
|
|
|
|
|
|
|
obj._path.push(obj.data.title);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var $path = $('<span>', {
|
|
|
|
var sortable = {};
|
|
|
|
'class': 'cp-app-drive-search-path'
|
|
|
|
var sortableFolders = [];
|
|
|
|
}).appendTo($element.find('.cp-app-drive-element-name'));
|
|
|
|
filesList.forEach(function (r) {
|
|
|
|
createTitle($path, obj._path);
|
|
|
|
// if r.id === null, then it's a folder, not a file
|
|
|
|
|
|
|
|
r.paths.forEach(function (path) {
|
|
|
|
|
|
|
|
if (!r.inSharedFolder &&
|
|
|
|
|
|
|
|
APP.hideDuplicateOwned && manager.isDuplicateOwned(path)) { return; }
|
|
|
|
|
|
|
|
var _path = path.slice();
|
|
|
|
|
|
|
|
var key = path.pop();
|
|
|
|
|
|
|
|
var root = manager.find(path);
|
|
|
|
|
|
|
|
var obj = {
|
|
|
|
|
|
|
|
path: path,
|
|
|
|
|
|
|
|
_path: _path,
|
|
|
|
|
|
|
|
key: key,
|
|
|
|
|
|
|
|
root: root,
|
|
|
|
|
|
|
|
data: r.data
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
if (manager.isFolder(root[key])) {
|
|
|
|
|
|
|
|
sortableFolders.push(obj);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sortable[root[key]] = obj;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
var _folders = sortElements(true, [ROOT], sortableFolders, null, !getSortFolderDesc(), true);
|
|
|
|
|
|
|
|
var sortableKeys = Object.keys(sortable).map(Number);
|
|
|
|
|
|
|
|
var _files = sortElements(false, [ROOT], sortableKeys, APP.store[SORT_FILE_BY], !getSortFileDesc(), true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var addEl = function (obj, folder) {
|
|
|
|
|
|
|
|
var $element = createElement(obj.path, obj.key, obj.root, folder);
|
|
|
|
|
|
|
|
$element.addClass('cp-app-drive-element-notrash cp-app-drive-search-result');
|
|
|
|
|
|
|
|
$element.off('contextmenu');
|
|
|
|
|
|
|
|
$element.contextmenu(openContextMenu('default'));
|
|
|
|
|
|
|
|
$element.data('context', 'default');
|
|
|
|
|
|
|
|
if (folder) {
|
|
|
|
|
|
|
|
$element.find('.cp-app-drive-element-list').css({
|
|
|
|
|
|
|
|
visibility: 'hidden'
|
|
|
|
|
|
|
|
}).text('');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (manager.isPathIn(obj._path, ['hrefArray'])) {
|
|
|
|
|
|
|
|
obj._path.pop();
|
|
|
|
|
|
|
|
obj._path.push(obj.data.title);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var $path = $('<span>', {
|
|
|
|
|
|
|
|
'class': 'cp-app-drive-search-path'
|
|
|
|
|
|
|
|
}).appendTo($element.find('.cp-app-drive-element-name'));
|
|
|
|
|
|
|
|
createTitle($path, obj._path);
|
|
|
|
|
|
|
|
|
|
|
|
$list.append($element);
|
|
|
|
$list.append($element);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (_folders.length) { getFolderListHeader(true, true).appendTo($list); }
|
|
|
|
if (_folders.length) { getFolderListHeader(true, true).appendTo($list); }
|
|
|
|
_folders.forEach(function (el) {
|
|
|
|
_folders.forEach(function (el) {
|
|
|
|
var obj = el;
|
|
|
|
var obj = el;
|
|
|
|
addEl(obj, true);
|
|
|
|
addEl(obj, true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (_files.length) { getFileListHeader(true).appendTo($list); }
|
|
|
|
if (_files.length) { getFileListHeader(true).appendTo($list); }
|
|
|
|
_files.forEach(function (el) {
|
|
|
|
_files.forEach(function (el) {
|
|
|
|
var obj = sortable[el];
|
|
|
|
var obj = sortable[el];
|
|
|
|
addEl(obj, false);
|
|
|
|
addEl(obj, false);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
setTimeout(collapseDrivePath);
|
|
|
|
|
|
|
|
spinner.hide();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
setTimeout(collapseDrivePath);
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var displayRecent = function ($list) {
|
|
|
|
var displayRecent = function ($list) {
|
|
|
@ -3612,12 +3636,11 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var $dirContent = $('<div>', {id: FOLDER_CONTENT_ID});
|
|
|
|
var $dirContent = $('<div>', {id: FOLDER_CONTENT_ID});
|
|
|
|
$dirContent.data('path', path);
|
|
|
|
$dirContent.data('path', path);
|
|
|
|
if (!isSearch && !isTags) {
|
|
|
|
if (!isTags) {
|
|
|
|
var mode = getViewMode();
|
|
|
|
$dirContent.addClass(getViewModeClass(isSearch));
|
|
|
|
if (mode) {
|
|
|
|
if (!isSearch) {
|
|
|
|
$dirContent.addClass(getViewModeClass());
|
|
|
|
createViewModeButton(APP.toolbar.$bottomR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
createViewModeButton(APP.toolbar.$bottomR);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var $list = $('<ul>').appendTo($dirContent);
|
|
|
|
var $list = $('<ul>').appendTo($dirContent);
|
|
|
|