Example #1
0
 def _renderItem(self, index, text, value, name, cssClass, checked=False):
     kw = {}
     if checked:
         kw["checked"] = "checked"
     id = "%s.%s" % (name, index)
     elem = renderElement(u"input", value=value, name=name, id=id, cssClass=cssClass, type="radio", **kw)
     return renderElement(u"label", contents="%s %s" % (elem, text), **{"for": id})
Example #2
0
    def __call__(self):
        """Render the widget to HTML."""
        value = self._getFormValue()
        html = "<label for='%s'>%s" % (self.name, translate(self.context.title, context=self.request))
        if self.__required:
            # Use the numeric character reference here instead of &nbsp; to make
            # our xml-parsing tests happier.
            html += " <span class='required' title='%s'>&#160;</span>" % (
                translate(_(u"title_required", default="Required"), context=self.request)
            )
        if self.context.description:
            html += " <span class='formHelp'>%s</span>" % translate(self.context.description, context=self.request)
        html += "</label>\n"

        if value == "on":
            kw = {"checked": "checked"}
        else:
            kw = {}
        if self.disabled:
            kw["disabled"] = "disabled"
        return "%s  %s %s" % (
            renderElement(self.tag, type="hidden", name=self.name + ".used", id=self.name + ".used", value=""),
            renderElement(
                self.tag,
                type=self.type,
                name=self.name,
                id=self.name,
                cssClass=self.cssClass,
                extra=self.extra,
                value="on",
                **kw
            ),
            html,
        )
Example #3
0
 def __call__(self):
     displayMaxWidth = self.displayMaxWidth or 0
     hidden = renderElement(self.tag,
                            type='hidden',
                            name=self.name + ".used",
                            id=self.name + ".used",
                            value="")
     if displayMaxWidth > 0:
         elem = renderElement(self.tag,
                              type=self.type,
                              name=self.name,
                              id=self.name,
                              cssClass=self.cssClass,
                              size=self.displayWidth,
                              maxlength=displayMaxWidth,
                              extra=self.extra)
     else:
         elem = renderElement(self.tag,
                              type=self.type,
                              name=self.name,
                              id=self.name,
                              cssClass=self.cssClass,
                              size=self.displayWidth,
                              extra=self.extra)
     return "%s %s" % (hidden, elem)
Example #4
0
    def renderItem(self, index, text, value, name, cssClass):
        id = "%s.%s" % (name, index)
        elem = renderElement("input", type="checkbox", cssClass=cssClass, name=name, id=id, value=value)

        label = renderElement("label", extra=u"for=%s" % id, contents=text)

        return self._joinButtonToMessageTemplate % (elem, label)
Example #5
0
 def __call__(self):
     displayMaxWidth = self.displayMaxWidth or 0
     hidden = renderElement(self.tag,
                            type='hidden',
                            name=self.name+".used",
                            id=self.name+".used",
                            value="")
     if displayMaxWidth > 0:
         elem = renderElement(self.tag,
                              type=self.type,
                              name=self.name,
                              id=self.name,
                              cssClass=self.cssClass,
                              size=self.displayWidth,
                              maxlength=displayMaxWidth,
                              extra=self.extra)
     else:
         elem = renderElement(self.tag,
                              type=self.type,
                              name=self.name,
                              id=self.name,
                              cssClass=self.cssClass,
                              size=self.displayWidth,
                              extra=self.extra)
     return "%s %s" % (hidden, elem)
Example #6
0
    def __call__(self):
        """Render the widget to HTML."""
        value = self._getFormValue()
        html = "<label for='%s'>%s" % (self.name, translate(self.context.title, context=self.request))
        if self.__required:
            # Use the numeric character reference here instead of &nbsp; to make
            # our xml-parsing tests happier.
            html += " <span class='required' title='%s'>&#160;</span>" % (translate(_(u'title_required', default='Required'), context=self.request))
        if self.context.description:
            html += " <span class='formHelp'>%s</span>" % translate(self.context.description, context=self.request)
        html += "</label>\n"

        if value == 'on':
            kw = {'checked': 'checked'}
        else:
            kw = {}
        if self.disabled:
            kw['disabled'] = 'disabled'
        return "%s  %s %s" % (
            renderElement(self.tag,
                          type='hidden',
                          name=self.name + ".used",
                          id=self.name + ".used",
                          value=""
                          ),
            renderElement(self.tag,
                          type=self.type,
                          name=self.name,
                          id=self.name,
                          cssClass=self.cssClass,
                          extra=self.extra,
                          value="on",
                          **kw),
            html
            )
