X-Git-Url: http://git.onelab.eu/?p=myslice.git;a=blobdiff_plain;f=plugins%2Ftabs%2F__init__.py;h=4bab62d93ae0cb3873b90015cfc74c0b5d139ba1;hp=d1b9bda3803766f417a8568355e47d92707a12a1;hb=f19bceaa080ab47bae751cd0597a9fb32d1b6b4f;hpb=c37b38da17ad1530ebb76e7fa5ddb1bc634c59a4 diff --git a/plugins/tabs/__init__.py b/plugins/tabs/__init__.py index d1b9bda3..4bab62d9 100644 --- a/plugins/tabs/__init__.py +++ b/plugins/tabs/__init__.py @@ -1,7 +1,24 @@ from unfold.composite import Composite +# although the persistent_active feature originally targetted any kind of +# composite widget, the current implementation clearly +# works only with Tabs, as the javascript function for enabling a given tab +# cannot just set the 'active' class on some DOM element, but is required +# by bootstrap to call the tab() javascript method + class Tabs (Composite): + """A composite plugin for arranging sons as selectable tabs + +persistent_active: if set to True, enables preserving +the domid for the active tab, so that a given page +will re-open with the same active tab +""" + + def __init__ (self, persistent_active=False, *args, **kwds): + Composite.__init__ (self, *args, **kwds) + self.persistent_active=persistent_active + def requirements (self): return { 'js_files' : ['js/tabs.js', 'js/bootstrap.js'], 'css_files' : ['css/bootstrap.css', 'css/tabs.css', ] @@ -10,6 +27,11 @@ class Tabs (Composite): def template_file (self): return "tabs.html" + def template_env (self, request): + inherited=Composite.template_env(self,request) + inherited.update({'persistent_active':self.persistent_active}) + return inherited + # see Composite.py for the details of template_env, that exposes global # 'sons' as a list of sons with each a set of a few attributes def json_settings_list (self):