Module: BootstrapHelper

Defined in:
lib/bootstrap2-rails/bootstrap_helper.rb

Instance Method Summary collapse

Instance Method Details

#display_toast_message(message, type) ⇒ Object

display a message using the JQuery Toast Message plugin types available: notice, success, warning an error



17
18
19
20
21
22
23
# File 'lib/bootstrap2-rails/bootstrap_helper.rb', line 17

def display_toast_message(message, type)
  return nil unless ['notice', 'success', 'warning', 'error'].include? type.to_s.downcase
  result = "<script>"
  result << "$().toastmessage('show#{type.to_s.capitalize}Toast', '#{message}');"
  result << "</script>"
  result.html_safe
end

#sort_icon(direction, column, table_column) ⇒ Object



9
10
11
12
13
# File 'lib/bootstrap2-rails/bootstrap_helper.rb', line 9

def sort_icon(direction, column, table_column)
  return nil if column != table_column    
  return (:i, nil, {class: 'icon-chevron-up', style: 'float: right'}) if direction == 'asc'
  return (:i, nil, {class: 'icon-chevron-down', style: 'float: right'}) if direction == 'desc'
end

#sortable(column, title = nil) ⇒ Object

returns a link to sort table columns



3
4
5
6
7
# File 'lib/bootstrap2-rails/bootstrap_helper.rb', line 3

def sortable(column, title = nil)
  title ||= column.titleize
  direction = params[:direction] == "asc" ? "desc" : "asc"
  link_to title, sort: column, direction: direction
end