"""
open/dulcinea/lib/ui/tabs.qpy
"""
from qp.fill.css import format_style_rule, TextStyle
from qp.fill.html import href
class Tab(object):
def __init__(self, name, title, index_url, content):
self.name = name
self.title = title
self.index_url = index_url
self.content = content
def get_name(self):
return self.name
def get_title(self):
return self.title
def get_index_url(self):
return self.index_url
def format_content:xml(self):
self.content
def format_tabs:xml(tabs, selected_name):
for tab in tabs:
if tab.get_name() == selected_name:
selected = tab
break
else:
selected = tabs[0]
'
'
'
'
for tab in tabs:
if tab is selected:
'- '
else:
'
- '
href(tab.get_index_url(), tab.get_title())
'
'
'
\n'
'
'
selected.format_content()
'
\n'
'
\n'
def format_tabs_css:str(
selected_text_style=TextStyle(
background='rgb(48,109,164)',
color='#fff',
anchor_style='color: white; text-decoration: none',
hover_style='text-decoration: underline',
visited_style='color: white',
link_style='color: white'),
unselected_text_style=TextStyle(
background='rgb(76, 149, 199)',
color='#fff',
anchor_style='color: white; text-decoration: none',
hover_style='text-decoration: underline',
visited_style='color: white',
link_style='color: white')
):
unselected_text_style.format_rules('div.tabs', ['ul.tabbox li'])
selected_text_style.format_rules('div.tabs', ['ul.tabbox li.selected'])
selected_text_style.format_rules('div.tabs', ['ul.tabbox li.selected',
'div.tabcontents'])
format_style_rule('div.tabs ul.tabbox', [],
'margin: 0',
'padding: 0',
'list-style: none')
format_style_rule('div.tabs ul.tabbox', ['li'],
'margin: 0 1ex 0 0',
'padding: 0.5ex 1em 0.5ex 1em',
'float:left')
format_style_rule('div.tabs div.tabcontents', [],
'clear:both'
)
# div.tabs ul gets weird margin on IE6 & IE7 without this
format_style_rule('body.IE6 div.tabs', [], 'border:thin solid rgb(239, 239, 239);')
format_style_rule('body.IE7 div.tabs', [], 'border:thin solid rgb(239, 239, 239);')