Coverage for khufu/modals/modal.py : 86%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/bin/env python
2# encoding: utf-8
3"""
4*Modal*
6:Author:
7 David Young
8"""
9import sys
10import os
12def modal(
13 modalHeaderContent="",
14 modalBodyContent="",
15 modalFooterContent="",
16 htmlId=False,
17 centerContent=False,
18 htmlClass=False
19):
20 """
21 *generate a modal to by generated with a js event*
23 **Key Arguments**
26 - ``modalHeaderContent`` -- the heading for the modal
27 - ``modalBodyContent`` -- the content (form or text)
28 - ``modalFooterContent`` -- the foot (usually buttons)
29 - ``htmlId`` -- id for button to hook onto with href
30 - ``centerContent`` - center the content in the form?
31 - ``htmlClass`` - htmlClass for the form
33 **Return**
35 - ``modal`` -- the modal
37 """
38 if htmlClass is False:
39 htmlClass = ""
41 if htmlId is False:
42 htmlId = ""
43 else:
44 htmlId = """id="%(htmlId)s" """ % locals()
45 if centerContent is False:
46 centerContent = ""
47 else:
48 centerContent = "center-content"
50 ## VARIABLES ##
51 modal = """<div class="modal hide fade %(htmlClass)s" %(htmlId)s>
52 <div class="modal-header">
53 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
54 <h3>%(modalHeaderContent)s</h3>
55 </div>
56 <div class="modal-body %(centerContent)s">
57 %(modalBodyContent)s
58 </div>
59 <div class="modal-footer">
60 %(modalFooterContent)s
61 </div>
62 </div>""" % locals()
64 return modal