def __call__(self, field, **kwargs):
		field_id = kwargs.pop('id', field.id)
		html = []
		allowed_formats = ['%d', '%m', '%Y', '%H', '%M', '%S']
		for format in field.format.split():
			if format in allowed_formats:	
				choices = self.FORMAT_CHOICES[format]
				id_suffix = format.replace('%', '-')
				id_current = field_id + id_suffix
				kwargs['class'] = self.FORMAT_CLASSES[format]
				try:
					del kwargs['placeholder']
				except:
					pass
				html.append('<select %s>' % html_params(name=field.name, id=id_current, **kwargs))
				if field.data:
					current_value = int(field.data.strftime(format))
				else:
					current_value = int(datetime.now().strftime(format))
				for value, label in choices:
					selected = (value == current_value)
					html.append(Select.render_option(value, label, selected))
				html.append('</select>')
			else:
				html.append(format)
				html.append('<input type="hidden" value="{0}" {1}></input>'.format(format, html_params(name=field.name, id=id_current, **kwargs)))
			html.append(' ')
			
		return HTMLString(''.join(html))
Exemplo n.º 2
0
    def render(self, table_id):
        """Render the table
        """
        # NB: in html_args, setting an argument to `False` makes it
        # disappear.
        html = []

        toolbar_args = html_params(id="{}-toolbar".format(table_id),
                                   class_="btn-toolbar",
                                   role="toolbar")
        html.append("<div {}>".format(toolbar_args))
        html += list(self.generate_toolbar())
        html.append("</div>")

        table_args = self.table_args
        table_args.update({
            'id': table_id,
            'data-toolbar': "#{}-toolbar".format(table_id),
        })

        html.append("<table {}>".format(html_params(**table_args)))
        html += list(self.generate_table_header())
        html += list(self.generate_table_footer())
        html.append("</table>")

        return Markup("\n".join(html))
Exemplo n.º 3
0
def list_widget(**kwargs):    
    
    div_class = kwargs.pop('div_class')
    field_model = kwargs.pop('model')
    field_id_select = kwargs.pop('id_select')

    if kwargs.has_key('options'):
        options = kwargs.pop('options')
    else:
        options = list()
        
    if type(options) != list:
        NameError('Opções da lista precisam ser do tipo list - Valor passado: ' + str(type(options)) )
    
    html = [u'<div  %s>' % html_params(**{'data-bind': 'with: $root.' + field_model, 'class': div_class})]
    html.append(u'<input %s/>' % html_params(**{'type':'text','data-bind': "value:itemToAdd, valueUpdate: 'afterkeydown'"}))
    html.append(u'&nbsp;')
    html.append(u'<button %s>' % html_params(**{'class':'btn btn-mini btn-info','data-bind':'enable: itemToAdd().length > 0, click: addItem'}))
    html.append(u'Adicionar')
    html.append(u'</button>')    
    html.append(u'<h6>Seus interesses</h6>')
    html.append(u'<select %s>' % html_params(**{'id': field_id_select, 'name': field_id_select ,'multiple': 'multiple', 'height': 5, 'data-bind': 'options:allItems, selectedOptions:selectedItems'}))
    if (options):        
        for option in options:
            html.append('<option value="%s">%s</option>' % (option, option))
    
    html.append(u'</select>')
    html.append(u'<div>')
    html.append(u'<button %s>' % html_params(**{'class': 'btn btn-mini btn-danger', 'data-bind':'click: removeSelected, enable: selectedItems().length > 0'}))
    html.append(u'Remover')
    html.append(u'</button>')
    html.append(u'</div>')
    html.append(u'</div>')
   
    return unescape(u''.join(html))
