From cf021bc5a2766f8d54ee518f1a6309952f00c7d7 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 23 Dec 2013 15:34:42 -0800 Subject: [PATCH] CRM-13863 - Ensure crmAccordions work in popup context --- js/Common.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/js/Common.js b/js/Common.js index 0976395d80..3e6feeefe9 100644 --- a/js/Common.js +++ b/js/Common.js @@ -1061,19 +1061,15 @@ CRM.validate = CRM.validate || { }); $.fn.crmAccordions = function (speed) { - var container = $('#crm-container'); - if (speed === undefined) { - speed = 200; - } - if ($(this).length > 0) { - container = $(this); - } - if (container.length > 0 && !container.hasClass('crm-accordion-processed')) { + var container = $(this).length > 0 ? $(this) : $('.crm-container'); + speed = speed === undefined ? 200 : speed; + container + .off('click.crmAccordions') // Allow normal clicking of links - container.on('click', 'div.crm-accordion-header a', function (e) { + .on('click.crmAccordions', 'div.crm-accordion-header a', function (e) { e.stopPropagation && e.stopPropagation(); - }); - container.on('click', '.crm-accordion-header, .crm-collapsible .collapsible-title', function () { + }) + .on('click.crmAccordions', '.crm-accordion-header, .crm-collapsible .collapsible-title', function () { if ($(this).parent().hasClass('collapsed')) { $(this).next().css('display', 'none').slideDown(speed); } @@ -1083,8 +1079,6 @@ CRM.validate = CRM.validate || { $(this).parent().toggleClass('collapsed'); return false; }); - container.addClass('crm-accordion-processed'); - } }; $.fn.crmAccordionToggle = function (speed) { $(this).each(function () { -- 2.25.1