CRM-14170 - Close help dialog when clicked twice
authorColeman Watts <coleman@civicrm.org>
Wed, 5 Feb 2014 00:48:33 +0000 (16:48 -0800)
committerColeman Watts <coleman@civicrm.org>
Wed, 5 Feb 2014 00:48:33 +0000 (16:48 -0800)
js/Common.js

index 0fc1c0fc73a96e72eee3a6e96b2ee24846eb247b..552ff5af568d488922f64005d4f84174a0a87936 100644 (file)
@@ -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,