[css] introducing scale and rhythm composition
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Thu, 29 Apr 2010 08:39:13 +0200
changeset 5480 2d5c46e78ae9
parent 5473 ee87c5352e63
child 5481 2236b2f57c67
[css] introducing scale and rhythm composition
selectors.py
web/data/cubicweb.css
web/data/cubicweb.rhythm.js
web/data/rhythm15.png
web/data/rhythm18.png
web/data/rhythm20.png
web/data/rhythm22.png
web/data/rhythm24.png
web/data/rhythm26.png
web/views/actions.py
web/views/basetemplates.py
--- a/selectors.py	Wed May 05 18:10:33 2010 +0200
+++ b/selectors.py	Thu Apr 29 08:39:13 2010 +0200
@@ -1288,6 +1288,10 @@
                 return None
         super(is_in_state, self).__init__(score)
 
+@objectify_selector
+def debug_mode(cls, req, rset=None, **kwargs):
+    """Return 1 if running in debug mode"""
+    return req.vreg.config.debugmode and 1 or 0
 
 ## deprecated stuff ############################################################
 
--- a/web/data/cubicweb.css	Wed May 05 18:10:33 2010 +0200
+++ b/web/data/cubicweb.css	Thu Apr 29 08:39:13 2010 +0200
@@ -8,6 +8,8 @@
 /* xhtml tags                          */
 /***************************************/
 
+.rhythm_bg { background: url(/data/rhythm20.png) repeat ! important; }
+
 html, body {
   background: #e2e2e2;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/data/cubicweb.rhythm.js	Thu Apr 29 08:39:13 2010 +0200
@@ -0,0 +1,6 @@
+$(document).ready(function() {
+    $('a.rhythm').click(function (event){
+        $('div#pageContent').toggleClass('rhythm_bg');
+	event.preventDefault();
+	});
+    });
Binary file web/data/rhythm15.png has changed
Binary file web/data/rhythm18.png has changed
Binary file web/data/rhythm20.png has changed
Binary file web/data/rhythm22.png has changed
Binary file web/data/rhythm24.png has changed
Binary file web/data/rhythm26.png has changed
--- a/web/views/actions.py	Wed May 05 18:10:33 2010 +0200
+++ b/web/views/actions.py	Thu Apr 29 08:39:13 2010 +0200
@@ -29,7 +29,7 @@
     one_line_rset, multi_lines_rset, one_etype_rset, relation_possible,
     nonempty_rset, non_final_entity,
     authenticated_user, match_user_groups, match_search_state,
-    has_permission, has_add_permission, implements,
+    has_permission, has_add_permission, implements, debug_mode,
     )
 from cubicweb.web import uicfg, controller, action
 from cubicweb.web.views import linksearch_select_url, vid_from_rset
@@ -412,6 +412,21 @@
     def url(self):
         return 'http://www.cubicweb.org'
 
+class GotRhythmAction(action.Action):
+    __regid__ = 'rhythm'
+    __select__ = debug_mode()
+
+    category = 'footer'
+    order = 3
+    title = _('Got rhythm?')
+
+    def url(self):
+        from logilab.mtconverter import xml_escape
+        return xml_escape(self._cw.url()+'#')
+
+    def html_class(self):
+        self._cw.add_js('cubicweb.rhythm.js')
+        return 'rhythm'
 
 ## default actions ui configuration ###########################################
 
--- a/web/views/basetemplates.py	Wed May 05 18:10:33 2010 +0200
+++ b/web/views/basetemplates.py	Thu Apr 29 08:39:13 2010 +0200
@@ -394,8 +394,10 @@
                                                             rset=self.cw_rset)
         footeractions = actions.get('footer', ())
         for i, action in enumerate(footeractions):
-            self.w(u'<a href="%s">%s</a>' % (action.url(),
-                                             self._cw._(action.title)))
+            self.w(u'<a href="%s"' % action.url())
+            if getattr(action, 'html_class'):
+                self.w(u' class="%s"' % action.html_class())
+            self.w(u'>%s</a>' % self._cw._(action.title))
             if i < (len(footeractions) - 1):
                 self.w(u' | ')
         self.w(u'</div>')