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

Side by Side Diff: static/js/main.js

Issue 29551738: Issue 5634 - Replaced logo and refactored navbar width and colors (Closed) Base URL: https://hg.adblockplus.org/web.adblockplus.org
Patch Set: Fixed navbar-logo-2x Created Sept. 28, 2017, 1:03 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
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 29 matching lines...) Expand all
40 { 40 {
41 if (typeof window.event !== "undefined" 41 if (typeof window.event !== "undefined"
42 && typeof window.event.cancelBubble !== "undefined") 42 && typeof window.event.cancelBubble !== "undefined")
43 window.event.cancelBubble = true; 43 window.event.cancelBubble = true;
44 else 44 else
45 event.stopPropagation(); 45 event.stopPropagation();
46 } 46 }
47 47
48 function initLanguageSelection() 48 function initLanguageSelection()
49 { 49 {
50 var language = document.getElementById("language"); 50 var language = document.getElementById("locale");
51 51
52 // skip if page does not have language selection (EG: blog) 52 // skip if page does not have language selection (EG: blog)
53 if (!language) 53 if (!language)
54 return; 54 return;
55 55
56 var languageSelection = language.getElementsByTagName("ul")[0]; 56 var languageSelection = language.getElementsByTagName("ul")[0];
57 57
58 document.documentElement.onclick = function() 58 document.documentElement.onclick = function()
59 { 59 {
60 removeClass(languageSelection, "visible"); 60 removeClass(languageSelection, "visible");
(...skipping 10 matching lines...) Expand all
71 } 71 }
72 72
73 function navigationClick(event) 73 function navigationClick(event)
74 { 74 {
75 var element = event.target; 75 var element = event.target;
76 while (true) 76 while (true)
77 { 77 {
78 if (!element) 78 if (!element)
79 return; 79 return;
80 80
81 if (hasClass(element, "selected") || element.id == "hamburger") 81 if (hasClass(element, "selected") || element.id == "navbar-menu")
82 { 82 {
83 if ("querySelector" in document) 83 if ("querySelector" in document)
ire 2017/09/28 08:38:44 This if statement is no longer needed since you're
juliandoucette 2017/10/04 15:33:28 Acknowledged.
84 { 84 {
85 event.preventDefault(); 85 event.preventDefault();
86 toggleClass(document.querySelector("header nav > ul"), "visible"); 86 toggleClass(document.getElementById("navbar-nav"), "visible");
87 } 87 }
88 return false; 88 return false;
89 } 89 }
90 element = element.parentElement; 90 element = element.parentElement;
91 } 91 }
92 } 92 }
93 93
94 function initMenu() 94 function initMenu()
95 { 95 {
96 if ("querySelector" in document) 96 if ("querySelector" in document)
97 document.querySelector("header nav").onclick = navigationClick; 97 document.getElementById("navbar-menu").onclick = navigationClick;
ire 2017/09/28 08:38:44 This if statement is no longer needed since you're
juliandoucette 2017/10/04 15:33:28 Acknowledged.
98 } 98 }
99 99
100 function initFooterSection(section) 100 function initFooterSection(section)
101 { 101 {
102 var header = section.getElementsByTagName("h1")[0]; 102 var header = section.getElementsByTagName("h1")[0];
103 header.onclick = function() 103 header.onclick = function()
104 { 104 {
105 toggleClass(section, "visible"); 105 toggleClass(section, "visible");
106 }; 106 };
107 } 107 }
108 108
109 function initFooter() 109 function initFooter()
110 { 110 {
111 var footerContent = document.getElementById("footer-content"); 111 var footerContent = document.getElementById("footer-content");
112 var footerNav = footerContent.getElementsByTagName("nav")[0]; 112 var footerNav = footerContent.getElementsByTagName("nav")[0];
113 var footerNavSections = footerNav.getElementsByTagName("section"); 113 var footerNavSections = footerNav.getElementsByTagName("section");
114 114
115 for (var i = 0; i < footerNavSections.length; i++) 115 for (var i = 0; i < footerNavSections.length; i++)
116 { 116 {
117 var section = footerNavSections[i]; 117 var section = footerNavSections[i];
118 initFooterSection(section); 118 initFooterSection(section);
119 } 119 }
120 } 120 }
121 121
122 initLanguageSelection(); 122 initLanguageSelection();
123 initMenu(); 123 initMenu();
124 initFooter(); 124 initFooter();
125 })(); 125 })();
OLDNEW

Powered by Google App Engine
This is Rietveld