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

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

Issue 2733963002: MD Settings: Debounce navigation event in side nav. (Closed)
Patch Set: fix test Created 3 years, 9 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',
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 * @param {string} url 64 * @param {string} url
65 */ 65 */
66 setSelectedUrl_: function(url) { 66 setSelectedUrl_: function(url) {
67 this.$.topMenu.selected = this.$.subMenu.selected = url; 67 this.$.topMenu.selected = this.$.subMenu.selected = url;
68 }, 68 },
69 69
70 /** 70 /**
71 * @param {!Event} event 71 * @param {!Event} event
72 * @private 72 * @private
73 */ 73 */
74 onSelectorActivate_: function(event) { 74 onSelectorActivate_: function(event) {
dschuyler 2017/03/15 01:13:02 I think we can remove the inner (nested) onSelecto
hcarmona 2017/03/15 19:22:09 This unfortunately doesn't work because the items
hcarmona 2017/03/16 00:58:19 We spoke in person and I had misunderstood what yo
75 this.setSelectedUrl_(event.detail.selected); 75 this.setSelectedUrl_(event.detail.selected);
76 76
77 var path = new URL(event.detail.selected).pathname; 77 this.debounce('side-nav-route-change', function() {
78 var route = settings.getRouteForPath(path); 78 var path = new URL(event.detail.selected).pathname;
79 assert(route, 'settings-menu has an entry with an invalid route.'); 79 var route = settings.getRouteForPath(path);
80 settings.navigateTo( 80 assert(route, 'settings-menu has an entry with an invalid route.');
81 route, /* dynamicParams */ null, /* removeSearch */ true); 81 settings.navigateTo(
82 route, /* dynamicParams */ null, /* removeSearch */ true);
83 });
82 }, 84 },
83 85
84 /** 86 /**
85 * @param {boolean} opened Whether the menu is expanded. 87 * @param {boolean} opened Whether the menu is expanded.
86 * @return {string} Which icon to use. 88 * @return {string} Which icon to use.
87 * @private 89 * @private
88 * */ 90 * */
89 arrowState_: function(opened) { 91 arrowState_: function(opened) {
90 return opened ? 'cr:arrow-drop-up' : 'cr:arrow-drop-down'; 92 return opened ? 'cr:arrow-drop-up' : 'cr:arrow-drop-down';
91 }, 93 },
92 }); 94 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698