Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
232624b1 | 3 | | CiviCRM version 4.4 | |
6a488035 TO |
4 | +--------------------------------------------------------------------+ |
5 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
6 | +--------------------------------------------------------------------+ | |
7 | | This file is a part of CiviCRM. | | |
8 | | | | |
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. | | |
12 | | | | |
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. | | |
17 | | | | |
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 | +--------------------------------------------------------------------+ | |
25 | *} | |
26 | {if $config->stateCountryMap} | |
75e14bbf CW |
27 | <script type="text/javascript"> |
28 | {literal} | |
29 | cj(function($) { | |
30 | function chainSelect(e) { | |
2f50fc92 CW |
31 | var info = $(this).data('chainSelect'); |
32 | var val = info.target.val(); | |
33 | var placeholder = $(this).val() ? "{/literal}{ts escape='js'}Loading{/ts}{literal}..." : info.placeholder; | |
34 | info.target.html('<option value="">' + placeholder + '</option>'); | |
75e14bbf | 35 | if ($(this).val()) { |
2f50fc92 | 36 | $.getJSON(info.callback, {_value: $(this).val()}, function(data) { |
75e14bbf CW |
37 | var options = ''; |
38 | $.each(data, function() { | |
39 | options += '<option value="' + this.value + '">' + this.name + '</option>'; | |
40 | }); | |
2f50fc92 | 41 | info.target.html(options).val(val).trigger('change'); |
75e14bbf CW |
42 | }); |
43 | } else { | |
2f50fc92 | 44 | info.target.trigger('change'); |
75e14bbf CW |
45 | } |
46 | } | |
6a488035 | 47 | {/literal} |
75e14bbf CW |
48 | {foreach from=$config->stateCountryMap item=stateCountryMap} |
49 | {if $stateCountryMap.country && $stateCountryMap.state_province} | |
2f50fc92 | 50 | $('select[name="{$stateCountryMap.country}"], #{$stateCountryMap.country}').data('chainSelect', {ldelim} |
75e14bbf | 51 | callback: CRM.url('civicrm/ajax/jqState'), |
2f50fc92 CW |
52 | target: $('select[name="{$stateCountryMap.state_province}"], #{$stateCountryMap.state_province}'), |
53 | placeholder: "{ts escape='js'}(choose country first){/ts}" | |
54 | {rdelim}).on('change', chainSelect); | |
75e14bbf CW |
55 | {/if} |
56 | {if $stateCountryMap.state_province && $stateCountryMap.county} | |
2f50fc92 | 57 | $('select[name="{$stateCountryMap.state_province}"], #{$stateCountryMap.state_province}').data('chainSelect', {ldelim} |
75e14bbf | 58 | callback: CRM.url('civicrm/ajax/jqCounty'), |
2f50fc92 CW |
59 | target: $('select[name="{$stateCountryMap.county}"], #{$stateCountryMap.county}'), |
60 | placeholder: "{ts escape='js'}(choose state first){/ts}" | |
61 | {rdelim}).on('change', chainSelect); | |
75e14bbf CW |
62 | {/if} |
63 | {/foreach} | |
6a488035 | 64 | {literal} |
75e14bbf CW |
65 | }); |
66 | {/literal} | |
6a488035 TO |
67 | </script> |
68 | {/if} |