bootstrap_help 0.0.24 → 0.0.25
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 +4 -4
- data/README.md +16 -0
- data/lib/bootstrap_help/button_helpers.rb +15 -2
- data/lib/bootstrap_help/railtie.rb +1 -0
- data/lib/bootstrap_help/version.rb +1 -1
- data/lib/bootstrap_help.rb +1 -0
- data/spec/bootstrap_helper/button_helper_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c41d4737f95ad4021d359cab30fc681d16aafb8
|
4
|
+
data.tar.gz: 67f4e360dcb4512dcdb47535772f54ea8a4924a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43d622224a3cd5007de397778bdda8395e9a689f7d14e6ecf4a75a4731e238805e3bd86c2efce4076f9f0d6dfc9aaa5971df438fbbe54f4ec238028e1778755d
|
7
|
+
data.tar.gz: 97ca13598de23fb34aef8482c78ddb8960320cc906fbdfc509c761a97a281cf1d52ce576f78614b1d34382256cdf9d61415051dc6b6b41be504948eec12107d6
|
data/README.md
CHANGED
@@ -46,6 +46,22 @@ The Table Helper helps you quickly build Bootstrap tables with collections of in
|
|
46
46
|
= column 'Type of Apple', :type
|
47
47
|
```
|
48
48
|
|
49
|
+
### Button Helper
|
50
|
+
|
51
|
+
The button helper renders buttons with the proper Bootstrap markup. You can optionally add icons from the Bootstrap library that are listed [here](http://getbootstrap.com/2.3.2/base-css.html#icons "Bootstrap Icons")
|
52
|
+
|
53
|
+
```haml
|
54
|
+
= button_to "New Store", new_store_path
|
55
|
+
= button_to "Edit Store", edit_store_path(@store), icon: "edit"
|
56
|
+
```
|
57
|
+
|
58
|
+
```haml
|
59
|
+
= button_toolbar do
|
60
|
+
= button "zoom-in", store
|
61
|
+
= button "edit", edit_store_path(@store)
|
62
|
+
= button "remove-sign", store, method: :delete
|
63
|
+
```
|
64
|
+
|
49
65
|
## Contributing
|
50
66
|
|
51
67
|
1. Fork it
|
@@ -4,6 +4,7 @@ module BootstrapHelp
|
|
4
4
|
include ActionView::Helpers::TextHelper
|
5
5
|
include ActionView::Helpers::UrlHelper
|
6
6
|
include ActionView::Context
|
7
|
+
include BootstrapHelp::OptionHelpers
|
7
8
|
|
8
9
|
def button_toolbar(&block)
|
9
10
|
@buttons = []
|
@@ -11,7 +12,7 @@ module BootstrapHelp
|
|
11
12
|
content_tag :div, class: "btn-toolbar" do
|
12
13
|
content_tag :div, class: "btn-group" do
|
13
14
|
@buttons.each do |button|
|
14
|
-
concat(
|
15
|
+
concat(draw_icon_button(*button))
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -22,9 +23,21 @@ module BootstrapHelp
|
|
22
23
|
nil
|
23
24
|
end
|
24
25
|
|
26
|
+
def button_to(name=nil, url=nil, options={})
|
27
|
+
icon_suffix = options[:icon]
|
28
|
+
options.delete_if { |k, v| k == :icon }
|
29
|
+
button_options = append_css_class("btn btn-primary", options)
|
30
|
+
link_to url, button_options do
|
31
|
+
if icon_suffix.present?
|
32
|
+
concat(content_tag :i, nil, class: "icon-#{icon_suffix}")
|
33
|
+
end
|
34
|
+
concat(name)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
25
38
|
private
|
26
39
|
|
27
|
-
def
|
40
|
+
def draw_icon_button(*args)
|
28
41
|
icon_suffix = args.first
|
29
42
|
options = args[1] || {}
|
30
43
|
html_options = args[2] || {}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module BootstrapHelp
|
2
2
|
class Railtie < Rails::Railtie
|
3
3
|
initializer "bootstrap_help.nav_helpers" do
|
4
|
+
ActionView::Base.send :include, OptionHelpers
|
4
5
|
ActionView::Base.send :include, ButtonHelpers
|
5
6
|
ActionView::Base.send :include, NavHelpers
|
6
7
|
ActionView::Base.send :include, TableHelpers
|
data/lib/bootstrap_help.rb
CHANGED
@@ -2,6 +2,7 @@ require 'rails'
|
|
2
2
|
require 'action_view'
|
3
3
|
require 'bootstrap_help/railtie'
|
4
4
|
require "bootstrap_help/version"
|
5
|
+
require 'bootstrap_help/option_helpers'
|
5
6
|
require 'bootstrap_help/button_helpers'
|
6
7
|
require 'bootstrap_help/nav_helpers'
|
7
8
|
require 'bootstrap_help/table_helpers'
|
@@ -8,6 +8,8 @@ describe BootstrapHelp::ButtonHelpers do
|
|
8
8
|
HelpersClass.new
|
9
9
|
end
|
10
10
|
|
11
|
+
let(:options_hash) {{ class: "test" }}
|
12
|
+
|
11
13
|
describe '#table_for' do
|
12
14
|
it 'returns a bootstrap table for a given collection' do
|
13
15
|
expected_result = "<div class=\"btn-toolbar\"><div class=\"btn-group\"><a class=\"btn\" href=\"/test\"><i class=\"icon-edit\"></i></a><a class=\"btn\" href=\"/test-again\"><i class=\"icon-new\"></i></a><a class=\"btn\" data-method=\"delete\" href=\"/test-again\" rel=\"nofollow\"><i class=\"icon-new\"></i></a></div></div>"
|
@@ -21,4 +23,16 @@ describe BootstrapHelp::ButtonHelpers do
|
|
21
23
|
expect(helpers.button_toolbar(&block)).to eq(expected_result)
|
22
24
|
end
|
23
25
|
end
|
26
|
+
|
27
|
+
describe '#button_to' do
|
28
|
+
it "returns a primary button" do
|
29
|
+
expect(helpers.button_to('New Store', '#')).to eq("<a class=\"btn btn-primary\" href=\"#\">New Store</a>")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns a primary button with an icon when specified" do
|
33
|
+
expected_result = "<a class=\"btn btn-primary\" href=\"#\"><i class=\"icon-edit\"></i>New Store</a>"
|
34
|
+
expect(helpers.button_to('New Store', '#', icon: "edit")).
|
35
|
+
to eq(expected_result)
|
36
|
+
end
|
37
|
+
end
|
24
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap_help
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Klina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|