epi_js 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/epi_js/version.rb +1 -1
- data/vendor/assets/javascripts/visibility_map.coffee +39 -16
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9cb4601137674203e8fb811db4c557d346b5a83
|
4
|
+
data.tar.gz: d9b3e66fdce959db6657b60634ba4a2af381b6aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf5bf618e901d016ffb74f29420e1164f53d5af956aaf76a603dc14852a5063e5952127075f6af4614aaee41ff6bded6cabac6dbde5a171a0b1b946ba1342ddc
|
7
|
+
data.tar.gz: 35763559ef74f24841f42e249ee7f515f81b038d1a6af5b673cf17aedc3b63cd56ca4341bd07a58725acccf1a3e894ae98739447d2cd7363e807f251170c117e
|
data/lib/epi_js/version.rb
CHANGED
@@ -1,19 +1,42 @@
|
|
1
1
|
(($) ->
|
2
|
+
'use strict'
|
3
|
+
class GenericVisibilityChecker
|
4
|
+
constructor: (element) ->
|
5
|
+
@element = element
|
6
|
+
@map = @element.data('visibility-map')
|
7
|
+
@allFields = $($.unique $.map @map, (val) -> $(val).get())
|
8
|
+
|
9
|
+
check: ->
|
10
|
+
toShow = $ $.unique $.map @getValue(), (value) => $(@map[value]).get()
|
11
|
+
toHide = @allFields.not(toShow)
|
12
|
+
|
13
|
+
toShow.show()
|
14
|
+
toShow.trigger('visibility.show')
|
15
|
+
$(':input:not([data-visibility-map-no-auto-enable])', toShow).prop('disabled', false)
|
16
|
+
|
17
|
+
toHide.hide()
|
18
|
+
toHide.trigger('visibility.hide')
|
19
|
+
$(':input', toHide).prop('disabled', true)
|
20
|
+
|
21
|
+
getValue: ->
|
22
|
+
$.makeArray(@element.val())
|
23
|
+
|
24
|
+
class CheckboxVisibilityChecker extends GenericVisibilityChecker
|
25
|
+
getValue: ->
|
26
|
+
$.map $("input[type='checkbox'][name='#{@element.attr('name')}']:checked"), (inputElement) ->
|
27
|
+
$(inputElement).val()
|
28
|
+
|
2
29
|
$.fn.setVisibility = ->
|
3
30
|
@each ->
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
)
|
14
|
-
|
15
|
-
|
16
|
-
$(document.body).on 'change', '[data-visibility-map]', ->
|
17
|
-
$(@).setVisibility()
|
18
|
-
|
19
|
-
$('input[data-visibility-map]:checked, select[data-visibility-map]').setVisibility()
|
31
|
+
data = $(this).data('visibility-checker')
|
32
|
+
unless data?
|
33
|
+
checkerClass = if $(this).is("input[type='checkbox']") then CheckboxVisibilityChecker else GenericVisibilityChecker
|
34
|
+
$(this).data('visibility-checker', data = new checkerClass $(this))
|
35
|
+
data.check()
|
36
|
+
|
37
|
+
$ ->
|
38
|
+
$('input[data-visibility-map]:checked, select[data-visibility-map]').setVisibility()
|
39
|
+
|
40
|
+
$(document.body).on 'change', '[data-visibility-map]', (e) ->
|
41
|
+
$(e.target).setVisibility()
|
42
|
+
) jQuery
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epi_js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shuo Chen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.4.
|
137
|
+
rubygems_version: 2.4.5.1
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: jQuery scripts used in various projects
|