From d4137906be2852d82777070dd081760cd69fdf8a Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Mon, 7 May 2018 11:23:59 +0400 Subject: [PATCH] =?UTF-8?q?ulib/web:=20possibilit=C3=A9=20d'avoir=20un=20c?= =?UTF-8?q?ontainer=20non=20fluid=20pour=20menu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/nulib/python/nulib/web/bootstrap.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/nulib/python/nulib/web/bootstrap.py b/lib/nulib/python/nulib/web/bootstrap.py index 214c9d9..a34ac48 100644 --- a/lib/nulib/python/nulib/web/bootstrap.py +++ b/lib/nulib/python/nulib/web/bootstrap.py @@ -62,11 +62,15 @@ class Menu(ui.Menu): """Un menu""" def __init__(self, title, mitems=None, profiles=None, - id=None, in_profiles=None, css=None, navbar_type=None, **kw): + id=None, in_profiles=None, css=None, + navbar_type=None, container_fluid=None, **kw): if navbar_type is None: navbar_type = kw.pop('t', None) + if container_fluid is None: container_fluid = kw.pop('f', None) super(Menu, self).__init__(title, mitems, profiles, id, in_profiles, css, **kw) if navbar_type is None: navbar_type = 'static' self.navbar_type = navbar_type + if container_fluid is None: container_fluid = True + self.container_fluid = container_fluid def __mitem(self, mitem, sel_profile): # ne pas afficher un menu qui n'est pas dans le bon profil @@ -100,25 +104,32 @@ class Menu(ui.Menu): lines.append(u"""""") return lines - def render(self, select=None, profile=None, navbar_type=None, **kw): + def __is_navbar_fixed(self, navbar_type): + return navbar_type == 'fixed' or navbar_type == 'fixed-top' + def __is_navbar_static(self, navbar_type): + return navbar_type == 'static' or navbar_type == 'static-top' + + def render(self, select=None, profile=None, navbar_type=None, container_fluid=None, **kw): if select is None: select = kw.pop('s', None) if profile is None: profile = kw.pop('p', None) if navbar_type is None: navbar_type = kw.pop('t', None) + if container_fluid is None: container_fluid = kw.pop('f', None) if navbar_type is None: navbar_type = self.navbar_type + if container_fluid is None: container_fluid = self.container_fluid if select is not None: self.select(select, profile) selection = self.get_mitem() lines = [] - if navbar_type == 'fixed' or navbar_type == 'fixed-top': + if self.__is_navbar_fixed(navbar_type): lines.append(u"""""") css = u'' - css = ui.addclassif('navbar-fixed-top', navbar_type == 'fixed' or navbar_type == 'fixed-top', css) - css = ui.addclassif('navbar-static-top', navbar_type == 'static' or navbar_type == 'static-top', css) + css = ui.addclassif('navbar-fixed-top', self.__is_navbar_fixed(navbar_type), css) + css = ui.addclassif('navbar-static-top', self.__is_navbar_static(navbar_type), css) if self.profiles is not None and self.sel_profile is not None: css = ui.addclassif('%s-profile' % self.sel_profile, None, css) css = ui.addclassif(self.css, None, css) lines.append(u"""