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-menu' shows a menu with a hardcoded set of pages and subpages. | 7 * 'settings-menu' shows a menu with a hardcoded set of pages and subpages. |
8 */ | 8 */ |
9 Polymer({ | 9 Polymer({ |
10 is: 'settings-menu', | 10 is: 'settings-menu', |
11 | 11 |
12 properties: { | 12 properties: { |
13 /** @private */ | 13 /** @private */ |
14 advancedOpened_: Boolean, | 14 advancedOpened_: Boolean, |
15 | 15 |
16 /** | 16 /** |
17 * The current active route. | 17 * The current active route. |
18 * @type {!SettingsRoute} | 18 * @type {!SettingsRoute} |
19 */ | 19 */ |
20 currentRoute: { | 20 currentRoute: { |
21 type: Object, | 21 type: Object, |
22 notify: true, | 22 notify: true, |
23 observer: 'currentRouteChanged_', | 23 observer: 'currentRouteChanged_', |
24 }, | 24 }, |
25 | |
26 /** | |
27 * Dictionary defining page visibility. | |
28 * @type {Object} | |
michaelpg
2016/07/21 04:23:03
type unnecessary -- closure's Polymer pass figures
Moe
2016/07/21 18:27:32
Done. Thanks for the explanation!
| |
29 */ | |
30 pageVisibility: { | |
31 type: Object, | |
32 value: function() { return {}; }, | |
michaelpg
2016/07/21 04:23:03
This shouldn't need a default value here-- set it
Moe
2016/07/21 18:27:32
Done.
| |
33 }, | |
25 }, | 34 }, |
26 | 35 |
27 attached: function() { | 36 attached: function() { |
28 document.addEventListener('toggle-advanced-page', function(e) { | 37 document.addEventListener('toggle-advanced-page', function(e) { |
29 if (e.detail) | 38 if (e.detail) |
30 this.$.advancedPage.open(); | 39 this.$.advancedPage.open(); |
31 else | 40 else |
32 this.$.advancedPage.close(); | 41 this.$.advancedPage.close(); |
33 }.bind(this)); | 42 }.bind(this)); |
34 | 43 |
35 this.$.advancedPage.addEventListener('paper-submenu-open', function() { | 44 this.$.advancedPage.addEventListener('paper-submenu-open', function() { |
36 this.fire('toggle-advanced-page', true); | 45 this.fire('toggle-advanced-page', true); |
37 }.bind(this)); | 46 }.bind(this)); |
38 | 47 |
39 this.$.advancedPage.addEventListener('paper-submenu-close', function() { | 48 this.$.advancedPage.addEventListener('paper-submenu-close', function() { |
40 this.fire('toggle-advanced-page', false); | 49 this.fire('toggle-advanced-page', false); |
41 }.bind(this)); | 50 }.bind(this)); |
42 | 51 |
43 this.fire('toggle-advanced-page', this.currentRoute.page == 'advanced'); | 52 this.fire('toggle-advanced-page', this.currentRoute.page == 'advanced'); |
44 }, | 53 }, |
45 | 54 |
46 /** | 55 /** |
47 * @param {!SettingsRoute} newRoute | 56 * @param {!SettingsRoute} newRoute |
48 * @private | 57 * @private |
49 */ | 58 */ |
50 currentRouteChanged_: function(newRoute) { | 59 currentRouteChanged_: function(newRoute) { |
51 // Sync URL changes to the side nav menu. | 60 // Sync URL changes to the side nav menu. |
52 | 61 |
53 if (newRoute.page == 'advanced') { | 62 if (newRoute.page == 'advanced') { |
63 assert(! /** @type {{hideAdvancedSettings: boolean}} */ | |
64 (this.pageVisibility.hideAdvancedSettings)); | |
54 this.$.advancedMenu.selected = this.currentRoute.section; | 65 this.$.advancedMenu.selected = this.currentRoute.section; |
55 this.$.basicMenu.selected = null; | 66 this.$.basicMenu.selected = null; |
56 } else if (newRoute.page == 'basic') { | 67 } else if (newRoute.page == 'basic') { |
57 this.$.advancedMenu.selected = null; | 68 this.$.advancedMenu.selected = null; |
58 this.$.basicMenu.selected = this.currentRoute.section; | 69 this.$.basicMenu.selected = this.currentRoute.section; |
59 } else { | 70 } else { |
60 this.$.advancedMenu.selected = null; | 71 this.$.advancedMenu.selected = null; |
61 this.$.basicMenu.selected = null; | 72 this.$.basicMenu.selected = null; |
62 } | 73 } |
63 }, | 74 }, |
(...skipping 30 matching lines...) Expand all Loading... | |
94 | 105 |
95 /** | 106 /** |
96 * @param {boolean} opened Whether the menu is expanded. | 107 * @param {boolean} opened Whether the menu is expanded. |
97 * @return {string} Which icon to use. | 108 * @return {string} Which icon to use. |
98 * @private | 109 * @private |
99 * */ | 110 * */ |
100 arrowState_: function(opened) { | 111 arrowState_: function(opened) { |
101 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; | 112 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; |
102 }, | 113 }, |
103 }); | 114 }); |
OLD | NEW |