Пример #1
0
 def __init__(self, text='Submit', button='btn-primary', size='', classes='', style=''):
     template = '\n<!-- form button -->\n' \
                '<input type="submit" value="{text}" ' \
                '   class="btn {button} {size} {classes}" style="{style}" />\n' \
                '<!-- / form button -->\n'
     button = ssw(button, 'btn-')
     size = ssw(size, 'btn-')
     super(FormButton, self).__init__(template, {'text': text,
                                                 'button': button, 'size': size,
                                                 'classes': classes, 'style': style})
Пример #2
0
 def __init__(self, text='Show', button='btn-default', size='',
              disabled=False, classes='', style=''):
     template = '<button class="btn {button} {size} {classes}" style="{style}" ' \
                '    {disabled} data-toggle="modal" data-target="#{modal_id}">\n' \
                '    {text}\n' \
                '</button>\n'
     button = ssw(button, 'btn-')
     size = ssw(size, 'btn-')
     disabled = 'disabled="disabled"' if disabled else ''
     modal_id = None
     super(ModalButton, self).__init__(template, {'modal_id': modal_id, 'text': text,
                                                  'button': button, 'size': size, 'disabled': disabled,
                                                  'classes': classes, 'style': style})
     return
Пример #3
0
 def __init__(self, header='', body='Body must be defined', footer='', button='Show', modal_size=''):
     modal_id = unique_name('id_m')
     modal_label = unique_name('lbl_m')
     if button and not isinstance(button, ModalButton):
         button = ModalButton(button)
     button.set_modal_id(modal_id)
     if header and not isinstance(header, ModalHeader):
         header = ModalHeader(header)
     if body and not isinstance(body, ModalBody):
         body = ModalBody(body)
     if footer and not isinstance(footer, ModalFooter):
         footer = ModalFooter(footer)
     template = '<!-- Modal --> \n' \
                '{button}\n' \
                '<div class="modal fade" id={modal_id} tabindex="-1" role="dialog" ' \
                '    aria-labelledby="{modal_label}" aria-hidden="True">\n' \
                '    <div class="modal-dialog {modal_size}">\n' \
                '        <div class="modal-content">\n' \
                '{header}\n' \
                '{body}\n' \
                '{footer}\n' \
                '        </div>\n' \
                '    </div>\n' \
                '</div>\n' \
                '<!-- / Modal --> \n'
     modal_size = ssw(modal_size, 'modal-')
     super(Modal, self).__init__(template,
                                 {'header': header, 'body': body, 'footer': footer, 'button': button,
                                  'modal_size': modal_size, 'modal_id': modal_id, 'modal_label': modal_label})
     return
Пример #4
0
 def generate(self):
     """ Bootstrap glyphicon """
     glyph, classes, style = self.args
     if isinstance(glyph, (tuple, list)):
         rtn = ''
         for g in glyph:
             rtn += Glyphicon(g, classes, style)
         return rtn
     template = '<span class="glyphicon {glyph} {classes}" style="{style}"></span>'
     glyph = ssw(glyph, 'glyphicon-')
     rtn = template.format(glyph=glyph, classes=classes, style=style)
     return rtn
Пример #5
0
 def generate(self):
     """ Bootstrap button """
     text, button, size, disabled, classes, style = self.args
     template = '<!-- start of button -->\n' \
                '    <button type="button" class="btn {button} {size} {classes}" style="{style}" {disabled}>\n' \
                '        {text}\n' \
                '    </button>\n' \
                '<!-- end of button -->\n'
     if isinstance(text, (tuple, list)):
         rtn = ''
         for t in text:
             rtn += Button(t, button, size, disabled, classes, style)
         return rtn
     button = ssw(button, 'btn-')
     size = ssw(size, 'btn-')
     if disabled:
         disabled = 'disabled="disabled" '
     else:
         disabled = ''
     rtn = template.format(button=button, size=size, classes=classes, style=style, disabled=disabled, text=text)
     return rtn