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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 showAboutPage_: { | 56 showAboutPage_: { |
| 57 type: Boolean, | 57 type: Boolean, |
| 58 value: false, | 58 value: false, |
| 59 }, | 59 }, |
| 60 }, | 60 }, |
| 61 | 61 |
| 62 attached: function() { | 62 attached: function() { |
| 63 document.addEventListener('toggle-advanced-page', function(e) { | 63 document.addEventListener('toggle-advanced-page', function(e) { |
| 64 this.showAdvancedPage_ = e.detail; | 64 this.showAdvancedPage_ = e.detail; |
| 65 this.isAdvancedMenuOpen_ = e.detail; | 65 this.isAdvancedMenuOpen_ = e.detail; |
| 66 this.currentRoute = { | |
|
michaelpg
2016/06/30 17:13:22
can this be submitted separately?
dschuyler
2016/07/01 19:21:22
Done.
| |
| 67 page: this.isAdvancedMenuOpen_ ? 'advanced' : 'basic', | |
| 68 section: '', | |
| 69 subpage: [], | |
| 70 url: '', | |
|
Dan Beam
2016/06/30 06:45:54
can you just omit URL?
dschuyler
2016/06/30 23:52:18
We could change the SettingsRoute typedef to not r
Dan Beam
2016/06/30 23:59:15
how are all the other assignments to currentRoute
dschuyler
2016/07/01 19:21:22
Done.
dschuyler
2016/07/01 19:21:22
Acknowledged.
| |
| 71 }; | |
| 66 if (this.showAdvancedPage_) { | 72 if (this.showAdvancedPage_) { |
| 67 scrollWhenReady( | 73 scrollWhenReady( |
| 68 function() { | 74 function() { |
| 69 return this.$$('settings-advanced-page'); | 75 return this.$$('settings-advanced-page'); |
| 70 }.bind(this), | 76 }.bind(this), |
| 71 function() { | 77 function() { |
| 72 return this.$$('#toggleContainer'); | 78 return this.$$('#toggleContainer'); |
| 73 }.bind(this)); | 79 }.bind(this)); |
| 74 } | 80 } |
| 75 }.bind(this)); | 81 }.bind(this)); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 95 | 101 |
| 96 this.showAdvancedToggle_ = !this.showAboutPage_ && !isSubpage; | 102 this.showAdvancedToggle_ = !this.showAboutPage_ && !isSubpage; |
| 97 | 103 |
| 98 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; | 104 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; |
| 99 | 105 |
| 100 this.showAdvancedPage_ = | 106 this.showAdvancedPage_ = |
| 101 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || | 107 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || |
| 102 newRoute.page == 'advanced'; | 108 newRoute.page == 'advanced'; |
| 103 | 109 |
| 104 this.style.height = isSubpage ? '100%' : ''; | 110 this.style.height = isSubpage ? '100%' : ''; |
| 111 | |
| 112 this.$.overscroll.style.paddingBottom = | |
| 113 (this.parentNode.scrollHeight - this.lastSettingsElementHeight_()) + | |
| 114 'px'; | |
| 115 }, | |
| 116 | |
| 117 /** | |
| 118 * Return the height of the last item in the settings content area. Used to | |
| 119 * determine how much padding to apply to the end of the content so that the | |
| 120 * last element may align with the top of the content area. | |
| 121 * @return {number} | |
| 122 * @private | |
| 123 */ | |
| 124 lastSettingsElementHeight_: function() { | |
| 125 /** | |
| 126 * @param {Element} element | |
| 127 * @return {number} | |
| 128 */ | |
| 129 function calcHeight(element) { | |
| 130 var style = getComputedStyle(element); | |
| 131 return element.offsetHeight + parseFloat(style.marginTop) + | |
| 132 parseFloat(style.marginBottom); | |
| 133 } | |
| 134 | |
| 135 Polymer.dom.flush(); | |
|
Dan Beam
2016/06/30 06:45:54
why is this required?
dschuyler
2016/07/01 19:21:21
I moved it up to where this is called from
and com
Dan Beam
2016/07/02 00:17:31
can't we just use async() to act after this instea
dschuyler
2016/07/02 00:23:55
Done.
| |
| 136 if (!this.currentRoute || this.currentRoute.subpage.length != 0 || | |
| 137 this.showAboutPage_) { | |
|
Dan Beam
2016/06/30 06:45:54
can this be done earlier?
dschuyler
2016/07/01 19:21:22
Done.
| |
| 138 return 0; | |
| 139 } | |
| 140 | |
| 141 if (this.showAdvancedPage_) { | |
| 142 return calcHeight(this.$$('settings-advanced-page').$$( | |
| 143 '[section=reset]')); | |
|
Dan Beam
2016/06/30 06:45:54
why the reset section?
dschuyler
2016/07/01 19:21:22
Changed to fetching last settings-section.
| |
| 144 } | |
| 145 | |
| 146 var toggleContainer = this.$$('#toggleContainer'); | |
| 147 if (toggleContainer) | |
| 148 return calcHeight(toggleContainer); | |
| 149 | |
| 150 return 0; | |
| 105 }, | 151 }, |
| 106 | 152 |
| 107 /** @private */ | 153 /** @private */ |
| 108 toggleAdvancedPage_: function() { | 154 toggleAdvancedPage_: function() { |
| 109 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); | 155 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); |
| 110 }, | 156 }, |
| 111 }); | 157 }); |
| OLD | NEW |