Index: static/js/main.js |
=================================================================== |
--- a/static/js/main.js |
+++ b/static/js/main.js |
@@ -65,29 +65,28 @@ |
}; |
} |
- function getSelectedItem(menu) |
+ function navigationClick(e) |
Thomas Greiner
2015/07/29 11:06:59
Rename variable to "event" to (1) make it consiste
saroyanm
2015/07/29 13:55:50
Done.
|
{ |
- var items = menu.getElementsByTagName("li"); |
- for (var i = 0; i < items.length; i++) |
+ var element = e.target; |
+ while (true) |
{ |
- var item = items[i]; |
- if (hasClass(item, "selected")) |
- return item; |
+ if (!element) |
+ return; |
+ |
+ if (hasClass(element, "selected") || element.id == "hamburger") |
+ { |
+ if ("querySelector" in document) |
+ toggleClass(document.querySelector("header nav>ul"), "visible"); |
Thomas Greiner
2015/07/29 11:06:59
Don't forget to call `event.preventDefault()` and
Thomas Greiner
2015/07/29 11:06:59
Detail: Missing whitespaces in selector string.
saroyanm
2015/07/29 13:55:50
Done.
saroyanm
2015/07/29 13:55:50
Done.
|
+ return; |
+ } |
+ 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("nav").onclick = navigationClick; |
Thomas Greiner
2015/07/29 11:06:59
No need to use `document.querySelector`. `document
saroyanm
2015/07/29 13:55:50
Just noticed that there are two nav elements on th
|
} |
function initFooterSection(section) |