← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14638: Closes all other dropdowns when another is opened.

 

------------------------------------------------------------
revno: 14638
committer: Mark Polak <markpo@xxxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-04-03 17:35:50 +0200
message:
  Closes all other dropdowns when another is opened.
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.js	2014-03-30 10:32:05 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.js	2014-04-03 15:35:50 +0000
@@ -63,18 +63,24 @@
         var id = $(element).parent().attr('id'),
             dropdown_menu = $('div#' + id.split('_')[0]);
 
+        function closeAllDropdowns() {
+            $('.app-menu-dropdown').each(function () {
+                $(this).attr('data-clicked-open', 'false');
+                $(this).hide();
+            });
+            hideDropDown();
+        }
+
         $(element).click(function () {
-            var open = false;
-
             return function () {
-                if (open === true) {
+                var thisDropDownStatus = $(dropdown_menu).attr('data-clicked-open');
+                closeAllDropdowns();
+
+                if (thisDropDownStatus === 'true') {
                     $(dropdown_menu).attr('data-clicked-open', 'false');
-                    hideDropDown();
-                    open = false;
                 } else {
                     $(dropdown_menu).attr('data-clicked-open', 'true');
                     showDropDown(dropdown_menu.attr('id'));
-                    open = true;
                 }
             }
         }());