bootstrap_it 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/bootstrap_it.gemspec +9 -8
- data/lib/bootstrap_it/config.rb +1 -1
- data/lib/bootstrap_it/engine.rb +1 -1
- data/lib/bootstrap_it/version.rb +1 -1
- data/lib/bootstrap_it/view_helpers.rb +4 -1
- data/lib/bootstrap_it/view_helpers/breadcrumb.rb +3 -2
- data/lib/bootstrap_it/view_helpers/button.rb +47 -39
- data/lib/bootstrap_it/view_helpers/button_group.rb +23 -4
- data/lib/bootstrap_it/view_helpers/dropdown_menu.rb +6 -5
- data/lib/bootstrap_it/view_helpers/form.rb +40 -41
- data/lib/bootstrap_it/view_helpers/grid.rb +9 -5
- data/lib/bootstrap_it/view_helpers/icon.rb +4 -2
- data/lib/bootstrap_it/view_helpers/list.rb +5 -5
- data/lib/bootstrap_it/view_helpers/misc.rb +37 -36
- data/lib/bootstrap_it/view_helpers/mixin.rb +16 -24
- data/lib/bootstrap_it/view_helpers/nav.rb +23 -21
- data/lib/bootstrap_it/view_helpers/pagination.rb +8 -6
- data/lib/bootstrap_it/view_helpers/table.rb +6 -10
- data/lib/bootstrap_it/view_helpers/text.rb +10 -8
- data/spec/spec_helper.rb +5 -2
- data/spec/support/example_groups/view_helpers_example_group.rb +4 -5
- data/spec/view_helpers/breadcrumb_spec.rb +8 -4
- data/spec/view_helpers/button_group_spec.rb +4 -4
- data/spec/view_helpers/button_spec.rb +25 -23
- data/spec/view_helpers/button_toolbar_spec.rb +3 -3
- data/spec/view_helpers/dropdown_menu_spec.rb +9 -9
- data/spec/view_helpers/form_spec.rb +4 -4
- data/spec/view_helpers/grid_spec.rb +5 -5
- data/spec/view_helpers/icon_spec.rb +2 -2
- data/spec/view_helpers/list_spec.rb +9 -9
- data/spec/view_helpers/misc_spec.rb +11 -11
- data/spec/view_helpers/mixin_spec.rb +49 -38
- data/spec/view_helpers/nav_spec.rb +14 -10
- data/spec/view_helpers/pagination_spec.rb +6 -6
- data/spec/view_helpers/table_spec.rb +9 -10
- data/spec/view_helpers/text_spec.rb +3 -3
- data/spec/views/examples_spec.rb +49 -36
- metadata +31 -32
- data/lib/bootstrap_it/view_helpers/button_toolbar.rb +0 -21
@@ -4,8 +4,9 @@ module BootstrapIt
|
|
4
4
|
#
|
5
5
|
# Grid
|
6
6
|
#
|
7
|
-
# @author
|
7
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
8
8
|
#
|
9
|
+
# @see http://getbootstrap.com/css/#grid Bootstrap docs
|
9
10
|
class Grid < WrapIt::Container
|
10
11
|
html_class 'container'
|
11
12
|
child :row, 'BootstrapIt::ViewHelpers::GridRow'
|
@@ -14,14 +15,15 @@ module BootstrapIt
|
|
14
15
|
#
|
15
16
|
# GridRow
|
16
17
|
#
|
17
|
-
# @author
|
18
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
18
19
|
#
|
19
20
|
class GridRow < WrapIt::Container
|
20
21
|
#
|
21
22
|
# Clearfix
|
22
23
|
#
|
23
|
-
# @author
|
24
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
24
25
|
#
|
26
|
+
# @see http://getbootstrap.com/css/#grid-responsive-resets Bootstrap docs
|
25
27
|
class Clearfix < WrapIt::Base
|
26
28
|
TYPES = %w(visible-xs visible-sm visible-md visible-lg
|
27
29
|
hidden-xs hidden-sm hidden-md hidden-lg)
|
@@ -30,7 +32,9 @@ module BootstrapIt
|
|
30
32
|
[-_]?
|
31
33
|
(?:(?:extra[-_]?small)|xs|small|sm|medium|md|large|lg)
|
32
34
|
\z/xi
|
35
|
+
|
33
36
|
html_class 'clearfix'
|
37
|
+
|
34
38
|
after_initialize do
|
35
39
|
type = @arguments.extract_first!(Symbol, String, and: [REGEXP]) ||
|
36
40
|
'visible-md'
|
@@ -55,7 +59,7 @@ module BootstrapIt
|
|
55
59
|
#
|
56
60
|
# GridCell
|
57
61
|
#
|
58
|
-
# @author
|
62
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
59
63
|
#
|
60
64
|
class GridCell < WrapIt::Container
|
61
65
|
include SizableColumn
|
@@ -70,6 +74,6 @@ module BootstrapIt
|
|
70
74
|
end
|
71
75
|
end
|
72
76
|
|
73
|
-
|
77
|
+
register :grid, 'BootstrapIt::ViewHelpers::Grid'
|
74
78
|
end
|
75
79
|
end
|
@@ -4,8 +4,10 @@ module BootstrapIt
|
|
4
4
|
#
|
5
5
|
# Icon
|
6
6
|
#
|
7
|
-
# @author
|
7
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
8
8
|
#
|
9
|
+
# @see http://getbootstrap.com/components/#glyphicons Bootstrap docs
|
10
|
+
# @see http://fontawesome.io/icons/ Font awesome icon list
|
9
11
|
class Icon < WrapIt::Base
|
10
12
|
omit_content
|
11
13
|
|
@@ -19,6 +21,6 @@ module BootstrapIt
|
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
|
-
|
24
|
+
register :icon, 'BootstrapIt::ViewHelpers::Icon'
|
23
25
|
end
|
24
26
|
end
|
@@ -4,21 +4,21 @@ module BootstrapIt
|
|
4
4
|
#
|
5
5
|
# ListItem
|
6
6
|
#
|
7
|
-
# @author
|
7
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
8
8
|
#
|
9
9
|
class ListItem < WrapIt::Base
|
10
|
-
|
11
|
-
|
10
|
+
include WrapIt::TextContainer
|
12
11
|
include Activable
|
13
12
|
include Disableable
|
14
|
-
|
13
|
+
|
14
|
+
default_tag 'li'
|
15
15
|
end
|
16
16
|
|
17
17
|
|
18
18
|
#
|
19
19
|
# ListLinkItem
|
20
20
|
#
|
21
|
-
# @author
|
21
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
22
22
|
#
|
23
23
|
class ListLinkItem < WrapIt::Link
|
24
24
|
REGEXP = /\Ali_/
|
@@ -4,15 +4,16 @@ module BootstrapIt
|
|
4
4
|
#
|
5
5
|
# Jumbotron
|
6
6
|
#
|
7
|
-
# @author
|
7
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
8
8
|
#
|
9
|
+
# @see http://getbootstrap.com/components/#jumbotron Bootstrap docs
|
9
10
|
class Jumbotron < WrapIt::Base
|
10
11
|
html_class 'jumbotron'
|
11
12
|
switch :full_width
|
12
13
|
|
13
14
|
after_capture do
|
14
|
-
full_width? &&
|
15
|
-
'div',
|
15
|
+
full_width? && self[:content] = content_tag(
|
16
|
+
'div', render_sections, class: 'container'
|
16
17
|
)
|
17
18
|
end
|
18
19
|
end
|
@@ -20,8 +21,9 @@ module BootstrapIt
|
|
20
21
|
#
|
21
22
|
# PageHeader
|
22
23
|
#
|
23
|
-
# @author
|
24
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
24
25
|
#
|
26
|
+
# @see http://getbootstrap.com/components/#page-header Bootstrap docs
|
25
27
|
class PageHeader < WrapIt::Base
|
26
28
|
html_class 'page-header'
|
27
29
|
end
|
@@ -29,8 +31,9 @@ module BootstrapIt
|
|
29
31
|
#
|
30
32
|
# Alert
|
31
33
|
#
|
32
|
-
# @author
|
34
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
33
35
|
#
|
36
|
+
# @see http://getbootstrap.com/components/#alerts Bootstrap docs
|
34
37
|
class Alert < WrapIt::Container
|
35
38
|
include WrapIt::TextContainer
|
36
39
|
|
@@ -40,18 +43,20 @@ module BootstrapIt
|
|
40
43
|
enum :appearence, %i(success info warning danger),
|
41
44
|
default: :success, html_class: true
|
42
45
|
switch :dismissable, html_class: true
|
43
|
-
child :link, 'WrapIt::Link',
|
46
|
+
child :link, 'WrapIt::Link', class: 'alert-link'
|
47
|
+
section :dismissable
|
48
|
+
place :dismissable, before: :content
|
44
49
|
|
45
|
-
|
50
|
+
after_capture do
|
46
51
|
if dismissable?
|
47
|
-
|
52
|
+
self[:dismissable] = content_tag(
|
48
53
|
'button',
|
49
54
|
html_safe('×'),
|
50
55
|
type: 'button',
|
51
56
|
class: 'close',
|
52
57
|
data: {dismiss: 'alert'},
|
53
58
|
'aria-hidden' => true
|
54
|
-
)
|
59
|
+
)
|
55
60
|
end
|
56
61
|
end
|
57
62
|
end
|
@@ -59,8 +64,9 @@ module BootstrapIt
|
|
59
64
|
#
|
60
65
|
# ProgressBar
|
61
66
|
#
|
62
|
-
# @author
|
67
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
63
68
|
#
|
69
|
+
# @see http://getbootstrap.com/components/#progress Bootstrap docs
|
64
70
|
class ProgressBar < WrapIt::Base
|
65
71
|
include WrapIt::TextContainer
|
66
72
|
|
@@ -85,24 +91,27 @@ module BootstrapIt
|
|
85
91
|
@options[:style] = "width: #{@completed}%"
|
86
92
|
end
|
87
93
|
|
88
|
-
|
94
|
+
after_capture do
|
95
|
+
rendered = render_sections
|
89
96
|
text =
|
90
|
-
if
|
97
|
+
if rendered.empty?
|
91
98
|
I18n.translate(
|
92
99
|
'bootstrap_it.progress_bar.text', completed: @completed
|
93
100
|
)
|
94
101
|
else
|
95
|
-
|
102
|
+
rendered
|
96
103
|
end
|
97
|
-
|
104
|
+
# TODO: do it with wrap when simple wrapping will be coded
|
105
|
+
self[:content] = content_tag('span', text, class: 'sr-only')
|
98
106
|
end
|
99
107
|
end
|
100
108
|
|
101
109
|
#
|
102
110
|
# Progress
|
103
111
|
#
|
104
|
-
# @author
|
112
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
105
113
|
#
|
114
|
+
# @see http://getbootstrap.com/components/#progress Bootstrap docs
|
106
115
|
class Progress < WrapIt::Container
|
107
116
|
include Activable
|
108
117
|
|
@@ -110,35 +119,27 @@ module BootstrapIt
|
|
110
119
|
html_class_prefix 'progress-'
|
111
120
|
|
112
121
|
child :bar, 'BootstrapIt::ViewHelpers::ProgressBar'
|
113
|
-
|
114
122
|
switch :striped, html_class: true
|
123
|
+
section :first_bar
|
124
|
+
place :first_bar, before: :content
|
115
125
|
|
116
126
|
after_initialize do
|
117
|
-
|
127
|
+
self.deffered_render = true
|
128
|
+
args = @arguments.clone
|
118
129
|
# TODO: PORTABILITY: replace deep_dup (Rails)
|
119
130
|
opts = @options.deep_dup
|
120
131
|
opts[:class].select! { |o| o != 'progress' && o != 'progress-striped' }
|
121
|
-
|
132
|
+
opts[:section] = :first_bar
|
133
|
+
args.push(opts)
|
134
|
+
bar(*args)
|
122
135
|
end
|
123
|
-
|
124
|
-
after_capture do
|
125
|
-
@content = capture do
|
126
|
-
ProgressBar.new(@template, *@first_bar_args).render
|
127
|
-
end + @content
|
128
|
-
end
|
129
|
-
|
130
|
-
# after_capture do
|
131
|
-
# @content = capture do
|
132
|
-
# @bars.reduce(empty_html) { |a, e| a += e.render }
|
133
|
-
# end + @content
|
134
|
-
# end
|
135
136
|
end
|
136
137
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
138
|
+
register :jumbotron, 'BootstrapIt::ViewHelpers::Jumbotron'
|
139
|
+
register :jumbo, 'BootstrapIt::ViewHelpers::Jumbotron'
|
140
|
+
register :page_header, 'BootstrapIt::ViewHelpers::PageHeader'
|
141
|
+
register :alert_box, 'BootstrapIt::ViewHelpers::Alert'
|
142
|
+
register :progress_bar, 'BootstrapIt::ViewHelpers::Progress'
|
143
|
+
register :progress, 'BootstrapIt::ViewHelpers::Progress'
|
143
144
|
end
|
144
145
|
end
|
@@ -4,7 +4,7 @@ module BootstrapIt
|
|
4
4
|
#
|
5
5
|
# SizableColumn
|
6
6
|
#
|
7
|
-
# @author
|
7
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
8
8
|
#
|
9
9
|
module SizableColumn
|
10
10
|
extend ActiveSupport::Concern
|
@@ -56,7 +56,7 @@ module BootstrapIt
|
|
56
56
|
#
|
57
57
|
# PlacableColumn
|
58
58
|
#
|
59
|
-
# @author
|
59
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
60
60
|
#
|
61
61
|
module PlacableColumn
|
62
62
|
extend ActiveSupport::Concern
|
@@ -122,7 +122,7 @@ module BootstrapIt
|
|
122
122
|
#
|
123
123
|
# Contextual
|
124
124
|
#
|
125
|
-
# @author
|
125
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
126
126
|
#
|
127
127
|
module Contextual
|
128
128
|
extend ActiveSupport::Concern
|
@@ -134,7 +134,7 @@ module BootstrapIt
|
|
134
134
|
#
|
135
135
|
# Activable
|
136
136
|
#
|
137
|
-
# @author
|
137
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
138
138
|
#
|
139
139
|
module Activable
|
140
140
|
extend ActiveSupport::Concern
|
@@ -146,7 +146,7 @@ module BootstrapIt
|
|
146
146
|
#
|
147
147
|
# Disablable
|
148
148
|
#
|
149
|
-
# @author
|
149
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
150
150
|
#
|
151
151
|
module Disableable
|
152
152
|
extend ActiveSupport::Concern
|
@@ -172,7 +172,7 @@ module BootstrapIt
|
|
172
172
|
#
|
173
173
|
# Sizable
|
174
174
|
#
|
175
|
-
# @author
|
175
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
176
176
|
#
|
177
177
|
module Sizable
|
178
178
|
extend ActiveSupport::Concern
|
@@ -219,7 +219,7 @@ module BootstrapIt
|
|
219
219
|
#
|
220
220
|
# Justifable
|
221
221
|
#
|
222
|
-
# @author
|
222
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
223
223
|
#
|
224
224
|
module Justifable
|
225
225
|
extend ActiveSupport::Concern
|
@@ -231,43 +231,35 @@ module BootstrapIt
|
|
231
231
|
#
|
232
232
|
# DropdownMenuWrapper
|
233
233
|
#
|
234
|
-
# @author
|
234
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
235
235
|
#
|
236
236
|
module DropdownMenuWrapper
|
237
237
|
extend ActiveSupport::Concern
|
238
238
|
|
239
239
|
included do |base|
|
240
|
-
# puts "--- #{base.name}"
|
241
240
|
base <= WrapIt::Container || fail(
|
242
241
|
TypeError, 'Can be included only into WrapIt::Container subclasses'
|
243
242
|
)
|
244
|
-
|
243
|
+
|
245
244
|
child :dropdown_menu, 'BootstrapIt::ViewHelpers::DropdownMenu'
|
245
|
+
|
246
246
|
after_initialize do
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
unless @dropdown_items.empty?
|
251
|
-
@content += capture do
|
252
|
-
items = @dropdown_items
|
253
|
-
dropdown_menu do |menu|
|
254
|
-
items.each { |item| menu.send(item[0], *item[1], &item[2]) }
|
255
|
-
end
|
256
|
-
end
|
257
|
-
end
|
247
|
+
self.deffered_render = true
|
248
|
+
dropdown_menu deffered_render: true
|
249
|
+
@dropdown_menu = children.first
|
258
250
|
end
|
259
251
|
end
|
260
252
|
|
261
253
|
def header(*args, &block)
|
262
|
-
@
|
254
|
+
@dropdown_menu.header(*args, &block)
|
263
255
|
end
|
264
256
|
|
265
257
|
def divider(*args, &block)
|
266
|
-
@
|
258
|
+
@dropdown_menu.divider(*args, &block)
|
267
259
|
end
|
268
260
|
|
269
261
|
def link_item(*args, &block)
|
270
|
-
@
|
262
|
+
@dropdown_menu.link_item(*args, &block)
|
271
263
|
end
|
272
264
|
end
|
273
265
|
|
@@ -4,7 +4,7 @@ module BootstrapIt
|
|
4
4
|
#
|
5
5
|
# DropdownNavItem
|
6
6
|
#
|
7
|
-
# @author
|
7
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
8
8
|
#
|
9
9
|
class DropdownNavItem < WrapIt::Container
|
10
10
|
include WrapIt::TextContainer
|
@@ -14,16 +14,14 @@ module BootstrapIt
|
|
14
14
|
|
15
15
|
default_tag 'li'
|
16
16
|
html_class 'dropdown'
|
17
|
+
place :children, before: :end
|
17
18
|
|
18
19
|
after_capture do
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
# TODO: Replace 'link_to'
|
25
|
-
@content = @template.link_to(
|
26
|
-
body, '#', class: 'dropdown-toggle', data: {toggle: 'dropdown'}
|
20
|
+
rendered = render_sections(except: :children)
|
21
|
+
rendered << html_safe(' ') << content_tag('span', '', class: 'caret')
|
22
|
+
self[:content] = @template.content_tag(
|
23
|
+
'a', rendered, href: '#', class: 'dropdown-toggle',
|
24
|
+
data: {toggle: 'dropdown'}
|
27
25
|
)
|
28
26
|
end
|
29
27
|
end
|
@@ -31,8 +29,9 @@ module BootstrapIt
|
|
31
29
|
#
|
32
30
|
# Nav
|
33
31
|
#
|
34
|
-
# @author
|
32
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
35
33
|
#
|
34
|
+
# @see http://getbootstrap.com/components/#nav Bootstrap docs
|
36
35
|
class Nav < WrapIt::Container
|
37
36
|
include Justifable
|
38
37
|
|
@@ -46,8 +45,9 @@ module BootstrapIt
|
|
46
45
|
#
|
47
46
|
# NavPills
|
48
47
|
#
|
49
|
-
# @author
|
48
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
50
49
|
#
|
50
|
+
# @see http://getbootstrap.com/components/#nav-pills Bootstrap docs
|
51
51
|
class NavPills < Nav
|
52
52
|
default_tag 'ul'
|
53
53
|
switch :stacked, html_class: 'nav-stacked'
|
@@ -57,8 +57,9 @@ module BootstrapIt
|
|
57
57
|
#
|
58
58
|
# NavTabs
|
59
59
|
#
|
60
|
-
# @author
|
60
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
61
61
|
#
|
62
|
+
# @see http://getbootstrap.com/components/#nav-tabs Bootstrap docs
|
62
63
|
class NavTabs < Nav
|
63
64
|
default_tag 'ul'
|
64
65
|
html_class 'nav-tabs'
|
@@ -67,8 +68,9 @@ module BootstrapIt
|
|
67
68
|
#
|
68
69
|
# NavBar
|
69
70
|
#
|
70
|
-
# @author
|
71
|
+
# @author Alexey Ovchinnikov <alexiss@cybernetlab.ru>
|
71
72
|
#
|
73
|
+
# @see http://getbootstrap.com/components/#navbar Bootstrap docs
|
72
74
|
class NavBar < WrapIt::Container
|
73
75
|
default_tag 'nav'
|
74
76
|
html_class 'navbar'
|
@@ -81,16 +83,16 @@ module BootstrapIt
|
|
81
83
|
@options[:role] = 'navigation'
|
82
84
|
end
|
83
85
|
|
84
|
-
child :button, 'BootstrapIt::ViewHelpers::Button',
|
85
|
-
child :text, 'BootstrapIt::ViewHelpers::Text',
|
86
|
+
child :button, 'BootstrapIt::ViewHelpers::Button', class: 'navbar-btn'
|
87
|
+
child :text, 'BootstrapIt::ViewHelpers::Text', class: 'navbar-text'
|
86
88
|
alias_method :p, :text
|
87
|
-
child :span, 'BootstrapIt::ViewHelpers::Text',
|
89
|
+
child :span, 'BootstrapIt::ViewHelpers::Text', class: 'navbar-text'
|
88
90
|
end
|
89
91
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
92
|
+
register :nav_pills, 'BootstrapIt::ViewHelpers::NavPills'
|
93
|
+
register :pills, 'BootstrapIt::ViewHelpers::NavPills'
|
94
|
+
register :nav_tabs, 'BootstrapIt::ViewHelpers::NavTabs'
|
95
|
+
register :tabs, 'BootstrapIt::ViewHelpers::NavTabs'
|
96
|
+
register :navbar, 'BootstrapIt::ViewHelpers::NavBar'
|
95
97
|
end
|
96
98
|
end
|