bh 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +2 -1
- data/CHANGELOG.md +19 -0
- data/README.md +51 -18
- data/bh.gemspec +13 -9
- data/examples/middleman/.gitignore +18 -0
- data/examples/middleman/Gemfile +6 -0
- data/examples/middleman/config.rb +1 -0
- data/examples/middleman/source/index.html.erb +158 -0
- data/examples/padrino/Gemfile +9 -0
- data/examples/padrino/app/app.rb +16 -0
- data/examples/padrino/app/views/index.html.erb +155 -0
- data/examples/padrino/config.ru +5 -0
- data/examples/padrino/config/apps.rb +5 -0
- data/examples/padrino/config/boot.rb +8 -0
- data/examples/rails/.gitignore +12 -0
- data/examples/rails/Gemfile +5 -0
- data/examples/rails/app/controllers/application_controller.rb +6 -0
- data/examples/rails/app/controllers/users_controller.rb +2 -0
- data/examples/rails/app/models/user.rb +15 -0
- data/examples/rails/app/views/application/index.html.erb +160 -0
- data/examples/rails/bin/rails +4 -0
- data/examples/rails/config.ru +4 -0
- data/examples/rails/config/application.rb +12 -0
- data/examples/rails/config/boot.rb +3 -0
- data/examples/rails/config/environment.rb +5 -0
- data/examples/rails/config/environments/development.rb +7 -0
- data/examples/rails/config/routes.rb +4 -0
- data/examples/rails/config/secrets.yml +22 -0
- data/examples/rails/log/.keep +0 -0
- data/gemfiles/Gemfile.rails-3.x +2 -0
- data/gemfiles/Gemfile.rails-4.x +2 -0
- data/lib/bh.rb +15 -4
- data/lib/bh/classes/alert_box.rb +35 -0
- data/lib/bh/classes/base.rb +125 -0
- data/lib/bh/classes/button.rb +58 -0
- data/lib/bh/classes/button_to.rb +33 -0
- data/lib/bh/classes/cdn.rb +35 -0
- data/lib/bh/classes/dropdown.rb +56 -0
- data/lib/bh/classes/icon.rb +34 -0
- data/lib/bh/classes/link_to.rb +22 -0
- data/lib/bh/classes/modal.rb +68 -0
- data/lib/bh/classes/nav.rb +37 -0
- data/lib/bh/classes/navbar.rb +78 -0
- data/lib/bh/classes/panel.rb +72 -0
- data/lib/bh/classes/panel_row.rb +13 -0
- data/lib/bh/classes/progress_bar.rb +89 -0
- data/lib/bh/classes/stack.rb +19 -0
- data/lib/bh/classes/vertical.rb +27 -0
- data/lib/bh/core_ext/middleman.rb +24 -0
- data/lib/bh/core_ext/padrino.rb +25 -0
- data/lib/bh/core_ext/rails/base_helper.rb +21 -0
- data/lib/bh/{helpers → core_ext/rails}/form/base_helper.rb +3 -1
- data/lib/bh/{helpers → core_ext/rails}/form/check_box_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/field_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/fields_for_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/fieldset_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/file_field_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/legend_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/radio_button_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/select_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/static_control_helper.rb +1 -1
- data/lib/bh/{helpers → core_ext/rails}/form/submit_helper.rb +1 -1
- data/lib/bh/{form_builders → core_ext/rails}/form_builder.rb +11 -10
- data/lib/bh/core_ext/rails/form_for_helper.rb +32 -0
- data/lib/bh/core_ext/railtie.rb +27 -0
- data/lib/bh/helpers/alert_box_helper.rb +40 -0
- data/lib/bh/helpers/button_helper.rb +35 -58
- data/lib/bh/helpers/button_to_helper.rb +48 -10
- data/lib/bh/helpers/cdn_helper.rb +11 -35
- data/lib/bh/helpers/dropdown_helper.rb +29 -62
- data/lib/bh/helpers/glyphicon_helper.rb +7 -13
- data/lib/bh/helpers/horizontal_helper.rb +35 -0
- data/lib/bh/helpers/icon_helper.rb +15 -29
- data/lib/bh/helpers/link_to_helper.rb +52 -41
- data/lib/bh/helpers/modal_helper.rb +49 -79
- data/lib/bh/helpers/nav_helper.rb +25 -40
- data/lib/bh/helpers/navbar_helper.rb +36 -170
- data/lib/bh/helpers/panel_helper.rb +45 -72
- data/lib/bh/helpers/panel_row_helper.rb +20 -38
- data/lib/bh/helpers/progress_bar_helper.rb +48 -59
- data/lib/bh/helpers/vertical_helper.rb +33 -0
- data/lib/bh/version.rb +1 -1
- data/lib/bh/views/bh/_alert_dismiss_button.html +4 -0
- data/lib/bh/views/bh/_dropdown.html.erb +5 -5
- data/lib/bh/views/bh/_dropdown_split.html.erb +5 -5
- data/lib/bh/views/bh/_modal.html.erb +5 -8
- data/lib/bh/views/bh/_navbar.html.erb +5 -0
- data/spec/padrino/button_to_helper.rb +35 -0
- data/spec/padrino_spec.rb +28 -0
- data/spec/rails/button_to_helper.rb +31 -0
- data/spec/{helpers → rails}/form/check_box_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/field_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/fields_for_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/fieldset_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/file_field_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/legend_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/radio_button_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/select_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/static_control_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form/submit_helper_spec.rb +3 -3
- data/spec/{helpers → rails}/form_for_helper_spec.rb +3 -3
- data/spec/rails_helper.rb +25 -0
- data/spec/rails_spec.rb +28 -0
- data/spec/shared/alert_box_helper.rb +62 -0
- data/spec/shared/button_helper.rb +52 -0
- data/spec/shared/button_to_helper.rb +42 -0
- data/spec/shared/cdn_helper.rb +36 -0
- data/spec/shared/dropdown_helper.rb +112 -0
- data/spec/shared/glyphicon_helper.rb +21 -0
- data/spec/shared/horizontal_helper.rb +37 -0
- data/spec/shared/icon_helper.rb +31 -0
- data/spec/shared/link_to_helper.rb +62 -0
- data/spec/shared/modal_helper.rb +104 -0
- data/spec/shared/nav_helper.rb +49 -0
- data/spec/shared/navbar_helper.rb +63 -0
- data/spec/shared/panel_helper.rb +76 -0
- data/spec/shared/panel_row_helper.rb +21 -0
- data/spec/shared/progress_bar_helper.rb +103 -0
- data/spec/shared/vertical_helper.rb +43 -0
- data/spec/spec_helper.rb +6 -29
- data/spec/support/matchers.rb +38 -0
- data/spec/support/padrino.rb +33 -0
- data/spec/support/rails.rb +27 -0
- metadata +183 -94
- data/config.rb +0 -6
- data/lib/bh/helpers/alert_helper.rb +0 -77
- data/lib/bh/helpers/base_helper.rb +0 -39
- data/lib/bh/helpers/form_for_helper.rb +0 -30
- data/lib/bh/middleman.rb +0 -39
- data/lib/bh/railtie.rb +0 -42
- data/spec/dummy/index.html.erb +0 -60
- data/spec/dummy/layouts/default.erb +0 -17
- data/spec/helpers/alert_helper_spec.rb +0 -84
- data/spec/helpers/button_helper_spec.rb +0 -100
- data/spec/helpers/button_to_helper_spec.rb +0 -25
- data/spec/helpers/cdn_helper_spec.rb +0 -100
- data/spec/helpers/dropdown_helper_spec.rb +0 -146
- data/spec/helpers/glyphicon_helper_spec.rb +0 -21
- data/spec/helpers/icon_helper_spec.rb +0 -45
- data/spec/helpers/link_to_helper_spec.rb +0 -124
- data/spec/helpers/modal_helper_spec.rb +0 -133
- data/spec/helpers/nav_helper_spec.rb +0 -53
- data/spec/helpers/navbar_helper_spec.rb +0 -194
- data/spec/helpers/panel_helper_spec.rb +0 -95
- data/spec/helpers/panel_row_helper_spec.rb +0 -27
- data/spec/helpers/progress_bar_helper_spec.rb +0 -114
@@ -1,80 +1,53 @@
|
|
1
|
-
require 'bh/
|
1
|
+
require 'bh/classes/panel'
|
2
|
+
require 'bh/classes/panel_row'
|
3
|
+
require 'bh/classes/stack'
|
2
4
|
|
3
5
|
module Bh
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
module Helpers
|
7
|
+
# Displays a Bootstrap-styled panel.
|
8
|
+
# @see http://getbootstrap.com/components/#panels
|
9
|
+
# @return [String] the HTML to display a Bootstrap-styled panel.
|
10
|
+
# @overload panel(body, options = {})
|
11
|
+
# @param [#to_s] body the content to display as the panel body.
|
12
|
+
# @param [Hash] options the options for the panel. Any option not
|
13
|
+
# listed below is passed as an HTML attribute to the panel’s `<div>`.
|
14
|
+
# @option options [#to_s] :title the text to display as the panel title.
|
15
|
+
# @option options [#to_s] :heading the text to display as the panel
|
16
|
+
# heading.
|
17
|
+
# @option options [#to_s] :body the text to display as the panel body.
|
18
|
+
# Using this option is equivalent to passing the body as an argument.
|
19
|
+
# @option options [#to_s] :context (#to_s) (:default) the contextual
|
20
|
+
# alternative to apply to the panel heading and border. Can be
|
21
|
+
# `:danger`, `:info`, `:primary`, `:success` or `:warning`.
|
22
|
+
# @option options [#to_s] :tag (#to_s) (:div) the HTML tag to wrap the
|
23
|
+
# panel into.
|
24
|
+
# @example Display an informative panel with plain-text content.
|
25
|
+
# panel 'You accepted the Terms of service.', context: :success
|
26
|
+
# @overload panel(options = {}, &block)
|
27
|
+
# @param [Hash] options the options for the panel (see above).
|
28
|
+
# @yieldreturn [#to_s] the content to display in the panel.
|
29
|
+
# @example Display a panel with HTML content.
|
30
|
+
# panel title: 'Thanks' do
|
31
|
+
# content_tag :div, class: 'panel-body' do
|
32
|
+
# content_tag :em, 'ou accepted the Terms of service.'
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
def panel(*args, &block)
|
36
|
+
panel = Bh::Panel.new self, *args, &block
|
37
|
+
panel.extract! :body, :context, :title, :heading, :tag
|
8
38
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
# which case, the options are the second parameter), or as a block (in
|
14
|
-
# which case, the options are the first paramter).
|
15
|
-
# @example An panel with plain-text content passed as the first parameter.
|
16
|
-
# panel 'Your profile was updated!', context: :info, title: 'Profile'
|
17
|
-
# @example A panel with HTML content passed as a block.
|
18
|
-
# panel context: :info, title: 'Profile'
|
19
|
-
# content_tag :strong, "Your profile was updated!"
|
20
|
-
# end
|
21
|
-
#
|
22
|
-
# @return [String] an HTML block tag for a panel.
|
23
|
-
# @param [String] content_or_options_with_block the content to display in
|
24
|
-
# the panel.
|
25
|
-
# @param [Hash] options the display options for the panel.
|
26
|
-
# @option options [#to_s] :context (:default) the contextual alternative to
|
27
|
-
# apply to the panel depending on its importance. Can be :default,
|
28
|
-
# :primary, :success, :info, :warning or :danger.
|
29
|
-
# @option options [#to_s] :body if present, the panel will include the
|
30
|
-
# provided text wrapped in a 'panel-body' block, for proper padding
|
31
|
-
# @see http://getbootstrap.com/components/#panels-basic
|
32
|
-
# @option options [#to_s] :heading if present, the panel will include a
|
33
|
-
# heading with the provided text.
|
34
|
-
# @option options [#to_s] :title if present, the panel will include a
|
35
|
-
# heading with the provided text wrapped in a 'panel-title' block, for
|
36
|
-
# proper title styling and link coloring.
|
37
|
-
# @option options [#to_s] :tag (:div) the HTML tag to wrap the panel in.
|
38
|
-
# @see http://getbootstrap.com/components/#panels-heading
|
39
|
-
def panel(content_or_options_with_block = nil, options = nil, &block)
|
40
|
-
if block_given?
|
41
|
-
panel_string capture(&block), content_or_options_with_block || {}
|
42
|
-
elsif content_or_options_with_block.is_a?(Hash) && options.nil?
|
43
|
-
panel_string nil, content_or_options_with_block
|
44
|
-
else
|
45
|
-
panel_string content_or_options_with_block, options || {}
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def panel_string(content = nil, options = {})
|
52
|
-
content = prepend_optional_body_to content, options
|
53
|
-
content = prepend_optional_heading_to content, options
|
54
|
-
tag = options.fetch :tag, :div
|
55
|
-
content_tag tag, content, class: panel_class(options[:context])
|
56
|
-
end
|
39
|
+
panel.append_class! :panel
|
40
|
+
panel.append_class! panel.context_class
|
41
|
+
panel.merge_html! panel.body
|
42
|
+
panel.prepend_html! panel.heading
|
57
43
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
def prepend_optional_body_to(content, options = {})
|
65
|
-
body = options[:body]
|
66
|
-
body = content_tag :div, body, class: 'panel-body' if body
|
67
|
-
safe_join [body, content].compact
|
68
|
-
end
|
69
|
-
|
70
|
-
def prepend_optional_heading_to(content, options = {})
|
71
|
-
title = if options[:title]
|
72
|
-
content_tag :h3, options[:title], class: 'panel-title'
|
73
|
-
elsif options[:heading]
|
74
|
-
options[:heading]
|
44
|
+
if panel_row = Bh::Stack.find(Bh::PanelRow)
|
45
|
+
container = Bh::Base.new(self) { panel.content_tag panel.tag }
|
46
|
+
container.append_class! panel_row.column_class
|
47
|
+
container.render_tag :div
|
48
|
+
else
|
49
|
+
panel.render_tag panel.tag
|
75
50
|
end
|
76
|
-
heading = content_tag :div, title, class: 'panel-heading' if title
|
77
|
-
safe_join [heading, content].compact
|
78
51
|
end
|
79
52
|
end
|
80
53
|
end
|
@@ -1,46 +1,28 @@
|
|
1
|
-
require 'bh/
|
1
|
+
require 'bh/classes/panel_row'
|
2
2
|
|
3
3
|
module Bh
|
4
|
-
|
5
|
-
|
6
|
-
# @see http://getbootstrap.com/components/#panels
|
7
|
-
module PanelRowHelper
|
8
|
-
include PanelHelper # for panel
|
9
|
-
|
10
|
-
# Returns an HTML block tag that follows the Bootstrap documentation
|
11
|
-
# on how to display a *row*, passing column options to each panel in
|
12
|
-
# the row.
|
13
|
-
#
|
14
|
-
# @return [String] an HTML block tag for a row of panels.
|
15
|
-
# @param [Hash] options the display options for the row of panels.
|
16
|
-
# @option options [#to_s] :column_class the class to apply to the column
|
17
|
-
# <div> that wraps every panel in the row. Useful to specify a grid size
|
18
|
-
# for the column such as 'col-sm-4' to indicate how many columns of the
|
19
|
-
# row each panel should occupy.
|
20
|
-
# @see http://getbootstrap.com/css/#grid
|
4
|
+
module Helpers
|
5
|
+
# Wraps a set of Bootstrap-styled panels in a row.
|
21
6
|
# @see http://getbootstrap.com/components/#panels
|
7
|
+
# @see http://getbootstrap.com/css/#grid
|
8
|
+
# @return [String] the HTML to display a row of Bootstrap-styled panels.
|
9
|
+
# @param [Hash] options the options for the row. Any option not
|
10
|
+
# listed below is passed as an HTML attribute to the row’s `<div>`.
|
11
|
+
# @option options [#to_s] :column_class the class to wrap each panel with.
|
12
|
+
# Useful to specify a grid size for the column such as 'col-sm-4' to
|
13
|
+
# indicate how many columns of the row each panel should occupy.
|
14
|
+
# @yieldreturn [#to_s] the panels to display in a row.
|
15
|
+
# @example Display a row of two panels with the same width.
|
16
|
+
# panel_row column_class: 'col-sm-6' do
|
17
|
+
# panel 'Panel #1', context: :success
|
18
|
+
# panel 'Panel #2', context: :info
|
19
|
+
# end
|
22
20
|
def panel_row(options = {}, &block)
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
# Overrides PanelHelper +panel+ to be able to add a column <div> around
|
31
|
-
# each panel in a row, to make it fit inside the panel row.
|
32
|
-
def panel(*args, &block)
|
33
|
-
panel = super *args, &block
|
34
|
-
if @panel_column_class
|
35
|
-
content_tag :div, panel, class: @panel_column_class
|
36
|
-
else
|
37
|
-
panel
|
38
|
-
end
|
39
|
-
end
|
21
|
+
panel_row = Bh::PanelRow.new self, options, &block
|
22
|
+
panel_row.extract! :column_class
|
40
23
|
|
41
|
-
|
42
|
-
|
43
|
-
capture(&block).tap{ @panel_column_class = nil }
|
24
|
+
panel_row.append_class! :row
|
25
|
+
panel_row.render_tag :div
|
44
26
|
end
|
45
27
|
end
|
46
28
|
end
|
@@ -1,66 +1,55 @@
|
|
1
|
-
require 'bh/
|
1
|
+
require 'bh/classes/progress_bar'
|
2
2
|
|
3
3
|
module Bh
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
4
|
+
module Helpers
|
5
|
+
# Displays one or more Bootstrap-styled progress bars.
|
6
|
+
# @see http://getbootstrap.com/components/#progress
|
7
|
+
# @return [String] the HTML to display Bootstrap-styled progress bars.
|
8
|
+
# @overload progress_bar(bar_options = {}, container_options = {})
|
9
|
+
# @param [Hash] bar_options the options to display a single progress bar.
|
10
|
+
# Any option not listed below is passed as an HTML attribute to the
|
11
|
+
# bar’s `<div>`.
|
12
|
+
# @option bar_options [Boolean, #to_s] :label (false) the label to display
|
13
|
+
# on top of the progress bar. If set to false, the label is hidden. If
|
14
|
+
# set to true, the label is generated from the percentage value. Any
|
15
|
+
# other provided value is used directly as the label.
|
16
|
+
# @option bar_options [Boolean] :striped (false) whether to display a
|
17
|
+
# striped version of the progress bar (rather than solid color).
|
18
|
+
# @option bar_options [Boolean] :animated (false) whether to display an
|
19
|
+
# animated version of the progress bar (rather than solid color).
|
20
|
+
# @option bar_options [#to_s] :context (:default) the contextual
|
21
|
+
# alternative to apply to the progress bar. Can be `:success`, `:info`,
|
22
|
+
# `:warning` or `:danger`.
|
23
|
+
# @param [Hash] container_options the options to pass as HTML attributes
|
24
|
+
# to the container’s `<div>`.
|
25
|
+
# @example Display a 30% warning progress bar.
|
26
|
+
# progress_bar percentage: 30, context: :warning
|
27
|
+
# @overload progress_bar(stacked_bars_options = [], container_options = {})
|
28
|
+
# @param [Hash] stacked_bars_options an array of bar_options (see above).
|
29
|
+
# When an array is provided, a group of stacked progress bars is
|
30
|
+
# displayed, each one matching the corresponding bar options.
|
31
|
+
# @param [Hash] container_options the options to pass as HTML attributes
|
32
|
+
# to the container’s `<div>`.
|
33
|
+
# @example Display two stacked progress bars.
|
34
|
+
# progress_bar [{percentage: 30, context: :warning}, {percentage: 20}]
|
35
|
+
def progress_bar(args = nil, container_options = {})
|
36
|
+
progress_bars = Array.wrap(args).map do |options|
|
37
|
+
progress_bar = Bh::ProgressBar.new self, nil, options
|
38
|
+
progress_bar.extract! :percentage, :context, :striped, :animated, :label
|
39
|
+
|
40
|
+
progress_bar.merge! progress_bar.aria_values
|
41
|
+
progress_bar.append_class! :'progress-bar'
|
42
|
+
progress_bar.append_class! progress_bar.context_class
|
43
|
+
progress_bar.append_class! progress_bar.striped_class
|
44
|
+
progress_bar.append_class! progress_bar.animated_class
|
45
|
+
progress_bar.merge! progress_bar.values
|
46
|
+
progress_bar.prepend_html! progress_bar.label
|
47
|
+
progress_bar
|
43
48
|
end
|
44
49
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
def progress_bar_label(percentage, options = {})
|
49
|
-
text = "#{percentage}%#{" (#{options[:context]})" if options[:context]}"
|
50
|
-
case options.fetch(:label, false)
|
51
|
-
when true then text
|
52
|
-
when false then content_tag(:span, text, class: 'sr-only')
|
53
|
-
else options[:label]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def progress_bar_class(options = {})
|
58
|
-
valid_contexts = %w(success info warning danger)
|
59
|
-
context = context_for options[:context], valid: valid_contexts
|
60
|
-
context = context.in?(valid_contexts) ? "progress-bar-#{context}" : nil
|
61
|
-
striped = 'progress-bar-striped' if options[:striped]
|
62
|
-
animated = 'progress-bar-striped active' if options[:animated]
|
63
|
-
['progress-bar', context, striped, animated].compact.join ' '
|
50
|
+
container = Bh::Base.new self, progress_bars, container_options
|
51
|
+
container.append_class! :progress
|
52
|
+
container.render_tag :div
|
64
53
|
end
|
65
54
|
end
|
66
55
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'bh/classes/navbar'
|
2
|
+
require 'bh/classes/vertical'
|
3
|
+
|
4
|
+
module Bh
|
5
|
+
module Helpers
|
6
|
+
# Displays the non-collapsable portion of a Bootstrap-styled navbar.
|
7
|
+
# @see http://getbootstrap.com/components/#navbar
|
8
|
+
# @return [String] the HTML to display the non-collapsable portion of a
|
9
|
+
# Bootstrap-styled navbar.
|
10
|
+
# @overload vertical(content, options = {})
|
11
|
+
# @param [#to_s] content the non-collapsable content to display in the
|
12
|
+
# navbar.
|
13
|
+
# @param [Hash] options the options to pass to the wrapping `<div>`.
|
14
|
+
# @overload vertical(options = {}, &block)
|
15
|
+
# @param [Hash] options the options to pass to the wrapping `<div>`.
|
16
|
+
# @yieldreturn [#to_s] the non-collapsable content to display in the
|
17
|
+
# navbar.
|
18
|
+
# @example Display a navbar a non-collapsable links.
|
19
|
+
# navbar do
|
20
|
+
# vertical do
|
21
|
+
# link_to 'Home', '/'
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
def vertical(*args, &block)
|
25
|
+
if navbar = Bh::Stack.find(Bh::Navbar)
|
26
|
+
vertical = Bh::Vertical.new self, *args, &block
|
27
|
+
vertical.append_class! :'navbar-header'
|
28
|
+
vertical.prepend_html! vertical.toggle_button(navbar.id)
|
29
|
+
vertical.render_tag :div
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/bh/version.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
<div class="<%=
|
2
|
-
<button class="dropdown-toggle <%=
|
3
|
-
<%= caption %>
|
1
|
+
<div class="<%= div[:class] %>">
|
2
|
+
<button class="dropdown-toggle <%= button[:class] %>" type="button" id="<%= button[:id] %>" data-toggle="dropdown">
|
3
|
+
<%= button[:caption] %>
|
4
4
|
<span class="caret"></span>
|
5
5
|
</button>
|
6
|
-
<ul class="<%=
|
7
|
-
<%=
|
6
|
+
<ul class="<%= ul[:class] %>" role="menu" aria-labelledby="<%= button[:id] %>">
|
7
|
+
<%= content %>
|
8
8
|
</ul>
|
9
9
|
</div>
|
@@ -1,10 +1,10 @@
|
|
1
|
-
<div class="<%=
|
2
|
-
<button type="button" class="<%=
|
3
|
-
<button class="dropdown-toggle <%=
|
1
|
+
<div class="<%= div[:class] %>">
|
2
|
+
<button type="button" class="<%= button[:class] %>"><%= button[:caption] %></button>
|
3
|
+
<button class="dropdown-toggle <%= button[:class] %>" type="button" id="<%= button[:id] %>" data-toggle="dropdown">
|
4
4
|
<span class="caret"></span>
|
5
5
|
<span class="sr-only">Toggle Dropdown</span>
|
6
6
|
</button>
|
7
|
-
<ul class="<%=
|
8
|
-
<%=
|
7
|
+
<ul class="<%= ul[:class] %>" role="menu" aria-labelledby="<%= button[:id] %>">
|
8
|
+
<%= content %>
|
9
9
|
</ul>
|
10
10
|
</div>
|
@@ -1,17 +1,14 @@
|
|
1
|
-
<button class="<%= button[:class] %>" data-toggle="modal" data-target="#<%= id %>">
|
2
|
-
|
3
|
-
|
4
|
-
<div class="modal fade" id="<%= id %>" tabindex="-1" role="dialog" aria-labelledby="label-<%= id %>" aria-hidden="true">
|
5
|
-
<div class="<%= dialog_class %>">
|
1
|
+
<button class="<%= button[:class] %>" data-toggle="modal" data-target="#<%= div[:id] %>"><%= button[:caption] %></button>
|
2
|
+
<div class="modal fade" id="<%= div[:id] %>" tabindex="-1" role="dialog" aria-labelledby="label-<%= div[:id] %>" aria-hidden="true">
|
3
|
+
<div class="<%= div[:class] %>">
|
6
4
|
<div class="modal-content">
|
7
5
|
<div class="modal-header">
|
8
6
|
<button type="button" class="close" data-dismiss="modal">
|
9
7
|
<span aria-hidden="true">×</span><span class="sr-only">Close</span>
|
10
8
|
</button>
|
11
|
-
<h4 class="modal-title" id="label-<%= id %>"><%= title %></h4>
|
9
|
+
<h4 class="modal-title" id="label-<%= div[:id] %>"><%= div[:title] %></h4>
|
12
10
|
</div>
|
13
|
-
<%=
|
14
|
-
<%= yield %>
|
11
|
+
<%= content %>
|
15
12
|
</div>
|
16
13
|
</div>
|
17
14
|
</div>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
shared_examples_for 'the button_to helper (Padrino)' do
|
2
|
+
all_tests_pass_with 'no button_to options (Padrino)'
|
3
|
+
all_tests_pass_with 'only extra button_to options (Padrino)'
|
4
|
+
all_tests_pass_with 'extra button_to options (Padrino)'
|
5
|
+
all_tests_pass_for 'the button_to helper'
|
6
|
+
end
|
7
|
+
|
8
|
+
#--
|
9
|
+
|
10
|
+
shared_examples_for 'no button_to options (Padrino)' do
|
11
|
+
specify 'uses the original button_to helper' do
|
12
|
+
html = '<form action="/" accept-charset="UTF-8" method="post"><input type="hidden" name="authenticity_token" /><input type="submit" value="content" /></form>'
|
13
|
+
expect(:button_to).to generate html
|
14
|
+
|
15
|
+
# @note: Only Padrino >= 0.13.0 renders the content of the block as a
|
16
|
+
# <button> so the exact content is only partially tested here.
|
17
|
+
expect(bh.button_to('/'){ 'content' }).to include 'content'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
shared_examples_for 'only extra button_to options (Padrino)' do
|
22
|
+
specify 'uses the original button_to helper' do
|
23
|
+
options = {class: 'big', id: 'my-form', submit_options: {class: 'important', data: {value: 1}, id: 'my-button_to'}}
|
24
|
+
html = '<form action="/" accept-charset="UTF-8" class="big" id="my-form" method="post"><input type="hidden" name="authenticity_token" /><input type="submit" value="content" class="important" data-value="1" id="my-button_to" /></form>'
|
25
|
+
expect(button_to: options).to generate html
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
shared_examples_for 'extra button_to options (Padrino)' do
|
30
|
+
specify 'passes the options to the form and the submit_options to the button' do
|
31
|
+
options = {context: :default, class: 'big', id: 'my-form', submit_options: {class: 'important', data: {value: 1}, id: 'my-button_to'}}
|
32
|
+
html = '<form action="/" accept-charset="UTF-8" class="big" id="my-form" method="post"><input type="hidden" name="authenticity_token" /><input type="submit" value="content" class="important btn btn-default" data-value="1" id="my-button_to" /></form>'
|
33
|
+
expect(button_to: options).to generate html
|
34
|
+
end
|
35
|
+
end
|