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
def generate(self): heading, body, panel_type, expand = self.args # noinspection PyUnresolvedReferences template = '<!-- Collapsable panel start -->\n' \ ' <div class="panel {panel_type}">\n' \ ' <div class="panel-heading">\n' \ ' <h4 class="panel-title">\n' \ ' <a data-toggle="collapse" data-target="#{panel_id}" href="#{panel_id}">\n' \ ' {heading}\n' \ ' </a>\n' \ ' </h4>\n' \ ' </div>\n' \ ' <div id="{panel_id}" class="panel-collapse collapse {expand}">\n' \ ' <div class="panel-body">\n' \ ' {content}\n' \ ' </div>\n' \ ' </div>\n' \ ' </div>\n' \ '<!-- Accordion panel end -->' panel_id = unique_name('apm_id') expand = 'in' if expand else '' rtn = template.format(panel_id=panel_id, panel_type=panel_type, heading=heading, content=body, expand=expand) return rtn
def __init__(self, accordion_panels): assert isinstance(accordion_panels, (list, tuple)) accordion_id = unique_name('aid') for p in accordion_panels: # set accordion id in our panels p.accordion_id = accordion_id super(Accordion, self).__init__(accordion_id, accordion_panels)