From ca0de7b521c5de49acfceb18feda439a3ba27b48 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 22 Mar 2014 19:48:28 -0400 Subject: [PATCH] CaseView - Keep the state of accordions when refreshing --- templates/CRM/Case/Form/CaseView.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/templates/CRM/Case/Form/CaseView.js b/templates/CRM/Case/Form/CaseView.js index 6a9e8ea66d..3d98231295 100644 --- a/templates/CRM/Case/Form/CaseView.js +++ b/templates/CRM/Case/Form/CaseView.js @@ -215,6 +215,27 @@ }); 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)) -- 2.25.1