Chromium Code Reviews| 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..999305fc6d16d5add5b84982f10951eb314b451d 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,17 @@ 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 with the selected item. |
| + * @param {function()=} opt_onCancel Cancel callback with no selected item. |
| */ |
| DefaultActionDialog.prototype.show = function(title, message, items, |
| - defaultIndex, opt_onOk, opt_onCancel) { |
| + defaultIndex, onSelectedItem, opt_onCancel) { |
| - var show = FileManagerDialogBase.prototype.showOkCancelDialog.call( |
| - this, title, message, opt_onOk, opt_onCancel); |
| + this.onSelectedItemCallback_ = onSelectedItem; |
| + this.onCancelledCallback_ = opt_onCancel || function() {}; |
|
hirono
2013/12/13 06:50:10
Will this called when the close button is clicked
yoshiki
2013/12/13 07:37:34
Good point! It never been called. Removed this and
|
| + |
| + var show = FileManagerDialogBase.prototype.showTitleAndTextDialog.call( |
| + this, title, message); |
| if (!show) { |
| console.error('DefaultActionDialog can\'t be shown.'); |
| @@ -128,15 +133,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 +150,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(); |
| } |
| }; |