| OLD | NEW | 
|---|
| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 58     language.onclick = function(event) | 58     language.onclick = function(event) | 
| 59     { | 59     { | 
| 60       if (hasClass(languageSelection, "visible")) | 60       if (hasClass(languageSelection, "visible")) | 
| 61         return; | 61         return; | 
| 62 | 62 | 
| 63       addClass(languageSelection, "visible"); | 63       addClass(languageSelection, "visible"); | 
| 64       stopPropagation(event); | 64       stopPropagation(event); | 
| 65     }; | 65     }; | 
| 66   } | 66   } | 
| 67 | 67 | 
| 68   function getSelectedItem(menu) | 68   function navigationClick(event) | 
| 69   { | 69   { | 
| 70     var items = menu.getElementsByTagName("li"); | 70     var element = event.target; | 
| 71     for (var i = 0; i < items.length; i++) | 71     while (true) | 
| 72     { | 72     { | 
| 73       var item = items[i]; | 73       if (!element) | 
| 74       if (hasClass(item, "selected")) | 74         return false; | 
| 75         return item; | 75 | 
|  | 76       if (hasClass(element, "selected") || element.id == "hamburger") | 
|  | 77       { | 
|  | 78         if ("querySelector" in document) | 
|  | 79         { | 
|  | 80           event.preventDefault(); | 
|  | 81           toggleClass(document.querySelector("header nav > ul"), "visible"); | 
|  | 82         } | 
|  | 83         return false; | 
|  | 84       } | 
|  | 85       element = element.parentElement; | 
| 76     } | 86     } | 
| 77   } | 87   } | 
| 78 | 88 | 
| 79   function initMenu() | 89   function initMenu() | 
| 80   { | 90   { | 
| 81     if ("querySelector" in document) | 91     if ("querySelector" in document) | 
| 82     { | 92       document.querySelector("header nav").onclick = navigationClick; | 
| 83       var menu = document.querySelector("header nav>ul"); |  | 
| 84       var selectedItem = getSelectedItem(menu); |  | 
| 85       if (selectedItem) |  | 
| 86         selectedItem.onclick = function() |  | 
| 87         { |  | 
| 88           toggleClass(menu, "visible"); |  | 
| 89         }; |  | 
| 90     } |  | 
| 91   } | 93   } | 
| 92 | 94 | 
| 93   function initFooterSection(section) | 95   function initFooterSection(section) | 
| 94   { | 96   { | 
| 95     var header = section.getElementsByTagName("h1")[0]; | 97     var header = section.getElementsByTagName("h1")[0]; | 
| 96     header.onclick = function() | 98     header.onclick = function() | 
| 97     { | 99     { | 
| 98       toggleClass(section, "visible"); | 100       toggleClass(section, "visible"); | 
| 99     }; | 101     }; | 
| 100   } | 102   } | 
| 101 | 103 | 
| 102   function initFooter() | 104   function initFooter() | 
| 103   { | 105   { | 
| 104     var footerContent = document.getElementById("footer-content"); | 106     var footerContent = document.getElementById("footer-content"); | 
| 105     var footerNav = footerContent.getElementsByTagName("nav")[0]; | 107     var footerNav = footerContent.getElementsByTagName("nav")[0]; | 
| 106     var footerNavSections = footerNav.getElementsByTagName("section"); | 108     var footerNavSections = footerNav.getElementsByTagName("section"); | 
| 107 | 109 | 
| 108     for (var i = 0; i < footerNavSections.length; i++) | 110     for (var i = 0; i < footerNavSections.length; i++) | 
| 109     { | 111     { | 
| 110       var section = footerNavSections[i]; | 112       var section = footerNavSections[i]; | 
| 111       initFooterSection(section); | 113       initFooterSection(section); | 
| 112     } | 114     } | 
| 113   } | 115   } | 
| 114 | 116 | 
| 115   initLanguageSelection(); | 117   initLanguageSelection(); | 
| 116   initMenu(); | 118   initMenu(); | 
| 117   initFooter(); | 119   initFooter(); | 
| 118 })(); | 120 })(); | 
| OLD | NEW | 
|---|