Class: ActiveAdmin::Views::TabsRenderer
- Defined in:
- lib/active_admin/views/tabs_renderer.rb
Overview
Renders out a horizontal list of tabs.
Constant Summary
Constants included from Arbre::HTML
Arbre::HTML::AUTO_BUILD_ELEMENTS, Arbre::HTML::HTML5_ELEMENTS
Instance Attribute Summary
Attributes inherited from Renderer
Instance Method Summary collapse
-
#current?(menu_item) ⇒ Boolean
protected
Returns true if the menu item name is @current_tab.
- #default_options ⇒ Object protected
- #render_item(item) ⇒ Object protected
- #render_menu(menu) ⇒ Object protected
- #render_nested_menu(item) ⇒ Object protected
-
#to_html(menu, options = {}) ⇒ Object
Pass in an ActiveAdmin::Menu and it will display the first level of navigation as a horizontal list of tabs.
Methods inherited from Renderer
#call_method_or_proc_on, #haml, #initialize, #method_missing, #set_ivar_on_view, #to_s
Methods included from Arbre::HTML
#current_dom_context, #helpers, #method_missing
Methods included from ActiveAdmin::ViewHelpers::RendererHelper
Constructor Details
This class inherits a constructor from ActiveAdmin::Renderer
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ActiveAdmin::Renderer
Instance Method Details
#current?(menu_item) ⇒ Boolean (protected)
Returns true if the menu item name is @current_tab
47 48 49 |
# File 'lib/active_admin/views/tabs_renderer.rb', line 47 def current?() @current_tab.split("/").include?(.name) unless @current_tab.blank? end |
#default_options ⇒ Object (protected)
51 52 53 |
# File 'lib/active_admin/views/tabs_renderer.rb', line 51 def { :id => "tabs" } end |
#render_item(item) ⇒ Object (protected)
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/active_admin/views/tabs_renderer.rb', line 24 def render_item(item) if !call_method_or_proc_on(self, item.display_if_block) return elsif (!item.url or item.url == '#') and item.children.any? and (item.children.detect {|child| call_method_or_proc_on(self, child.display_if_block)}).nil? return end content_tag :li, :id => item.dom_id, :class => [("current" if current?(item)), ("has_nested" unless item.children.blank?)].compact.join(" ") do unless item.children.blank? link_to(item.name, item.url || "#") + (item) else link_to item.name, item.url end end end |
#render_menu(menu) ⇒ Object (protected)
16 17 18 19 20 21 22 |
# File 'lib/active_admin/views/tabs_renderer.rb', line 16 def () content_tag :ul, :id => [:id] do .items.collect do |item| render_item(item) end.join.html_safe end end |
#render_nested_menu(item) ⇒ Object (protected)
40 41 42 43 44 |
# File 'lib/active_admin/views/tabs_renderer.rb', line 40 def (item) content_tag :ul do item.children.collect {|child| render_item(child)}.join.html_safe end end |
#to_html(menu, options = {}) ⇒ Object
Pass in an ActiveAdmin::Menu and it will display the first level of navigation as a horizontal list of tabs
9 10 11 12 |
# File 'lib/active_admin/views/tabs_renderer.rb', line 9 def to_html(, = {}) = .merge() () end |