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

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: Created 4 years, 6 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
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = {
Dan Beam 2016/06/23 02:48:21 why is this necessary?
dschuyler 2016/06/23 18:33:10 The route was not being correctly set. This could
67 page: this.isAdvancedMenuOpen_ ? 'advanced' : 'basic',
68 section: '',
69 subpage: [],
70 url: '',
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
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.$.endOfPageSpace.style.paddingBottom =
113 (this.parentNode.scrollHeight - this.lastSettingsElementHeight_()) +
114 'px';
115 },
116
117 /**
118 * Height of the element including margin sizes.
119 * @param {Element} element
120 * @return {number}
121 * @private
122 */
123 calcHeight_: function(element) {
124 var style = getComputedStyle(element);
125 return element.offsetHeight + parseFloat(style.marginTop) +
126 parseFloat(style.marginBottom);
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() {
Dan Beam 2016/06/23 02:48:21 can calcHeight_ just live inside here instead as a
dschuyler 2016/06/23 18:33:10 Done.
137 Polymer.dom.flush();
138 if (!this.currentRoute || this.currentRoute.subpage.length != 0 ||
139 this.showAboutPage_)
Dan Beam 2016/06/23 02:48:21 all these conditionals are more than 1 line in the
dschuyler 2016/06/23 18:33:10 Done.
140 return 0;
141 if (this.showAdvancedPage_)
142 return this.calcHeight_(this.$$('settings-advanced-page').$$(
143 '[section=reset]'));
144 if (this.$$('#toggleContainer'))
Dan Beam 2016/06/23 02:48:21 don't query this twice, i.e. var toggleContainer
dschuyler 2016/06/23 18:33:10 Done.
145 return this.calcHeight_(this.$$('#toggleContainer'));
146 return 0;
105 }, 147 },
106 148
107 /** @private */ 149 /** @private */
108 toggleAdvancedPage_: function() { 150 toggleAdvancedPage_: function() {
109 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); 151 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_);
110 }, 152 },
111 }); 153 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698