da-js 1.0.0 → 1.2.1

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
- SHA1:
3
- metadata.gz: 4030934aa9a7b6bf91ddbad0bc8802c261dbdade
4
- data.tar.gz: 680b7b9e12660c9d6c08cdc2e11c4dca67bccb47
2
+ SHA256:
3
+ metadata.gz: 3ce2526b33932c7db329c1ba4cea698420694b9752a608b7471501379531be6a
4
+ data.tar.gz: 4c189b4f3a79d7c618d9b73c8ae98aa98992dc1b5425375b1651a3969979e042
5
5
  SHA512:
6
- metadata.gz: d8bb67a9d1a8454846f6a9826ba9b2a2a94c293cb7728d40c6f47e4c44404fd5ed0b6697544ef6cbfa35848a5042e5c00931998b9fc9a2def0e3077cbf235a0f
7
- data.tar.gz: c36c3789e28637e8d6d4d1eee97104e73940716c1d3974ba48d510f648d62dcb22362595a2f7662529e2f216ca2aad809f5e647e651831b46a0158c1083a0f2f
6
+ metadata.gz: 6052c825693cb2864d71207106a13c024683ee1a9035e145420d59263706ae1164a1798bf874a1411a0a3edcb68dbab5343234f38e488179df084d26e0f7176e
7
+ data.tar.gz: 55341ecbc4165e14ce29d08ecc403143ee9ba2025915eadbf2c595f3fd98bec16da8ca71148b958925df92d46623f99002ae6a4209925b073040d69a65b2a0a6
@@ -1,13 +1,43 @@
1
- ## Devel
1
+ ## Version 1.2.1
2
+ * Relax gemspec version requirements: Can now be used with Rails 6.
3
+
4
+ ## Version 1.2
5
+ ### Conditional Visibility
6
+ * The current state of an element with conditional visibility can now be queried with `$(...).data('visible-if-state')`.
7
+
8
+ ## Version 1.1.2
9
+ * Relax gemspec version requirements: Can now be used with Rails 5.
10
+
11
+ ## Version 1.1.1
12
+ * Relax gem version requirement for Sprockets: Can now be used with Sprockets 3.
13
+
14
+ ## Version 1.1.0
15
+ ### Numeric Value
16
+ * The rules for deciding if “german” parsing rules should be used have changed: Instead of only looking at the `lang` attribute of the `<html>` element, now the first `lang` attribute found on the input element itself or any of its parent elements is considered. (This means, that the `lang` attribute of `<html>` will only be used if there are no intermediate elements with different `lang` attributes.)
17
+
18
+ ## Version 1.0.0
19
+ ### Conditional Visibility
20
+ * Breaking: Option `skipAnimations` has been removed. To force re-evaluation of visibilities without animation (e.g. after the DOM has been modified), use `$(...).trigger("setVisibilities")` instead (this is already done automatically on `pageready`.)
21
+ * New option `animate`: Use `$(...).conditionalVisibility({animate: false})` if you want conditional visibility to work completely without animations.
22
+
23
+
24
+ ## Version 0.2.0
2
25
  * Add $.fn.numericValue().
3
26
 
27
+ ### Conditional Visibility
28
+ * Make events triggering visibility re-calculation customizable.
29
+ * After an element is shown / hidden, a `shown.conditionalVisibility` / `hidden.conditionalVisibility` event is triggered.
30
+
31
+
4
32
  ## Version 0.1.0
5
33
  * Add $.fn.conditionalVisibility().
6
34
  * Now requires CoffeeScript.
7
35
 
36
+
8
37
  ## Version 0.0.2
9
38
  * Now supports forms generated by Formtastic.
10
39
  * Return 'this' from formChangeTracker() to make it chainable.
11
40
 
41
+
12
42
  ## Version 0.0.1
13
- * Initial Version
43
+ * Initial Version
@@ -18,10 +18,10 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.add_dependency "railties", ">= 3.1.0", "< 5"
22
- s.add_dependency "sprockets", "~> 2.0"
23
- s.add_dependency "coffee-script", "~> 2.2"
24
-
21
+ s.add_dependency "railties", ">= 3.1.0", "< 7"
22
+ s.add_dependency "sprockets"
23
+ s.add_dependency "coffee-script"
24
+
25
25
  s.add_development_dependency "cucumber", "~> 1.3"
26
26
  s.add_development_dependency "rspec-expectations", "~> 2.7"
