simple_form_custom_inputs 0.0.3 → 0.0.4

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: 12e746e0a14477d80aabed40e16f6f81d7cd03f5
4
- data.tar.gz: 2a2d1cefe64ae5a20705201d3cee4544333c9985
3
+ metadata.gz: 58d04be2f172a7b254564f4c13df2b4cfb8dfb4c
4
+ data.tar.gz: c679f6ef8484e9b51e3e39a6fc158e8c15d56b2c
5
5
  SHA512:
6
- metadata.gz: 3102a8593a2a29feb903e84f6e54e36e583134ad87fac143306d28728838cec66d6bfe4fe3507e418467adbd56130b02500261aedb087d5f257749a9c64207e8
7
- data.tar.gz: 83952c6245ea7110028c639b3e588a5305ffcb61830dedf655900f1d598bd2def8a812de4e2e7f21921d9162f9b9ac8b0593a67ad85604d3b0a60ec9dc8b03fb
6
+ metadata.gz: 64c094807fa8501e38960a0cb8ce83db8dcc44e598dfdd1d4eba3d3b4f32b73bce8478384c6b1ec8bb631785e8689648236bab349e3e25fac17f961dae5c42ee
7
+ data.tar.gz: ed1fadb8b54c9e7cd29fb842239591be6cf9b2d4bb21ea3edd61029513fe0396e3c8e466472a3c6d6ac71c686ba218fdfbc837d50d48481a3ba49bbcc7494409
data/README.md CHANGED
@@ -9,7 +9,8 @@
9
9
  - [x] Datepicker
10
10
  - [ ] Datetimepicker
11
11
  - [ ] Timepicker
12
- - [ ] File
12
+ - [x] File button
13
+ - [x] File drag n drop
13
14
 
14
15
  ## Installation
15
16
 
@@ -43,6 +44,7 @@ In app/assets/javascripts/application.js, you should add as follows:
43
44
  //= require switchery
44
45
  //= require jquery.maskedinput
45
46
  //= require bootstrap-datepicker
47
+ //= require ezdz/dist/jquery.ezdz
46
48
  //= require simple_form_custom_inputs
47
49
  //= require ...
48
50
  ```
@@ -54,18 +56,19 @@ Application.scss
54
56
  @import "bootstrap";
55
57
  @import "switchery";
56
58
  @import "bootstrap-datepicker";
59
+ @import "ezdz/dist/jquery.ezdz";
57
60
  ```
58
61
 
59
62
  Basic Example:
60
63
 
61
64
  ```erb
62
-
63
65
  <%= simple_form_for :example do |f| %>
64
66
  <%= f.input :boolean, as: :switch %>
65
67
  <%= f.input :boolean, as: :switch, input_html: {data: {color: '#FF0', secondary_color: '#0F0', jack_color: '#FFF', jack_secondary_color: '#000', size: 'small'}} %>
66
68
  <%= f.input :phone, as: :masked, input_html: {data: {pattern: '(99) 99999-9999'}} %>
67
69
  <%= f.input :time, as: :datepicker %>
68
70
  <%= f.input :photo, as: :button_file, label: false, class: 'btn btn-info', input_html: {multiple: true, data: {multiple_caption: '{count} files selected'}} %>
71
+ <%= f.input :album, as: :drop_file, label: false, input_html: {multiple: true, data: {text: 'Send pictures', preview: false}} %>
69
72
  <% end %>
70
73
 
71
74
  ```
@@ -43,6 +43,7 @@ source 'https://rails-assets.org' do
43
43
  gem 'rails-assets-switchery'
44
44
  gem 'rails-assets-jquery.maskedinput'
45
45
  gem 'rails-assets-bootstrap-datepicker'
46
+ gem 'rails-assets-ezdz'
46
47
  end
47
48
 
