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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb0803775215bcccd029fb2569ee2faa52109be3926b8d48e2a5e1c74eab5e37
4
- data.tar.gz: 3027ea16142e60e77fd58dadcaffef36a1ac21de6c1708e5fb2207a7e0eb58c8
3
+ metadata.gz: 778db97c3c4d202f8c98dab753ec0197d7a52bdcf3036ba1a15524bcc8a21cda
4
+ data.tar.gz: 94e9bcac5645082563a17cac8b3a3877d8dca1ae7b28608fd8e5c6ec4ba3f6b6
5
5
  SHA512:
6
- metadata.gz: 0e78594a0693f470165cedd51fb48e894b51ad5b909c997e227d74c0379db8133a054e0606b2fe298f30a45fd06843a9b7d8a4e2d3fd7e746256167a00d9e3b9
7
- data.tar.gz: 41eb6bc2021961b4775a9a044340d5cde19e259d4c8cd745519b4103536a4afe1799eb8b7218d021936ae944fb231532a03ca03b5c20c42786064053716ce2b4
6
+ metadata.gz: 92b23a5a7f43a5ca4e954198ee1d6dc44ba7d24d5a9811a89970bd60ae1066ae0c45ababdb45a9e74eeaad37b4cbf3a5823ea9484c39a978fd26e91d5d939bbe
7
+ data.tar.gz: 4366f548362edd9cfec2de37cb36e6edf7d46064541b7bdb3407f427afe4989ca98d7080c1815978f10031c18b50680dff8f6336f3d7800fe7f66ceac181fadb
@@ -10,6 +10,7 @@
10
10
  //= require ./effective_time/input
11
11
  //= require ./effective_time_zone_select/input
12
12
 
13
+ //= require ./effective_clear/input
13
14
  //= require ./effective_checks/input
14
15
  //= require ./effective_ck_editor/input
15
16
  //= require ./effective_editor/input
@@ -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
- EffectiveForm.reset($(event.currentTarget))
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,3 @@
1
+ $(document).on 'click', 'button[type=clear]', (event) ->
2
+ event.preventDefault()
3
+ $(event.currentTarget).closest('form').trigger('clear')
@@ -0,0 +1 @@
1
+ //= require ./initialize
@@ -58,6 +58,3 @@ $(document).on 'select2:reinitialize', (event) ->
58
58
 
59
59
  $select.trigger('change')
60
60
  true
61
-
62
- $(document).on 'reset', 'form', (event) ->
63
- $(event.currentTarget).find('select').val('').trigger('change.select2')
@@ -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
@@ -1,3 +1,3 @@
1
1
  module EffectiveBootstrap
2
- VERSION = '0.6.8'.freeze
2
+ VERSION = '0.6.9'.freeze
3
3
  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.8
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