| 1 |
// $Id$
|
| 2 |
|
| 3 |
/**
|
| 4 |
* Set the select box change behavior for the country selector
|
| 5 |
*/
|
| 6 |
Drupal.behaviors.ucAddressesCountrySelect = function(context) {
|
| 7 |
$('select[@id*=-country-]:not(.ucAddressesCountrySelect-processed)', context).addClass('ucAddressesCountrySelect-processed').change(
|
| 8 |
function() {
|
| 9 |
uc_addresses_update_zone_select(this.id, '');
|
| 10 |
}
|
| 11 |
);
|
| 12 |
}
|
| 13 |
|
| 14 |
function uc_addresses_update_zone_select(country_select, default_zone) {
|
| 15 |
var zone_select =
|
| 16 |
country_select.substr(0, country_select.length - 10) +
|
| 17 |
'-zone' +
|
| 18 |
country_select.substr(country_select.length - 2 );
|
| 19 |
|
| 20 |
var options = {
|
| 21 |
'country_id' : $('#' + country_select).val(),
|
| 22 |
'form_build_id' : $('form[@id^=uc-addresses] input[@name=form_build_id]').val()
|
| 23 |
};
|
| 24 |
|
| 25 |
$('#' + zone_select).parent()
|
| 26 |
.siblings('.zone-throbber')
|
| 27 |
.attr('style', 'background-image: url(' + Drupal.settings.basePath + 'misc/throbber.gif); background-repeat: no-repeat; background-position: 100% -20px;')
|
| 28 |
.html(' ');
|
| 29 |
|
| 30 |
$.post(Drupal.settings.basePath + '?q=uc_addresses_js_util', options,
|
| 31 |
function (contents) {
|
| 32 |
if (contents.match('value="-1"') != null) {
|
| 33 |
$('#' + zone_select).attr('disabled', 'disabled');
|
| 34 |
}
|
| 35 |
else {
|
| 36 |
$('#' + zone_select).removeAttr('disabled');
|
| 37 |
}
|
| 38 |
$('#' + zone_select).empty().append(contents).val(default_zone).change();
|
| 39 |
$('#' + zone_select).parent().siblings('.zone-throbber').removeAttr('style').empty();
|
| 40 |
}
|
| 41 |
);
|
| 42 |
}
|