Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 | 131 |
| 132 this.showAdvancedToggle_ = !this.showAboutPage_ && !isSubpage; | 132 this.showAdvancedToggle_ = !this.showAboutPage_ && !isSubpage; |
| 133 | 133 |
| 134 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; | 134 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; |
| 135 | 135 |
| 136 this.showAdvancedPage_ = | 136 this.showAdvancedPage_ = |
| 137 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || | 137 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || |
| 138 newRoute.page == 'advanced'; | 138 newRoute.page == 'advanced'; |
| 139 | 139 |
| 140 this.style.height = isSubpage ? '100%' : ''; | 140 this.style.height = isSubpage ? '100%' : ''; |
| 141 | |
| 142 // Wait for the dom-if changes prior to calculating the overflow padding. | |
| 143 this.async(function() { | |
| 144 this.$.overscroll.style.paddingBottom = this.overscrollHeight_() + 'px'; | |
| 145 }); | |
| 146 }, | |
| 147 | |
| 148 /** | |
| 149 * Return the height that the over scroll padding should be set to. | |
| 150 * This is used to determine how much padding to apply to the end of the | |
| 151 * content so that the last element may align with the top of the content | |
| 152 * area. | |
| 153 * @return {number} | |
| 154 * @private | |
| 155 */ | |
| 156 overscrollHeight_: function() { | |
| 157 if (!this.currentRoute || this.currentRoute.subpage.length != 0 || | |
| 158 this.showAboutPage_) { | |
| 159 return 0; | |
| 160 } | |
| 161 | |
| 162 /** | |
| 163 * @param {!Element} element | |
| 164 * @return {number} | |
| 165 */ | |
| 166 function calcHeight(scrollHeight, element) { | |
|
Dan Beam
2016/07/20 21:22:39
nit: missing a @param, BUT, can we just get this v
dschuyler
2016/07/21 00:14:23
That is nicer, thanks.
Done.
| |
| 167 var style = getComputedStyle(element); | |
| 168 var height = scrollHeight - element.offsetHeight + | |
| 169 parseFloat(style.marginTop) + parseFloat(style.marginBottom); | |
| 170 assert(height >= 0); | |
| 171 return height; | |
| 172 } | |
| 173 | |
| 174 var scrollHeight = this.parentNode.scrollHeight; | |
| 175 | |
| 176 if (this.showAdvancedPage_) { | |
| 177 var lastSection = this.$$('settings-advanced-page').$$( | |
| 178 'settings-section:last-of-type'); | |
| 179 // |lastSection| may be null in unit tests. | |
| 180 if (lastSection) | |
| 181 return calcHeight(scrollHeight, lastSection); | |
| 182 } | |
| 183 | |
| 184 var toggleContainer = this.$$('#toggleContainer'); | |
| 185 if (toggleContainer) | |
| 186 return calcHeight(scrollHeight, toggleContainer); | |
| 187 | |
| 188 return 0; | |
| 141 }, | 189 }, |
| 142 | 190 |
| 143 /** @private */ | 191 /** @private */ |
| 144 toggleAdvancedPage_: function() { | 192 toggleAdvancedPage_: function() { |
| 145 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); | 193 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); |
| 146 }, | 194 }, |
| 147 | 195 |
| 148 /** | 196 /** |
| 149 * Navigates to the default search page (if necessary). | 197 * Navigates to the default search page (if necessary). |
| 150 * @private | 198 * @private |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 172 query, assert(this.$$('settings-basic-page'))); | 220 query, assert(this.$$('settings-basic-page'))); |
| 173 }.bind(this), 0); | 221 }.bind(this), 0); |
| 174 | 222 |
| 175 this.showAdvancedPage_ = true; | 223 this.showAdvancedPage_ = true; |
| 176 setTimeout(function() { | 224 setTimeout(function() { |
| 177 settings.getSearchManager().search( | 225 settings.getSearchManager().search( |
| 178 query, assert(this.$$('settings-advanced-page'))); | 226 query, assert(this.$$('settings-advanced-page'))); |
| 179 }.bind(this), 0); | 227 }.bind(this), 0); |
| 180 }, | 228 }, |
| 181 }); | 229 }); |
| OLD | NEW |