Class: LogicalTabs::TabPane
- Inherits:
-
Object
- Object
- LogicalTabs::TabPane
- Defined in:
- lib/logical_tabs/tab_pane.rb
Overview
This contains the info for a single tab and pane
Instance Attribute Summary collapse
-
#base_id ⇒ Object
Returns the value of attribute base_id.
-
#content ⇒ Object
Returns the value of attribute content.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pane_content ⇒ Object
Returns the value of attribute pane_content.
-
#tab_text ⇒ Object
Returns the value of attribute tab_text.
-
#tabbed_panel ⇒ Object
Returns the value of attribute tabbed_panel.
Instance Method Summary collapse
-
#composite_id ⇒ Object
generates an ID for this tab_pane that includes the base_id of the containing tabbed_panel and the base_id of this tab_pane.
-
#initialize(tabbed_panel, name, options = {}) ⇒ TabPane
constructor
tabbed_panel must be an instance of TabbedPanel.
- #render_header(selected = false) ⇒ Object
-
#render_pane(selected = false) ⇒ Object
Generates HTML output for the panel Pass “true” to set this as the selected/visible panel.
-
#render_tab(selected = false) ⇒ Object
Generates output for the tab.
- #tab_link ⇒ Object
Constructor Details
#initialize(tabbed_panel, name, options = {}) ⇒ TabPane
tabbed_panel must be an instance of TabbedPanel
Name is required, is used as the primary reference to this tab
Other options:
:base_id The string used as the beginning of the ID for CSS
IDs for the tab and pane. :base_id => 'foo' will
generate a tab with ID 'foo_tab' and a panel with ID
'foo_panel'. Defaults to name.downcase
:tab_text The text to display in the tab. Defaults to name.
:content The content for the panel itself, in HTML
22 23 24 25 26 27 28 |
# File 'lib/logical_tabs/tab_pane.rb', line 22 def initialize(tabbed_panel, name, = {}) @tabbed_panel = tabbed_panel @name = name @base_id = [:base_id] || name.underscore.gsub(/\s+/,'_') @tab_text = [:tab_text] || name @content = [:content] || '' end |
Instance Attribute Details
#base_id ⇒ Object
Returns the value of attribute base_id.
6 7 8 |
# File 'lib/logical_tabs/tab_pane.rb', line 6 def base_id @base_id end |
#content ⇒ Object
Returns the value of attribute content.
6 7 8 |
# File 'lib/logical_tabs/tab_pane.rb', line 6 def content @content end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/logical_tabs/tab_pane.rb', line 6 def name @name end |
#pane_content ⇒ Object
Returns the value of attribute pane_content.
6 7 8 |
# File 'lib/logical_tabs/tab_pane.rb', line 6 def pane_content @pane_content end |
#tab_text ⇒ Object
Returns the value of attribute tab_text.
6 7 8 |
# File 'lib/logical_tabs/tab_pane.rb', line 6 def tab_text @tab_text end |
#tabbed_panel ⇒ Object
Returns the value of attribute tabbed_panel.
6 7 8 |
# File 'lib/logical_tabs/tab_pane.rb', line 6 def tabbed_panel @tabbed_panel end |
Instance Method Details
#composite_id ⇒ Object
generates an ID for this tab_pane that includes the base_id of the containing tabbed_panel and the base_id of this tab_pane.
54 55 56 |
# File 'lib/logical_tabs/tab_pane.rb', line 54 def composite_id (@tabbed_panel.base_id + "_tp_" + @base_id).html_safe end |
#render_header(selected = false) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/logical_tabs/tab_pane.rb', line 40 def render_header(selected = false) v.content_tag(:h3, @tab_text, :class => ("pane_print_header ").html_safe ).html_safe end |
#render_pane(selected = false) ⇒ Object
Generates HTML output for the panel Pass “true” to set this as the selected/visible panel
60 61 62 63 64 65 66 |
# File 'lib/logical_tabs/tab_pane.rb', line 60 def render_pane(selected = false) v.content_tag(:div, render_header + @content, :id => (composite_id + "_pane").html_safe, :class => "pane " + (selected ? "pane_selected" : "pane_unselected") ).html_safe end |
#render_tab(selected = false) ⇒ Object
Generates output for the tab. Pass “true” to set this as the selected tab.
32 33 34 35 36 37 38 |
# File 'lib/logical_tabs/tab_pane.rb', line 32 def render_tab(selected = false) v.content_tag(:li, tab_link, :id => (composite_id + "_tab").html_safe, :class => ("tab " + (selected ? "tab_selected" : "tab_unselected")).html_safe ).html_safe end |
#tab_link ⇒ Object
48 49 50 |
# File 'lib/logical_tabs/tab_pane.rb', line 48 def tab_link v.content_tag(:a, @tab_text, :href => '#', :class => 'tab_link' ).html_safe end |