1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
540 'resinput' : self.render_select(form, field, jsnodes['to'], selected=True), |
540 'resinput' : self.render_select(form, field, jsnodes['to'], selected=True), |
541 'addinput' : self.add_button % jsnodes, |
541 'addinput' : self.add_button % jsnodes, |
542 'removeinput': self.remove_button % jsnodes |
542 'removeinput': self.remove_button % jsnodes |
543 }) |
543 }) |
544 |
544 |
|
545 |
545 class BitSelect(Select): |
546 class BitSelect(Select): |
546 """Select widget for IntField using a vocabulary with bit masks as values. |
547 """Select widget for IntField using a vocabulary with bit masks as values. |
547 |
548 |
548 See also :class:`~cubicweb.web.facet.BitFieldFacet`. |
549 See also :class:`~cubicweb.web.facet.BitFieldFacet`. |
549 """ |
550 """ |
685 req.add_js('jquery.ui.datepicker-%s.js' % req.lang) |
686 req.add_js('jquery.ui.datepicker-%s.js' % req.lang) |
686 domid = field.dom_id(form, self.suffix) |
687 domid = field.dom_id(form, self.suffix) |
687 # XXX find a way to understand every format |
688 # XXX find a way to understand every format |
688 fmt = req.property_value('ui.date-format') |
689 fmt = req.property_value('ui.date-format') |
689 fmt = fmt.replace('%Y', 'yy').replace('%m', 'mm').replace('%d', 'dd') |
690 fmt = fmt.replace('%Y', 'yy').replace('%m', 'mm').replace('%d', 'dd') |
690 req.add_onload(u'cw.jqNode("%s").datepicker(' |
691 req.add_onload(u'$("#%s").datepicker(' |
691 '{buttonImage: "%s", dateFormat: "%s", firstDay: 1,' |
692 '{buttonImage: "%s", dateFormat: "%s", firstDay: 1,' |
692 ' showOn: "button", buttonImageOnly: true})' % ( |
693 ' showOn: "button", buttonImageOnly: true})' % ( |
693 domid, req.uiprops['CALENDAR_ICON'], fmt)) |
694 domid, req.uiprops['CALENDAR_ICON'], fmt)) |
694 return self._render_input(form, field, domid) |
695 return self._render_input(form, field, domid) |
695 |
696 |
716 self.timesteps = timesteps |
717 self.timesteps = timesteps |
717 self.separator = separator |
718 self.separator = separator |
718 |
719 |
719 def _render(self, form, field, renderer): |
720 def _render(self, form, field, renderer): |
720 domid = field.dom_id(form, self.suffix) |
721 domid = field.dom_id(form, self.suffix) |
721 form._cw.add_onload(u'cw.jqNode("%s").timePicker({step: %s, separator: "%s"})' % ( |
722 form._cw.add_onload(u'$("#%s").timePicker({step: %s, separator: "%s"})' % ( |
722 domid, self.timesteps, self.separator)) |
723 domid, self.timesteps, self.separator)) |
723 return self._render_input(form, field, domid) |
724 return self._render_input(form, field, domid) |
724 |
725 |
725 |
726 |
726 class JQueryDateTimePicker(FieldWidget): |
727 class JQueryDateTimePicker(FieldWidget): |