[views] Backport main_header monkeypatch from squareui (closes #3348088)
authorVladimir Popescu <vladimir.popescu@logilab.fr>
Mon, 09 Dec 2013 11:32:00 +0100
changeset 585 2a63796abb42
parent 584 44f466ecc207
child 625 fb0db36b7812
[views] Backport main_header monkeypatch from squareui (closes #3348088)
views/basetemplates.py
--- a/views/basetemplates.py	Mon Dec 09 15:44:13 2013 +0100
+++ b/views/basetemplates.py	Mon Dec 09 11:32:00 2013 +0100
@@ -137,48 +137,22 @@
 @monkeypatch(basetemplates.HTMLPageHeader)
 def main_header(self, view):
     """build the top menu with authentification info and the rql box"""
-    spans = {'headtext': 3,
-             'header-center': 7,
-             'header-right': 2,
+    spans = {'headtext': 'col-md-2',
+             'header-center': 'col-md-9',
+             'header-right': 'col-md-1 pull-right',
              }
     w = self.w
-    w(u'<div id="header" class="navbar">'
-      u'<div class="navbar-inner">'
-      u'<div class="container">'
-      u'<div class="row">')
-    prev_span_size = 0
+    w(u'<div id="header" class="navbar navbar-default" role="navigation">'
+      u'<div class="container">')
     for colid, context in self.headers:
+        w(u'<div id="%s" class="%s">' % (colid, spans.get(colid, 'col-md-2')))
         components = self._cw.vreg['ctxcomponents'].poss_visible_objects(
             self._cw, rset=self.cw_rset, view=view, context=context)
-        if components:
-            span_size = spans.get(colid, 2) + prev_span_size
-            prev_span_size = 0
-            w(u'<div id="%s" class="col-md-%s">' % (colid, span_size))
-            klass = ' pull-right' if context in ('header-center', 'header-right') else ''
-            w(u'<ul class="nav%s">' % klass)
-            for comp in components:
-                w(u'<li>')
-                comp.render(w=w)
-                w(u'</li>')
-            w(u'</ul>')
-            w(u'</div>')
-        else:
-            # Keep size to make a bigger span the next time
-            prev_span_size += spans.get(colid, 2)
-    w(u'</div></div></div></div>\n')
-    # get login form to display it as modal window / Backport from Orbui
-    login = self._cw.vreg['forms'].select('logform', self._cw)
-    self.w(u'<div id="loginModal" class="modal hide fade in">'
-           u'<div class="modal-header">'
-           u'<a class="close" data-dismiss="modal">x</a>'
-           u'<h3>%s</h3>'
-           u'</div>'
-           u'<div class="modal-body">' % self._cw._('log in'))
-    login.render(w=self.w)
-    self.w(u'</div>'
-           u' <div class="modal-footer"></div>'
-           u'</div>')
-
+        for comp in components:
+            comp.render(w=w)
+            w(u'&#160;')
+        w(u'</div>')
+    w(u'</div></div>\n')
 
 
 ###############################################################################