From b0ca6188bda72b0a01653fd45af569194d5d53e8 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 4 Feb 2014 16:48:33 -0800 Subject: [PATCH] CRM-14170 - Close help dialog when clicked twice --- js/Common.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/js/Common.js b/js/Common.js index 0fc1c0fc73..552ff5af56 100644 --- a/js/Common.js +++ b/js/Common.js @@ -427,15 +427,19 @@ CRM.validate = CRM.validate || { .on('click', 'a.crm-summary-link', false); }; - var h; + var helpDisplay, helpPrevious; CRM.help = function (title, params, url) { - h && h.close && h.close(); - var options = { - expires: 0 - }; - h = CRM.alert('...', title, 'crm-help crm-msg-loading', options); + if (helpDisplay && helpDisplay.isOpen) { + helpDisplay.close(); + // If the same link is clicked twice, just close the display - todo use underscore method for this comparison + if (helpPrevious === JSON.stringify(params)) { + return; + } + } + helpPrevious = JSON.stringify(params); params.class_name = 'CRM_Core_Page_Inline_Help'; params.type = 'page'; + helpDisplay = CRM.alert('...', title, 'crm-help crm-msg-loading', {expires: 0}); $.ajax(url || CRM.url('civicrm/ajax/inline'), { data: params, -- 2.25.1