ulib/web: possibilité d'avoir un container non fluid pour menu
This commit is contained in:
parent
6e142b7e61
commit
d4137906be
|
@ -62,11 +62,15 @@ class Menu(ui.Menu):
|
||||||
"""Un menu"""
|
"""Un menu"""
|
||||||
|
|
||||||
def __init__(self, title, mitems=None, profiles=None,
|
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 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)
|
super(Menu, self).__init__(title, mitems, profiles, id, in_profiles, css, **kw)
|
||||||
if navbar_type is None: navbar_type = 'static'
|
if navbar_type is None: navbar_type = 'static'
|
||||||
self.navbar_type = navbar_type
|
self.navbar_type = navbar_type
|
||||||
|
if container_fluid is None: container_fluid = True
|
||||||
|
self.container_fluid = container_fluid
|
||||||
|
|
||||||
def __mitem(self, mitem, sel_profile):
|
def __mitem(self, mitem, sel_profile):
|
||||||
# ne pas afficher un menu qui n'est pas dans le bon profil
|
# ne pas afficher un menu qui n'est pas dans le bon profil
|
||||||
|
@ -100,25 +104,32 @@ class Menu(ui.Menu):
|
||||||
lines.append(u"""</ul>""")
|
lines.append(u"""</ul>""")
|
||||||
return lines
|
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 select is None: select = kw.pop('s', None)
|
||||||
if profile is None: profile = kw.pop('p', None)
|
if profile is None: profile = kw.pop('p', None)
|
||||||
if navbar_type is None: navbar_type = kw.pop('t', 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 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)
|
if select is not None: self.select(select, profile)
|
||||||
selection = self.get_mitem()
|
selection = self.get_mitem()
|
||||||
lines = []
|
lines = []
|
||||||
if navbar_type == 'fixed' or navbar_type == 'fixed-top':
|
if self.__is_navbar_fixed(navbar_type):
|
||||||
lines.append(u"""<style type="text/css">body { margin-top: 50px; }</style>""")
|
lines.append(u"""<style type="text/css">body { margin-top: 50px; }</style>""")
|
||||||
css = u''
|
css = u''
|
||||||
css = ui.addclassif('navbar-fixed-top', navbar_type == 'fixed' or navbar_type == 'fixed-top', css)
|
css = ui.addclassif('navbar-fixed-top', self.__is_navbar_fixed(navbar_type), css)
|
||||||
css = ui.addclassif('navbar-static-top', navbar_type == 'static' or navbar_type == 'static-top', 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:
|
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('%s-profile' % self.sel_profile, None, css)
|
||||||
css = ui.addclassif(self.css, None, css)
|
css = ui.addclassif(self.css, None, css)
|
||||||
lines.append(u"""<div class="navbar navbar-default%s" role="navigation">""" % css)
|
lines.append(u"""<div class="navbar navbar-default%s" role="navigation">""" % css)
|
||||||
lines.append(u"""<div class="container-fluid">
|
lines.append(u"""<div class="container%s">
|
||||||
<div class="navbar-header">
|
<div class="navbar-header">
|
||||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||||
<span class="sr-only">Tooggle navigation</span>
|
<span class="sr-only">Tooggle navigation</span>
|
||||||
|
@ -128,7 +139,7 @@ class Menu(ui.Menu):
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="navbar-collapse collapse">
|
<div class="navbar-collapse collapse">
|
||||||
<ul class="nav navbar-nav">""")
|
<ul class="nav navbar-nav">""" % ('-fluid' if container_fluid else ''))
|
||||||
if self.profiles is not None:
|
if self.profiles is not None:
|
||||||
# gestion des profils
|
# gestion des profils
|
||||||
lines.append(u"""<li class="navbar-text"><form class="form-inline" method="get">""")
|
lines.append(u"""<li class="navbar-text"><form class="form-inline" method="get">""")
|
||||||
|
|
Loading…
Reference in New Issue