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 behaviors: [settings.RouteObserverBehavior], | 12 behaviors: [settings.RouteObserverBehavior], |
13 | 13 |
14 properties: { | 14 properties: { |
15 advancedOpened: { | 15 advancedOpened: { |
16 type: Boolean, | 16 type: Boolean, |
17 notify: true, | 17 notify: true, |
18 }, | 18 }, |
19 | 19 |
20 /** | 20 /** |
21 * Dictionary defining page visibility. Controlled by settings-ui. | 21 * Dictionary defining page visibility. |
22 * @type {!PageVisibility|undefined} | 22 * @type {!GuestModePageVisibility} |
23 */ | 23 */ |
24 pageVisibility: Object, | 24 pageVisibility: { |
| 25 type: Object, |
| 26 }, |
25 }, | 27 }, |
26 | 28 |
27 listeners: { | 29 listeners: { |
28 'topMenu.tap': 'onLinkTap_', | 30 'topMenu.tap': 'onLinkTap_', |
29 'subMenu.tap': 'onLinkTap_', | 31 'subMenu.tap': 'onLinkTap_', |
30 }, | 32 }, |
31 | 33 |
32 /** @param {!settings.Route} newRoute */ | 34 /** @param {!settings.Route} newRoute */ |
33 currentRouteChanged: function(newRoute) { | 35 currentRouteChanged: function(newRoute) { |
34 var currentPath = newRoute.path; | 36 var currentPath = newRoute.path; |
35 | 37 |
36 // Focus the initially selected path. | 38 // Focus the initially selected path. |
37 var anchors = this.root.querySelectorAll('a'); | 39 var anchors = this.root.querySelectorAll('a'); |
38 for (var i = 0; i < anchors.length; ++i) { | 40 for (var i = 0; i < anchors.length; ++i) { |
39 if (anchors[i].getAttribute('href') == currentPath) { | 41 if (anchors[i].getAttribute('href') == currentPath) { |
40 this.setSelectedUrl_(anchors[i].href); | 42 this.setSelectedUrl_(anchors[i].href); |
41 return; | 43 return; |
42 } | 44 } |
43 } | 45 } |
44 | 46 |
45 this.setSelectedUrl_(''); // Nothing is selected. | 47 this.setSelectedUrl_(''); // Nothing is selected. |
46 }, | 48 }, |
47 | 49 |
48 /** | 50 /** |
49 * @param {boolean|undefined} visibility | |
50 * @return {boolean} | |
51 * @private | |
52 */ | |
53 showPage_: function(visibility) { | |
54 return visibility !== false; | |
55 }, | |
56 | |
57 /** | |
58 * Prevent clicks on sidebar items from navigating. These are only links for | 51 * Prevent clicks on sidebar items from navigating. These are only links for |
59 * accessibility purposes, taps are handled separately by <iron-selector>. | 52 * accessibility purposes, taps are handled separately by <iron-selector>. |
60 * @param {!Event} event | 53 * @param {!Event} event |
61 * @private | 54 * @private |
62 */ | 55 */ |
63 onLinkTap_: function(event) { | 56 onLinkTap_: function(event) { |
64 if (event.target.hasAttribute('href')) | 57 if (event.target.hasAttribute('href')) |
65 event.preventDefault(); | 58 event.preventDefault(); |
66 }, | 59 }, |
67 | 60 |
(...skipping 22 matching lines...) Expand all Loading... |
90 | 83 |
91 /** | 84 /** |
92 * @param {boolean} opened Whether the menu is expanded. | 85 * @param {boolean} opened Whether the menu is expanded. |
93 * @return {string} Which icon to use. | 86 * @return {string} Which icon to use. |
94 * @private | 87 * @private |
95 * */ | 88 * */ |
96 arrowState_: function(opened) { | 89 arrowState_: function(opened) { |
97 return opened ? 'cr:arrow-drop-up' : 'cr:arrow-drop-down'; | 90 return opened ? 'cr:arrow-drop-up' : 'cr:arrow-drop-down'; |
98 }, | 91 }, |
99 }); | 92 }); |
OLD | NEW |