bootstrap_builders 0.0.7 → 0.0.8
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 +14 -0
- data/app/helpers/bootstrap_builders/application_helper.rb +9 -2
- data/lib/bootstrap_builders.rb +1 -0
- data/lib/bootstrap_builders/arguments_parser.rb +35 -0
- data/lib/bootstrap_builders/button.rb +1 -1
- data/lib/bootstrap_builders/class_attribute_handler.rb +8 -0
- data/lib/bootstrap_builders/tabs.rb +19 -1
- data/lib/bootstrap_builders/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f43a631bcbdf0f1260acd838942e89370548386
|
4
|
+
data.tar.gz: 5e31aab0381b04f8d53d6f637eeef0b8745c7077
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81ab0ea91a7288126daf96766d93efcf31483c9c4f6a00186c52749c01f0366ec3c59b6ea89568d4116a57a675b63254460ac3051e16310f7290d0b840975d42
|
7
|
+
data.tar.gz: f06b0c4e58863482c73967a16925f02a14a1f73b1c51f0b01e5d6b52b9c9b45349678db6515f8c79f88d49cdcd0c1997d68d6aecf6a0f79ddd13f47e44786358
|
data/README.md
CHANGED
@@ -83,6 +83,20 @@ The classes "bb-table" and "table" are always added.
|
|
83
83
|
= bb_btn "/url", "My label", :block, :lg, confirm: true
|
84
84
|
```
|
85
85
|
|
86
|
+
### Tabs
|
87
|
+
|
88
|
+
```haml
|
89
|
+
= bb_tabs do |tabs|
|
90
|
+
= tabs.tab "Title" do
|
91
|
+
Content of tab
|
92
|
+
```
|
93
|
+
|
94
|
+
```haml
|
95
|
+
= bb_tabs :pills, :stacked do |tabs|
|
96
|
+
= tabs.tab "Title", "id-of-content-container" do
|
97
|
+
Content of tab
|
98
|
+
```
|
99
|
+
|
86
100
|
## Contributing to bootstrap_builders
|
87
101
|
|
88
102
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
@@ -49,6 +49,7 @@ module BootstrapBuilders::ApplicationHelper
|
|
49
49
|
args[:data][:confirm] ||= t("are_you_sure")
|
50
50
|
|
51
51
|
button = BootstrapBuilders::Button.new(args.merge(icon: "remove", context: self, can_type: :destroy, method: :delete))
|
52
|
+
button.classes.remove(["btn-default"])
|
52
53
|
button.classes.add(["btn-danger", "bb-btn", "bb-btn-destroy"])
|
53
54
|
button.classes.add("bb-btn-destroy-#{button.can_model_class.name.tableize.singularize}") if button.can_model_class
|
54
55
|
button.classes.add("bb-btn-destroy-#{button.can_model_class.name.tableize.singularize}-#{button.can_model.id}") if button.can_model
|
@@ -107,8 +108,14 @@ module BootstrapBuilders::ApplicationHelper
|
|
107
108
|
table.html
|
108
109
|
end
|
109
110
|
|
110
|
-
def bb_tabs(args
|
111
|
-
|
111
|
+
def bb_tabs(*args)
|
112
|
+
args = BootstrapBuilders::ArgumentsParser.new(
|
113
|
+
arguments: args,
|
114
|
+
argument_hash_default: {context: self},
|
115
|
+
short_true_arguments: [:justified, :pills, :stacked]
|
116
|
+
).arguments
|
117
|
+
|
118
|
+
tabs = BootstrapBuilders::Tabs.new(*args)
|
112
119
|
yield tabs
|
113
120
|
tabs.to_html
|
114
121
|
end
|
data/lib/bootstrap_builders.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
class BootstrapBuilders::ArgumentsParser
|
2
|
+
attr_reader :arguments
|
3
|
+
|
4
|
+
def initialize(args)
|
5
|
+
@arguments = args.fetch(:arguments)
|
6
|
+
|
7
|
+
if args[:argument_hash_default]
|
8
|
+
@argument_hash = args.fetch(:argument_hash_default)
|
9
|
+
else
|
10
|
+
@argument_hash = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
if @arguments.last.is_a?(Hash)
|
14
|
+
@argument_hash = @argument_hash.merge(@arguments.pop)
|
15
|
+
end
|
16
|
+
|
17
|
+
@arguments << @argument_hash
|
18
|
+
|
19
|
+
@short_true_arguments = args[:short_true_arguments]
|
20
|
+
parse_short_true_arguments if @short_true_arguments
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def parse_short_true_arguments
|
26
|
+
@arguments.delete_if do |argument|
|
27
|
+
if @short_true_arguments.include?(argument)
|
28
|
+
@argument_hash[argument] = true
|
29
|
+
true
|
30
|
+
else
|
31
|
+
false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -17,7 +17,7 @@ class BootstrapBuilders::Button
|
|
17
17
|
|
18
18
|
real_args[:label] ||= args.shift if args.first.is_a?(String)
|
19
19
|
|
20
|
-
pass_args = [:block, :lg, :md, :sm, :xs]
|
20
|
+
pass_args = [:block, :confirm, :lg, :md, :mini, :sm, :xs]
|
21
21
|
args.each do |arg|
|
22
22
|
real_args[arg] = true if pass_args.include?(arg)
|
23
23
|
end
|
@@ -9,6 +9,14 @@ class BootstrapBuilders::ClassAttributeHandler
|
|
9
9
|
@classes += convert_to_array(class_argument)
|
10
10
|
end
|
11
11
|
|
12
|
+
def remove(class_argument)
|
13
|
+
if class_argument.is_a?(Array)
|
14
|
+
@classes -= class_argument
|
15
|
+
else
|
16
|
+
@classes.delete(class_argument)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
12
20
|
def include?(attr_class)
|
13
21
|
@classes.include?(attr_class)
|
14
22
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class BootstrapBuilders::Tabs
|
2
2
|
def initialize(args)
|
3
|
+
@args = args
|
3
4
|
@context = args.fetch(:context)
|
4
5
|
@tabs = []
|
5
6
|
end
|
@@ -19,7 +20,8 @@ class BootstrapBuilders::Tabs
|
|
19
20
|
|
20
21
|
def to_html
|
21
22
|
container = HtmlGen::Element.new(:div, inden: " ", classes: ["bb-tabs-container"])
|
22
|
-
ul = container.add_ele(:ul, classes:
|
23
|
+
ul = container.add_ele(:ul, classes: nav_classes)
|
24
|
+
container.add_ele(:div, classes: ["clearfix"])
|
23
25
|
|
24
26
|
@tabs.each do |tab|
|
25
27
|
li = ul.add_ele(:li)
|
@@ -38,4 +40,20 @@ class BootstrapBuilders::Tabs
|
|
38
40
|
|
39
41
|
container.html
|
40
42
|
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def nav_classes
|
47
|
+
classes = ["nav"]
|
48
|
+
classes << "nav-stacked" if @args[:stacked]
|
49
|
+
classes << "nav-justified" if @args[:justified]
|
50
|
+
|
51
|
+
if @args[:pills]
|
52
|
+
classes << "nav-pills"
|
53
|
+
else
|
54
|
+
classes << "nav-tabs"
|
55
|
+
end
|
56
|
+
|
57
|
+
classes
|
58
|
+
end
|
41
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap_builders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -238,6 +238,7 @@ files:
|
|
238
238
|
- config/routes.rb
|
239
239
|
- config/spring.rb
|
240
240
|
- lib/bootstrap_builders.rb
|
241
|
+
- lib/bootstrap_builders/arguments_parser.rb
|
241
242
|
- lib/bootstrap_builders/attribute_rows.rb
|
242
243
|
- lib/bootstrap_builders/button.rb
|
243
244
|
- lib/bootstrap_builders/class_attribute_handler.rb
|
@@ -271,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
272
|
version: '0'
|
272
273
|
requirements: []
|
273
274
|
rubyforge_project:
|
274
|
-
rubygems_version: 2.
|
275
|
+
rubygems_version: 2.4.0
|
275
276
|
signing_key:
|
276
277
|
specification_version: 4
|
277
278
|
summary: A library to generate Bootstrap HTML for Rails.
|