da-js 1.2.1 → 1.3

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
  SHA256:
3
- metadata.gz: 3ce2526b33932c7db329c1ba4cea698420694b9752a608b7471501379531be6a
4
- data.tar.gz: 4c189b4f3a79d7c618d9b73c8ae98aa98992dc1b5425375b1651a3969979e042
3
+ metadata.gz: 297d35e3613edee0251be3530d2d5d5d22fe2d94a87d39b0e074a5321799fe28
4
+ data.tar.gz: 685474146d93ba5bc47c580e266808aae53d00e4ddfbc7c9074f96e14af95c12
5
5
  SHA512:
6
- metadata.gz: 6052c825693cb2864d71207106a13c024683ee1a9035e145420d59263706ae1164a1798bf874a1411a0a3edcb68dbab5343234f38e488179df084d26e0f7176e
7
- data.tar.gz: 55341ecbc4165e14ce29d08ecc403143ee9ba2025915eadbf2c595f3fd98bec16da8ca71148b958925df92d46623f99002ae6a4209925b073040d69a65b2a0a6
6
+ metadata.gz: 6e11b743b1a5ce9e4ad29e05e7500d6816137b48563448c0e8ca98ba195ef68dbf149173ef026518e3128ac7e6b83543a23994bd605b577266758cfd3fde714a
7
+ data.tar.gz: 5668570bda4bde3f9e1bcb522c0d2e4c9a97669c89cb344f3ca0b95d9094937c89cb68850be37323e992c7089995ead6ea0bc0404bb41c058dd843d716c2ec17
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## Version 1.3
2
+ ### Conditional Visibility
3
+ * After visibility has been recalculated for all elememtn, a `updated.conditionalVisibility` event is triggered.
4
+
1
5
  ## Version 1.2.1
2
6
  * Relax gemspec version requirements: Can now be used with Rails 6.
3
7
 
data/Rakefile CHANGED
@@ -1,8 +1 @@
1
1
  require "bundler/gem_tasks"
2
-
3
- require 'cucumber'
4
- require 'cucumber/rake/task'
5
-
6
- Cucumber::Rake::Task.new(:test) do |t|
7
- t.cucumber_opts = "features --format progress"
8
- end
data/da-js.gemspec CHANGED
@@ -18,14 +18,7 @@ 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", "< 7"
21
+ s.add_dependency "railties", ">= 3.1.0"
22
22
  s.add_dependency "sprockets"
23
23
  s.add_dependency "coffee-script"
24
-
25
- s.add_development_dependency "cucumber", "~> 1.3"
26
- s.add_development_dependency "rspec-expectations", "~> 2.7"
27
- s.add_development_dependency "sinatra", "~> 1.4"
28
- s.add_development_dependency "sinatra-contrib"
29
- s.add_development_dependency "capybara-webkit", "~> 1.3"
30
- s.add_development_dependency "launchy"
31
24
  end
@@ -1,40 +1,40 @@
1
1
  # Hide/show elements dynamically according to their `data-visible-if` attribute.
2
2
  #
3
3
  # All elements with a `data-visible-if` attribute are checked on change, focusout and click events:
4
- # For each element, the content of its `data-visible-if` attribute is eval'd. If the eval'd code
4
+ # For each element, the content of its `data-visible-if` attribute is eval'd. If the eval'd code
5
5
  # returns true, the element is shown – otherwise it is hidden. (The attribute must contain valid
6
6
  # JavaScript code.)
7
7
  #
8
- # Use `$("body").conditionalVisibility()` to enable the functionality for the whole document,
9
- # or use a more specific selector to enable it only for some elements.
8
+ # Use `$("body").conditionalVisibility()` to enable the functionality for the whole document,
9
+ # or use a more specific selector to enable it only for some elements.
10
10
  #
11
11
  # The following options can be specified when initializing the plugin:
