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

Delta Between Two Patch Sets: static/js/main.js

Issue 29558641: Issue 5740 - Implemented new abp.org footer styles (Closed) Base URL: https://bitbucket.org/adblockplus/adblockplus.org
Left Patch Set: Searched for and removed orphan styles Created Oct. 5, 2017, 5:09 p.m.
Right Patch Set: Addressed comments Created Oct. 11, 2017, 1:11 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « static/img/footer-youtube-glyphicon.png ('k') | templates/default.tmpl » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 locale = document.getElementById("navbar-locale-selected");
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 (!locale)
54 return; 54 return;
55 55
56 var languageSelection = language.getElementsByTagName("ul")[0]; 56 locale.onclick = function()
57
58 document.documentElement.onclick = function()
59 { 57 {
60 removeClass(languageSelection, "visible"); 58 toggleClass(document.getElementById("navbar-locale-menu"), "visible");
61 };
62
63 language.onclick = function(event)
64 {
65 if (hasClass(languageSelection, "visible"))
66 return;
67
68 addClass(languageSelection, "visible");
69 stopPropagation(event);
70 }; 59 };
71 } 60 }
72 61
73 function navigationClick(event) 62 function navigationClick(event)
74 { 63 {
75 var element = event.target; 64 toggleClass(document.getElementById("navbar-menu"), "visible");
76 while (true)
77 {
78 if (!element)
79 return;
80
81 if (hasClass(element, "selected") || element.id == "hamburger")
82 {
83 if ("querySelector" in document)
84 {
85 event.preventDefault();
86 toggleClass(document.querySelector("header nav > ul"), "visible");
87 }
88 return false;
89 }
90 element = element.parentElement;
91 }
92 } 65 }
93 66
94 function initMenu() 67 function initMenu()
95 { 68 {
96 if ("querySelector" in document) 69 document.getElementById("navbar-menu-toggle").onclick = navigationClick;
97 document.querySelector("header nav").onclick = navigationClick;
98 } 70 }
99 71
100 initLanguageSelection(); 72 initLanguageSelection();
101 initMenu(); 73 initMenu();
102 })(); 74 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld