Index: ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js |
diff --git a/ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js b/ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js |
index 9c9d73fdb7eeaf95bb10574131a0d56d354a5b8b..29d7ea913708d7f42bf51bb7d33d7e854927c7f4 100644 |
--- a/ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js |
+++ b/ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js |
@@ -3,43 +3,29 @@ |
// found in the LICENSE file. |
/** |
- * @fileoverview 'cr-dialog' is a component for showing a modal dialog. |
+ * @fileoverview 'cr-dialog' is a component for showing a modal dialog. If the |
+ * dialog is closed via close(), a 'close' event is fired. If the dialog is |
+ * canceled via cancel(), a 'cancel' event is fired followed by a 'close' event. |
+ * Additionally clients can inspect the dialog's |returnValue| property inside |
+ * 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
|
+ * where a truthy value means success, and a falsy value means it was canceled. |
*/ |
Polymer({ |
is: 'cr-dialog', |
+ extends: 'dialog', |
- properties: { |
- /** @override */ |
- noCancelOnOutsideClick: { |
- type: Boolean, |
- value: true, |
- }, |
- |
- /** @override */ |
- noCancelOnEscKey: { |
- type: Boolean, |
- value: false, |
- }, |
- |
- /** |
- * @type {!Element} |
- * @override |
- */ |
- sizingTarget: { |
- type: Element, |
- value: function() { |
- return assert(this.$$('.body-container')); |
- }, |
- }, |
- |
- /** @override */ |
- withBackdrop: { |
- type: Boolean, |
- value: true, |
- }, |
+ cancel: function() { |
+ this.fire('cancel'); |
+ 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
|
}, |
- behaviors: [Polymer.PaperDialogBehavior], |
+ /** |
+ * @param {string=} opt_returnValue |
+ * @override |
+ */ |
+ 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
|
+ 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
|
+ }, |
/** @return {!PaperIconButtonElement} */ |
getCloseButton: function() { |