twitter-bootstrap-for-rails 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +694 -0
- data/Rakefile +1 -0
- data/app/helpers/bootstrap_panel_helper.rb +62 -0
- data/app/helpers/breadcrumbs_helper.rb +10 -0
- data/app/helpers/dropdown_helper.rb +144 -0
- data/app/helpers/flash_block_helper.rb +48 -0
- data/app/helpers/form_group_helper.rb +21 -0
- data/app/helpers/glyphicon_helper.rb +38 -0
- data/app/helpers/modal_dialog_helper.rb +81 -0
- data/app/helpers/navbar_helper.rb +234 -0
- data/app/helpers/paginator_helper.rb +63 -0
- data/app/helpers/resource_table_helper.rb +165 -0
- data/app/helpers/title_helper.rb +24 -0
- data/app/views/twitter-bootstrap/_breadcrumbs.erb +13 -0
- data/lib/bs_form_builder.rb +95 -0
- data/lib/form_builder.rb +125 -0
- data/lib/helpers.rb +14 -0
- data/lib/twitter/bootstrap/for/rails.rb +50 -0
- data/lib/twitter/bootstrap/for/rails/breadcrumbs.rb +65 -0
- data/lib/twitter/bootstrap/for/rails/version.rb +10 -0
- data/twitter-bootstrap-for-rails.gemspec +23 -0
- data/vendor/assets/fonts/glyphicons-halflings-regular.eot +0 -0
- data/vendor/assets/fonts/glyphicons-halflings-regular.svg +229 -0
- data/vendor/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/vendor/assets/fonts/glyphicons-halflings-regular.woff +0 -0
- data/vendor/assets/javascripts/bootstrap.js +2002 -0
- data/vendor/assets/javascripts/bootstrap.min.js +9 -0
- data/vendor/assets/javascripts/bs-confirmation-dialog.js.erb +24 -0
- data/vendor/assets/stylesheets/bootstrap.css.erb +7098 -0
- data/vendor/assets/stylesheets/bootstrap.min.css.erb +9 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 62db7fe57ee026bf081a2544227be6cfe4c80a2a
|
4
|
+
data.tar.gz: 1f00188dabe3b5285eaec9e204d5c30405d8f7a5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 85eb725cc2f34b3b06ec7922a00b09d53674e0f5c4bed8904dee6ea0dda625a22c353d8003975855fe0ec96400e68b4b66c1bae3b62c73ace8aad69afde2e1ff
|
7
|
+
data.tar.gz: 1bfc4f7fe8c913eba7af979c50e9307ae7dcabf8ee12b93b8eb13edc4d50128e7befb0e4868e3b4e80d3fb8963986afad1a60b822b7e7e5e7d5f41b0750753ae
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Ivan
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,694 @@
|
|
1
|
+
# Twitter Bootstrap For Rails
|
2
|
+
|
3
|
+
This gem allow you to use <a href="http://getbootstrap.com/">Twitter Bootstrap 3</a> in ruby on rails application.
|
4
|
+
|
5
|
+
Current using version of Twitter Bootstrap is 3.0.2
|
6
|
+
|
7
|
+
Feedback: khrapach_ivan@mail.ru
|
8
|
+
|
9
|
+
## Installing the gem
|
10
|
+
|
11
|
+
Inset to the `gemfile` of your RoR application:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'twitter-bootstrap-for-rails', git: 'https://github.com/Xp-Apache/twitter-bootstrap-for-rails'
|
15
|
+
```
|
16
|
+
|
17
|
+
Run `bundle install`:
|
18
|
+
|
19
|
+
Include stylesheets and javascript of Twitter Bootstrap in you `application.css` and `application.js`.
|
20
|
+
|
21
|
+
`assets/stylesheets/application.css`:
|
22
|
+
|
23
|
+
```css
|
24
|
+
/*
|
25
|
+
*= require bootstrap
|
26
|
+
*/
|
27
|
+
```
|
28
|
+
|
29
|
+
`assets/javascripts/application.js`:
|
30
|
+
|
31
|
+
```js
|
32
|
+
//
|
33
|
+
//= require bootstrap
|
34
|
+
//
|
35
|
+
```
|
36
|
+
|
37
|
+
If you want use minified script and stylesheets, replase `require bootstrap` on `require bootstrap.min`
|
38
|
+
in `application.css` and `application.js` files.
|
39
|
+
|
40
|
+
## Glyphicons
|
41
|
+
|
42
|
+
<a href="http://glyphicons.com/">Glyphicons</a> Halflings are normally not available for free, but their creator has made them available
|
43
|
+
for Bootstrap free of cost. As a thank you, we only ask that you to include a link back to
|
44
|
+
<a href="http://glyphicons.com/">Glyphicons</a>
|
45
|
+
whenever possible.
|
46
|
+
|
47
|
+
### Using
|
48
|
+
```erb
|
49
|
+
<%= glyph :search %>
|
50
|
+
```
|
51
|
+
|
52
|
+
## Form group
|
53
|
+
|
54
|
+
### Basic usage
|
55
|
+
|
56
|
+
```erb
|
57
|
+
<%= form_for @o do |f| %>
|
58
|
+
<%= form_group class: 'has-error' do %>
|
59
|
+
<%= f.label :some_field %>
|
60
|
+
<%= f.text_field :some_field %>
|
61
|
+
<% end %>
|
62
|
+
<% end %>
|
63
|
+
```
|
64
|
+
|
65
|
+
### Usage as form builder helper
|
66
|
+
|
67
|
+
```erb
|
68
|
+
<%= form_for @o do |f| %>
|
69
|
+
<%= f.form_group class: :some_field do |fg| %>
|
70
|
+
<%= fg.label %>
|
71
|
+
<%= fg.text_field %>
|
72
|
+
<% end %>
|
73
|
+
<% end %>
|
74
|
+
```
|
75
|
+
|
76
|
+
### Submit button
|
77
|
+
```erb
|
78
|
+
<%= form_for @o do |f| %>
|
79
|
+
<%= f.form_group do |fg| %>
|
80
|
+
<%= fg.submit %>
|
81
|
+
<% end %>
|
82
|
+
<% end %>
|
83
|
+
```
|
84
|
+
|
85
|
+
### Check boxes
|
86
|
+
|
87
|
+
```erb
|
88
|
+
<%= form_for @o do |f| %>
|
89
|
+
<%= f.form_group :boolean_field do |fg| %>
|
90
|
+
<%= fg.check_box %>
|
91
|
+
<% end %>
|
92
|
+
<% end %>
|
93
|
+
```
|
94
|
+
|
95
|
+
```erb
|
96
|
+
<%= form_for @o do |f| %>
|
97
|
+
<%= f.form_group :boolean_field do |fg| %>
|
98
|
+
<%= fg.check_box 'Custom text for label' %>
|
99
|
+
<% end %>
|
100
|
+
<% end %>
|
101
|
+
```
|
102
|
+
|
103
|
+
### Disable render validation error
|
104
|
+
|
105
|
+
Rendering of validation error for field disabled for `.form-inline` and `.form-horizontal`.
|
106
|
+
|
107
|
+
Use `validation_error` method of `form_group` for rendering validation error in needed place.
|
108
|
+
|
109
|
+
```erb
|
110
|
+
<%= form_for @o, html: { class: 'form-horizontal' } do |f| %>
|
111
|
+
<%= form_group :field do |fg| %>
|
112
|
+
<%= fg.label class: 'col-md-2' %>
|
113
|
+
<div class="col-md-10">
|
114
|
+
<%= fg.text_field %>
|
115
|
+
<%= fg.validation_error %>
|
116
|
+
</div>
|
117
|
+
<% end %>
|
118
|
+
<% end %>
|
119
|
+
```
|
120
|
+
|
121
|
+
If you want disable rendering validation error for vertical form, use `render_validation_error`
|
122
|
+
option with value `false` in `form_for` method:
|
123
|
+
|
124
|
+
```erb
|
125
|
+
<%= form_form @o, render_validation_error: false do |f| %>
|
126
|
+
...
|
127
|
+
<% end %>
|
128
|
+
```
|
129
|
+
|
130
|
+
If you want disable rendering validation error for specific form group, use `render_validation_error`
|
131
|
+
option with value `false` in `form_group` method:
|
132
|
+
|
133
|
+
```erb
|
134
|
+
<%= form_for @o do |f| %>
|
135
|
+
<%= form_group :field, render_validation_error: false %>
|
136
|
+
...
|
137
|
+
<% end %>
|
138
|
+
<% end %>
|
139
|
+
```
|
140
|
+
|
141
|
+
### Static control
|
142
|
+
|
143
|
+
```erb
|
144
|
+
<%= form_for @o, html: { class: 'form-horizontal' } do |f| %>
|
145
|
+
<%= form_group :field do |fg| %>
|
146
|
+
<%= fg.label class="col-md-2" %>
|
147
|
+
|
148
|
+
<div class="col-md-10">
|
149
|
+
<%= fg.static %>
|
150
|
+
<%= fg.validation_error %>
|
151
|
+
</div>
|
152
|
+
<% end %>
|
153
|
+
<% end %>
|
154
|
+
```
|
155
|
+
|
156
|
+
## Placeholders and Titles for form controllers
|
157
|
+
|
158
|
+
Gem using I18n API for set placeholders and titles in form controls.
|
159
|
+
|
160
|
+
```yml
|
161
|
+
en:
|
162
|
+
activerecord:
|
163
|
+
placeholders:
|
164
|
+
model_name:
|
165
|
+
field_name: 'Placeholder text'
|
166
|
+
```
|
167
|
+
|
168
|
+
You make use globall placeholder keys. Just use option `placeholder` with specific key:
|
169
|
+
`f.text_field :x, placeholder: :some_symbol` and add in you l10n file:
|
170
|
+
|
171
|
+
```yml
|
172
|
+
en:
|
173
|
+
activerecord:
|
174
|
+
placeholders:
|
175
|
+
some_symbol: 'Some text'
|
176
|
+
```
|
177
|
+
|
178
|
+
You may use the `placeholder` option with string. Use empty string for disabling placeholder.
|
179
|
+
|
180
|
+
```erb
|
181
|
+
<%= f.text_field :x, placeholder: '' %>
|
182
|
+
```
|
183
|
+
|
184
|
+
## Required fields (and labels for him)
|
185
|
+
|
186
|
+
`app/models/example_model.rb`:
|
187
|
+
|
188
|
+
```ruby
|
189
|
+
class ExampleModel < ActiveRecord::Base
|
190
|
+
validates example_field, presence: true
|
191
|
+
end
|
192
|
+
```
|
193
|
+
|
194
|
+
`app/controllers/example_controller.rb`:
|
195
|
+
|
196
|
+
```ruby
|
197
|
+
class ExampleController < ApplicationController
|
198
|
+
def new
|
199
|
+
@o = ExampleModel.new
|
200
|
+
end
|
201
|
+
end
|
202
|
+
```
|
203
|
+
|
204
|
+
`app/views/example/new.html.erb`:
|
205
|
+
|
206
|
+
```erb
|
207
|
+
<%= form_for @o do |f| %>
|
208
|
+
<%= f.label :example_field %>
|
209
|
+
<%= f.text_field :example_field %>
|
210
|
+
<%= f.text_field :example_field required = false %>
|
211
|
+
<% end %>
|
212
|
+
```
|
213
|
+
|
214
|
+
`http://localhost:3000/examples/new`:
|
215
|
+
|
216
|
+
```html
|
217
|
+
<form accept-charset="UTF-8" action="/example" id="new_example_model" method="post" role="form">
|
218
|
+
<label class="required-label" for="example_model_example_field">Example field</label>
|
219
|
+
<input id="example_model_example_field" name="example_model[example_field]" required="required" type="text" />
|
220
|
+
<input id="example_model_example_field" name="example_model[example_field]" type="text" />
|
221
|
+
</form>
|
222
|
+
```
|
223
|
+
|
224
|
+
## Quick creating tables for collection of models
|
225
|
+
|
226
|
+
```erb
|
227
|
+
<%= resource_table Model, @collection, [field1, field2, [field3, field_for_field3]] %>
|
228
|
+
```
|
229
|
+
|
230
|
+
Helper `resource_table` creating table for collection of models.
|
231
|
+
|
232
|
+
The first parameter is the model class
|
233
|
+
|
234
|
+
The second parameter is the collection of models.
|
235
|
+
|
236
|
+
The third parameter is the collection of model fields or methods.
|
237
|
+
Nesting arrays using for sequience invoking of methods. For example, `[[:field, :subdield, :method]]`
|
238
|
+
invoke `item.field.subfield.method`.
|
239
|
+
|
240
|
+
Table including buttons for actions with model. For control of rendering this buttons, use boolean options:
|
241
|
+
* `can_remove`;
|
242
|
+
* `can_show`;
|
243
|
+
* `can_create`;
|
244
|
+
* `can_edit`.
|
245
|
+
|
246
|
+
<%= resource_table Model, @collection, [field1, field2, [field3, field_for_field3]], can_remove: false %>
|
247
|
+
|
248
|
+
### Remove confirmation
|
249
|
+
|
250
|
+
User I18n API for set default confirmation text:
|
251
|
+
|
252
|
+
```yml
|
253
|
+
en:
|
254
|
+
bootstrap:
|
255
|
+
resource_table:
|
256
|
+
remove_confirmation: 'Your remove confirmation text`
|
257
|
+
```
|
258
|
+
|
259
|
+
Use custom string with option `remove_confirmation`:
|
260
|
+
|
261
|
+
```erb
|
262
|
+
<%= resource_table Model, @collection, [fields], remove_confirmation: 'Your remove confrimation' %>
|
263
|
+
```
|
264
|
+
|
265
|
+
Use string for eval:
|
266
|
+
|
267
|
+
```erb
|
268
|
+
<%= resource_table Model, @collection, [fields], remove_confirmation: '"Remove #{item.name}?"' %>
|
269
|
+
```
|
270
|
+
|
271
|
+
User Proc:
|
272
|
+
|
273
|
+
```erb
|
274
|
+
<%= resource_table Model, @collection, [fields], remove_confirmation: Proc.new {|item| "Remove #{item.name}?"} %>
|
275
|
+
```
|
276
|
+
|
277
|
+
## Button dropdowns
|
278
|
+
|
279
|
+
```erb
|
280
|
+
<%= dropdown 'Actions' do |dd| %>
|
281
|
+
<%= dd.item 'Home', root_path # Menu item with link %>
|
282
|
+
<%= dd.item 'Disabled', class: 'disabled' # disabled menu item, without link %>
|
283
|
+
<%= dd.divider # Menu divider %>
|
284
|
+
<%= dd.header 'Text' # Menu header %>
|
285
|
+
<% end %>
|
286
|
+
```
|
287
|
+
|
288
|
+
### Customizing
|
289
|
+
#### Dropup
|
290
|
+
|
291
|
+
```erb
|
292
|
+
<%= dropdown 'Actions', drop_direction: :up do |dd| %>
|
293
|
+
...
|
294
|
+
<% end %>
|
295
|
+
```
|
296
|
+
|
297
|
+
#### Split button dropdown
|
298
|
+
|
299
|
+
```erb
|
300
|
+
<%= dropdown 'Actions', button: {split: true} do |dd| %>
|
301
|
+
...
|
302
|
+
<% end %>
|
303
|
+
```
|
304
|
+
|
305
|
+
#### Customize buttons
|
306
|
+
|
307
|
+
```erb
|
308
|
+
<%= dropdown 'Actions', button: {class: 'btn-primary', split: {class: 'btn-default'}} do |dd| %>
|
309
|
+
...
|
310
|
+
<% end %>
|
311
|
+
```
|
312
|
+
|
313
|
+
## Bootstrap confirmation dialog
|
314
|
+
`app/assets/javascripts/application.js`:
|
315
|
+
|
316
|
+
```js
|
317
|
+
//
|
318
|
+
//= require bootstrap.min
|
319
|
+
//= require bs-confirmation-dialog
|
320
|
+
//
|
321
|
+
```
|
322
|
+
|
323
|
+
### I18n
|
324
|
+
|
325
|
+
```yml
|
326
|
+
en:
|
327
|
+
bootstrap:
|
328
|
+
confirm_dialog_title: 'Confirm action'
|
329
|
+
confirm_button: 'Yes'
|
330
|
+
dismiss_button: 'No'
|
331
|
+
```
|
332
|
+
|
333
|
+
## Navbar
|
334
|
+
### Default navbar
|
335
|
+
|
336
|
+
```erb
|
337
|
+
<%= navbar brand: 'Brand' do |nav| %>
|
338
|
+
<%= nav.group do |ng| %>
|
339
|
+
<%= ng.item 'Link', root_path %>
|
340
|
+
<%= ng.item 'Link', '#' %>
|
341
|
+
|
342
|
+
<%= ng.dropdown 'Dropdown' do |dd| %>
|
343
|
+
<%= dd.item 'Action', '#' %>
|
344
|
+
<%= dd.item 'Another action', '#' %>
|
345
|
+
<%= dd.item 'Something else here', '#' %>
|
346
|
+
<%= dd.divider %>
|
347
|
+
<%= dd.item 'Separated link', '#' %>
|
348
|
+
<%= dd.divider %>
|
349
|
+
<%= dd.item 'One more separated link', '#' %>
|
350
|
+
<% end %>
|
351
|
+
<% end %>
|
352
|
+
|
353
|
+
<form class="navbar-form navbar-left" role="search">
|
354
|
+
<div class="form-group">
|
355
|
+
<input type="text" class="form-control" placeholder="Search">
|
356
|
+
</div>
|
357
|
+
<button type="submit" class="btn btn-default">Submit</button>
|
358
|
+
</form>
|
359
|
+
|
360
|
+
<%= nav.group pull: :right do |ng| %>
|
361
|
+
<%= ng.item 'Link', '#' %>
|
362
|
+
|
363
|
+
<%= ng.dropdown 'Dropdown' do |dd| %>
|
364
|
+
<%= dd.item 'Action', '#' %>
|
365
|
+
<%= dd.item 'Another action', '#' %>
|
366
|
+
<%= dd.item 'Something else here', '#' %>
|
367
|
+
<%= dd.divider %>
|
368
|
+
<%= dd.item 'Separated link', '#' %>
|
369
|
+
<% end %>
|
370
|
+
<% end %>
|
371
|
+
<% end %>
|
372
|
+
```
|
373
|
+
|
374
|
+
### Buttons
|
375
|
+
|
376
|
+
```erb
|
377
|
+
<%= navbar do |nav| %>
|
378
|
+
<%= nav.button 'Sign in' %>
|
379
|
+
<% end %>
|
380
|
+
```
|
381
|
+
|
382
|
+
### Text
|
383
|
+
|
384
|
+
```erb
|
385
|
+
<%= navbar do |nav| %>
|
386
|
+
<%= nav.text 'Signed in as Mark Otto' %>
|
387
|
+
<% end %>
|
388
|
+
```
|
389
|
+
|
390
|
+
### Non-nav links
|
391
|
+
|
392
|
+
```erb
|
393
|
+
<%= navbar do |nav| %>
|
394
|
+
<%= nav.text "Signed in as #{nav.link 'Mark Otto', '#'}".html_safe, pull: :right %>
|
395
|
+
<% end %>
|
396
|
+
```
|
397
|
+
|
398
|
+
### Fixed to top
|
399
|
+
|
400
|
+
```erb
|
401
|
+
<%= navbar fixed: :top do |nav| %>
|
402
|
+
...
|
403
|
+
<% end %>
|
404
|
+
```
|
405
|
+
|
406
|
+
### Fixed to bottom
|
407
|
+
|
408
|
+
```erb
|
409
|
+
<%= navbar fixed: :bottom do |nav| %>
|
410
|
+
...
|
411
|
+
<% end %>
|
412
|
+
```
|
413
|
+
|
414
|
+
### Static top
|
415
|
+
|
416
|
+
```erb
|
417
|
+
<%= navbar static: :top do |nav| %>
|
418
|
+
...
|
419
|
+
<% end %>
|
420
|
+
```
|
421
|
+
|
422
|
+
### Inverted navbar
|
423
|
+
|
424
|
+
```erb
|
425
|
+
<%= navbar inverse: true do |nav| %>
|
426
|
+
...
|
427
|
+
<% end %>
|
428
|
+
```
|
429
|
+
|
430
|
+
## Breadcrumbs
|
431
|
+
|
432
|
+
`/app/controllers/application_controller.rb`:
|
433
|
+
|
434
|
+
```ruby
|
435
|
+
class ApplicationController < ActionController::Base
|
436
|
+
add_breadcrumb :root # root_path will be used as url
|
437
|
+
end
|
438
|
+
```
|
439
|
+
|
440
|
+
`/app/controllers/examples_controller.rb`:
|
441
|
+
|
442
|
+
```ruby
|
443
|
+
class ExamplesController < ApplicationController
|
444
|
+
add_breadcrumb :index, :examples_path
|
445
|
+
|
446
|
+
def edit
|
447
|
+
@example = Example.find params[:id]
|
448
|
+
add_breadcrumb @example # @example.to_s as name, example_path(@example) as url
|
449
|
+
add_breadcrumb :edit, edit_example_path(@example)
|
450
|
+
end
|
451
|
+
end
|
452
|
+
```
|
453
|
+
|
454
|
+
`/app/views/layouts/application.html.erb`:
|
455
|
+
|
456
|
+
```erb
|
457
|
+
<!DOCTYPE html>
|
458
|
+
<html>
|
459
|
+
<head>
|
460
|
+
...
|
461
|
+
</head>
|
462
|
+
<body>
|
463
|
+
...
|
464
|
+
|
465
|
+
<%= render_breadcrumbs %>
|
466
|
+
|
467
|
+
<%= yield %>
|
468
|
+
</body>
|
469
|
+
</html>
|
470
|
+
```
|
471
|
+
|
472
|
+
`/config/locales/en.yml`:
|
473
|
+
|
474
|
+
```yml
|
475
|
+
en:
|
476
|
+
breadcrumbs:
|
477
|
+
root: 'Home'
|
478
|
+
edit: `Edit`
|
479
|
+
|
480
|
+
examples:
|
481
|
+
index: 'Examples'
|
482
|
+
edit: 'Edit example'
|
483
|
+
```
|
484
|
+
|
485
|
+
## Pagination
|
486
|
+
|
487
|
+
### Default pagination
|
488
|
+
|
489
|
+
```erb
|
490
|
+
<%= paginator @current_page, @total_pages %>
|
491
|
+
```
|
492
|
+
|
493
|
+
### Disabled and active states
|
494
|
+
|
495
|
+
Disabled and active states set automatically
|
496
|
+
|
497
|
+
### Sizing
|
498
|
+
|
499
|
+
```erb
|
500
|
+
<%= paginator @current_page, @total_pages, size: :large
|
501
|
+
```
|
502
|
+
|
503
|
+
```erb
|
504
|
+
<%= paginator @current_page, @total_pages, size: :small
|
505
|
+
```
|
506
|
+
|
507
|
+
### Page param name
|
508
|
+
|
509
|
+
```erb
|
510
|
+
<%= paginator @current_page, @total_pages, param: :p
|
511
|
+
```
|
512
|
+
|
513
|
+
## Alerts
|
514
|
+
|
515
|
+
```erb
|
516
|
+
<%= bs_alert :success, 'Message' %>
|
517
|
+
```
|
518
|
+
|
519
|
+
Render rules:
|
520
|
+
|
521
|
+
- `:success` render as `.alert-success`;
|
522
|
+
- `:info` render as `.alert-info`;
|
523
|
+
- `:warning` render as `.alert-warning`;
|
524
|
+
- `:danger` render as `.alert-danger`;
|
525
|
+
- `:notice` render as `.alert-success`;
|
526
|
+
- `:alert` render as `.alert-danger`;
|
527
|
+
- another keys render as `alert-info`.
|
528
|
+
|
529
|
+
### Flash block
|
530
|
+
|
531
|
+
```erb
|
532
|
+
<%= flash_block %>
|
533
|
+
```
|
534
|
+
|
535
|
+
Each flash message render as `bs_alert(flash_message_key, flash_message)`.
|
536
|
+
|
537
|
+
## Modal dialog
|
538
|
+
|
539
|
+
```erb
|
540
|
+
<%= modal_dialog id: 'myModal',
|
541
|
+
header: content_tag(:h4, 'Modal dialog header'),
|
542
|
+
body: 'Modal body',
|
543
|
+
footer: 'Dialog footer' %>
|
544
|
+
```
|
545
|
+
|
546
|
+
### Complex content
|
547
|
+
|
548
|
+
```erb
|
549
|
+
<% dialog_footer = capture do %>
|
550
|
+
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
551
|
+
<button type="button" class="btn btn-primary">Save changes</button>
|
552
|
+
<% end %>
|
553
|
+
|
554
|
+
<%= modal_dialog id: 'myModal',
|
555
|
+
header: content_tag(:h4, 'Modal dialog header'),
|
556
|
+
body: 'Modal body',
|
557
|
+
footer: dialog_footer %>
|
558
|
+
```
|
559
|
+
|
560
|
+
### Dismiss button
|
561
|
+
|
562
|
+
```erb
|
563
|
+
<%= modal_dialog id: 'myModal',
|
564
|
+
header: content_tag(:h4, 'Modal dialog header'),
|
565
|
+
body: 'Modal body',
|
566
|
+
footer: dismiss_button('Ok') %>
|
567
|
+
```
|
568
|
+
|
569
|
+
## Panels
|
570
|
+
|
571
|
+
### Basic example
|
572
|
+
|
573
|
+
```erb
|
574
|
+
<%= panel do %>
|
575
|
+
Basic panel example
|
576
|
+
<% end %>
|
577
|
+
```
|
578
|
+
|
579
|
+
### Panel with heading
|
580
|
+
|
581
|
+
```erb
|
582
|
+
<%= panel header: 'Panel heading without title' do %>
|
583
|
+
Panel content
|
584
|
+
<% end %>
|
585
|
+
```
|
586
|
+
|
587
|
+
```erb
|
588
|
+
<%= panel title: {level: 3, content: 'Panel title'} do %>
|
589
|
+
Panel content
|
590
|
+
<% end %>
|
591
|
+
```
|
592
|
+
|
593
|
+
### Panel with footer
|
594
|
+
|
595
|
+
```erb
|
596
|
+
<%= panel footer: 'Panel footer' do %>
|
597
|
+
Panel content
|
598
|
+
<% end %>
|
599
|
+
```
|
600
|
+
|
601
|
+
### Contextual alternatives
|
602
|
+
|
603
|
+
```erb
|
604
|
+
<%= panel header: 'Panel header', context: :primary do %>
|
605
|
+
Panel content
|
606
|
+
<% end %>
|
607
|
+
```
|
608
|
+
|
609
|
+
```erb
|
610
|
+
<%= panel header: 'Panel header', context: :info do %>
|
611
|
+
Panel content
|
612
|
+
<% end %>
|
613
|
+
```
|
614
|
+
|
615
|
+
```erb
|
616
|
+
<%= panel header: 'Panel header', context: :success do %>
|
617
|
+
Panel content
|
618
|
+
<% end %>
|
619
|
+
```
|
620
|
+
|
621
|
+
```erb
|
622
|
+
<%= panel header: 'Panel header', context: :warning do %>
|
623
|
+
Panel content
|
624
|
+
<% end %>
|
625
|
+
```
|
626
|
+
|
627
|
+
```erb
|
628
|
+
<%= panel header: 'Panel header', context: :danger do %>
|
629
|
+
Panel content
|
630
|
+
<% end %>
|
631
|
+
```
|
632
|
+
|
633
|
+
## Global settings
|
634
|
+
|
635
|
+
`config/initializers/bootstrap.rb`:
|
636
|
+
|
637
|
+
```ruby
|
638
|
+
Twitter::Bootstrap::For::Rails.setup do |config|
|
639
|
+
# Globally disable or enable rendering validation errors inside form groups
|
640
|
+
config.render_validation_error = true
|
641
|
+
end
|
642
|
+
```
|
643
|
+
|
644
|
+
## Page header helper
|
645
|
+
|
646
|
+
`app/views/layouts/application.html.erb`:
|
647
|
+
|
648
|
+
```erb
|
649
|
+
<!DOCTYPE html>
|
650
|
+
<html>
|
651
|
+
<head>
|
652
|
+
<%= page_title @title %>
|
653
|
+
<!-- Another content for head section -->
|
654
|
+
</head>
|
655
|
+
|
656
|
+
<body>
|
657
|
+
<%= yield :title %>
|
658
|
+
<!-- Another content for body section -->
|
659
|
+
</body>
|
660
|
+
</html>
|
661
|
+
```
|
662
|
+
|
663
|
+
Text fo title get from `page_titles.controller_name.action_name` of you i18n hash.
|
664
|
+
|
665
|
+
### User another key for page title
|
666
|
+
|
667
|
+
In action of some controller, for example:
|
668
|
+
|
669
|
+
```ruby
|
670
|
+
...
|
671
|
+
@title = :i_found_it
|
672
|
+
...
|
673
|
+
```
|
674
|
+
|
675
|
+
Text tot title get from `page_titles.controller_name.i_found_it` in this case.
|
676
|
+
|
677
|
+
### Custom title text
|
678
|
+
|
679
|
+
In action of some controller, for example:
|
680
|
+
|
681
|
+
```ruby
|
682
|
+
...
|
683
|
+
@title = 'Some custom text'
|
684
|
+
...
|
685
|
+
```
|
686
|
+
|
687
|
+
## Change log
|
688
|
+
|
689
|
+
v1.3.3 - Available manually set required option for form controls
|
690
|
+
v1.3.2 - Added required labels
|
691
|
+
v1.3.1 - Added page_title helper
|
692
|
+
v1.2.1 - Fix trouble with disabling create button in resource table
|
693
|
+
v1.2.0 - Added check_box for form_group
|
694
|
+
v1.1.0 - Added bootstrap panel helper
|