CaseView - Keep the state of accordions when refreshing
authorColeman Watts <coleman@civicrm.org>
Sat, 22 Mar 2014 23:48:28 +0000 (19:48 -0400)
committerColeman Watts <coleman@civicrm.org>
Sun, 23 Mar 2014 00:08:31 +0000 (20:08 -0400)
templates/CRM/Case/Form/CaseView.js

index 6a9e8ea66d35a61e348e2310a1f30d90c222f1f8..3d982312953b30c44ea43124b2f865d9c1285303 100644 (file)
         });
         return false;
       });
+
     $().crmAccordions();
+
+    // Keep the state of accordions when refreshing
+    var accordionStates = [];
+    $('#crm-main-content-wrapper')
+      .on('crmBeforeLoad', function(e) {
+        if ($(e.target).is(this)) {
+          accordionStates = [];
+          $('.crm-accordion-wrapper', this).each(function() {
+            accordionStates.push($(this).hasClass('collapsed'));
+          });
+        }
+      })
+      .on('crmLoad', function(e) {
+        if ($(e.target).is(this)) {
+          var $targets = $('.crm-accordion-wrapper', this);
+          $.each(accordionStates, function(i, isCollapsed) {
+            $targets.eq(i).toggleClass('collapsed', isCollapsed);
+          });
+        }
+      });
   });
 }(cj, CRM))