| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 /** | 6 /** |
| 7 * DefaultActionDialog contains a message, a list box, an ok button, and a | 7 * DefaultActionDialog contains a message, a list box, an ok button, and a |
| 8 * cancel button. | 8 * cancel button. |
| 9 * This dialog should be used as action picker for file operations. | 9 * This dialog should be used as action picker for file operations. |
| 10 */ | 10 */ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 this.list_.activateItemAtIndex = this.activateItemAtIndex_.bind(this); | 34 this.list_.activateItemAtIndex = this.activateItemAtIndex_.bind(this); |
| 35 | 35 |
| 36 this.initialFocusElement_ = this.list_; | 36 this.initialFocusElement_ = this.list_; |
| 37 | 37 |
| 38 var self = this; | 38 var self = this; |
| 39 | 39 |
| 40 // Binding stuff doesn't work with constructors, so we have to create | 40 // Binding stuff doesn't work with constructors, so we have to create |
| 41 // closure here. | 41 // closure here. |
| 42 this.list_.itemConstructor = function(item) { | 42 this.list_.itemConstructor = function(item) { |
| 43 return self.renderItem(item); | 43 return self.renderItem(item); |
| 44 } | 44 }; |
| 45 } | 45 } |
| 46 | 46 |
| 47 DefaultActionDialog.prototype = { | 47 DefaultActionDialog.prototype = { |
| 48 __proto__: cr.ui.dialogs.BaseDialog.prototype | 48 __proto__: cr.ui.dialogs.BaseDialog.prototype |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 /** | 51 /** |
| 52 * Overrides BaseDialog::onInputFocus | 52 * Overrides BaseDialog::onInputFocus |
| 53 */ | 53 */ |
| 54 DefaultActionDialog.prototype.onInputFocus = function() { | 54 DefaultActionDialog.prototype.onInputFocus = function() { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 /** | 117 /** |
| 118 * List activation handler. Closes dialog and calls 'ok' callback. | 118 * List activation handler. Closes dialog and calls 'ok' callback. |
| 119 * | 119 * |
| 120 * @param {int} index Activated index. | 120 * @param {int} index Activated index. |
| 121 */ | 121 */ |
| 122 DefaultActionDialog.prototype.activateItemAtIndex_ = function(index) { | 122 DefaultActionDialog.prototype.activateItemAtIndex_ = function(index) { |
| 123 this.hide(); | 123 this.hide(); |
| 124 if (this.onOk_) | 124 if (this.onOk_) |
| 125 this.onOk_(this.dataModel_.item(index).task); | 125 this.onOk_(this.dataModel_.item(index).task); |
| 126 } | 126 }; |
| 127 | 127 |
| 128 /** | 128 /** |
| 129 * Closes dialog and invokes callback with currently-selected item. | 129 * Closes dialog and invokes callback with currently-selected item. |
| 130 */ | 130 */ |
| 131 DefaultActionDialog.prototype.onOkClick_ = function() { | 131 DefaultActionDialog.prototype.onOkClick_ = function() { |
| 132 this.activateItemAtIndex_(this.selectionModel_.selectedIndex); | 132 this.activateItemAtIndex_(this.selectionModel_.selectedIndex); |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 // Overrides BaseDialog::onContainerKeyDown_; | 135 // Overrides BaseDialog::onContainerKeyDown_; |
| 136 DefaultActionDialog.prototype.onContainerKeyDown_ = function(event) { | 136 DefaultActionDialog.prototype.onContainerKeyDown_ = function(event) { |
| 137 // Handle Escape. | 137 // Handle Escape. |
| 138 if (event.keyCode == 27) { | 138 if (event.keyCode == 27) { |
| 139 this.onCancelClick_(event); | 139 this.onCancelClick_(event); |
| 140 event.preventDefault(); | 140 event.preventDefault(); |
| 141 } else if (event.keyCode == 32 || event.keyCode == 13) { | 141 } else if (event.keyCode == 32 || event.keyCode == 13) { |
| 142 this.onOkClick_(); | 142 this.onOkClick_(); |
| 143 event.preventDefault(); | 143 event.preventDefault(); |
| 144 } | 144 } |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 return {DefaultActionDialog: DefaultActionDialog}; | 147 return {DefaultActionDialog: DefaultActionDialog}; |
| 148 }); | 148 }); |
| OLD | NEW |