Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @fileoverview | |
| 7 * Behavior common to all Settings pages | |
|
michaelpg
2015/12/02 19:22:52
nit: period. and more accurate comment
stevenjb
2015/12/02 21:57:10
Done.
| |
| 8 * | |
| 9 * Example: | |
| 10 * behaviors: [SettingsPageVisibility], | |
| 11 * | |
| 12 * @group Chrome UI Behavior | |
|
michaelpg
2015/12/02 19:22:52
do we ever plan to use @group for anything?
stevenjb
2015/12/02 21:57:10
Dunno, but we have it everywhere.
| |
| 13 */ | |
| 14 | |
| 15 /** | |
| 16 * Set this to override page visibility, e.g. in tests. | |
| 17 * @type !Object|undefined | |
| 18 */ | |
| 19 var SettingPageDefaultVisibility; | |
| 20 | |
| 21 /** @polymerBehavior */ | |
| 22 var SettingsPageVisibility = { | |
| 23 properties: { | |
| 24 /** Dictionary of pages to hide. Includes 'basic' and 'advanced'. */ | |
|
michaelpg
2015/12/02 19:22:52
Can you provide a more specific /** @type */?
Isn
stevenjb
2015/12/02 21:57:10
Opps. It did originally but then I decided that wa
| |
| 25 pageVisible: { | |
| 26 type: Object, | |
| 27 value: SettingPageDefaultVisibility, | |
| 28 notify: true, | |
| 29 }, | |
| 30 }, | |
| 31 | |
| 32 /** | |
| 33 * Sets the visibility for each page in |pages| to true, causing it to load. | |
| 34 * @param {!Array<string>} pages | |
| 35 */ | |
| 36 setVisiblePages: function(pages) { | |
| 37 var visible = this.pageVisible || {}; | |
|
michaelpg
2015/12/02 19:22:52
since setVisiblePages([]) is a no-op (it doesn't h
stevenjb
2015/12/02 21:57:10
That kinda sorta almost makes sense to me :) Done.
| |
| 38 for (var p of pages) { | |
| 39 visible[p] = true; | |
| 40 } | |
| 41 this.set('pageVisible', visible); | |
|
michaelpg
2015/12/02 19:22:52
this.pageVisible = visible
stevenjb
2015/12/02 21:57:10
Done.
| |
| 42 }, | |
| 43 | |
| 44 /** | |
| 45 * Sets the visibility for all settings-section entries unless | |
| 46 * pageVisible has already been explicitly defined. | |
| 47 */ | |
| 48 showDefaultSections: function() { | |
| 49 if (this.pageVisible != undefined) | |
| 50 return; | |
| 51 var pages = []; | |
| 52 var sections = this.shadowRoot.querySelectorAll('settings-section'); | |
| 53 var len = sections.length; | |
| 54 for (var i = 0; i < len; ++i) { | |
| 55 pages.push(sections[i].section); | |
| 56 } | |
| 57 this.setVisiblePages(pages); | |
| 58 }, | |
| 59 }; | |
| OLD | NEW |