Exemplo n.º 4
0
 def __call__(self, field, **kwargs):
     attrs = dict(kwargs)
     btn_attrs = attrs.pop('btn_attrs', {})
     data_attrs = attrs.pop('data_attrs', {})
     btn_container_attrs = attrs.pop('btn_container_attrs', {})
     data_container_attrs = attrs.pop('data_container_attrs', {})
     btn_container = []
     data_container = []
     output = []
     for (option_value, option_label, selected) in field.iter_choices():
         btn = ButtonWidget()
         rendered_btn = btn(field, text=option_label, value=option_value, **btn_attrs)
         btn_container.append(rendered_btn)
         rb = Input('checkbox' if self.multiple else 'radio')
         if selected:
             rb_attrs = dict(data_attrs, value=option_value, checked='checked')
         else:
             rb_attrs = dict(data_attrs, value=option_value)
         rendered_rb = rb(field, id='{}_{}'.format(field.id, option_value), **rb_attrs)
         data_container.append(rendered_rb)
     btn = '<div %s>%s</div>' % (html_params(**btn_container_attrs), ' '.join(btn_container))
     data = '<div %s>%s</div>' % (html_params(**data_container_attrs), ' '.join(data_container))
     output.append(btn)
     output.append(data)
     return '\n'.join(output)
    def __call__(self, field, **kwargs):
        kwargs.setdefault('id', field.id)
        if field.data:
            file_url = self.upload_set.url(field.data)
            return HTMLString('<a href="%s" class="file-url">%s</a><input %s>' % (file_url,
                                                                 field.data,
                                                                 html_params(name=field.name, type='file', **kwargs)))

        else: 
            return HTMLString('<input %s>' % html_params(name=field.name, type='file', **kwargs))
Exemplo n.º 6
0
	def __call__(self, field, **kwargs):
		kwargs.setdefault('id', field.id)
		kwargs.setdefault('text', self.text)
		kwargs.setdefault('type', 'submit')
		kwargs.setdefault('glyph', self.glyph)

		if kwargs['glyph'] != '' :
			glyphclass = html_params(class_='glyphicon ' + kwargs['glyph'])
		else:
			glyphclass = ''

		return HTMLString('<button %s> <span %s> %s </span> </button>' % (html_params(name=field.name, **kwargs), glyphclass, kwargs['text']))
Exemplo n.º 7
0
def select_multi_checkbox(field, ul_class='', **kwargs):
  kwargs.setdefault('type', 'checkbox')
  field_id = kwargs.pop('id', field.id)
  html = [u'<ul %s>' % html_params(id=field_id, class_=ul_class)]
  for value, label, checked in field.iter_choices():
    choice_id = u'%s-%s' % (field_id, value)
    options = dict(kwargs, name=field.name, value=value, id=choice_id)
    if checked:
      options['checked'] = 'checked'
    html.append(u'<li><input %s /> ' % html_params(**options))
    html.append(u'<label for="%s">%s</label></li>' % (choice_id, label))
  html.append(u'</ul>')
  return u''.join(html)
Exemplo n.º 8
0
  def __call__(self, field, **kwargs):
    field_id        = kwargs.pop('id', field.id)
    html            = []
    allowed_format  = ['%d', '%m', '%Y', '%H', '%I', '%M', '%p']

    # Handle custom year ranges
    startyear = 2010
    endyear = 2020
    if 'startyear' in field.description:
        startyear = int(field.description['startyear'])
    if 'endyear' in field.description:
        endyear = int(field.description['endyear'])

    self.FORMAT_CHOICES['%Y'] = [(x, str(x)) for x in range(endyear, startyear, -1)]


    html.append('<div class="form-inline">')
    for format in field.format.split():
      if (format in allowed_format):
        choices     = self.FORMAT_CHOICES.get(format, [(None, 'Invalid Format')])
        id_suffix   = format.replace('%', '-')
        id_current  = field_id + id_suffix

        kwargs['class'] = self.FORMAT_CLASSES.get('format', 'form-control')
#        kwargs['class'] = 'form-control'
        kwargs['style'] = self.FORMAT_STYLES.get(format, '')
        try: del kwargs['placeholder']
        except: pass

        html.append('<select %s>' % html_params(name=field.name, id=id_current, **kwargs))

        if field.data:
            try: current_value = int(field.data.strftime(format))
            except: current_value = field.data.strftime(format)
        else:
            current_value = None

        for value, label in choices:
          selected = (value == current_value)
          html.append(Select.render_option(value, label, selected))
        html.append('</select>')
      else:
        html.append(format)
        html.append('<input type="hidden" value="'+format+'" %s></input>' % html_params(name=field.name, id=id_current, **kwargs))

      html.append(' ')

    html.append('</div>')

    return HTMLString(''.join(html))
