From: Coleman Watts Date: Wed, 5 Feb 2014 00:48:33 +0000 (-0800) Subject: CRM-14170 - Close help dialog when clicked twice X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b0ca6188bda72b0a01653fd45af569194d5d53e8;p=civicrm-core.git CRM-14170 - Close help dialog when clicked twice --- 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,