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. | 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 | |
| 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 | |
| 10 * the 'close' callback to determine whether it was canceled or just closed, | |
|
michaelpg
2016/07/28 16:50:50
"callback" is confusing here, since close is also
Dan Beam
2016/07/28 17:31:43
that's fine by me
| |
| 11 * where a truthy value means success, and a falsy value means it was canceled. | |
| 7 */ | 12 */ |
| 8 Polymer({ | 13 Polymer({ |
| 9 is: 'cr-dialog', | 14 is: 'cr-dialog', |
| 15 extends: 'dialog', | |
| 10 | 16 |
| 11 properties: { | 17 cancel: function() { |
| 12 /** @override */ | 18 this.fire('cancel'); |
| 13 noCancelOnOutsideClick: { | 19 HTMLDialogElement.prototype.close.call(this); |
|
michaelpg
2016/07/28 16:50:50
shouldn't this provide the returnValue argument ''
Dan Beam
2016/07/28 17:31:43
undefined results in '' as a returnValue (of the d
dpapad
2016/07/28 18:47:34
Actually after trying this manually it turns out t
| |
| 14 type: Boolean, | |
| 15 value: true, | |
| 16 }, | |
| 17 | |
| 18 /** @override */ | |
| 19 noCancelOnEscKey: { | |
| 20 type: Boolean, | |
| 21 value: false, | |
| 22 }, | |
| 23 | |
| 24 /** | |
| 25 * @type {!Element} | |
| 26 * @override | |
| 27 */ | |
| 28 sizingTarget: { | |
| 29 type: Element, | |
| 30 value: function() { | |
| 31 return assert(this.$$('.body-container')); | |
| 32 }, | |
| 33 }, | |
| 34 | |
| 35 /** @override */ | |
| 36 withBackdrop: { | |
| 37 type: Boolean, | |
| 38 value: true, | |
| 39 }, | |
| 40 }, | 20 }, |
| 41 | 21 |
| 42 behaviors: [Polymer.PaperDialogBehavior], | 22 /** |
| 23 * @param {string=} opt_returnValue | |
| 24 * @override | |
| 25 */ | |
| 26 close: function(opt_returnValue) { | |
|
michaelpg
2016/07/28 16:50:50
it looks like nobody ever uses this parameter -- w
Dan Beam
2016/07/28 17:31:43
we're overriding native HTMLDialogElement#close
| |
| 27 HTMLDialogElement.prototype.close.call(this, 'success'); | |
|
michaelpg
2016/07/28 16:50:50
why include opt_returnValue only to discard it?
Dan Beam
2016/07/28 17:31:43
see above
| |
| 28 }, | |
| 43 | 29 |
| 44 /** @return {!PaperIconButtonElement} */ | 30 /** @return {!PaperIconButtonElement} */ |
| 45 getCloseButton: function() { | 31 getCloseButton: function() { |
| 46 return this.$.close; | 32 return this.$.close; |
| 47 }, | 33 }, |
| 48 }); | 34 }); |
| OLD | NEW |