Module: BootstrapButtonHelper

Defined in:
app/helpers/bootstrap_button_helper.rb

Overview

RAILS BOOTSTRAP ENGINE

Bootstrap Buttons

Copyright 2012-2013 Luiz Eduardo de Oliveira Fonseca, Agência Orangeweb Licensed under The MIT License opensource.org/licenses/MIT

Instance Method Summary collapse

Instance Method Details

#button_to_back(title, link, opts = {}) ⇒ Object

Alias para link_to_cancel



47
48
49
# File 'app/helpers/bootstrap_button_helper.rb', line 47

def button_to_back title, link, opts={}
	link_to_cancel title, link, opts
end

#button_to_cancel(title, link, opts = {}) ⇒ Object

Cria um link para voltar

<a href=“link”><i class=“icon-name”></i> title</a>



36
37
38
39
40
# File 'app/helpers/bootstrap_button_helper.rb', line 36

def button_to_cancel title, link, opts={}
	opts[:class] = "" if opts[:class].nil?
	opts[:class] << " btn "
	link_button_to title, link, opts
end

#button_to_delete(title, link, opts = {}) ⇒ Object

Cria um link para apagar registros

<a href=“link”><i class=“icon-name”></i> title</a>



73
74
75
76
77
78
79
# File 'app/helpers/bootstrap_button_helper.rb', line 73

def button_to_delete title, link, opts={}
	opts[:class] = "" if opts[:class].nil?
	opts[:class] << " btn-important "
	opts[:method] = :delete
	opts[:data] = { confirm: 'Tem certeza que deseja apagar este registro?' }  	
	link_button_to raw(icon(:trash) + " #{title}"), link, opts
end

#button_to_edit(title, link, opts = {}) ⇒ Object

Cria um button para editar registros

<a class=“btn btn-warning” href=“link”>title</a>



22
23
24
25
26
# File 'app/helpers/bootstrap_button_helper.rb', line 22

def button_to_edit title, link, opts={}
	opts[:class] = "" if opts[:class].nil?
	opts[:class] << " btn-warning"
	link_button_to raw(icon(:pencil) + " #{title}"), link, opts
end

#button_to_new(title, link, opts = {}) ⇒ Object

Cria um link para novos registros

<a href=“link”><i class=“icon-name”></i> title</a>



59
60
61
62
63
# File 'app/helpers/bootstrap_button_helper.rb', line 59

def button_to_new title, link, opts={}
	opts[:class] = "" if opts[:class].nil?
	opts[:class] << " btn-primary "
	link_button_to raw(icon(:plus) + " #{title}"), link, opts
end

Cria um link para novos registros

<a href=“link”><i class=“icon-name”></i> title</a>



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'app/helpers/bootstrap_button_helper.rb', line 89

def link_button_to title, link, opts={}
	opts[:class] = "" if opts[:class].nil?
	opts[:class] << " btn "
	
		unless opts[:small].nil? then
			opts[:class] += " btn-small "
			opts.delete(:small)
		end
		
		unless opts[:mini].nil? then
			opts[:class] += " btn-mini "
			opts.delete(:mini)
		end
		
		unless opts[:large].nil? then
			opts[:class] += " btn-large "
			opts.delete(:large)
		end
		
		unless opts[:block].nil? then
			opts[:class] += " btn-block "
			opts.delete(:block)
		end
		
	opts[:class].strip! 						
		
	link_to title, link, opts
end