Example #7
0
 def _renderItem(self, index, text, value, name, cssClass, checked=False):
     kw = {}
     if checked:
         kw["checked"] = "checked"
     id = "%s.%s" % (name, index)
     elem = renderElement("input", type="checkbox", cssClass=cssClass, name=name, id=id, value=value, **kw)
     contents = self._joinButtonToMessageTemplate % (elem, escape(text))
     return renderElement(u"label", contents=contents, **{"for": id})
Example #8
0
 def __call__(self):
     button_el = widget.renderElement("span", contents="&nbsp;", 
         id="advanced_options_button")
     advanced_input = widget.renderElement("input", name="advanced",
         value="true", contents="&nbsp;", hidden="true")
     return "%s<br/>%s" %(super(SearchTextWidget, self).__call__(),
         widget.renderElement("a", contents="%s%s%s" %(button_el, 
             advanced_input, _("advanced options")),
             id="show_advanced_options", href="javascript:;")
     )
 def _data(self, item, i, l):
     super(Viewlet, self)._data(item, i, l)
     if 'url' in item and item['url']:
         if not 'wysiwyg' in item:
             item['wysiwyg'] = ''
         item['wysiwyg'] += renderElement('p',
                                          contents=renderElement('a',
                                                                 href=item['url'],
                                                                 cssClass='button read-more',
                                                                 contents=translate(_(u'Read more'), context=self.request)))
         item['url'] = None
Example #10
0
    def renderItem(self, index, text, value, name, cssClass):
        id = '%s.%s' % (name, index)
        elem = renderElement('input',
                             type="checkbox",
                             cssClass=cssClass,
                             name=name,
                             id=id,
                             value=value)

        label = renderElement('label', extra=u"for=%s" % id, contents=text)

        return self._joinButtonToMessageTemplate % (elem, label)
Example #11
0
 def __call__(self):
     dbitem_field = self.context
     bugtask = dbitem_field.context
     if self._renderedValueSet():
         dbitem = self._data
     else:
         dbitem = dbitem_field.get(bugtask)
     if dbitem:
         return renderElement(
             'span', contents=dbitem.title,
             cssClass="%s%s" % (dbitem_field.__name__, dbitem.name))
     else:
         return renderElement('span', contents='&mdash;')
Example #12
0
 def __call__(self):
     dbitem_field = self.context
     bugtask = dbitem_field.context
     if self._renderedValueSet():
         dbitem = self._data
     else:
         dbitem = dbitem_field.get(bugtask)
     if dbitem:
         return renderElement('span',
                              contents=dbitem.title,
                              cssClass="%s%s" %
                              (dbitem_field.__name__, dbitem.name))
     else:
         return renderElement('span', contents='&mdash;')
Example #13
0
    def renderItem(self, index, text, value, name, cssClass):
        id = '{0}.{1}'.format(name, index)
        elem = renderElement('input',
                             type="checkbox",
                             cssClass=cssClass,
                             name=name,
                             id=id,
                             value=value)

        label = renderElement('label',
                              extra=u'for={0}'.format(id),
                              contents=text)

        return self._joinButtonToMessageTemplate.format(elem, label)
Example #14
0
 def _renderItem(self, index, text, value, name, cssClass, checked=False):
     kw = {}
     if checked:
         kw['checked'] = 'checked'
     id = '%s.%s' % (name, index)
     elem = renderElement(u'input',
                          value=value,
                          name=name,
                          id=id,
                          cssClass=cssClass,
                          type='radio',
                          **kw)
     return renderElement(u'label',
                          contents='%s&nbsp;%s' % (elem, text),
                          **{'for': id})
Example #15
0
 def _renderItem(self, index, text, value, name, cssClass, checked=False):
     kw = {}
     if checked:
         kw['checked'] = 'checked'
     id = '%s.%s' % (name, index)
     elem = renderElement(u'input',
                          value=value,
                          name=name,
                          id=id,
                          cssClass=cssClass,
                          type='radio',
                          **kw)
     return renderElement(u'label',
                          contents='%s&nbsp;%s' % (elem, text),
                          **{'for': id})
Example #16
0
 def _renderItem(self, index, text, value, name, cssClass, checked=False):
     kw = {}
     if checked:
         kw['checked'] = 'checked'
     id = '%s.%s' % (name, index)
     elem = renderElement('input',
                          type="checkbox",
                          cssClass=cssClass,
                          name=name,
                          id=id,
                          value=value,
                          **kw)
     contents = self._joinButtonToMessageTemplate % (elem, escape(text))
     return renderElement(u'label',
                          contents=contents,
                          **{'for': id})
Example #17
0
 def renderSelectedItem(self, index, text, value, name, cssClass):
     """Render an item for a particular `value` that is selected."""
     return renderElement('option',
                          contents=escape(text),
                          value=value,
                          cssClass=cssClass,
                          selected='selected')
Example #18
0
 def renderSelectedItem(self, index, text, value, name, cssClass):
     """Render an item for a particular `value` that is selected."""
     return renderElement('option',
                          contents=escape(text),
                          value=value,
                          cssClass=cssClass,
                          selected='selected')
Example #19
0
    def __call__(self):
        # get the data to display:
        if self._renderedValueSet():
            data = self._data
        else:
            data = self.context.get(self.context.context)

        # deal with special cases:
        if data == self.context.missing_value:
            return translate(self._missingValueMessage, self.request)
        data = list(data)
        if not data:
            return translate(self._emptySequenceMessage, self.request)

        parts = []
        for i, item in enumerate(data):
            widget = self._getWidget(i)
            widget.setRenderedValue(item)
            s = widget()
            if self.itemTag:
                s = "<%s>%s</%s>" % (self.itemTag, s, self.itemTag)
            parts.append(s)
        contents = "\n".join(parts)
        if self.tag:
            contents = "\n%s\n" % contents
            contents = renderElement(self.tag,
                                     cssClass=self.cssClass,
                                     extra=self.extra,
                                     contents=contents)
        return contents
Example #20
0
 def _renderItem(self, index, text, value, name, cssClass, checked=False):
     kw = {}
     if checked:
         kw['checked'] = 'checked'
     id = '%s.%s' % (name, index)
     elem = renderElement('input',
                          type="checkbox",
                          cssClass=cssClass,
                          name=name,
                          id=id,
                          value=value,
                          **kw)
     contents = self._joinButtonToMessageTemplate % (elem, text)
     return renderElement(u'label',
                          contents=contents,
                          **{'for': id})
Example #21
0
    def __call__(self):
        res = u''
        value = self._getFormValue()
        if value is None or value == self.context.missing_value:
            value = []

        if isinstance(value, (str, unicode)):
            value = value.split(self.context.delimiter)

        for cell in range(0, self.context.cells):
            kwargs = {'type': self.type,
                      'name': self.name,
                      'id': self.name + '%s' % cell,
                      'value': value[cell] if len(value) > cell else u'',
                      'cssClass': self.cssClass,
                      'style': self.style,
                      'size': self.displayWidth,
                      'extra': self.extra
                      }
            if self.displayMaxWidth:
                kwargs['maxlength'] = self.displayMaxWidth

            if cell:
                res += u'&nbsp; &rarr; &nbsp;'
            res += renderElement(self.tag, **kwargs)
        return res
Example #22
0
    def __call__(self):
        # get the data to display:
        if self._renderedValueSet():
            data = self._data
        else:
            data = self.context.get(self.context.context)

        # deal with special cases:
        if data == self.context.missing_value:
            return translate(self._missingValueMessage, self.request)
        data = list(data)
        if not data:
            return translate(self._emptySequenceMessage, self.request)

        parts = []
        for i, item in enumerate(data):
            widget = self._getWidget(i)
            widget.setRenderedValue(item)
            s = widget()
            if self.itemTag:
                s = "<%s>%s</%s>" % (self.itemTag, s, self.itemTag)
            parts.append(s)
        contents = "\n".join(parts)
        if self.tag:
            contents = "\n%s\n" % contents
            contents = renderElement(self.tag,
                                     cssClass=self.cssClass,
                                     extra=self.extra,
                                     contents=contents)
        return contents
 def __call__(self):
     area = super(ProposeTextWidget, self).__call__()
     choice = self.choice()
     attr = {'name':self.name,
             'id':self.name,
             'cssClass': 'propose-widget' + self.cssClass,
             'contents':area + choice}
     return renderElement('div', **attr)
Example #24
0
 def _div(self, cssClass, contents, **kw):
     """Render a simple div tag."""
     if contents:
         return renderElement('div',
                              cssClass=cssClass,
                              contents="\n%s\n" % contents,
                              **kw)
     return ""
Example #25
0
 def _div(self, cssClass, contents, **kw):
     """Render a simple div tag."""
     if contents:
         return renderElement('div',
                              cssClass=cssClass,
                              contents="\n%s\n" % contents,
                              **kw)
     return ""
Example #26
0
 def renderValue(self, value):
     rendered_items = self.renderItems(value)
     contents = "\n%s\n" %"\n".join(rendered_items)
     return renderElement('select',
                          name=self.name,
                          id=self.name,
                          contents=contents,
                          size=self.size,
                          extra=self.extra)
 def renderItem(self, index, text, value, name, cssClass):
     id = '%s.%s' % (name, index)
     el = renderElement('input',
                          type="checkbox",
                          cssClass=cssClass,
                          name=name,
                          id=id,
                          value=value)
     return self._joinButtonToMessageTemplate % (cssClass, el, text, value)
Example #28
0
 def renderValue(self, value):
     rendered_items = self.renderItems(value)
     contents = "\n%s\n" %"\n".join(rendered_items)
     return renderElement('select',
                          name=self.name,
                          id=self.name,
                          contents=contents,
                          size=self.size,
                          extra=self.extra)
Example #29
0
 def renderItem(self, index, text, value, name, cssClass):
     id = '%s.%s' % (name, index)
     el = renderElement('input',
                        type="checkbox",
                        cssClass=cssClass,
                        name=name,
                        id=id,
                        value=value)
     return self._joinButtonToMessageTemplate % (cssClass, el, text, value)
Example #30
0
    def renderValue(self, value):
        """Render the widget with the selected value.

        The original renderValue separates the items with either
        '&nbsp;' or '<br />' which isn't suitable for us.
        """
        rendered_items = self.renderItems(value)
        return renderElement(
            'table', cssClass=self.cssClass,
            contents='\n'.join(rendered_items))
Example #31
0
 def __call__(self):
     assignee_field = self.context
     bugtask = assignee_field.context
     if self._renderedValueSet():
         assignee = self._data
     else:
         assignee = assignee_field.get(bugtask)
     if assignee:
         person_img = renderElement(
             'img', style="padding-bottom: 2px", src="/@@/person", alt="")
         return renderElement(
             'a', href=canonical_url(assignee),
             contents="%s %s" % (
                 person_img, html_escape(assignee.displayname)))
     else:
         if bugtask.pillar.official_malone:
             return renderElement('i', contents='not assigned')
         else:
             return renderElement('i', contents='unknown')
Example #32
0
 def __call__(self):
     """See IBrowserWidget."""
     value = self._getFormValue()
     if value:
         rendered_items = self.renderItems(value)
         return renderElement(
             self.tag, id=self.name, cssClass=self.cssClass, contents="\n".join(rendered_items), extra=self.extra
         )
     else:
         return self.translate(self._messageNoValue)
Example #33
0
    def renderValue(self, value):
        """Render the widget with the selected value.

        The original renderValue separates the items with either
        '&nbsp;' or '<br />' which isn't suitable for us.
        """
        rendered_items = self.renderItems(value)
        return renderElement('table',
                             cssClass=self.cssClass,
                             contents='\n'.join(rendered_items))
Example #34
0
 def __call__(self):
     return renderElement("textarea",
                          name=self.name,
                          id=self.name,
                          cssClass=self.cssClass,
                          rows=self.height,
                          cols=self.width,
                          style=self.style,
                          contents=escape(self._getFormValue()),
                          extra=self.extra)
 def __call__(self):
     return renderElement("textarea",
                          name=self.name,
                          id=self.name,
                          cssClass=self.cssClass,
                          rows=self.height,
                          cols=self.width,
                          style=self.style,
                          contents=escape(self._getFormValue()),
                          extra=self.extra)
Example #36
0
    def __call__(self):
        """Render the widget to HTML."""
        value = self._getFormValue()
        html = u"<label for='{0}'>{1}".format(
            self.name,
            translate(self.context.title, context=self.request)
        )
        if self.__required:
            # Use the numeric character reference here instead of &nbsp; to make
            # our xml-parsing tests happier.
            html += u" <span class='required' title='{0}'>&#160;</span>".format(
                translate(_(u'title_required', default='Required'), context=self.request)
            )
        if self.context.description:
            html += u" <span class='formHelp'>{0}</span>".format(
                translate(self.context.description, context=self.request)
            )
        html += u"</label>\n"

        if value == 'on':
            kw = {'checked': 'checked'}
        else:
            kw = {}
        if self.disabled:
            kw['disabled'] = 'disabled'
        return u'{0}  {1} {2}'.format(
            renderElement(self.tag,
                          type='hidden',
                          name=self.name + ".used",
                          id=self.name + ".used",
                          value=""
                          ),
            renderElement(self.tag,
                          type=self.type,
                          name=self.name,
                          id=self.name,
                          cssClass=self.cssClass,
                          extra=self.extra,
                          value="on",
                          **kw),
            html
        )
Example #37
0
 def renderItem(self, index, text, value, name, cssClass):
     """Render an item of the list."""
     text = html_escape(text)
     id = '%s.%s' % (name, index)
     elem = renderElement(u'input',
                          value=value,
                          name=name,
                          id=id,
                          cssClass=cssClass,
                          type='radio')
     return self._renderRow(text, value, id, elem)
Example #38
0
 def renderItems(self, value):
     """Render items of sequence."""
     items = []
     cssClass = self.cssClass or ""
     if cssClass:
         cssClass += "-item"
     tag = self.itemTag
     for item in value:
         term = self.vocabulary.getTerm(item)
         items.append(renderElement(tag, cssClass=cssClass, contents=escape(self.textForValue(term))))
     return items
Example #39
0
 def renderValue(self, value):
     # All we really add here is the ':list' in the name argument
     # and mutliple='multiple' to renderElement().
     rendered_items = self.renderItems(value)
     return renderElement(self.tag,
                          name=self.name + ':list',
                          id=self.name,
                          multiple='multiple',
                          size=self.size,
                          contents="\n".join(rendered_items),
                          extra=self.extra)
Example #40
0
 def __call__(self):
     if self._renderedValueSet():
         content = self._data
     else:
         content = self.context.default
     if content == self.context.missing_value:
         return ""
     content = str(content)
     return renderElement("span",
                          contents=escape(content),
                          cssClass=self.cssClass)
 def renderItem(self, index, text, value, name, cssClass):
     """Render an item of the list."""
     text = html_escape(text)
     id = '%s.%s' % (name, index)
     elem = renderElement(u'input',
                          value=value,
                          name=name,
                          id=id,
                          cssClass=cssClass,
                          type='radio')
     return self._renderRow(text, value, id, elem)
Example #42
0
 def renderValue(self, value):
     # All we really add here is the ':list' in the name argument
     # and mutliple='multiple' to renderElement().
     rendered_items = self.renderItems(value)
     return renderElement(self.tag,
                          name=self.name + ':list',
                          id=self.name,
                          multiple='multiple',
                          size=self.size,
                          contents="\n".join(rendered_items),
                          extra=self.extra)
Example #43
0
 def setUpOptions(self):
     """Set up options to be rendered."""
     self.options = {}
     for option in ["primary", "ppa"]:
         attributes = dict(
             type="radio", name=self.name, value=option,
             id="%s.option.%s" % (self.name, option))
         if (self.default_option is not None and
             self.request.form_ng.getOne(
                 self.name, self.default_option) == option):
             attributes["checked"] = "checked"
         self.options[option] = renderElement("input", **attributes)
Example #44
0
 def __call__(self):
     """See IBrowserWidget."""
     value = self._getFormValue()
     if value:
         rendered_items = self.renderItems(value)
         return renderElement(self.tag,
                              id=self.name,
                              cssClass=self.cssClass,
                              contents="\n".join(rendered_items),
                              extra=self.extra)
     else:
         return self.translate(self._messageNoValue)
Example #45
0
 def hidden(self):
     items = []
     for item in self._getFormValue():
         items.append(
             renderElement(u'input',
                           type='hidden',
                           name=self.name+':list',
                           id=self.name,
                           value=self.vocabulary.getTerm(item).token,
                           cssClass=self.cssClass,
                           extra=self.extra))
     return '\n'.join(items)
Example #46
0
 def hidden(self):
     items = []
     for item in self._getFormValue():
         items.append(
             renderElement(u'input',
                           type='hidden',
                           name=self.name+':list',
                           id=self.name,
                           value=self.vocabulary.getTerm(item).token,
                           cssClass=self.cssClass,
                           extra=self.extra))
     return '\n'.join(items)
Example #47
0
 def __call__(self):
     if self._renderedValueSet():
         content = self._data
     else:
         content = self.context.default
     if content == self.context.missing_value:
         return ""
     formatter = self.request.locale.dates.getFormatter(
         self._category, (self.displayStyle or None))
     content = formatter.format(content)
     return renderElement("span", contents=escape(content),
                          cssClass=self.cssClass)
 def _renderItem(self, index, text, value, name, cssClass, checked=False):
     """Render a checkbox and text without without label."""
     kw = {}
     if checked:
         kw['checked'] = 'checked'
     value = html_escape(value)
     text = html_escape(text)
     id = '%s.%s' % (name, index)
     element = renderElement(
         u'input', value=value, name=name, id=id,
         cssClass=cssClass, type='checkbox', **kw)
     return self._joinButtonToMessageTemplate % (element, text)
 def __call__(self):
     
     attr = {'name':self.name,
             'id':self.name,
             'cssClass':'ui-codemirror %s' % self.cssClass,
             'rows':self.height,
             'cols':self.width,
             'style':self.style,
             'data-mode':self.context.mode,
             'contents':escape(self._getFormValue()),
             'extra':self.extra}
             
     return renderElement('code', **attr)
Example #50
0
 def __call__(self):
     if self._renderedValueSet():
         content = self._data
     else:
         content = self.context.default
     if not content:
         # If there is no content it is not useful to render an anchor.
         return ''
     content = escape(content)
     kw = dict(contents=content, href=content)
     if self.linkTarget:
         kw["target"] = self.linkTarget
     return renderElement("a", **kw)
Example #51
0
 def __call__(self):
     assignee_field = self.context
     bugtask = assignee_field.context
     if self._renderedValueSet():
         assignee = self._data
     else:
         assignee = assignee_field.get(bugtask)
     if assignee:
         person_img = renderElement('img',
                                    style="padding-bottom: 2px",
                                    src="/@@/person",
                                    alt="")
         return renderElement(
             'a',
             href=canonical_url(assignee),
             contents="%s %s" %
             (person_img, html_escape(assignee.displayname)))
     else:
         if bugtask.pillar.official_malone:
             return renderElement('i', contents='not assigned')
         else:
             return renderElement('i', contents='unknown')
Example #52
0
 def __call__(self):
     if self._renderedValueSet():
         content = self._data
     else:
         content = self.context.default
     if content == self.context.missing_value:
         return ""
     content = localizeDateTime(content, self.request)
     formatter = self.request.locale.dates.getFormatter(
         self._category, (self.displayStyle or None))
     content = formatter.format(content)
     return renderElement("span", contents=textwidgets.escape(content),
                          cssClass=self.cssClass)
Example #53
0
 def __call__(self):
     if self._renderedValueSet():
         content = self._data
     else:
         content = self.context.default
     if not content:
         # If there is no content it is not useful to render an anchor.
         return ''
     content = escape(content)
     kw = dict(contents=content, href=content)
     if self.linkTarget:
         kw["target"] = self.linkTarget
     return renderElement("a", **kw)
Example #54
0
 def __call__(self):
     """Render the widget to HTML."""
     value = self._getFormValue()
     if value == 'on':
         kw = {'checked': 'checked'}
     else:
         kw = {}
     return "%s %s" % (
         renderElement(self.tag,
                       type='hidden',
                       name=self.name + ".used",
                       id=self.name + ".used",
                       value=""),
         renderElement(self.tag,
                       type=self.type,
                       name=self.name,
                       id=self.name,
                       cssClass=self.cssClass,
                       extra=self.extra,
                       value="on",
                       **kw),
     )
 def setUpOptions(self):
     """Set up options to be rendered."""
     self.options = {}
     for option in ["personal", "package", "project"]:
         attributes = dict(type="radio",
                           name=self.name,
                           value=option,
                           id="%s.option.%s" % (self.name, option))
         if self.request.form_ng.getOne(self.name,
                                        self.default_option) == option:
             attributes["checked"] = "checked"
         if self._read_only:
             attributes["disabled"] = "disabled"
         self.options[option] = renderElement("input", **attributes)
Example #56
0
 def __call__(self):
     displayMaxWidth = self.displayMaxWidth or 0
     if displayMaxWidth > 0:
         return renderElement(self.tag,
                              type=self.type,
                              name=self.name,
                              id=self.name,
                              value='',
                              cssClass=self.cssClass,
                              style=self.style,
                              size=self.displayWidth,
                              maxlength=displayMaxWidth,
                              extra=self.extra)
     else:
         return renderElement(self.tag,
                              type=self.type,
                              name=self.name,
                              id=self.name,
                              value='',
                              cssClass=self.cssClass,
                              style=self.style,
                              size=self.displayWidth,
                              extra=self.extra)
 def setUpOptions(self):
     """Set up options to be rendered."""
     self.options = {}
     for option in ['personal', 'product']:
         attributes = dict(type='radio',
                           name=self.name,
                           value=option,
                           id='%s.option.%s' % (self.name, option))
         if self.request.form_ng.getOne(self.name,
                                        self.default_option) == option:
             attributes['checked'] = 'checked'
         self.options[option] = renderElement('input', **attributes)
     self.product_widget.onKeyPress = (
         "selectWidget('%s.option.product', event)" % self.name)
Example #58
0
 def _renderItem(self, index, text, value, name, cssClass, checked=False):
     # This is an almost-complete copy of the method in Zope.  We need it
     # to inject the style in the label, and we omit the "for" in the label
     # because it is redundant (and not used in legacy tests).
     kw = {}
     if checked:
         kw['checked'] = 'checked'
     value = html_escape(value)
     text = html_escape(text)
     id = '%s.%s' % (name, index)
     elem = renderElement(u'input',
                          value=value,
                          name=name,
                          id=id,
                          cssClass=cssClass,
                          type='radio',
                          **kw)
     if '<label' in text:
         return '%s&nbsp;%s' % (elem, text)
     else:
         return renderElement(u'label',
                              contents='%s&nbsp;%s' % (elem, text),
                              **{'style': 'font-weight: normal'})
Example #59
0
 def renderItems(self, value):
     """Render items of sequence."""
     items = []
     cssClass = self.cssClass or ''
     if cssClass:
         cssClass += "-item"
     tag = self.itemTag
     for item in value:
         term = self.vocabulary.getTerm(item)
         items.append(renderElement(
             tag,
             cssClass=cssClass,
             contents=escape(self.textForValue(term))))
     return items