Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: static/js/main.js

Issue 29322846: Issue 2826 - Hamburger menu not visible on all pages (Closed)
Patch Set: Created July 29, 2015, 1:13 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « static/css/main-mobile.css ('k') | templates/default.tmpl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: static/js/main.js
===================================================================
--- a/static/js/main.js
+++ b/static/js/main.js
@@ -65,29 +65,31 @@
};
}
- function getSelectedItem(menu)
+ function navigationClick(event)
{
- var items = menu.getElementsByTagName("li");
- for (var i = 0; i < items.length; i++)
+ var element = event.target;
+ while (true)
{
- var item = items[i];
- if (hasClass(item, "selected"))
- return item;
+ if (!element)
+ return false;
+
+ if (hasClass(element, "selected") || element.id == "hamburger")
+ {
+ if ("querySelector" in document)
+ {
+ event.preventDefault();
+ toggleClass(document.querySelector("header nav > ul"), "visible");
+ }
+ return false;
+ }
+ element = element.parentElement;
}
}
function initMenu()
{
if ("querySelector" in document)
- {
- var menu = document.querySelector("header nav>ul");
- var selectedItem = getSelectedItem(menu);
- if (selectedItem)
- selectedItem.onclick = function()
- {
- toggleClass(menu, "visible");
- };
- }
+ document.querySelector("header nav").onclick = navigationClick;
}
function initFooterSection(section)
« no previous file with comments | « static/css/main-mobile.css ('k') | templates/default.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld