Permalink
Browse files

Allow configuring classes on generated <ul> tags

  • Loading branch information...
ffmike committed Feb 7, 2012
1 parent d861622 commit f68b658022b50b2cbf05a790a030f7f70f2f8f11
Showing with 14 additions and 8 deletions.
  1. +7 −1 lib/tabulous/options.rb
  2. +7 −7 lib/tabulous/tabulous.rb
View
@@ -18,7 +18,7 @@ def initialize
@inactive_text_color = '#888'
end
end
-
+
mattr_accessor :always_render_subtabs
@@always_render_subtabs = false
@@ -34,6 +34,12 @@ def initialize
mattr_accessor :html5
@@html5 = false
+ mattr_accessor :tab_list_class
+ @@tab_list_class = nil
+
+ mattr_accessor :subtab_list_class
+ @@subtab_list_class = nil
+
def self.raise_error_if_no_tab_found=(value)
msg = "DEPRECATION WARNING: Tabulous's config.raise_error_if_no_tab_found "
msg << "has been replaced by config.when_action_has_no_tab. "
View
@@ -3,7 +3,7 @@ module Tabulous
def self.setup
yield self
end
-
+
def self.tabs(&block)
@@tabs_block = block
end
@@ -20,7 +20,7 @@ def self.render_tabs(view)
active_tab = active_tab(view)
active_tab_name = (active_tab ? active_tab.name : nil);
html << (@@html5 ? '<nav id="tabs">' : '<div id="tabs">')
- html << '<ul>'
+ html << (@@tab_list_class ? '<ul class="' + @@tab_list_class + '">' : '<ul>')
for tab in main_tabs
next if !tab.visible?(view)
html << render_tab(:text => tab.text(view),
@@ -32,7 +32,7 @@ def self.render_tabs(view)
html << (@@html5 ? '</nav>' : '</div>')
view.raw(html)
end
-
+
def self.render_subtabs(view)
initialize_tabs(view)
return if !tab_defined?(view) && @@when_action_has_no_tab == :do_not_render
@@ -41,7 +41,7 @@ def self.render_subtabs(view)
tab = active_tab(view)
html = ''
html << (@@html5 ? '<nav id="subtabs">' : '<div id="subtabs">')
- html << '<ul>'
+ html << (@@subtab_list_class ? '<ul class="' + @@subtab_list_class + '">' : '<ul>')
if tab.nil?
subtabs = []
else
@@ -103,7 +103,7 @@ def self.tabs=(ary)
@@tabs << tab
end
end
-
+
def self.actions=(ary)
@@actions = {}
ary.each do |a|
@@ -120,11 +120,11 @@ def self.actions=(ary)
@@actions[controller][action] << tab
end
end
-
+
def self.main_tabs
@@tabs.select { |t| !t.subtab? }
end
-
+
def self.active_tab(view)
controller = view.controller_name.to_sym
action = view.action_name.to_sym

0 comments on commit f68b658

Please sign in to comment.