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

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

Issue 1943133002: [MD settings] remove unneeded properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 4 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 * Example: 9 * Example:
10 * 10 *
11 * <settings-menu selected-page-id="{{selectedPageId}}"> 11 * <settings-menu selected-page-id="{{selectedPageId}}">
12 * </settings-menu> 12 * </settings-menu>
13 */ 13 */
14 Polymer({ 14 Polymer({
15 is: 'settings-menu', 15 is: 'settings-menu',
16 16
17 properties: { 17 properties: {
18 /** @private */
19 advancedOpened_: Boolean,
20
21 /** @private */
22 basicOpened_: Boolean,
23
24 /** 18 /**
25 * The current active route. 19 * The current active route.
26 */ 20 */
27 currentRoute: { 21 currentRoute: {
28 type: Object, 22 type: Object,
29 notify: true, 23 notify: true,
30 observer: 'currentRouteChanged_', 24 observer: 'currentRouteChanged_',
31 }, 25 },
32 }, 26 },
33 27
34 /** @private */ 28 /** @private */
35 currentRouteChanged_: function() { 29 currentRouteChanged_: function() {
36 var submenu = this.shadowRoot.querySelector( 30 // Sync URL changes to the side nav menu.
37 'paper-submenu[data-page="' + this.currentRoute.page + '"]'); 31
38 if (submenu) 32 this.$.advancedPage.opened = this.currentRoute.page == 'advanced';
dpapad 2016/05/03 01:00:02 Did you consider updating those 4 properties via b
dschuyler 2016/05/03 20:48:53 Yeah, it's nicer if these are in bound in the html
39 submenu.opened = true; 33 this.$.basicPage.opened = this.currentRoute.page == 'basic';
34
35 if (this.$.advancedPage.opened)
36 this.$.advancedMenu.selected = this.currentRoute.section;
37
38 if (this.$.basicPage.opened)
39 this.$.basicMenu.selected = this.currentRoute.section;
40 }, 40 },
41 41
42 /** @private */ 42 /** @private */
43 openPage_: function(event) { 43 openPage_: function(event) {
44 var submenuRoute = event.currentTarget.dataset.page; 44 var submenuRoute = event.currentTarget.parentNode.dataset.page;
45 if (submenuRoute) { 45 if (submenuRoute) {
46 this.currentRoute = { 46 this.currentRoute = {
47 page: submenuRoute, 47 page: submenuRoute,
48 section: event.currentTarget.dataset.section, 48 section: event.currentTarget.dataset.section,
49 subpage: [], 49 subpage: [],
50 }; 50 };
51 } 51 }
52 }, 52 },
53 53
54 /** 54 /**
55 * @param {boolean} opened Whether the menu is expanded. 55 * @param {boolean} opened Whether the menu is expanded.
56 * @return {string} Which icon to use. 56 * @return {string} Which icon to use.
57 * @private 57 * @private
58 * */ 58 * */
59 arrowState_: function(opened) { 59 arrowState_: function(opened) {
60 return opened ? 'arrow-drop-up' : 'arrow-drop-down'; 60 return opened ? 'arrow-drop-up' : 'arrow-drop-down';
61 }, 61 },
62 }); 62 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698