Module: Admin::LayoutHelper
- Defined in:
- app/helpers/amalgam/admin/layout_helper.rb
Instance Method Summary collapse
- #body_class ⇒ Object
- #controller_links ⇒ Object
- #drop_down(title, path = '#', options = {}, &block) ⇒ Object
- #dropdown_item(title, path = "#", options = {}) ⇒ Object
- #menu_item(title, path = "#", options = {}) ⇒ Object
Instance Method Details
#body_class ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'app/helpers/amalgam/admin/layout_helper.rb', line 21 def body_class return @cls if @cls @cls = [] @cls << "#{params[:controller]}_controller" @cls << [params[:action],params[:controller]]*'_' @cls << I18n.locale.to_s @cls << Rails.env @cls << @body_class if @body_class @cls = @cls.map(&:parameterize)*' ' end |
#controller_links ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/helpers/amalgam/admin/layout_helper.rb', line 32 def controller_links links = "" Amalgam..each do |name,actions| unless actions.first.is_a? Hash links += drop_down name.classify.constantize.model_name.human,'#', :controller => "amalgam/admin/#{name}" do dropdown = "" actions.each do |action| dropdown += dropdown_item(I18n.t("amalgam.admin.actions.#{action}"), amalgam.send("admin_#{name}_path")) if action == 'index' || action == :index dropdown += dropdown_item(I18n.t('amalgam.admin.actions.new'), amalgam.send("new_admin_#{name.singularize}_path")) if action == 'new' || action == :new dropdown += dropdown_item(I18n.t("amalgam.admin.actions.#{action}"), amalgam.send("#{action}_admin_#{name}_path")) if action != 'index' && action != :index && action != 'new' && action != :new end dropdown.html_safe end else links += I18n.t("amalgam.admin.menus.#{name}"), amalgam.send("admin_#{name}_path"), :controller => "amalgam/admin/#{actions.first[:controller]}" end end links.html_safe end |
#drop_down(title, path = '#', options = {}, &block) ⇒ Object
15 16 17 18 19 |
# File 'app/helpers/amalgam/admin/layout_helper.rb', line 15 def drop_down(title, path='#', ={}, &block) content_tag :li, :class => "dropdown #{is_active?(path,)}" do drop_down_link(title,path) + drop_down_list(&block) end end |
#dropdown_item(title, path = "#", options = {}) ⇒ Object
9 10 11 12 13 |
# File 'app/helpers/amalgam/admin/layout_helper.rb', line 9 def dropdown_item(title, path="#", ={}) content_tag(:li) do link_to(title, path,) end end |
#menu_item(title, path = "#", options = {}) ⇒ Object
3 4 5 6 7 |
# File 'app/helpers/amalgam/admin/layout_helper.rb', line 3 def (title, path="#", ={}) content_tag(:li, :class => is_active?(path,)) do link_to(title, path) end end |