/[drupal]/contributions/modules/location/location_autocomplete.js
ViewVC logotype

Contents of /contributions/modules/location/location_autocomplete.js

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


Revision 1.3 - (show annotations) (download) (as text)
Tue Dec 2 22:50:21 2008 UTC (11 months, 3 weeks ago) by bdragon
Branch: MAIN
CVS Tags: DRUPAL-6--3-1-RC1, DRUPAL-6--3-0, HEAD
Branch point for: DRUPAL-6--3
Changes since 1.2: +26 -10 lines
File MIME type: text/javascript
* Fix [#339471] (reported by theabacus) -- Make province search accept country names.
* Implement multiple country autocomplete.
* Allow location_province_code() to operate on an array of countries.
* Extend autocomplete to handle setting specific classes to join country and province fields together -- should be more robust.
* Switch to using views "force single" stuff for country and province filters.
  - If you are having trouble editing country or province filters, please see [#341827]!
* Implement autocomplete for views province filter.
1 // $Id: location_autocomplete.js,v 1.2 2008/08/06 15:29:51 bdragon Exp $
2
3 /**
4 * Twiddle the province autocomplete whenever the user changes the country.
5 */
6 Drupal.behaviors.location = function(context) {
7 $('select.location_auto_country:not(.location-processed)', context).change(function(e) {
8 var obj = this;
9 var input = null;
10 var result = this.className.match(/(location_auto_join_[^ ]*)/);
11 if (result) {
12 input = $('.location_auto_province.' + result)
13 }
14 else {
15 // No joining class found, fallback to searching the immediate area.
16 input = $('.location_auto_province', $(this).parents('fieldset:first, .views-exposed-form:first'))
17 }
18
19 if (input && input.length) {
20 //Unbind events on province field and empty its value
21 input.unbind().val('');
22 input.each(function(i) {
23 //Get the (hidden) *-autocomplete input element
24 var input_autocomplete = $('#' + this.id + '-autocomplete');
25 // Update autocomplete url
26 input_autocomplete.val(input_autocomplete.val().substr(0, input_autocomplete.val().lastIndexOf('/') + 1) + $(obj).val());
27 // Mark as not processed.
28 input_autocomplete.removeClass('autocomplete-processed');
29 });
30 // Reprocess.
31 Drupal.behaviors.autocomplete(document);
32 }
33 }).addClass('location-processed');
34 };

  ViewVC Help
Powered by ViewVC 1.1.2