Module: BootstrapHelper

Defined in:
app/helpers/bootstrap_helper.rb

Instance Method Summary collapse

Instance Method Details

#add_button(path) ⇒ Object



19
20
21
# File 'app/helpers/bootstrap_helper.rb', line 19

def add_button(path)
  button path, "Add", "plus", :get, nil    
end

#bootstrap_form_for(name, *args, &block) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'app/helpers/bootstrap_helper.rb', line 27

def bootstrap_form_for(name, *args, &block)
  options = args.extract_options!
  form_output = form_for(name, *(args << options.deep_merge(:builder => BootstrapFormBuilder, :html => { :multipart => true}))) do |builder|
    output = capture(builder, &block)      
    render_form_errors(builder.object) + ("div", output, :class => "row col-md-5")      
  end

  ("div", form_output, :class => "row col-md-12")
end

#button(path, text, icon, method = :get, size = :sm, data = nil) ⇒ Object



3
4
5
# File 'app/helpers/bootstrap_helper.rb', line 3

def button(path, text, icon, method = :get, size = :sm, data = nil)
  link_to raw("<span class='glyphicon glyphicon-#{icon}'></span> #{text}"), path, :class => "btn btn-default btn-#{size}", :method => method, :data => data  
end

#delete_button(path, text = "Delete") ⇒ Object



11
12
13
# File 'app/helpers/bootstrap_helper.rb', line 11

def delete_button(path, text = "Delete")
  button path, text, "trash", :delete, :sm, { confirm: "Are you sure?" }
end

#edit_button(path) ⇒ Object



15
16
17
# File 'app/helpers/bootstrap_helper.rb', line 15

def edit_button(path)
  button path, "Edit", "pencil"
end

#horizontal_bootstrap_form_for(name, *args, &block) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'app/helpers/bootstrap_helper.rb', line 38

def horizontal_bootstrap_form_for(name, *args, &block)
  options = args.extract_options!
  form_output = form_for(name, *(args << options.deep_merge(:builder => HorizontalBootstrapFormBuilder, :html => { :multipart => true, :class => "form-horizontal"}))) do |builder|
    output = capture(builder, &block)      
    render_form_errors(builder.object) + ("div", output, :class => "row col-md-12")      
  end

  ("div", form_output, :class => "row col-md-8")
end

#red_delete_button(path, text) ⇒ Object



7
8
9
# File 'app/helpers/bootstrap_helper.rb', line 7

def red_delete_button(path, text)
  link_to raw("<span class='glyphicon glyphicon-trash'></span> #{text}"), path, :class => "btn btn-danger", :method => :delete, :data => { confirm: "Are you sure?" }  
end

#refresh_button(path) ⇒ Object



23
24
25
# File 'app/helpers/bootstrap_helper.rb', line 23

def refresh_button(path)
  button path, "Refresh", "refresh", :post, nil        
end

#render_form_errors(object) ⇒ Object



48
49
50
# File 'app/helpers/bootstrap_helper.rb', line 48

def render_form_errors(object)
  render("layouts/form_errors", :target => object)
end