Exemplo n.º 9
0
 def tempfunc(self, **kwargs):
     kwargs.setdefault('type',self.field_type)
     field_id = kwargs.pop('id',self.id)
     html = [u'<ul %s>'% html_params(id=field_id)]
     for value, label, checked in self.iter_choices():
         choice_id = u'%s-%s' % (field_id, value)
         options = dict(kwargs, name=self.name, value=value, id=choice_id)
         if checked:
              options['checked'] = 'checked'
         html.append(u'<li><label %s>' % html_params(class_="radio"))
         html.append(u'<input %s />'% html_params(**options))
         html.append(u'%s</label></li>' % label)
     html.append(u'</ul>')
     return HTMLString(u''.join(html))
Exemplo n.º 10
0
def render_list(field,**kwargs):
        kwargs.setdefault('type',field.field_type)
        field_id = kwargs.pop('id',field.id)
        html = [u'<ul %s>'% html_params(id=field_id,class_="unstyled")]
        for value, label, checked in field.iter_choices():
            choice_id = u'%s-%s' % (field_id, value)
            options = dict(kwargs, name=field.name, value=value, id=choice_id)
            if checked:
                 options['checked'] = 'checked'
            html.append(u'<li><label %s>' % html_params(class_=field.field_type))
            html.append(u'<input %s />'% html_params(**options))
            html.append(u'%s</label></li>' % label)
        html.append(u'</ul>')
        return HTMLString(u''.join(html))
Exemplo n.º 11
0
 def __call__(self, field, **kwargs):
     kwargs.setdefault('type', 'checkbox')
     field_id = kwargs.pop('id', field.id)
     html = []
     for value, label, checked in field.iter_choices():
         choice_id = u'%s-%s' % (field_id, value)
         options = dict(kwargs, name=field.name, value=value, id=choice_id)
         html.append(u'<label class="checkbox" %s>' % html_params(id=field_id))
         if checked:
             options['checked'] = 'checked'
         html.append(u'<input %s>' % html_params(**options))
         html.append(label)
         html.append(u'</label>')
     return u''.join(html)
Exemplo n.º 12
0
    def __call__(self, **kwargs):
        if self.horizontal:
            # kwargs.setdefault('class_', "radioField_horizontal")
            self.widget.prefix_label = True

            from wtforms.widgets.core import html_params, HTMLString

            kwargs.setdefault("id", self.id)
            kwargs.setdefault("class_", " table table-condensed likert")
            html = ["<%s %s>" % ("table", html_params(**kwargs))]
            html.append("<tr>")
            for subfield in self:
                html.append("<td>%s</td>" % (subfield.label))
            html.append("</tr>")
            html.append("<tr>")
            for subfield in self:
                html.append("<td>%s</td>" % (subfield()))
            html.append("</tr>")

            html.append("</%s>" % "table")
            return HTMLString("".join(html))
        else:
            kwargs.setdefault("class_", "radio")
            self.widget.prefix_label = False
            return super(MyRadioField, self).__call__(**kwargs)
Exemplo n.º 13
0
 def render_option(cls, name, value, label, selected, **kwargs):
     from cgi import escape
     options = dict(
         kwargs, 
         value=value,
         type='checkbox',
         id='%s-%s' % (name, value),
         name=name
     )
     if selected:
         options['checked'] = True
     return HTMLString(
         """\
         <li>
             <div class="checkbox">'
                 <label>
                     <input {params}></input>
                     {label}
                 </label>
             </div>
         </li>
         """
         .format(
             params=html_params(**options),
             label=escape(unicode(label)),
         )
     )
Exemplo n.º 14
0
 def render_option(cls, value, label, selected, **kwargs):
     value, tracker_id = value
     options = dict(kwargs, value=value)
     if selected:
         options['selected'] = True
     options['data-tracker_id'] = tracker_id
     return HTMLString('<option %s>%s</option>' % (html_params(**options), escape(text_type(label))))
