From: Hypolite Petovan Date: Fri, 15 Feb 2019 03:26:18 +0000 (-0500) Subject: Improve global open/close functions in main.js X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ae3bf47019faf51422c80303e000643c8d655531;p=friendica.git Improve global open/close functions in main.js --- diff --git a/view/js/main.js b/view/js/main.js index c3d9cbed5c..3370d7ccd3 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -17,25 +17,30 @@ function _resizeIframe(obj, desth) { } function openClose(theID) { - if (document.getElementById(theID).style.display == "block") { - document.getElementById(theID).style.display = "none" - } else { - document.getElementById(theID).style.display = "block" + var el = document.getElementById(theID); + if (el) { + if (window.getComputedStyle(el).display === "none") { + openMenu(theID); + } else { + closeMenu(theID); + } } } function openMenu(theID) { var el = document.getElementById(theID); - if (el) { - el.style.display = "block"; + if (!el.dataset.display) { + el.dataset.display = 'block'; + } + el.style.display = el.dataset.display; } } function closeMenu(theID) { - var el = document.getElementById(theID) - + var el = document.getElementById(theID); if (el) { + el.dataset.display = window.getComputedStyle(el).display; el.style.display = "none"; } }