effective_form_inputs 1.1.10 → 1.1.11

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
  SHA1:
3
- metadata.gz: 273d6a542f186a294fd7f79b81dbb815da8417b0
4
- data.tar.gz: 7fafc590c61a949ff71f5c3a75cddf21b65391c8
3
+ metadata.gz: 49d3e07769895f8fe1d25f353f7cca1b796aa8c4
4
+ data.tar.gz: af46d954e2c058fab64aa2188efa4b8808cf6ede
5
5
  SHA512:
6
- metadata.gz: d3644072febc20674f2737455a339f4a78a958641ea1be612e9aff6cb6c46fed12f7a9bfeafd113e33a6b18fcab23facc5e10dcaccad2b79cd519794f4f44f68
7
- data.tar.gz: e97694a722a1f08951d9fea4a898ef2aa911cc1272c55650e4260c96745784bcb3205c9ce81d740c82dae957599e18733fd22ce4a077ac785bf4510717664089
6
+ metadata.gz: 12d3ccf450c2e837c8f75af3056ffbae1eb1ca4edd8966a6747b65099d18419978aa649a5cd9d6c24842ff0bbb1c55acc5c0b128850974db27278a8827bfade0
7
+ data.tar.gz: b4ea5cef5220ecc5fd2f7d34a0f52dfe3191c2f1b436229a02db49d43cf46eee7fc813ea25507de3b2f5469568f3c73b8fcc9dd24cb05e39203799770995f935
data/README.md CHANGED
@@ -254,6 +254,15 @@ To disable this behaviour, call with `date_linked: false`.
254
254
  = f.input :end_at, :as => :effective_date_time_picker, :date_linked => false
255
255
  ```
256
256
 
257
+ ### Events
258
+
259
+ The date picker library doesn't trigger a regular `change`. Instead you must watch for the `dp.change` event.
260
+
261
+ More info is available here:
262
+
263
+ http://eonasdan.github.io/bootstrap-datetimepicker/Events/
264
+
265
+
257
266
  ## Effective Date Picker
258
267
 
259
268
  This custom form input is based on the following awesome project:
@@ -879,6 +888,63 @@ validates :phone, format: { with: /\A\(\d{3}\) \d{3}-\d{4}( x\d+)?\Z/ }
879
888
  validates :phone, effective_tel: true # Enforces same format as above
880
889
  ```
881
890
 
