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

Side by Side Diff: chrome/browser/resources/settings/settings_main/settings_main.js

Issue 2090753002: [MD settings] end of page padding in content area (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unit test fix Created 4 years, 4 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 | « chrome/browser/resources/settings/settings_main/settings_main.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 6 * @fileoverview
7 * 'settings-main' displays the selected settings page. 7 * 'settings-main' displays the selected settings page.
8 */ 8 */
9 Polymer({ 9 Polymer({
10 is: 'settings-main', 10 is: 'settings-main',
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 this.showPages_ = { 123 this.showPages_ = {
124 about: false, 124 about: false,
125 basic: newRoute.page == 'basic' || !this.inSubpage_, 125 basic: newRoute.page == 'basic' || !this.inSubpage_,
126 advanced: newRoute.page == 'advanced' || 126 advanced: newRoute.page == 'advanced' ||
127 (!this.inSubpage_ && this.advancedToggleExpanded_), 127 (!this.inSubpage_ && this.advancedToggleExpanded_),
128 }; 128 };
129 129
130 if (this.showPages_.advanced) 130 if (this.showPages_.advanced)
131 this.advancedToggleExpanded_ = true; 131 this.advancedToggleExpanded_ = true;
132 } 132 }
133
134 // Wait for the dom-if changes prior to calculating the overflow padding.
135 this.async(function() {
136 this.$.overscroll.style.paddingBottom = this.overscrollHeight_() + 'px';
137 });
138 },
139
140 /**
141 * Return the height that the over scroll padding should be set to.
142 * This is used to determine how much padding to apply to the end of the
143 * content so that the last element may align with the top of the content
144 * area.
145 * @return {number}
146 * @private
147 */
148 overscrollHeight_: function() {
149 if (!this.currentRoute || this.currentRoute.subpage.length != 0 ||
150 this.showPages_.about) {
151 return 0;
152 }
153
154 /**
155 * @param {!Element} element
156 * @return {number}
157 */
158 var calcHeight = function(element) {
159 var style = getComputedStyle(element);
160 var height = this.parentNode.scrollHeight - element.offsetHeight +
161 parseFloat(style.marginTop) + parseFloat(style.marginBottom);
162 assert(height >= 0);
163 return height;
164 }.bind(this);
165
166 if (this.showPages_.advanced) {
167 var lastSection = this.$$('settings-advanced-page').$$(
168 'settings-section:last-of-type');
169 // |lastSection| may be null in unit tests.
170 if (!lastSection)
171 return 0;
172 return calcHeight(lastSection);
173 }
174
175 assert(this.showPages_.basic);
176 var lastSection = this.$$('settings-basic-page').$$(
177 'settings-section:last-of-type');
178 // |lastSection| may be null in unit tests.
179 if (!lastSection)
180 return 0;
181 return calcHeight(lastSection) - this.$$('#toggleContainer').offsetHeight;
133 }, 182 },
134 183
135 /** @private */ 184 /** @private */
136 toggleAdvancedPage_: function() { 185 toggleAdvancedPage_: function() {
137 this.fire('toggle-advanced-page', !this.advancedToggleExpanded_); 186 this.fire('toggle-advanced-page', !this.advancedToggleExpanded_);
138 }, 187 },
139 188
140 /** 189 /**
141 * Navigates to the default search page (if necessary). 190 * Navigates to the default search page (if necessary).
142 * @private 191 * @private
(...skipping 19 matching lines...) Expand all
162 setTimeout(function() { 211 setTimeout(function() {
163 settings.getSearchManager().search( 212 settings.getSearchManager().search(
164 query, assert(this.$$('settings-basic-page'))); 213 query, assert(this.$$('settings-basic-page')));
165 }.bind(this), 0); 214 }.bind(this), 0);
166 setTimeout(function() { 215 setTimeout(function() {
167 settings.getSearchManager().search( 216 settings.getSearchManager().search(
168 query, assert(this.$$('settings-advanced-page'))); 217 query, assert(this.$$('settings-advanced-page')));
169 }.bind(this), 0); 218 }.bind(this), 0);
170 }, 219 },
171 }); 220 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/settings/settings_main/settings_main.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698