[basetemplates] Use a size of 2 for side columns (closes #4538123)

authorRémi Cardona <remi.cardona@logilab.fr>
changesetc825185c17fe
branchdefault
phasepublic
hiddenno
parent revision#e388a69cb77f [basetemplates] Allow setting the number of columns in twbs layout
child revision#c89950b2fef7 [basetemplates] Fix the main template global header/nav bar (closes #4881614)
files modified by this revision
data/cubes.squareui.js
views/basetemplates.py
views/component.py
# HG changeset patch
# User Rémi Cardona <remi.cardona@logilab.fr>
# Date 1421938630 -3600
# Thu Jan 22 15:57:10 2015 +0100
# Node ID c825185c17fe5728cdaaa8bdbb2e9eef97017387
# Parent e388a69cb77f9c5b11113fd4a40278c1c551b5ef
[basetemplates] Use a size of 2 for side columns (closes #4538123)

diff --git a/data/cubes.squareui.js b/data/cubes.squareui.js
@@ -15,11 +15,11 @@
1 
2      toggleLeftColumn: function (toggle) {
3          var $contentCol = $('#main-center');
4          var $asideCols = $(".cwjs-aside");
5          if ($asideCols.length) {
6 -            var collapsendContentClass = twbs_col_cls + (twbs_grid_columns - $asideCols.length * 3);
7 +            var collapsendContentClass = twbs_col_cls + (twbs_grid_columns - $asideCols.length * twbs_col_size);
8              var fullContentClass = twbs_col_cls + twbs_grid_columns;
9              var displayAsideboxes = cw.cubes.squareui.getLocalData('asideboxes');
10              if (toggle === undefined) {
11                  displayAsideboxes = $asideCols.hasClass('hidden');
12                  cw.cubes.squareui.storeLocalData('asideboxes', displayAsideboxes);
diff --git a/views/basetemplates.py b/views/basetemplates.py
@@ -24,10 +24,11 @@
13  basetemplates.TheMainTemplate.doctype = HTML5
14 
15  # options which can be changed freely
16  basetemplates.TheMainTemplate.twbs_container_cls = 'container-fluid'
17  basetemplates.TheMainTemplate.twbs_col_cls = 'col-xs-'
18 +basetemplates.TheMainTemplate.twbs_col_size = 2
19 
20  # options which require recompiling bootstrap.css from source
21  basetemplates.TheMainTemplate.twbs_grid_columns = 12
22 
23 
@@ -72,11 +73,11 @@
24      right_boxes = list(self._cw.vreg['ctxcomponents'].poss_visible_objects(
25          self._cw, rset=self.cw_rset, view=view, context='right'))
26      nb_boxes = int(bool(left_boxes)) + int(bool(right_boxes))
27      content_cols = self.twbs_grid_columns
28      if nb_boxes:
29 -        content_cols = self.twbs_grid_columns-(3*nb_boxes)
30 +        content_cols = self.twbs_grid_columns - self.twbs_col_size * nb_boxes
31      self.nav_column(view, left_boxes, 'left')
32      self.content_column(view, content_cols)
33      self.nav_column(view, right_boxes, 'right')
34      self.w(u'</div>\n') # closes class=row
35      self.w(u'</div>\n') # closes id="page" from template_page_content
@@ -119,12 +120,12 @@
36          for box in boxes:
37              box.render(w=stream.write, view=view)
38          html = stream.getvalue()
39          if html:
40              # only display aside columns if html availble
41 -            self.w(u'<aside id="aside-main-%s" class="%s3 cwjs-aside">\n' %
42 -                   (context, self.twbs_col_cls))
43 +            self.w(u'<aside id="aside-main-%s" class="%s%s cwjs-aside">\n' %
44 +                   (context, self.twbs_col_cls, self.twbs_col_size))
45              self.w(html)
46              self.w(u'</aside>\n')
47      return len(boxes)
48 
49  @monkeypatch(basetemplates.TheMainTemplate)
diff --git a/views/component.py b/views/component.py
@@ -31,10 +31,11 @@
50      icon_css_cls = 'glyphicon glyphicon-align-justify'
51 
52      def render(self, w):
53          define_var = self._cw.html_headers.define_var
54          define_var('twbs_col_cls', TheMainTemplate.twbs_col_cls)
55 +        define_var('twbs_col_size', TheMainTemplate.twbs_col_size)
56          define_var('twbs_grid_columns', TheMainTemplate.twbs_grid_columns)
57          w(u'''<button class="btn btn-default navbar-btn" id="cw-aside-toggle"
58                onclick="cw.cubes.squareui.toggleLeftColumn()" title="%(label)s">
59                <span class="%(icon_class)s"></span>
60                </button>''' % {