Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: chrome/browser/resources/settings/controls/dialog_drawer.js

Issue 2465433002: Create implementation of the side panel using a dialog. (Closed)
Patch Set: Feedback Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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.close_();
34 else
35 this.open_();
36 },
37
38 /** Shows drawer and slides it into view. */
39 open_: function() {
dpapad 2016/11/16 22:52:46 @private. Here and elsewhere.
hcarmona 2016/12/08 19:59:00 This is public now.
40 if (!this.open) {
41 this.showModal();
42 this.classList.add('opening');
43 }
44 },
45
46 /** Slides the drawer away, then closes it in a different event. */
47 close_: function() {
48 if (this.open) {
49 this.classList.remove('opening');
50 this.classList.add('closing');
51 }
52 },
53
54 /**
55 * Listens for a tap event outside the dialog in order to close it.
56 * @param {Event} event
57 */
58 onDialogTap_: function(event) {
59 var rect = this.getBoundingClientRect();
60
61 // We can ignore checking top/bottom because dialog is height 100%.
62 if (event.detail.x < rect.left || event.detail.x > rect.right)
dpapad 2016/11/16 22:52:46 Would this also work, given that the dialog is fil
hcarmona 2016/12/08 19:59:00 Done.
63 this.close_();
64 },
65
66 /**
67 * Overrides the default cancel machanism to allow for a close animation.
68 * @param {Event} event
69 */
70 onDialogCancel_: function(event) {
71 event.preventDefault();
72 this.close_();
73 },
74
75 /** Closes the dialog when the closing animation is over. */
76 onDialogTransitionEnd_: function() {
77 if (this.classList.contains('closing')) {
78 this.classList.remove('closing');
79 this.close();
80 }
81 },
82 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698