cubicweb/web/htmlwidgets.py
changeset 12567 26744ad37953
parent 11057 0b59724cb3f2
child 12825 71a842bdf81d
equal deleted inserted replaced
12566:6b3523f81f42 12567:26744ad37953
    22 """
    22 """
    23 
    23 
    24 import random
    24 import random
    25 from math import floor
    25 from math import floor
    26 
    26 
    27 from six import add_metaclass
       
    28 from six.moves import range
       
    29 
       
    30 from logilab.mtconverter import xml_escape
    27 from logilab.mtconverter import xml_escape
    31 from logilab.common.deprecation import class_deprecated
    28 from logilab.common.deprecation import class_deprecated
    32 
    29 
    33 from cubicweb.utils import UStringIO
    30 from cubicweb.utils import UStringIO
    34 from cubicweb.uilib import toggle_action, htmlescape
    31 from cubicweb.uilib import toggle_action, htmlescape
   116                 _bwcompatible_render_item(self.w, item)
   113                 _bwcompatible_render_item(self.w, item)
   117             self.box_end_content()
   114             self.box_end_content()
   118         self.w(u'</div>')
   115         self.w(u'</div>')
   119 
   116 
   120 
   117 
   121 @add_metaclass(class_deprecated)
   118 class SideBoxWidget(BoxWidget, metaclass=class_deprecated):
   122 class SideBoxWidget(BoxWidget):
       
   123     """default CubicWeb's sidebox widget"""
   119     """default CubicWeb's sidebox widget"""
   124     __deprecation_warning__ = '[3.10] class %(cls)s is deprecated'
   120     __deprecation_warning__ = '[3.10] class %(cls)s is deprecated'
   125 
   121 
   126     title_class = u'sideBoxTitle'
   122     title_class = u'sideBoxTitle'
   127     main_div_class = u'sideBoxBody'
   123     main_div_class = u'sideBoxBody'
   208 
   204 
   209     def _end_menu(self):
   205     def _end_menu(self):
   210         self.w(u'</ul></div></div>')
   206         self.w(u'</ul></div></div>')
   211 
   207 
   212 
   208 
   213 @add_metaclass(class_deprecated)
   209 class BoxField(HTMLWidget, metaclass=class_deprecated):
   214 class BoxField(HTMLWidget):
       
   215     """couples label / value meant to be displayed in a box"""
   210     """couples label / value meant to be displayed in a box"""
   216     __deprecation_warning__ = '[3.10] class %(cls)s is deprecated'
   211     __deprecation_warning__ = '[3.10] class %(cls)s is deprecated'
   217     def __init__(self, label, value):
   212     def __init__(self, label, value):
   218         self.label = label
   213         self.label = label
   219         self.value = value
   214         self.value = value
   222         self.w(u'<li><div><span class="label">%s</span>&#160;'
   217         self.w(u'<li><div><span class="label">%s</span>&#160;'
   223                u'<span class="value">%s</span></div></li>'
   218                u'<span class="value">%s</span></div></li>'
   224                % (self.label, self.value))
   219                % (self.label, self.value))
   225 
   220 
   226 
   221 
   227 @add_metaclass(class_deprecated)
   222 class BoxSeparator(HTMLWidget, metaclass=class_deprecated):
   228 class BoxSeparator(HTMLWidget):
       
   229     """a menu separator"""
   223     """a menu separator"""
   230     __deprecation_warning__ = '[3.10] class %(cls)s is deprecated'
   224     __deprecation_warning__ = '[3.10] class %(cls)s is deprecated'
   231 
   225 
   232     def _render(self):
   226     def _render(self):
   233         self.w(u'</ul><hr class="boxSeparator"/><ul>')
   227         self.w(u'</ul><hr class="boxSeparator"/><ul>')
   234 
   228 
   235 
   229 
   236 @add_metaclass(class_deprecated)
   230 class BoxLink(HTMLWidget, metaclass=class_deprecated):
   237 class BoxLink(HTMLWidget):
       
   238     """a link in a box"""
   231     """a link in a box"""
   239     __deprecation_warning__ = '[3.10] class %(cls)s is deprecated'
   232     __deprecation_warning__ = '[3.10] class %(cls)s is deprecated'
   240     def __init__(self, href, label, _class='', title='', ident='', escape=False):
   233     def __init__(self, href, label, _class='', title='', ident='', escape=False):
   241         self.href = href
   234         self.href = href
   242         if escape:
   235         if escape:
   254             self.w(u'<li id="%s" class="%s">%s</li>\n' % (self.ident, self._class, link))
   247             self.w(u'<li id="%s" class="%s">%s</li>\n' % (self.ident, self._class, link))
   255         else:
   248         else:
   256             self.w(u'<li class="%s">%s</li>\n' % (self._class, link))
   249             self.w(u'<li class="%s">%s</li>\n' % (self._class, link))
   257 
   250 
   258 
   251 
   259 @add_metaclass(class_deprecated)
   252 class BoxHtml(HTMLWidget, metaclass=class_deprecated):
   260 class BoxHtml(HTMLWidget):
       
   261     """a form in a box"""
   253     """a form in a box"""
   262     __deprecation_warning__ = '[3.10] class %(cls)s is deprecated'
   254     __deprecation_warning__ = '[3.10] class %(cls)s is deprecated'
   263     def __init__(self, rawhtml):
   255     def __init__(self, rawhtml):
   264         self.rawhtml = rawhtml
   256         self.rawhtml = rawhtml
   265 
   257