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.
7 * 'cr-settings-main' displays the selected settings page.
11 * <cr-settings-main pages="{{pages}}" selectedPageId="{{selectedId}}">
14 * See cr-settings-drawer for example of use in 'core-drawer-panel'.
16 * @group Chrome Settings Elements
17 * @element cr-settings-main
19 Polymer('cr-settings-main', {
25 * @type CrSettingsPrefsElement
31 * Pages that may be shown.
34 * @type Array<!Object>
40 * ID of the currently selected page.
42 * @attribute selectedPageId
56 var observer = new MutationObserver(this.pageContainerUpdated_.bind(this));
57 observer.observe(this.$.pageContainer,
58 /** @type {MutationObserverInit} */ {
61 this.pages = this.$.pageContainer.items;
62 this.ensureSelection_();
66 * If no page is selected, selects the first page. This happens on load and
67 * when a selected page is removed.
71 ensureSelection_: function() {
72 if (!this.pages.length)
74 if (this.selectedPageId == '')
75 this.selectedPageId = this.pages[0].PAGE_ID;
79 * Updates the list of pages using the pages in core-animated-pages.
83 pageContainerUpdated_: function() {
84 this.pages = this.$.pageContainer.items;
85 this.ensureSelection_();