12
- #
13
- # - `events`: The events which should trigger re-evaluation of visibilities (default:
12
+ #
13
+ # - `events`: The events which should trigger re-evaluation of visibilities (default:
14
14
  # `"change focusout click"`)
15
15
  #
16
16
  # - `animate`: If elements should be shown/hidden using animations (default: `true`).
17
- #
17
+ #
18
18
  # There are two ways to manually force re-evaluation of visibilities:
19
19
  #
20
20
  # - `$(…).trigger("updateVisibilities")` updates visibilities (using animations) and then triggers
21
21
  # `shown.conditionalVisibility` / `hidden.conditionalVisibility` events accordingly.
22
- #
23
- # - `$(…).trigger("setVisibilities")` sets visibilities directly (no animations, does not trigger
22
+ #
23
+ # - `$(…).trigger("setVisibilities")` sets visibilities directly (no animations, does not trigger
24
24
  # custom events). This is already called automatically on pageready. You may want to call this
25
- # manually after new elements have been added to the DOM (eg a modal with content fetched via
25
+ # manually after new elements have been added to the DOM (eg a modal with content fetched via
26
26
  # ajax).
27
- #
28
- # The current state of an element with conditional visibility can be queried using
27
+ #
28
+ # The current state of an element with conditional visibility can be queried using
29
29
  # `$(...).data('visible-if-state')`, which returns either `'visible'` or `'hidden'`. This differs
30
30
  # from using jQuery’s `:visible` or `:hidden` pseude-selectors on the element in that it has
31
31
  # immediate effect, even if animations are used: When an element changes from being visible to being
32
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
33
+ # `data('visible-if-state')` will return `'hidden'` immediately after the evaluation of the
34
34
  # visibility condition.
35
35
  #
36
36
  # Example:
37
- #
37
+ #
38
38
  # <form id="myform">
39
39
  # <input id="checkbox" type="checkbox" >
40
40
  # <input id="text" data-visible-if="$('#checkbox')[0].checked">
@@ -44,12 +44,12 @@
44
44
  # </script>
45
45
 
46
46
  $.fn.conditionalVisibility = (options = {}) ->
47
- defaults =
47
+ defaults =
48
48
  animate: true
49
49
  events: "change focusout click"
50
-
50
+
51
51
  options = $.extend({}, defaults, options)
52
-
52
+
53
53
  updateVisibilities = (event) ->
54
54
  $(this).find("[data-visible-if]").each ->
55
55
  $this = $(this)
@@ -58,22 +58,21 @@ $.fn.conditionalVisibility = (options = {}) ->
58
58
  if $this.is(":hidden")
59
59
  if options.animate then $this.slideDown(100) else $this.show()
60
60
  $this.promise().done -> $this.trigger("shown.conditionalVisibility")
61
- else
61
+ else
62
62
  $(this).data("visible-if-state", "hidden")
63
63
  if $this.is(":visible")
64
64
  if options.animate then $this.slideUp(100) else $this.hide()
65
65
  $this.promise().done -> $this.trigger("hidden.conditionalVisibility")
66
-
66
+ $(this).trigger("updated.conditionalVisibility")
67
+
67
68
  setVisibilities = (event) ->
68
69
  $(this).find("[data-visible-if]").each ->
69
70
  $this = $(this)
70
71
  isVisible = !!eval($this.data("visible-if"))
71
72
  $(this).data("visible-if-state", if isVisible then "visible" else "hidden")
72
73
  $this.toggle isVisible
73
-
74
+
74
75
  this
75
76
  .on "#{options.events} updateVisibilities", updateVisibilities
76
77
  .on "setVisibilities", setVisibilities
77
78
  .trigger "setVisibilities"