Exemplo n.º 15
0
    def render_option(cls, value, label, mixed):
        """
        Render option as HTML tag, but not forget to wrap options into
        ``optgroup`` tag if ``label`` var is ``list`` or ``tuple``.
        """
        if isinstance(label, (list, tuple)):
            children = []

            for item_value, item_label in label:
                item_html = cls.render_option(item_value, item_label, mixed)
                children.append(item_html)

            html = u'<optgroup label="%s">%s</optgroup>'
            data = (escape(unicode(value)), u'\n'.join(children))
        else:
            coerce_func, data = mixed
            selected = coerce_func(value) == data

            options = {'value': value}

            if selected:
                options['selected'] = u'selected'

            html = u'<option %s>%s</option>'
            data = (html_params(**options), escape(unicode(label)))

        return HTMLString(html % data)
Exemplo n.º 16
0
 def __call__(self, field, **kwargs):
   kwargs.setdefault('id', field.id)
   html = [u'<select %s class="chzn-select">' % html_params(name=field.name, **kwargs)]
   for val, label, selected in field.iter_choices():
     html.append(self.render_option(val, label, selected))
   html.append(u'</select>')
   return HTMLString(u''.join(html))
Exemplo n.º 17
0
    def __call__(self, field, **kwargs):
        
        kwargs.setdefault('id', field.id)
        value = field._value()
        c = kwargs.pop('class', '') or kwargs.pop('class_', '')
        kwargs['class'] = u'%s %s' % (self.upload_class, c)

        html = ''
        hidden_field = ''

        if value:
            upload = field.data
            file_url = upload.file_url()
            thumb_url = upload.thumbnail_url()

            kwargs.setdefault('value', value)
            
            if upload.temp:
                hidden_field = '<input id="%s-plupload-aux" type="text" style="display: none;" name="%s-plupload-aux" value="%s">' % (field.name, field.name, upload.uuid)

            html = """
            <ul class="thumbnails aprovapp-form-thumb">
                <li id="gallery" data-toggle="modal-gallery" data-target="#modal-gallery">
                    <a href="%s" class="thumbnail" data-gallery="gallery"><img src="%s" alt="%s"/></a>
                </li>
            </ul>""" % (file_url, thumb_url, upload.original_filename)

        return HTMLString('<input %s>' % html_params(name=field.name, type='file', **kwargs) + hidden_field + html)
Exemplo n.º 18
0
	def __call__(self, field, **kwargs):
		kwargs.setdefault('id', field.id)
		kwargs.setdefault('type', self.input_type)
		kwargs.setdefault('text', field.name)
		if 'value' not in kwargs:
			kwargs['value'] = field._value()
		return HTMLString('<input %s> %s' % (html_params(name=field.name, **kwargs), kwargs['text']))
Exemplo n.º 19
0
 def __call__(self):
     if 'enctype' not in self.attributes:
         for field in self:
             if isinstance(field, FileField):
                 self.attributes['enctype'] = 'multipart/form-data'
                 break
     return HTMLString('<form {}>\n{}\n</form>'.format(
         html_params(**self.attributes), '\n'.join(field() for field in self)))
Exemplo n.º 20
0
    def __call__(self, field, **kwargs):
        kwargs.setdefault('id', field.id)
        if 'class_' in kwargs:
            kwargs['class_'] = 'form-control-static %s' % kwargs['class_']
        else:
            kwargs['class_'] = 'form-control-static'

        return Markup('<div %s>%s</div>' % (html_params(**kwargs), field._value()))
Exemplo n.º 21
0
 def __call__(self, field, **kwargs):
     kwargs.setdefault('id', field.id)
     if self.multiple:
         kwargs['multiple'] = True
     html = [u'<select %s>' % html_params(name=field.name, **kwargs)]
     for val, label, selected in field.iter_choices():
         #NEW STUFF
         if hasattr(label, '__iter__'):
             html.append(u'<optgroup %s>' % html_params(label=val))
             for v, l, s in self.iter_group(field, label):
                 html.append(self.render_option(v, l, s))
             html.append(u'</optgroup>')
         else:
             html.append(self.render_option(val, label, selected))
         #/NEW STUFF
     html.append(u'</select>')
     return HTMLString(u''.join(html))
