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..8935841cafa0d3533c392df48feaf6b8b480e3cf 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)} onSelected Callback which called when an item is |
arv (Not doing code reviews)
2014/01/06 15:13:34
Callback which _is_ called ...
yoshiki
2014/01/08 04:59:02
Done.
|
+ * selected. |
*/ |
DefaultActionDialog.prototype.show = function(title, message, items, |
- defaultIndex, opt_onOk, opt_onCancel) { |
+ defaultIndex, onSelectedItem) { |
arv (Not doing code reviews)
2014/01/06 15:13:34
The @param does not match
yoshiki
2014/01/08 04:59:02
Done.
|
- 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(); |
arv (Not doing code reviews)
2014/01/06 15:13:34
wrong indentation
yoshiki
2014/01/08 04:59:02
Done.
|
event.preventDefault(); |
} else if (event.keyCode == 32 || event.keyCode == 13) { |
- this.onOkClick_(); |
+ this.onSelected_(); |
event.preventDefault(); |
} |
}; |