unirer-bootstrap 0.7 → 0.8

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: 761e08c4629879130c3302845bb10a03aec1902d
4
- data.tar.gz: 9a16f38d18e74137d31dfb611ab53e060d5b37f3
3
+ metadata.gz: 8f4a8a84f994214b529c256b245e0697d0a3ab54
4
+ data.tar.gz: 5eaac740fc2b2cb23aa42e3f6f6d7c3f336e9b59
5
5
  SHA512:
6
- metadata.gz: 1221a55c4ce85804ec3ecb44c74246741f9ebef881294357893921b2fba8d82a90169b191e524ebb5b07585b8261787d85b39e23770c1dc6f2a62909d1fd32be
7
- data.tar.gz: 37702172f108843c5c8ce13372549729242723cdc0be5c02cdd3f9eda55d8a9432f31ad48c0977ae24b1a7db4c3ce9b02681859040bbbef74d395e8823fb1087
6
+ metadata.gz: 48b3a7288d98c4a58c16cfd22a770aca1bbfaa8df052b66f0e7fa2d2ac5c87718a7a110c67ba1a329b444c84e3b4433d6c0b46cec339a84cd46a2dc2ebd72cb2
7
+ data.tar.gz: 8fee421b384511b9258ca19cf6e6c97bf43d574360d8b2b8da7220d34d86c00001f5eab48421f82cf8f9f5abc64f3d60e16a6702c21c2ea91f11b9dd1c9be3b0
data/README.md CHANGED
@@ -80,6 +80,7 @@ The following JavaScript libraries are switchable, and the version can be config
80
80
  - :'bootstrap-datetimepicker'
81
81
  - :'bootstrap-datepicker'
82
82
  - :'bootstrap-table'
83
+ - :'bootstrap-fileinput'
83
84
  - :buttons
84
85
  - :react
85
86
 
@@ -98,6 +99,7 @@ The following JavaScript libraries are switchable, and the version can be config
98
99
  - :'bootstrap-datetimepicker'
99
100
  - :'bootstrap-datepicker'
100
101
  - :'bootstrap-table'
102
+ - :'bootstrap-fileinput'
101
103
  - :buttons
102
104
  - :'animate.css'
103
105
 
@@ -106,9 +108,37 @@ The following JavaScript libraries are switchable, and the version can be config
106
108
  ### Render the Form Field
107
109
  The Form Field partial includes the HTML form field tags for Rails Form Builder and Bootstrap.
108
110
  ```erb
109
- <%= render partial: 'unirer/bootstrap/form_field', locals: { options: { model: model, form: f, name: :phone_number, type: :tel_field } } %>
111
+ <%= render partial: 'unirer/bootstrap/form_field',
112
+ locals: {
113
+ options: {
114
+ model: model,
115
+ form: f,
116
+ name: :phone_number,
117
+ type: :tel_field
118
+ }
119
+ }
120
+ %>
121
+ ```
122
+
123
+
124
+
125
+ ### Render the Form Select Box
126
+ The Form Select Box partial includes the HTML select tags for Rails Form Builder and Bootstrap.
127
+ ```ruby
128
+ <%= render partial: 'unirer/bootstrap/form_field',
129
+ locals: {
130
+ options: {
131
+ model: model,
132
+ form: f,
133
+ name: :country_id,
134
+ choices: @countries.select('id, name').map { |country| [ country.name, country.id ] },
135
+ options: { prompt: '请选择国家' }
136
+ }
137
+ }
138
+ %>
110
139
  ```
111
140
 
141
+
112
142
  The 4 options are required: model, form, name, and type.
113
143
  Here are more options:
114
144
  - label: the customized label text.
@@ -21,7 +21,7 @@
21
21
  prefix = options[:prefix]
22
22
  suffix = options[:suffix]
23
23
 
