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

Unified Diff: chrome/browser/resources/file_manager/foreground/js/default_action_dialog.js

Issue 108163005: [Files.app] Remove OK and Cancel buttons in task picker dialog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 11 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 | « no previous file | chrome/browser/resources/file_manager/foreground/js/file_manager_commands.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/foreground/js/default_action_dialog.js
diff --git a/chrome/browser/resources/file_manager/foreground/js/default_action_dialog.js b/chrome/browser/resources/file_manager/foreground/js/default_action_dialog.js
index a5c8290a2397b3b6b0097df240bb7167a14787e0..cba4e6ad0df68519b8cac1e2e9d196c758afffc5 100644
--- a/chrome/browser/resources/file_manager/foreground/js/default_action_dialog.js
+++ b/chrome/browser/resources/file_manager/foreground/js/default_action_dialog.js
@@ -36,6 +36,8 @@ cr.define('cr.filebrowser', function() {
// but doesn't exceed predefined size.
this.list_.autoExpands = true;
this.list_.activateItemAtIndex = this.activateItemAtIndex_.bind(this);
+ // Use 'click' instead of 'change' for keyboard users.
+ this.list_.addEventListener('click', this.onSelected_.bind(this));
this.initialFocusElement_ = this.list_;
@@ -93,14 +95,16 @@ cr.define('cr.filebrowser', function() {
* @param {string} message Message in dialog caption.
* @param {Array.<Object>} items Items to render in the list.
* @param {number} defaultIndex Item to select by default.
- * @param {function(Object=)} opt_onOk OK callback with the selected item.
- * @param {function()=} opt_onCancel Cancel callback.
+ * @param {function(Object)} onSelectedItem Callback which is called when an
+ * item is selected.
*/
DefaultActionDialog.prototype.show = function(title, message, items,
- defaultIndex, opt_onOk, opt_onCancel) {
+ defaultIndex, onSelectedItem) {
- var show = FileManagerDialogBase.prototype.showOkCancelDialog.call(
- this, title, message, opt_onOk, opt_onCancel);
+ this.onSelectedItemCallback_ = onSelectedItem;
+
+ var show = FileManagerDialogBase.prototype.showTitleAndTextDialog.call(
+ this, title, message);
if (!show) {
console.error('DefaultActionDialog can\'t be shown.');
@@ -128,15 +132,15 @@ cr.define('cr.filebrowser', function() {
*/
DefaultActionDialog.prototype.activateItemAtIndex_ = function(index) {
this.hide();
- this.onOk_(this.dataModel_.item(index));
+ this.onSelectedItemCallback_(this.dataModel_.item(index));
};
/**
* Closes dialog and invokes callback with currently-selected item.
- * @override
*/
- DefaultActionDialog.prototype.onOkClick_ = function() {
- this.activateItemAtIndex_(this.selectionModel_.selectedIndex);
+ DefaultActionDialog.prototype.onSelected_ = function() {
+ if (this.selectionModel_.selectedIndex !== -1)
+ this.activateItemAtIndex_(this.selectionModel_.selectedIndex);
};
/**
@@ -145,10 +149,10 @@ cr.define('cr.filebrowser', function() {
DefaultActionDialog.prototype.onContainerKeyDown_ = function(event) {
// Handle Escape.
if (event.keyCode == 27) {
- this.onCancelClick_(event);
+ this.hide();
event.preventDefault();
} else if (event.keyCode == 32 || event.keyCode == 13) {
- this.onOkClick_();
+ this.onSelected_();
event.preventDefault();
}
};
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/foreground/js/file_manager_commands.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698