Cleanup js
authorColeman Watts <coleman@civicrm.org>
Wed, 10 Jul 2013 14:17:39 +0000 (07:17 -0700)
committerColeman Watts <coleman@civicrm.org>
Wed, 10 Jul 2013 14:18:07 +0000 (07:18 -0700)
js/Common.js
templates/CRM/Profile/Form/Dynamic.tpl

index 294f76b98b295d97f1c3abc569bcacf59e128062..8b926423078a1201c684940e0f7d9d4945be65bf 100644 (file)
@@ -44,10 +44,12 @@ var cj = jQuery;
 function ts(text, params) {
   "use strict";
   text = CRM.strings[text] || text;
-  if (params && typeof(params) === 'object') {
+  if (typeof(params) === 'object') {
     for (var i in params) {
-      // sprintf emulation: escape % characters in the replacements to avoid conflicts
-      text = text.replace(new RegExp('%' + i, 'g'), params[i].replace(/%/g, '%-crmescaped-'));
+      if (typeof(params[i]) === 'string') {
+        // sprintf emulation: escape % characters in the replacements to avoid conflicts
+        text = text.replace(new RegExp('%' + i, 'g'), params[i].replace(/%/g, '%-crmescaped-'));
+      }
     }
     return text.replace(/%-crmescaped-/g, '%');
   }
index 389f91f0c1e419666fc959de057596ad13eeb48d..971b8e2d065e28f19df9d3b163aaeffd2623c38f 100644 (file)
@@ -341,7 +341,7 @@ cj(document).ready(function(){
     var queryString = cj.param(formData);
     queryString = queryString + '&snippet=5&gid=' + {/literal}"{$profileID}"{literal};
     var postUrl = {/literal}"{crmURL p='civicrm/profile/create' h=0 }"{literal};
-    var blockNo = {/literal}{$blockNo}{literal};
+    var blockNo = {/literal}{if $blockNo}{$blockNo}{else}null{/if}{literal};
     var prefix  = {/literal}"{$prefix}"{literal};
     var response = cj.ajax({
       type: "POST",