Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 Polymer({ | |
| 6 is: 'dialog-drawer', | |
| 7 extends: 'dialog', | |
| 8 | |
| 9 properties: { | |
| 10 /** Enables notifications for |Dialog.open|. */ | |
| 11 open: { | |
| 12 type: Boolean, | |
| 13 notify: true, | |
| 14 }, | |
| 15 | |
| 16 /** The alignment of the drawer on the screen ('left' or 'right'). */ | |
| 17 align: { | |
| 18 type: String, | |
| 19 value: 'left', | |
| 20 reflectToAttribute: true, | |
| 21 }, | |
| 22 }, | |
| 23 | |
| 24 listeners: { | |
| 25 'cancel': 'onDialogCancel_', | |
| 26 'tap': 'onDialogTap_', | |
| 27 'transitionend': 'onDialogTransitionEnd_', | |
| 28 }, | |
| 29 | |
| 30 /** Toggles the drawer open and close. */ | |
| 31 toggle: function() { | |
| 32 if (this.open) | |
| 33 this.closeDrawer(); | |
| 34 else | |
| 35 this.openDrawer(); | |
| 36 }, | |
| 37 | |
| 38 /** Shows drawer and slides it into view. */ | |
| 39 openDrawer: function() { | |
| 40 if (!this.open) { | |
| 41 this.showModal(); | |
| 42 this.classList.add('opening'); | |
| 43 } | |
| 44 }, | |
| 45 | |
| 46 /** Slides the drawer away, then closes it after the transition has ended. */ | |
| 47 closeDrawer: function() { | |
| 48 if (this.open) { | |
| 49 this.classList.remove('opening'); | |
| 50 this.classList.add('closing'); | |
| 51 } | |
| 52 }, | |
| 53 | |
| 54 /** | |
| 55 * Stop propagation of a tap event inside the container. This will allow | |
| 56 * |onDialogTap_| to only be called when clicked outside the container. | |
| 57 * @param {Event} event | |
|
dpapad
2016/12/09 18:57:53
!Event here and line 75.
hcarmona
2016/12/09 19:21:26
Done.
| |
| 58 * @private | |
| 59 */ | |
| 60 onContainerTap_: function(event) { | |
| 61 event.stopPropagation(); | |
| 62 }, | |
| 63 | |
| 64 /** | |
| 65 * Close the dialog when tapped outside the container. | |
| 66 * @param {Event} event | |
| 67 * @private | |
| 68 */ | |
| 69 onDialogTap_: function(event) { | |
|
dpapad
2016/12/09 18:57:53
We are not using |event| here, so how about droppi
hcarmona
2016/12/09 19:21:26
Done.
| |
| 70 this.closeDrawer(); | |
| 71 }, | |
| 72 | |
| 73 /** | |
| 74 * Overrides the default cancel machanism to allow for a close animation. | |
| 75 * @param {Event} event | |
| 76 * @private | |
| 77 */ | |
| 78 onDialogCancel_: function(event) { | |
| 79 event.preventDefault(); | |
| 80 this.closeDrawer(); | |
| 81 }, | |
| 82 | |
| 83 /** | |
| 84 * Closes the dialog when the closing animation is over. | |
| 85 * @private | |
| 86 */ | |
| 87 onDialogTransitionEnd_: function() { | |
| 88 if (this.classList.contains('closing')) { | |
| 89 this.classList.remove('closing'); | |
| 90 this.close(); | |
| 91 } | |
| 92 }, | |
| 93 }); | |
| OLD | NEW |