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

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

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

Powered by Google App Engine
This is Rietveld 408576698