Exemplo n.º 22
0
    def __call__(self, field, **kwargs):  # noqa: C901
        field_id = kwargs.pop('id', field.id)
        html = []
        allowed_format = ['%d', '%m', '%Y']
        surrounded_div = kwargs.pop('surrounded_div', None)
        css_class = kwargs.get('class', None)

        for date_format in field.format.split():
            if date_format in allowed_format:
                choices = self.FORMAT_CHOICES[date_format]
                id_suffix = date_format.replace('%', '-')
                id_current = field_id + id_suffix

                if css_class is not None:  # pragma: no cover
                    select_class = "{} {}".format(
                        css_class, self.FORMAT_CLASSES[date_format]
                    )
                else:
                    select_class = self.FORMAT_CLASSES[date_format]

                kwargs['class'] = select_class

                try:
                    del kwargs['placeholder']
                except KeyError:
                    pass

                if surrounded_div is not None:
                    html.append('<div class="%s">' % surrounded_div)

                html.append('<select %s>' % html_params(name=field.name,
                                                        id=id_current,
                                                        **kwargs))

                if field.data:
                    current_value = int(field.data.strftime(date_format))
                else:
                    current_value = None

                for value, label in choices:
                    selected = (value == current_value)

                    # Defaults to blank
                    if value == 1 or value == 1930:
                        html.append(
                            Select.render_option("None", " ", selected)
                        )

                    html.append(Select.render_option(value, label, selected))

                html.append('</select>')

                if surrounded_div is not None:
                    html.append("</div>")

            html.append(' ')

        return HTMLString(''.join(html))
Exemplo n.º 23
0
 def render_custom_option(self, field, value, label, selected, **kwargs):
     container_attrs = kwargs['container_attrs']
     data_attrs = kwargs['data_attrs']
     img_url = self.get_img_url(field, value)
     img_class = 'ui-selected' if selected else ''
     item_image = '<img class="%s" src="%s" alt="%s" title="%s" />' % (img_class, img_url, label, label)
     cb = Input('checkbox' if self.multiple else 'radio')
     rendered_cb = cb(field, id=False, value=value, checked=selected, **data_attrs)
     return '<span %s>%s%s</span>' % (html_params(**container_attrs), rendered_cb, item_image)
Exemplo n.º 24
0
 def __call__(self, field, **kwargs):
     kwargs["class_"] = u"form-control-static"
     # Assume that the field provides access to the value.
     value = field._value()
     return HTMLString(u''.join([
         u'<p {}>'.format(html_params(**kwargs)),
         value,
         u'</p>',
     ]))
Exemplo n.º 25
0
 def __call__(self, field, **kwargs):
     kwargs["data-provide"] = u"datepicker"
     for (option, value) in field.datepicker_options.items():
         attribute = 'data-date-{0}'.format(option.replace('_', '-'))
         kwargs[attribute] = value
     options = dict(kwargs, name=field.name)
     if field.data:
         options["value"] = field.data
     return HTMLString(u"<input {0}>".format(html_params(**options)))
Exemplo n.º 26
0
 def __call__(self, field, **kwargs):
     kwargs.setdefault('id', field.id)
     if self.multiple:
         kwargs['multiple'] = True
     html = ['<select %s multiple>' % html_params(name=field.name, **kwargs)]
     for val, label, selected in field.iter_choices():
         html.append(self.render_option(val, label, selected))
     html.append('</select>')
     return HTMLString(''.join(html))
