]> git.mxchange.org Git - friendica.git/commitdiff
Improve global open/close functions in main.js
authorHypolite Petovan <hypolite@mrpetovan.com>
Fri, 15 Feb 2019 03:26:18 +0000 (22:26 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Fri, 15 Feb 2019 03:26:18 +0000 (22:26 -0500)
view/js/main.js

index c3d9cbed5cf2ce1ec617628de3f34ccb3a83c646..3370d7ccd3a20515e2b1dbed10459756b4fcb103 100644 (file)
@@ -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";
        }
 }