From 0f5816a693d8a62cb311ae9bce2606ca48a57ba9 Mon Sep 17 00:00:00 2001 From: Kurund Jalmi Date: Tue, 30 Apr 2013 22:47:32 -0700 Subject: [PATCH] whitespace fixes --- js/Common.js | 630 +++++++++++++++++++++++++++------------------------ 1 file changed, 340 insertions(+), 290 deletions(-) diff --git a/js/Common.js b/js/Common.js index c9f76c912a..191eba268f 100644 --- a/js/Common.js +++ b/js/Common.js @@ -22,7 +22,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * @file: global functions for CiviCRM @@ -47,7 +47,7 @@ function ts(text, params) { if (params && 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-')); + text = text.replace(new RegExp('%' + i, 'g'), params[i].replace(/%/g, '%-crmescaped-')); } return text.replace(/%-crmescaped-/g, '%'); } @@ -66,33 +66,34 @@ function ts(text, params) { * @param elementType Value to set display style to for showBlocks (e.g. 'block' or 'table-row' or ...) * @return none */ -function on_load_init_blocks(showBlocks, hideBlocks, elementType) -{ - if ( elementType == null ) { - var elementType = 'block'; - } - - /* This loop is used to display the blocks whose IDs are present within the showBlocks array */ - for ( var i = 0; i < showBlocks.length; i++ ) { - var myElement = document.getElementById(showBlocks[i]); - /* getElementById returns null if element id doesn't exist in the document */ - if (myElement != null) { - myElement.style.display = elementType; - } else { - alert('showBlocks array item not in .tpl = ' + showBlocks[i]); - } +function on_load_init_blocks(showBlocks, hideBlocks, elementType) { + if (elementType == null) { + var elementType = 'block'; + } + + /* This loop is used to display the blocks whose IDs are present within the showBlocks array */ + for (var i = 0; i < showBlocks.length; i++) { + var myElement = document.getElementById(showBlocks[i]); + /* getElementById returns null if element id doesn't exist in the document */ + if (myElement != null) { + myElement.style.display = elementType; } + else { + alert('showBlocks array item not in .tpl = ' + showBlocks[i]); + } + } - /* This loop is used to hide the blocks whose IDs are present within the hideBlocks array */ - for ( var i = 0; i < hideBlocks.length; i++ ) { - var myElement = document.getElementById(hideBlocks[i]); - /* getElementById returns null if element id doesn't exist in the document */ - if (myElement != null) { - myElement.style.display = 'none'; - } else { - alert('showBlocks array item not in .tpl = ' + hideBlocks[i]); - } + /* This loop is used to hide the blocks whose IDs are present within the hideBlocks array */ + for (var i = 0; i < hideBlocks.length; i++) { + var myElement = document.getElementById(hideBlocks[i]); + /* getElementById returns null if element id doesn't exist in the document */ + if (myElement != null) { + myElement.style.display = 'none'; + } + else { + alert('showBlocks array item not in .tpl = ' + hideBlocks[i]); } + } } /** @@ -107,54 +108,65 @@ function on_load_init_blocks(showBlocks, hideBlocks, elementType) * @param field_type Type of element radio/select * @param invert Boolean - if true, we HIDE target on value match; if false, we SHOW target on value match * @return none -*/ -function showHideByValue(trigger_field_id, trigger_value, target_element_id, target_element_type, field_type, invert ) { - if ( target_element_type == null ) { - var target_element_type = 'block'; - } else if ( target_element_type == 'table-row' ) { - var target_element_type = ''; - } - - if (field_type == 'select') { - var trigger = trigger_value.split("|"); - var selectedOptionValue = document.getElementById(trigger_field_id).options[document.getElementById(trigger_field_id).selectedIndex].value; - - var target = target_element_id.split("|"); - for(var j = 0; j < target.length; j++) { - if ( invert ) { - cj('#' + target[j]).show(); - } else { - cj('#' + target[j]).hide(); - } - for(var i = 0; i < trigger.length; i++) { - if (selectedOptionValue == trigger[i]) { - if ( invert ) { - cj('#' + target[j]).hide(); - } else { - cj('#' + target[j]).show(); - } - } - } + */ +function showHideByValue(trigger_field_id, trigger_value, target_element_id, target_element_type, field_type, invert) { + if (target_element_type == null) { + var target_element_type = 'block'; + } + else { + if (target_element_type == 'table-row') { + var target_element_type = ''; + } + } + + if (field_type == 'select') { + var trigger = trigger_value.split("|"); + var selectedOptionValue = document.getElementById(trigger_field_id).options[document.getElementById(trigger_field_id).selectedIndex].value; + + var target = target_element_id.split("|"); + for (var j = 0; j < target.length; j++) { + if (invert) { + cj('#' + target[j]).show(); + } + else { + cj('#' + target[j]).hide(); + } + for (var i = 0; i < trigger.length; i++) { + if (selectedOptionValue == trigger[i]) { + if (invert) { + cj('#' + target[j]).hide(); + } + else { + cj('#' + target[j]).show(); + } } + } + } - } else if (field_type == 'radio') { - var target = target_element_id.split("|"); - for(var j = 0; j < target.length; j++) { - if (document.getElementsByName(trigger_field_id)[0].checked) { - if ( invert ) { - cj('#' + target[j]).hide(); - } else { - cj('#' + target[j]).show(); - } - } else { - if ( invert ) { - cj('#' + target[j]).show(); - } else { - cj('#' + target[j]).hide(); - } - } + } + else { + if (field_type == 'radio') { + var target = target_element_id.split("|"); + for (var j = 0; j < target.length; j++) { + if (document.getElementsByName(trigger_field_id)[0].checked) { + if (invert) { + cj('#' + target[j]).hide(); + } + else { + cj('#' + target[j]).show(); + } } + else { + if (invert) { + cj('#' + target[j]).show(); + } + else { + cj('#' + target[j]).hide(); + } + } + } } + } } /** @@ -170,49 +182,51 @@ function showHideByValue(trigger_field_id, trigger_value, target_element_id, tar * @return */ function toggleCheckboxVals(fldPrefix, object) { - if ( object.id == 'toggleSelect' && cj(object).is(':checked') ) { - cj( 'Input[id*="' + fldPrefix + '"],Input[id*="toggleSelect"]').attr('checked', true); - } else { - cj( 'Input[id*="' + fldPrefix + '"],Input[id*="toggleSelect"]').attr('checked', false); - } - // change the class of selected rows - on_load_init_checkboxes(object.form.name); + if (object.id == 'toggleSelect' && cj(object).is(':checked')) { + cj('Input[id*="' + fldPrefix + '"],Input[id*="toggleSelect"]').attr('checked', true); + } + else { + cj('Input[id*="' + fldPrefix + '"],Input[id*="toggleSelect"]').attr('checked', false); + } + // change the class of selected rows + on_load_init_checkboxes(object.form.name); } function countSelectedCheckboxes(fldPrefix, form) { - fieldCount = 0; - for( i=0; i < form.elements.length; i++) { - fpLen = fldPrefix.length; - if (form.elements[i].type == 'checkbox' && form.elements[i].name.slice(0,fpLen) == fldPrefix && form.elements[i].checked == true) { - fieldCount++; - } + fieldCount = 0; + for (i = 0; i < form.elements.length; i++) { + fpLen = fldPrefix.length; + if (form.elements[i].type == 'checkbox' && form.elements[i].name.slice(0, fpLen) == fldPrefix && form.elements[i].checked == true) { + fieldCount++; } - return fieldCount; + } + return fieldCount; } /** * Function to enable task action select */ -function toggleTaskAction( status ) { - var radio_ts = document.getElementsByName('radio_ts'); - if (!radio_ts[1]) { - radio_ts[0].checked = true; - } - if ( radio_ts[0].checked || radio_ts[1].checked ) { - status = true; - } - - var formElements = ['task', 'Go', 'Print']; - for(var i=0; i