Exemplo n.º 27
0
 def __call__(self, field, **kwargs):
     kwargs.setdefault('id', field.id)
     html=''
     html+='<div class=\"btn-toolbar m-b-sm btn-editor\" data-role=\"editor-toolbar\"data-target=\"#editor\"><div class=\"btn-group\"><a class=\"btn btn-default btn-sm dropdown-toggle\" data-toggle=\"dropdown\"        title=\"Font\"><i class=\"fa fa-font\"></i><b class=\"caret\"></b></a><ul class=\"dropdown-menu\"></ul></div><div class=\"btn-group\"><a class=\"btn btn-default btn-sm dropdown-toggle\" data-toggle=\"dropdown\"        title=\"Font Size\"><i class=\"fa fa-text-height\"></i>            &nbsp;<b class=\"caret\"></b></a><ul class=\"dropdown-menu\"><li><a data-edit=\"fontSize 5\"><font size=\"5\">                        Huge</font></a></li><li><a data-edit=\"fontSize 3\"><font size=\"3\">                        Normal</font></a></li><li><a data-edit=\"fontSize 1\"><font size=\"1\">                        Small</font></a></li></ul></div><div class=\"btn-group\"><a class=\"btn btn-default btn-sm\" data-edit=\"bold\" title=\"Bold (Ctrl/Cmd+B)\"><i class=\"fa fa-bold\"></i></a><a class=\"btn btn-default btn-sm\" data-edit=\"italic\" title=\"Italic (Ctrl/Cmd+I)\"><i class=\"fa fa-italic\"></i></a><a class=\"btn btn-default btn-sm\" data-edit=\"strikethrough\" title=\"Strikethrough\"><i class=\"fa fa-strikethrough\"></i></a><a class=\"btn btn-default btn-sm\" data-edit=\"underline\" title=\"Underline (Ctrl/Cmd+U)\"><i class=\"fa fa-underline\"></i></a></div><div class=\"btn-group\"><a class=\"btn btn-default btn-sm\" data-edit=\"insertunorderedlist\" title=\"Bullet list\"><i class=\"fa fa-list-ul\"></i></a><a class=\"btn btn-default btn-sm\" data-edit=\"insertorderedlist\" title=\"Number list\"><i class=\"fa fa-list-ol\"></i></a><a class=\"btn btn-default btn-sm\" data-edit=\"outdent\" title=\"Reduce indent (Shift+Tab)\"><i class=\"fa fa-dedent\"></i></a><a class=\"btn btn-default btn-sm\" data-edit=\"indent\" title=\"Indent (Tab)\"><i class=\"fa fa-indent\"></i></a></div><div class=\"btn-group\"><a class=\"btn btn-default btn-sm\" data-edit=\"justifyleft\" title=\"Align Left (Ctrl/Cmd+L)\"><i class=\"fa fa-align-left\"></i></a><a class=\"btn btn-default btn-sm\" data-edit=\"justifycenter\" title=\"Center (Ctrl/Cmd+E)\"><i class=\"fa fa-align-center\"></i></a><a class=\"btn btn-default btn-sm\" data-edit=\"justifyright\" title=\"Align Right (Ctrl/Cmd+R)\"><i class=\"fa fa-align-right\"></i></a><a class=\"btn btn-default btn-sm\" data-edit=\"justifyfull\" title=\"Justify (Ctrl/Cmd+J)\"><i class=\"fa fa-align-justify\"></i></a></div><div class=\"btn-group\"><a class=\"btn btn-default btn-sm dropdown-toggle\" data-toggle=\"dropdown\"        title=\"Hyperlink\"><i class=\"fa fa-link\"></i></a><div class=\"dropdown-menu\"><div class=\"input-group m-l-xs m-r-xs\"><input class=\"form-control input-sm\" placeholder=\"URL\" type=\"text\" data-edit=\"createLink\"                /><div class=\"input-group-btn\"><button class=\"btn btn-default btn-sm\" type=\"button\">                        Add</button></div></div></div><a class=\"btn btn-default btn-sm\" data-edit=\"unlink\" title=\"Remove Hyperlink\"><i class=\"fa fa-cut\"></i></a></div><div class=\"btn-group hide\"><a class=\"btn btn-default btn-sm\" title=\"Insert picture (or just drag & drop)\"        id=\"pictureBtn\"><i class=\"fa fa-picture-o\"></i></a><input type=\"file\" data-role=\"magic-overlay\" data-target=\"#pictureBtn\"        data-edit=\"insertImage\" /></div><div class=\"btn-group\"><a class=\"btn btn-default btn-sm\" data-edit=\"undo\" title=\"Undo (Ctrl/Cmd+Z)\"><i class=\"fa fa-undo\"></i></a><a class=\"btn btn-default btn-sm\" data-edit=\"redo\" title=\"Redo (Ctrl/Cmd+Y)\"><i class=\"fa fa-repeat\"></i></a></div></div>'
     html+='<textarea class=\"hide flask-wysiwyg\"   data-editor=\"editor\" %s>%s</textarea>'
     html+='<div id=\"editor\"   style=\"overflow:scroll;height:150px;max-height:150px\"  class="bootstrap-wysiwyg form-control" >%s</div>'
     
     
     return HTMLString(html % (html_params(name=field.name, **kwargs), escape(text_type(field._value())),escape(text_type(field._value()))))
