bootstrap-view-helpers 0.0.11 → 0.0.12
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.
- data/CHANGELOG.md +7 -0
- data/README.md +120 -2
- data/app/TODO.md +8 -0
- data/app/controllers/bootstrap_view_helpers_controller.rb +8 -0
- data/app/helpers/bootstrap/alert_helper.rb +17 -16
- data/app/helpers/bootstrap/flash_helper.rb +54 -0
- data/app/helpers/bootstrap/modal_helper.rb +123 -0
- data/app/helpers/bootstrap/nav_helper.rb +1 -1
- data/app/helpers/bootstrap/table_helper.rb +51 -0
- data/app/views/application/_bootstrap_view_helper_nav_bar.html.erb +2 -2
- data/app/views/application/_bootstrap_view_helper_side_bar.html.erb +8 -4
- data/app/views/bootstrap_view_helpers/_flash_helper.html.erb +1 -0
- data/app/views/bootstrap_view_helpers/_modal_alert.html.erb +9 -0
- data/app/views/bootstrap_view_helpers/_modal_basic.html.erb +9 -0
- data/app/views/bootstrap_view_helpers/_modal_block.html.erb +15 -0
- data/app/views/bootstrap_view_helpers/_modal_confirm.html.erb +8 -0
- data/app/views/bootstrap_view_helpers/_table_default.html.erb +3 -0
- data/app/views/bootstrap_view_helpers/_table_example.html.erb +18 -0
- data/app/views/bootstrap_view_helpers/_table_with_class.html.erb +3 -0
- data/app/views/bootstrap_view_helpers/flash_helper.html.erb +25 -0
- data/app/views/bootstrap_view_helpers/modal.html.erb +40 -0
- data/app/views/bootstrap_view_helpers/tables.html.erb +51 -0
- data/lib/bootstrap-view-helpers/version.rb +1 -1
- metadata +17 -2
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## v 0.0.12
|
4
|
+
|
5
|
+
* added `modal` and `modal_trigger` for Bootstrap modal dialogs
|
6
|
+
* added `modal_alert` and `modal_confirm` which work similarly to their Javascript counterparts
|
7
|
+
* added `flash_messages` helper for flash support
|
8
|
+
* added `bs_table_tag` for consistent Bootstrap tables
|
9
|
+
|
3
10
|
## v 0.0.11
|
4
11
|
|
5
12
|
* added `nav_bar_text`
|
data/README.md
CHANGED
@@ -12,6 +12,10 @@ Includes support for:
|
|
12
12
|
* navigation
|
13
13
|
* nav bar
|
14
14
|
* nav list
|
15
|
+
* modal dialogs
|
16
|
+
* modal_trigger
|
17
|
+
* modal_alert
|
18
|
+
* modal_confirm
|
15
19
|
* icons
|
16
20
|
* icons with text
|
17
21
|
* buttons
|
@@ -29,7 +33,10 @@ Includes support for:
|
|
29
33
|
* submit_tag_button
|
30
34
|
* cancel_tag_button
|
31
35
|
* alerts
|
36
|
+
* table helper
|
32
37
|
|
38
|
+
For the complete list of available helpers see the [API documentation](http://rubydoc.info/gems/bootstrap-view-helpers/frames/file/README.md).
|
39
|
+
|
33
40
|
## Note
|
34
41
|
|
35
42
|
This is a new gem undergoing a lot of change. There is a chance that some backwards
|
@@ -91,7 +98,7 @@ Complete [API documentation](http://rubydoc.info/gems/bootstrap-view-helpers/fra
|
|
91
98
|
|
92
99
|
<%= nav_bar_links(pull: 'right') do %>
|
93
100
|
<%= nav_bar_text('logged in as admin') %>
|
94
|
-
<%= nav_dropdown('
|
101
|
+
<%= nav_dropdown('Dropdown 1') do %>
|
95
102
|
<%= dropdown_item('One', 'foo')%>
|
96
103
|
<% end %>
|
97
104
|
<% end %>
|
@@ -108,6 +115,64 @@ Complete [API documentation](http://rubydoc.info/gems/bootstrap-view-helpers/fra
|
|
108
115
|
<% end %>
|
109
116
|
```
|
110
117
|
|
118
|
+
### Modal Dailogs an Friends
|
119
|
+
|
120
|
+
#### Simple Example Using Defaults
|
121
|
+
|
122
|
+
```erb
|
123
|
+
<%= modal_trigger("Click to show modal", href: '#modal-1') %>
|
124
|
+
|
125
|
+
<%= modal(id: 'modal-1') do %>
|
126
|
+
<%= modal_header("Heading") %>
|
127
|
+
<%= modal_body("The body ...") %>
|
128
|
+
<%= modal_footer %>
|
129
|
+
<% end %>
|
130
|
+
```
|
131
|
+
|
132
|
+
#### Block Form Using Other Modal Helpers
|
133
|
+
|
134
|
+
```erb
|
135
|
+
<%= modal_trigger("Click to show modal", href: '#modal-2', class: 'btn btn-primary') %>
|
136
|
+
|
137
|
+
<%= modal(id: 'modal-2') do %>
|
138
|
+
<%= modal_header(close: false) do %>
|
139
|
+
Heading <small>(with no close button)</small>
|
140
|
+
<% end %>
|
141
|
+
<%= modal_body do %>
|
142
|
+
<h4>Modal Body</h4>
|
143
|
+
<p>With additional markup</p>
|
144
|
+
<% end %>
|
145
|
+
<%= modal_footer do %>
|
146
|
+
<%= button("Save", :primary) %>
|
147
|
+
<%= modal_footer_close_button("Dismiss") %>
|
148
|
+
<% end %>
|
149
|
+
<% end %>
|
150
|
+
```
|
151
|
+
|
152
|
+
#### Modal Alert - Similar to JS Alert
|
153
|
+
|
154
|
+
```erb
|
155
|
+
<%= modal_trigger("Click to show Alert", href: '#alert') %>
|
156
|
+
<%= modal_alert("Watch out", id: 'alert') %>
|
157
|
+
|
158
|
+
<%= modal_trigger("Click to show Alert w/block", href: '#alert-block') %>
|
159
|
+
<%= modal_alert(id: 'alert-block', header: 'Custom Header') do %>
|
160
|
+
This is some <b>bold</b> text from the <code>modal_alert</code> block.
|
161
|
+
<% end %>
|
162
|
+
```
|
163
|
+
|
164
|
+
#### Modal Confirm - Similar to JS Confirm
|
165
|
+
|
166
|
+
```erb
|
167
|
+
<%= modal_trigger("Click to show Confirm", href: '#confirm') %>
|
168
|
+
<%= modal_confirm("Watch out", id: 'confirm') %>
|
169
|
+
|
170
|
+
<%= modal_trigger("Click to show Confirm w/block", href: '#confirm-block') %>
|
171
|
+
<%= modal_confirm(id: 'confirm-block', header: 'Custom Header') do %>
|
172
|
+
This is some <b>bold</b> text from the <code>modal_confirm</code> block.
|
173
|
+
<% end %>
|
174
|
+
```
|
175
|
+
|
111
176
|
### Icons
|
112
177
|
|
113
178
|
See: http://twitter.github.io/bootstrap/base-css.html#icons
|
@@ -282,4 +347,57 @@ cancel_button_tag('Return', :small, :warning, url: '/', id: 'my-id')
|
|
282
347
|
<li>Two</li>
|
283
348
|
</ul>
|
284
349
|
<% end %>
|
285
|
-
```
|
350
|
+
```
|
351
|
+
|
352
|
+
### Flash
|
353
|
+
|
354
|
+
[API Documentation](http://rubydoc.info/gems/bootstrap-view-helpers/Bootstrap/FlashHelper)
|
355
|
+
|
356
|
+
```erb
|
357
|
+
# in a layout or view
|
358
|
+
|
359
|
+
<%= flash_messages %>
|
360
|
+
<%= flash_messages close: false %>
|
361
|
+
<%= flash_messages class: 'flash', id: 'my-flash' %>
|
362
|
+
```
|
363
|
+
|
364
|
+
```ruby
|
365
|
+
# override default mapping (e.g., in initializer)
|
366
|
+
|
367
|
+
Bootstrap::FlashHelper.mapping[:notice] = :success
|
368
|
+
Bootstrap::FlashHelper.mapping[:mistake] = :error
|
369
|
+
```
|
370
|
+
|
371
|
+
### Table Helper
|
372
|
+
|
373
|
+
* [API Documentation](http://rubydoc.info/gems/bootstrap-view-helpers/Bootstrap/TableHelper)
|
374
|
+
* [Bootstrap Documentation](http://twitter.github.io/bootstrap/base-css.html#tables)
|
375
|
+
|
376
|
+
Don't keep repeating the Bootstrap table classes:
|
377
|
+
|
378
|
+
```erb
|
379
|
+
# instead of
|
380
|
+
<table class='table table-bordered table-striped table-hover'>
|
381
|
+
...
|
382
|
+
</table>
|
383
|
+
|
384
|
+
# do this
|
385
|
+
<%= bs_table_tag do %>
|
386
|
+
...
|
387
|
+
<% end %>
|
388
|
+
```
|
389
|
+
|
390
|
+
Customize the classes used (e.g. in an initializer):
|
391
|
+
|
392
|
+
```ruby
|
393
|
+
# change the default
|
394
|
+
Bootstrap::TableHelper.class_lists[:default] = 'table table-striped'
|
395
|
+
|
396
|
+
# create a custom class list
|
397
|
+
Bootstrap::TableHelper.class_lists[:admin] = 'admin table table-striped table-compact'
|
398
|
+
|
399
|
+
# use the custom list
|
400
|
+
<%= bs_table_tag(:admin) do %>
|
401
|
+
...
|
402
|
+
<% end %>
|
403
|
+
```
|
data/app/TODO.md
ADDED
@@ -10,4 +10,12 @@ class BootstrapViewHelpersController < ApplicationController
|
|
10
10
|
def index
|
11
11
|
end
|
12
12
|
|
13
|
+
def flash_helper
|
14
|
+
flash.now[:notice] = ":notice is mapped to :info"
|
15
|
+
flash.now[:alert] = ":alert is mapped to :error"
|
16
|
+
flash.now[:warning] = 'Unrecognized types use Bootstrap default'
|
17
|
+
flash.now[:success] = "The operation was a success"
|
18
|
+
flash.now[:error] = "There was an error"
|
19
|
+
flash.now[:info] = "Here is some info"
|
20
|
+
end
|
13
21
|
end
|
@@ -17,6 +17,7 @@
|
|
17
17
|
# </ul>
|
18
18
|
# <% end %>
|
19
19
|
module Bootstrap::AlertHelper
|
20
|
+
InvalidAlertTypeError = Class.new(StandardError)
|
20
21
|
|
21
22
|
ALERT_ATTRIBUTES = %w(error success info block)
|
22
23
|
|
@@ -28,31 +29,23 @@ module Bootstrap::AlertHelper
|
|
28
29
|
# @option options [Boolean] :close if +false+, don't include a close link ('x')
|
29
30
|
# @return [String] Returns html for alert
|
30
31
|
def alert(*args, &block)
|
31
|
-
|
32
|
+
body = alert_body(args, &block)
|
32
33
|
options = canonicalize_options(args.extract_options!)
|
33
34
|
options = ensure_class(options, 'alert')
|
34
35
|
options = add_alert_classes(options, args)
|
35
36
|
heading = options.delete(:heading)
|
36
37
|
show_close = options.delete(:close) != false
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
capture(&block)
|
43
|
-
end
|
44
|
-
else
|
45
|
-
content_tag(:div, options) do
|
46
|
-
alert_close(show_close) +
|
47
|
-
alert_heading(heading) +
|
48
|
-
text
|
49
|
-
end
|
39
|
+
content_tag(:div, options) do
|
40
|
+
alert_close(show_close) +
|
41
|
+
alert_heading(heading) +
|
42
|
+
body
|
50
43
|
end
|
51
44
|
end
|
52
45
|
|
53
46
|
# Return an alert box close button
|
54
47
|
#
|
55
|
-
# @return [String] html for alert close button
|
48
|
+
# @return [String] html for alert close button unless _show_ is +false+
|
56
49
|
def alert_close(show=true)
|
57
50
|
return '' unless show
|
58
51
|
content_tag(:button, '×'.html_safe, class: 'close', data: {dismiss: 'alert'})
|
@@ -60,7 +53,7 @@ module Bootstrap::AlertHelper
|
|
60
53
|
|
61
54
|
# Return an alert heading
|
62
55
|
#
|
63
|
-
# @return [String] html for alert heading
|
56
|
+
# @return [String] html for alert heading unless _heading_ is blank.
|
64
57
|
def alert_heading(heading)
|
65
58
|
return '' unless heading.present?
|
66
59
|
content_tag(:h4, heading)
|
@@ -68,6 +61,14 @@ module Bootstrap::AlertHelper
|
|
68
61
|
|
69
62
|
private
|
70
63
|
|
64
|
+
def alert_body(args, &block)
|
65
|
+
if block_given?
|
66
|
+
capture(&block)
|
67
|
+
else
|
68
|
+
args.shift
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
71
72
|
def add_alert_classes(options, alert_attributes)
|
72
73
|
validate_alert_attributes(alert_attributes)
|
73
74
|
classes = ['alert'] + alert_attributes.map { |e| "alert-#{e}" }
|
@@ -75,7 +76,7 @@ module Bootstrap::AlertHelper
|
|
75
76
|
end
|
76
77
|
|
77
78
|
def validate_alert_attributes(alert_attributes)
|
78
|
-
alert_attributes.each { |e| raise(
|
79
|
+
alert_attributes.each { |e| raise(InvalidAlertTypeError, e.inspect) unless ALERT_ATTRIBUTES.include?(e.to_s) }
|
79
80
|
end
|
80
81
|
|
81
82
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Rails helpers for producing flash messages styled as Bootstrap alert boxes.
|
2
|
+
#
|
3
|
+
# @example
|
4
|
+
# # in a layout or view
|
5
|
+
#
|
6
|
+
# flash_messages
|
7
|
+
# flash_messages close: false
|
8
|
+
# flash_messages class: 'flash', id: 'my-flash'
|
9
|
+
#
|
10
|
+
# # override default mapping
|
11
|
+
#
|
12
|
+
# Bootstrap::FlashHelper.mapping[:notice] = :success
|
13
|
+
# Bootstrap::FlashHelper.mapping[:mistake] = :error
|
14
|
+
#
|
15
|
+
module Bootstrap::FlashHelper
|
16
|
+
DEFAULT_MAPPING = {
|
17
|
+
:notice => :info,
|
18
|
+
:alert => :error,
|
19
|
+
}
|
20
|
+
|
21
|
+
mattr_accessor :mapping
|
22
|
+
self.mapping = DEFAULT_MAPPING.dup
|
23
|
+
|
24
|
+
# Returns Bootstrap alerts for each entry in +flash+
|
25
|
+
#
|
26
|
+
# @param options [Hash] unrecognized options are passed the the {Bootstrap::AlertHelper#alert} method
|
27
|
+
# @option options [Boolean] :close if +false+ the close button is not shown
|
28
|
+
# @return [String]
|
29
|
+
def flash_messages(options={})
|
30
|
+
messages = flash.map { |type, message| _bs_flash_for(type, message, options) }
|
31
|
+
safe_join(messages, "\n")
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def _bs_flash_for(type, message, options={})
|
37
|
+
options = canonicalize_options(options)
|
38
|
+
alert_class = _bs_alert_class_for(type)
|
39
|
+
options = ensure_class(options, alert_class)
|
40
|
+
|
41
|
+
alert(message, options)
|
42
|
+
end
|
43
|
+
|
44
|
+
def _bs_alert_class_for(type)
|
45
|
+
mapped_type = _bs_map_type(type)
|
46
|
+
|
47
|
+
"alert-#{mapped_type}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def _bs_map_type(type)
|
51
|
+
mapping[type.to_sym] || type
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# Rails helper for producing Bootstrap modal dialogs
|
2
|
+
#
|
3
|
+
module Bootstrap::ModalHelper
|
4
|
+
|
5
|
+
# Returns an A tag to trigger (open) a Boostrap modal
|
6
|
+
def modal_trigger(text, options={})
|
7
|
+
options = canonicalize_options(options)
|
8
|
+
href = options.delete(:href) or raise(ArgumentError, 'missing :href option')
|
9
|
+
options.merge!(role: 'button', href: href, data: { toggle: 'modal'})
|
10
|
+
options = ensure_class(options, 'btn')
|
11
|
+
|
12
|
+
content_tag(:a, text, options)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Returns a Bootstrap modal dialog
|
16
|
+
def modal(options={})
|
17
|
+
options = canonicalize_options(options)
|
18
|
+
options.has_key?(:id) or raise(ArgumentError, "missing :id option")
|
19
|
+
options = ensure_class(options, %w(modal hide fade))
|
20
|
+
options.merge!(tabindex: "-1", role: "dialog")
|
21
|
+
|
22
|
+
content_tag(:div, options) do
|
23
|
+
yield
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns a DIV for Bootstrap modal header
|
28
|
+
def modal_header(*args, &block)
|
29
|
+
options = canonicalize_options(args.extract_options!)
|
30
|
+
options = ensure_class(options, 'modal-header')
|
31
|
+
show_close = options.delete(:close) != false
|
32
|
+
|
33
|
+
content = block_given? ? capture(&block) : args.shift
|
34
|
+
|
35
|
+
content_tag(:div, options) do
|
36
|
+
modal_header_close_button(show_close) +
|
37
|
+
content_tag(:h3) do
|
38
|
+
content
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns a DIV for Bootstrap modal body
|
44
|
+
def modal_body(*args, &block)
|
45
|
+
options = canonicalize_options(args.extract_options!)
|
46
|
+
options = ensure_class(options, 'modal-body')
|
47
|
+
content = block_given? ? capture(&block) : args.shift
|
48
|
+
|
49
|
+
content_tag(:div, options) do
|
50
|
+
content
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Returns a DIV for Bootstrap modal footer
|
55
|
+
# Defaults to including #modal_footer_close_button.
|
56
|
+
def modal_footer(*args, &block)
|
57
|
+
options = canonicalize_options(args.extract_options!)
|
58
|
+
options = ensure_class(options, 'modal-footer')
|
59
|
+
|
60
|
+
content = if block_given?
|
61
|
+
capture(&block)
|
62
|
+
elsif args.size > 0
|
63
|
+
args.shift
|
64
|
+
else
|
65
|
+
modal_footer_close_button
|
66
|
+
end
|
67
|
+
|
68
|
+
content_tag(:div, options) do
|
69
|
+
content
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Returns a Bootstrap modal close button
|
74
|
+
def modal_header_close_button(show=true)
|
75
|
+
return ''.html_safe unless show
|
76
|
+
button("×".html_safe, type: 'button', class: 'close modal-close modal-header-close', data: {dismiss: 'modal'})
|
77
|
+
end
|
78
|
+
|
79
|
+
# Returns a close button for Bootstrap modal footer.
|
80
|
+
def modal_footer_close_button(*args)
|
81
|
+
options = canonicalize_options(args.extract_options!)
|
82
|
+
options = ensure_class(options, 'modal-close modal-footer-close')
|
83
|
+
options.merge!(data: {dismiss: 'modal'})
|
84
|
+
args.unshift("Close") if args.empty?
|
85
|
+
|
86
|
+
button(*args, options)
|
87
|
+
end
|
88
|
+
|
89
|
+
def modal_footer_ok_button(*args)
|
90
|
+
options = canonicalize_options(args.extract_options!)
|
91
|
+
options = ensure_class(options, 'modal-footer-ok')
|
92
|
+
options.merge!(data: {dismiss: 'modal'})
|
93
|
+
args.unshift("Ok") if args.empty?
|
94
|
+
|
95
|
+
button(*args, options)
|
96
|
+
end
|
97
|
+
|
98
|
+
def modal_alert(*args, &block)
|
99
|
+
options = canonicalize_options(args.extract_options!)
|
100
|
+
header = options.delete(:header) || "Alert"
|
101
|
+
|
102
|
+
modal(options) do
|
103
|
+
modal_header(header) +
|
104
|
+
modal_body(*args, &block) +
|
105
|
+
modal_footer
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def modal_confirm(*args, &block)
|
110
|
+
options = canonicalize_options(args.extract_options!)
|
111
|
+
header = options.delete(:header) || "Confirmation"
|
112
|
+
|
113
|
+
modal(options) do
|
114
|
+
modal_header(header) +
|
115
|
+
modal_body(*args, &block) +
|
116
|
+
modal_footer do
|
117
|
+
modal_footer_close_button(icon('remove', 'Cancel')) +
|
118
|
+
modal_footer_ok_button(icon('ok', :white, 'Ok'), :primary)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Rails helper for producing consistent Bootstrap styled tables.
|
2
|
+
#
|
3
|
+
# @example
|
4
|
+
# # in your view
|
5
|
+
#
|
6
|
+
# <%= bs_table_tag do %>
|
7
|
+
# ...
|
8
|
+
#
|
9
|
+
# <%= bs_table_tag(id: 'my-id', class: 'another-class') do %>
|
10
|
+
# ...
|
11
|
+
#
|
12
|
+
# # configure a custom set of classes:
|
13
|
+
# Bootstrap::TableHelper.classes[:admin] = %w(admin table table-striped table-compact)
|
14
|
+
#
|
15
|
+
# <%= bs_table_tag(:admin) do %>
|
16
|
+
#
|
17
|
+
#
|
18
|
+
module Bootstrap::TableHelper
|
19
|
+
InvalidClassListsKeyError = Class.new(StandardError)
|
20
|
+
|
21
|
+
DEFAULT_CLASS_LIST = %w(table table-bordered table-striped table-hover)
|
22
|
+
|
23
|
+
mattr_accessor :class_lists
|
24
|
+
self.class_lists = {default: DEFAULT_CLASS_LIST.dup}
|
25
|
+
|
26
|
+
# Produces a wrapper TABLE element with Bootstrap classes.
|
27
|
+
#
|
28
|
+
# @overload bs_table_tag(class_list=:default, options={})
|
29
|
+
# @param class_list [Symbol] a key of the +Bootstrap::class_lists+ Hash
|
30
|
+
# @param options [Hash] unrecognized options become attributes of the <table> element
|
31
|
+
# @return [String]
|
32
|
+
def bs_table_tag(*args, &block)
|
33
|
+
options = canonicalize_options(args.extract_options!)
|
34
|
+
table_classes = _get_table_classes(args.shift)
|
35
|
+
options = ensure_class(options, table_classes)
|
36
|
+
|
37
|
+
content_tag(:table, options) do
|
38
|
+
yield
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def _get_table_classes(key)
|
45
|
+
key = key.presence || :default
|
46
|
+
self.class_lists.fetch(key)
|
47
|
+
rescue KeyError
|
48
|
+
raise(InvalidClassListsKeyError, "did not find key: #{key.inspect} -- Did you forget to set Bootstrap::TableHelper.class_lists[#{key.inspect}]?")
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -2,11 +2,15 @@
|
|
2
2
|
|
3
3
|
<%= nav_list_header('Sidebar Header') %>
|
4
4
|
|
5
|
-
<%= dropdown_item('Icons', bvh_path('icons')) %>
|
6
|
-
<%= dropdown_item('Buttons', bvh_path('buttons')) %>
|
7
|
-
<%= dropdown_item('Labels and badges', bvh_path('labels_and_badges')) %>
|
8
5
|
<%= dropdown_item('Accordions', bvh_path('accordions')) %>
|
9
|
-
<%= dropdown_item('Form helpers', bvh_path('form_helpers')) %>
|
10
6
|
<%= dropdown_item('Alerts', bvh_path('alerts')) %>
|
7
|
+
<%= dropdown_item('Buttons', bvh_path('buttons')) %>
|
8
|
+
<%= dropdown_item('Icons', bvh_path('icons')) %>
|
9
|
+
<%= dropdown_item('Form helpers', bvh_path('form_helpers')) %>
|
10
|
+
<%= dropdown_item('Flash', bvh_path('flash_helper')) %>
|
11
|
+
<%= dropdown_item('Labels and badges', bvh_path('labels_and_badges')) %>
|
12
|
+
<%= dropdown_item('Modal Helpers', bvh_path('modal')) %>
|
13
|
+
<%= dropdown_item('Nav Helpers', bvh_path) %>
|
14
|
+
<%= dropdown_item('Table Helpers', bvh_path('tables')) %>
|
11
15
|
|
12
16
|
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= flash_messages class: 'foo' %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%= modal_trigger("Click to show Alert", href: '#alert') %>
|
2
|
+
<%= modal_trigger("Click to show Alert w/block", href: '#alert-block') %>
|
3
|
+
|
4
|
+
<%= modal_alert("Watch out", id: 'alert') %>
|
5
|
+
|
6
|
+
<%= modal_alert(id: 'alert-block', header: 'Custom Header') do %>
|
7
|
+
This is some <b>bold</b> text from the <code>modal_alert</code> block.
|
8
|
+
<% end %>
|
9
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= modal_trigger("Click to show modal", href: '#modal-2', class: 'btn btn-primary') %>
|
2
|
+
|
3
|
+
<%= modal(id: 'modal-2') do %>
|
4
|
+
<%= modal_header(close: false) do %>
|
5
|
+
Heading <small>(with no close button)</small>
|
6
|
+
<% end %>
|
7
|
+
<%= modal_body do %>
|
8
|
+
<h4>Modal Body</h4>
|
9
|
+
<p>With additional markup</p>
|
10
|
+
<% end %>
|
11
|
+
<%= modal_footer do %>
|
12
|
+
<%= button("Save", :primary) %>
|
13
|
+
<%= modal_footer_close_button("Dismiss") %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%= modal_trigger("Click to show Confirm", href: '#confirm') %>
|
2
|
+
<%= modal_trigger("Click to show Confirm w/block", href: '#confirm-block') %>
|
3
|
+
|
4
|
+
<%= modal_confirm("Watch out", id: 'confirm') %>
|
5
|
+
|
6
|
+
<%= modal_confirm(id: 'confirm-block', header: 'Custom Header') do %>
|
7
|
+
This is some <b>bold</b> text from the <code>modal_confirm</code> block.
|
8
|
+
<% end %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<h1>Flash Helper</h1>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<%= link_to('API Documentation', 'http://rubydoc.info/gems/bootstrap-view-helpers/Bootstrap/FlashHelper') %>
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<h2>Example</h2>
|
8
|
+
<%= render partial: 'flash_helper' %>
|
9
|
+
|
10
|
+
<h2>Source</h2>
|
11
|
+
<%= bvh_show_source('bootstrap_view_helpers/_flash_helper') %>
|
12
|
+
|
13
|
+
<pre>
|
14
|
+
# in controller
|
15
|
+
|
16
|
+
def my_action
|
17
|
+
flash.now[:notice] = ":notice is mapped to :info"
|
18
|
+
flash.now[:alert] = ":alert is mapped to :error"
|
19
|
+
flash.now[:warning] = 'Unrecognized types use Bootstrap default'
|
20
|
+
flash.now[:success] = "The operation was a success"
|
21
|
+
flash.now[:error] = "There was an error"
|
22
|
+
flash.now[:info] = "Here is some info"
|
23
|
+
end
|
24
|
+
</pre>
|
25
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<h1>Modal Helpers</h1>
|
2
|
+
|
3
|
+
<ul>
|
4
|
+
<li><%= link_to('Bootstrap Documentation', 'http://twitter.github.io/bootstrap/javascript.html#modals') %></li>
|
5
|
+
<li><%= link_to('API Documentation', 'http://rubydoc.info/gems/bootstrap-view-helpers/Bootstrap/ModalHelper') %>
|
6
|
+
</ul>
|
7
|
+
|
8
|
+
<h2>Basic Modal</h2>
|
9
|
+
|
10
|
+
<h3>Example</h3>
|
11
|
+
<%= render partial: 'modal_basic' %>
|
12
|
+
|
13
|
+
<h3>Source</h3>
|
14
|
+
<%= bvh_show_source('bootstrap_view_helpers/_modal_basic') %>
|
15
|
+
|
16
|
+
<h2>Modal Utilizing Options, block form</h2>
|
17
|
+
|
18
|
+
<h3>Example</h3>
|
19
|
+
<%= render partial: 'modal_block' %>
|
20
|
+
|
21
|
+
<h3>Source</h3>
|
22
|
+
<%= bvh_show_source('bootstrap_view_helpers/_modal_block') %>
|
23
|
+
|
24
|
+
<h2>Modal Alert</h2>
|
25
|
+
<p>Simulate a Javascript <code>alert</code>:</p>
|
26
|
+
|
27
|
+
<h3>Example</h3>
|
28
|
+
<%= render partial: 'modal_alert' %>
|
29
|
+
|
30
|
+
<h3>Source</h3>
|
31
|
+
<%= bvh_show_source('bootstrap_view_helpers/_modal_alert') %>
|
32
|
+
|
33
|
+
<h2>Modal Confirm</h2>
|
34
|
+
<p>Simulate a Javascript <code>confirm</code>:</p>
|
35
|
+
|
36
|
+
<h3>Example</h3>
|
37
|
+
<%= render partial: 'modal_confirm' %>
|
38
|
+
|
39
|
+
<h3>Source</h3>
|
40
|
+
<%= bvh_show_source('bootstrap_view_helpers/_modal_confirm') %>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<h1>Tables</h1>
|
2
|
+
|
3
|
+
<p><%= link_to('Bootstrap Documentation', 'http://twitter.github.io/bootstrap/base-css.html#tables') %>
|
4
|
+
|
5
|
+
<p>When all your tables are the same, don't keep repeating the bootstrap table classes.</p>
|
6
|
+
|
7
|
+
<p>Instead of this repeated for every table:</p>
|
8
|
+
|
9
|
+
<pre>
|
10
|
+
<%=h %(<table class='table table-bordered table-striped table-hover'>
|
11
|
+
...
|
12
|
+
</table>) %>
|
13
|
+
</pre>
|
14
|
+
|
15
|
+
<p>do this instead</p>
|
16
|
+
<%= bvh_show_source('bootstrap_view_helpers/_table_default') %>
|
17
|
+
|
18
|
+
<h2>Example</h2>
|
19
|
+
<%= render partial: 'table_example' %>
|
20
|
+
|
21
|
+
<h2>Source</h2>
|
22
|
+
<%= bvh_show_source('bootstrap_view_helpers/_table_example') %>
|
23
|
+
|
24
|
+
|
25
|
+
<h2>Configuration</h2>
|
26
|
+
|
27
|
+
<p>Change the default table classes (e.g., in an initializer):</p>
|
28
|
+
<pre>
|
29
|
+
Bootstrap::TableHelper.classes[:default] = ['table', 'table-hover']
|
30
|
+
</pre>
|
31
|
+
|
32
|
+
<p>Define named sets of classes:<p>
|
33
|
+
<pre>
|
34
|
+
Bootstrap::TableHelper.classes[:user] = ['user', 'table', 'table-striped', 'table-hover']
|
35
|
+
Bootstrap::TableHelper.classes[:admin] = ['admin', 'table', 'table-striped', 'table-hover', 'table-bordered', 'table-compact']
|
36
|
+
</pre>
|
37
|
+
|
38
|
+
<p>Specify the name when you call the helper:</p>
|
39
|
+
<%= bvh_show_source('bootstrap_view_helpers/_table_with_class') %>
|
40
|
+
|
41
|
+
<h2>Other HTML Attributes</h2>
|
42
|
+
<p>Unrecognized options become html attributes of the table:<p>
|
43
|
+
|
44
|
+
<pre>
|
45
|
+
# this call
|
46
|
+
bs_table_tag(id: 'my-id', class: 'another-class')
|
47
|
+
|
48
|
+
# produces
|
49
|
+
<%=h %(<table class="other-class table table-bordered table-striped table-hover" id="my-id">) %>
|
50
|
+
|
51
|
+
</pre>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap-view-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -282,27 +282,42 @@ files:
|
|
282
282
|
- app/helpers/bootstrap/button_helper.rb
|
283
283
|
- app/helpers/bootstrap/common_helper.rb
|
284
284
|
- app/helpers/bootstrap/dropdown_helper.rb
|
285
|
+
- app/helpers/bootstrap/flash_helper.rb
|
285
286
|
- app/helpers/bootstrap/form_helper.rb
|
286
287
|
- app/helpers/bootstrap/icon_helper.rb
|
287
288
|
- app/helpers/bootstrap/icon_renderer.rb
|
289
|
+
- app/helpers/bootstrap/modal_helper.rb
|
288
290
|
- app/helpers/bootstrap/nav_helper.rb
|
289
291
|
- app/helpers/bootstrap/stamp_helper.rb
|
292
|
+
- app/helpers/bootstrap/table_helper.rb
|
290
293
|
- app/helpers/bootstrap_examples/application_helper.rb
|
294
|
+
- app/TODO.md
|
291
295
|
- app/views/application/_bootstrap_view_helper_nav_bar.html.erb
|
292
296
|
- app/views/application/_bootstrap_view_helper_side_bar.html.erb
|
293
297
|
- app/views/bootstrap_view_helpers/_accordions.html.erb
|
294
298
|
- app/views/bootstrap_view_helpers/_alert_block.html.erb
|
295
299
|
- app/views/bootstrap_view_helpers/_alert_options.html.erb
|
296
300
|
- app/views/bootstrap_view_helpers/_alert_types.html.erb
|
301
|
+
- app/views/bootstrap_view_helpers/_flash_helper.html.erb
|
297
302
|
- app/views/bootstrap_view_helpers/_form_helper_1.html.erb
|
298
303
|
- app/views/bootstrap_view_helpers/_icons.html.erb
|
304
|
+
- app/views/bootstrap_view_helpers/_modal_alert.html.erb
|
305
|
+
- app/views/bootstrap_view_helpers/_modal_basic.html.erb
|
306
|
+
- app/views/bootstrap_view_helpers/_modal_block.html.erb
|
307
|
+
- app/views/bootstrap_view_helpers/_modal_confirm.html.erb
|
308
|
+
- app/views/bootstrap_view_helpers/_table_default.html.erb
|
309
|
+
- app/views/bootstrap_view_helpers/_table_example.html.erb
|
310
|
+
- app/views/bootstrap_view_helpers/_table_with_class.html.erb
|
299
311
|
- app/views/bootstrap_view_helpers/accordions.html.erb
|
300
312
|
- app/views/bootstrap_view_helpers/alerts.html.erb
|
301
313
|
- app/views/bootstrap_view_helpers/buttons.html.erb
|
314
|
+
- app/views/bootstrap_view_helpers/flash_helper.html.erb
|
302
315
|
- app/views/bootstrap_view_helpers/form_helpers.html.erb
|
303
316
|
- app/views/bootstrap_view_helpers/icons.html.erb
|
304
317
|
- app/views/bootstrap_view_helpers/index.html.erb
|
305
318
|
- app/views/bootstrap_view_helpers/labels_and_badges.html.erb
|
319
|
+
- app/views/bootstrap_view_helpers/modal.html.erb
|
320
|
+
- app/views/bootstrap_view_helpers/tables.html.erb
|
306
321
|
- app/views/layouts/bootstrap_view_helpers.html.erb
|
307
322
|
- config/routes.rb
|
308
323
|
- lib/bootstrap-view-helpers/engine.rb
|