da-js 1.1.2 → 1.2.0
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/assets/javascripts/da-js/conditional_visibility.js.coffee +13 -1
- data/lib/da-js/version.rb +1 -1
- 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: b9b54d38ef3a270d776753b97bbdc967f0f752db
|
4
|
+
data.tar.gz: b0f51caf20b76fae69bf1528ad3cbc548fa80e04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57b93dfaabe2deca5ee18ab9c486cdbd174519a2db418710e65e4c42fdab4138b6c2109a7bddabbbbe2777cfcec1486c937cced69d43319bae61df7e0ae40267
|
7
|
+
data.tar.gz: 8540936bbef29f0ef6e20af4f36418bffeb81b434294b5bf3958a2675e76300180eec7e576165c7b71fe67cc57da4eff6f0dfcd7578e90c364525f3240bab9cd
|
data/CHANGELOG.md
CHANGED
@@ -25,6 +25,14 @@
|
|
25
25
|
# manually after new elements have been added to the DOM (eg a modal with content fetched via
|
26
26
|
# ajax).
|
27
27
|
#
|
28
|
+
# The current state of an element with conditional visibility can be queried using
|
29
|
+
# `$(...).data('visible-if-state')`, which returns either `'visible'` or `'hidden'`. This differs
|
30
|
+
# from using jQuery’s `:visible` or `:hidden` pseude-selectors on the element in that it has
|
31
|
+
# immediate effect, even if animations are used: When an element changes from being visible to being
|
32
|
+
# hidden, it is still `:visible` in the jQuery sense until the animation has completed. However,
|
33
|
+
# `data('visible-if-state')` will return `'hidden'` immediately after the evaluation of the
|
34
|
+
# visibility condition.
|
35
|
+
#
|
28
36
|
# Example:
|
29
37
|
#
|
30
38
|
# <form id="myform">
|
@@ -46,10 +54,12 @@ $.fn.conditionalVisibility = (options = {}) ->
|
|
46
54
|
$(this).find("[data-visible-if]").each ->
|
47
55
|
$this = $(this)
|
48
56
|
if eval($this.data("visible-if"))
|
57
|
+
$(this).data("visible-if-state", "visible")
|
49
58
|
if $this.is(":hidden")
|
50
59
|
if options.animate then $this.slideDown(100) else $this.show()
|
51
60
|
$this.promise().done -> $this.trigger("shown.conditionalVisibility")
|
52
61
|
else
|
62
|
+
$(this).data("visible-if-state", "hidden")
|
53
63
|
if $this.is(":visible")
|
54
64
|
if options.animate then $this.slideUp(100) else $this.hide()
|
55
65
|
$this.promise().done -> $this.trigger("hidden.conditionalVisibility")
|
@@ -57,7 +67,9 @@ $.fn.conditionalVisibility = (options = {}) ->
|
|
57
67
|
setVisibilities = (event) ->
|
58
68
|
$(this).find("[data-visible-if]").each ->
|
59
69
|
$this = $(this)
|
60
|
-
|
70
|
+
isVisible = !!eval($this.data("visible-if"))
|
71
|
+
$(this).data("visible-if-state", if isVisible then "visible" else "hidden")
|
72
|
+
$this.toggle isVisible
|
61
73
|
|
62
74
|
this
|
63
75
|
.on "#{options.events} updateVisibilities", updateVisibilities
|
data/lib/da-js/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: da-js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Daschek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
version: '0'
|
195
195
|
requirements: []
|
196
196
|
rubyforge_project: da-js
|
197
|
-
rubygems_version: 2.5.2
|
197
|
+
rubygems_version: 2.5.2.3
|
198
198
|
signing_key:
|
199
199
|
specification_version: 4
|
200
200
|
summary: Mixed jQuery extensions
|