Module: TwBootStrapHelper::ViewHelper
- Defined in:
- lib/tw_bootstrap_helper/view_helper.rb
Overview
Extende os Helpers da Aplicação
Instance Method Summary collapse
- #bootstrap_label(title, type, options = {}) ⇒ Object
- #bootstrap_link_to(title, path, type, options = {}) ⇒ Object
- #cancel_link_to(title, path, options = {}) ⇒ Object
- #danger_link_to(title, path, options = {}) ⇒ Object
-
#default_link_to(title, path, options = {}) ⇒ Object
Default Options from Links with Bootstraper.
- #delete_link_to(title, path, options = {}) ⇒ Object
- #edit_link_to(title, path, options = {}) ⇒ Object
-
#grid_col(cols, center = true, &block) ⇒ Object
Bootstrap Col Grid.
-
#grid_row(&block) ⇒ Object
Bootstrap Row Grid.
- #info_link_to(title, path, options = {}) ⇒ Object
- #label_back(title = "<< Voltar") ⇒ Object
- #label_default(title, options = {}) ⇒ Object
- #label_details(title = "+ Detalhes") ⇒ Object
- #label_error(title = "Erro") ⇒ Object
- #label_important(title, options = {}) ⇒ Object
- #label_incomplete(title = "Incompleto") ⇒ Object
-
#label_new(title = "Novo") ⇒ Object
Commom Alias from Labels.
- #label_notice(title, options = {}) ⇒ Object
- #label_success(title, options = {}) ⇒ Object
- #label_warning(title, options = {}) ⇒ Object
- #lorem_ipsum ⇒ Object
-
#nav_icon(title, link) ⇒ Object
Bootstrap Row Grid.
- #new_link_to(title, path, options = {}) ⇒ Object
-
#pill(&block) ⇒ Object
Show a Pill Toolbar.
-
#pill_item(&block) ⇒ Object
Show a Pill Toolbar Item.
-
#pill_link_to(title, path, options = {}) ⇒ Object
Commom Alias from Links.
- #primary_link_to(title, path, options = {}) ⇒ Object
- #success_link_to(title, path, options = {}) ⇒ Object
-
#table(opts = {}, &block) ⇒ Object
HTML HELPERS ================.
- #table_body(&block) ⇒ Object
- #table_head(&block) ⇒ Object
- #table_td(value = "", options = {}) ⇒ Object
- #table_td_block(options = {}, &block) ⇒ Object
- #table_th(value = "", options = {}) ⇒ Object
- #table_th_block(options = {}, &block) ⇒ Object
- #table_tr(&block) ⇒ Object
Instance Method Details
#bootstrap_label(title, type, options = {}) ⇒ Object
95 96 97 98 99 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 95 def bootstrap_label title, type, ={} [:class] = "" unless .has_key?(:class) [:class].insert(0, " label " + type.to_s) raw content_tag :span, " #{title} ", end |
#bootstrap_link_to(title, path, type, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 15 def bootstrap_link_to title, path, type, ={} [:class] = "" unless .has_key?(:class) [:class].insert(0, " btn " + type.to_s) if .has_key?(:small) then if [:small] == true then [:class].insert(-1, " small ") end .delete(:small) end [:class].to_s.strip! link_to title, path, end |
#cancel_link_to(title, path, options = {}) ⇒ Object
68 69 70 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 68 def cancel_link_to title, path, ={} default_link_to title, path, end |
#danger_link_to(title, path, options = {}) ⇒ Object
54 55 56 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 54 def danger_link_to title, path, ={} bootstrap_link_to title, path, :danger, end |
#default_link_to(title, path, options = {}) ⇒ Object
Default Options from Links with Bootstraper
34 35 36 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 34 def default_link_to title, path, ={} bootstrap_link_to title, path, :default, end |
#delete_link_to(title, path, options = {}) ⇒ Object
76 77 78 79 80 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 76 def delete_link_to title, path, ={} [:confirm] = 'Tem certeza que deseja apagar este item?' [:method] = :delete danger_link_to title, path, end |
#edit_link_to(title, path, options = {}) ⇒ Object
72 73 74 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 72 def edit_link_to title, path, ={} info_link_to title, path, end |
#grid_col(cols, center = true, &block) ⇒ Object
Bootstrap Col Grid
154 155 156 157 158 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 154 def grid_col(cols, center=true,&block) content = capture(&block) cl = "span#{cols}" content_tag(:div, content, :class => cl) end |
#grid_row(&block) ⇒ Object
Bootstrap Row Grid
147 148 149 150 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 147 def grid_row(&block) content = capture(&block) raw content_tag(:div, content, :class => "grid row") end |
#info_link_to(title, path, options = {}) ⇒ Object
44 45 46 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 44 def info_link_to title, path, ={} bootstrap_link_to title, path, :info, end |
#label_back(title = "<< Voltar") ⇒ Object
139 140 141 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 139 def label_back title="<< Voltar" label_default title end |
#label_default(title, options = {}) ⇒ Object
101 102 103 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 101 def label_default title, ={} bootstrap_label title, :default, ={} end |
#label_details(title = "+ Detalhes") ⇒ Object
135 136 137 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 135 def label_details title="+ Detalhes" label_notice title end |
#label_error(title = "Erro") ⇒ Object
127 128 129 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 127 def label_error title="Erro" label_important title end |
#label_important(title, options = {}) ⇒ Object
113 114 115 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 113 def label_important title, ={} bootstrap_label title, :important, ={} end |
#label_incomplete(title = "Incompleto") ⇒ Object
131 132 133 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 131 def label_incomplete title="Incompleto" label_warning title end |
#label_new(title = "Novo") ⇒ Object
Commom Alias from Labels
123 124 125 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 123 def label_new title="Novo" label_success title end |
#label_notice(title, options = {}) ⇒ Object
117 118 119 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 117 def label_notice title, ={} bootstrap_label title, :notice, ={} end |
#label_success(title, options = {}) ⇒ Object
105 106 107 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 105 def label_success title, ={} bootstrap_label title, :success, ={} end |
#label_warning(title, options = {}) ⇒ Object
109 110 111 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 109 def label_warning title, ={} bootstrap_label title, :warning, ={} end |
#lorem_ipsum ⇒ Object
214 215 216 217 218 219 220 221 222 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 214 def lorem_ipsum <<-eos Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris fermentum tempor arcu in mollis. Aliquam erat volutpat. Sed malesuada lacinia nibh, eget posuere turpis accumsan vitae. Aliquam lacus massa, pellentesque auctor volutpat eu, luctus ac enim. Nullam venenatis tellus nec tortor dictum rutrum. Proin sed magna eu mauris posuere vulputate vel quis nunc. Donec at elit sapien, vitae mattis arcu. Maecenas sollicitudin auctor volutpat. Vivamus tincidunt interdum placerat. In mattis, metus vel pellentesque accumsan, neque nisi ornare lectus, et interdum lectus ipsum sed augue. Nullam sollicitudin placerat enim a lobortis. Curabitur id lorem turpis, sit amet euismod elit. eos end |
#nav_icon(title, link) ⇒ Object
Bootstrap Row Grid
162 163 164 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 162 def nav_icon(title, link) raw content_tag(:div, link + content_tag(:span, title), :class => "nav-icon-item corner h-margin v-margin") end |
#new_link_to(title, path, options = {}) ⇒ Object
64 65 66 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 64 def new_link_to title, path, ={} success_link_to title, path, end |
#pill(&block) ⇒ Object
Show a Pill Toolbar
83 84 85 86 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 83 def pill(&block) content = capture(&block) content_tag(:div, content_tag(:ul, content, :class => "pills")) end |
#pill_item(&block) ⇒ Object
Show a Pill Toolbar Item
89 90 91 92 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 89 def pill_item(&block) content = capture(&block) content_tag(:li, content) end |
#pill_link_to(title, path, options = {}) ⇒ Object
Commom Alias from Links
60 61 62 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 60 def pill_link_to title, path, ={} link_to title, path, end |
#primary_link_to(title, path, options = {}) ⇒ Object
39 40 41 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 39 def primary_link_to title, path, ={} bootstrap_link_to title, path, :primary, end |
#success_link_to(title, path, options = {}) ⇒ Object
49 50 51 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 49 def success_link_to title, path, ={} bootstrap_link_to title, path, :success, end |
#table(opts = {}, &block) ⇒ Object
HTML HELPERS ================
169 170 171 172 173 174 175 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 169 def table(opts={}, &block) content = capture(&block) opts[:class] = "zebra-striped" content_tag(:table, content, opts) end |
#table_body(&block) ⇒ Object
194 195 196 197 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 194 def table_body(&block) content = capture(&block) content_tag(:tbody, content) end |
#table_head(&block) ⇒ Object
178 179 180 181 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 178 def table_head(&block) content = capture(&block) content_tag(:thead, content_tag(:tr, content)) end |
#table_td(value = "", options = {}) ⇒ Object
210 211 212 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 210 def table_td(value="", ={}) content_tag(:td, value, ) end |
#table_td_block(options = {}, &block) ⇒ Object
205 206 207 208 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 205 def table_td_block(={}, &block) content = capture(&block) content_tag(:td, content, ) end |
#table_th(value = "", options = {}) ⇒ Object
189 190 191 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 189 def table_th(value="", ={}) content_tag(:th, value) end |
#table_th_block(options = {}, &block) ⇒ Object
184 185 186 187 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 184 def table_th_block(={}, &block) content = capture(&block) content_tag(:th, content) end |
#table_tr(&block) ⇒ Object
200 201 202 203 |
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 200 def table_tr(&block) content = capture(&block) content_tag(:tr, content) end |