|
# bootstrap button helpers, iconified |
|
# known to work with gem "bootstrap-sass", ">= 2.3.0.0" |
|
|
|
def iconified_link_to(icon, body, url, html_options = {}) |
|
# not a button, see below |
|
link_to url, html_options do |
|
"#{content_tag(:i, nil, :class => icon.to_s )} #{body}".html_safe |
|
end |
|
end |
|
|
|
def iconified_button_to(icon, body, url, html_options = {}) |
|
html_options[:class] = (html_options[:class] || "" ) + ' btn' #add default btn class to other classes |
|
iconified_link_to(icon, body, url, html_options).html_safe |
|
end |
|
|
|
def edit_button(url, html_options = {}) |
|
iconified_button_to('icon-pencil', "Edit", url, html_options) |
|
end |
|
|
|
def delete_button(url, html_options = {}) |
|
html_options[:class] = (html_options[:class] || "" ) + ' btn-danger' |
|
html_options[:method] = :delete |
|
html_options[:data] = { :confirm => 'Are you sure?' } |
|
iconified_button_to('icon-trash icon-white', "Delete", url, html_options) |
|
end |
|
|
|
def cancel_button(url = nil, html_options = {}) |
|
html_options[:class] = (html_options[:class] || "" ) + ' btn-warning' |
|
iconified_button_to('icon-remove icon-white', "Cancel", url || :back , html_options) |
|
end |