the tabs plugin has a persistent_active feature to enable saving the active tab in...
[myslice.git] / plugins / tabs / __init__.py
1 from unfold.composite import Composite
2
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
8
9 class Tabs (Composite):
10     
11     """A composite plugin for arranging sons as selectable tabs
12     
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
16 """
17
18     def __init__ (self, persistent_active=False, *args, **kwds):
19         Composite.__init__ (self, *args, **kwds)
20         self.persistent_active=persistent_active
21         
22     def requirements (self):
23         return { 'js_files'     : ['js/tabs.js', 'js/bootstrap.js'],
24                  'css_files'    : ['css/bootstrap.css', 'css/tabs.css', ] 
25                  }
26
27     def template_file (self):
28         return "tabs.html"
29
30     def template_env (self, request):
31         inherited=Composite.template_env(self,request)
32         inherited.update({'persistent_active':self.persistent_active})
33         return inherited
34
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):
38         return []
39