Merge pull request #3119 from pradpnayak/CRM-14380
[civicrm-core.git] / templates / CRM / common / customData.tpl
index 6c45f8d5cf2242d47fb677aff4dee8e5b66f0628..64ed2fa60e196942ca54d765b2687074b3ffad12 100644 (file)
@@ -1,8 +1,8 @@
 {*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -29,9 +29,7 @@
 {/if}
 {literal}
 <script type="text/javascript">
-var CRM = CRM || {};
-CRM.buildCustomData = function( type, subType, subName, cgCount, groupID, isMultiple )
-{
+CRM.buildCustomData = function( type, subType, subName, cgCount, groupID, isMultiple ) {
   var dataUrl = {/literal}"{crmURL p=$urlPath h=0 q='snippet=4&type='}"{literal} + type;
 
   if ( subType ) {
@@ -41,11 +39,12 @@ CRM.buildCustomData = function( type, subType, subName, cgCount, groupID, isMult
   if ( subName ) {
     dataUrl = dataUrl + '&subName=' + subName;
     cj('#customData' + subName ).show();
-  } else {
+  }
+  else {
     cj('#customData').show();
   }
   if ( groupID ) {
-         dataUrl = dataUrl + '&groupID=' + groupID;
+      dataUrl = dataUrl + '&groupID=' + groupID;
   }
 
   {/literal}
@@ -66,7 +65,8 @@ CRM.buildCustomData = function( type, subType, subName, cgCount, groupID, isMult
   if ( !cgCount ) {
     cgCount = 1;
     var prevCount = 1;
-  } else if ( cgCount >= 1 ) {
+  }
+  else if ( cgCount >= 1 ) {
     var prevCount = cgCount;
     cgCount++;
   }
@@ -75,16 +75,19 @@ CRM.buildCustomData = function( type, subType, subName, cgCount, groupID, isMult
 
 
   if ( isMultiple ) {
-         var fname = '#custom_group_' + groupID + '_' + prevCount;
+    var fname = '#custom_group_' + groupID + '_' + prevCount;
     if (cj(".add-more-link-" + groupID + "-" + prevCount ).length) {
       cj(".add-more-link-" + groupID + "-" + prevCount).hide();
-    } else {
-                  cj("#add-more-link-"+prevCount).hide();
     }
-  } else {
+    else {
+      cj("#add-more-link-"+prevCount).hide();
+    }
+  }
+  else {
     if ( subName && subName != 'null' ) {
       var fname = '#customData' + subName ;
-    } else {
+    }
+    else {
       var fname = '#customData';
     }
   }
@@ -92,6 +95,7 @@ CRM.buildCustomData = function( type, subType, subName, cgCount, groupID, isMult
   cj.ajax({
     url: dataUrl,
     dataType: 'html',
+    async: false,
     success: function(response) {
       var target = cj(fname);
       var storage = {};
@@ -107,7 +111,7 @@ CRM.buildCustomData = function( type, subType, subName, cgCount, groupID, isMult
           storage[id] = cj(this).detach();
         }
       });
-      target.html(response);
+      target.html(response).trigger('crmLoad');
       target.children().each(function() {
         var id = cj(this).attr('id');
         if (id && storage[id]) {
@@ -117,7 +121,6 @@ CRM.buildCustomData = function( type, subType, subName, cgCount, groupID, isMult
       storage = null;
     }
   });
-
 };
 
 </script>