891
+
892
+ ## Effective Time Picker
893
+
894
+ This custom form input is based on the following awesome project:
895
+
896
+ Bootstrap 3 Datepicker (https://github.com/Eonasdan/bootstrap-datetimepicker)
897
+
898
+
899
+ ### Installation
900
+
901
+ If you've already installed the 'All Form Inputs' assets (see above), there are no additional installation steps.
902
+
903
+ To install this form input individually, add the following to your application.js:
904
+
905
+ ```ruby
906
+ //= require effective_time_picker/input
907
+ ```
908
+
909
+ and add the following to your application.css:
910
+
911
+ ```ruby
912
+ *= require effective_time_picker/input
913
+ ```
914
+
915
+ ### Usage
916
+
917
+ As a Rails Form Helper input:
918
+
919
+ ```ruby
920
+ = form_for @user do |f|
921
+ = f.effective_time_picker :started_at
922
+ ```
923
+
924
+ As a SimpleForm input:
925
+
926
+ ```ruby
927
+ = simple_form_for @user do |f|
928
+ = f.input :started_at, :as => :effective_time_picker
929
+ ```
930
+
931
+ As a SimpleForm input without the input group (time glyphicon)
932
+
933
+ ```ruby
934
+ = simple_form_for @user do |f|
935
+ = f.input :started_at, :as => :effective_time_picker, :input_group => false
936
+ ```
937
+
938
+ ### Options
939
+
940
+ The default `:input_js => options` used to initialize this form input are as follows:
941
+
942
+ ```ruby
943
+ :input_js => {:format => ''%H:%M''}
944
+ ```
945
+
946
+ For more options, please see Effective Date Time Picker above
947
+
882
948
  ## Effective URL
883
949
 
884
950
  This custom form input enforces the url starts with http:// or https://
@@ -5,4 +5,5 @@
5
5
  //= require ./effective_price/input
6
6
  //= require ./effective_select/input
7
7
  //= require ./effective_tel/input
8
+ //= require ./effective_time_picker/input
8
9
  //= require ./effective_url/input
@@ -0,0 +1,17 @@
1
+ # http://eonasdan.github.io/bootstrap-datetimepicker/Options/
2
+
3
+ initialize = ->
4
+ $('input.effective_time_picker:not(.initialized)').each (i, element) ->
5
+ element = $(element)
6
+ options = element.data('input-js-options') || {}
7
+
8
+ element.addClass('initialized').datetimepicker(options)
9
+
10
+ $ -> initialize()
11
+ $(document).on 'page:change', -> initialize()
12
+ $(document).on 'turbolinks:load', -> initialize()
13
+ $(document).on 'turbolinks:render', -> initialize()
14
+ $(document).on 'cocoon:after-insert', -> initialize()
15
+ $(document).on 'turbolinks:before-cache', ->
16
+ $('input.effective_time_picker.initialized').datetimepicker('destroy')
17
+
@@ -0,0 +1,4 @@
1
+ //= require ../effective_date_time_picker/moment
2
+ //= require ../effective_date_time_picker/bootstrap-datetimepicker
3
+ //= require ../effective_date_time_picker/overrides
4
+ //= require ./initialize
@@ -0,0 +1 @@
1
+ @import '../effective_date_time_picker/input';
@@ -37,5 +37,14 @@ module Effective
37
37
  def effective_tel(method, options_tag = nil, options = {}, html_options = {})
38
38
  Inputs::EffectiveTel::Input.new(@object, @object_name, @template, method, options, html_options).to_html
39
39
  end
40
+
41
+ def effective_time_picker(method, options = {})
42
+ Inputs::EffectiveTimePicker::Input.new(@object, @object_name, @template, method, options, options).to_html
43
+ end
44
+
45
+ def effective_url(method, options_tag = nil, options = {}, html_options = {})
46
+ Inputs::EffectiveUrl::Input.new(@object, @object_name, @template, method, options, html_options).to_html
47
+ end
48
+
40
49
  end
41
50
  end
@@ -73,16 +73,16 @@ module Effective
73
73
  private
74
74
 
75
75
  # I'm passed something...I don't know what it is, but it needs to be an Array
76
- def arrayize_html_class_key(something)
77
- case something
76
+ def arrayize_html_class_key(value)
77
+ case value
78
78
  when Hash
79
- arrayize_html_class_key(something[:class])
79
+ arrayize_html_class_key(value[:class])
80
80
  when Array
81
- something.compact.map(&:to_s)
81
+ value.compact.map(&:to_s)
82
82
  when String
83
- something.split(' ')
83
+ value.split(' ')
84
84
  when Symbol
85
- [something.to_s]
85
+ [value.to_s]
86
86
  else
87
87
  []
88
88
  end
@@ -0,0 +1,43 @@
1
+ module Inputs
2
+ module EffectiveTimePicker
3
+ class Input < Effective::FormInput
4
+ delegate :content_tag, :text_field_tag, :to => :@template
5
+
6
+ def default_input_js
7
+ {format: 'HH:mm', showClear: true}
8
+ end
9
+
10
+ def default_input_html
11
+ {class: 'effective_time_picker time'}
12
+ end
13
+
14
+ def to_html
15
+ if options[:input_group] == false
16
+ return text_field_tag(field_name, value, tag_options)
17
+ end
18
+
19
+ content_tag(:div, class: 'input-group') do
20
+ content_tag(:span, class: 'input-group-addon') do
21
+ content_tag(:i, '', class: 'glyphicon glyphicon-time').html_safe
22
+ end +
23
+ text_field_tag(field_name, value, tag_options)
24
+ end
25
+ end
26
+
27
+ def value
28
+ val = super
29
+ val.respond_to?(:strftime) ? val.strftime('%H:%M') : val
30
+ end
31
+
32
+ def html_options
33
+ super.tap do |html_options|
34
+ if js_options[:format] == default_input_js[:format] # Unless someone changed from the default
35
+ html_options[:pattern] = '\d{2}:\d{2}' # Match default pattern defined above
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+
@@ -0,0 +1,12 @@
1
+ # = simple_form_for @thing do |f|
2
+ # = f.input :updated_at, :as => :effective_date_picker
3
+
4
+ if defined?(SimpleForm)
5
+
6
+ class EffectiveTimePickerInput < SimpleForm::Inputs::StringInput
7
+ def input(wrapper_options = nil)
8
+ Inputs::EffectiveTimePicker::Input.new(object, object_name, template, attribute_name, input_options, (merge_wrapper_options(input_html_options, wrapper_options) || {})).to_html
9
+ end
10
+ end
11
+
12
+ end
@@ -1,3 +1,3 @@
1
1
  module EffectiveFormInputs
2
- VERSION = '1.1.10'.freeze
2
+ VERSION = '1.1.11'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_form_inputs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.10
4
+ version: 1.1.11
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: 2017-10-19 00:00:00.000000000 Z
11
+ date: 2017-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -71,6 +71,8 @@ files:
71
71
  - app/assets/javascripts/effective_tel/initialize.js.coffee
72
72
  - app/assets/javascripts/effective_tel/input.js
73
73
  - app/assets/javascripts/effective_tel/jquery.maskedInput.js
74
+ - app/assets/javascripts/effective_time_picker/initialize.js.coffee
75
+ - app/assets/javascripts/effective_time_picker/input.js
74
76
  - app/assets/javascripts/effective_url/initialize.js.coffee
75
77
  - app/assets/javascripts/effective_url/input.js
76
78
  - app/assets/stylesheets/effective_date_picker/input.scss
@@ -84,6 +86,7 @@ files:
84
86
  - app/assets/stylesheets/effective_select/input.scss
85
87
  - app/assets/stylesheets/effective_select/overrides.scss
86
88
  - app/assets/stylesheets/effective_select/select2.css
89
+ - app/assets/stylesheets/effective_time_picker/input.scss
87
90
  - app/helpers/effective_form_inputs_helper.rb
88
91
  - app/models/effective/form_builder_inputs.rb
89
92
  - app/models/effective/form_input.rb
@@ -107,6 +110,8 @@ files:
107
110
  - app/models/inputs/effective_static_control_input.rb
108
111
  - app/models/inputs/effective_tel/input.rb
109
112
  - app/models/inputs/effective_tel_input.rb
113
+ - app/models/inputs/effective_time_picker/input.rb
114
+ - app/models/inputs/effective_time_picker_input.rb
110
115
  - app/models/inputs/effective_url/input.rb
111
116
  - app/models/inputs/effective_url_input.rb
112
117
  - app/validators/effective_email_validator.rb