Module: TwBootStrapHelper::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



95
96
97
98
99
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 95

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



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}"    
  (: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 (: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



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, options={}
	bootstrap_label title, :default, options={}
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, options={}
	bootstrap_label title, :important, options={}
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, options={}
	bootstrap_label title, :notice, options={}
end

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



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

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

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



109
110
111
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 109

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

#lorem_ipsumObject



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

Bootstrap Row Grid



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

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



83
84
85
86
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 83

def pill(&block)
  content = capture(&block)
  (:div, (: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)
  (:li, content)
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 ================


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"
  
  (: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)
  (: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)
  (:thead, (: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="", options={})
  (:td, value, options)
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(options={}, &block)
  content = capture(&block)
  (:td, content, options)
end

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



189
190
191
# File 'lib/tw_bootstrap_helper/view_helper.rb', line 189

def table_th(value="", options={})
  (: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(options={}, &block)
  content = capture(&block)
  (: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)
  (:tr, content)
end