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

Diff of /contributions/modules/uc_location/uc_location.js

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

revision 1.1 by mearnest, Mon Oct 5 21:15:52 2009 UTC revision 1.1.2.1 by mearnest, Fri Nov 20 22:46:32 2009 UTC
# Line 1  Line 1 
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()"
# Line 14  Drupal.behaviors.ucLocationInitialize = Line 14  Drupal.behaviors.ucLocationInitialize =
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  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.3