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 23 matching lines...) Expand all Loading... | |
| 34 observer: 'currentRouteChanged_', | 34 observer: 'currentRouteChanged_', |
| 35 }, | 35 }, |
| 36 | 36 |
| 37 /** @private */ | 37 /** @private */ |
| 38 showAdvancedPage_: { | 38 showAdvancedPage_: { |
| 39 type: Boolean, | 39 type: Boolean, |
| 40 value: false, | 40 value: false, |
| 41 }, | 41 }, |
| 42 | 42 |
| 43 /** @private */ | 43 /** @private */ |
| 44 whenAdvancedPageReady_: { | |
| 45 type: Object, | |
| 46 value: new PromiseResolver(), | |
|
michaelpg
2016/06/27 23:00:04
i know this is sort of a singleton, but for the sa
dpapad
2016/06/27 23:37:26
Done.
| |
| 47 }, | |
| 48 | |
| 49 /** @private */ | |
| 44 showAdvancedToggle_: { | 50 showAdvancedToggle_: { |
| 45 type: Boolean, | 51 type: Boolean, |
| 46 value: true, | 52 value: true, |
| 47 }, | 53 }, |
| 48 | 54 |
| 49 /** @private */ | 55 /** @private */ |
| 50 showBasicPage_: { | 56 showBasicPage_: { |
| 51 type: Boolean, | 57 type: Boolean, |
| 52 value: true, | 58 value: true, |
| 53 }, | 59 }, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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%' : ''; |
| 105 }, | 111 }, |
| 106 | 112 |
| 107 /** @private */ | 113 /** @private */ |
| 108 toggleAdvancedPage_: function() { | 114 toggleAdvancedPage_: function() { |
| 109 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); | 115 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); |
| 110 }, | 116 }, |
| 117 | |
| 118 /** @private */ | |
| 119 onAdvancedPageReady_: function() { | |
| 120 this.whenAdvancedPageReady_.resolve(); | |
| 121 }, | |
| 122 | |
| 123 /** | |
| 124 * Navigates to the default search page (if necessary). | |
| 125 * @private | |
| 126 */ | |
| 127 ensureInDefaultSearchPage_: function() { | |
| 128 if (this.currentRoute.page != 'basic' || | |
| 129 this.currentRoute.section != '' || | |
| 130 this.currentRoute.subpage.length != 0) { | |
| 131 this.currentRoute = {page: 'basic', section: '', subpage: [], url: ''}; | |
| 132 } | |
| 133 }, | |
| 134 | |
| 135 /** | |
| 136 * @param {string} query | |
| 137 */ | |
| 138 searchContents: function(query) { | |
| 139 this.ensureInDefaultSearchPage_(); | |
| 140 | |
| 141 // Search basic page immediately. | |
| 142 settings.search(query, assert(this.$$('settings-basic-page'))); | |
| 143 | |
| 144 // Force the advanced page to be rendered and search once ready. | |
| 145 this.showAdvancedPage_ = true; | |
|
michaelpg
2016/06/27 23:00:04
without using a PromiseResolver:
var searchAdvanc
dpapad
2016/06/27 23:37:27
What is the benefit of not using PromiseResolver h
michaelpg
2016/06/29 01:18:57
PromiseResolver is sugar for creating a Promise wh
dpapad
2016/06/29 18:20:12
Yes, added a comment for the current intention. Ke
michaelpg
2016/06/29 19:40:51
Makes sense. Polymer queues effects like dom-if's
| |
| 146 this.whenAdvancedPageReady_.promise.then(function() { | |
| 147 settings.search(query, assert(this.$$('settings-advanced-page'))); | |
| 148 }.bind(this)); | |
| 149 }, | |
| 111 }); | 150 }); |
| OLD | NEW |