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

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: modify cups dialog button to align by flexbox 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
« no previous file with comments | « ui/webui/resources/cr_elements/cr_dialog/cr_dialog.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
70 assert(entries.length == 1); 73 assert(entries.length <= 2);
71 bodyContainer.classList.toggle( 74 for (var i = 0; i < entries.length; i++) {
72 'bottom-scrollable', entries[0].intersectionRatio == 0); 75 var target = entries[i].target;
76 assert(target == bottomMarker || target == topMarker);
77
78 var classToToggle =
79 target == bottomMarker ? 'bottom-scrollable' : 'top-scrollable';
80
81 bodyContainer.classList.toggle(
82 classToToggle, entries[i].intersectionRatio == 0);
83 }
73 }; 84 };
74 85
75 this.intersectionObserver_ = new IntersectionObserver( 86 this.intersectionObserver_ = new IntersectionObserver(
76 callback, 87 callback,
77 /** @type {IntersectionObserverInit} */ ({ 88 /** @type {IntersectionObserverInit} */ ({
78 root: bodyContainer, 89 root: bodyContainer,
79 threshold: 0, 90 threshold: 0,
80 })); 91 }));
81 this.intersectionObserver_.observe(this.$.bodyBottomMarker); 92 this.intersectionObserver_.observe(bottomMarker);
93 this.intersectionObserver_.observe(topMarker);
82 } 94 }
83 }, 95 },
84 96
85 /** @override */ 97 /** @override */
86 detached: function() { 98 detached: function() {
87 if (this.intersectionObserver_) { 99 if (this.intersectionObserver_) {
88 this.intersectionObserver_.disconnect(); 100 this.intersectionObserver_.disconnect();
89 this.intersectionObserver_ = null; 101 this.intersectionObserver_ = null;
90 } 102 }
91 }, 103 },
(...skipping 29 matching lines...) Expand all
121 return; 133 return;
122 134
123 var actionButton = 135 var actionButton =
124 this.querySelector('.action-button:not([disabled]):not([hidden])'); 136 this.querySelector('.action-button:not([disabled]):not([hidden])');
125 if (actionButton) { 137 if (actionButton) {
126 actionButton.click(); 138 actionButton.click();
127 e.preventDefault(); 139 e.preventDefault();
128 } 140 }
129 }, 141 },
130 }); 142 });
OLDNEW
« no previous file with comments | « ui/webui/resources/cr_elements/cr_dialog/cr_dialog.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698