78
-
79
-
@@ -1,15 +1,15 @@
1
1
  (function( $ ) {
2
2
  // Track changes to form fields accordingly set/reset CSS class "changed".
3
3
  //
4
- // Usage:
4
+ // Usage:
5
5
  // $("#myform").formChangeTracker();
6
6
  //
7
7
  // If the form element is wrapped in an element with the class "field" (rails scaffold) or "input" (formtastic), the class "changed" is set/reset on this wrapper element. Otherwise, "changed" is set/reset on the form element itself and its label (if present).
8
-
8
+
9
9
  $.fn.formChangeTracker = function() {
10
10
 
11
11
  var elementSelector = "input[type!=hidden],textarea,select";
12
-
12
+
13
13
  return this.each(function() {
14
14
 
15
15
  var form = $(this);
@@ -26,7 +26,7 @@
26
26
  if (element.type == "checkbox" || element.type == "radio") return element.checked;
27
27
  return $(element).val();
28
28
  }
29
-
29
+
30
30
  function updateStatus(event, ignoreOtherRadiobuttons) {
31
31
  var targets = targetsForElement(this);
32
32
 
@@ -35,7 +35,7 @@
35
35
  } else {
36
36
  targets.removeClass('changed');
37
37
  }
38
-
38
+
39
39
  // For radiobuttons, if there is no container, also update all other radiobuttons of the same group
40
40
  if (this.type == "radio" && !ignoreOtherRadiobuttons && targets.index(this) != -1) {
41
41
  form.find("input[type=radio][name='" + this.name + "']").each(function() {
@@ -47,15 +47,15 @@
47
47
  function elementHasChanged(element) {
48
48
  return valueFor(element) !== $(element).data("initialValue");
49
49
  }
50
-
50
+
51
51
  // Return the element(s) on that the "changed" class should be set/removed.
52
52
  function targetsForElement(element) {
53
53
  // use wrapping element with class .field or .input (formtastic) if present ...
54
54
  var targets = $(element).closest("form .field, form .input");
55
-
55
+
56
56
  // ... or fallback to the form element itself (and its label)
57
57
  if (targets.length == 0) targets = $(element).add("label[for=" + element.id + "]");
58
-
58
+
59
59
  return targets;
60
60
  }
61
61
 
@@ -1,6 +1,6 @@
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
- # Thousands delimiters (",") are handled correctly.
3
+ # Thousands delimiters (",") are handled correctly.
4
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:
@@ -8,13 +8,13 @@
8
8
  # nullOnError: If true, null is returned (instead of 0) if the value is not numeric.
9
9
 
10
10
  $.fn.numericValue = (options = {}) ->
11
-
11
+
12
12
  delocalize = (val, locale) ->
13
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
20
  val = if $this.is(":input") then $this.val() else $this.text()
@@ -1 +1 @@
1
- //= require_tree ./da-js
1
+ //= require_tree ./da-js
data/lib/da-js/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Da
2
2
  module Js
3
- VERSION = "1.2.1".freeze
3
+ VERSION = "1.3".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.2.1
4
+ version: '1.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Daschek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-11 00:00:00.000000000 Z
11
+ date: 2024-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -17,9 +17,6 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.1.0
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '7'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,9 +24,6 @@ dependencies:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 3.1.0
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '7'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: sprockets
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,90 +52,6 @@ dependencies:
58
52
  - - ">="
59
53
  - !ruby/object:Gem::Version
60
54
  version: '0'
61
- - !ruby/object:Gem::Dependency
62
- name: cucumber
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '1.3'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '1.3'
75
- - !ruby/object:Gem::Dependency
76
- name: rspec-expectations
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '2.7'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '2.7'
89
- - !ruby/object:Gem::Dependency
90
- name: sinatra
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '1.4'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: '1.4'
103
- - !ruby/object:Gem::Dependency
104
- name: sinatra-contrib
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: '0'
117
- - !ruby/object:Gem::Dependency
118
- name: capybara-webkit
119
- requirement: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - "~>"
122
- - !ruby/object:Gem::Version
123
- version: '1.3'
124
- type: :development
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - "~>"
129
- - !ruby/object:Gem::Version
130
- version: '1.3'
131
- - !ruby/object:Gem::Dependency
132
- name: launchy
133
- requirement: !ruby/object:Gem::Requirement
134
- requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- version: '0'
138
- type: :development
139
- prerelease: false
140
- version_requirements: !ruby/object:Gem::Requirement
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: '0'
145
55
  description: Some jQuery extensions we tend to use in almost all our projects.
146
56
  email:
147
57
  - stefan@die-antwort.eu
@@ -155,20 +65,6 @@ files:
155
65
  - README.md
156
66
  - Rakefile
157
67
  - da-js.gemspec
158
- - features/change_tracker.feature
159
- - features/conditional_visibility.feature
160
- - features/numeric_value.feature
161
- - features/step_definitions/change_tracker_steps.rb
162
- - features/step_definitions/conditional_visibility_steps.rb
163
- - features/step_definitions/numeric_value_steps.rb
164
- - features/step_definitions/shared_steps.rb
165
- - features/support/env.rb
166
- - features/support/testapp/config.ru
167
- - features/support/testapp/testapp.rb
168
- - features/support/testapp/vendor/jquery-1.11.1.js
169
- - features/support/testapp/views/conditional_visibility.erb
170
- - features/support/testapp/views/form_change_tracker.erb
171
- - features/support/testapp/views/numeric_value.erb
172
68
  - lib/assets/javascripts/da-js.js
173
69
  - lib/assets/javascripts/da-js/conditional_visibility.js.coffee
174
70
  - lib/assets/javascripts/da-js/form_change_tracker.js
@@ -193,23 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
89
  - !ruby/object:Gem::Version
194
90
  version: '0'
195
91
  requirements: []
196
- rubyforge_project: da-js
197
- rubygems_version: 2.7.6.2
92
+ rubygems_version: 3.1.6
198
93
  signing_key:
199
94
  specification_version: 4
200
95
  summary: Mixed jQuery extensions
201
- test_files:
202
- - features/change_tracker.feature
203
- - features/conditional_visibility.feature
204
- - features/numeric_value.feature
205
- - features/step_definitions/change_tracker_steps.rb
206
- - features/step_definitions/conditional_visibility_steps.rb
207
- - features/step_definitions/numeric_value_steps.rb
208
- - features/step_definitions/shared_steps.rb
209
- - features/support/env.rb
210
- - features/support/testapp/config.ru
211
- - features/support/testapp/testapp.rb
212
- - features/support/testapp/vendor/jquery-1.11.1.js
213
- - features/support/testapp/views/conditional_visibility.erb
214
- - features/support/testapp/views/form_change_tracker.erb
215
- - features/support/testapp/views/numeric_value.erb
96
+ test_files: []
@@ -1,125 +0,0 @@
1
- @javascript
2
- Feature: Change tracker for forms
3
- There are two special cases:
4
- - A select has always a selected option. We use the first option (with empty value) as "empty".
5
- - All radiobuttons can initially be unselected, but going back to this state is impossible. So, in the "empty form" scenario, we skip the radiobutton in second part (when we test "resetting" the form elements)
6
-
7
- Scenario Outline: An empty form
8
- Given an empty <Form>
9
- Then no <Element> should be marked as changed
10
-
11
- When I enter some text in the textfield
12
- Then the textfield's <Element> should be marked as changed
13
-
14
- When I enter some text in the textarea
15
- Then the textarea's <Element> should be marked as changed
16
-
17
- When I check the checkbox
18
- Then the checkbox's <Element> should be marked as changed
19
-
20
- When I select the first option
21
- Then the select's <Element> should be marked as changed
22
-
23
- # Now for resetting everything (except radiobuttons, see feature description)
24
- When I clear the textfield
25
- Then the textfield's <Element> should no longer be marked as changed
26
-
27
- When I clear the textarea
28
- Then the textarea's <Element> should no longer be marked as changed
29
-
30
- When I uncheck the checkbox
31
- Then the checkbox's <Element> should no longer be marked as changed
32
-
33
- When I select the empty option
34
- Then the select's <Element> should no longer be marked as changed
35
-
36
- Examples:
37
- | Form | Element |
38
- | simple_form | form element and label |
39
- | scaffold_form | field container |
40
- | formtastic | field container |
41
-
42
-
43
- Scenario: Radiobuttons in an empty simple form
44
- Given an empty simple_form
45
- When I choose the first radiobutton
46
- Then the first radiobutton's form element and label should be marked as changed
47
- But the second radiobutton's form element and label should not be marked as changed
48
- And the third radiobutton's form element and label should not be marked as changed
49
-
50
-
51
- Scenario: Radiobuttons in an empty scaffold form
52
- Given an empty scaffold_form
53
- When I choose the first radiobutton
54
- Then the first radiobutton's field container should be marked as changed
55
-
56
-
57
- Scenario Outline: A prefilled form
58
- Given a prefilled <Form>
59
- Then no <Element> should be marked as changed
60
-
61
- When I change the textfield's content
62
- Then the textfield's <Element> should be marked as changed
63
- When I clear the textfield
64
- Then the textfield's <Element> should be marked as changed
65
-
66
- When I change the textarea's content
67
- Then the textarea's <Element> should be marked as changed
68
- When I clear the textarea
69
- Then the textarea's <Element> should be marked as changed
70
-
71
- When I uncheck the checkbox
72
- Then the checkbox's <Element> should be marked as changed
73
-
74
- When I select the second option
75
- Then the select's <Element> should be marked as changed
76
-
77
- # Now reset everything again
78
- When I reset the textfield to its initial value
79
- Then the textfield's <Element> should no longer be marked as changed
80
-
81
- When I reset the textarea to its initial value
82
- Then the textarea's <Element> should no longer be marked as changed
83
-
84
- When I check the checkbox
85
- Then the checkbox's <Element> should no longer be marked as changed
86
-
87
- When I select the first option
88
- Then the select's <Element> should no longer be marked as changed
89
-
90
- And no <Element> should be marked as changed
91
-
92
- Examples:
93
- | Form | Element |
94
- | simple_form | form element and label |
95
- | scaffold_form | field container |
96
- | formtastic | field container |
97
-
98
-
99
- Scenario: Radiobuttons in an prefilled simple form
100
- Given an prefilled simple_form
101
- Then no form element and label should be marked as changed
102
-
103
- When I choose the second radiobutton
104
- Then the second radiobutton's form element and label should be marked as changed
105
- And the first radiobutton's form element and label should be marked as changed
106
- But the third radiobutton's form element and label should not be marked as changed
107
-
108
- When I choose the first radiobutton
109
- Then no form element and label should be marked as changed
110
-
111
-
112
- Scenario Outline: Radiobuttons in an prefilled form
113
- Given an prefilled <Form>
114
- Then no form element and label should be marked as changed
115
-
116
- When I choose the second radiobutton
117
- Then the second radiobutton's field container should be marked as changed
118
-
119
- When I choose the first radiobutton
120
- Then no form element and label should be marked as changed
121
-
122
- Examples:
123
- | Form |
124
- | scaffold_form |
125
- | formtastic |
@@ -1,55 +0,0 @@
1
- @javascript
2
- Feature: Conditional visibility for elements
3
-
4
- Background:
5
- Given I visit the test page for "conditional visibility"
6
-
7
- Scenario: Basic functionality
8
- Then the "Other Country" input should be hidden
9
- But the "Message" input should be visible
10
-
11
- When I select "Other …" from the "Country" select
12
- Then the "Other Country" input should be visible
13
-
14
- When I uncheck the "I want to leave a message" checkbox
15
- Then the "Message" input should be hidden
16
-
17
- When I select "Austria" from the "Country" select
18
- Then the "Other Country" input should be hidden
19
-
20
- When I check the "I want to leave a message" checkbox
21
- Then the "Message" input should be visible
22
-
23
- Scenario: Changing a field value via javascript and triggering the event manually
24
- When I set the "I want to leave a message" checkbox to unchecked using JavaScript
25
- Then the "Message" input should be visible
26
-
27
- When I trigger the "updateVisibilities" event on the form
28
- Then the "Message" input should be hidden
29
-
30
-
31
- Scenario: Manually configuring events triggering visibility re-calculations
32
- # Assert default behaviour first
33
- When I enter "foo" in the "amount" field
34
- Then the "#amount_info" element should be hidden
35
- When I blur the "amount" field
36
- Then the "#amount_info" element should be visible
37
-
38
- Given I visit the test page for "conditional visibility" with options "{events: 'keypress'}"
39
- Then the "#amount_info" element should be hidden
40
- When I enter "foo" in the "amount" field
41
- Then the "#amount_info" element should be visible
42
-
43
-
44
- Scenario: Using the triggered events
45
- Given I bind an event listener to "shown.conditionalVisibility"
46
- And I bind an event listener to "hidden.conditionalVisibility"
47
- When I select "Other …" from the "Country" select
48
- Then the event listener for "shown.conditionalVisibility" should have been called "1" time
49
- And the event listener for "hidden.conditionalVisibility" should have been called "0" times
50
- When I select "Austria" from the "Country" select
51
- Then the event listener for "shown.conditionalVisibility" should have been called "1" times
52
- And the event listener for "hidden.conditionalVisibility" should have been called "1" times
53
-
54
-
55
-
@@ -1,66 +0,0 @@
1
- @javascript
2
- Feature: Numeric value of input elements
3
-
4
- Background:
5
- Given I visit the test page for "numeric value"
6
-
7
- Scenario Outline: English locale
8
- When I fill in "textfield" with "<String>"
9
- Then the numeric value of "textfield" should be "<Value>"
10
-
11
- Examples:
12
- | String | Value |
13
- | 1 | 1 |
14
- | 1.2 | 1.2 |
15
- | 1234.56 | 1234.56 |
16
- | 1,234.56 | 1234.56 |
17
- | 1,234 | 1234 |
18
- | abc | 0 |
19
- | $ 3 | 0 |
20
- | | 0 |
21
-
22
- Scenario Outline: German locale
23
- Given the HTML element has a lang attribute set to "de"
24
- When I fill in "textfield" with "<String>"
25
- Then the numeric value of "textfield" should be "<Value>"
26
-
27
- Examples:
28
- | String | Value |
29
- | 1 | 1 |
30
- | 1,2 | 1.2 |
31
- | 1234,56 | 1234.56 |
32
- | 1.234,56 | 1234.56 |
33
- | 1.234 | 1234 |
34
- | abc | 0 |
35
- | € 5 | 0 |
36
- | | 0 |
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
-
44
- Scenario: Reading value from non-input elements
45
- Then the numeric value of "non_input_element_english" should be "1234.56"
46
- Given the HTML element has a lang attribute set to "de"
47
- Then the numeric value of "non_input_element_german" should be "5678.9"
48
-
49
- Scenario Outline: Ignoring the currency sign
50
- When I fill in "textfield" with "<String>"
51
- Then the numeric value (ignoring currency sign) of "textfield" should be "<Value>"
52
- Examples:
53
- | String | Value |
54
- | € 1 | 1 |
55
- | $123.45 | 123.45 |
56
- | $$ 3 | 0 |
57
- | €$ 7 | 0 |
58
-
59
- Scenario Outline: Using `nullOnError`
60
- When I fill in "textfield" with "<String>"
61
- Then the numeric value (using `nullOnError: true`) of "textfield" should be "<Value>"
62
- Examples:
63
- | String | Value |
64
- | 1,234 | 1234 |
65
- | abc | null |
66
- | € 5 | null |