Exemplo n.º 28
0
    def __call__(self, field, **kwargs):
        kwargs.setdefault('id', field.id)
        kwargs.setdefault('data-dojo-type', self.dojo_type)

        html = ['<select %s>' % html_params(name=field.name, **kwargs)]
        for val, label, selected in field.iter_choices():
            html.append(self.render_option(val, label, selected))
        html.append('</select>')
        return HTMLString(''.join(html))
Exemplo n.º 29
0
 def __call__(self, field, **kwargs):
     kwargs.setdefault('id', field.id)
     html=''
     html+='<div class=\"btn-toolbar\" data-role=\"editor-toolbar\" data-target=\"#editor\">'
     html+='      <div class=\"btn-group\">'
     html+='        <a class=\"btn dropdown-toggle\" data-toggle=\"dropdown\" title=\"Font\"><i class=\"icon-font\"></i><b class=\"caret\"></b></a>'
     html+='          <ul class=\"dropdown-menu\">'
     html+='          </ul>'
     html+='        </div>'
     html+='      <div class=\"btn-group\">'
     html+='        <a class=\"btn dropdown-toggle\" data-toggle=\"dropdown\" title=\"Font Size\"><i class=\"icon-text-height\"></i>&nbsp;<b class=\"caret\"></b></a>'
     html+='          <ul class=\"dropdown-menu\">'
     html+='          <li><a data-edit=\"fontSize 5\"><font size=\"5\">Huge</font></a></li>'
     html+='          <li><a data-edit=\"fontSize 3\"><font size=\"3\">Normal</font></a></li>'
     html+='          <li><a data-edit=\"fontSize 1\"><font size=\"1\">Small</font></a></li>'
     html+='          </ul>'
     html+='      </div>'
     html+='      <div class=\"btn-group\">'
     html+='        <a class=\"btn\" data-edit=\"bold\" title=\"Bold (Ctrl/Cmd+B)\"><i class=\"icon-bold\"></i></a>'
     html+='        <a class=\"btn\" data-edit=\"italic\" title=\"Italic (Ctrl/Cmd+I)\"><i class=\"icon-italic\"></i></a>'
     html+='        <a class=\"btn\" data-edit=\"strikethrough\" title=\"Strikethrough\"><i class=\"icon-strikethrough\"></i></a>'
     html+='        <a class=\"btn\" data-edit=\"underline\" title=\"Underline (Ctrl/Cmd+U)\"><i class=\"icon-underline\"></i></a>'
     html+='      </div>'
     html+='      <div class=\"btn-group\">'
     html+='        <a class=\"btn\" data-edit=\"insertunorderedlist\" title=\"Bullet list\"><i class=\"icon-list-ul\"></i></a>'
     html+='        <a class=\"btn\" data-edit=\"insertorderedlist\" title=\"Number list\"><i class=\"icon-list-ol\"></i></a>'
     html+='        <a class=\"btn\" data-edit=\"outdent\" title=\"Reduce indent (Shift+Tab)\"><i class=\"icon-indent-left\"></i></a>'
     html+='        <a class=\"btn\" data-edit=\"indent\" title=\"Indent (Tab)\"><i class=\"icon-indent-right\"></i></a>'
     html+='      </div>'
     html+='      <div class=\"btn-group\">'
     html+='        <a class=\"btn\" data-edit=\"justifyleft\" title=\"Align Left (Ctrl/Cmd+L)\"><i class=\"icon-align-left\"></i></a>'
     html+='        <a class=\"btn\" data-edit=\"justifycenter\" title=\"Center (Ctrl/Cmd+E)\"><i class=\"icon-align-center\"></i></a>'
     html+='        <a class=\"btn\" data-edit=\"justifyright\" title=\"Align Right (Ctrl/Cmd+R)\"><i class=\"icon-align-right\"></i></a>'
     html+='        <a class=\"btn\" data-edit=\"justifyfull\" title=\"Justify (Ctrl/Cmd+J)\"><i class=\"icon-align-justify\"></i></a>'
     html+='      </div>'
     html+='      <div class=\"btn-group\">'
     html+='		  <a class=\"btn dropdown-toggle\" data-toggle=\"dropdown\" title=\"Hyperlink\"><i class=\"icon-link\"></i></a>'
     html+='		    <div class=\"dropdown-menu input-append\">'
     html+='			    <input class=\"span2\" placeholder=\"URL\" type=\"text\" data-edit=\"createLink\"/>'
     html+='			    <button class=\"btn\" type=\"button\">Add</button>'
     html+='        </div>'
     html+='        <a class=\"btn\" data-edit=\"unlink\" title=\"Remove Hyperlink\"><i class=\"icon-cut\"></i></a>'
     html+='      </div>'
     html+='      <div class=\"btn-group\">'
     html+='        <a class=\"btn\" title=\"Insert picture (or just drag & drop)\" id=\"pictureBtn\"><i class=\"icon-picture\"></i></a>'
     html+='        <input type=\"file\" data-role=\"magic-overlay\" data-target=\"#pictureBtn\" data-edit=\"insertImage\" />'
     html+='      </div>'
     html+='      <div class=\"btn-group\">'
     html+='        <a class=\"btn\" data-edit=\"undo\" title=\"Undo (Ctrl/Cmd+Z)\"><i class=\"icon-undo\"></i></a>'
     html+='        <a class=\"btn\" data-edit=\"redo\" title=\"Redo (Ctrl/Cmd+Y)\"><i class=\"icon-repeat\"></i></a>'
     html+='      </div>'
     html+='      <input type=\"text\" data-edit=\"inserttext\" id=\"voiceBtn\" x-webkit-speech=\"\">'
     html+='    </div> '
     html+='    <div id=\"editor\" %s>%s</div> '        
     
     return HTMLString(html % (html_params(name=field.name, **kwargs), escape(text_type(field._value()))))
