twitter_bootstrap_builder 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -18
- data/Gemfile +4 -4
- data/LICENSE +21 -21
- data/README.md +29 -29
- data/Rakefile +2 -2
- data/app/views/kaminari/twitter_bootstrap/_first_page.html.haml +15 -15
- data/app/views/kaminari/twitter_bootstrap/_gap.html.haml +8 -8
- data/app/views/kaminari/twitter_bootstrap/_last_page.html.haml +12 -12
- data/app/views/kaminari/twitter_bootstrap/_next_page.html.haml +13 -13
- data/app/views/kaminari/twitter_bootstrap/_page.html.haml +15 -15
- data/app/views/kaminari/twitter_bootstrap/_paginator.html.haml +20 -20
- data/app/views/kaminari/twitter_bootstrap/_prev_page.html.haml +13 -13
- data/lib/twitter_bootstrap_builder.rb +26 -26
- data/lib/twitter_bootstrap_builder/builders/base.rb +19 -19
- data/lib/twitter_bootstrap_builder/builders/drop_down_builder.rb +19 -19
- data/lib/twitter_bootstrap_builder/builders/drop_down_button_builder.rb +10 -10
- data/lib/twitter_bootstrap_builder/builders/drop_down_link_builder.rb +10 -10
- data/lib/twitter_bootstrap_builder/builders/fieldset_builder.rb +116 -116
- data/lib/twitter_bootstrap_builder/builders/form_builder.rb +10 -10
- data/lib/twitter_bootstrap_builder/builders/link_button_builder.rb +14 -14
- data/lib/twitter_bootstrap_builder/builders/nav_bar_builder.rb +24 -24
- data/lib/twitter_bootstrap_builder/builders/nav_container_builder.rb +38 -38
- data/lib/twitter_bootstrap_builder/builders/nav_list_builder.rb +37 -37
- data/lib/twitter_bootstrap_builder/builders/submit_button_builder.rb +14 -14
- data/lib/twitter_bootstrap_builder/builders/tab_builder.rb +22 -22
- data/lib/twitter_bootstrap_builder/builders/table_builder.rb +77 -77
- data/lib/twitter_bootstrap_builder/engine.rb +16 -16
- data/lib/twitter_bootstrap_builder/extensions/twitter_bootstrap_markup.rb +6 -6
- data/lib/twitter_bootstrap_builder/helpers/buttons_helper.rb +50 -50
- data/lib/twitter_bootstrap_builder/helpers/commons_helper.rb +148 -114
- data/lib/twitter_bootstrap_builder/helpers/dropdowns_helper.rb +32 -32
- data/lib/twitter_bootstrap_builder/version.rb +3 -3
- data/twitter_bootstrap_builder.gemspec +20 -20
- data/vendor/assets/javascripts/bootstrap.js +1737 -1737
- data/vendor/assets/javascripts/twitter_bootstrap_builder.js +27 -27
- data/vendor/assets/stylesheets/bootstrap.css +4914 -4914
- data/vendor/assets/stylesheets/twitter_bootstrap_builder.css +57 -33
- metadata +17 -7
@@ -1,20 +1,20 @@
|
|
1
|
-
module TwitterBootstrapBuilder
|
2
|
-
module Builders
|
3
|
-
class DropDownBuilder < Base
|
4
|
-
|
5
|
-
def to_s
|
6
|
-
dropdown = self.dropdown_class.new(options[:text])
|
7
|
-
dropdown.append template.capture(self, &block) if block
|
8
|
-
dropdown.send(options[:type]) if options[:type] && dropdown.respond_to?(options[:type])
|
9
|
-
dropdown.send(options[:size]) if options[:size] && dropdown.respond_to?(options[:size])
|
10
|
-
dropdown.as_nav_item if dropdown.respond_to? :as_nav_item
|
11
|
-
dropdown.to_s
|
12
|
-
end
|
13
|
-
|
14
|
-
def link_to(*args, &block)
|
15
|
-
Tag.block(:li, template.link_to(*args, &block)).html_safe
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
1
|
+
module TwitterBootstrapBuilder
|
2
|
+
module Builders
|
3
|
+
class DropDownBuilder < Base
|
4
|
+
|
5
|
+
def to_s
|
6
|
+
dropdown = self.dropdown_class.new(options[:text])
|
7
|
+
dropdown.append template.capture(self, &block) if block
|
8
|
+
dropdown.send(options[:type]) if options[:type] && dropdown.respond_to?(options[:type])
|
9
|
+
dropdown.send(options[:size]) if options[:size] && dropdown.respond_to?(options[:size])
|
10
|
+
dropdown.as_nav_item if dropdown.respond_to? :as_nav_item
|
11
|
+
dropdown.to_s
|
12
|
+
end
|
13
|
+
|
14
|
+
def link_to(*args, &block)
|
15
|
+
Tag.block(:li, template.link_to(*args, &block)).html_safe
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
20
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module TwitterBootstrapBuilder
|
2
|
-
module Builders
|
3
|
-
class DropDownButtonBuilder < DropDownBuilder
|
4
|
-
|
5
|
-
def dropdown_class
|
6
|
-
DropdownButton
|
7
|
-
end
|
8
|
-
|
9
|
-
end
|
10
|
-
end
|
1
|
+
module TwitterBootstrapBuilder
|
2
|
+
module Builders
|
3
|
+
class DropDownButtonBuilder < DropDownBuilder
|
4
|
+
|
5
|
+
def dropdown_class
|
6
|
+
DropdownButton
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
end
|
11
11
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module TwitterBootstrapBuilder
|
2
|
-
module Builders
|
3
|
-
class DropDownLinkBuilder < DropDownBuilder
|
4
|
-
|
5
|
-
def dropdown_class
|
6
|
-
DropdownLink
|
7
|
-
end
|
8
|
-
|
9
|
-
end
|
10
|
-
end
|
1
|
+
module TwitterBootstrapBuilder
|
2
|
+
module Builders
|
3
|
+
class DropDownLinkBuilder < DropDownBuilder
|
4
|
+
|
5
|
+
def dropdown_class
|
6
|
+
DropdownLink
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
end
|
11
11
|
end
|
@@ -1,117 +1,117 @@
|
|
1
|
-
module TwitterBootstrapBuilder
|
2
|
-
module Builders
|
3
|
-
class FieldsetBuilder < Base
|
4
|
-
|
5
|
-
def to_s
|
6
|
-
fieldset = Tag.block(:fieldset, class: 'form-horizontal')
|
7
|
-
fieldset.append template.capture(self, &block) if block
|
8
|
-
fieldset.to_s
|
9
|
-
end
|
10
|
-
|
11
|
-
def form_builder
|
12
|
-
options[:form_builder]
|
13
|
-
end
|
14
|
-
|
15
|
-
def model
|
16
|
-
options[:model] || form_builder.object
|
17
|
-
end
|
18
|
-
|
19
|
-
def actions(&block)
|
20
|
-
actions = Tag.block(:div, class: 'form-actions')
|
21
|
-
actions.append template.capture(self, &block) if block
|
22
|
-
actions.html_safe
|
23
|
-
end
|
24
|
-
|
25
|
-
def display_field(method, options={})
|
26
|
-
ControlGroup.new(options[:label] || model.class.human_attribute_name(method)) do |cg|
|
27
|
-
cg.append Tag.block(:span, model.send(method).to_s.gsub("\n", '<br>'), class: 'display')
|
28
|
-
end.html_safe
|
29
|
-
end
|
30
|
-
|
31
|
-
def text_field(method, options={})
|
32
|
-
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
33
|
-
cg.append form_builder.text_field(method, options)
|
34
|
-
end.html_safe
|
35
|
-
end
|
36
|
-
|
37
|
-
TwitterBootstrapMarkup::InputSize::VALUES.each do |size|
|
38
|
-
define_method "text_field_#{size}" do |method, options={}|
|
39
|
-
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
40
|
-
options.append!(:class, "input-#{size}")
|
41
|
-
cg.append form_builder.text_field(method, options)
|
42
|
-
end.html_safe
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def text_area(method, options={})
|
47
|
-
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
48
|
-
cg.append form_builder.text_area(method, options)
|
49
|
-
end.html_safe
|
50
|
-
end
|
51
|
-
|
52
|
-
TwitterBootstrapMarkup::InputSize::VALUES.each do |size|
|
53
|
-
define_method "text_area_#{size}" do |method, options={}|
|
54
|
-
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
55
|
-
options.append!(:class, "input-#{size}")
|
56
|
-
cg.append form_builder.text_area(method, options)
|
57
|
-
end.html_safe
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def email_field(method, options={})
|
62
|
-
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
63
|
-
cg.append form_builder.email_field(method, options)
|
64
|
-
end.html_safe
|
65
|
-
end
|
66
|
-
|
67
|
-
def password_field(method, options={})
|
68
|
-
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
69
|
-
cg.append form_builder.password_field(method, options)
|
70
|
-
end.html_safe
|
71
|
-
end
|
72
|
-
|
73
|
-
def check_box(method, options={})
|
74
|
-
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
75
|
-
cg.append form_builder.check_box(method, options)
|
76
|
-
end.html_safe
|
77
|
-
end
|
78
|
-
|
79
|
-
def hidden_field(method, options={})
|
80
|
-
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
81
|
-
cg.append form_builder.hidden_field(method, options)
|
82
|
-
end.html_safe
|
83
|
-
end
|
84
|
-
|
85
|
-
def select(method, choices, options={}, html_options={})
|
86
|
-
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
87
|
-
cg.append form_builder.select(method, choices, options, html_options)
|
88
|
-
end.html_safe
|
89
|
-
end
|
90
|
-
|
91
|
-
def date_select(method, options={}, html_options={})
|
92
|
-
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
93
|
-
cg.append form_builder.date_select(method, form_builder.send('objectify_options', options), html_options)
|
94
|
-
end.html_safe
|
95
|
-
end
|
96
|
-
|
97
|
-
def time_select(method, options={}, html_options={})
|
98
|
-
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
99
|
-
cg.append form_builder.time_select(method, form_builder.send('objectify_options', options), html_options)
|
100
|
-
end.html_safe
|
101
|
-
end
|
102
|
-
|
103
|
-
def datetime_select(method, options={}, html_options={})
|
104
|
-
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
105
|
-
cg.append form_builder.datetime_select(method, form_builder.send('objectify_options', options), html_options)
|
106
|
-
end.html_safe
|
107
|
-
end
|
108
|
-
|
109
|
-
def custom_field(label, options={}, &block)
|
110
|
-
ControlGroup.new(label, options) do |cg|
|
111
|
-
cg.append template.capture(self, &block) if block
|
112
|
-
end.html_safe
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
end
|
1
|
+
module TwitterBootstrapBuilder
|
2
|
+
module Builders
|
3
|
+
class FieldsetBuilder < Base
|
4
|
+
|
5
|
+
def to_s
|
6
|
+
fieldset = Tag.block(:fieldset, class: 'form-horizontal')
|
7
|
+
fieldset.append template.capture(self, &block) if block
|
8
|
+
fieldset.to_s
|
9
|
+
end
|
10
|
+
|
11
|
+
def form_builder
|
12
|
+
options[:form_builder]
|
13
|
+
end
|
14
|
+
|
15
|
+
def model
|
16
|
+
options[:model] || form_builder.object
|
17
|
+
end
|
18
|
+
|
19
|
+
def actions(&block)
|
20
|
+
actions = Tag.block(:div, class: 'form-actions')
|
21
|
+
actions.append template.capture(self, &block) if block
|
22
|
+
actions.html_safe
|
23
|
+
end
|
24
|
+
|
25
|
+
def display_field(method, options={})
|
26
|
+
ControlGroup.new(options[:label] || model.class.human_attribute_name(method)) do |cg|
|
27
|
+
cg.append Tag.block(:span, model.send(method).to_s.gsub("\n", '<br>'), class: 'display')
|
28
|
+
end.html_safe
|
29
|
+
end
|
30
|
+
|
31
|
+
def text_field(method, options={})
|
32
|
+
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
33
|
+
cg.append form_builder.text_field(method, options)
|
34
|
+
end.html_safe
|
35
|
+
end
|
36
|
+
|
37
|
+
TwitterBootstrapMarkup::InputSize::VALUES.each do |size|
|
38
|
+
define_method "text_field_#{size}" do |method, options={}|
|
39
|
+
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
40
|
+
options.append!(:class, "input-#{size}")
|
41
|
+
cg.append form_builder.text_field(method, options)
|
42
|
+
end.html_safe
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def text_area(method, options={})
|
47
|
+
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
48
|
+
cg.append form_builder.text_area(method, options)
|
49
|
+
end.html_safe
|
50
|
+
end
|
51
|
+
|
52
|
+
TwitterBootstrapMarkup::InputSize::VALUES.each do |size|
|
53
|
+
define_method "text_area_#{size}" do |method, options={}|
|
54
|
+
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
55
|
+
options.append!(:class, "input-#{size}")
|
56
|
+
cg.append form_builder.text_area(method, options)
|
57
|
+
end.html_safe
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def email_field(method, options={})
|
62
|
+
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
63
|
+
cg.append form_builder.email_field(method, options)
|
64
|
+
end.html_safe
|
65
|
+
end
|
66
|
+
|
67
|
+
def password_field(method, options={})
|
68
|
+
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
69
|
+
cg.append form_builder.password_field(method, options)
|
70
|
+
end.html_safe
|
71
|
+
end
|
72
|
+
|
73
|
+
def check_box(method, options={})
|
74
|
+
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
75
|
+
cg.append form_builder.check_box(method, options)
|
76
|
+
end.html_safe
|
77
|
+
end
|
78
|
+
|
79
|
+
def hidden_field(method, options={})
|
80
|
+
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
81
|
+
cg.append form_builder.hidden_field(method, options)
|
82
|
+
end.html_safe
|
83
|
+
end
|
84
|
+
|
85
|
+
def select(method, choices, options={}, html_options={})
|
86
|
+
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
87
|
+
cg.append form_builder.select(method, choices, options, html_options)
|
88
|
+
end.html_safe
|
89
|
+
end
|
90
|
+
|
91
|
+
def date_select(method, options={}, html_options={})
|
92
|
+
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
93
|
+
cg.append form_builder.date_select(method, form_builder.send('objectify_options', options), html_options)
|
94
|
+
end.html_safe
|
95
|
+
end
|
96
|
+
|
97
|
+
def time_select(method, options={}, html_options={})
|
98
|
+
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
99
|
+
cg.append form_builder.time_select(method, form_builder.send('objectify_options', options), html_options)
|
100
|
+
end.html_safe
|
101
|
+
end
|
102
|
+
|
103
|
+
def datetime_select(method, options={}, html_options={})
|
104
|
+
ControlGroup.new(options[:label] || model.class.human_attribute_name(method), for: "#{form_builder.object_name}_#{method}") do |cg|
|
105
|
+
cg.append form_builder.datetime_select(method, form_builder.send('objectify_options', options), html_options)
|
106
|
+
end.html_safe
|
107
|
+
end
|
108
|
+
|
109
|
+
def custom_field(label, options={}, &block)
|
110
|
+
ControlGroup.new(label, options) do |cg|
|
111
|
+
cg.append template.capture(self, &block) if block
|
112
|
+
end.html_safe
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
end
|
117
117
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module TwitterBootstrapBuilder
|
2
|
-
module Builders
|
3
|
-
module FormBuilder
|
4
|
-
|
5
|
-
def fieldset_horizontal(&block)
|
6
|
-
Builders::FieldsetBuilder.new(@template, form_builder: self, &block).html_safe
|
7
|
-
end
|
8
|
-
|
9
|
-
end
|
10
|
-
end
|
1
|
+
module TwitterBootstrapBuilder
|
2
|
+
module Builders
|
3
|
+
module FormBuilder
|
4
|
+
|
5
|
+
def fieldset_horizontal(&block)
|
6
|
+
Builders::FieldsetBuilder.new(@template, form_builder: self, &block).html_safe
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
end
|
11
11
|
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
module TwitterBootstrapBuilder
|
2
|
-
module Builders
|
3
|
-
class LinkButtonBuilder < Base
|
4
|
-
|
5
|
-
def to_s
|
6
|
-
link_button = block ? LinkButton.new(*options[:args], &Proc.new {}) : LinkButton.new(*options[:args])
|
7
|
-
link_button.send(options[:type]) if options[:type]
|
8
|
-
link_button.send(options[:size]) if options[:size]
|
9
|
-
link_button.append template.capture(self, &block) if block
|
10
|
-
link_button.to_s
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
end
|
1
|
+
module TwitterBootstrapBuilder
|
2
|
+
module Builders
|
3
|
+
class LinkButtonBuilder < Base
|
4
|
+
|
5
|
+
def to_s
|
6
|
+
link_button = block ? LinkButton.new(*options[:args], &Proc.new {}) : LinkButton.new(*options[:args])
|
7
|
+
link_button.send(options[:type]) if options[:type]
|
8
|
+
link_button.send(options[:size]) if options[:size]
|
9
|
+
link_button.append template.capture(self, &block) if block
|
10
|
+
link_button.to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
15
|
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
module TwitterBootstrapBuilder
|
2
|
-
module Builders
|
3
|
-
class NavBarBuilder < Base
|
4
|
-
|
5
|
-
def to_s
|
6
|
-
nav_bar = NavBar.top
|
7
|
-
nav_bar.append template.capture(self, &block) if block
|
8
|
-
nav_bar.to_s
|
9
|
-
end
|
10
|
-
|
11
|
-
def brand(title, url)
|
12
|
-
Brand.new(title, url).html_safe
|
13
|
-
end
|
14
|
-
|
15
|
-
def container(&block)
|
16
|
-
NavContainerBuilder.new(template, &block).html_safe
|
17
|
-
end
|
18
|
-
|
19
|
-
def container_right(&block)
|
20
|
-
NavContainerBuilder.new(template, align: :right, &block).html_safe
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
1
|
+
module TwitterBootstrapBuilder
|
2
|
+
module Builders
|
3
|
+
class NavBarBuilder < Base
|
4
|
+
|
5
|
+
def to_s
|
6
|
+
nav_bar = NavBar.top
|
7
|
+
nav_bar.append template.capture(self, &block) if block
|
8
|
+
nav_bar.to_s
|
9
|
+
end
|
10
|
+
|
11
|
+
def brand(title, url)
|
12
|
+
Brand.new(title, url).html_safe
|
13
|
+
end
|
14
|
+
|
15
|
+
def container(&block)
|
16
|
+
NavContainerBuilder.new(template, &block).html_safe
|
17
|
+
end
|
18
|
+
|
19
|
+
def container_right(&block)
|
20
|
+
NavContainerBuilder.new(template, align: :right, &block).html_safe
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
25
|
end
|
@@ -1,39 +1,39 @@
|
|
1
|
-
module TwitterBootstrapBuilder
|
2
|
-
module Builders
|
3
|
-
class NavContainerBuilder < Base
|
4
|
-
|
5
|
-
def to_s
|
6
|
-
nav_container = NavContainer.new
|
7
|
-
nav_container.pull_right if options[:align] == :right
|
8
|
-
nav_container.append template.capture(self, &block) if block
|
9
|
-
nav_container.to_s
|
10
|
-
end
|
11
|
-
|
12
|
-
def link_to(*args, &block)
|
13
|
-
options = args.select { |a| a.is_a?(Hash) }.first || {}
|
14
|
-
if options[:active_if].is_a?(Proc) ? options[:active_if].call : options[:active_if]
|
15
|
-
active_link_to(*args, &block)
|
16
|
-
else
|
17
|
-
Tag.block(:li, template.link_to(*args, &block)).html_safe
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def active_link_to(*args, &block)
|
22
|
-
Tag.block(:li, template.link_to(*args, &block), class: 'active').html_safe
|
23
|
-
end
|
24
|
-
|
25
|
-
def divider
|
26
|
-
Tag.block(:li, Divider.vertical).html_safe
|
27
|
-
end
|
28
|
-
|
29
|
-
def dropdown_link(text, &block)
|
30
|
-
Tag.block(:li, DropDownLinkBuilder.new(template, text: text, &block).html_safe).html_safe
|
31
|
-
end
|
32
|
-
|
33
|
-
def custom(&block)
|
34
|
-
Tag.block(:li, Tag.block(:a, template.capture(self, &block))).html_safe
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
1
|
+
module TwitterBootstrapBuilder
|
2
|
+
module Builders
|
3
|
+
class NavContainerBuilder < Base
|
4
|
+
|
5
|
+
def to_s
|
6
|
+
nav_container = NavContainer.new
|
7
|
+
nav_container.pull_right if options[:align] == :right
|
8
|
+
nav_container.append template.capture(self, &block) if block
|
9
|
+
nav_container.to_s
|
10
|
+
end
|
11
|
+
|
12
|
+
def link_to(*args, &block)
|
13
|
+
options = args.select { |a| a.is_a?(Hash) }.first || {}
|
14
|
+
if options[:active_if].is_a?(Proc) ? options[:active_if].call : options[:active_if]
|
15
|
+
active_link_to(*args, &block)
|
16
|
+
else
|
17
|
+
Tag.block(:li, template.link_to(*args, &block)).html_safe
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def active_link_to(*args, &block)
|
22
|
+
Tag.block(:li, template.link_to(*args, &block), class: 'active').html_safe
|
23
|
+
end
|
24
|
+
|
25
|
+
def divider
|
26
|
+
Tag.block(:li, Divider.vertical).html_safe
|
27
|
+
end
|
28
|
+
|
29
|
+
def dropdown_link(text, &block)
|
30
|
+
Tag.block(:li, DropDownLinkBuilder.new(template, text: text, &block).html_safe).html_safe
|
31
|
+
end
|
32
|
+
|
33
|
+
def custom(&block)
|
34
|
+
Tag.block(:li, Tag.block(:a, template.capture(self, &block))).html_safe
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
39
|
end
|