48
49
  group :development, :test do
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- simple_form_custom_inputs (0.0.2)
4
+ simple_form_custom_inputs (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -116,6 +116,8 @@ GEM
116
116
  sprockets-rails (>= 2.0.0)
117
117
  rails-assets-bootstrap-datepicker (1.6.4)
118
118
  rails-assets-jquery (>= 1.7.1)
119
+ rails-assets-ezdz (0.5.1)
120
+ rails-assets-jquery (>= 1.8)
119
121
  rails-assets-fastclick (0.6.11)
120
122
  rails-assets-jquery (3.2.1)
121
123
  rails-assets-jquery.maskedinput (1.4.1)
@@ -196,6 +198,7 @@ DEPENDENCIES
196
198
  puma (~> 3.0)
197
199
  rails (~> 5.0.2)
198
200
  rails-assets-bootstrap-datepicker!
201
+ rails-assets-ezdz!
199
202
  rails-assets-jquery.maskedinput!
200
203
  rails-assets-switchery!
201
204
  sass-rails (~> 5.0)
@@ -17,6 +17,7 @@
17
17
  //= require switchery
18
18
  //= require jquery.maskedinput
19
19
  //= require bootstrap-datepicker
20
+ //= require ezdz/dist/jquery.ezdz
20
21
  //= require I18n/pt-BR
21
22
  //= require simple_form_custom_inputs
22
23
  //= require_tree .
@@ -2,6 +2,7 @@
2
2
  @import "bootstrap";
3
3
  @import "switchery";
4
4
  @import "bootstrap-datepicker";
5
+ @import "ezdz/dist/jquery.ezdz";
5
6
 
6
7
  body {
7
8
  padding: 30px;
@@ -4,6 +4,7 @@ autoload :SwitchInput, "simple_form_custom_inputs/simple_form/switch_input"
4
4
  autoload :MaskedInput, "simple_form_custom_inputs/simple_form/masked_input"
5
5
  autoload :DatepickerInput, "simple_form_custom_inputs/simple_form/datepicker_input"
6
6
  autoload :ButtonFileInput, "simple_form_custom_inputs/simple_form/button_file_input"
7
+ autoload :DropFileInput, "simple_form_custom_inputs/simple_form/drop_file_input"
7
8
 
8
9
  module SimpleFormCustomInputs
9
10
  class Engine < ::Rails::Engine; end
@@ -0,0 +1,13 @@
1
+ require 'active_support/core_ext/string/output_safety'
2
+
3
+ class DropFileInput < SimpleForm::Inputs::FileInput
4
+ attr_accessor :output_buffer
5
+
6
+ def input(wrapper_options = nil)
7
+ input_html_options[:class] << 'drop-file'
8
+ input_html_options[:multiple] = true if options[:multiple]
9
+ merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
10
+
11
+ @builder.file_field(attribute_name, merged_input_options)
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module SimpleFormCustomInputs
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -14,15 +14,22 @@ var initSwitchery = function() {
14
14
  var initMasks = function() {
15
15
  var input = $(".masked input");
16
16
  var pattern = input.data("pattern");
17
- input.mask(pattern);
17
+ if (input && pattern)
18
+ input.mask(pattern);
18
19
  };
19
20
 
20
21
  var initDatepicker = function() {
21
- $(".datepicker input").datepicker({
22
- autoclose: true,
23
- todayHighlight: true,
24
- language: $(".datepicker input").data("locale")
25
- });
22
+ try {
23
+ $(".datepicker input").datepicker({
24
+ autoclose: true,
25
+ todayHighlight: true,
26
+ language: $(".datepicker input").data("locale")
27
+ });
28
+ }
29
+
30
+ catch (e) {
31
+
32
+ }
26
33
  };
27
34
 
28
35
  var handleAttachementLabel = function() {
@@ -44,13 +51,23 @@ var handleAttachementLabel = function() {
44
51
  label.innerHTML = labelVal;
45
52
  });
46
53
  });
47
- }
54
+ };
55
+
56
+ var initDropFile = function() {
57
+ var input = $(".drop-file");
58
+ input.ezdz({
59
+ className: input.attr('class'),
60
+ text: input.data('text'),
61
+ previewImage: input.data('preview')
62
+ });
63
+ };
48
64
 
49
65
  var ready = function() {
50
66
  initSwitchery();
51
67
  initMasks();
52
68
  initDatepicker();
53
69
  handleAttachementLabel();
70
+ initDropFile();
54
71
  };
55
72
 
56
73
  if (typeof Turbolinks == "undefined") {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form_custom_inputs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Barreto
@@ -170,6 +170,7 @@ files:
170
170
  - lib/simple_form_custom_inputs.rb
171
171
  - lib/simple_form_custom_inputs/simple_form/button_file_input.rb
172
172
  - lib/simple_form_custom_inputs/simple_form/datepicker_input.rb
173
+ - lib/simple_form_custom_inputs/simple_form/drop_file_input.rb
173
174
  - lib/simple_form_custom_inputs/simple_form/masked_input.rb
174
175
  - lib/simple_form_custom_inputs/simple_form/switch_input.rb
175
176
  - lib/simple_form_custom_inputs/version.rb