Chromium Code Reviews| Index: chrome/browser/resources/uber/uber_frame.js |
| diff --git a/chrome/browser/resources/uber/uber_frame.js b/chrome/browser/resources/uber/uber_frame.js |
| index 8c5bb3bfe5c6be5c5c40373a6532f72a720c66d0..f1dc93482011642f749f65b7820958b88d07d346 100644 |
| --- a/chrome/browser/resources/uber/uber_frame.js |
| +++ b/chrome/browser/resources/uber/uber_frame.js |
| @@ -77,14 +77,22 @@ cr.define('uber_frame', function() { |
| var navItem = |
| document.querySelector('li[controls="' + params.pageId + '"]'); |
| setSelection(navItem); |
| + showNavItems(); |
| + } |
| + |
| + /** |
| + * @return {Object} The currently selected nav item, if any. |
|
Dan Beam
2014/06/09 21:22:24
{Element}
michaelpg
2014/06/09 22:47:21
Done.
|
| + */ |
| + function getSelectedNavItem() { |
| + return document.querySelector('li.selected'); |
| } |
| /** |
| * Sets selection on the given nav item. |
| - * @param {boolean} newSelection The item to be selected. |
| + * @param {Object} newSelection The item to be selected. |
| */ |
| function setSelection(newSelection) { |
| - var lastSelectedNavItem = document.querySelector('li.selected'); |
| + var lastSelectedNavItem = getSelectedNavItem(); |
| if (lastSelectedNavItem !== newSelection) { |
| newSelection.classList.add('selected'); |
| if (lastSelectedNavItem) |
| @@ -93,6 +101,19 @@ cr.define('uber_frame', function() { |
| } |
| /** |
| + * Shows nav items belonging to the same group as the selected item. |
| + */ |
| + function showNavItems() { |
| + var navItems = document.querySelectorAll('li'); |
| + var selectedNavItem = getSelectedNavItem(); |
| + assert(selectedNavItem); |
| + |
| + var selectedGroup = selectedNavItem.getAttribute('group'); |
| + for (var i = 0; i < navItems.length; ++i) |
|
Dan Beam
2014/06/09 21:22:24
nit: curlies
michaelpg
2014/06/09 22:47:21
Done.
|
| + navItems[i].hidden = navItems[i].getAttribute('group') != selectedGroup; |
| + } |
| + |
| + /** |
| * Adjusts this frame's content to scrolls from the outer frame. This is done |
| * to obscure text in RTL as a user scrolls over the content of this frame (as |
| * currently RTL scrollbars still draw on the right). |