[nav component/cosmetics] have nice looking arrows insteads of << / >>
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Fri, 06 May 2011 11:07:05 +0200
changeset 7323 53f38d39287f
parent 7322 108c87e0538c
child 7325 b850b54f668a
[nav component/cosmetics] have nice looking arrows insteads of << / >>
web/component.py
web/data/cubicweb.css
web/data/cubicweb.old.css
web/data/go_next.png
web/data/go_prev.png
web/views/navigation.py
--- a/web/component.py	Fri May 06 08:52:09 2011 +0200
+++ b/web/component.py	Fri May 06 11:07:05 2011 +0200
@@ -1,4 +1,4 @@
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -57,8 +57,6 @@
     page_link_templ = u'<span class="slice"><a href="%s" title="%s">%s</a></span>'
     selected_page_link_templ = u'<span class="selectedSlice"><a href="%s" title="%s">%s</a></span>'
     previous_page_link_templ = next_page_link_templ = page_link_templ
-    no_previous_page_link = u'&lt;&lt;'
-    no_next_page_link = u'&gt;&gt;'
 
     def __init__(self, req, rset, **kwargs):
         super(NavigationComponent, self).__init__(req, rset=rset, **kwargs)
@@ -131,7 +129,33 @@
             return self.selected_page_link_templ % (url, content, content)
         return self.page_link_templ % (url, content, content)
 
-    def previous_link(self, path, params, content='&lt;&lt;', title=_('previous_results')):
+    @property
+    def prev_icon_url(self):
+        return xml_escape(self._cw.data_url('go_prev.png'))
+
+    @property
+    def next_icon_url(self):
+        return xml_escape(self._cw.data_url('go_next.png'))
+
+    @property
+    def no_previous_page_link(self):
+        return u'<img src="%s" class="prevnext_nogo"/>' % self.prev_icon_url
+
+    @property
+    def no_next_page_link(self):
+        return u'<img src="%s" class="prevnext_nogo"/>' % self.next_icon_url
+
+    @property
+    def no_content_prev_link(self):
+        return '<img src="%s" class="prevnext"/>' % self.prev_icon_url
+
+    @property
+    def no_content_next_link(self):
+        return '<img src="%s" class="prevnext"/>' % self.next_icon_url
+
+    def previous_link(self, path, params, content=None, title=_('previous_results')):
+        if not content:
+            content = self.no_content_prev_link
         start = self.starting_from
         if not start :
             return self.no_previous_page_link
@@ -140,7 +164,9 @@
         url = xml_escape(self.page_url(path, params, start, stop))
         return self.previous_page_link_templ % (url, title, content)
 
-    def next_link(self, path, params, content='&gt;&gt;', title=_('next_results')):
+    def next_link(self, path, params, content=None, title=_('next_results')):
+        if not content:
+            content = self.no_content_next_link
         start = self.starting_from + self.page_size
         if start >= self.total:
             return self.no_next_page_link
--- a/web/data/cubicweb.css	Fri May 06 08:52:09 2011 +0200
+++ b/web/data/cubicweb.css	Fri May 06 11:07:05 2011 +0200
@@ -120,6 +120,19 @@
   border: none;
 }
 
+
+img.prevnext {
+  width: 22px;
+  height: 22px;
+}
+
+img.prevnext_nogo {
+  width: 22px;
+  height: 22px;
+  filter:alpha(opacity=25); /* IE */
+  opacity:.25;
+}
+
 fieldset {
   border: none;
 }
--- a/web/data/cubicweb.old.css	Fri May 06 08:52:09 2011 +0200
+++ b/web/data/cubicweb.old.css	Fri May 06 11:07:05 2011 +0200
@@ -69,6 +69,18 @@
   text-align: center;
 }
 
+img.prevnext {
+  width: 22px;
+  height: 22px;
+}
+
+img.prevnext_nogo {
+  width: 22px;
+  height: 22px;
+  filter:alpha(opacity=25); /* IE */
+  opacity:.25;
+}
+
 p {
   margin: 0em 0px 0.2em;
   padding-top: 2px;
Binary file web/data/go_next.png has changed
Binary file web/data/go_prev.png has changed
--- a/web/views/navigation.py	Fri May 06 08:52:09 2011 +0200
+++ b/web/views/navigation.py	Fri May 06 11:07:05 2011 +0200
@@ -40,10 +40,10 @@
         self.clean_params(params)
         basepath = self._cw.relative_path(includeparams=False)
         self.w(u'<div class="pagination">')
-        self.w(u'%s&#160;' % self.previous_link(basepath, params))
+        self.w(self.previous_link(basepath, params))
         self.w(u'[&#160;%s&#160;]' %
                u'&#160;| '.join(self.iter_page_links(basepath, params)))
-        self.w(u'&#160;%s' % self.next_link(basepath, params))
+        self.w(u'&#160;&#160;%s' % self.next_link(basepath, params))
         self.w(u'</div>')
 
     def index_display(self, start, stop):
@@ -74,12 +74,12 @@
         basepath = self._cw.relative_path(includeparams=False)
         w = self.w
         w(u'<div class="pagination">')
-        w(u'%s&#160;' % self.previous_link(basepath, params))
+        w(self.previous_link(basepath, params))
         w(u'<select onchange="javascript: document.location=this.options[this.selectedIndex].value">')
         for option in self.iter_page_links(basepath, params):
             w(option)
         w(u'</select>')
-        w(u'&#160;%s' % self.next_link(basepath, params))
+        w(u'&#160;&#160;%s' % self.next_link(basepath, params))
         w(u'</div>')