From 583aa1131e4f07987dbf01c0a9b28753362dd564 Mon Sep 17 00:00:00 2001 From: zombieFox Date: Sun, 3 Feb 2019 14:36:40 +0000 Subject: [PATCH] [refactor] improve header menu control --- js/control.js | 15 --------------- js/menu.js | 24 ++++++++++++++++++++---- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/js/control.js b/js/control.js index a46366ad..e80ed521 100644 --- a/js/control.js +++ b/js/control.js @@ -509,20 +509,6 @@ var control = (function() { return value / 100; } }; - // var toggleValue = function(object) { - // var value = false; - // if (helper.getObject({ - // object: state.get(), - // path: object.path - // })) { - // value = true; - // }; - // helper.setObject({ - // path: object.path, - // object: state.get(), - // newValue: value - // }); - // }; var changeValue = function(object) { if (object.path) { var newValue = valueType[object.type](object); @@ -554,7 +540,6 @@ var control = (function() { if (object.func) { object.func(); }; - // toggleValue(object); } }; object.element.addEventListener(eventType[object.type], function() { diff --git a/js/menu.js b/js/menu.js index 093d7b5f..a075aac5 100644 --- a/js/menu.js +++ b/js/menu.js @@ -35,22 +35,38 @@ var menu = (function() { }; var close = function() { - state.get().menu = false; + helper.setObject({ + object: state.get(), + path: "menu", + newValue: false + }); render(); }; var open = function() { _scrollToTop(helper.e(".menu-content")); - state.get().menu = true; + helper.setObject({ + object: state.get(), + path: "menu", + newValue: true + }); render(); }; var toggle = function() { if (state.get().menu) { - state.get().menu = false; + helper.setObject({ + object: state.get(), + path: "menu", + newValue: false + }); } else { _scrollToTop(helper.e(".menu-content")); - state.get().menu = true; + helper.setObject({ + object: state.get(), + path: "menu", + newValue: true + }); }; render(); };