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

Side by Side Diff: ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js

Issue 2702523005: MD Settings: long dialog body should have overscroll line. (Closed)
Patch Set: format and annotation Created 3 years, 8 months 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
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. If the 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 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. 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 9 * Additionally clients can inspect the dialog's |returnValue| property inside
10 * the 'close' event listener to determine whether it was canceled or just 10 * the 'close' event listener to determine whether it was canceled or just
(...skipping 13 matching lines...) Expand all
24 /** 24 /**
25 * True if the dialog should remain open on 'popstate' events. This is used 25 * True if the dialog should remain open on 'popstate' events. This is used
26 * for navigable dialogs that have their separate navigation handling code. 26 * for navigable dialogs that have their separate navigation handling code.
27 */ 27 */
28 ignorePopstate: { 28 ignorePopstate: {
29 type: Boolean, 29 type: Boolean,
30 value: false, 30 value: false,
31 }, 31 },
32 }, 32 },
33 33
34 /** @private {?IntersectionObserver} */
35 intersectionObserver_: null,
36
34 /** @override */ 37 /** @override */
35 ready: function() { 38 ready: function() {
36 // If the active history entry changes (i.e. user clicks back button), 39 // If the active history entry changes (i.e. user clicks back button),
37 // all open dialogs should be cancelled. 40 // all open dialogs should be cancelled.
38 window.addEventListener('popstate', function() { 41 window.addEventListener('popstate', function() {
39 if (!this.ignorePopstate && this.open) 42 if (!this.ignorePopstate && this.open)
40 this.cancel(); 43 this.cancel();
41 }.bind(this)); 44 }.bind(this));
42 }, 45 },
43 46
47 attached: function() {
dpapad 2017/03/29 17:42:16 @override
scottchen 2017/03/29 21:02:08 Done.
48 var bodyContainer = this.$$('.body-container');
49
50 var callback = function(entries) {
51 assert(entries.length == 1);
52 entries[0].intersectionRatio == 0 ?
53 bodyContainer.classList.add('bottom-scrollable') :
54 bodyContainer.classList.remove('bottom-scrollable');
55 };
56
57 this.intersectionObserver_ = new IntersectionObserver(callback, {
58 root: bodyContainer,
59 threshold: 0,
60 });
61 this.intersectionObserver_.observe(this.$.bodyBottomMarker);
dpapad 2017/03/29 17:42:16 We only have a few dialogs that use this functiona
scottchen 2017/03/29 21:02:08 Done.
62 },
63
64 detached: function() {
dpapad 2017/03/29 17:42:16 @override
scottchen 2017/03/29 21:02:08 Done.
65 this.intersectionObserver_.disconnect();
66 this.intersectionObserver_ = null;
67 },
68
44 cancel: function() { 69 cancel: function() {
45 this.fire('cancel'); 70 this.fire('cancel');
46 HTMLDialogElement.prototype.close.call(this, ''); 71 HTMLDialogElement.prototype.close.call(this, '');
47 }, 72 },
48 73
49 /** 74 /**
50 * @param {string=} opt_returnValue 75 * @param {string=} opt_returnValue
51 * @override 76 * @override
52 */ 77 */
53 close: function(opt_returnValue) { 78 close: function(opt_returnValue) {
54 HTMLDialogElement.prototype.close.call(this, 'success'); 79 HTMLDialogElement.prototype.close.call(this, 'success');
55 }, 80 },
56 81
57 /** @return {!PaperIconButtonElement} */ 82 /** @return {!PaperIconButtonElement} */
58 getCloseButton: function() { 83 getCloseButton: function() {
59 return this.$.close; 84 return this.$.close;
60 }, 85 },
61 }); 86 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698