| 1 |
// $Id$ |
// $Id: uc_location.js,v 1.2 2009/10/20 21:15:18 mearnest Exp $ |
| 2 |
|
|
| 3 |
/** |
/** |
| 4 |
* Initialize the uc_location module code: add the "apply_address()" |
* Initialize the uc_location module code: add the "apply_address()" |
| 14 |
$('#edit-panes-delivery-delivery-address-select,#edit-panes-billing-billing-address-select').change( |
$('#edit-panes-delivery-delivery-address-select,#edit-panes-billing-billing-address-select').change( |
| 15 |
function (evt) { |
function (evt) { |
| 16 |
if (evt.target.id == 'edit-panes-delivery-delivery-address-select') { |
if (evt.target.id == 'edit-panes-delivery-delivery-address-select') { |
| 17 |
apply_address("delivery", evt.target.value); |
uc_location_apply_address("delivery", evt.target.value); |
| 18 |
} |
} |
| 19 |
else if (evt.target.id == 'edit-panes-billing-billing-address-select') { |
else if (evt.target.id == 'edit-panes-billing-billing-address-select') { |
| 20 |
apply_address("billing", evt.target.value); |
uc_location_apply_address("billing", evt.target.value); |
| 21 |
} |
} |
| 22 |
}); |
}); |
| 23 |
|
|
| 24 |
Drupal.settings.ucLocation.initialized = true; |
Drupal.settings.ucLocation.initialized = true; |
| 25 |
} |
} |
| 26 |
|
} |
| 27 |
|
|
| 28 |
|
function uc_location_apply_address(type, address_str) { |
| 29 |
|
if (address_str == "0") { |
| 30 |
|
return; |
| 31 |
|
} |
| 32 |
|
eval("var address = " + address_str + ";"); |
| 33 |
|
var pane = "edit-panes-" + type + "-" + type; |
| 34 |
|
|
| 35 |
|
document.getElementById(pane + "-first-name").value = address.first_name; |
| 36 |
|
document.getElementById(pane + "-last-name").value = address.last_name; |
| 37 |
|
document.getElementById(pane + "-company").value = address.company; |
| 38 |
|
document.getElementById(pane + "-phone").value = address.phone; |
| 39 |
|
document.getElementById(pane + "-street1").value = address.street1; |
| 40 |
|
document.getElementById(pane + "-street2").value = address.street2; |
| 41 |
|
document.getElementById(pane + "-city").value = address.city; |
| 42 |
|
document.getElementById(pane + "-postal-code").value = address.postal_code; |
| 43 |
|
|
| 44 |
|
var country = document.getElementById(pane + "-country"); |
| 45 |
|
if(country.value != address.country) { |
| 46 |
|
country.value = address.country; |
| 47 |
|
uc_update_zone_select(pane + "-country", address.zone); |
| 48 |
|
} |
| 49 |
|
else { |
| 50 |
|
$("#" + pane + "-zone").val(address.zone).trigger("change"); |
| 51 |
|
} |
| 52 |
} |
} |