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

Contents of /contributions/modules/addresses/addresses.js

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


Revision 1.2 - (show annotations) (download) (as text)
Sat Aug 2 04:05:57 2008 UTC (15 months, 3 weeks ago) by brmassa
Branch: MAIN
CVS Tags: DRUPAL-6--1-0, DRUPAL-6--1-0-alpha2, DRUPAL-6--1-0-ALPHA3, DRUPAL-6--1-05, DRUPAL-6--1-04, DRUPAL-6--1-01, DRUPAL-6--1-03, DRUPAL-6--1-02, HEAD
Changes since 1.1: +3 -2 lines
File MIME type: text/javascript
New features:
* JavaScript (besides not being used yet) is now JSLint compliant
1 /**
2 * $Id: addresses.js,v 1.1 2008/01/30 08:59:10 brmassa Exp $
3 * @author Bruno Massa
4 * @file addresses.js
5 * Autocompletion for Province field.
6 * This jQuery function will force the Province field
7 * to autcomplete the pronvice for a given country.
8 */
9 /*global Drupal, $ */
10
11 Drupal.behaviors.addresses = function(context) {
12 // Use this ID to 'simplify' the callings
13 var id = '#edit-addresses-';
14
15 // Record the original URL
16 var url = Drupal.settings.absPath + '/admin/settings/addresses/autocomplete/';
17
18 // Get all address
19 for (var n = 0; true; n++) {
20 // Check if this Field exists.
21 // If not, stop the script
22 if (!$(id + n +'-country').length) {
23 break;
24 }
25
26 // Set the country code at the beginning
27 if ($(id + n +'-country').val()) {
28 $(id + n +'-province-autocomplete').val(url + $(id + n +'-country').val());
29 }
30
31 // Change the country code everytime the country field changes
32 $(id + n +'-country').change(function() {
33 $(id + n +'-province-autocomplete').val(url + $(this).val());
34 // Drupal.behaviors.autocomplete();
35 });
36 }
37 };

  ViewVC Help
Powered by ViewVC 1.1.2