Module: TwBootsrapHelper::ViewHelper

Defined in:
lib/tw_bootstrap_helper/view_helper.rb

Overview

Extende os Helpers da Aplicação

Instance Method Summary collapse

Instance Method Details

#bootstrap_label(title, type, options = {}) ⇒ Object



111
112
113
114
115
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 111

def bootstrap_label title, type, options={}
  options[:class] = "" unless options.has_key?(:class) 
  options[:class].insert(0, " label " + type.to_s)
  raw  :span, " #{title} ", options
end


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, options={}

  options[:class] = "" unless options.has_key?(:class) 
  options[:class].insert(0, " btn " + type.to_s)
	
	if options.has_key?(:small) then
  if options[:small] == true then
options[:class].insert(-1, " small ")
  end	
options.delete(:small)
	end
	
	options[:class].to_s.strip!
  link_to title, path, options
	
end


68
69
70
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 68

def cancel_link_to title, path, options={}
  default_link_to title, path, options
end


54
55
56
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 54

def danger_link_to title, path, options={}
  bootstrap_link_to title, path, :danger, options
end

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, options={}
  bootstrap_link_to title, path, :default, options
end


76
77
78
79
80
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 76

def delete_link_to title, path, options={}
  options[:confirm] = 'Tem certeza que deseja apagar este item?'
	options[:method] = :delete
  danger_link_to title, path, options
end


72
73
74
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 72

def edit_link_to title, path, options={} 
  info_link_to title, path, options
end

#grid_col(cols, center = true, &block) ⇒ Object

Bootstrap Col Grid



170
171
172
173
174
175
176
177
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 170

def grid_col(cols, center=true,&block)
  content = capture(&block)
  cl = "span#{cols} border corner h-padding opaque "
  
  cl += " center " if center
  
  (:div, content, :class => cl)
end

#grid_row(&block) ⇒ Object

Bootstrap Row Grid



163
164
165
166
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 163

def grid_row(&block)
  content = capture(&block)
  raw (:div, content, :class => "grid row") 
end


44
45
46
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 44

def info_link_to title, path, options={}
  bootstrap_link_to title, path, :info, options
end

#label_back(title = "<< Voltar") ⇒ Object



155
156
157
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 155

def label_back title="<< Voltar"
	label_default title
end

#label_default(title, options = {}) ⇒ Object



117
118
119
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 117

def label_default title, options={}
	bootstrap_label title, :default, options={}
end

#label_details(title = "+ Detalhes") ⇒ Object



151
152
153
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 151

def label_details title="+ Detalhes"
	label_notice title
end

#label_error(title = "Erro") ⇒ Object



143
144
145
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 143

def label_error title="Erro"
	label_important title
end

#label_important(title, options = {}) ⇒ Object



129
130
131
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 129

def label_important title, options={}
	bootstrap_label title, :important, options={}
end

#label_incomplete(title = "Incompleto") ⇒ Object



147
148
149
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 147

def label_incomplete title="Incompleto"
	label_warning title
end

#label_new(title = "Novo") ⇒ Object

Commom Alias from Labels



139
140
141
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 139

def label_new title="Novo"
	label_success title
end

#label_notice(title, options = {}) ⇒ Object



133
134
135
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 133

def label_notice title, options={}
	bootstrap_label title, :notice, options={}
end

#label_success(title, options = {}) ⇒ Object



121
122
123
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 121

def label_success title, options={}
	bootstrap_label title, :success, options={}
end

#label_warning(title, options = {}) ⇒ Object



125
126
127
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 125

def label_warning title, options={}
	bootstrap_label title, :warning, options={}
end

#lorem_ipsum_textObject



234
235
236
237
238
239
240
241
242
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 234

def lorem_ipsum_text
  <<-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

Bootstrap Row Grid



181
182
183
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 181

def nav_icon(title, link)
  raw (:div, link + (:span, title), :class => "nav-icon-item  corner h-margin v-margin") 
end


64
65
66
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 64

def new_link_to title, path, options={}
  success_link_to title, path, options
end

#pill(&block) ⇒ Object

Show a Pill Toolbar



99
100
101
102
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 99

def pill(&block)
  content = capture(&block)
  (:div, (:ul, content, :class => "pills border corner h-padding"))
end

#pill_item(&block) ⇒ Object

Show a Pill Toolbar Item



105
106
107
108
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 105

def pill_item(&block)
  content = capture(&block)
  (:li, content, :class => "pill-item")
end

Commom Alias from Links



60
61
62
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 60

def pill_link_to title, path, options={}
  link_to title, path, options
end


39
40
41
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 39

def primary_link_to title, path, options={}
  bootstrap_link_to title, path, :primary, options
end


49
50
51
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 49

def success_link_to title, path, options={}
  bootstrap_link_to title, path, :success, options
end

#table(opts = {}, &block) ⇒ Object

HTML HELPERS ================


188
189
190
191
192
193
194
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 188

def table(opts={}, &block)
  content = capture(&block)
  
  opts[:class] = "border zebra-striped corner"
  
  (:table, content, opts)
end

#table_body(&block) ⇒ Object



213
214
215
216
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 213

def table_body(&block)
  content = capture(&block)
  (:tbody, content)
end

#table_head(&block) ⇒ Object



197
198
199
200
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 197

def table_head(&block)
  content = capture(&block)
  (:thead, (:tr, content))
end

#table_td(value = "", options = {}) ⇒ Object



230
231
232
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 230

def table_td(value="", options={})
  (:td, value, options)
end

#table_td_block(options = {}, &block) ⇒ Object



225
226
227
228
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 225

def table_td_block(options={}, &block)
  content = capture(&block)
  (:td, content, options)
end

#table_th(value = "", options = {}) ⇒ Object



208
209
210
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 208

def table_th(value="", options={})
  (:th, value)
end

#table_th_block(options = {}, &block) ⇒ Object



203
204
205
206
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 203

def table_th_block(options={}, &block)
  content = capture(&block)
  (:th, content)
end

#table_tr(&block) ⇒ Object



219
220
221
222
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 219

def table_tr(&block)
  content = capture(&block)
  (:tr, content)
end

#toolbar(&block) ⇒ Object

Show a Toolbar



85
86
87
88
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 85

def toolbar(&block)
  content = capture(&block)
  (:div, (:ul, content), :class => "toolbar corner border gradient")
end

#toolbar_item(&block) ⇒ Object

Show a Toolbar



91
92
93
94
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 91

def toolbar_item(&block)
  content = capture(&block)
  (:li, content, :class => "toolbar-item")
end