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

Side by Side Diff: anwiki/_override-static/global/global/js/main.js

Issue 9044122: Fixed regression: menu selection doesn't work on mobile (Closed)
Patch Set: Created Dec. 21, 2012, 11:16 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 "use strict"; 1 "use strict";
2 2
3 (function() 3 (function()
4 { 4 {
5 function escapeRegExp(string) 5 function escapeRegExp(string)
6 { 6 {
7 return string.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); 7 return string.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
8 } 8 }
9 9
10 function hasClass(element, className) 10 function hasClass(element, className)
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 for (var i = 0; i < items.length; i++) 70 for (var i = 0; i < items.length; i++)
71 { 71 {
72 var item = items[i]; 72 var item = items[i];
73 if (hasClass(item, "selected")) 73 if (hasClass(item, "selected"))
74 return item; 74 return item;
75 } 75 }
76 } 76 }
77 77
78 function initMenu() 78 function initMenu()
79 { 79 {
80 var menu = document.getElementById("menu"); 80 if ("querySelector" in document)
Felix Dahlke 2012/12/21 12:57:12 Why not just: if (document.querySelector)
81 var selectedItem = getSelectedItem(menu);
82 selectedItem.onclick = function()
83 { 81 {
84 toggleClass(menu, "visible"); 82 var menu = document.querySelector("header nav>ul");
85 }; 83 var selectedItem = getSelectedItem(menu);
84 selectedItem.onclick = function()
85 {
86 toggleClass(menu, "visible");
87 };
88 }
86 } 89 }
87 90
88 function initFooterSection(section) 91 function initFooterSection(section)
89 { 92 {
90 var header = section.getElementsByTagName("h1")[0]; 93 var header = section.getElementsByTagName("h1")[0];
91 header.onclick = function() 94 header.onclick = function()
92 { 95 {
93 toggleClass(section, "visible"); 96 toggleClass(section, "visible");
94 }; 97 };
95 } 98 }
96 99
97 function initFooter() 100 function initFooter()
98 { 101 {
99 var footerContent = document.getElementById("footer-content"); 102 var footerContent = document.getElementById("footer-content");
100 var footerNav = footerContent.getElementsByTagName("nav")[0]; 103 var footerNav = footerContent.getElementsByTagName("nav")[0];
101 var footerNavSections = footerNav.getElementsByTagName("section"); 104 var footerNavSections = footerNav.getElementsByTagName("section");
102 105
103 for (var i = 0; i < footerNavSections.length; i++) 106 for (var i = 0; i < footerNavSections.length; i++)
104 { 107 {
105 var section = footerNavSections[i]; 108 var section = footerNavSections[i];
106 initFooterSection(section); 109 initFooterSection(section);
107 } 110 }
108 } 111 }
109 112
110 initLanguageSelection(); 113 initLanguageSelection();
111 initMenu(); 114 initMenu();
112 initFooter(); 115 initFooter();
113 })(); 116 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld