2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.5 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2014 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
26 {if $config->stateCountryMap}
27 <script type="text/javascript">
30 function chainSelect(e) {
31 var info = $(this).data('chainSelect');
32 var val = info.target.val();
33 var multiple = info.target.attr('multiple');
34 var placeholder = $(this).val() ? "{/literal}{ts escape='js'}Loading{/ts}{literal}..." : info.placeholder;
35 !multiple && info.target.html('<option value="">' + placeholder + '</option>');
39 $.each($(this).val(), function(index, value) {
40 $.getJSON(info.callback, {_value: value}, function(data) {
41 $.each(data, function() {
43 options += '<option value="' + this.value + '">' + this.name + '</option>';
46 info.target.html(options).val(val).trigger('change');
51 $.getJSON(info.callback, {_value: $(this).val()}, function(data) {
53 $.each(data, function() {
55 options += '<option value="' + this.value + '">' + this.name + '</option>';
58 info.target.html(options).val(val).trigger('change');
62 info.target.trigger('change');
66 {foreach from=$config->stateCountryMap item=stateCountryMap}
67 {if $stateCountryMap.country && $stateCountryMap.state_province}
68 $('select[name="{$stateCountryMap.country}"], #{$stateCountryMap.country}').data('chainSelect', {ldelim}
69 callback: CRM.url('civicrm/ajax/jqState'),
70 target: $('select[name="{$stateCountryMap.state_province}"], #{$stateCountryMap.state_province}'),
71 placeholder: "{ts escape='js'}(choose country first){/ts}"
72 {rdelim}).on('change', chainSelect);
74 {if $stateCountryMap.state_province && $stateCountryMap.county}
75 $('select[name="{$stateCountryMap.state_province}"], #{$stateCountryMap.state_province}').data('chainSelect', {ldelim}
76 callback: CRM.url('civicrm/ajax/jqCounty'),
77 target: $('select[name="{$stateCountryMap.county}"], #{$stateCountryMap.county}'),
78 placeholder: "{ts escape='js'}(choose state first){/ts}"
79 {rdelim}).on('change', chainSelect);