bootstrap_ui_helper 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -2
- data/README.md +0 -8
- data/app/assets/javascripts/bootstrap_ui_helper.js +29 -23
- data/app/helpers/alert_box_helper.rb +5 -9
- data/app/helpers/bootstrap_form_helper.rb +80 -82
- data/app/helpers/bootstrap_form_options_helper.rb +32 -18
- data/app/helpers/button_helper.rb +3 -5
- data/app/helpers/dropdown_helper.rb +0 -4
- data/app/helpers/format_helper.rb +8 -0
- data/app/helpers/icon_helper.rb +32 -27
- data/app/helpers/modal_helper.rb +49 -36
- data/app/helpers/nav_helper.rb +4 -7
- data/app/helpers/navbar_helper.rb +55 -9
- data/app/helpers/panel_helper.rb +29 -65
- data/app/helpers/panel_row_helper.rb +2 -3
- data/app/helpers/progress_bar_helper.rb +1 -3
- data/codeclimate.yml +2 -39
- data/lib/bootstrap_ui_helper/version.rb +1 -1
- metadata +3 -4
- data/app/helpers/link_helper.rb +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddccba0e62ae94336a902898de6bfecf864d0913
|
4
|
+
data.tar.gz: 301bc1e5129a8c32ffe65712ea35b7781936bcf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9a732dd179af6596ed50b9ad5e506d82c907b27947fb45e8873a71f1469d47373bb60ada764dc8f5bbfd44aa5c73ea4327c708ae1facfcb6f81fbe76f49b534
|
7
|
+
data.tar.gz: b48ed5fb3ad875fddaec24e155609b71b7a827d0800b1cbab3510ebe9fc82704bd941ba201ea167bd836dce9ed597575c14eac034488997279a3fd5973a2d21a
|
data/CHANGELOG.md
CHANGED
@@ -1,2 +1,24 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# bootstrap_ui_helper Change Log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
bootstrap_ui_helper is in a 0.3.2 beta state. This means that its APIs and behavior are subject to breaking changes without deprecation notices.
|
6
|
+
|
7
|
+
## [0.3.1](https://github.com/Sen-Zhang/bootstrap_ui_helper/releases/tag/0.3.1) (2015-10-16)
|
8
|
+
|
9
|
+
Fixes:
|
10
|
+
|
11
|
+
* Fix dropdown_helper
|
12
|
+
|
13
|
+
## [0.3.2](https://github.com/Sen-Zhang/bootstrap_ui_helper/releases/tag/0.3.2) (2015-11-09)
|
14
|
+
|
15
|
+
Changes:
|
16
|
+
|
17
|
+
* Redo panel_helper
|
18
|
+
* Redo modal_helper
|
19
|
+
* Refactor icon_helper
|
20
|
+
* Refactor panel_helper
|
21
|
+
* Refactor panel_row_helper
|
22
|
+
* Refactor nav_helper
|
23
|
+
* Refactor navbar_helper
|
24
|
+
* Refactor form_helper
|
data/README.md
CHANGED
@@ -38,11 +38,3 @@ In `application.css`, add the following line:
|
|
38
38
|
## Usage
|
39
39
|
|
40
40
|
Please proceed to http://sen-zhang.github.io/#/articles/bootstrap_ui_helper for more details and examples on how to use the helpers.
|
41
|
-
|
42
|
-
## Contributing
|
43
|
-
|
44
|
-
1. Fork it ( https://github.com/[my-github-username]/bootstrap_ui_helper/fork )
|
45
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
46
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
47
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
48
|
-
5. Create a new Pull Request
|
@@ -1,5 +1,5 @@
|
|
1
|
-
(function (
|
2
|
-
|
1
|
+
(function ($, document) {
|
2
|
+
'use strict';
|
3
3
|
|
4
4
|
/*
|
5
5
|
* create a jquery DOM element based on tag name and options
|
@@ -19,27 +19,33 @@
|
|
19
19
|
*/
|
20
20
|
$.fn.nav = function () {
|
21
21
|
var $this = $(this),
|
22
|
-
activeChildLocator = $this.data(
|
22
|
+
activeChildLocator = $this.data('active-el-locator'),
|
23
23
|
children = $this.children();
|
24
24
|
|
25
25
|
if (activeChildLocator % 1 === 0) {
|
26
|
-
$(children[activeChildLocator]).attr(
|
26
|
+
$(children[activeChildLocator]).attr('active', true);
|
27
27
|
} else {
|
28
|
-
$this.children(activeChildLocator).attr(
|
28
|
+
$this.children(activeChildLocator).attr('active', true);
|
29
29
|
}
|
30
30
|
|
31
31
|
$this.children().remove();
|
32
32
|
|
33
33
|
children.each(function () {
|
34
34
|
var $child = $(this),
|
35
|
-
wrapper
|
35
|
+
wrapper;
|
36
36
|
|
37
|
-
if ($child.
|
38
|
-
$
|
39
|
-
|
40
|
-
|
37
|
+
if ($child.prop('tagName') === 'LI') {
|
38
|
+
$this.append($child);
|
39
|
+
} else {
|
40
|
+
wrapper = createElement('li', {role: 'presentation'});
|
41
|
+
|
42
|
+
if ($child.attr('active') === 'true') {
|
43
|
+
$child.removeAttr('active');
|
44
|
+
wrapper.addClass('active');
|
45
|
+
}
|
41
46
|
|
42
|
-
|
47
|
+
$this.append(wrapper.append($child));
|
48
|
+
}
|
43
49
|
});
|
44
50
|
};
|
45
51
|
|
@@ -50,14 +56,14 @@
|
|
50
56
|
*/
|
51
57
|
$.fn.panelRow = function () {
|
52
58
|
var $this = $(this),
|
53
|
-
columnClass = $this.data(
|
59
|
+
columnClass = $this.data('column-class'),
|
54
60
|
children = $this.children();
|
55
61
|
|
56
62
|
$this.children().remove();
|
57
63
|
|
58
64
|
children.each(function () {
|
59
65
|
var $child = $(this),
|
60
|
-
wrapper = createElement(
|
66
|
+
wrapper = createElement('div');
|
61
67
|
|
62
68
|
$this.append(wrapper.addClass(columnClass).append($child));
|
63
69
|
});
|
@@ -65,13 +71,13 @@
|
|
65
71
|
|
66
72
|
/*
|
67
73
|
* Button Group
|
68
|
-
* make sure children button group has the same size of their parents
|
74
|
+
* make sure children button group has the same size of their parents
|
69
75
|
*
|
70
76
|
*/
|
71
77
|
$.fn.buttonGroup = function () {
|
72
78
|
var $this = $(this);
|
73
79
|
|
74
|
-
$this.children(
|
80
|
+
$this.children('.btn-group').addClass($this.data('size'));
|
75
81
|
};
|
76
82
|
|
77
83
|
/*
|
@@ -79,19 +85,19 @@
|
|
79
85
|
*
|
80
86
|
*/
|
81
87
|
$.fn.navBar = function () {
|
82
|
-
var $this
|
83
|
-
|
84
|
-
|
88
|
+
var $this = $(this),
|
89
|
+
$burgerBtn = $this.find('.navbar-toggle'),
|
90
|
+
$collapse = $this.find('.navbar-collapse');
|
85
91
|
|
86
92
|
if ($burgerBtn.length > 0 && $collapse.length > 0) {
|
87
|
-
var collapseId = $collapse.attr(
|
93
|
+
var collapseId = $collapse.attr('id');
|
88
94
|
|
89
|
-
if ($collapse.attr(
|
95
|
+
if ($collapse.attr('id') === undefined) {
|
90
96
|
collapseId = Math.random().toString(36).substring(7);
|
91
|
-
$collapse.attr(
|
97
|
+
$collapse.attr('id', collapseId);
|
92
98
|
}
|
93
99
|
|
94
|
-
$burgerBtn.attr(
|
100
|
+
$burgerBtn.attr('data-target', '#' + collapseId);
|
95
101
|
}
|
96
102
|
};
|
97
103
|
|
@@ -110,4 +116,4 @@
|
|
110
116
|
$("[data-bui='btn_group']").buttonGroup();
|
111
117
|
|
112
118
|
});
|
113
|
-
})(jQuery);
|
119
|
+
})(window.jQuery, window.document);
|
@@ -1,16 +1,12 @@
|
|
1
1
|
module AlertBoxHelper
|
2
2
|
include ActionView::Helpers
|
3
|
+
include FormatHelper
|
3
4
|
|
4
5
|
def alert_box(content_or_options=nil, options={}, &block)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
dismissible = options.delete(:dismiss).present?
|
12
|
-
klass = options.delete(:class)
|
13
|
-
type = alert_type(options.delete(:type))
|
6
|
+
content, options = parse_content_or_options(content_or_options, options)
|
7
|
+
dismissible = options.delete(:dismiss).present?
|
8
|
+
klass = options.delete(:class)
|
9
|
+
type = alert_type(options.delete(:type))
|
14
10
|
|
15
11
|
prepend_class(options, 'alert', type, klass)
|
16
12
|
options[:role] = 'alert'
|
@@ -3,10 +3,12 @@ module BootstrapFormHelper
|
|
3
3
|
include PanelHelper
|
4
4
|
|
5
5
|
mattr_accessor :layout
|
6
|
+
alias_method :fieldset, :panel
|
7
|
+
|
6
8
|
FIELD_HELPERS = [:email_field, :password_field, :text_field, :text_area,
|
7
9
|
:search_field, :telephone_field, :url_field, :number_field,
|
8
10
|
:file_field, :date_field, :time_field, :month_field,
|
9
|
-
:week_field, :datetime_field]
|
11
|
+
:week_field, :datetime_field, :datetime_local_field]
|
10
12
|
|
11
13
|
def form_for(record, options = {}, &block)
|
12
14
|
html_options = options[:html] ||= {}
|
@@ -17,8 +19,7 @@ module BootstrapFormHelper
|
|
17
19
|
super
|
18
20
|
end
|
19
21
|
|
20
|
-
# TODO: color_field,
|
21
|
-
|
22
|
+
# TODO: color_field, range_field
|
22
23
|
FIELD_HELPERS.each do |helper|
|
23
24
|
define_method helper do |object_name, method, options={}|
|
24
25
|
label_class, field_wrapper = ['col-sm-3 control-label', true] if layout == :horizontal
|
@@ -26,18 +27,18 @@ module BootstrapFormHelper
|
|
26
27
|
prepend_class(options, 'form-control') unless __callee__ == :file_field
|
27
28
|
|
28
29
|
required = 'required' if options.delete(:required)
|
29
|
-
label_sr_only = 'sr-only' if options[:label].is_a?(FalseClass)
|
30
|
+
label_sr_only = 'sr-only' if options[:label].is_a?(FalseClass) || layout == :inline
|
30
31
|
label_class = squeeze_n_strip("#{label_class} #{required} #{label_sr_only}")
|
31
|
-
help_text = (options
|
32
|
+
help_text = render_help_text(options.delete(:help))
|
32
33
|
prefix_content = options.delete(:prefix)
|
33
34
|
suffix_content = options.delete(:suffix)
|
34
35
|
|
35
|
-
label_proc = proc { label(object_name, method, options
|
36
|
+
label_proc = proc { label(object_name, method, options.delete(:label), class: label_class) }
|
36
37
|
|
37
38
|
input_proc = proc do
|
38
39
|
input_content = if prefix_content.present? || suffix_content.present?
|
39
|
-
prefix_addon =
|
40
|
-
suffix_addon =
|
40
|
+
prefix_addon = render_input_addon(prefix_content)
|
41
|
+
suffix_addon = render_input_addon(suffix_content)
|
41
42
|
content_tag :div, class: 'input-group' do
|
42
43
|
prefix_addon + super(object_name, method, options) + suffix_addon
|
43
44
|
end
|
@@ -50,44 +51,46 @@ module BootstrapFormHelper
|
|
50
51
|
|
51
52
|
render_field(field_wrapper, label_proc, input_proc)
|
52
53
|
end
|
54
|
+
end
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
+
def fields_for(record_name, record_object = nil, options = {}, &block)
|
57
|
+
fieldset = HashWithIndifferentAccess.new(options.delete(:fieldset))
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
if fieldset.present?
|
60
|
+
type = get_panel_type(fieldset[:type])
|
61
|
+
title = fieldset[:title]
|
62
|
+
end
|
61
63
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
64
|
+
content_tag :fieldset, class: "panel #{type}" do
|
65
|
+
((title.present? ? (content_tag :div, title, class: 'panel-heading') : '') +
|
66
|
+
(content_tag :div, class: 'panel-body' do
|
67
|
+
super
|
68
|
+
end)).html_safe
|
68
69
|
end
|
70
|
+
end
|
69
71
|
|
70
|
-
|
72
|
+
def render_help_text(help)
|
73
|
+
(help.present? ? "<span class='help-block text-left'>#{help}</span>" : '').html_safe
|
74
|
+
end
|
71
75
|
|
72
|
-
|
73
|
-
|
76
|
+
def render_input_addon(content)
|
77
|
+
return ('').html_safe if content.blank?
|
74
78
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
79
|
+
if content.is_a?(String)
|
80
|
+
"<span class='input-group-addon'>#{content}</span>".html_safe
|
81
|
+
elsif content.is_a?(Hash) && content.key?(:icon)
|
82
|
+
"<span class='input-group-addon'>#{icon(content[:icon])}</span>".html_safe
|
83
|
+
else
|
84
|
+
('').html_safe
|
82
85
|
end
|
86
|
+
end
|
83
87
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
88
|
+
def render_field(inline_style, label_proc, input_proc)
|
89
|
+
content_tag :div, class: 'form-group' do
|
90
|
+
if inline_style
|
91
|
+
(label_proc.call + (content_tag :div, class: 'col-sm-9', &input_proc)).html_safe
|
92
|
+
else
|
93
|
+
(label_proc.call + input_proc.call).html_safe
|
91
94
|
end
|
92
95
|
end
|
93
96
|
end
|
@@ -99,56 +102,25 @@ module BootstrapFormHelper
|
|
99
102
|
attr_accessor :output_buffer
|
100
103
|
|
101
104
|
def check_box(method, options = {}, checked_value = '1', unchecked_value = '0')
|
102
|
-
layout_inline = options
|
105
|
+
layout_inline, help_text, label = parse_options(options)
|
103
106
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
options[:label]
|
108
|
-
end
|
109
|
-
|
110
|
-
if layout_inline
|
111
|
-
content_tag :label, class: 'checkbox-inline', &proc
|
112
|
-
else
|
113
|
-
content_tag :div, class: 'checkbox' do
|
114
|
-
content_tag :label, &proc
|
115
|
-
end
|
116
|
-
end
|
107
|
+
check_box_proc = proc do
|
108
|
+
@template.check_box(@object_name, method, objectify_options(options), checked_value, unchecked_value) +
|
109
|
+
label
|
117
110
|
end
|
118
111
|
|
119
|
-
|
120
|
-
content_tag :div, class: 'form-group' do
|
121
|
-
content_tag :div, class: 'col-sm-offset-3 col-sm-9', &check_box
|
122
|
-
end
|
123
|
-
else
|
124
|
-
check_box.call
|
125
|
-
end
|
112
|
+
render_input_field(layout_inline, help_text, :checkbox, &check_box_proc)
|
126
113
|
end
|
127
114
|
|
128
115
|
def radio_button(method, tag_value, options = {})
|
129
|
-
layout_inline = options
|
116
|
+
layout_inline, help_text, label = parse_options(options)
|
130
117
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
end
|
135
|
-
|
136
|
-
if layout_inline
|
137
|
-
content_tag :label, class: 'radio-inline', &proc
|
138
|
-
else
|
139
|
-
content_tag :div, class: 'radio' do
|
140
|
-
content_tag :label, &proc
|
141
|
-
end
|
142
|
-
end
|
118
|
+
radio_button_proc = proc do
|
119
|
+
@template.radio_button(@object_name, method, tag_value, objectify_options(options)) +
|
120
|
+
label
|
143
121
|
end
|
144
122
|
|
145
|
-
|
146
|
-
content_tag :div, class: 'form-group' do
|
147
|
-
content_tag :div, class: 'col-sm-offset-3 col-sm-9', &radio_button
|
148
|
-
end
|
149
|
-
else
|
150
|
-
radio_button.call
|
151
|
-
end
|
123
|
+
render_input_field(layout_inline, help_text, :radio, &radio_button_proc)
|
152
124
|
end
|
153
125
|
|
154
126
|
def submit(value=nil, options={})
|
@@ -167,6 +139,33 @@ module BootstrapFormHelper
|
|
167
139
|
end
|
168
140
|
|
169
141
|
private
|
142
|
+
def parse_options(options)
|
143
|
+
layout_inline = options.delete(:layout).try(:to_sym) == :inline
|
144
|
+
help_text = render_help_text(options.delete(:help))
|
145
|
+
label = options.delete(:label)
|
146
|
+
|
147
|
+
[layout_inline, help_text, label]
|
148
|
+
end
|
149
|
+
|
150
|
+
def get_input_lambda(layout_inline, help_text, type, &block)
|
151
|
+
lambda do
|
152
|
+
return (content_tag :label, class: "#{type}-inline", &block) + help_text if layout_inline
|
153
|
+
|
154
|
+
(content_tag :div, class: "#{type}" do
|
155
|
+
content_tag :label, &block
|
156
|
+
end) + help_text
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def render_input_field(layout_inline, help_text, type, &block)
|
161
|
+
input_lambda = get_input_lambda(layout_inline, help_text, type, &block)
|
162
|
+
|
163
|
+
return input_lambda.call unless horizontal_layout?
|
164
|
+
|
165
|
+
content_tag :div, class: 'form-group' do
|
166
|
+
content_tag :div, class: 'col-sm-offset-3 col-sm-9', &input_lambda
|
167
|
+
end
|
168
|
+
end
|
170
169
|
|
171
170
|
def horizontal_layout?
|
172
171
|
BootstrapFormHelper.layout == :horizontal
|
@@ -174,17 +173,16 @@ module BootstrapFormHelper
|
|
174
173
|
end
|
175
174
|
|
176
175
|
private
|
177
|
-
|
178
176
|
def get_form_layout(form_layout)
|
179
177
|
case form_layout.try(:to_sym)
|
180
178
|
when :horizontal
|
181
|
-
layout = :horizontal
|
179
|
+
self.layout = :horizontal
|
182
180
|
'form form-horizontal'
|
183
181
|
when :inline
|
184
|
-
layout = :inline
|
182
|
+
self.layout = :inline
|
185
183
|
'form form-inline'
|
186
184
|
else
|
187
|
-
layout = :basic
|
185
|
+
self.layout = :basic
|
188
186
|
'form'
|
189
187
|
end
|
190
188
|
end
|
@@ -4,16 +4,15 @@ module BootstrapFormOptionsHelper
|
|
4
4
|
include FormatHelper
|
5
5
|
include BootstrapFormHelper
|
6
6
|
|
7
|
-
|
8
7
|
def select(method, choices = nil, options = {}, html_options = {}, &block)
|
9
8
|
label_class, field_wrapper = horizontal_layout? ? ['col-sm-3 control-label', true] : []
|
10
9
|
|
11
|
-
required
|
12
|
-
label_sr_only = 'sr-only' if
|
13
|
-
|
14
|
-
|
15
|
-
help_text = (html_options[:help] ? "<span class='help-block text-left'>#{html_options[:help]}</span>" : '').html_safe
|
10
|
+
required = 'required' if options.delete(:required)
|
11
|
+
label_sr_only = 'sr-only' if options[:label].is_a?(FalseClass) || layout == :inline
|
12
|
+
label_class = squeeze_n_strip("#{label_class} #{required} #{label_sr_only}")
|
13
|
+
help_text = render_help_text(options.delete(:help))
|
16
14
|
|
15
|
+
prepend_class(html_options, 'form-control')
|
17
16
|
select_proc = proc do
|
18
17
|
@template.select(@object_name,
|
19
18
|
method,
|
@@ -22,38 +21,49 @@ module BootstrapFormOptionsHelper
|
|
22
21
|
@default_options.merge(html_options),
|
23
22
|
&block) + help_text
|
24
23
|
end
|
25
|
-
|
26
|
-
label_proc = proc { label(method, html_options[:label], class: label_class) }
|
24
|
+
label_proc = proc { label(method, options.delete(:label), class: label_class) }
|
27
25
|
|
28
26
|
render_field(field_wrapper, label_proc, select_proc)
|
29
27
|
end
|
30
28
|
|
31
29
|
def collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
|
32
30
|
check_boxes_proc = proc do
|
33
|
-
@template.collection_check_boxes(@object_name,
|
34
|
-
|
31
|
+
@template.collection_check_boxes(@object_name,
|
32
|
+
method,
|
33
|
+
collection,
|
34
|
+
value_method,
|
35
|
+
text_method,
|
36
|
+
objectify_options(options),
|
37
|
+
@default_options.merge(html_options),
|
35
38
|
&block)
|
36
39
|
end
|
37
40
|
|
38
|
-
render_collection(options
|
41
|
+
render_collection(options.delete(:label), &check_boxes_proc)
|
39
42
|
end
|
40
43
|
|
41
44
|
def collection_radio_buttons(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
|
42
|
-
|
43
|
-
@template.collection_radio_buttons(@object_name,
|
44
|
-
|
45
|
+
radio_buttons_proc = proc do
|
46
|
+
@template.collection_radio_buttons(@object_name,
|
47
|
+
method,
|
48
|
+
collection,
|
49
|
+
value_method,
|
50
|
+
text_method,
|
51
|
+
objectify_options(options),
|
52
|
+
@default_options.merge(html_options),
|
45
53
|
&block)
|
46
54
|
end
|
47
55
|
|
48
|
-
render_collection(options
|
56
|
+
render_collection(options.delete(:label), &radio_buttons_proc)
|
49
57
|
end
|
50
58
|
|
51
59
|
private
|
52
60
|
|
53
61
|
def render_label(label)
|
54
|
-
label_class = 'col-sm-3 control-label'
|
62
|
+
label_class = horizontal_layout? ? 'col-sm-3 control-label' : ''
|
63
|
+
label_class += ' sr-only' if label.blank?
|
55
64
|
|
56
|
-
|
65
|
+
rendered_label = ("<label class='#{label_class}'>#{label}</label> ").html_safe
|
66
|
+
basic_layout? ? content_tag(:div, rendered_label) : rendered_label
|
57
67
|
end
|
58
68
|
|
59
69
|
def render_input(&input_block)
|
@@ -66,6 +76,10 @@ module BootstrapFormOptionsHelper
|
|
66
76
|
end
|
67
77
|
end
|
68
78
|
|
79
|
+
def basic_layout?
|
80
|
+
BootstrapFormHelper.layout == :basic
|
81
|
+
end
|
82
|
+
|
69
83
|
def horizontal_layout?
|
70
84
|
BootstrapFormHelper.layout == :horizontal
|
71
85
|
end
|
@@ -77,7 +91,7 @@ module BootstrapFormOptionsHelper
|
|
77
91
|
def render(&block)
|
78
92
|
rendered_collection = render_collection do |item, value, text, default_html_options|
|
79
93
|
default_html_options[:multiple] = true
|
80
|
-
builder
|
94
|
+
builder = instantiate_builder(CheckBoxBuilder, item, value, text, default_html_options)
|
81
95
|
|
82
96
|
if block_given?
|
83
97
|
@template_object.capture(builder, &block)
|
@@ -3,16 +3,14 @@ module ButtonHelper
|
|
3
3
|
include FormatHelper
|
4
4
|
|
5
5
|
def button(content_or_options=nil, options={}, &block)
|
6
|
-
|
6
|
+
content, options = parse_content_or_options(content_or_options, options)
|
7
7
|
|
8
8
|
layout = 'btn-block' if options.delete(:layout).try(:to_sym) == :block
|
9
9
|
size = get_btn_size(options.delete(:size))
|
10
10
|
type = get_btn_type(options.delete(:type))
|
11
11
|
prepend_class(options, 'btn', type, size, layout)
|
12
12
|
|
13
|
-
content_tag :button, options
|
14
|
-
content.presence || capture(&block)
|
15
|
-
end
|
13
|
+
content_tag :button, (content.presence || capture(&block)), options
|
16
14
|
end
|
17
15
|
|
18
16
|
def button_group(options={}, &block)
|
@@ -38,7 +36,7 @@ module ButtonHelper
|
|
38
36
|
end
|
39
37
|
|
40
38
|
def navbar_button(content_or_options=nil, options={}, &block)
|
41
|
-
|
39
|
+
content, options = parse_content_or_options(content_or_options, options)
|
42
40
|
|
43
41
|
prepend_class(options, 'navbar-btn')
|
44
42
|
button content, options, &block
|
@@ -7,4 +7,12 @@ module FormatHelper
|
|
7
7
|
def prepend_class(options, *attrs)
|
8
8
|
options[:class] = squeeze_n_strip("#{attrs.join(' ')} #{options[:class]}")
|
9
9
|
end
|
10
|
+
|
11
|
+
def parse_content_or_options(content_or_options, options)
|
12
|
+
if content_or_options.is_a?(Hash)
|
13
|
+
[nil, content_or_options]
|
14
|
+
else
|
15
|
+
[content_or_options, options]
|
16
|
+
end
|
17
|
+
end
|
10
18
|
end
|
data/app/helpers/icon_helper.rb
CHANGED
@@ -9,46 +9,35 @@ module IconHelper
|
|
9
9
|
attr_accessor :options
|
10
10
|
|
11
11
|
def initialize(type, options)
|
12
|
-
@type = type
|
12
|
+
@type = type.to_s.tr('_', '-')
|
13
13
|
@options = options
|
14
14
|
end
|
15
15
|
|
16
16
|
def render
|
17
|
-
|
18
|
-
type: type,
|
19
|
-
size: options.delete(:size).presence || :normal,
|
20
|
-
fw: options.delete(:fixed_with).presence,
|
21
|
-
li: options.delete(:list_icon).presence,
|
22
|
-
inverse: options.delete(:inverse).presence,
|
23
|
-
border: options.delete(:border).presence,
|
24
|
-
pull: options.delete(:pull).presence,
|
25
|
-
animate: options.delete(:animate).presence,
|
26
|
-
orientation: options.delete(:orientation).presence
|
27
|
-
|
28
|
-
# TODO add fa-stack support
|
29
|
-
# stack = options.delete(:stack).presence
|
30
|
-
}
|
31
|
-
|
32
|
-
prepend_class(options, 'fa', render_fa_class(icon_options))
|
17
|
+
render_fa_class(options)
|
33
18
|
|
34
19
|
content_tag :i, nil, options
|
35
20
|
end
|
36
21
|
|
37
22
|
private
|
38
23
|
def render_fa_class(options)
|
39
|
-
type = "fa-#{
|
24
|
+
type = "fa-#{@type}"
|
40
25
|
raise 'Invalid Icon Type!' if ValidIcons::VALID_ICONS.exclude?(type)
|
41
26
|
|
42
27
|
size = get_icon_size(options.delete(:size))
|
43
|
-
fw = options
|
44
|
-
li = options
|
45
|
-
inverse = options
|
46
|
-
border = options
|
47
|
-
pull = get_icon_position(options
|
48
|
-
animate = get_icon_animation(options
|
49
|
-
orientation = get_icon_orientation(options
|
50
|
-
|
51
|
-
|
28
|
+
fw = options.delete(:fw).presence ? 'fa-fw' : nil
|
29
|
+
li = options.delete(:li).presence ? 'fa-li' : nil
|
30
|
+
inverse = options.delete(:inverse).presence ? 'fa-inverse' : nil
|
31
|
+
border = options.delete(:border).presence ? 'fa-border' : nil
|
32
|
+
pull = get_icon_position(options.delete(:pull))
|
33
|
+
animate = get_icon_animation(options.delete(:animate))
|
34
|
+
orientation = get_icon_orientation(options.delete(:orientation))
|
35
|
+
|
36
|
+
# TODO add fa-stack support
|
37
|
+
# stack = options.delete(:stack).presence
|
38
|
+
|
39
|
+
prepend_class(options, 'fa', type, size, fw, li, inverse, border, pull,
|
40
|
+
animate, orientation)
|
52
41
|
end
|
53
42
|
|
54
43
|
def get_icon_size(size)
|
@@ -109,4 +98,20 @@ module IconHelper
|
|
109
98
|
|
110
99
|
IconCreator.new(type, options).render
|
111
100
|
end
|
101
|
+
|
102
|
+
def icon_list(options={}, &block)
|
103
|
+
prepend_class(options, 'fa-ul')
|
104
|
+
|
105
|
+
content_tag :ul, options, &block
|
106
|
+
end
|
107
|
+
|
108
|
+
def icon_list_item(content_or_options, options={}, &block)
|
109
|
+
content, options = parse_content_or_options(content_or_options, options)
|
110
|
+
icon_options = options.delete(:icon_html)
|
111
|
+
icon = icon(icon_options.delete(:type), icon_options)
|
112
|
+
|
113
|
+
content_tag :li, options do
|
114
|
+
(icon + (content.presence || capture(&block))).html_safe
|
115
|
+
end
|
116
|
+
end
|
112
117
|
end
|
data/app/helpers/modal_helper.rb
CHANGED
@@ -3,63 +3,76 @@ module ModalHelper
|
|
3
3
|
include FormatHelper
|
4
4
|
|
5
5
|
def modal(options={}, &block)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
button_options[:data] = (button_options[:data] || {}).merge({toggle: 'modal', target: "##{modal_dialog_id}"})
|
11
|
-
size = case options.delete(:size).try(:to_sym)
|
12
|
-
when :xsmall
|
13
|
-
'modal-sm'
|
14
|
-
when :large
|
15
|
-
'modal-lg'
|
16
|
-
else
|
17
|
-
end
|
18
|
-
|
19
|
-
prepend_class(options, 'modal', 'fade')
|
20
|
-
options.merge!({id: modal_dialog_id, tabindex: -1, role: 'dialog', aria: {hidden: true}})
|
6
|
+
caption,
|
7
|
+
button_options,
|
8
|
+
modal_dialog_options,
|
9
|
+
modal_content_options = parse_modal_options(options)
|
21
10
|
|
22
11
|
((button caption, button_options) +
|
23
12
|
(content_tag :div, options do
|
24
|
-
content_tag :div,
|
25
|
-
content_tag :div,
|
26
|
-
yield if block_given?
|
27
|
-
end
|
13
|
+
content_tag :div, modal_dialog_options do
|
14
|
+
content_tag :div, modal_content_options, &block
|
28
15
|
end
|
29
16
|
end)).html_safe
|
30
17
|
end
|
31
18
|
|
32
19
|
def modal_header(content_or_options=nil, options={}, &block)
|
33
|
-
|
20
|
+
content, options = parse_content_or_options(content_or_options, options)
|
34
21
|
|
35
|
-
|
22
|
+
title_options = options.delete(:title_html) || {}
|
23
|
+
prepend_class(options, 'modal-header')
|
36
24
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end)).html_safe
|
25
|
+
header_proc = block_given? ? block : proc { modal_title(content, title_options) }
|
26
|
+
|
27
|
+
content_tag :div, options do
|
28
|
+
render_close_btn + capture(&header_proc)
|
42
29
|
end
|
43
30
|
end
|
44
31
|
|
45
|
-
|
46
|
-
|
32
|
+
%w(title body footer).each do |part|
|
33
|
+
define_method "modal_#{part}" do |content_or_options=nil, options={}, &block|
|
34
|
+
content, options = parse_content_or_options(content_or_options, options)
|
35
|
+
tag = part == 'title' ? options.delete(:tag).try(:to_sym) || :h4 : :div
|
47
36
|
|
48
|
-
|
37
|
+
prepend_class(options, "modal-#{part}")
|
49
38
|
|
50
|
-
|
51
|
-
content.presence || capture(&block)
|
39
|
+
content_tag tag, (content.presence || capture(&block)), options
|
52
40
|
end
|
53
41
|
end
|
54
42
|
|
55
|
-
|
56
|
-
|
43
|
+
private
|
44
|
+
|
45
|
+
def parse_modal_options(options)
|
46
|
+
button_options = options.delete(:button_html) || {}
|
47
|
+
modal_dialog_options = options.delete(:modal_dialog_html) || {}
|
48
|
+
modal_content_options = options.delete(:modal_content_html) || {}
|
49
|
+
caption = button_options.delete(:caption) || 'Modal'
|
50
|
+
modal_id = options[:id] || "modal-#{SecureRandom.hex(3)}"
|
51
|
+
button_options[:data] = (button_options[:data] || {}).merge({toggle: 'modal', target: "##{modal_id}"})
|
52
|
+
size = get_modal_size(options.delete(:size).try(:to_sym))
|
53
|
+
|
54
|
+
prepend_class(options, 'modal', 'fade')
|
55
|
+
prepend_class(modal_dialog_options, 'modal-dialog', size)
|
56
|
+
prepend_class(modal_content_options, 'modal-content')
|
57
57
|
|
58
|
-
|
58
|
+
options.deep_merge!({id: modal_id, tabindex: -1, role: 'dialog', aria: {hidden: true}})
|
59
59
|
|
60
|
-
|
61
|
-
|
60
|
+
[caption, button_options, modal_dialog_options, modal_content_options]
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_modal_size(size)
|
64
|
+
case size
|
65
|
+
when :small
|
66
|
+
'modal-sm'
|
67
|
+
when :large
|
68
|
+
'modal-lg'
|
69
|
+
else
|
62
70
|
end
|
63
71
|
end
|
64
72
|
|
73
|
+
def render_close_btn
|
74
|
+
content_tag :button, type: :button, class: 'close', data: {dismiss: 'modal'} do
|
75
|
+
content_tag :span, 'x', aria: {hidden: true}
|
76
|
+
end
|
77
|
+
end
|
65
78
|
end
|
data/app/helpers/nav_helper.rb
CHANGED
@@ -11,7 +11,7 @@ module NavHelper
|
|
11
11
|
@options = options
|
12
12
|
end
|
13
13
|
|
14
|
-
def render
|
14
|
+
def render(content)
|
15
15
|
nav_options = {
|
16
16
|
as: options.delete(:as).presence || :tabs,
|
17
17
|
layout: options.delete(:layout).presence
|
@@ -21,10 +21,9 @@ module NavHelper
|
|
21
21
|
active = options.delete(:active)
|
22
22
|
|
23
23
|
prepend_class(options, 'nav', build_nav_class(nav_options))
|
24
|
+
options.deep_merge!(data: {bui: 'nav', active_el_locator: active})
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
[tag, options]
|
26
|
+
content_tag tag, content, options
|
28
27
|
end
|
29
28
|
|
30
29
|
private
|
@@ -49,8 +48,6 @@ module NavHelper
|
|
49
48
|
end
|
50
49
|
|
51
50
|
def nav(options={}, &block)
|
52
|
-
|
53
|
-
|
54
|
-
content_tag tag, options, &block
|
51
|
+
NavCreator.new(options).render capture(&block)
|
55
52
|
end
|
56
53
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module NavbarHelper
|
2
2
|
include ActionView::Helpers
|
3
|
+
include FormatHelper
|
3
4
|
|
4
5
|
# TODO: add navbar form support
|
5
6
|
def navbar(options={}, &block)
|
@@ -9,8 +10,7 @@ module NavbarHelper
|
|
9
10
|
position, position_style = parse_position(options.delete(:position), padding)
|
10
11
|
|
11
12
|
prepend_class(options, style, position)
|
12
|
-
|
13
|
-
options[:data] = (options[:data] || {}).merge(bui: 'navbar')
|
13
|
+
options.deep_merge!(data: {bui: 'navbar'})
|
14
14
|
|
15
15
|
(position_style + (content_tag :nav, options do
|
16
16
|
content_tag :div, class: container, &block
|
@@ -20,14 +20,16 @@ module NavbarHelper
|
|
20
20
|
def vertical(options={}, &block)
|
21
21
|
prepend_class(options, 'navbar-header')
|
22
22
|
|
23
|
+
btn_content = ("<span class='icon-bar'></span>" * 3).html_safe
|
24
|
+
btn_options = {
|
25
|
+
class: 'navbar-toggle collapsed',
|
26
|
+
type: :button,
|
27
|
+
data: {toggle: 'collapse'},
|
28
|
+
aria: {expanded: false}
|
29
|
+
}
|
30
|
+
|
23
31
|
content_tag :div, options do
|
24
|
-
(content_tag :button,
|
25
|
-
class: 'navbar-toggle collapsed',
|
26
|
-
type: :button,
|
27
|
-
data: {toggle: 'collapse'},
|
28
|
-
aria: {expanded: false} do
|
29
|
-
("<span class='icon-bar'></span>" * 3).html_safe
|
30
|
-
end) + capture(&block)
|
32
|
+
(content_tag :button, btn_content, btn_options) + capture(&block)
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
@@ -51,6 +53,50 @@ module NavbarHelper
|
|
51
53
|
content_tag :ul, options, &block
|
52
54
|
end
|
53
55
|
|
56
|
+
def navbar_link_to(name = nil, options = nil, html_options = nil, &block)
|
57
|
+
html_options, options, name = options, name, block if block_given?
|
58
|
+
options ||= {}
|
59
|
+
html_options ||= {}
|
60
|
+
|
61
|
+
prepend_class(html_options, 'navbar-link')
|
62
|
+
|
63
|
+
link_to options, html_options do
|
64
|
+
block_given? ? (yield name) : name
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def navbar_link(name = nil, options = nil, html_options = nil, &block)
|
69
|
+
html_options, options, name = options, name, block if block_given?
|
70
|
+
options ||= {}
|
71
|
+
html_options ||= {}
|
72
|
+
|
73
|
+
prepend_class(html_options, 'navbar-link')
|
74
|
+
active = 'active' if html_options.delete(:active)
|
75
|
+
|
76
|
+
|
77
|
+
content_tag :li, class: active do
|
78
|
+
link_to options, html_options do
|
79
|
+
block_given? ? (yield name) : name
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def navbar_brand(name = nil, options = nil, html_options = nil, &block)
|
85
|
+
html_options, options, name = options, name, block if block_given?
|
86
|
+
options ||= {}
|
87
|
+
html_options ||= {}
|
88
|
+
|
89
|
+
prepend_class(html_options, 'navbar-brand')
|
90
|
+
|
91
|
+
link_to options, html_options do
|
92
|
+
block_given? ? (yield name) : name
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def navbar_dropdown(content=nil, list=[], options={})
|
97
|
+
dropdown(content, list, options.merge({category: :navbar}))
|
98
|
+
end
|
99
|
+
|
54
100
|
private
|
55
101
|
|
56
102
|
def parse_position(position, padding)
|
data/app/helpers/panel_helper.rb
CHANGED
@@ -1,78 +1,42 @@
|
|
1
1
|
module PanelHelper
|
2
2
|
include ActionView::Helpers
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
def panel(options={}, &block)
|
5
|
+
tag = options.delete(:tag).try(:to_sym) || :div
|
6
|
+
type = get_panel_type(options.delete(:type))
|
7
7
|
|
8
|
-
|
9
|
-
attr_accessor :options
|
10
|
-
attr_accessor :block
|
11
|
-
attr_accessor :output_buffer
|
8
|
+
prepend_class(options, 'panel', type)
|
12
9
|
|
13
|
-
|
14
|
-
|
15
|
-
@options = options
|
16
|
-
@block = block
|
17
|
-
end
|
18
|
-
|
19
|
-
def render
|
20
|
-
heading = options.delete(:heading)
|
21
|
-
title = options.delete(:title)
|
22
|
-
footer = options.delete(:footer)
|
23
|
-
tag = options.delete(:tag).try(:to_sym).presence || :div
|
24
|
-
type = get_panel_type(options.delete(:type))
|
25
|
-
|
26
|
-
prepend_class(options, 'panel', type)
|
27
|
-
|
28
|
-
content_tag tag, options do
|
29
|
-
(panel_header(heading, title) + panel_body(content, block) +
|
30
|
-
panel_footer(footer)).html_safe
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
def panel_header(heading, title)
|
36
|
-
return '' if heading.blank? && title.blank?
|
37
|
-
|
38
|
-
if title.present?
|
39
|
-
"<div class='panel-heading'><h3 class='panel-title'>#{title}</h3></div>"
|
40
|
-
else
|
41
|
-
"<div class='panel-heading'>#{heading}</div>"
|
42
|
-
end
|
43
|
-
end
|
10
|
+
content_tag tag, options, &block
|
11
|
+
end
|
44
12
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
end
|
13
|
+
%w(heading title body footer).each do |part|
|
14
|
+
define_method "panel_#{part}" do |content_or_options=nil, options={}, &block|
|
15
|
+
content, options = parse_content_or_options(content_or_options, options)
|
50
16
|
|
51
|
-
|
52
|
-
|
53
|
-
end
|
17
|
+
tag = part == 'title' ? options.delete(:tag).try(:to_sym) || :h3 : :div
|
18
|
+
prepend_class(options, "panel-#{part}")
|
54
19
|
|
55
|
-
|
56
|
-
case type.try(:to_sym)
|
57
|
-
when :primary
|
58
|
-
'panel-primary'
|
59
|
-
when :info
|
60
|
-
'panel-info'
|
61
|
-
when :success
|
62
|
-
'panel-success'
|
63
|
-
when :warning
|
64
|
-
'panel-warning'
|
65
|
-
when :danger
|
66
|
-
'panel-danger'
|
67
|
-
else
|
68
|
-
'panel-default'
|
69
|
-
end
|
20
|
+
content_tag tag, content || capture(&block), options
|
70
21
|
end
|
71
22
|
end
|
72
23
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
24
|
+
private
|
25
|
+
|
26
|
+
def get_panel_type(type)
|
27
|
+
case type.try(:to_sym)
|
28
|
+
when :primary
|
29
|
+
'panel-primary'
|
30
|
+
when :info
|
31
|
+
'panel-info'
|
32
|
+
when :success
|
33
|
+
'panel-success'
|
34
|
+
when :warning
|
35
|
+
'panel-warning'
|
36
|
+
when :danger
|
37
|
+
'panel-danger'
|
38
|
+
else
|
39
|
+
'panel-default'
|
40
|
+
end
|
77
41
|
end
|
78
42
|
end
|
@@ -2,9 +2,8 @@ module PanelRowHelper
|
|
2
2
|
|
3
3
|
def panel_row(options={}, &block)
|
4
4
|
column_class = options.delete(:column_class) || ''
|
5
|
-
|
6
|
-
|
7
|
-
options[:data] = data
|
5
|
+
|
6
|
+
options.deep_merge!(data: {bui: 'panel_row', column_class: column_class})
|
8
7
|
prepend_class(options, 'row')
|
9
8
|
|
10
9
|
content_tag :div, options, &block
|
@@ -17,9 +17,7 @@ module ProgressBarHelper
|
|
17
17
|
options[:role] = 'progressbar'
|
18
18
|
options[:aria] = {valuemax: 100, valuemin: 0, valuenow: percentage}
|
19
19
|
|
20
|
-
content_tag :div, options
|
21
|
-
label.present? ? label : (content_tag :span, label, class: 'sr-only')
|
22
|
-
end
|
20
|
+
content_tag :div, label, options
|
23
21
|
end
|
24
22
|
|
25
23
|
private
|
data/codeclimate.yml
CHANGED
@@ -1,20 +1,4 @@
|
|
1
|
-
# This is a sample .codeclimate.yml configured for Engine analysis on Code
|
2
|
-
# Climate Platform. For an overview of the Code Climate Platform, see here:
|
3
|
-
# http://docs.codeclimate.com/article/300-the-codeclimate-platform
|
4
|
-
|
5
|
-
# Under the engines key, you can configure which engines will analyze your repo.
|
6
|
-
# Each key is an engine name. For each value, you need to specify enabled: true
|
7
|
-
# to enable the engine as well as any other engines-specific configuration.
|
8
|
-
|
9
|
-
# For more details, see here:
|
10
|
-
# http://docs.codeclimate.com/article/289-configuring-your-repository-via-codeclimate-yml#platform
|
11
|
-
|
12
|
-
# For a list of all available engines, see here:
|
13
|
-
# http://docs.codeclimate.com/article/296-engines-available-engines
|
14
|
-
|
15
1
|
engines:
|
16
|
-
# to turn on an engine, add it here and set enabled to `true`
|
17
|
-
# to turn off an engine, set enabled to `false` or remove it
|
18
2
|
rubocop:
|
19
3
|
enabled: true
|
20
4
|
checks:
|
@@ -33,26 +17,5 @@ engines:
|
|
33
17
|
enabled: false
|
34
18
|
csslint:
|
35
19
|
enabled: true
|
36
|
-
|
37
|
-
|
38
|
-
# decide which files will receive ratings based on those issues. This is
|
39
|
-
# specified by path patterns under the ratings key.
|
40
|
-
|
41
|
-
# For more details see here:
|
42
|
-
# http://docs.codeclimate.com/article/289-configuring-your-repository-via-codeclimate-yml#platform
|
43
|
-
|
44
|
-
# Note: If the ratings key is not specified, this will result in a 0.0 GPA on your dashboard.
|
45
|
-
|
46
|
-
# ratings:
|
47
|
-
# paths:
|
48
|
-
# - app/**
|
49
|
-
# - lib/**
|
50
|
-
# - "**.rb"
|
51
|
-
# - "**.go"
|
52
|
-
|
53
|
-
# You can globally exclude files from being analyzed by any engine using the
|
54
|
-
# exclude_paths key.
|
55
|
-
|
56
|
-
#exclude_paths:
|
57
|
-
#- spec/**/*
|
58
|
-
#- vendor/**/*
|
20
|
+
fixme:
|
21
|
+
enabled: false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap_ui_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sen Zhang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10
|
11
|
+
date: 2015-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -64,7 +64,6 @@ files:
|
|
64
64
|
- app/helpers/format_helper.rb
|
65
65
|
- app/helpers/icon_helper.rb
|
66
66
|
- app/helpers/label_helper.rb
|
67
|
-
- app/helpers/link_helper.rb
|
68
67
|
- app/helpers/modal_helper.rb
|
69
68
|
- app/helpers/nav_helper.rb
|
70
69
|
- app/helpers/navbar_helper.rb
|
@@ -96,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
95
|
version: '0'
|
97
96
|
requirements: []
|
98
97
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.4.
|
98
|
+
rubygems_version: 2.4.8
|
100
99
|
signing_key:
|
101
100
|
specification_version: 4
|
102
101
|
summary: Bootstrap UI Helper
|
data/app/helpers/link_helper.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
module LinkHelper
|
2
|
-
include FormatHelper
|
3
|
-
|
4
|
-
def navbar_link_to(name = nil, options = nil, html_options = nil, &block)
|
5
|
-
html_options, options, name = options, name, block if block_given?
|
6
|
-
options ||= {}
|
7
|
-
html_options ||= {}
|
8
|
-
|
9
|
-
prepend_class(html_options, 'navbar-link')
|
10
|
-
|
11
|
-
return link_to(name, options, html_options) unless block_given?
|
12
|
-
|
13
|
-
link_to options, html_options do
|
14
|
-
yield name
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def navbar_link(name = nil, options = nil, html_options = nil, &block)
|
19
|
-
html_options, options, name = options, name, block if block_given?
|
20
|
-
options ||= {}
|
21
|
-
html_options ||= {}
|
22
|
-
|
23
|
-
prepend_class(html_options, 'navbar-link')
|
24
|
-
active = 'active' if html_options.delete(:active)
|
25
|
-
|
26
|
-
|
27
|
-
content_tag :li, class: active do
|
28
|
-
if block_given?
|
29
|
-
link_to options, html_options do
|
30
|
-
yield name
|
31
|
-
end
|
32
|
-
else
|
33
|
-
link_to name, options, html_options
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def navbar_brand(name = nil, options = nil, html_options = nil, &block)
|
39
|
-
html_options, options, name = options, name, block if block_given?
|
40
|
-
options ||= {}
|
41
|
-
html_options ||= {}
|
42
|
-
|
43
|
-
prepend_class(html_options, 'navbar-brand')
|
44
|
-
|
45
|
-
if block_given?
|
46
|
-
link_to options, html_options do
|
47
|
-
yield name
|
48
|
-
end
|
49
|
-
else
|
50
|
-
link_to name, options, html_options
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|