Exemplo n.º 30
0
 def generate_toolbar(self):
     """An “add fee” button"""
     args = {
         'class': "btn btn-primary",
         'href': url_for(".membership_fee_create")
     }
     yield "<a {}>".format(html_params(**args))
     yield "<span class=\"glyphicon glyphicon-plus\"></span>"
     yield gettext("Beitrag erstellen")
     yield "</a>"
Exemplo n.º 31
0
    def __call__(self, field, **kwargs):
        kwargs.setdefault('id', field.id)
        if 'required' not in kwargs and 'required' in getattr(
                field, 'flags', []):
            kwargs['required'] = True

        # TODO use proper HTML generation
        html = ""
        html += '<div class="btn-group btn-group-toggle" data-toggle="buttons">\n'

        for choice in field.choices:
            value, desc = choice
            html += '<label class="btn btn-secondary switch-%s">' % value
            html += '<input type="radio" %s>' % html_params(name=field.name,
                                                            value=value,
                                                            checked=(field.data
                                                                     == value),
                                                            **kwargs)
            html += desc
            html += '</label>\n'

        html += '</div>\n'

        return Markup(html)
Exemplo n.º 32
0
 def __call__(self, field, **kwargs):
     kwargs.setdefault('id', field.id)
     return HTMLString(
         '<input %s>' %
         html_params(name=field.name, multiple='', type='file', **kwargs))
Exemplo n.º 33
0
 def test_quoting(self):
     assert html_params(foo='hi&bye"quot') == 'foo="hi&amp;bye&#34;quot"'
Exemplo n.º 34
0
 def test_aria_prefix(self):
     assert html_params(aria_foo="bar") == 'aria-foo="bar"'
     assert html_params(aria_foo_bar="foobar") == 'aria-foo-bar="foobar"'
Exemplo n.º 35
0
 def test_data_prefix(self):
     assert html_params(data_foo=22) == 'data-foo="22"'
     assert html_params(data_foo_bar=1) == 'data-foo-bar="1"'
Exemplo n.º 36
0
 def __call__(self, field, text='', **kwargs):
     return '<button %s>%s</button>' % (html_params(**kwargs), text)
Exemplo n.º 37
0
 def __call__(self, field, **kwargs):
     kwargs.setdefault('id', field.id)
     return HTMLString('<textarea rows="10" cols="100" '
                       '%s>%s</textarea>' % (
                           html_params(name=field.name, **kwargs),
                           escape(text_type(field._value()))))