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

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

Issue 29355239: Issue 4481 - Scripts should expect the language selector to be missing, e.g. on the blog (Closed) Base URL: https://hg.adblockplus.org/web.adblockplus.org/
Patch Set: Created Sept. 28, 2016, 11:10 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 30 matching lines...) Expand all
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("language");
51 if (!language)
saroyanm 2016/09/28 12:34:27 Detail: I think it make sense to have a small comm
52 return;
53
51 var languageSelection = language.getElementsByTagName("ul")[0]; 54 var languageSelection = language.getElementsByTagName("ul")[0];
52 55
53 document.documentElement.onclick = function() 56 document.documentElement.onclick = function()
54 { 57 {
55 removeClass(languageSelection, "visible"); 58 removeClass(languageSelection, "visible");
56 }; 59 };
57 60
58 language.onclick = function(event) 61 language.onclick = function(event)
59 { 62 {
60 if (hasClass(languageSelection, "visible")) 63 if (hasClass(languageSelection, "visible"))
(...skipping 13 matching lines...) Expand all
74 return; 77 return;
75 78
76 if (hasClass(element, "selected") || element.id == "hamburger") 79 if (hasClass(element, "selected") || element.id == "hamburger")
77 { 80 {
78 if ("querySelector" in document) 81 if ("querySelector" in document)
79 { 82 {
80 event.preventDefault(); 83 event.preventDefault();
81 toggleClass(document.querySelector("header nav > ul"), "visible"); 84 toggleClass(document.querySelector("header nav > ul"), "visible");
82 } 85 }
83 return false; 86 return false;
84 } 87 }
85 element = element.parentElement; 88 element = element.parentElement;
86 } 89 }
87 } 90 }
88 91
89 function initMenu() 92 function initMenu()
90 { 93 {
91 if ("querySelector" in document) 94 if ("querySelector" in document)
92 document.querySelector("header nav").onclick = navigationClick; 95 document.querySelector("header nav").onclick = navigationClick;
93 } 96 }
94 97
(...skipping 16 matching lines...) Expand all
111 { 114 {
112 var section = footerNavSections[i]; 115 var section = footerNavSections[i];
113 initFooterSection(section); 116 initFooterSection(section);
114 } 117 }
115 } 118 }
116 119
117 initLanguageSelection(); 120 initLanguageSelection();
118 initMenu(); 121 initMenu();
119 initFooter(); 122 initFooter();
120 })(); 123 })();
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