da-js 1.1.2 → 1.2.0

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: 62e98347e13e596d9a0738937d662e126aeeb495
4
- data.tar.gz: 5de66d7174979eaefa9dddab50a936c91d16bffa
3
+ metadata.gz: b9b54d38ef3a270d776753b97bbdc967f0f752db
4
+ data.tar.gz: b0f51caf20b76fae69bf1528ad3cbc548fa80e04
5
5
  SHA512:
6
- metadata.gz: a9a68989e6c5e78bea820418dc0daceecdc4443e5036b924876223a23b864d8df14c7156ff128b9b3f452bd62d182d3f5dbf187481897d805282c7dc912462ee
7
- data.tar.gz: abc1feea91c35648d7e75c3b0296b2b7569eb9acbaa37dea00a9dda402f3c2f3e9085f74523b37ed5fc0e1e78dd8924fd3b318b658cf5267d88a2d5e6bd02e3f
6
+ metadata.gz: 57b93dfaabe2deca5ee18ab9c486cdbd174519a2db418710e65e4c42fdab4138b6c2109a7bddabbbbe2777cfcec1486c937cced69d43319bae61df7e0ae40267
7
+ data.tar.gz: 8540936bbef29f0ef6e20af4f36418bffeb81b434294b5bf3958a2675e76300180eec7e576165c7b71fe67cc57da4eff6f0dfcd7578e90c364525f3240bab9cd
@@ -1,3 +1,7 @@
1
+ ## Version 1.2
2
+ ### Conditional Visibility
3
+ * The current state of an element with conditional visibility can now be queried with `$(...).data('visible-if-state')`.
4
+
1
5
  ## Version 1.1.2
2
6
  * Relax gemspec version requirements: Can now be used with Rails 5.
3
7
 
@@ -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
- $this.toggle !!eval($this.data("visible-if"))
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
@@ -1,5 +1,5 @@
1
1
  module Da
2
2
  module Js
3
- VERSION = "1.1.2"
3
+ VERSION = "1.2.0".freeze
4
4
  end
5
5
  end
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.1.2
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: 2017-07-14 00:00:00.000000000 Z
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