Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * @fileoverview 'cr-dialog' is a component for showing a modal dialog. If the | 6 * @fileoverview 'cr-dialog' is a component for showing a modal dialog. If the |
| 7 * dialog is closed via close(), a 'close' event is fired. If the dialog is | 7 * dialog is closed via close(), a 'close' event is fired. If the dialog is |
| 8 * canceled via cancel(), a 'cancel' event is fired followed by a 'close' event. | 8 * canceled via cancel(), a 'cancel' event is fired followed by a 'close' event. |
| 9 * Additionally clients can inspect the dialog's |returnValue| property inside | 9 * Additionally clients can inspect the dialog's |returnValue| property inside |
| 10 * the 'close' event listener to determine whether it was canceled or just | 10 * the 'close' event listener to determine whether it was canceled or just |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 /** @return {!PaperIconButtonElement} */ | 106 /** @return {!PaperIconButtonElement} */ |
| 107 getCloseButton: function() { | 107 getCloseButton: function() { |
| 108 return this.$.close; | 108 return this.$.close; |
| 109 }, | 109 }, |
| 110 | 110 |
| 111 /** | 111 /** |
| 112 * @param {!Event} e | 112 * @param {!Event} e |
| 113 * @private | 113 * @private |
| 114 */ | 114 */ |
| 115 onKeypress_: function(e) { | 115 onKeypress_: function(e) { |
| 116 if (e.target != this) | 116 if (!e.target) |
|
dpapad
2017/04/04 23:46:14
Is that possible?
tommycli
2017/04/05 21:07:07
Done.
| |
| 117 return; | 117 return; |
| 118 if (e.key != 'Enter') | 118 if (e.key != 'Enter') |
| 119 return; | 119 return; |
| 120 | 120 |
| 121 // Accept Enter keys from either the dialog, or a child paper-input element. | |
| 122 if (e.target != this && e.target.tagName != 'PAPER-INPUT') | |
|
dpapad
2017/04/04 23:46:14
Can we add a test for this? You can use a <paper-i
tommycli
2017/04/05 21:07:07
Done.
| |
| 123 return; | |
| 124 | |
| 121 var actionButton = | 125 var actionButton = |
| 122 this.querySelector('.action-button:not([disabled]):not([hidden])'); | 126 this.querySelector('.action-button:not([disabled]):not([hidden])'); |
| 123 if (actionButton) { | 127 if (actionButton) { |
| 124 actionButton.click(); | 128 actionButton.click(); |
| 125 e.preventDefault(); | 129 e.preventDefault(); |
| 126 } | 130 } |
| 127 }, | 131 }, |
| 128 }); | 132 }); |
| OLD | NEW |