Coverage for khufu/typography/a.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# encoding: utf-8
2from builtins import range
3from . import *
5def a(
6 content="",
7 href=False,
8 tableIndex=False,
9 thumbnail=False,
10 pull=False,
11 triggerStyle=False,
12 htmlClass=False,
13 htmlId=False,
14 notification=False,
15 postInBackground=False,
16 openInNewTab=False,
17 popover=False):
18 """
19 *Generate an anchor - TBS style*
21 **Key Arguments**
23 - ``content`` -- the content
24 - ``href`` -- the href link for the anchor
25 - ``tableIndex`` -- table index for the dropdown menus [ False | -1 ]
26 - ``pull`` -- direction to float the link (esp if image)
27 - ``triggerStyle`` -- link to be used as a dropDown or tab trigger? [ False | "dropdown" | "tab" | "thumbnail" ]
28 - ``htmlClass`` -- the class of the link
29 - ``htmlId`` -- the html id of the anchor
30 - ``postInBackground`` -- post to the href in the background, to fire data off to a cgi script to action without leaving page
31 - ``notification`` -- a notification to be displayed on webpage
32 - ``openInNewTab`` -- open the link in a new tab?
35 **Return**
37 - ``a`` -- the a
39 """
40 triggerClass = ""
41 dropdownCaret = ""
43 falseList = [href, triggerClass,
44 triggerStyle, tableIndex, dropdownCaret, pull]
45 for i in range(len(falseList)):
46 if not falseList[i]:
47 falseList[i] = ""
48 [href, triggerClass, triggerStyle,
49 tableIndex, dropdownCaret, pull] = falseList
51 if popover is False:
52 popover = ""
54 if openInNewTab is not False:
55 openInNewTab = """target="_blank" """
56 else:
57 openInNewTab = ""
59 if not htmlId:
60 htmlId = ""
61 else:
62 htmlId = 'id="%(htmlId)s"' % locals()
64 if notification is False:
65 notification = ""
66 else:
67 notification = """notification="%(notification)s" """ % locals()
69 if tableIndex is True:
70 tableIndex = """tableIndex = "%(tableIndex)s" """ % locals()
72 if thumbnail:
73 thumbnail = "thumbnail"
74 else:
75 thumbnail = ""
77 if htmlClass is False:
78 htmlClass = ""
80 if pull:
81 pull = "pull-%(pull)s" % locals()
83 if postInBackground is True:
84 postInBackground = "postInBackground"
85 else:
86 postInBackground = ""
88 if triggerStyle == "dropdown":
89 triggerClass = "dropdown-toggle"
90 triggerToggle = """data-toggle="dropdown" """
91 dropdownCaret = """<b class="caret"></b> """
92 elif triggerStyle in ["tab", "modal"]:
93 triggerToggle = """data-toggle="%(triggerStyle)s" """ % locals()
94 else:
95 triggerToggle = ""
97 a = """<a %(tableIndex)s href="%(href)s" %(popover)s class="%(triggerClass)s %(thumbnail)s %(pull)s %(htmlClass)s %(postInBackground)s" %(openInNewTab)s %(htmlId)s %(triggerToggle)s %(notification)s>%(content)s%(dropdownCaret)s</a>""" % locals()
99 return a