Explorar o código

Enable fastLoad for topnav dropdown menu items

Vijayakrishnan %!s(int64=5) %!d(string=hai) anos
pai
achega
10af5eddf3
Modificáronse 1 ficheiros con 17 adicións e 7 borrados
  1. 17 7
      public/js/mc.js

+ 17 - 7
public/js/mc.js

@@ -91,30 +91,40 @@ function initFastLoad(_parent = false) {
 
     fastCache = {};
 
-    var allAs = $('a:not([onclick]):not([href="#"]):visible');
+    var allAs = $('a:not([onclick]):not([href="#"])');
     if(_parent) {
-        allAs = _parent.find('a:not([onclick]):not([href="#"]):visible');
+        allAs = _parent.find('a:not([onclick]):not([href="#"])');
     }
     // find links without event handlers
     allAs.each(function() {
         if(!$(this).closest('[moe]').length) {
-            var handlers = findEventHandlers('click', this);
-            if(!handlers || !handlers.length) {
-                enableFastLoad(this);
+            if($(this).closest('.dropdown-menu[aria-labelledby="practice-management"]').length) {
+                enableFastLoad(this, true);
+            }
+            else {
+                var handlers = findEventHandlers('click', this);
+                if(!handlers || !handlers.length) {
+                    enableFastLoad(this);
+                }
             }
         }
     });
 
-    function enableFastLoad(_a) {
+    function enableFastLoad(_a, _menuItem = false) {
         $(_a).on('click', function() {
             fastLoad(this.href, true, true);
+            if(_menuItem) {
+                $(this).closest('.dropdown-menu')
+                    .removeClass('show')
+                    .prev('.dropdown-toggle').attr('aria-expanded', 'false');
+            }
             return false;
         });
         console.info('FastLoad enabled for ' + _a.innerText + ' [' + _a.href + ']');
     }
 
     // fast cache
-    allAs = $('a:not([onclick]):not([href="#"]):visible');
+    allAs = $('a:not([onclick]):not([href="#"])');
     allAs.each(function() {
         var a = this;
         $.get(a.href, function (_data) {