1 from unfold.composite import Composite
3 # although the persistent_active feature originally targetted any kind of
4 # composite widget, the current implementation clearly
5 # works only with Tabs, as the javascript function for enabling a given tab
6 # cannot just set the 'active' class on some DOM element, but is required
7 # by bootstrap to call the tab() javascript method
9 class Tabs (Composite):
11 """A composite plugin for arranging sons as selectable tabs
13 persistent_active: if set to True, enables preserving
14 the domid for the active tab, so that a given page
15 will re-open with the same active tab
18 def __init__ (self, persistent_active=False, *args, **kwds):
19 Composite.__init__ (self, *args, **kwds)
20 self.persistent_active=persistent_active
22 def requirements (self):
23 return { 'js_files' : ['js/tabs.js', 'js/bootstrap.js'],
24 'css_files' : ['css/bootstrap.css', 'css/tabs.css', ]
27 def template_file (self):
30 def template_env (self, request):
31 inherited=Composite.template_env(self,request)
32 inherited.update({'persistent_active':self.persistent_active})
35 # see Composite.py for the details of template_env, that exposes global
36 # 'sons' as a list of sons with each a set of a few attributes
37 def json_settings_list (self):