24
- field_options = {
24
+ input_options = {
25
25
  disabled: options[:disabled],
26
26
  class: input_class_list,
27
27
  placeholder: options[:placeholder],
@@ -41,17 +41,25 @@
41
41
  <%= form.label name, class: label_class %>
42
42
  <% end %>
43
43
 
44
- <div class='<%= field_class %>'>
45
- <% if prefix.present? %>
46
- <span class='input-group-addon'><%= prefix %></span>
47
- <% end %>
44
+ <% if prefix.present? || suffix.present? %>
48
45
 
49
- <%= form.send type, name, field_options %>
46
+ <div class='<%= field_class %>'>
47
+ <% if prefix.present? %>
48
+ <span class='input-group-addon'><%= prefix %></span>
49
+ <% end %>
50
50
 
51
- <% if suffix.present? %>
52
- <span class='input-group-addon'><%= suffix %></span>
53
- <% end %>
54
- </div>
51
+ <%= form.send type, name, input_options %>
52
+
53
+ <% if suffix.present? %>
54
+ <span class='input-group-addon'><%= suffix %></span>
55
+ <% end %>
56
+ </div>
57
+
58
+ <% else %>
59
+
60
+ <%= form.send type, name, input_options %>
61
+
62
+ <% end %>
55
63
 
56
64
  <% if model.errors[name].present? && !error_hidden %>
57
65
  <p class='<%= error_class %>'><%= model.errors[name].first %></p>
@@ -0,0 +1,67 @@
1
+ <%
2
+ model = options[:model]
3
+ form = options[:form]
4
+ name = options[:name]
5
+
6
+ group_class_list = [ 'form-group', options[:group_class] ]
7
+ label_class_list = [ 'control-label', options[:label_class] ]
8
+ field_class_list = [ 'input-group', options[:field_class] ]
9
+ input_class_list = [ 'form-control', options[:input_class] ]
10
+ error_class_list = [ 'text-danger', options[:error_class] ]
11
+ group_class_list << 'has-error' if model.errors[name].present?
12
+
13
+ group_class = group_class_list.flatten.join ' '
14
+ label_class = label_class_list.flatten.join ' '
15
+ field_class = field_class_list.flatten.join ' '
16
+ input_class = input_class_list.flatten.join ' '
17
+ error_class = error_class_list.flatten.join ' '
18
+
19
+ label_text = options[:label_text]
20
+ prefix = options[:prefix]
21
+ suffix = options[:suffix]
22
+
23
+ input_options = {
24
+ class: input_class_list,
25
+ disabled: options[:disabled],
26
+ readonly: options[:readonly]
27
+ }
28
+
29
+ error_hidden = options[:error_hidden]
30
+
31
+ choices = options[:choices]
32
+ flags = options[:options]
33
+ %>
34
+
35
+ <div class='<%= group_class %>'>
36
+
37
+ <% if label_text.present? %>
38
+ <%= form.label name, class: label_class do %><%= label_text %><% end %>
39
+ <% else %>
40
+ <%= form.label name, class: label_class %>
41
+ <% end %>
42
+
43
+ <% if prefix.present? || suffix.present? %>
44
+
45
+ <div class='<%= field_class %>'>
46
+ <% if prefix.present? %>
47
+ <span class='input-group-addon'><%= prefix %></span>
48
+ <% end %>
49
+
50
+ <%= form.select name, choices, flags, input_options %>
51
+
52
+ <% if suffix.present? %>
53
+ <span class='input-group-addon'><%= suffix %></span>
54
+ <% end %>
55
+ </div>
56
+
57
+ <% else %>
58
+
59
+ <%= form.select name, choices, flags, input_options %>
60
+
61
+ <% end %>
62
+
63
+ <% if model.errors[name].present? && !error_hidden %>
64
+ <p class='<%= error_class %>'><%= model.errors[name].first %></p>
65
+ <% end %>
66
+
67
+ </div>
@@ -11,6 +11,11 @@
11
11
  <%= javascript_include_tag "//cdn.bootcss.com/bootstrap-table/#{library_version(:'bootstrap-table', '1.10.1', options)}/locale/bootstrap-table-zh-CN.min.js", charset: 'UTF-8' %>
12
12
  <% end %>
13
13
 
14
+ <% if library_enabled?(:'bootstrap-fileinput', options) %>
15
+ <%= javascript_include_tag "//cdn.bootcss.com/bootstrap-fileinput/#{library_version(:'bootstrap-fileinput', '4.3.1', options)}/js/fileinput.min.js" %>
16
+ <%= javascript_include_tag "//cdn.bootcss.com/bootstrap-fileinput/#{library_version(:'bootstrap-fileinput', '4.3.1', options)}/js/fileinput_locale_zh.min.js", charset: 'UTF-8' %>
17
+ <% end %>
18
+
14
19
  <%= javascript_include_tag "//cdn.bootcss.com/Buttons/#{library_version(:buttons, '2.0.0', options)}/js/buttons.min.js" if library_enabled?(:buttons, options) %>
15
20
 
16
21
  <% if library_enabled?(:react, options) %>
@@ -3,7 +3,8 @@
3
3
  <%= stylesheet_link_tag "//cdn.bootcss.com/bootstrap/#{library_version(:'bootstrap-theme', '3.3.6', options)}/css/bootstrap-theme.min.css", media: 'all' if library_enabled?(:'bootstrap-theme', options) %>
4
4
  <%= stylesheet_link_tag "//cdn.bootcss.com/bootstrap-datetimepicker/#{library_version(:'bootstrap-datetimepicker', '4.17.37', options)}/css/bootstrap-datetimepicker.min.css", media: 'all' if library_enabled?(:'bootstrap-datetimepicker', options) %>
5
5
  <%= stylesheet_link_tag "//cdn.bootcss.com/bootstrap-datepicker/#{library_version(:'bootstrap-datepicker', '1.6.0', options)}/css/bootstrap-datepicker.min.css", media: 'all' if library_enabled?(:'bootstrap-datepicker', options) %>
6
- <%= stylesheet_link_tag "//cdn.bootcss.com/bootstrap-table/#{library_version(:'bootstrap-table', '1.10.0', options)}/bootstrap-table.min.css", media: 'all' if library_enabled?(:'bootstrap-datetimepicker', options) %>
6
+ <%= stylesheet_link_tag "//cdn.bootcss.com/bootstrap-table/#{library_version(:'bootstrap-table', '1.10.0', options)}/bootstrap-table.min.css", media: 'all' if library_enabled?(:'bootstrap-table', options) %>
7
+ <%= stylesheet_link_tag "//cdn.bootcss.com/bootstrap-fileinput/#{library_version(:'bootstrap-fileinput', '4.3.1', options)}/css/fileinput.min.css", media: 'all' if library_enabled?(:'bootstrap-fileinput', options) %>
7
8
 
8
9
  <%= stylesheet_link_tag "//cdn.bootcss.com/font-awesome/#{library_version(:'font-awesome', '4.5.0', options)}/css/font-awesome.min.css", media: 'all' if library_enabled?(:'font-awesome', options) %>
9
10
  <%= stylesheet_link_tag "//cdn.bootcss.com/Buttons/#{library_version(:buttons, '2.0.0', options)}/css/buttons.min.css", media: 'all' if library_enabled?(:buttons, options) %>
@@ -1,5 +1,5 @@
1
1
  module Unirer
2
2
  module Bootstrap
3
- VERSION = '0.7'.freeze
3
+ VERSION = '0.8'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unirer-bootstrap
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.7'
4
+ version: '0.8'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-16 00:00:00.000000000 Z
11
+ date: 2016-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -42,6 +42,7 @@ files:
42
42
  - app/helpers/unirer/bootstrap/application_helper.rb
43
43
  - app/views/layouts/unirer/bootstrap/application.html.erb
44
44
  - app/views/unirer/bootstrap/_form_field.html.erb
45
+ - app/views/unirer/bootstrap/_form_select_box.html.erb
45
46
  - app/views/unirer/bootstrap/_meta.html.erb
46
47
  - app/views/unirer/bootstrap/_script.html.erb
47
48
  - app/views/unirer/bootstrap/_style.html.erb