/[drupal]/contributions/modules/uc_addresses/uc_addresses.js
ViewVC logotype

Contents of /contributions/modules/uc_addresses/uc_addresses.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Mon Apr 20 20:50:00 2009 UTC (7 months, 1 week ago) by freixas
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +31 -22 lines
File MIME type: text/javascript
ucCountrySelect changed to ucAddressesCountrySelect.
Added form build ID as a POST parameter.
Now calls uc_addresses_js_util instead of uc_js_util.
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 }

  ViewVC Help
Powered by ViewVC 1.1.2