effective_addresses 1.3.2 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2a0de702ce06b137ff76dd3369442ddf9ba5f94
|
4
|
+
data.tar.gz: 698755ab5f757fcbb8ee8c1d481b8e5df0bf238c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cb549e5323b92b3b312d9ca9b33e66d7959a4f9b7d7b628f384522bf8a8405c1f8ac3f845fe2f65844e49a94d558d70223beda6e311524d380c6b2bfe08c005
|
7
|
+
data.tar.gz: 236e4f110bc5956d46b1ba0c9ad9fd0ed0732ff74995631b630b38ba33ba9c3d0989535f8ea1af280247fa4b0c885b427fee308706f056facdcef94d2d18c71a
|
@@ -1,20 +1,37 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
loadSubregions = ($countrySelect) ->
|
2
|
+
$.each $countrySelect, (index, countrySelector) ->
|
3
|
+
$particularCountrySelect = $(countrySelector)
|
4
|
+
countryCode = $particularCountrySelect.val()
|
5
|
+
uuid = $particularCountrySelect.data('effective-address-country')
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
$nestedFields = $particularCountrySelect.closest('.nested-fields')
|
8
|
+
$form = $particularCountrySelect.closest('form')
|
9
9
|
|
10
|
-
|
11
|
-
url = "/addresses/subregions/#{country_code}"
|
12
|
-
state_select = (nested_fields || form).find("select[data-effective-address-state='#{uuid}']").first()
|
10
|
+
$container = if $nestedFields.length == 0 then $form else $nestedFields
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
# clear postal_code values on country change
|
13
|
+
$container.find("input[data-effective-address-postal-code='#{uuid}']").val('')
|
14
|
+
|
15
|
+
# load state options
|
16
|
+
url = "/addresses/subregions/#{countryCode}"
|
17
|
+
$stateSelect = $container.find("select[data-effective-address-state='#{uuid}']:first")
|
18
|
+
|
19
|
+
if countryCode.length == 0
|
20
|
+
$stateSelect.prop('disabled', true).addClass('disabled').parent('.form-group').addClass('disabled')
|
21
|
+
$stateSelect.html('<option value="">Please choose a country first</option>')
|
22
|
+
else
|
23
|
+
$stateSelect.removeProp('disabled').removeClass('disabled').parent('.form-group').removeClass('disabled')
|
24
|
+
$stateSelect.find('option').first().text('loading...')
|
25
|
+
$stateSelect.load url, ->
|
26
|
+
stateSelectAvailable = $(@).find('option:last').val().length > 0
|
27
|
+
if stateSelectAvailable
|
28
|
+
$(@).prop('required', true)
|
29
|
+
$(@).removeProp('disabled')
|
30
|
+
else
|
31
|
+
$(@).removeProp('required')
|
32
|
+
$(@).prop('disabled', true)
|
33
|
+
|
34
|
+
$(document).on 'change', 'select[data-effective-address-country]', -> loadSubregions($(@))
|
35
|
+
|
36
|
+
$ -> loadSubregions($('select[data-effective-address-country]'))
|
37
|
+
$(document).on 'page:change', -> loadSubregions($('select[data-effective-address-country]'))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_addresses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|