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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 | 134 |
| 135 if (this.showPages_.advanced) { | 135 if (this.showPages_.advanced) { |
| 136 assert(!this.pageVisibility || | 136 assert(!this.pageVisibility || |
| 137 this.pageVisibility.advancedSettings !== false); | 137 this.pageVisibility.advancedSettings !== false); |
| 138 this.advancedToggleExpanded_ = true; | 138 this.advancedToggleExpanded_ = true; |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 // Wait for any other changes prior to calculating the overflow padding. | 142 // Wait for any other changes prior to calculating the overflow padding. |
| 143 setTimeout(function() { | 143 setTimeout(function() { |
| 144 // Ensure any dom-if reflects the current properties. | |
| 145 Polymer.dom.flush(); | |
|
dschuyler
2016/07/30 00:46:29
I moved this to keep all the timeout/flush
('is th
| |
| 146 | |
| 144 this.$.overscroll.style.paddingBottom = this.overscrollHeight_() + 'px'; | 147 this.$.overscroll.style.paddingBottom = this.overscrollHeight_() + 'px'; |
| 145 }.bind(this)); | 148 }.bind(this)); |
| 146 }, | 149 }, |
| 147 | 150 |
| 148 /** | 151 /** |
| 149 * Return the height that the over scroll padding should be set to. | 152 * Return the height that the overscroll padding should be set to. |
| 150 * This is used to determine how much padding to apply to the end of the | 153 * 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 | 154 * content so that the last element may align with the top of the content |
| 152 * area. | 155 * area. |
| 153 * @return {number} | 156 * @return {number} |
| 154 * @private | 157 * @private |
| 155 */ | 158 */ |
| 156 overscrollHeight_: function() { | 159 overscrollHeight_: function() { |
| 157 if (!this.currentRoute || this.currentRoute.subpage.length != 0 || | 160 if (!this.currentRoute || this.currentRoute.subpage.length != 0 || |
| 158 this.showPages_.about) { | 161 this.showPages_.about) { |
| 159 return 0; | 162 return 0; |
| 160 } | 163 } |
| 161 | 164 |
| 162 // Ensure any dom-if reflects the current properties. | 165 var query = 'settings-section[section="' + this.currentRoute.section + '"]'; |
| 163 Polymer.dom.flush(); | 166 var topSection = this.$$('settings-basic-page').$$(query); |
| 167 if (!topSection && this.showPages_.advanced) | |
| 168 topSection = this.$$('settings-advanced-page').$$(query); | |
| 164 | 169 |
| 165 /** | 170 if (topSection) { |
| 166 * @param {!Element} element | 171 return Math.max(0, |
| 167 * @return {number} | 172 this.parentNode.scrollHeight - |
| 168 */ | 173 (this.$.overscroll.offsetTop - |
| 169 var calcHeight = function(element) { | 174 (topSection.offsetParent.offsetTop + topSection.offsetTop))); |
| 170 var style = getComputedStyle(element); | |
| 171 var height = this.parentNode.scrollHeight - element.offsetHeight + | |
| 172 parseFloat(style.marginTop) + parseFloat(style.marginBottom); | |
| 173 assert(height >= 0); | |
| 174 return height; | |
| 175 }.bind(this); | |
| 176 | |
| 177 if (this.showPages_.advanced) { | |
| 178 var lastSection = this.$$('settings-advanced-page').$$( | |
| 179 'settings-section:last-of-type'); | |
| 180 // |lastSection| may be null in unit tests. | |
| 181 if (!lastSection) | |
| 182 return 0; | |
| 183 return calcHeight(lastSection); | |
| 184 } | 175 } |
| 185 | |
| 186 assert(this.showPages_.basic); | |
| 187 var lastSection = this.$$('settings-basic-page').$$( | |
| 188 'settings-section:last-of-type'); | |
| 189 // |lastSection| may be null in unit tests. | |
| 190 if (!lastSection) | |
| 191 return 0; | |
| 192 var toggleContainer = this.$$('#toggleContainer'); | |
| 193 return calcHeight(lastSection) - | |
| 194 (toggleContainer ? toggleContainer.offsetHeight : 0); | |
| 195 }, | 176 }, |
| 196 | 177 |
| 197 /** @private */ | 178 /** @private */ |
| 198 toggleAdvancedPage_: function() { | 179 toggleAdvancedPage_: function() { |
| 199 this.fire('toggle-advanced-page', !this.advancedToggleExpanded_); | 180 this.fire('toggle-advanced-page', !this.advancedToggleExpanded_); |
| 200 }, | 181 }, |
| 201 | 182 |
| 202 /** | 183 /** |
| 203 * Navigates to the default search page (if necessary). | 184 * Navigates to the default search page (if necessary). |
| 204 * @private | 185 * @private |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 | 222 |
| 242 /** | 223 /** |
| 243 * @param {(boolean|undefined)} visibility | 224 * @param {(boolean|undefined)} visibility |
| 244 * @return {boolean} True unless visibility is false. | 225 * @return {boolean} True unless visibility is false. |
| 245 * @private | 226 * @private |
| 246 */ | 227 */ |
| 247 showAdvancedSettings_: function(visibility) { | 228 showAdvancedSettings_: function(visibility) { |
| 248 return visibility !== false; | 229 return visibility !== false; |
| 249 }, | 230 }, |
| 250 }); | 231 }); |
| OLD | NEW |