effective_bootstrap 0.6.8 → 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/effective_bootstrap.js +1 -0
- data/app/assets/javascripts/effective_bootstrap/form.js.coffee +14 -1
- data/app/assets/javascripts/effective_clear/initialize.js.coffee +3 -0
- data/app/assets/javascripts/effective_clear/input.js +1 -0
- data/app/assets/javascripts/effective_select/overrides.js.coffee +0 -3
- data/app/models/effective/form_builder.rb +5 -0
- data/app/models/effective/form_inputs/clear.rb +22 -0
- data/lib/effective_bootstrap/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 778db97c3c4d202f8c98dab753ec0197d7a52bdcf3036ba1a15524bcc8a21cda
|
4
|
+
data.tar.gz: 94e9bcac5645082563a17cac8b3a3877d8dca1ae7b28608fd8e5c6ec4ba3f6b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92b23a5a7f43a5ca4e954198ee1d6dc44ba7d24d5a9811a89970bd60ae1066ae0c45ababdb45a9e74eeaad37b4cbf3a5823ea9484c39a978fd26e91d5d939bbe
|
7
|
+
data.tar.gz: 4366f548362edd9cfec2de37cb36e6edf7d46064541b7bdb3407f427afe4989ca98d7080c1815978f10031c18b50680dff8f6336f3d7800fe7f66ceac181fadb
|
@@ -50,6 +50,12 @@ this.EffectiveForm ||= new class
|
|
50
50
|
$form.find('[type=submit]').removeAttr('disabled')
|
51
51
|
$form
|
52
52
|
|
53
|
+
clear: ($form) ->
|
54
|
+
$form.find('input').not(':button, :submit, :reset, :hidden, :checkbox, :radio').val('')
|
55
|
+
$form.find('textarea').val('')
|
56
|
+
$form.find('select').val('').trigger('change.select2')
|
57
|
+
$form.find('input[type=checkbox],input[type=radio]').prop('checked', false).trigger('change')
|
58
|
+
|
53
59
|
spin: -> @current_submit.addClass('form-current-submit') if @current_submit.length > 0
|
54
60
|
|
55
61
|
beforeAjax: ($form) ->
|
@@ -165,5 +171,12 @@ $(document).on 'ajax:beforeSend', '[data-method=delete]', (event) ->
|
|
165
171
|
if ($delete = $(@)).data('closest')
|
166
172
|
EffectiveForm.setCurrentDelete($delete.closest($delete.data('closest')))
|
167
173
|
|
174
|
+
# Clear
|
168
175
|
$(document).on 'reset', 'form', (event) ->
|
169
|
-
|
176
|
+
$form = $(event.currentTarget)
|
177
|
+
EffectiveForm.reset($form)
|
178
|
+
|
179
|
+
$(document).on 'clear', 'form', (event) ->
|
180
|
+
$form = $(event.currentTarget)
|
181
|
+
EffectiveForm.reset($form)
|
182
|
+
setTimeout -> EffectiveForm.clear($form)
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require ./initialize
|
@@ -21,6 +21,11 @@ module Effective
|
|
21
21
|
alias_method :super_text_field, :text_field
|
22
22
|
alias_method :super_text_area, :text_area
|
23
23
|
|
24
|
+
def clear(name = 'Clear', options = {})
|
25
|
+
(options = name; name = 'Clear') if name.kind_of?(Hash)
|
26
|
+
Effective::FormInputs::Clear.new(name, options, builder: self).to_html
|
27
|
+
end
|
28
|
+
|
24
29
|
def check_box(name, options = {})
|
25
30
|
Effective::FormInputs::CheckBox.new(name, options, builder: self).to_html {
|
26
31
|
checked_value = options.fetch(:checked_value, '1')
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Effective
|
2
|
+
module FormInputs
|
3
|
+
class Clear < Effective::FormInput
|
4
|
+
|
5
|
+
def to_html(&block)
|
6
|
+
content_tag(:button, options[:input]) do
|
7
|
+
icon_name.present? ? (icon(icon_name) + name) : name
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def input_html_options
|
12
|
+
{ class: 'btn btn-primary', type: 'clear' }
|
13
|
+
end
|
14
|
+
|
15
|
+
def icon_name
|
16
|
+
return @icon unless @icon.nil?
|
17
|
+
@icon = options[:input].delete(:icon) || ''.html_safe
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
@@ -380,6 +380,8 @@ files:
|
|
380
380
|
- app/assets/javascripts/effective_checks/input.js
|
381
381
|
- app/assets/javascripts/effective_ck_editor/initialize.js.coffee
|
382
382
|
- app/assets/javascripts/effective_ck_editor/input.js
|
383
|
+
- app/assets/javascripts/effective_clear/initialize.js.coffee
|
384
|
+
- app/assets/javascripts/effective_clear/input.js
|
383
385
|
- app/assets/javascripts/effective_date/initialize.js.coffee
|
384
386
|
- app/assets/javascripts/effective_date/input.js
|
385
387
|
- app/assets/javascripts/effective_datetime/bootstrap-datetimepicker.js
|
@@ -574,6 +576,7 @@ files:
|
|
574
576
|
- app/models/effective/form_inputs/check_box.rb
|
575
577
|
- app/models/effective/form_inputs/checks.rb
|
576
578
|
- app/models/effective/form_inputs/ck_editor.rb
|
579
|
+
- app/models/effective/form_inputs/clear.rb
|
577
580
|
- app/models/effective/form_inputs/collection_input.rb
|
578
581
|
- app/models/effective/form_inputs/date_field.rb
|
579
582
|
- app/models/effective/form_inputs/datetime_field.rb
|