bootstrap_helper 3.2.2.0 → 3.2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/lib/bootstrap_helper/helper.rb +61 -43
- data/lib/bootstrap_helper/version.rb +1 -1
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -17,12 +17,12 @@ module BootstrapHelper
|
|
17
17
|
id_attribute = (@body_id)? " id=\"#{@body_id}-page\"" : ""
|
18
18
|
|
19
19
|
raw(%Q|<!--[if lt IE 7 ]>
|
20
|
-
<body class="#{class_attribute} ie6"><![endif]-->
|
21
|
-
<!--[if gte IE 7 ]>
|
22
|
-
<body class="#{class_attribute} ie"><![endif]-->
|
23
|
-
<!--[if !IE]>-->
|
24
|
-
<body#{id_attribute} class="#{class_attribute}">
|
25
|
-
<!--<![endif]-->|)
|
20
|
+
<body class="#{class_attribute} ie6"><![endif]-->
|
21
|
+
<!--[if gte IE 7 ]>
|
22
|
+
<body class="#{class_attribute} ie"><![endif]-->
|
23
|
+
<!--[if !IE]>-->
|
24
|
+
<body#{id_attribute} class="#{class_attribute}">
|
25
|
+
<!--<![endif]-->|)
|
26
26
|
|
27
27
|
end
|
28
28
|
|
@@ -42,6 +42,24 @@ module BootstrapHelper
|
|
42
42
|
sanitize( html, :tags => %w(table thead tbody tr td th ol ul li div span font img sup sub br hr a pre p h1 h2 h3 h4 h5 h6), :attributes => %w(style src href size color) )
|
43
43
|
end
|
44
44
|
|
45
|
+
|
46
|
+
def ibutton(text, path, options = {})
|
47
|
+
|
48
|
+
color_btn_class = ["btn-primary", "btn-danger", "btn-info" , "btn-warning", "btn-success", "btn-inverse"]
|
49
|
+
|
50
|
+
class_name = (options[:class].present?)? options[:class] : ""
|
51
|
+
icon_class = ""
|
52
|
+
|
53
|
+
if options[:iclass].present?
|
54
|
+
icon_class = options[:iclass]
|
55
|
+
icon_class << " icon-white" if !(color_btn_class & class_name.split(" ")).empty?
|
56
|
+
options.delete(:iclass)
|
57
|
+
end
|
58
|
+
link_to path, options do
|
59
|
+
content_tag(:i, "", :class => icon_class) + content_tag(:span, " #{text}" )
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
45
63
|
def render_table(rows, renderrers, table_options = {})
|
46
64
|
table_options = {
|
47
65
|
:has_header => true,
|
@@ -50,56 +68,56 @@ module BootstrapHelper
|
|
50
68
|
:id => nil,
|
51
69
|
:class_name => "auto",
|
52
70
|
:blank_message => "No results available."
|
53
|
-
|
71
|
+
}.merge(table_options)
|
54
72
|
|
55
|
-
|
73
|
+
table_tag_options = table_options[:id] ? { :id => table_options[:id], :class => table_options[:class_name] } : { :class => table_options[:class_name] }
|
56
74
|
|
57
|
-
|
75
|
+
table = TagNode.new('table', table_tag_options)
|
58
76
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
77
|
+
if !table_options[:caption].blank?
|
78
|
+
table << caption = TagNode.new(:caption)
|
79
|
+
caption << table_options[:caption]
|
80
|
+
end
|
63
81
|
|
64
|
-
|
65
|
-
|
66
|
-
|
82
|
+
if table_options[:has_header] == true
|
83
|
+
table << thead = TagNode.new(:thead)
|
84
|
+
thead << tr = TagNode.new(:tr, :class => 'odd')
|
67
85
|
|
68
|
-
|
69
|
-
|
70
|
-
|
86
|
+
renderrers.each do |renderrer|
|
87
|
+
tr << th = TagNode.new(:th)
|
88
|
+
th << renderrer[0]
|
89
|
+
end
|
71
90
|
end
|
72
|
-
end
|
73
91
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
92
|
+
table << tbody = TagNode.new('tbody')
|
93
|
+
row_info = {}
|
94
|
+
row_info[:total] = rows.length
|
95
|
+
rows.each_with_index do |row,i|
|
96
|
+
row_info[:current] = i
|
97
|
+
tbody << tr = TagNode.new('tr', :class => cycle("","odd") )
|
98
|
+
renderrers.each do |renderrer|
|
99
|
+
tr << td = TagNode.new('td')
|
100
|
+
|
101
|
+
if renderrer[1].class == Proc
|
102
|
+
if table_options[:has_row_info] == true
|
103
|
+
td << renderrer[1].call(row, row_info)
|
104
|
+
else
|
105
|
+
td << renderrer[1].call(row)
|
106
|
+
end
|
86
107
|
else
|
87
|
-
td << renderrer[1]
|
108
|
+
td << renderrer[1]
|
88
109
|
end
|
89
|
-
else
|
90
|
-
td << renderrer[1]
|
91
110
|
end
|
92
111
|
end
|
93
|
-
end
|
94
112
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
113
|
+
if rows.length <= 0 && table_options[:blank_message] != false
|
114
|
+
tbody << tr = TagNode.new('tr', :class => "no-record" )
|
115
|
+
tr << td = TagNode.new('td', :colspan => renderrers.length)
|
116
|
+
td << table_options[:blank_message]
|
117
|
+
end
|
100
118
|
|
101
|
-
|
102
|
-
|
119
|
+
return table.to_s
|
120
|
+
end
|
103
121
|
|
104
122
|
# .current will be added to current action, but if you want to add .current to another link, you can set @current = ['/other_link']
|
105
123
|
# TODO: hot about render_list( *args )
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.2.
|
4
|
+
version: 3.2.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|