unirer-bootstrap 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +64 -1
- data/app/views/unirer/bootstrap/_form_field.html.erb +10 -1
- data/lib/unirer/bootstrap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82031e81a5620437b1b0e87cf61e6cf168eb0cef
|
4
|
+
data.tar.gz: f1e1b5beb7c2c069c790f20a177ef77d0ae5ff4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ba674ac414a97ede719677691f33b66fe6e3ad903c1c5e19613b8fd747971b9fc32fe2734474e009ee962905e1be5df3377d749e5ab342f3fc2173ba0d12028
|
7
|
+
data.tar.gz: 99cb58e1652bc698d87b711105cc41d1aef2c170339783086ddd5301f7b5928e1576c42cb2f6279ac2d2bd1c50163a83ff36ae1dbbd687f9777daaa34642acdc
|
data/README.md
CHANGED
@@ -11,10 +11,73 @@ Unirer (统一资源表现)是一系列的资源表现引擎。Bootstrap 资源
|
|
11
11
|
gem 'unirer-bootstrap'
|
12
12
|
```
|
13
13
|
|
14
|
-
##
|
14
|
+
## Render the Pre-defined Partials:
|
15
15
|
```erb
|
16
16
|
<%= render partial: 'unirer/bootstrap/meta' %>
|
17
17
|
<%= render partial: 'unirer/bootstrap/script' %>
|
18
18
|
<%= render partial: 'unirer/bootstrap/style' %>
|
19
|
+
<%= render partial: 'unirer/bootstrap/form_field', locals: { options: { model: model, form: f, name: :phone_number, type: :telephone_field } } %>
|
20
|
+
```
|
21
|
+
|
22
|
+
### Render the Meta
|
23
|
+
The Meta partial includes the HTML meta tags for Bootstrap.
|
24
|
+
```erb
|
25
|
+
<%= render partial: 'unirer/bootstrap/meta' %>
|
26
|
+
```
|
27
|
+
|
28
|
+
The source codes of the Meta partial:
|
29
|
+
```html
|
30
|
+
<meta charset="UTF-8" />
|
31
|
+
<meta name="format-detection" content="telephone=no" />
|
32
|
+
<meta name="msapplication-tap-highlight" content="no" />
|
33
|
+
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />
|
34
|
+
<meta name="renderer" content="webkit" />
|
35
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
36
|
+
```
|
37
|
+
|
38
|
+
### Render the Script
|
39
|
+
The Script partial includes the HTML script tags for jQuery, Bootstrap, and React. All the CDN servers of the JavaScript libraries are optimized for China only.
|
40
|
+
```erb
|
41
|
+
<%= render partial: 'unirer/bootstrap/script' %>
|
42
|
+
```
|
43
|
+
|
44
|
+
The source codes of the Script partial:
|
45
|
+
```html
|
46
|
+
<%= javascript_include_tag '//cdn.bootcss.com/jquery/2.2.0/jquery.min.js' %>
|
47
|
+
<%= javascript_include_tag '//cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min.js' %>
|
48
|
+
|
49
|
+
<%= javascript_include_tag '//cdn.bootcss.com/moment.js/2.11.1/moment-with-locales.min.js' %>
|
50
|
+
<%= javascript_include_tag '//cdn.bootcss.com/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js' %>
|
51
|
+
|
52
|
+
<%= javascript_include_tag '//cdn.bootcss.com/react/0.14.6/react.min.js' %>
|
53
|
+
<%= javascript_include_tag '//cdn.bootcss.com/react/0.14.6/react-dom.min.js' %>
|
54
|
+
```
|
55
|
+
|
56
|
+
### Render the Style
|
57
|
+
The Style partial includes the HTML style tags for Bootstrap and Font Awesome. All the CDN servers of the CSS libraries are optimized for China only.
|
58
|
+
```erb
|
59
|
+
<%= render partial: 'unirer/bootstrap/style' %>
|
60
|
+
```
|
61
|
+
|
62
|
+
The source codes of the Style partial:
|
63
|
+
```html
|
64
|
+
<%= stylesheet_link_tag '//cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css', media: 'all' %>
|
65
|
+
<%= stylesheet_link_tag '//cdn.bootcss.com/font-awesome/4.5.0/css/font-awesome.min.css', media: 'all' %>
|
66
|
+
|
67
|
+
<%= stylesheet_link_tag '//cdn.bootcss.com/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css', media: 'all' %>
|
68
|
+
```
|
69
|
+
|
70
|
+
### Render the Form Field
|
71
|
+
The Form Field partial includes the HTML form field tags for Rails Form Builder and Bootstrap.
|
72
|
+
```erb
|
19
73
|
<%= render partial: 'unirer/bootstrap/form_field', locals: { model: model, form: f, name: :phone_number, type: :tel_field } %>
|
20
74
|
```
|
75
|
+
|
76
|
+
The 4 options are required: model, form, name, and type.
|
77
|
+
Here are more options:
|
78
|
+
- label: the customized label text.
|
79
|
+
- label_class: the CSS class for the label tag.
|
80
|
+
- field_class: the CSS class for the wrapper of the form control.
|
81
|
+
- error_class: the CSS class for the validation error block of this field.
|
82
|
+
- prefix: the HTML source codes of input group addon before the form control.
|
83
|
+
- suffix: the HTML source codes of input group addon after the form control.
|
@@ -4,6 +4,7 @@
|
|
4
4
|
name = options[:name]
|
5
5
|
type = options[:type]||:text_field
|
6
6
|
|
7
|
+
label_text = options[:label]
|
7
8
|
label_class = [ 'control-label', options[:label_class]||'col-xs-2' ].flatten.join ' '
|
8
9
|
field_class = [ options[:field_class]||'col-xs-10 input-group' ].flatten.join ' '
|
9
10
|
error_class = [ options[:error_class]||'col-xs-offset-2 col-xs-10 text-danger' ].flatten.join ' '
|
@@ -22,7 +23,13 @@
|
|
22
23
|
%>
|
23
24
|
|
24
25
|
<div class='form-group'>
|
25
|
-
|
26
|
+
|
27
|
+
<% if label_text.present? %>
|
28
|
+
<%= form.label name, class: label_class do %><%= label_text %><% end %>
|
29
|
+
<% else %>
|
30
|
+
<%= form.label name, class: label_class %>
|
31
|
+
<% end %>
|
32
|
+
|
26
33
|
<div class='<%= field_class %>'>
|
27
34
|
<% if prefix.present? %>
|
28
35
|
<span class='input-group-addon'><%= prefix %></span>
|
@@ -34,7 +41,9 @@
|
|
34
41
|
<span class='input-group-addon'><%= suffix %></span>
|
35
42
|
<% end %>
|
36
43
|
</div>
|
44
|
+
|
37
45
|
<% if model.errors[name].present? %>
|
38
46
|
<p class='<%= error_class %>'><%= model.errors[name].first %></p>
|
39
47
|
<% end %>
|
48
|
+
|
40
49
|
</div>
|
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.
|
4
|
+
version: '0.3'
|
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-01-
|
11
|
+
date: 2016-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|