improvement and format fixes
authormonishdeb <monish.deb@webaccessglobal.com>
Thu, 9 Apr 2015 16:22:29 +0000 (21:52 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Thu, 9 Apr 2015 16:22:29 +0000 (21:52 +0530)
templates/CRM/Batch/Form/Entry.js

index 3aa8cb730e1968d199df20bf3ab05c08c00bea74..fcf5b4ecb5ea3a9a92b6aeaad52905a6c2ce1bbc 100755 (executable)
@@ -6,8 +6,11 @@ CRM.$(function($) {
       'url': CRM.url('civicrm/ajax/batch')
     };
 
-    $("#Entry").ajaxSubmit(options).on('click', function() {
-      $(this).block();
+    $("#Entry").ajaxSubmit(options);
+
+    //avoid multiple click on submit button
+    $("#_qf_Entry_upload").on('click', function() {
+      $('#Entry').block();
     });
 
     // validate rows
@@ -154,7 +157,7 @@ function checkColumns(parentRow) {
     parentRow.find("div:first span").prop('class', 'batch-invalid');
   }
   else {
-    if (inValidRow == 0 && validRow > 0) {
+    if (inValidRow === 0 && validRow > 0) {
       parentRow.find("div:first span").prop('class', 'batch-valid');
     }
     else {
@@ -180,10 +183,11 @@ function formatMoney(amount) {
   var t = CRM.setting.monetaryThousandSeparator;
   var d = CRM.setting.monetaryDecimalPoint;
 
+  c = isNaN(c = Math.abs(c)) ? 2 : c;
+  t = t === undefined ? "." : t, s = n < 0 ? "-" : "";
+  d = d === undefined ? "," : d;
+
   var n = amount,
-    c = isNaN(c = Math.abs(c)) ? 2 : c,
-    d = d == undefined ? "," : d,
-    t = t == undefined ? "." : t, s = n < 0 ? "-" : "",
     i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
     j = (j = i.length) > 3 ? j % 3 : 0;
 
@@ -199,12 +203,12 @@ function formatMoney(amount) {
 function setFieldValue(fname, fieldValue, blockNo) {
   var elementId = cj('[name="field[' + blockNo + '][' + fname + ']"]');
 
-  if (elementId.length == 0) {
+  if (elementId.length === 0) {
     elementId = cj('input[type=checkbox][name^="field[' + blockNo + '][' + fname + ']"][type!=hidden]');
   }
 
   // if element not found than return
-  if (elementId.length == 0) {
+  if (elementId.length === 0) {
     return;
   }
 
@@ -242,7 +246,7 @@ function setFieldValue(fname, fieldValue, blockNo) {
       if (editor) {
         switch (editor) {
           case 'ckeditor':
-            var elemtId = elementId.attr('id');
+            elemtId = elementId.attr('id');
             oEditor = CKEDITOR.instances[elemtId];
             oEditor.setData(htmlContent);
             break;
@@ -251,9 +255,10 @@ function setFieldValue(fname, fieldValue, blockNo) {
             tinyMCE.get(elemtId).setContent(htmlContent);
             break;
           case 'joomlaeditor':
-          // TO DO
+            // TO DO
           case 'drupalwysiwyg':
-          // TO DO
+            // TO DO
+            break;
           default:
             elementId.val(fieldValue);
         }
@@ -267,7 +272,7 @@ function setFieldValue(fname, fieldValue, blockNo) {
   // since we use different display field for date we also need to set it.
   // also check for date time field and set the value correctly
   if (isDateElement && fieldValue) {
-    setDateFieldValue(fname, fieldValue, blockNo)
+    setDateFieldValue(fname, fieldValue, blockNo);
   }
 }