| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 showNoResultsFound_: { | 53 showNoResultsFound_: { |
| 54 type: Boolean, | 54 type: Boolean, |
| 55 value: false, | 55 value: false, |
| 56 }, | 56 }, |
| 57 | 57 |
| 58 toolbarSpinnerActive: { | 58 toolbarSpinnerActive: { |
| 59 type: Boolean, | 59 type: Boolean, |
| 60 value: false, | 60 value: false, |
| 61 notify: true, | 61 notify: true, |
| 62 }, | 62 }, |
| 63 |
| 64 /** |
| 65 * Dictionary defining page visibility. |
| 66 * @type {!GuestModePageVisibility} |
| 67 */ |
| 68 pageVisibility: { |
| 69 type: Object, |
| 70 value: function() { return {}; }, |
| 71 }, |
| 63 }, | 72 }, |
| 64 | 73 |
| 65 /** @override */ | 74 /** @override */ |
| 66 created: function() { | 75 created: function() { |
| 67 /** @private {!PromiseResolver} */ | 76 /** @private {!PromiseResolver} */ |
| 68 this.resolver_ = new PromiseResolver; | 77 this.resolver_ = new PromiseResolver; |
| 69 settings.main.rendered = this.resolver_.promise; | 78 settings.main.rendered = this.resolver_.promise; |
| 70 }, | 79 }, |
| 71 | 80 |
| 72 /** @override */ | 81 /** @override */ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 96 * @private | 105 * @private |
| 97 */ | 106 */ |
| 98 arrowState_: function(opened) { | 107 arrowState_: function(opened) { |
| 99 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; | 108 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; |
| 100 }, | 109 }, |
| 101 | 110 |
| 102 /** | 111 /** |
| 103 * @param {boolean} showBasicPage | 112 * @param {boolean} showBasicPage |
| 104 * @param {boolean} inSubpage | 113 * @param {boolean} inSubpage |
| 105 * @return {boolean} | 114 * @return {boolean} |
| 115 * @private |
| 106 */ | 116 */ |
| 107 showAdvancedToggle_: function(showBasicPage, inSubpage) { | 117 showAdvancedToggle_: function(showBasicPage, inSubpage) { |
| 108 return showBasicPage && !inSubpage; | 118 return showBasicPage && !inSubpage; |
| 109 }, | 119 }, |
| 110 | 120 |
| 111 /** | 121 /** |
| 112 * @param {!SettingsRoute} newRoute | 122 * @param {!SettingsRoute} newRoute |
| 113 * @private | 123 * @private |
| 114 */ | 124 */ |
| 115 currentRouteChanged_: function(newRoute) { | 125 currentRouteChanged_: function(newRoute) { |
| 116 this.inSubpage_ = newRoute.subpage.length > 0; | 126 this.inSubpage_ = newRoute.subpage.length > 0; |
| 117 this.style.height = this.inSubpage_ ? '100%' : ''; | 127 this.style.height = this.inSubpage_ ? '100%' : ''; |
| 118 | 128 |
| 119 if (newRoute.page == 'about') { | 129 if (newRoute.page == 'about') { |
| 120 this.showPages_ = {about: true, basic: false, advanced: false}; | 130 this.showPages_ = {about: true, basic: false, advanced: false}; |
| 121 } else { | 131 } else { |
| 122 this.showPages_ = { | 132 this.showPages_ = { |
| 123 about: false, | 133 about: false, |
| 124 basic: newRoute.page == 'basic' || !this.inSubpage_, | 134 basic: newRoute.page == 'basic' || !this.inSubpage_, |
| 125 advanced: newRoute.page == 'advanced' || | 135 advanced: newRoute.page == 'advanced' || |
| 126 (!this.inSubpage_ && this.advancedToggleExpanded_), | 136 (!this.inSubpage_ && this.advancedToggleExpanded_), |
| 127 }; | 137 }; |
| 128 | 138 |
| 129 if (this.showPages_.advanced) | 139 if (this.showPages_.advanced) { |
| 140 assert(!this.pageVisibility || |
| 141 this.pageVisibility.advancedSettings !== false); |
| 130 this.advancedToggleExpanded_ = true; | 142 this.advancedToggleExpanded_ = true; |
| 143 } |
| 131 } | 144 } |
| 132 | 145 |
| 133 // Wait for any other changes prior to calculating the overflow padding. | 146 // Wait for any other changes prior to calculating the overflow padding. |
| 134 this.async(function() { | 147 this.async(function() { |
| 135 this.$.overscroll.style.paddingBottom = this.overscrollHeight_() + 'px'; | 148 this.$.overscroll.style.paddingBottom = this.overscrollHeight_() + 'px'; |
| 136 }); | 149 }); |
| 137 }, | 150 }, |
| 138 | 151 |
| 139 /** | 152 /** |
| 140 * Return the height that the over scroll padding should be set to. | 153 * Return the height that the over scroll padding should be set to. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 return 0; | 186 return 0; |
| 174 return calcHeight(lastSection); | 187 return calcHeight(lastSection); |
| 175 } | 188 } |
| 176 | 189 |
| 177 assert(this.showPages_.basic); | 190 assert(this.showPages_.basic); |
| 178 var lastSection = this.$$('settings-basic-page').$$( | 191 var lastSection = this.$$('settings-basic-page').$$( |
| 179 'settings-section:last-of-type'); | 192 'settings-section:last-of-type'); |
| 180 // |lastSection| may be null in unit tests. | 193 // |lastSection| may be null in unit tests. |
| 181 if (!lastSection) | 194 if (!lastSection) |
| 182 return 0; | 195 return 0; |
| 183 return calcHeight(lastSection) - this.$$('#toggleContainer').offsetHeight; | 196 var toggleContainer = this.$$('#toggleContainer'); |
| 197 return calcHeight(lastSection) - |
| 198 (toggleContainer ? toggleContainer.offsetHeight : 0); |
| 184 }, | 199 }, |
| 185 | 200 |
| 186 /** @private */ | 201 /** @private */ |
| 187 toggleAdvancedPage_: function() { | 202 toggleAdvancedPage_: function() { |
| 188 this.fire('toggle-advanced-page', !this.advancedToggleExpanded_); | 203 this.fire('toggle-advanced-page', !this.advancedToggleExpanded_); |
| 189 }, | 204 }, |
| 190 | 205 |
| 191 /** | 206 /** |
| 192 * Navigates to the default search page (if necessary). | 207 * Navigates to the default search page (if necessary). |
| 193 * @private | 208 * @private |
| (...skipping 30 matching lines...) Expand all Loading... |
| 224 // completed. | 239 // completed. |
| 225 return; | 240 return; |
| 226 } | 241 } |
| 227 | 242 |
| 228 this.toolbarSpinnerActive = false; | 243 this.toolbarSpinnerActive = false; |
| 229 this.showNoResultsFound_ = | 244 this.showNoResultsFound_ = |
| 230 !request.isSame('') && !request.didFindMatches(); | 245 !request.isSame('') && !request.didFindMatches(); |
| 231 }.bind(this)); | 246 }.bind(this)); |
| 232 }.bind(this), 0); | 247 }.bind(this), 0); |
| 233 }, | 248 }, |
| 249 |
| 250 /** |
| 251 * @param {(boolean|undefined)} visibility |
| 252 * @return {boolean} True unless visibility is false. |
| 253 * @private |
| 254 */ |
| 255 showAdvancedSettings_: function(visibility) { |
| 256 return visibility !== false; |
| 257 }, |
| 234 }); | 258 }); |
| OLD | NEW |