effective_bootstrap 0.3.17 → 0.3.18
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/app/assets/javascripts/effective_bootstrap.js +1 -0
- data/app/assets/javascripts/effective_bootstrap/form.js.coffee +14 -6
- data/app/assets/javascripts/effective_number_text/initialize.js.coffee +6 -0
- data/app/assets/javascripts/effective_number_text/input.js +1 -0
- data/app/assets/javascripts/effective_select_or_text/initialize.js +8 -5
- data/app/models/effective/form_builder.rb +4 -0
- data/app/models/effective/form_inputs/number_text_field.rb +15 -0
- data/app/models/effective/form_inputs/select_or_text.rb +14 -6
- data/lib/effective_bootstrap/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ccfe6cf9b10dafad917ac4e6311f0fb4eec24e8
|
4
|
+
data.tar.gz: c8efb6470623663cfba0197533373f9608c8a8f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c80e53176e6f7e849d37c4f306119b598f3f5671249717876b9043d4954a84eb9817beae3d61ba3da9e04853ddb6a180b2624c2685354694437741fac4733e7
|
7
|
+
data.tar.gz: 9c0d9b638d3c5d643b3cc4a30a33eb144ba2c1ba0ec39560031b003b26e68a85698c9e6717fb0a21b3ae9563cd039b1273d56d5aaf5bd5e432cfc3276290a690
|
@@ -10,6 +10,7 @@
|
|
10
10
|
//= require ./effective_checks/input
|
11
11
|
//= require ./effective_editor/input
|
12
12
|
//= require ./effective_file/input
|
13
|
+
//= require ./effective_number_text/input
|
13
14
|
//= require ./effective_percent/input
|
14
15
|
//= require ./effective_phone/input
|
15
16
|
//= require ./effective_price/input
|
@@ -85,14 +85,22 @@ this.EffectiveForm ||= new class
|
|
85
85
|
@current_submit = $form.find("##{@current_submit.attr('id')}.form-actions")
|
86
86
|
|
87
87
|
# Process Flash
|
88
|
+
flash_status = ''
|
89
|
+
flash_message = ''
|
90
|
+
|
88
91
|
if @remote_form_flash.length > 0
|
89
|
-
@
|
90
|
-
|
91
|
-
|
92
|
-
|
92
|
+
flash_status = @remote_form_flash[0][0]
|
93
|
+
flash_message = @remote_form_flash[0][1]
|
94
|
+
|
95
|
+
@flash($form, flash_status, flash_message, true)
|
96
|
+
|
97
|
+
# Fire off form events
|
98
|
+
was_error = ($form.hasClass('with-errors') || flash_status == 'danger' || flash_status == 'error')
|
99
|
+
|
100
|
+
$form.trigger((if was_error then 'effective-form:error' else 'effective-form:success'), flash_message)
|
101
|
+
$form.trigger('effective-form:complete', flash_message, was_error)
|
93
102
|
|
94
|
-
|
95
|
-
$form.trigger('effective-form:complete')
|
103
|
+
@remote_form_flash = ''
|
96
104
|
true
|
97
105
|
|
98
106
|
flash: ($form, status, message, skip_success = false) ->
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# Prevent non-currency buttons from being pressed
|
2
|
+
$(document).on 'keydown', "input[type='text'].effective_number_text", (event) ->
|
3
|
+
allowed = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', ',', '.']
|
4
|
+
|
5
|
+
if event.key && event.key.length == 1 && event.metaKey == false && allowed.indexOf(event.key) == -1
|
6
|
+
event.preventDefault()
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require ./initialize
|
@@ -13,15 +13,18 @@ $(document).on('click', '[data-effective-select-or-text]', function(event) {
|
|
13
13
|
$visible = $obj.children('.form-group:visible').first();
|
14
14
|
$hidden = $obj.children('.form-group:not(:visible)').first();
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
$visible_input = $visible.find('input,textarea,select').first()
|
17
|
+
$hidden_input = $hidden.find('input,textarea,select').first()
|
18
18
|
|
19
|
-
|
19
|
+
required = $visible_input.prop('required') || $hidden_input.prop('required')
|
20
|
+
|
21
|
+
$hidden_input.prop('required', required)
|
22
|
+
$visible_input.removeAttr('required')
|
20
23
|
|
21
24
|
$visible.fadeOut('fast', function() {
|
22
|
-
|
23
|
-
$hidden.fadeIn('fast');
|
25
|
+
$hidden.prop('required', required).detach().insertAfter($visible).fadeIn('fast');
|
24
26
|
});
|
25
27
|
|
26
28
|
return false; // This implicitly calls event.preventDefault() to cancel the action, and prevent the link from going somewhere.
|
27
29
|
});
|
30
|
+
|
@@ -82,6 +82,10 @@ module Effective
|
|
82
82
|
Effective::FormInputs::NumberField.new(name, options, builder: self).to_html { super(name, options) }
|
83
83
|
end
|
84
84
|
|
85
|
+
def number_text_field(name, options = {})
|
86
|
+
Effective::FormInputs::NumberTextField.new(name, options, builder: self).to_html
|
87
|
+
end
|
88
|
+
|
85
89
|
def password_field(name, options = {})
|
86
90
|
Effective::FormInputs::PasswordField.new(name, options, builder: self).to_html { super(name, options) }
|
87
91
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Effective
|
2
|
+
module FormInputs
|
3
|
+
class NumberTextField < Effective::FormInput
|
4
|
+
|
5
|
+
def build_input(&block)
|
6
|
+
@builder.super_text_field(name, options[:input])
|
7
|
+
end
|
8
|
+
|
9
|
+
def input_html_options
|
10
|
+
{ class: 'form-control effective_number_text', autocomplete: 'off' }
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -7,7 +7,7 @@ module Effective
|
|
7
7
|
attr_accessor :text_options
|
8
8
|
|
9
9
|
VISIBLE = {}
|
10
|
-
|
10
|
+
HIDDEN = { wrapper: { style: 'display: none;' } }
|
11
11
|
|
12
12
|
def initialize(name, options, builder:)
|
13
13
|
@name_text = options.delete(:name_text) || raise('Please include a text method name')
|
@@ -26,8 +26,13 @@ module Effective
|
|
26
26
|
|
27
27
|
def to_html(&block)
|
28
28
|
content_tag(:div, class: 'effective-select-or-text') do
|
29
|
-
|
30
|
-
|
29
|
+
if select?
|
30
|
+
@builder.send(email_field? ? :email_field : :text_field, name_text, text_options) +
|
31
|
+
@builder.select(name, select_collection, select_options)
|
32
|
+
else
|
33
|
+
@builder.select(name, select_collection, select_options) +
|
34
|
+
@builder.send(email_field? ? :email_field : :text_field, name_text, text_options)
|
35
|
+
end +
|
31
36
|
link_to(icon('rotate-ccw'), '#', class: 'effective-select-or-text-switch', title: 'Switch between choice and freeform', 'data-effective-select-or-text': true)
|
32
37
|
end
|
33
38
|
end
|
@@ -38,7 +43,10 @@ module Effective
|
|
38
43
|
|
39
44
|
value = object.send(name)
|
40
45
|
|
41
|
-
(value.present? && select_collection.include?(value))
|
46
|
+
return true if (value.present? && select_collection.include?(value))
|
47
|
+
return true if (value.to_i > 0 && select_collection.find { |obj| obj.respond_to?(:id) && obj.id == value.to_i })
|
48
|
+
|
49
|
+
return true if value.blank? && object.send(name_text).blank?
|
42
50
|
end
|
43
51
|
|
44
52
|
def text?
|
@@ -50,11 +58,11 @@ module Effective
|
|
50
58
|
end
|
51
59
|
|
52
60
|
def select_options
|
53
|
-
@select_options.merge(select? ? VISIBLE :
|
61
|
+
@select_options.merge(select? ? VISIBLE : HIDDEN)
|
54
62
|
end
|
55
63
|
|
56
64
|
def text_options
|
57
|
-
@text_options.merge(text? ? VISIBLE :
|
65
|
+
@text_options.merge(text? ? VISIBLE : HIDDEN)
|
58
66
|
end
|
59
67
|
|
60
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -388,6 +388,8 @@ files:
|
|
388
388
|
- app/assets/javascripts/effective_editor/quill.js
|
389
389
|
- app/assets/javascripts/effective_file/initialize.js.coffee
|
390
390
|
- app/assets/javascripts/effective_file/input.js
|
391
|
+
- app/assets/javascripts/effective_number_text/initialize.js.coffee
|
392
|
+
- app/assets/javascripts/effective_number_text/input.js
|
391
393
|
- app/assets/javascripts/effective_percent/initialize.js.coffee
|
392
394
|
- app/assets/javascripts/effective_percent/input.js
|
393
395
|
- app/assets/javascripts/effective_phone/initialize.js.coffee
|
@@ -448,6 +450,7 @@ files:
|
|
448
450
|
- app/models/effective/form_inputs/float_field.rb
|
449
451
|
- app/models/effective/form_inputs/form_group.rb
|
450
452
|
- app/models/effective/form_inputs/number_field.rb
|
453
|
+
- app/models/effective/form_inputs/number_text_field.rb
|
451
454
|
- app/models/effective/form_inputs/password_field.rb
|
452
455
|
- app/models/effective/form_inputs/percent_field.rb
|
453
456
|
- app/models/effective/form_inputs/phone_field.rb
|