# HG changeset patch # User Thierry Florac # Date 1404289801 -7200 # Node ID dbed1ff1e070f2c3f515350a7e12ceb993d8e23a # Parent ed38f50045e775308b722c654617e361d002b08e Added tabs viewlets manager in header panel diff -r ed38f50045e7 -r dbed1ff1e070 src/ztfy/myams/viewlet/toplinks/__init__.py --- a/src/ztfy/myams/viewlet/toplinks/__init__.py Wed Jul 02 10:29:06 2014 +0200 +++ b/src/ztfy/myams/viewlet/toplinks/__init__.py Wed Jul 02 10:30:01 2014 +0200 @@ -9,22 +9,28 @@ # import Zope3 interfaces # import local interfaces -from ztfy.myams.viewlet.toplinks.interfaces import ITopLinksViewletManager, ITopLinksViewlet, ITopLinksMenu +from ztfy.myams.viewlet.toplinks.interfaces import ITopLinksViewletManager, ITopLinksViewlet, ITopLinksMenu, \ + ITopTabsViewlet, ITopTabsTab # import Zope3 packages from zope.i18n import translate from zope.interface import implements +from zope.viewlet.manager import WeightOrderedViewletManager # import local packages from ztfy.baseskin.viewlet import WeightViewletManagerBase, ViewletBase -class TopLinksViewletManager(WeightViewletManagerBase): +class TopLinksViewletManager(WeightOrderedViewletManager): """Top links viewlet manager""" implements(ITopLinksViewletManager) +# +# Top links viewlet +# + class TopLinksViewlet(WeightViewletManagerBase, ViewletBase): """Top links viewlet""" @@ -70,3 +76,50 @@ if self.click_handler: data.update({'data-ams-click-handler': self.click_handler}) return ' '.join('%s=%s' % item for item in data.iteritems()) + + +# +# Top tabs viewlet +# + +class TopTabsViewlet(WeightViewletManagerBase, ViewletBase): + """Top tabs viewlet""" + + implements(ITopTabsViewlet) + + label = u"Label:" + css_class = u'top-tabs' + + def __init__(self, context, request, view, manager=None): + WeightViewletManagerBase.__init__(self, context, request, view) + ViewletBase.__init__(self, context, request, view, manager) + + def update(self): + WeightViewletManagerBase.update(self) + + +class TopTabsTab(ViewletBase): + """Top tabs tab""" + + implements(ITopTabsTab) + + css_class = u"" + label = u"Tab label" + click_handler = None + url = u"#" + data = {'data-toggle': 'tab'} + + def render(self): + label = translate(self.label, context=self.request) + return u'''
  • + %s +
  • ''' % (self.css_class, + self.url, + self.getDataAttributes(), + unicode(label, 'utf-8') if isinstance(label, str) else label) + + def getDataAttributes(self): + data = self.data.copy() + if self.click_handler: + data.update({'data-ams-click-handler': self.click_handler}) + return ' '.join('%s=%s' % item for item in data.iteritems()) diff -r ed38f50045e7 -r dbed1ff1e070 src/ztfy/myams/viewlet/toplinks/configure.zcml --- a/src/ztfy/myams/viewlet/toplinks/configure.zcml Wed Jul 02 10:29:06 2014 +0200 +++ b/src/ztfy/myams/viewlet/toplinks/configure.zcml Wed Jul 02 10:30:01 2014 +0200 @@ -11,7 +11,12 @@ + + diff -r ed38f50045e7 -r dbed1ff1e070 src/ztfy/myams/viewlet/toplinks/interfaces.py --- a/src/ztfy/myams/viewlet/toplinks/interfaces.py Wed Jul 02 10:29:06 2014 +0200 +++ b/src/ztfy/myams/viewlet/toplinks/interfaces.py Wed Jul 02 10:30:01 2014 +0200 @@ -23,6 +23,10 @@ """Top links viewlet manager interface""" +# +# Top dropdown menus viewlet +# + class ITopLinksMenu(IViewlet): """Top link menu""" @@ -51,3 +55,35 @@ viewlets = List(title=_("Top links menus"), value_type=Object(schema=ITopLinksMenu)) + + +# +# Top tabs viewlet +# + +class ITopTabsTab(IViewlet): + """Top tabs tab""" + + css_class = TextLine(title=_("Tab CSS class"), + required=False) + + label = TextLine(title=_("Tab label")) + + click_handler = TextLine(title=_("Tab click handler")) + + url = TextLine(title=_("Tab link location")) + + data = Dict(title=_("Tab data attributes"), + key_type=TextLine(), + value_type=TextLine()) + + +class ITopTabsViewlet(IViewlet): + """Top tabs viewlet""" + + label = TextLine(title=_("Main label")) + + css_class = TextLine(title=_("Main CSS class")) + + viewlets = List(title=_("Top tabs items"), + value_type=Object(schema=ITopTabsTab)) diff -r ed38f50045e7 -r dbed1ff1e070 src/ztfy/myams/viewlet/toplinks/toplinks.pt --- a/src/ztfy/myams/viewlet/toplinks/toplinks.pt Wed Jul 02 10:29:06 2014 +0200 +++ b/src/ztfy/myams/viewlet/toplinks/toplinks.pt Wed Jul 02 10:30:01 2014 +0200 @@ -1,15 +1,13 @@ - -
    - Label: - - Dropdown label - - - -
    -
    +
    + Label: + + Dropdown label + + + +
    diff -r ed38f50045e7 -r dbed1ff1e070 src/ztfy/myams/viewlet/toplinks/toptabs.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ztfy/myams/viewlet/toplinks/toptabs.pt Wed Jul 02 10:30:01 2014 +0200 @@ -0,0 +1,8 @@ +
    + Label: + +