Browse Source

#101 - close on outer click

Alex Trofimov 12 years ago
parent
commit
fd44a368e4
2 changed files with 22 additions and 4 deletions
  1. 17 3
      inc/js/functions.js
  2. 5 1
      modules/boonex/ocean/data/template/system/css/menu.css

+ 17 - 3
inc/js/functions.js

@@ -337,6 +337,12 @@ function bx_menu_slide (jSel, e, sPosition) {
         eSlider.slideUp()
     };
 
+    var fCloseAllOpened = function () {
+        $('.bx-sliding-menu-main:visible, .bx-popup-slide-wrapper:visible').each(function () {
+            bx_menu_slide('#' + this.id);
+        });
+    }
+
     var fOpen = function () {
         if (eIcon.length) {
             eIcon.attr('data-icon-orig', eIcon.attr('data-icon'));
@@ -358,17 +364,25 @@ function bx_menu_slide (jSel, e, sPosition) {
 
     if ($(jSel + ':visible').length) {
         fClose();
+        $(document).off('click.bx-sliding-menu');
     } 
     else {
-        $('.bx-sliding-menu-main:visible, .bx-popup-slide-wrapper:visible').each(function () {
-            bx_menu_slide('#' + this.id); // close all opened sliding menus
-        });
+        fCloseAllOpened();
         fOpen();
         eSlider.find('a').each(function () {
             $(this).on('click', function () {
                 fClose();
             });
         });
+
+        setTimeout(function () {
+            $(document).on('click.bx-sliding-menu', function (event) {            
+                if ($(event.target).parents('.bx-sliding-menu-main, .bx-popup-slide-wrapper').length || $(event.target).filter('.bx-sliding-menu-main, .bx-popup-slide-wrapper').length || e.isSameNode(event.target))
+                    event.stopPropagation();
+                else
+                    fCloseAllOpened();
+            });
+        }, 10);
     }
 }
 

+ 5 - 1
modules/boonex/ocean/data/template/system/css/menu.css

@@ -28,7 +28,11 @@ ul.bx-menu-toolbar li a img {
 	background-color: #008fb8;
 }
 
+ul.bx-menu-toolbar li a .sys-icon-a {
+    margin-top:1rem;
+}
+
 /* --------------- account popup menu */
 .bx-menu-account-popup-profile {
 	font-weight: bold;
-}
+}