epi_js 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a3f46b4a617bb177e498058a8353743a735a935
4
- data.tar.gz: a5d11d7473856a4ddefb743a3cbaf39973a85da4
3
+ metadata.gz: ca6a07f5e9daa465d4f9692f43e4712f4694d86b
4
+ data.tar.gz: 69256cadb7e6df86b24a9f310eb2424867ea8dd3
5
5
  SHA512:
6
- metadata.gz: d304a8d18a8f80e6ed4d1e3229a4c2b42e74e3e5aad4aa01753e84ca077e50a29c8cd990e481e1dc2aa77a584623f26d0f56deb97867a6c90376a30b99404e17
7
- data.tar.gz: 2ba79c94751e203407ae57c0f2bfd97db58b85de8445f70269416d8ab6f3b8603b6959e871437aece316788b2ff881257af33619c9257fc509af77741c4518b2
6
+ metadata.gz: 4b9a78656fd3d678777cc9526c52e88af427fc7c2538eb9bcbea94ada71084a94a963f0d9d368d3120c30611699cbad1862cdd68a7b4a9cc95831c4355a79a23
7
+ data.tar.gz: 884c2b247a4f5c06216de0beadcbf488cda9553fddd2f5b971a3ab16f6cc5b2d12f0a2f72c1e0db93b69bc5c794c8a743e53112b9b8ce94487bd5f1f42b41d77
@@ -1,3 +1,3 @@
1
1
  module EpiJs
2
- VERSION = "1.0.9"
2
+ VERSION = "1.0.10"
3
3
  end
@@ -1,5 +1,5 @@
1
1
  (($) ->
2
- 'use strict'
2
+ 'use strict'
3
3
  class GenericVisibilityChecker
4
4
  constructor: (element) ->
5
5
  @element = element
@@ -7,17 +7,17 @@
7
7
  @action = @element.data('visibility-map-action') ? 'show'
8
8
  @map = @element.data('visibility-map')
9
9
  @allFields = $($.unique $.map @map, (val) => $(val, @scope).get())
10
-
10
+
11
11
  check: ->
12
12
  fieldsForValue = $ $.unique $.map @getValue(), (value) => $(@map[value], @scope).get()
13
-
13
+
14
14
  if @action is 'show'
15
15
  toShow = fieldsForValue
16
16
  toHide = @allFields.not(fieldsForValue)
17
17
  else
18
18
  toHide = fieldsForValue
19
19
  toShow = @allFields.not(fieldsForValue)
20
-
20
+
21
21
  toShow.show()
22
22
  toShow.trigger('visibility.show')
23
23
 
@@ -27,33 +27,37 @@
27
27
  hideAll: ->
28
28
  @allFields.hide()
29
29
  @allFields.trigger('visibility.hide')
30
-
30
+
31
+ showAll: ->
32
+ @allFields.show()
33
+ @allFields.trigger('visibility.show')
34
+
31
35
  getValue: ->
32
36
  $.makeArray(@element.val())
33
-
37
+
34
38
  class CheckboxVisibilityChecker extends GenericVisibilityChecker
35
39
  getValue: ->
36
40
  $.map $("input[type='checkbox'][name='#{@element.attr('name')}']:checked"), (inputElement) ->
37
41
  $(inputElement).val()
38
-
42
+
39
43
  $.fn.setVisibility = (action) ->
40
44
  @each ->
41
45
  data = $(this).data('visibility-checker')
42
46
  unless data?
43
- checkerClass = if $(this).is("input[type='checkbox']") then CheckboxVisibilityChecker else GenericVisibilityChecker
47
+ checkerClass = if $(this).is("input[type='checkbox']") then CheckboxVisibilityChecker else GenericVisibilityChecker
44
48
  $(this).data('visibility-checker', data = new checkerClass $(this))
45
49
  action ?= 'check'
46
50
  data[action]()
47
-
51
+
48
52
  $ ->
49
53
  $('input[data-visibility-map]:checked, select[data-visibility-map]').setVisibility()
50
-
54
+
51
55
  $(document.body).on('visibility.show', (e) ->
52
56
  $(':input:not([data-visibility-map-no-auto-enable])', $(e.target)).prop('disabled', false)
53
57
  ).on('visibility.hide', (e) ->
54
58
  $(':input', $(e.target)).prop('disabled', true)
55
59
  )
56
-
60
+
57
61
  $(document.body).on 'change', '[data-visibility-map]', (e) ->
58
62
  $(this).setVisibility()
59
- ) jQuery
63
+ ) jQuery
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epi_js
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shuo Chen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-01-10 00:00:00.000000000 Z
12
+ date: 2018-04-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties