Module: BootstrapHelper
- Defined in:
- app/helpers/bootstrap_helper.rb
Instance Method Summary collapse
- #add_button(path) ⇒ Object
- #bootstrap_form_for(name, *args, &block) ⇒ Object
- #button(path, text, icon, method = :get, size = :sm, data = nil) ⇒ Object
- #delete_button(path, text = "Delete") ⇒ Object
- #edit_button(path) ⇒ Object
- #horizontal_bootstrap_form_for(name, *args, &block) ⇒ Object
- #red_delete_button(path, text) ⇒ Object
- #refresh_button(path) ⇒ Object
- #render_form_errors(object) ⇒ Object
Instance Method Details
#add_button(path) ⇒ Object
19 20 21 |
# File 'app/helpers/bootstrap_helper.rb', line 19 def (path) 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) = args. form_output = form_for(name, *(args << .deep_merge(:builder => BootstrapFormBuilder, :html => { :multipart => true}))) do |builder| output = capture(builder, &block) render_form_errors(builder.object) + content_tag("div", output, :class => "row col-md-5") end content_tag("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 (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 (path, text = "Delete") 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 (path) 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) = args. form_output = form_for(name, *(args << .deep_merge(:builder => HorizontalBootstrapFormBuilder, :html => { :multipart => true, :class => "form-horizontal"}))) do |builder| output = capture(builder, &block) render_form_errors(builder.object) + content_tag("div", output, :class => "row col-md-12") end content_tag("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 (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 (path) 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 |