Fixup breadcrumb and eventhandling

This commit is contained in:
Johannes Zellner
2022-08-23 16:10:30 +02:00
parent 05c8de7fc4
commit 5b97eae09a

View File

@@ -152,8 +152,6 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
return;
}
$scope.cwdParts = path.split('/').filter(function (p) { return !!p; }).map(function (p, i) { return { name: decodeURIComponent(p), path: path.split('/').slice(0, i+1).join('/') }; });
if ($scope.cwd === parentPath) {
var entry = $scope.entries.find(function (e) { return path === sanitize(parentPath + '/' + e.fileName); });
if (!entry) return Client.error('No such file or folder: ' + path);
@@ -162,6 +160,8 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
$scope.cwd = path;
$scope.selected = [];
$scope.cwdParts = path.split('/').filter(function (p) { return !!p; }).map(function (p, i) { return { name: decodeURIComponent(p), path: path.split('/').slice(0, i+1).join('/') }; });
// refresh will set busy to false once done
$scope.refresh();
} else if (entry.isFile) {
@@ -1084,45 +1084,6 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
return !!document.getElementsByClassName('modal in').length;
}
// handle save shortcuts
window.addEventListener('keydown', function (event) {
if((navigator.platform.match('Mac') ? event.metaKey : event.ctrlKey) && event.key === 's') {
if ($scope.view !== 'textEditor') return;
event.preventDefault();
$scope.$apply($scope.textEditor.save);
} else if((navigator.platform.match('Mac') ? event.metaKey : event.ctrlKey) && event.key === 'c') {
if ($scope.view === 'textEditor') return;
if ($scope.selected.length === 0) return;
if (isModalVisible()) return;
event.preventDefault();
$scope.$apply($scope.actionCopy);
} else if((navigator.platform.match('Mac') ? event.metaKey : event.ctrlKey) && event.key === 'x') {
if ($scope.view === 'textEditor') return;
if ($scope.selected.length === 0) return;
if (isModalVisible()) return;
event.preventDefault();
$scope.$apply($scope.actionCut);
} else if((navigator.platform.match('Mac') ? event.metaKey : event.ctrlKey) && event.key === 'v') {
if ($scope.view === 'textEditor') return;
if ($scope.clipboard.length === 0) return;
if (isModalVisible()) return;
event.preventDefault();
$scope.$apply($scope.actionPaste);
} else if((navigator.platform.match('Mac') ? event.metaKey : event.ctrlKey) && event.key === 'a') {
if ($scope.view === 'textEditor') return;
if (isModalVisible()) return;
event.preventDefault();
$scope.$apply($scope.actionSelectAll);
} else if(event.key === 'Escape') {
$scope.$apply(function () { $scope.selected = []; });
}
});
$translate(['filemanager.list.menu.edit', 'filemanager.list.menu.cut', 'filemanager.list.menu.copy', 'filemanager.list.menu.paste', 'filemanager.list.menu.rename', 'filemanager.list.menu.chown', 'filemanager.list.menu.extract', 'filemanager.list.menu.download', 'filemanager.list.menu.delete' ]).then(function (tr) {
$scope.menuOptions = [
{
@@ -1263,12 +1224,50 @@ app.controller('FileManagerController', ['$scope', '$translate', '$timeout', 'Cl
}
}
window.document.addEventListener('keydown', function (event) {
$scope.$apply(function () {
if (event.key === 'ArrowDown') selectNext();
else if (event.key === 'ArrowUp') selectPrev();
else if (event.key === 'Enter') openSelected();
else if (event.key === 'Backspace') $scope.goDirectoryUp();
});
// handle save shortcuts
window.addEventListener('keydown', function (event) {
if (event.key === 'ArrowDown') {
$scope.$apply(selectNext);
} else if (event.key === 'ArrowUp') {
$scope.$apply(selectPrev);
} else if (event.key === 'Enter') {
$scope.$apply(openSelected);
// } else if (event.key === 'Backspace') {
// if ($scope.view === 'fileTree') $scope.goDirectoryUp();
} else if((navigator.platform.match('Mac') ? event.metaKey : event.ctrlKey) && event.key === 's') {
if ($scope.view !== 'textEditor') return;
event.preventDefault();
$scope.$apply($scope.textEditor.save);
} else if((navigator.platform.match('Mac') ? event.metaKey : event.ctrlKey) && event.key === 'c') {
if ($scope.view === 'textEditor') return;
if ($scope.selected.length === 0) return;
if (isModalVisible()) return;
event.preventDefault();
$scope.$apply($scope.actionCopy);
} else if((navigator.platform.match('Mac') ? event.metaKey : event.ctrlKey) && event.key === 'x') {
if ($scope.view === 'textEditor') return;
if ($scope.selected.length === 0) return;
if (isModalVisible()) return;
event.preventDefault();
$scope.$apply($scope.actionCut);
} else if((navigator.platform.match('Mac') ? event.metaKey : event.ctrlKey) && event.key === 'v') {
if ($scope.view === 'textEditor') return;
if ($scope.clipboard.length === 0) return;
if (isModalVisible()) return;
event.preventDefault();
$scope.$apply($scope.actionPaste);
} else if((navigator.platform.match('Mac') ? event.metaKey : event.ctrlKey) && event.key === 'a') {
if ($scope.view === 'textEditor') return;
if (isModalVisible()) return;
event.preventDefault();
$scope.$apply($scope.actionSelectAll);
} else if(event.key === 'Escape') {
$scope.$apply(function () { $scope.selected = []; });
}
});
}]);