Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Unified Diff: ui/file_manager/file_manager/foreground/js/quick_view_controller.js

Issue 2070033002: Quick View: Change file selection with arrow keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/file_manager/file_manager/foreground/js/file_manager.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/quick_view_controller.js
diff --git a/ui/file_manager/file_manager/foreground/js/quick_view_controller.js b/ui/file_manager/file_manager/foreground/js/quick_view_controller.js
index 94b075c0fa93d68564e01723c1b4a9e6abc13252..d342ea28abf8908f8e9441530bf485178e27d903 100644
--- a/ui/file_manager/file_manager/foreground/js/quick_view_controller.js
+++ b/ui/file_manager/file_manager/foreground/js/quick_view_controller.js
@@ -11,12 +11,13 @@
* @param {!ListContainer} listContainer
* @param {!QuickViewModel} quickViewModel
* @param {!TaskController} taskController
+ * @param {!cr.ui.ListSelectionModel} fileListSelectionModel
*
* @constructor
*/
function QuickViewController(
quickView, metadataModel, selectionHandler, listContainer, quickViewModel,
- taskController) {
+ taskController, fileListSelectionModel) {
/**
* @type {!FilesQuickView}
* @private
@@ -48,6 +49,12 @@ function QuickViewController(
this.taskController_ = taskController;
/**
+ * @type {!cr.ui.ListSelectionModel}
+ * @private
+ */
+ this.fileListSelectionModel_ = fileListSelectionModel;
+
+ /**
* Current selection of selectionHandler.
*
* @type {!Array<!FileEntry>}
@@ -59,8 +66,8 @@ function QuickViewController(
FileSelectionHandler.EventType.CHANGE,
this.onFileSelectionChanged_.bind(this));
listContainer.element.addEventListener(
- 'keypress', this.onKeyPressToOpen_.bind(this));
- quickView.addEventListener('keypress', this.onKeyPressToClose_.bind(this));
+ 'keydown', this.onKeyDownToOpen_.bind(this));
+ quickView.addEventListener('keydown', this.onQuickViewKeyDown_.bind(this));
quickView.onOpenInNewButtonTap = this.onOpenInNewButtonTap_.bind(this);
}
@@ -82,7 +89,7 @@ QuickViewController.prototype.onOpenInNewButtonTap_ = function(event) {
* @param {!Event} event A keyboard event.
* @private
*/
-QuickViewController.prototype.onKeyPressToOpen_ = function(event) {
+QuickViewController.prototype.onKeyDownToOpen_ = function(event) {
if (this.entries_.length == 0)
return;
if (event.key === ' ') {
@@ -97,13 +104,26 @@ QuickViewController.prototype.onKeyPressToOpen_ = function(event) {
* @param {!Event} event A keyboard event.
* @private
*/
-QuickViewController.prototype.onKeyPressToClose_ = function(event) {
- if (event.key === ' ') {
- event.preventDefault();
- this.quickView_.close();
- this.listContainer_.focus();
+QuickViewController.prototype.onQuickViewKeyDown_ = function(event) {
+ switch (event.key) {
+ case ' ':
+ event.preventDefault();
+ this.quickView_.close();
+ this.listContainer_.focus();
+ break;
+ case 'ArrowRight':
+ var index = this.fileListSelectionModel_.selectedIndex + 1;
+ if (index >= this.fileListSelectionModel_.length)
+ index = 0;
+ this.fileListSelectionModel_.selectedIndex = index;
+ break;
+ case 'ArrowLeft':
+ var index = this.fileListSelectionModel_.selectedIndex - 1;
+ if (index < 0)
+ index = this.fileListSelectionModel_.length - 1;
+ this.fileListSelectionModel_.selectedIndex = index;
+ break;
}
- // TODO(oka): Open previous/next file with Left/Right.
};
/**
« no previous file with comments | « ui/file_manager/file_manager/foreground/js/file_manager.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698