dataType: 'json',
success: function(data) {
var selectLocBlockId = $('#loc_event_id').val();
- // Only change state when options are loaded
+ // Only change state when options are loaded.
if (data.address_1_state_province_id) {
var defaultState = data.address_1_state_province_id;
$('#address_1_state_province_id', $form).one('crmOptionsUpdated', function() {
if ( i == 'count_loc_used' ) {
if ( ((selectLocBlockId == locBlockId) && data.count_loc_used > 1) ||
((selectLocBlockId != locBlockId) && data.count_loc_used > 0) ) {
- displayMessage(data.count_loc_used);
+ // Counts retrieved via AJAX are already "other" Event counts.
+ displayMessage(parseInt(data.count_loc_used) + 1);
} else {
displayMessage(0);
}
var createNew = document.getElementsByName("location_option")[0].checked;
if (createNew) {
$('#existingLoc', $form).hide();
- //clear all location fields values.
+ // Clear all location fields values.
if (clear !== false) {
$(":input[id *= 'address_1_'], :input[id *= 'email_1_'], :input[id *= 'phone_1_']", $form).val("").change();
{/literal}{if $config->defaultContactCountry}
{if $config->defaultContactStateProvince}
- // Set default state once options are loaded
+ // Set default state once options are loaded.
var defaultState = {$config->defaultContactStateProvince}
{literal}
$('#address_1_state_province_id', $form).one('crmOptionsUpdated', function() {
showLocFields(false);
function displayMessage(count) {
- if (count) {
- var msg = {/literal}'{ts escape="js" 1="%1"}This location is used by %1 other events. Modifying location information will change values for all events.{/ts}'{literal};
- $('#locUsedMsg', $form).text(ts(msg, {1: count})).addClass('status');
+ if (parseInt(count) > 1) {
+ var otherCount = parseInt(count) - 1;
+ if (otherCount > 1) {
+ var msg = {/literal}'{ts escape="js" 1="%1"}This location is used by %1 other events. Modifying location information will change values for all events.{/ts}'{literal};
+ } else {
+ var msg = {/literal}'{ts escape="js" 1="%1"}This location is used by %1 other event. Modifying location information will also change values for that event.{/ts}'{literal};
+ }
+ $('#locUsedMsg', $form).text(ts(msg, {1: otherCount})).addClass('status');
} else {
$('#locUsedMsg', $form).text(' ').removeClass('status');
}