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

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

Issue 2008843003: [MD settings] redesign of side nav (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review changes Created 4 years, 6 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 *
9 * Example:
10 *
11 * <settings-menu selected-page-id="{{selectedPageId}}">
12 * </settings-menu>
13 */ 8 */
14 Polymer({ 9 Polymer({
15 is: 'settings-menu', 10 is: 'settings-menu',
16 11
17 properties: { 12 properties: {
13 /** @private */
14 advancedOpened_: Boolean,
15
18 /** 16 /**
19 * The current active route. 17 * The current active route.
18 * @type {!SettingsRoute}
20 */ 19 */
21 currentRoute: { 20 currentRoute: {
22 type: Object, 21 type: Object,
23 notify: true, 22 notify: true,
24 observer: 'currentRouteChanged_', 23 observer: 'currentRouteChanged_',
25 }, 24 },
26 }, 25 },
27 26
28 /** @private */ 27 attached: function() {
29 currentRouteChanged_: function() { 28 document.addEventListener('toggle-advanced-page', function(e) {
29 if (e.detail)
30 this.$.advancedPage.open();
31 else
32 this.$.advancedPage.close();
33 }.bind(this));
34
35 this.$.advancedPage.addEventListener('paper-submenu-open', function() {
36 this.fire('toggle-advanced-page', true);
37 }.bind(this));
38
39 this.$.advancedPage.addEventListener('paper-submenu-close', function() {
40 this.fire('toggle-advanced-page', false);
41 }.bind(this));
42
43 if (this.currentRoute.page == 'advanced')
44 this.$.advancedPage.open();
Dan Beam 2016/06/03 03:12:24 could this be: this.fire('toggle-advanced-page',
dschuyler 2016/06/06 21:47:55 Yes, but then it would fire an unnecessary event d
Dan Beam 2016/06/06 22:31:03 it seems like this would no-op on the other side a
dschuyler 2016/06/06 23:05:13 Done.
45 },
46
47 /**
48 * @param {!SettingsRoute} newRoute
49 * @private
50 */
51 currentRouteChanged_: function(newRoute) {
30 // Sync URL changes to the side nav menu. 52 // Sync URL changes to the side nav menu.
31 53
32 this.$.advancedPage.opened = this.currentRoute.page == 'advanced'; 54 if (newRoute.page == 'advanced') {
33 this.$.basicPage.opened = this.currentRoute.page == 'basic';
34
35 if (this.$.advancedPage.opened)
36 this.$.advancedMenu.selected = this.currentRoute.section; 55 this.$.advancedMenu.selected = this.currentRoute.section;
37 56 this.$.basicMenu.selected = null;
38 if (this.$.basicPage.opened) 57 } else if (newRoute.page == 'basic') {
58 this.$.advancedMenu.selected = null;
39 this.$.basicMenu.selected = this.currentRoute.section; 59 this.$.basicMenu.selected = this.currentRoute.section;
60 } else {
61 this.$.advancedMenu.selected = null;
62 this.$.basicMenu.selected = null;
63 }
40 }, 64 },
41 65
42 /** @private */ 66 /**
67 * @param {!Event} event
68 * @private
69 */
43 openPage_: function(event) { 70 openPage_: function(event) {
44 var submenuRoute = event.currentTarget.parentNode.dataset.page; 71 var submenuRoute = event.currentTarget.parentNode.dataset.page;
45 if (submenuRoute) { 72 if (submenuRoute) {
46 this.currentRoute = { 73 this.currentRoute = {
47 page: submenuRoute, 74 page: submenuRoute,
48 section: event.currentTarget.dataset.section, 75 section: event.currentTarget.dataset.section,
49 subpage: [], 76 subpage: [],
50 }; 77 };
51 } 78 }
52 }, 79 },
53 80
54 /** 81 /**
55 * @param {boolean} opened Whether the menu is expanded. 82 * @param {boolean} opened Whether the menu is expanded.
56 * @return {string} Which icon to use. 83 * @return {string} Which icon to use.
57 * @private 84 * @private
58 * */ 85 * */
59 arrowState_: function(opened) { 86 arrowState_: function(opened) {
60 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; 87 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down';
61 }, 88 },
62 }); 89 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698