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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 | 111 |
| 112 this.showAdvancedToggle_ = !this.showAboutPage_ && !isSubpage; | 112 this.showAdvancedToggle_ = !this.showAboutPage_ && !isSubpage; |
| 113 | 113 |
| 114 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; | 114 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; |
| 115 | 115 |
| 116 this.showAdvancedPage_ = | 116 this.showAdvancedPage_ = |
| 117 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || | 117 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || |
| 118 newRoute.page == 'advanced'; | 118 newRoute.page == 'advanced'; |
| 119 | 119 |
| 120 this.style.height = isSubpage ? '100%' : ''; | 120 this.style.height = isSubpage ? '100%' : ''; |
| 121 | |
| 122 /* Flush the dom-if changes prior to calculating the overflow padding. */ | |
| 123 Polymer.dom.flush(); | |
|
Dan Beam
2016/07/02 00:17:31
can't we just do:
this.async(function() {
this.
dschuyler
2016/07/02 00:23:55
Done.
| |
| 124 this.$.overscroll.style.paddingBottom = | |
| 125 (this.parentNode.scrollHeight - this.lastSettingsElementHeight_()) + | |
| 126 'px'; | |
| 127 }, | |
| 128 | |
| 129 /** | |
| 130 * Return the height of the last item in the settings content area. Used to | |
| 131 * determine how much padding to apply to the end of the content so that the | |
| 132 * last element may align with the top of the content area. | |
| 133 * @return {number} | |
| 134 * @private | |
| 135 */ | |
| 136 lastSettingsElementHeight_: function() { | |
| 137 if (!this.currentRoute || this.currentRoute.subpage.length != 0 || | |
| 138 this.showAboutPage_) { | |
| 139 return 0; | |
| 140 } | |
| 141 | |
| 142 /** | |
| 143 * @param {Element} element | |
| 144 * @return {number} | |
| 145 */ | |
| 146 function calcHeight(element) { | |
| 147 var style = getComputedStyle(element); | |
| 148 return element.offsetHeight + parseFloat(style.marginTop) + | |
| 149 parseFloat(style.marginBottom); | |
| 150 } | |
| 151 | |
| 152 if (this.showAdvancedPage_) { | |
| 153 var sections = this.$$('settings-advanced-page').$$( | |
| 154 '[data-page=advanced]').querySelectorAll('settings-section'); | |
| 155 return calcHeight(sections[sections.length - 1]); | |
| 156 } | |
| 157 | |
| 158 var toggleContainer = this.$$('#toggleContainer'); | |
| 159 if (toggleContainer) | |
| 160 return calcHeight(toggleContainer); | |
| 161 | |
| 162 return 0; | |
| 121 }, | 163 }, |
| 122 | 164 |
| 123 /** @private */ | 165 /** @private */ |
| 124 toggleAdvancedPage_: function() { | 166 toggleAdvancedPage_: function() { |
| 125 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); | 167 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); |
| 126 }, | 168 }, |
| 127 }); | 169 }); |
| OLD | NEW |