From 7cadb5f879df0cf78977f54ae4148ab8e57a09d9 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Thu, 9 Apr 2015 21:52:29 +0530 Subject: [PATCH] improvement and format fixes --- templates/CRM/Batch/Form/Entry.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/templates/CRM/Batch/Form/Entry.js b/templates/CRM/Batch/Form/Entry.js index 3aa8cb730e..fcf5b4ecb5 100755 --- a/templates/CRM/Batch/Form/Entry.js +++ b/templates/CRM/Batch/Form/Entry.js @@ -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); } } -- 2.25.1