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

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

Issue 2156413002: Settings Router Refactor: Migrate to settings.Route.navigateTo calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update for route rename Created 4 years, 5 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 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 {!settings.Route}
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 }, 25 },
26 26
27 attached: function() { 27 attached: function() {
28 document.addEventListener('toggle-advanced-page', function(e) { 28 document.addEventListener('toggle-advanced-page', function(e) {
29 if (e.detail) 29 if (e.detail)
30 this.$.advancedPage.open(); 30 this.$.advancedPage.open();
31 else 31 else
32 this.$.advancedPage.close(); 32 this.$.advancedPage.close();
33 }.bind(this)); 33 }.bind(this));
34 34
35 this.$.advancedPage.addEventListener('paper-submenu-open', function() { 35 this.$.advancedPage.addEventListener('paper-submenu-open', function() {
36 this.fire('toggle-advanced-page', true); 36 this.fire('toggle-advanced-page', true);
37 }.bind(this)); 37 }.bind(this));
38 38
39 this.$.advancedPage.addEventListener('paper-submenu-close', function() { 39 this.$.advancedPage.addEventListener('paper-submenu-close', function() {
40 this.fire('toggle-advanced-page', false); 40 this.fire('toggle-advanced-page', false);
41 }.bind(this)); 41 }.bind(this));
42 42
43 this.fire('toggle-advanced-page', this.currentRoute.page == 'advanced'); 43 this.fire('toggle-advanced-page', this.currentRoute.page == 'advanced');
44 }, 44 },
45 45
46 /** 46 /**
47 * @param {!SettingsRoute} newRoute 47 * @param {!settings.Route} newRoute
48 * @private 48 * @private
49 */ 49 */
50 currentRouteChanged_: function(newRoute) { 50 currentRouteChanged_: function(newRoute) {
51 // Sync URL changes to the side nav menu. 51 // Sync URL changes to the side nav menu.
52 52
53 if (newRoute.page == 'advanced') { 53 if (newRoute.page == 'advanced') {
54 this.$.advancedMenu.selected = this.currentRoute.section; 54 this.$.advancedMenu.selected = this.currentRoute.section;
55 this.$.basicMenu.selected = null; 55 this.$.basicMenu.selected = null;
56 } else if (newRoute.page == 'basic') { 56 } else if (newRoute.page == 'basic') {
57 this.$.advancedMenu.selected = null; 57 this.$.advancedMenu.selected = null;
(...skipping 17 matching lines...) Expand all
75 ripple.downAction(); 75 ripple.downAction();
76 ripple.upAction(); 76 ripple.upAction();
77 }, 77 },
78 78
79 /** 79 /**
80 * @param {!Event} event 80 * @param {!Event} event
81 * @private 81 * @private
82 */ 82 */
83 openPage_: function(event) { 83 openPage_: function(event) {
84 this.ripple_(/** @type {!Node} */(event.currentTarget)); 84 this.ripple_(/** @type {!Node} */(event.currentTarget));
85 var submenuRoute = event.currentTarget.parentNode.dataset.page; 85 var page = event.currentTarget.parentNode.dataset.page;
86 if (submenuRoute) { 86 switch (page) {
87 this.currentRoute = { 87 case 'basic':
88 page: submenuRoute, 88 settings.navigateTo(settings.Route.BASIC);
dschuyler 2016/07/21 21:58:53 This looks like it's missing the dataset.section.
tommycli 2016/07/22 19:06:08 Done. The bound-route-objects approach we discusse
89 section: event.currentTarget.dataset.section, 89 break;
90 subpage: [], 90 case 'advanced':
91 }; 91 settings.navigateTo(settings.Route.ADVANCED);
92 break;
93 case 'about':
94 settings.navigateTo(settings.Route.ABOUT);
95 break;
96 default:
97 assertNotReached();
92 } 98 }
93 }, 99 },
94 100
95 /** 101 /**
96 * @param {boolean} opened Whether the menu is expanded. 102 * @param {boolean} opened Whether the menu is expanded.
97 * @return {string} Which icon to use. 103 * @return {string} Which icon to use.
98 * @private 104 * @private
99 * */ 105 * */
100 arrowState_: function(opened) { 106 arrowState_: function(opened) {
101 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; 107 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down';
102 }, 108 },
103 }); 109 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698