da-js 1.0.0 → 1.1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 848ee36d4c3ddd09e76b54b23a45d689312ba9bc
|
4
|
+
data.tar.gz: 696747aae61f3806190d459d9c085273a852820a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 916271a3fdfb0c8273da35a30703e793bf555712ec8f27e1e1220f97f70895a66b48e85fb0179ea53f50454c822cb4e7ad72cc372f86e194f6e9f9b12582f47b
|
7
|
+
data.tar.gz: 346e53ba409248f4eefb8d4cc5ca4ff015213393eb0a6dc5d8bc8a90879faf3b162f8caf550e290e4fe0aa49886c813d0ed3d6dba2ac193f1898e64df803886e
|
data/CHANGELOG.md
CHANGED
@@ -1,13 +1,30 @@
|
|
1
|
-
##
|
1
|
+
## Version 1.1.0
|
2
|
+
## Numeric Value
|
3
|
+
* 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.)
|
4
|
+
|
5
|
+
## Version 1.0.0
|
6
|
+
### Conditional Visibility
|
7
|
+
* 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`.)
|
8
|
+
* New option `animate`: Use `$(...).conditionalVisibility({animate: false})` if you want conditional visibility to work completely without animations.
|
9
|
+
|
10
|
+
|
11
|
+
## Version 0.2.0
|
2
12
|
* Add $.fn.numericValue().
|
3
13
|
|
14
|
+
### Conditional Visibility
|
15
|
+
* Make events triggering visibility re-calculation customizable.
|
16
|
+
* After an element is shown / hidden, a `shown.conditionalVisibility` / `hidden.conditionalVisibility` event is triggered.
|
17
|
+
|
18
|
+
|
4
19
|
## Version 0.1.0
|
5
20
|
* Add $.fn.conditionalVisibility().
|
6
21
|
* Now requires CoffeeScript.
|
7
22
|
|
23
|
+
|
8
24
|
## Version 0.0.2
|
9
25
|
* Now supports forms generated by Formtastic.
|
10
26
|
* Return 'this' from formChangeTracker() to make it chainable.
|
11
27
|
|
28
|
+
|
12
29
|
## Version 0.0.1
|
13
30
|
* Initial Version
|
@@ -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
|
@@ -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
|
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
|
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
|
-
|
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)
|
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.1.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: 2015-12-21 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.2.
|
197
|
+
rubygems_version: 2.2.3
|
198
198
|
signing_key:
|
199
199
|
specification_version: 4
|
200
200
|
summary: Mixed jQuery extensions
|