web/views/tabs.py
changeset 2673 9e639925ca2f
parent 2123 3e1d2ab5f8c0
child 2674 ff6114c2c416
--- a/web/views/tabs.py	Thu Jun 18 21:01:55 2009 +0200
+++ b/web/views/tabs.py	Tue Aug 04 11:43:03 2009 +0200
@@ -109,8 +109,8 @@
         #if rql:
         #    self.req.execute(rql).get_entity(0,0).view(default, w=self.w)
         #    return
-        self.req.add_css('tabs-no-images.css')
-        self.req.add_js(('jquery.tools.min.js', 'cubicweb.htmlhelpers.js',
+        self.req.add_css('ui.tabs.css')
+        self.req.add_js(('ui.core.js', 'ui.tabs.js',
                          'cubicweb.ajax.js', 'cubicweb.tabs.js', 'cubicweb.lazy.js'))
         # prune tabs : not all are to be shown
         tabs = self.prune_tabs(tabs)
@@ -123,7 +123,7 @@
         else:
             uid = make_uid('tab')
             w(u'<div id="entity-tabs-%s">' % uid)
-        w(u'<ul class="css-tabs" id="tabs-%s">' % entity.eid)
+        w(u'<ul>')
         for tab in tabs:
             w(u'<li>')
             w(u'<a href="#as-%s">' % tab)
@@ -134,25 +134,22 @@
             w(u'</li>')
         w(u'</ul>')
         w(u'</div>')
-        w(u'<div id="panes-%s">' % entity.eid)
         for tab in tabs:
-            w(u'<div>')
+            w(u'<div id="as-%s">' % tab)
             if entity:
                 self.lazyview(tab, eid=entity.eid)
             else:
                 self.lazyview(tab, static=True)
             w(u'</div>')
-        w(u'</div>')
         # call the set_tab() JS function *after* each tab is generated
         # because the callback binding needs to be done before
         self.req.html_headers.add_onload(u"""
-    jQuery(function() {
-      jQuery("#tabs-%(eeid)s").tabs("#panes-%(eeid)s > div", {initialIndex: %(tabindex)s});
-      set_tab('%(vid)s', '%(cookiename)s');
-    });""" % {'eeid' : entity.eid,
-              'vid'  : active_tab,
-              'cookiename' : self.cookie_name,
-              'tabindex' : tabs.index(active_tab)})
+   jQuery('#entity-tabs-%(eeid)s > ul').tabs( { selected: %(tabindex)s });
+   set_tab('%(vid)s', '%(cookiename)s');
+ """ % {'tabindex'   : tabs.index(active_tab),
+        'vid'        : active_tab,
+        'eeid'       : (entity and entity.eid or uid),
+        'cookiename' : self.cookie_name})
 
 
 class EntityRelationView(EntityView):