27
27
  s.add_development_dependency "sinatra", "~> 1.4"
@@ -35,6 +35,12 @@ Feature: Numeric value of input elements
35
35
  | € 5 | 0 |
36
36
  | | 0 |
37
37
 
38
+ Scenario: Locale specified on the input element directly
39
+ Given the HTML element has a lang attribute set to "de"
40
+ And the element "textfield" has a lang attribute set to "en"
41
+ When I fill in "textfield" with "1,234.56"
42
+ Then the numeric value of "textfield" should be "1234.56"
43
+
38
44
  Scenario: Reading value from non-input elements
39
45
  Then the numeric value of "non_input_element_english" should be "1234.56"
40
46
  Given the HTML element has a lang attribute set to "de"
@@ -2,6 +2,10 @@ Given %r{the HTML element has a lang attribute set to "([^"]*)"$} do |lang|
2
2
  page.execute_script("$('html').attr('lang', '#{lang}')")
3
3
  end
4
4
 
5
+ Given %r{the element "([^"]*)" has a lang attribute set to "([^"]*)"$} do |id, lang|
6
+ page.execute_script("$('##{id}').attr('lang', '#{lang}')")
7
+ end
8
+
5
9
  Then %r{^the numeric value of "([^"]*)" should be "([^"]*)"$} do |input, value|
6
10
  page.evaluate_script("$('##{input}').numericValue()").should be_within(0.0001).of value.to_f
7
11
  end
@@ -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,7 +1,7 @@
1
1
  # Like val(), but return the value parsed as float (or 0, if the value is not numeric). Also works for non-input elements (using the element's text content as value).
2
2
  #
3
3
  # Thousands delimiters (",") are handled correctly.
4
- # German thousands delimiters (".") and separators (",") are handled correctly if the lang attribute of the HTML element is set to "de".
4
+ # German thousands delimiters (".") and separators (",") are handled correctly if the lang attribute of the input element (or any of its parent elements) is set to "de".
5
5
  #
6
6
  # Options:
7
7
  # ignoreCurrencySign: If true, values with leading currency signs (€, $) are considered numeric and parsed correctly.
@@ -9,14 +9,16 @@
9
9
 
10
10
  $.fn.numericValue = (options = {}) ->
11
11
 
12
- delocalize = (val) ->
13
- if $("html").attr("lang") == "de"
12
+ delocalize = (val, locale) ->
13
+ if locale == "de"
14
14
  val.replace(".", "").replace(",", ".")
15
15
  else
16
16
  val.replace(",", "")
17
17
 
18
18
  $this = $(this)
19
- val = delocalize(if $this.is(":input") then $this.val() else $this.text())
19
+ locale = $this.closest("[lang]").attr("lang")
20
+ val = if $this.is(":input") then $this.val() else $this.text()
21
+ val = delocalize(val, locale)
20
22
  val = val.replace(/^\s*[€$]\s*/, "") if options.ignoreCurrencySign
21
23
  if $.isNumeric(val)
22
24
  parseFloat(val)
@@ -1,5 +1,5 @@
1
1
  module Da
2
2
  module Js
3
- VERSION = "1.0.0"
3
+ VERSION = "1.2.1".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.0.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Daschek
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-17 00:00:00.000000000 Z
11
+ date: 2020-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 3.1.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '5'
22
+ version: '7'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,35 +29,35 @@ dependencies:
29
29
  version: 3.1.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '5'
32
+ version: '7'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: sprockets
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '2.0'
39
+ version: '0'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "~>"
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: '2.0'
46
+ version: '0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: coffee-script
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '2.2'
53
+ version: '0'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: '2.2'
60
+ version: '0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: cucumber
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -178,7 +178,7 @@ files:
178
178
  homepage: https://github.com/die-antwort/da-js
179
179
  licenses: []
180
180
  metadata: {}
181
- post_install_message:
181
+ post_install_message:
182
182
  rdoc_options: []
183
183
  require_paths:
184
184
  - lib
@@ -194,8 +194,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
194
  version: '0'
195
195
  requirements: []
196
196
  rubyforge_project: da-js
197
- rubygems_version: 2.2.2
198
- signing_key:
197
+ rubygems_version: 2.7.6.2
198
+ signing_key:
199
199
  specification_version: 4
200
200
  summary: Mixed jQuery extensions
201
201
  test_files: