예제 #1
0
 def html_hidden(self, context):
     """The HTML for a hidden input (<input type="hidden">)"""
     return html.input(
         type='hidden',
         id=context.id(self),
         name=context.name(self),
         value=context.default(self))
예제 #2
0
 def html(self, context):
     return html.input(
         type='password',
         name=context.name(self),
         value=context.default(self),
         maxlength=self.maxlength,
         size=self.size,
         style=self.style_width)
예제 #3
0
 def html(self, context):
     return html.input(
         type='image',
         name=context.name(self),
         value=self.description,
         src=self.img_src,
         height=self.img_height,
         width=self.img_width,
         border=self.border,
         alt=self.description)
예제 #4
0
 def html(self, context):
     accept = self.accept
     if accept and accept is not None:
         mime_list = ",".join(accept)
     else:
         mime_list = None
     return html.input(
         type='file',
         name=context.name(self),
         size=self.size,
         accept=mime_list)
예제 #5
0
 def html(self, context):
     js = self.javascript(context)
     color_picker_url = self.color_picker_url
     assert color_picker_url, (
         'You must give a base URL for the color picker')
     name = context.name(self)
     color_id = context.name(self, adding='pick')
     default_color = context.default(self) or '#ffffff'
     return html.table(
         cellspacing=0, border=0,
         c=[html.tr(
         html.td(width=20, id=color_id,
                 style="background-color: %s; border: thin black solid;" % default_color,
                 c=" "),
         html.td(
         html.input(type='text', size=8,
                    onchange="document.getElementById('%s').style.backgroundColor = this.value; return true" % color_id,
                    name=name, value=context.default(self)),
         html.input(type='button', value="pick",
                    onclick="colorpick(this, '%s', '%s')" % (name, color_id))))])
예제 #6
0
    def selection_html(self, selections, context):
        size = len(selections)
        
        if context.default(self):
            new_selections = []
            for default_value in context.default(self):
                for value, desc in selections:
                    if str(value) == str(default_value):
                        new_selections.append((value, desc))
                        break
            assert len(new_selections) == len(selections), (
                "Defaults don't match up with the cardinality of the "
                "selections")
            selections = new_selections

        encoded_value = ''
        for key, value in selections:
            encoded_value = encoded_value + urllib.quote(str(key)) + " "

        result = []
        result.append(
            html.select(
            name=context.name(self, adding='func'),
            size=size,
            c=[html.option(desc, value=value)
               for value, desc in selections]))
        result.append(html.br())
        for name, action in self.buttons(context):
            result.append(html.input(
                type='button',
                value=name,
                onclick=action))
        result.append(html.input(
            type='hidden',
            name=context.name(self),
            value=encoded_value))
        result.append(html.script(
            type='text/javascript',
            c=self.javascript(context)))
        return result
예제 #7
0
 def html(self, context):
     if self.confirm:
         query = ('return window.confirm(\'%s\')' % 
                  javascript_quote(self.confirm))
     else:
         query = None
     description = ((self.description) or 
                    self.default_description)
     return html.input(
         type='submit',
         name=context.name(self),
         value=description,
         onclick=query)
예제 #8
0
 def selection_html(self, selections, context):
     result = []
     id = 0
     for value, desc in selections:
         id = id + 1
         result.append(html.input(
             type='checkbox',
             name=context.name(self),
             id="%s_%i" % (context.name(self), id),
             value=value,
             checked=self.selected(value, context.default(self))
             and "checked" or None))
         result.append(html.label(
             " " + str(desc),
             for_="%s_%i" % (context.name(self), id)))
         result.append(html.br())
     return result
예제 #9
0
 def selection_html(self, selections, context):
     id = 0
     result = []
     for value, desc in selections:
         id = id + 1
         if self.selected(value, context.default(self)):
             checked = 'checked'
         else:
             checked = None
         result.append(html.input(
             type='radio',
             name=context.name(self),
             value=value,
             id="%s_%i" % (context.name(self), id),
             checked=checked))
         result.append(html.label(
             for_='%s_%i' % (context.name(self), id),
             c=desc))
         result.append(html.br())
     return result
예제 #10
0
 def html(self, context):
     return html.input(
         type='checkbox',
         name=context.name(self),
         checked = context.default(self) and "checked" or None)