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' event listener to determine whether it was canceled or just |
| 11 * closed, where a truthy value means success, and a falsy value means it was |
| 12 * canceled. |
7 */ | 13 */ |
8 Polymer({ | 14 Polymer({ |
9 is: 'cr-dialog', | 15 is: 'cr-dialog', |
| 16 extends: 'dialog', |
10 | 17 |
11 properties: { | 18 cancel: function() { |
12 /** @override */ | 19 this.fire('cancel'); |
13 noCancelOnOutsideClick: { | 20 HTMLDialogElement.prototype.close.call(this, ''); |
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 }, | 21 }, |
41 | 22 |
42 behaviors: [Polymer.PaperDialogBehavior], | 23 /** |
| 24 * @param {string=} opt_returnValue |
| 25 * @override |
| 26 */ |
| 27 close: function(opt_returnValue) { |
| 28 HTMLDialogElement.prototype.close.call(this, 'success'); |
| 29 }, |
43 | 30 |
44 /** @return {!PaperIconButtonElement} */ | 31 /** @return {!PaperIconButtonElement} */ |
45 getCloseButton: function() { | 32 getCloseButton: function() { |
46 return this.$.close; | 33 return this.$.close; |
47 }, | 34 }, |
48 }); | 35 }); |
OLD | NEW |