web/views/tabs.py
branchstable
changeset 7819 93d9a9c29bfb
parent 7742 1273c1bc0237
child 7820 2c73fc529a20
equal deleted inserted replaced
7818:be4a3e97090d 7819:93d9a9c29bfb
   138         w(u'<ul>')
   138         w(u'<ul>')
   139         active_tab_idx = None
   139         active_tab_idx = None
   140         for i, (tabid, domid, tabkwargs) in enumerate(tabs):
   140         for i, (tabid, domid, tabkwargs) in enumerate(tabs):
   141             w(u'<li>')
   141             w(u'<li>')
   142             w(u'<a href="#%s">' % domid)
   142             w(u'<a href="#%s">' % domid)
   143             w(u'<span onclick="%s">' % xml_escape(unicode(uilib.js.setTab(domid, self.cookie_name))))
       
   144             w(tabkwargs.pop('label', self._cw._(tabid)))
   143             w(tabkwargs.pop('label', self._cw._(tabid)))
   145             w(u'</span>')
       
   146             w(u'</a>')
   144             w(u'</a>')
   147             w(u'</li>')
   145             w(u'</li>')
   148             if domid == active_tab:
   146             if domid == active_tab:
   149                 active_tab_idx = i
   147                 active_tab_idx = i
   150         w(u'</ul>')
   148         w(u'</ul>')
   158         w(u'</div>')
   156         w(u'</div>')
   159         # call the setTab() JS function *after* each tab is generated
   157         # call the setTab() JS function *after* each tab is generated
   160         # because the callback binding needs to be done before
   158         # because the callback binding needs to be done before
   161         # XXX make work history: true
   159         # XXX make work history: true
   162         self._cw.add_onload(u"""
   160         self._cw.add_onload(u"""
   163   jQuery('#entity-tabs-%(eeid)s').tabs( { selected: %(tabindex)s });
   161   jQuery('#entity-tabs-%(eeid)s').tabs(
       
   162     { selected: %(tabindex)s,
       
   163       select: function(event, ui) {
       
   164         setTab(ui.panel.id, '%(cookiename)s');
       
   165       }
       
   166     });
   164   setTab('%(domid)s', '%(cookiename)s');
   167   setTab('%(domid)s', '%(cookiename)s');
   165 """ % {'tabindex'   : active_tab_idx,
   168 """ % {'tabindex'   : active_tab_idx,
   166        'domid'        : active_tab,
   169        'domid'        : active_tab,
   167        'eeid'       : (entity and entity.eid or uid),
   170        'eeid'       : (entity and entity.eid or uid),
   168        'cookiename' : self.cookie_name})
   171        'cookiename' : self.cookie_name})