bh 1.3.5 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +8 -0
- data/README.md +8 -138
- data/app/assets/stylesheets/bh.css +29 -0
- data/app/javascript/controllers/bh/theme_controller.js +17 -0
- data/app/views/bh/_grid.html.erb +6 -0
- data/app/views/bh/_table.html.erb +46 -0
- data/bh.gemspec +5 -31
- data/gemfiles/Gemfile.rails-3.x +0 -1
- data/lib/bh/bootstrap_helpers.rb +131 -0
- data/lib/bh/engine.rb +13 -0
- data/lib/bh/version.rb +3 -1
- data/lib/bh.rb +6 -14
- data/spec/spec_helper.rb +1 -1
- metadata +14 -298
- data/examples/middleman/.gitignore +0 -18
- data/examples/middleman/Gemfile +0 -6
- data/examples/middleman/config.rb +0 -1
- data/examples/middleman/source/index.html.erb +0 -158
- data/examples/padrino/Gemfile +0 -9
- data/examples/padrino/app/app.rb +0 -16
- data/examples/padrino/app/views/index.html.erb +0 -155
- data/examples/padrino/config/apps.rb +0 -5
- data/examples/padrino/config/boot.rb +0 -8
- data/examples/padrino/config.ru +0 -5
- data/examples/rails/.gitignore +0 -12
- data/examples/rails/Gemfile +0 -5
- data/examples/rails/app/controllers/application_controller.rb +0 -6
- data/examples/rails/app/controllers/users_controller.rb +0 -2
- data/examples/rails/app/models/user.rb +0 -15
- data/examples/rails/app/views/application/index.html.erb +0 -160
- data/examples/rails/bin/rails +0 -4
- data/examples/rails/config/application.rb +0 -12
- data/examples/rails/config/boot.rb +0 -3
- data/examples/rails/config/environment.rb +0 -5
- data/examples/rails/config/environments/development.rb +0 -7
- data/examples/rails/config/routes.rb +0 -4
- data/examples/rails/config/secrets.yml +0 -22
- data/examples/rails/config.ru +0 -4
- data/examples/rails/log/.keep +0 -0
- data/lib/bh/classes/alert_box.rb +0 -35
- data/lib/bh/classes/base.rb +0 -125
- data/lib/bh/classes/button.rb +0 -58
- data/lib/bh/classes/button_to.rb +0 -33
- data/lib/bh/classes/cdn.rb +0 -35
- data/lib/bh/classes/dropdown.rb +0 -56
- data/lib/bh/classes/icon.rb +0 -34
- data/lib/bh/classes/link_to.rb +0 -26
- data/lib/bh/classes/modal.rb +0 -68
- data/lib/bh/classes/nav.rb +0 -37
- data/lib/bh/classes/navbar.rb +0 -78
- data/lib/bh/classes/panel.rb +0 -72
- data/lib/bh/classes/panel_row.rb +0 -13
- data/lib/bh/classes/progress_bar.rb +0 -89
- data/lib/bh/classes/stack.rb +0 -19
- data/lib/bh/classes/vertical.rb +0 -27
- data/lib/bh/core_ext/middleman.rb +0 -24
- data/lib/bh/core_ext/padrino.rb +0 -25
- data/lib/bh/core_ext/rails/base_helper.rb +0 -21
- data/lib/bh/core_ext/rails/form/base_helper.rb +0 -150
- data/lib/bh/core_ext/rails/form/check_box_helper.rb +0 -35
- data/lib/bh/core_ext/rails/form/field_helper.rb +0 -15
- data/lib/bh/core_ext/rails/form/fields_for_helper.rb +0 -23
- data/lib/bh/core_ext/rails/form/fieldset_helper.rb +0 -16
- data/lib/bh/core_ext/rails/form/file_field_helper.rb +0 -15
- data/lib/bh/core_ext/rails/form/legend_helper.rb +0 -17
- data/lib/bh/core_ext/rails/form/radio_button_helper.rb +0 -19
- data/lib/bh/core_ext/rails/form/select_helper.rb +0 -16
- data/lib/bh/core_ext/rails/form/static_control_helper.rb +0 -43
- data/lib/bh/core_ext/rails/form/submit_helper.rb +0 -23
- data/lib/bh/core_ext/rails/form_builder.rb +0 -46
- data/lib/bh/core_ext/rails/form_for_helper.rb +0 -41
- data/lib/bh/core_ext/railtie.rb +0 -27
- data/lib/bh/helpers/alert_box_helper.rb +0 -40
- data/lib/bh/helpers/button_helper.rb +0 -40
- data/lib/bh/helpers/button_to_helper.rb +0 -65
- data/lib/bh/helpers/cdn_helper.rb +0 -46
- data/lib/bh/helpers/dropdown_helper.rb +0 -49
- data/lib/bh/helpers/glyphicon_helper.rb +0 -18
- data/lib/bh/helpers/horizontal_helper.rb +0 -35
- data/lib/bh/helpers/icon_helper.rb +0 -27
- data/lib/bh/helpers/link_to_helper.rb +0 -59
- data/lib/bh/helpers/modal_helper.rb +0 -55
- data/lib/bh/helpers/nav_helper.rb +0 -36
- data/lib/bh/helpers/navbar_helper.rb +0 -48
- data/lib/bh/helpers/panel_helper.rb +0 -53
- data/lib/bh/helpers/panel_row_helper.rb +0 -28
- data/lib/bh/helpers/progress_bar_helper.rb +0 -55
- data/lib/bh/helpers/vertical_helper.rb +0 -33
- data/lib/bh/views/bh/_alert_dismiss_button.html +0 -4
- data/lib/bh/views/bh/_dropdown.html.erb +0 -9
- data/lib/bh/views/bh/_dropdown_split.html.erb +0 -10
- data/lib/bh/views/bh/_modal.html.erb +0 -14
- data/lib/bh/views/bh/_navbar.html.erb +0 -5
data/lib/bh/classes/button.rb
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
require 'bh/classes/base'
|
|
2
|
-
|
|
3
|
-
module Bh
|
|
4
|
-
module Classes
|
|
5
|
-
class Button < Base
|
|
6
|
-
# @return [#to_s] the context-related class to assign to the button.
|
|
7
|
-
def context_class
|
|
8
|
-
Button.contexts[@options[:context]]
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
# @return [#to_s] the size-related class to assign to the alert box.
|
|
12
|
-
def size_class
|
|
13
|
-
Button.sizes[@options[:size]]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# @return [#to_s] the layout-related class to assign to the alert box.
|
|
17
|
-
def layout_class
|
|
18
|
-
Button.layouts[@options[:layout]]
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
# @return [Hash<Symbol, String>] the classes that Bootstrap requires to
|
|
24
|
-
# append to buttons for each possible context.
|
|
25
|
-
def self.contexts
|
|
26
|
-
HashWithIndifferentAccess.new(:'btn-default').tap do |klass|
|
|
27
|
-
klass[:danger] = :'btn-danger'
|
|
28
|
-
klass[:info] = :'btn-info'
|
|
29
|
-
klass[:link] = :'btn-link'
|
|
30
|
-
klass[:primary] = :'btn-primary'
|
|
31
|
-
klass[:success] = :'btn-success'
|
|
32
|
-
klass[:warning] = :'btn-warning'
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# @return [Hash<Symbol, String>] the classes that Bootstrap requires to
|
|
37
|
-
# append to buttons for each possible size.
|
|
38
|
-
def self.sizes
|
|
39
|
-
HashWithIndifferentAccess.new.tap do |klass|
|
|
40
|
-
klass[:extra_small] = :'btn-xs'
|
|
41
|
-
klass[:large] = :'btn-lg'
|
|
42
|
-
klass[:lg] = :'btn-lg'
|
|
43
|
-
klass[:sm] = :'btn-sm'
|
|
44
|
-
klass[:small] = :'btn-sm'
|
|
45
|
-
klass[:xs] = :'btn-xs'
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# @return [Hash<Symbol, String>] the classes that Bootstrap requires to
|
|
50
|
-
# append to buttons for each possible layout.
|
|
51
|
-
def self.layouts
|
|
52
|
-
HashWithIndifferentAccess.new.tap do |klass|
|
|
53
|
-
klass[:block] = :'btn-block'
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
data/lib/bh/classes/button_to.rb
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
require 'bh/classes/button'
|
|
2
|
-
|
|
3
|
-
module Bh
|
|
4
|
-
module Classes
|
|
5
|
-
class ButtonTo < Button
|
|
6
|
-
def initialize(app = nil, *args, &block)
|
|
7
|
-
@url = extract_url_from(*args, &block)
|
|
8
|
-
super
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def append_button_class!(klass)
|
|
12
|
-
case Bh.framework
|
|
13
|
-
when :rails then append_class! klass
|
|
14
|
-
when :padrino, :middleman then append_class_to! :submit_options, klass
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def append_form_class!(klass)
|
|
19
|
-
case Bh.framework
|
|
20
|
-
when :rails then append_class! klass, html_attributes, :form_class
|
|
21
|
-
when :padrino, :middleman then append_class! klass
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def accepts_block?
|
|
26
|
-
case Bh.framework
|
|
27
|
-
when :rails then defined?(ActionView::VERSION) # only Rails >= 4
|
|
28
|
-
when :padrino, :middleman then true
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
data/lib/bh/classes/cdn.rb
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
require 'bh/classes/base'
|
|
2
|
-
|
|
3
|
-
module Bh
|
|
4
|
-
module Classes
|
|
5
|
-
# @api private
|
|
6
|
-
class Cdn
|
|
7
|
-
# @note if unspecified, the version should match the latest available
|
|
8
|
-
# version. If that's not the case, it's a bug and should be fixed.
|
|
9
|
-
def self.bootstrap(options = {})
|
|
10
|
-
options[:version] ||= '3.3.2'
|
|
11
|
-
cdn_asset options.merge(library: 'bootstrap')
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
# @note if unspecified, the version should match the latest available
|
|
15
|
-
# version. If that's not the case, it's a bug and should be fixed.
|
|
16
|
-
def self.font_awesome(options = {})
|
|
17
|
-
options[:version] ||= '4.3.0'
|
|
18
|
-
cdn_asset options.merge(library: 'font-awesome')
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
def self.cdn_asset(options = {})
|
|
24
|
-
version = options[:version]
|
|
25
|
-
extension = options[:extension]
|
|
26
|
-
name = options[:name]
|
|
27
|
-
name = "#{name}.min" if options.fetch(:minified, true)
|
|
28
|
-
library = options[:library]
|
|
29
|
-
scheme = "#{options[:scheme]}:" if options[:scheme]
|
|
30
|
-
host = "#{scheme}//netdna.bootstrapcdn.com"
|
|
31
|
-
"#{host}/#{library}/#{version}/#{extension}/#{name}.#{extension}"
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
data/lib/bh/classes/dropdown.rb
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
require 'bh/classes/button'
|
|
2
|
-
|
|
3
|
-
module Bh
|
|
4
|
-
module Classes
|
|
5
|
-
class Dropdown < Button
|
|
6
|
-
# @return [#to_s] the group-related class to assign to the dropdown.
|
|
7
|
-
def groupable_class
|
|
8
|
-
Dropdown.groupables[@options[:groupable]]
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
# @return [#to_s] the direction-related class to assign to the dropdown.
|
|
12
|
-
def direction_class
|
|
13
|
-
Dropdown.directions[@options[:direction]]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# @return [#to_s] the align-related class to assign to the dropdown.
|
|
17
|
-
def align_class
|
|
18
|
-
Dropdown.aligns[@options[:align]]
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def id
|
|
22
|
-
@options.fetch :id, "dropdown-#{rand 10**10}"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def partial
|
|
26
|
-
@options[:split] ? 'dropdown_split' : 'dropdown'
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
private
|
|
30
|
-
|
|
31
|
-
# @return [Hash<Symbol, String>] the class that Bootstrap requires to
|
|
32
|
-
# append to a dropdown to display it as inline or block.
|
|
33
|
-
def self.groupables
|
|
34
|
-
HashWithIndifferentAccess.new(:'btn-group').tap do |klass|
|
|
35
|
-
klass[false] = :dropdown
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# @return [Hash<Symbol, String>] the class that Bootstrap requires to
|
|
40
|
-
# append to a dropdown to show a drop-"up" or -"down".
|
|
41
|
-
def self.directions
|
|
42
|
-
HashWithIndifferentAccess.new.tap do |klass|
|
|
43
|
-
klass[:up] = :dropup
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# @return [Hash<Symbol, String>] the class that Bootstrap requires to
|
|
48
|
-
# append to a dropdown to left- or right- align to the toggle button.
|
|
49
|
-
def self.aligns
|
|
50
|
-
HashWithIndifferentAccess.new.tap do |klass|
|
|
51
|
-
klass[:right] = :'dropdown-menu-right'
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
data/lib/bh/classes/icon.rb
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
require 'bh/classes/base'
|
|
2
|
-
|
|
3
|
-
module Bh
|
|
4
|
-
module Classes
|
|
5
|
-
# @api private
|
|
6
|
-
class Icon < Base
|
|
7
|
-
# @return [#to_s] the class to assign to the icon based on the Vector
|
|
8
|
-
# Icon library used.
|
|
9
|
-
def library_class
|
|
10
|
-
Icon.libraries[@options[:library].to_s.underscore] || @options[:library]
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# @return [#to_s] the class to assign to the icon based on the name
|
|
14
|
-
# of the icon.
|
|
15
|
-
def name_class
|
|
16
|
-
if name = @options[:name]
|
|
17
|
-
"#{library_class}-#{name.to_s.gsub '_', '-'}"
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
# @return [Hash<Symbol, String>] the classes that Bootstrap requires to
|
|
24
|
-
# append to icons for each possible vector icon library.
|
|
25
|
-
def self.libraries
|
|
26
|
-
HashWithIndifferentAccess.new(nil).tap do |klass|
|
|
27
|
-
klass[:font_awesome] = :'fa'
|
|
28
|
-
klass[:glyphicons] = :'glyphicon'
|
|
29
|
-
klass[:''] = :'glyphicon'
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
data/lib/bh/classes/link_to.rb
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
require 'bh/classes/base'
|
|
2
|
-
|
|
3
|
-
module Bh
|
|
4
|
-
module Classes
|
|
5
|
-
class LinkTo < Base
|
|
6
|
-
def initialize(app = nil, *args, &block)
|
|
7
|
-
@url = extract_url_from(*args, &block)
|
|
8
|
-
super
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def current_page?
|
|
12
|
-
case Bh.framework
|
|
13
|
-
when :rails
|
|
14
|
-
@app.current_page? @url
|
|
15
|
-
when :padrino, :middleman
|
|
16
|
-
request = Bh.framework == :middleman ? @app.req : @app.request
|
|
17
|
-
request.path_info == @app.url_for(@url)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def content
|
|
22
|
-
super if @content
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
data/lib/bh/classes/modal.rb
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
require 'bh/classes/button'
|
|
2
|
-
|
|
3
|
-
module Bh
|
|
4
|
-
module Classes
|
|
5
|
-
class Modal < Base
|
|
6
|
-
# Differently from other classes, Modal works with no content or block,
|
|
7
|
-
# given that the options[:body] is passed, in which case it functions
|
|
8
|
-
# as the content.
|
|
9
|
-
def initialize(app = nil, *args, &block)
|
|
10
|
-
if args.first.is_a?(Hash) && !block_given?
|
|
11
|
-
args.unshift args.first.delete(:body)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
super
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# @return [#to_s] the context-related class to assign to the modal button.
|
|
18
|
-
def button_context_class
|
|
19
|
-
Button.contexts[@options.fetch(:button, {})[:context]]
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# @return [#to_s] the size-related class to assign to the modal button.
|
|
23
|
-
def button_size_class
|
|
24
|
-
Button.sizes[@options.fetch(:button, {})[:size]]
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# @return [#to_s] the size-related class to assign to the modal dialog.
|
|
28
|
-
def dialog_size_class
|
|
29
|
-
Modal.dialog_sizes[@options[:size]]
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# @return [#to_s] the caption for the modal button.
|
|
33
|
-
def caption
|
|
34
|
-
@options.fetch(:button, {}).fetch :caption, title
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# @return [#to_s] the title to display on top of the modal dialog.
|
|
38
|
-
def title
|
|
39
|
-
@options.fetch :title, 'Modal'
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def id
|
|
43
|
-
@options.fetch :id, "modal-#{rand 10**10}"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
private
|
|
47
|
-
|
|
48
|
-
# @return [Hash<Symbol, String>] the classes that Bootstrap requires to
|
|
49
|
-
# append to the modal dialog for each possible size.
|
|
50
|
-
def self.dialog_sizes
|
|
51
|
-
HashWithIndifferentAccess.new.tap do |klass|
|
|
52
|
-
klass[:large] = :'modal-lg'
|
|
53
|
-
klass[:lg] = :'modal-lg'
|
|
54
|
-
klass[:sm] = :'modal-sm'
|
|
55
|
-
klass[:small] = :'modal-sm'
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def extract_content_from(*args, &block)
|
|
60
|
-
if block_given?
|
|
61
|
-
super
|
|
62
|
-
else
|
|
63
|
-
@app.content_tag :div, super, class: 'modal-body'
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|
data/lib/bh/classes/nav.rb
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
require 'bh/classes/base'
|
|
2
|
-
|
|
3
|
-
module Bh
|
|
4
|
-
module Classes
|
|
5
|
-
# @api private
|
|
6
|
-
class Nav < Base
|
|
7
|
-
# @return [#to_s] the style-related class to assign to the nav.
|
|
8
|
-
def style_class
|
|
9
|
-
Nav.styles[@options[:as]]
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
# @return [#to_s] the layout-related class to assign to the nav.
|
|
13
|
-
def layout_class
|
|
14
|
-
Nav.layouts[@options[:layout]]
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
# @return [Hash<Symbol, String>] the classes that Bootstrap requires to
|
|
20
|
-
# append to navs for each possible style.
|
|
21
|
-
def self.styles
|
|
22
|
-
HashWithIndifferentAccess.new(:'nav-tabs').tap do |klass|
|
|
23
|
-
klass[:pills] = :'nav-pills'
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# @return [Hash<Symbol, String>] the classes that Bootstrap requires to
|
|
28
|
-
# append to buttons for each possible layout.
|
|
29
|
-
def self.layouts
|
|
30
|
-
HashWithIndifferentAccess.new.tap do |klass|
|
|
31
|
-
klass[:justified] = :'nav-justified'
|
|
32
|
-
klass[:stacked] = :'nav-stacked'
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
data/lib/bh/classes/navbar.rb
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
require 'bh/classes/base'
|
|
2
|
-
|
|
3
|
-
module Bh
|
|
4
|
-
module Classes
|
|
5
|
-
class Navbar < Base
|
|
6
|
-
# @return [#to_s] the style-related class to assign to the navbar.
|
|
7
|
-
def style_class
|
|
8
|
-
Navbar.styles[@options[:inverted]]
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
# @return [#to_s] the position-related class to assign to the navbar.
|
|
12
|
-
def position_class
|
|
13
|
-
Navbar.positions[@options[:position]]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# @return [#to_s] the layout-related class to assign to the navbar.
|
|
17
|
-
def layout_class
|
|
18
|
-
Navbar.layouts[@options[:fluid]]
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def id
|
|
22
|
-
@id ||= @options.fetch :id, "navbar-collapse-#{rand 10**10}"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# @private
|
|
26
|
-
# The fixed navbar will overlay your other content, unless you add padding
|
|
27
|
-
# to the top or bottom of the <body>. Try out your own values or use our
|
|
28
|
-
# snippet below. Tip: By default, the navbar is 50px high.
|
|
29
|
-
# @see http://getbootstrap.com/components/#navbar-fixed-top
|
|
30
|
-
def body_padding_style
|
|
31
|
-
if body_padding_amount && body_padding_type
|
|
32
|
-
style = "padding-#{body_padding_type}: #{body_padding_amount}px"
|
|
33
|
-
@app.content_tag :style, "body {#{style}}"
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
private
|
|
38
|
-
|
|
39
|
-
# @return [Hash<Symbol, String>] the classes that Bootstrap requires to
|
|
40
|
-
# append to navbars to specify a color combination.
|
|
41
|
-
def self.styles
|
|
42
|
-
HashWithIndifferentAccess.new(:'navbar-default').tap do |klass|
|
|
43
|
-
klass[true] = :'navbar-inverse'
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# @return [Hash<Symbol, String>] the classes that Bootstrap requires to
|
|
48
|
-
# append to navbars to set a specific DOM position.
|
|
49
|
-
def self.positions
|
|
50
|
-
HashWithIndifferentAccess.new.tap do |klass|
|
|
51
|
-
klass[:static] = :'navbar-static-top'
|
|
52
|
-
klass[:static_top] = :'navbar-static-top'
|
|
53
|
-
klass[:top] = :'navbar-fixed-top'
|
|
54
|
-
klass[:fixed_top] = :'navbar-fixed-top'
|
|
55
|
-
klass[:bottom] = :'navbar-fixed-bottom'
|
|
56
|
-
klass[:fixed_bottom] = :'navbar-fixed-bottom'
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
# @return [Hash<Symbol, String>] the classes that Bootstrap requires to
|
|
61
|
-
# append to the navbar container for each possible layout.
|
|
62
|
-
def self.layouts
|
|
63
|
-
HashWithIndifferentAccess.new(:'container').tap do |klass|
|
|
64
|
-
klass[true] = :'container-fluid'
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def body_padding_amount
|
|
69
|
-
@options.fetch :padding, 70
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def body_padding_type
|
|
73
|
-
/navbar-fixed-(?<type>top|bottom)$/ =~ position_class
|
|
74
|
-
type
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
data/lib/bh/classes/panel.rb
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
require 'bh/classes/base'
|
|
2
|
-
|
|
3
|
-
module Bh
|
|
4
|
-
module Classes
|
|
5
|
-
class Panel < Base
|
|
6
|
-
# Differently from other classes, Panel works with no content or block,
|
|
7
|
-
# given that the options[:body] is passed, in which case it functions
|
|
8
|
-
# as the content.
|
|
9
|
-
def initialize(app = nil, *args, &block)
|
|
10
|
-
if args.first.is_a?(Hash) && !block_given?
|
|
11
|
-
args.unshift args.first.delete(:body)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
super
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# @return [#to_s] the content-related class to assign to the panel.
|
|
18
|
-
def context_class
|
|
19
|
-
Panel.contexts[@options[:context]]
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# @return [#to_s] the HTML tag to wrap the panel in.
|
|
23
|
-
def tag
|
|
24
|
-
@options.fetch :tag, :div
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# @return [#to_s] the text to display as the panel header
|
|
28
|
-
def heading
|
|
29
|
-
text = title || @options[:heading]
|
|
30
|
-
@app.content_tag :div, text, class: 'panel-heading' if text
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def merge_html!(html)
|
|
34
|
-
@content ||= html
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def body
|
|
38
|
-
if @options[:body]
|
|
39
|
-
@app.content_tag :div, @options[:body], class: 'panel-body'
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
private
|
|
44
|
-
|
|
45
|
-
def extract_content_from(*args, &block)
|
|
46
|
-
if block_given?
|
|
47
|
-
super
|
|
48
|
-
else
|
|
49
|
-
@app.content_tag :div, super, class: 'panel-body'
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def title
|
|
54
|
-
if @options[:title]
|
|
55
|
-
@app.content_tag :h3, @options[:title], class: 'panel-title'
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
# @return [Hash<Symbol, String>] the class that Bootstrap requires to
|
|
60
|
-
# append to an panel box based on its context.
|
|
61
|
-
def self.contexts
|
|
62
|
-
HashWithIndifferentAccess.new(:'panel-default').tap do |klass|
|
|
63
|
-
klass[:primary] = :'panel-primary'
|
|
64
|
-
klass[:success] = :'panel-success'
|
|
65
|
-
klass[:info] = :'panel-info'
|
|
66
|
-
klass[:warning] = :'panel-warning'
|
|
67
|
-
klass[:danger] = :'panel-danger'
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
data/lib/bh/classes/panel_row.rb
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
require 'bh/classes/base'
|
|
2
|
-
|
|
3
|
-
module Bh
|
|
4
|
-
module Classes
|
|
5
|
-
class ProgressBar < Base
|
|
6
|
-
# @return [#to_s] the context-related class to assign to the progress bar.
|
|
7
|
-
def context_class
|
|
8
|
-
ProgressBar.contexts[@options[:context]]
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
# @return [#to_s] the class to assign to make the progress bar striped.
|
|
12
|
-
def striped_class
|
|
13
|
-
ProgressBar.stripes[@options[:striped]]
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# @return [#to_s] the class to assign to make the progress bar aniamted.
|
|
17
|
-
def animated_class
|
|
18
|
-
ProgressBar.animations[@options[:animated]]
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
# @return [#to_s] the text to display as the label of the progress bar.
|
|
22
|
-
def label
|
|
23
|
-
labels[@options.fetch :label, false] || @options[:label]
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def aria_values
|
|
27
|
-
{}.tap do |values|
|
|
28
|
-
values[:'aria-valuemax'] = 100
|
|
29
|
-
values[:'aria-valuemin'] = 0
|
|
30
|
-
values[:'aria-valuenow'] = percentage
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def values
|
|
35
|
-
{}.tap do |values|
|
|
36
|
-
values[:role] = :progressbar
|
|
37
|
-
values[:style] = "width: #{percentage}%"
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
private
|
|
42
|
-
|
|
43
|
-
# @return [Hash<Symbol, String>] the classes that Bootstrap requires to
|
|
44
|
-
# append to the progress bar for each possible context.
|
|
45
|
-
def self.contexts
|
|
46
|
-
HashWithIndifferentAccess.new.tap do |klass|
|
|
47
|
-
klass[:danger] = :'progress-bar-danger'
|
|
48
|
-
klass[:info] = :'progress-bar-info'
|
|
49
|
-
klass[:success] = :'progress-bar-success'
|
|
50
|
-
klass[:warning] = :'progress-bar-warning'
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# @return [Hash<Symbol, String>] the classes that Bootstrap requires to
|
|
55
|
-
# append to the progress bar to make it look striped.
|
|
56
|
-
def self.stripes
|
|
57
|
-
HashWithIndifferentAccess.new.tap do |klass|
|
|
58
|
-
klass[true] = :'progress-bar-striped'
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# @return [Hash<Symbol, String>] the classes that Bootstrap requires to
|
|
63
|
-
# append to the progress bar to make it look animated.
|
|
64
|
-
def self.animations
|
|
65
|
-
HashWithIndifferentAccess.new.tap do |klass|
|
|
66
|
-
klass[true] = :'progress-bar-striped active'
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
# @return [Hash<Symbol, String>] the texts to uses as labels.
|
|
71
|
-
def labels
|
|
72
|
-
HashWithIndifferentAccess.new.tap do |label|
|
|
73
|
-
label[true] = text
|
|
74
|
-
label[false] = @app.content_tag(:span, text, class: 'sr-only')
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def percentage
|
|
79
|
-
@options.fetch :percentage, 0
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def text
|
|
83
|
-
"#{percentage}%".tap do |text|
|
|
84
|
-
text << " (#{@options[:context]})" if @options[:context]
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
end
|
data/lib/bh/classes/stack.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
module Bh
|
|
2
|
-
module Classes
|
|
3
|
-
class Stack
|
|
4
|
-
@@stack = []
|
|
5
|
-
|
|
6
|
-
def self.unshift(item)
|
|
7
|
-
@@stack.unshift item
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def self.shift
|
|
11
|
-
@@stack.shift
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def self.find(helper_class)
|
|
15
|
-
@@stack.find{|helper| helper.is_a? helper_class}
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
data/lib/bh/classes/vertical.rb
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require 'bh/classes/base'
|
|
2
|
-
|
|
3
|
-
module Bh
|
|
4
|
-
module Classes
|
|
5
|
-
class Vertical < Base
|
|
6
|
-
def toggle_button(navbar_id, options = {})
|
|
7
|
-
options[:'class'] = :'navbar-toggle'
|
|
8
|
-
options[:'data-target'] = :"##{navbar_id}"
|
|
9
|
-
options[:'data-toggle'] = :'collapse'
|
|
10
|
-
options[:'type'] = :'button'
|
|
11
|
-
@app.content_tag :button, options do
|
|
12
|
-
safe_join [toggle_text, toggle_bar, toggle_bar, toggle_bar]
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
def toggle_text
|
|
19
|
-
@app.content_tag :span, 'Toggle navigation', class: :'sr-only'
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def toggle_bar
|
|
23
|
-
@app.content_tag :span, nil, class: :'icon-bar'
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
module Bh
|
|
2
|
-
# @api private
|
|
3
|
-
# Provides methods to register Bh in third-party applications.
|
|
4
|
-
module Extensions
|
|
5
|
-
# Makes Bootstrap helpers available in Middleman applications.
|
|
6
|
-
#
|
|
7
|
-
# To use Bh in a Middleman app you need 2 steps:
|
|
8
|
-
#
|
|
9
|
-
# - include bh in the Gemfile
|
|
10
|
-
# - add `activate :bh` in the `config.rb` file
|
|
11
|
-
#
|
|
12
|
-
# The following class is registered as a Middleman extension, but you still
|
|
13
|
-
# need to activate it in the configuration file to make helpers available.
|
|
14
|
-
class MiddlemanExtension < Middleman::Extension
|
|
15
|
-
helpers do
|
|
16
|
-
include Bh::Helpers
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
Bh.framework = :middleman
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
::Middleman::Extensions.register(:bh, Bh::Extensions::MiddlemanExtension)
|