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

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

Issue 2795763003: MD Settings: adjust dialog style and scroll border visual (Closed)
Patch Set: add missing var declaration 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 if (!this.ignoreEnterKey) 60 if (!this.ignoreEnterKey)
61 this.addEventListener('keypress', this.onKeypress_.bind(this)); 61 this.addEventListener('keypress', this.onKeypress_.bind(this));
62 }, 62 },
63 63
64 /** @override */ 64 /** @override */
65 attached: function() { 65 attached: function() {
66 if (this.showScrollBorders) { 66 if (this.showScrollBorders) {
67 var bodyContainer = this.$$('.body-container'); 67 var bodyContainer = this.$$('.body-container');
68 68
69 var bottomMarker = this.$.bodyBottomMarker;
70 var topMarker = this.$.bodyTopMarker;
71
69 var callback = function(entries) { 72 var callback = function(entries) {
dschuyler 2017/04/06 21:53:22 How large can |entries.length| be?
scottchen 2017/04/06 22:15:57 At most 2, added an assert to call it out.
70 assert(entries.length == 1); 73 for (var i = 0; i < entries.length; i++) {
71 bodyContainer.classList.toggle( 74 var target = entries[i].target;
72 'bottom-scrollable', entries[0].intersectionRatio == 0); 75 assert(target == bottomMarker || target == topMarker);
76
77 var classToToggle =
78 target == bottomMarker ? 'bottom-scrollable' : 'top-scrollable';
79
80 bodyContainer.classList.toggle(
81 classToToggle, entries[i].intersectionRatio == 0);
82 }
73 }; 83 };
74 84
75 this.intersectionObserver_ = new IntersectionObserver( 85 this.intersectionObserver_ = new IntersectionObserver(
76 callback, 86 callback,
77 /** @type {IntersectionObserverInit} */ ({ 87 /** @type {IntersectionObserverInit} */ ({
78 root: bodyContainer, 88 root: bodyContainer,
79 threshold: 0, 89 threshold: 0,
80 })); 90 }));
81 this.intersectionObserver_.observe(this.$.bodyBottomMarker); 91 this.intersectionObserver_.observe(bottomMarker);
92 this.intersectionObserver_.observe(topMarker);
82 } 93 }
83 }, 94 },
84 95
85 /** @override */ 96 /** @override */
86 detached: function() { 97 detached: function() {
87 if (this.intersectionObserver_) { 98 if (this.intersectionObserver_) {
88 this.intersectionObserver_.disconnect(); 99 this.intersectionObserver_.disconnect();
89 this.intersectionObserver_ = null; 100 this.intersectionObserver_ = null;
90 } 101 }
91 }, 102 },
(...skipping 29 matching lines...) Expand all
121 return; 132 return;
122 133
123 var actionButton = 134 var actionButton =
124 this.querySelector('.action-button:not([disabled]):not([hidden])'); 135 this.querySelector('.action-button:not([disabled]):not([hidden])');
125 if (actionButton) { 136 if (actionButton) {
126 actionButton.click(); 137 actionButton.click();
127 e.preventDefault(); 138 e.preventDefault();
128 } 139 }
129 }, 140 },
130 }); 141 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698