# HG changeset patch # User Aurelien Campeas # Date 1234375915 -3600 # Node ID 40c7c2cf07974ccdde962b2e221e9cfd8f91d828 # Parent 1a23781534a2bc905bd3e6b6cd1f876bfeb43978 [tabs] reuse the new set_cookie controller method diff -r 1a23781534a2 -r 40c7c2cf0797 web/data/cubicweb.tabs.js --- a/web/data/cubicweb.tabs.js Wed Feb 11 18:47:12 2009 +0100 +++ b/web/data/cubicweb.tabs.js Wed Feb 11 19:11:55 2009 +0100 @@ -1,7 +1,6 @@ -function set_tab(tabname) { +function set_tab(tabname, cookiename) { // set appropriate cookie - // XXX see if we can no just do it with jQuery - async_remote_exec('remember_active_tab', tabname); + async_remote_exec('set_cookie', cookiename, tabname); // trigger show + tabname event trigger_load(tabname); } diff -r 1a23781534a2 -r 40c7c2cf0797 web/views/tabs.py --- a/web/views/tabs.py Wed Feb 11 18:47:12 2009 +0100 +++ b/web/views/tabs.py Wed Feb 11 19:11:55 2009 +0100 @@ -60,9 +60,13 @@ class TabsMixin(LazyViewMixin): + @property + def cookie_name(self): + return str('%s_active_tab' % self.config.appid) + def active_tab(self, tabs, default): cookie = self.req.get_cookie() - cookiename = '%s_active_tab' % self.config.appid + cookiename = self.cookie_name activetab = cookie.get(cookiename) if activetab is None: cookie[cookiename] = default @@ -97,7 +101,7 @@ for tab in tabs: w(u'
  • ') w(u'' % tab) - w(u'' % tab) + w(u'' % (tab, self.cookie_name)) w(self.req._(tab)) w(u'') w(u'') @@ -112,17 +116,11 @@ # because the callback binding needs to be done before self.req.html_headers.add_onload(u""" jQuery('#entity-tabs > ul').tabs( { selected: %(tabindex)s }); - set_tab('%(vid)s'); - """ % {'tabindex' : tabs.index(active_tab), - 'vid' : active_tab}) - + set_tab('%(vid)s', '%(cookiename)s'); + """ % {'tabindex' : tabs.index(active_tab), + 'vid' : active_tab, + 'cookiename' : self.cookie_name}) -@monkeypatch(JSonController) -def js_remember_active_tab(self, tabname): - cookie = self.req.get_cookie() - cookiename = '%s_active_tab' % self.config.appid - cookie[cookiename] = tabname - self.req.set_cookie(cookie, cookiename) class EntityRelatedTab(EntityView): """A view you should inherit from leftmost,