refactoring

This commit is contained in:
Devaev Maxim
2018-07-25 15:02:37 +03:00
parent 6c4385b52c
commit f04f5668f1
2 changed files with 9 additions and 5 deletions

View File

@@ -1,5 +1,9 @@
var ui = new function() {
this.init = function() {
Array.prototype.forEach.call(document.getElementsByClassName("ctl-item"), function(el_item) {
el_item.onclick = function() { __toggleMenu(el_item); };
});
window.onclick = __windowClickHandler;
Array.prototype.forEach.call(document.getElementsByClassName("window"), function(el_window) {
@@ -8,7 +12,7 @@ var ui = new function() {
});
};
this.toggleMenu = function(el_a) {
var __toggleMenu = function(el_a) {
Array.prototype.forEach.call(document.getElementsByClassName("ctl-item"), function(el_item) {
var el_menu = el_item.parentElement.querySelector(".ctl-dropdown-content");
if (el_item === el_a && el_menu.style.display === "none") {
@@ -31,7 +35,7 @@ var ui = new function() {
return;
}
}
ui.toggleMenu(null);
__toggleMenu(null);
}
};