58 self.req.html_headers.add_onload("trigger_load('%s');" % vid) |
58 self.req.html_headers.add_onload("trigger_load('%s');" % vid) |
59 |
59 |
60 |
60 |
61 class TabsMixin(LazyViewMixin): |
61 class TabsMixin(LazyViewMixin): |
62 |
62 |
|
63 @property |
|
64 def cookie_name(self): |
|
65 return str('%s_active_tab' % self.config.appid) |
|
66 |
63 def active_tab(self, tabs, default): |
67 def active_tab(self, tabs, default): |
64 cookie = self.req.get_cookie() |
68 cookie = self.req.get_cookie() |
65 cookiename = '%s_active_tab' % self.config.appid |
69 cookiename = self.cookie_name |
66 activetab = cookie.get(cookiename) |
70 activetab = cookie.get(cookiename) |
67 if activetab is None: |
71 if activetab is None: |
68 cookie[cookiename] = default |
72 cookie[cookiename] = default |
69 self.req.set_cookie(cookie, cookiename) |
73 self.req.set_cookie(cookie, cookiename) |
70 tab = default |
74 tab = default |
110 w(u'</div>') |
114 w(u'</div>') |
111 # call the set_tab() JS function *after* each tab is generated |
115 # call the set_tab() JS function *after* each tab is generated |
112 # because the callback binding needs to be done before |
116 # because the callback binding needs to be done before |
113 self.req.html_headers.add_onload(u""" |
117 self.req.html_headers.add_onload(u""" |
114 jQuery('#entity-tabs > ul').tabs( { selected: %(tabindex)s }); |
118 jQuery('#entity-tabs > ul').tabs( { selected: %(tabindex)s }); |
115 set_tab('%(vid)s'); |
119 set_tab('%(vid)s', '%(cookiename)s'); |
116 """ % {'tabindex' : tabs.index(active_tab), |
120 """ % {'tabindex' : tabs.index(active_tab), |
117 'vid' : active_tab}) |
121 'vid' : active_tab, |
|
122 'cookiename' : self.cookie_name}) |
118 |
123 |
119 |
|
120 @monkeypatch(JSonController) |
|
121 def js_remember_active_tab(self, tabname): |
|
122 cookie = self.req.get_cookie() |
|
123 cookiename = '%s_active_tab' % self.config.appid |
|
124 cookie[cookiename] = tabname |
|
125 self.req.set_cookie(cookie, cookiename) |
|
126 |
124 |
127 class EntityRelatedTab(EntityView): |
125 class EntityRelatedTab(EntityView): |
128 """A view you should inherit from leftmost, |
126 """A view you should inherit from leftmost, |
129 to wrap another actual view displaying entity related stuff. |
127 to wrap another actual view displaying entity related stuff. |
130 Such a view _must_ provide the rtype, target and vid attributes : |
128 Such a view _must_ provide the rtype, target and vid attributes : |