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

Side by Side Diff: chrome/browser/resources/settings/settings_main/settings_main.js

Issue 1138013005: Lots of small fixes to help wire things together for the 0.8 upgrade. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove undefined observer Created 5 years, 7 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 * 'cr-settings-main' displays the selected settings page. 7 * 'cr-settings-main' displays the selected settings page.
8 * 8 *
9 * Example: 9 * Example:
10 * 10 *
(...skipping 14 matching lines...) Expand all
25 * 25 *
26 * @type {?CrSettingsPrefsElement} 26 * @type {?CrSettingsPrefsElement}
27 */ 27 */
28 prefs: { 28 prefs: {
29 type: Object, 29 type: Object,
30 notify: true, 30 notify: true,
31 }, 31 },
32 32
33 /** 33 /**
34 * Pages that may be shown. 34 * Pages that may be shown.
35 * @type {?Array<!HTMLElement>} 35 * @type {!Array<!HTMLElement>}
36 */ 36 */
37 pages: Array, 37 pages: {
38 type: Array,
39 value: function() { return []; },
40 notify: true,
41 readOnly: true,
42 },
38 43
39 /** 44 /**
40 * Currently selected page. 45 * Currently selected page.
41 * @type {?HTMLElement} 46 * @type {?HTMLElement}
42 */ 47 */
43 selectedPage: { 48 selectedPage: {
44 type: Object, 49 type: Object,
45 notify: true, 50 notify: true,
46 }, 51 },
47 52
48 /** 53 /**
49 * ID of the currently selected page. 54 * ID of the currently selected page.
50 */ 55 */
51 selectedPageId: { 56 selectedPageId: {
52 type: String, 57 type: String,
53 notify: true, 58 notify: true,
54 observe: 'selectedPageIdChanged_', 59 value: '',
60 observer: 'selectedPageIdChanged_',
55 }, 61 },
56 }, 62 },
57 63
58 /** @override */ 64 /** @override */
59 ready: function() { 65 ready: function() {
60 var observer = new MutationObserver(this.pageContainerUpdated_.bind(this)); 66 var observer = new MutationObserver(this.pageContainerUpdated_.bind(this));
61 observer.observe(this.$.pageContainer, 67 observer.observe(this.$.pageContainer,
62 /** @type {MutationObserverInit} */ { 68 /** @type {MutationObserverInit} */ {
63 childList: true, 69 childList: true,
64 }); 70 });
(...skipping 12 matching lines...) Expand all
77 * We observe $.pageContainer.on-iron-select instead of using data binding 83 * We observe $.pageContainer.on-iron-select instead of using data binding
78 * for two reasons: 84 * for two reasons:
79 * 1) We need to exclude subpages 85 * 1) We need to exclude subpages
80 * 2) There is a bug with data binding or our useage of it here causing 86 * 2) There is a bug with data binding or our useage of it here causing
81 * this.selectedPage to get set to the index of $.pageContainer instead of 87 * this.selectedPage to get set to the index of $.pageContainer instead of
82 * the valueattr identifier (PAGE_ID). TODO(stevenjb/jlklien): Investigate 88 * the valueattr identifier (PAGE_ID). TODO(stevenjb/jlklien): Investigate
83 * fixing this and using filters once we switch to Polymer 0.8. 89 * fixing this and using filters once we switch to Polymer 0.8.
84 * @private 90 * @private
85 */ 91 */
86 onIronSelect_: function(event) { 92 onIronSelect_: function(event) {
87 if (event.target != this.$.pageContainer || !event.detail.isSelected || 93 if (event.target != this.$.pageContainer || event.detail.item.subpage) {
88 event.detail.item.subpage) {
89 return; 94 return;
90 } 95 }
91 this.selectedPageId = event.detail.item.PAGE_ID; 96 this.selectedPageId = event.detail.item.PAGE_ID;
92 }, 97 },
93 98
94 /** 99 /**
95 * If no page is selected, selects the first page. This happens on load and 100 * If no page is selected, selects the first page. This happens on load and
96 * when a selected page is removed. 101 * when a selected page is removed.
97 * @private 102 * @private
98 */ 103 */
99 ensureSelection_: function() { 104 ensureSelection_: function() {
100 if (!this.pages.length) 105 if (!this.pages.length)
101 return; 106 return;
102 if (this.selectedPageId == '') 107 if (this.selectedPageId == '')
103 this.selectedPageId = this.pages[0].PAGE_ID; 108 this.selectedPageId = this.pages[0].PAGE_ID;
104 }, 109 },
105 110
106 /** 111 /**
107 * Updates the list of pages using the pages in iron-pages. 112 * Updates the list of pages using the pages in iron-pages.
108 * @private 113 * @private
109 */ 114 */
110 pageContainerUpdated_: function() { 115 pageContainerUpdated_: function() {
111 this.pages = this.$.pageContainer.items.filter(function(item) { 116 this._setPages(this.$.pageContainer.items.filter(function(item) {
112 return !item.subpage; 117 return !item.subpage;
113 }); 118 }));
114 this.ensureSelection_(); 119 this.ensureSelection_();
115 }, 120 },
116 }); 121 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698