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 23 matching lines...) Expand all Loading... | |
| 34 /** @override */ | 34 /** @override */ |
| 35 ready: function() { | 35 ready: function() { |
| 36 // If the active history entry changes (i.e. user clicks back button), | 36 // If the active history entry changes (i.e. user clicks back button), |
| 37 // all open dialogs should be cancelled. | 37 // all open dialogs should be cancelled. |
| 38 window.addEventListener('popstate', function() { | 38 window.addEventListener('popstate', function() { |
| 39 if (!this.ignorePopstate && this.open) | 39 if (!this.ignorePopstate && this.open) |
| 40 this.cancel(); | 40 this.cancel(); |
| 41 }.bind(this)); | 41 }.bind(this)); |
| 42 }, | 42 }, |
| 43 | 43 |
| 44 attached: function() { | |
|
Dan Beam
2017/02/23 06:22:24
i also considered overriding showModal() but liked
dpapad
2017/02/23 18:28:35
Nit: Add @override
Also that looks fine. If/when
Dan Beam
2017/02/24 05:43:09
Done.
| |
| 45 var title = this.getContentChildren('[select=".title"]'); | |
| 46 if (title.length) | |
| 47 title[0].tabIndex = -1; | |
| 48 }, | |
| 49 | |
| 44 cancel: function() { | 50 cancel: function() { |
| 45 this.fire('cancel'); | 51 this.fire('cancel'); |
| 46 HTMLDialogElement.prototype.close.call(this, ''); | 52 HTMLDialogElement.prototype.close.call(this, ''); |
| 47 }, | 53 }, |
| 48 | 54 |
| 49 /** | 55 /** |
| 50 * @param {string=} opt_returnValue | 56 * @param {string=} opt_returnValue |
| 51 * @override | 57 * @override |
| 52 */ | 58 */ |
| 53 close: function(opt_returnValue) { | 59 close: function(opt_returnValue) { |
| 54 HTMLDialogElement.prototype.close.call(this, 'success'); | 60 HTMLDialogElement.prototype.close.call(this, 'success'); |
| 55 }, | 61 }, |
| 56 | 62 |
| 57 /** @return {!PaperIconButtonElement} */ | 63 /** @return {!PaperIconButtonElement} */ |
| 58 getCloseButton: function() { | 64 getCloseButton: function() { |
| 59 return this.$.close; | 65 return this.$.close; |
| 60 }, | 66 }, |
| 61 }); | 67 }); |
| OLD | NEW |