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

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

#!/usr/local/bin/python 

# encoding: utf-8 

""" 

_dryxTBS_tables 

============================= 

:Summary: 

    Tables partial for dryxTwitterBootstrap 

 

:Author: 

    David Young 

 

:Date Created: 

    April 16, 2013 

 

:dryx syntax: 

    - ``xxx`` = come back here and do some more work 

    - ``_someObject`` = a 'private' object that should only be changed for debugging 

 

:Notes: 

    - If you have any questions requiring this script please email me: d.r.young@qub.ac.uk 

""" 

 

################################################################### 

# CLASSES                                                         # 

################################################################### 

 

################################################################### 

# PUBLIC FUNCTIONS                                                # 

################################################################### 

## LAST MODIFIED : April 16, 2013 

## CREATED : April 16, 2013 

## AUTHOR : DRYX 

def tr( 

        cellContent="", 

        color=False): 

    """Generate a table row - TBS style 

 

    **Key Arguments:** 

        - ``cellContent`` -- the content - either <td>s or <th>s 

        - ``color`` -- [ sucess | error | warning | info ] 

 

    **Return:** 

        - ``tr`` -- the table row 

    """ 

    if color is False: 

        color = "" 

 

    tr = """ 

        <tr class="%s"> 

            %s 

        </tr>""" % (color, cellContent,) 

 

    return tr 

 

 

## LAST MODIFIED : April 16, 2013 

## CREATED : April 16, 2013 

## AUTHOR : DRYX 

def th( 

        content="", 

        color=False): 

    """Generate a table header cell - TBS style 

 

    **Key Arguments:** 

        - ``content`` -- the content 

        - ``color`` -- [ sucess | error | warning | info ] 

 

    **Return:** 

        - ``th`` -- the table header cell 

    """ 

    if color is False: 

        color = "" 

 

    th = """ 

        <th class="%s"> 

            %s 

        </th>""" % (color, content,) 

 

    return th 

 

 

## LAST MODIFIED : April 16, 2013 

## CREATED : April 16, 2013 

## AUTHOR : DRYX 

def td( 

        content="", 

        color=False): 

    """Generate a table data cell - TBS style 

 

    **Key Arguments:** 

        - ``content`` -- the content 

        - ``color`` -- [ sucess | error | warning | info ] 

 

    **Return:** 

        - ``td`` -- the table data cell 

    """ 

    if color is False: 

        color = "" 

 

    td = """ 

        <td class="%s"> 

            %s 

        </td>""" % (color, content,) 

 

    return td 

 

 

## LAST MODIFIED : April 16, 2013 

## CREATED : April 16, 2013 

## AUTHOR : DRYX 

def tableCaption( 

        content=""): 

    """Generate a table caption - TBS style 

 

    **Key Arguments:** 

        - ``content`` -- the content 

 

    **Return:** 

        - ``tableCaption`` -- the table caption 

    """ 

    tableCaption = """ 

        <tableCaption class=""> 

            %s 

        </tableCaption>""" % (content,) 

 

    return tableCaption 

 

 

## LAST MODIFIED : April 16, 2013 

## CREATED : April 16, 2013 

## AUTHOR : DRYX 

def thead( 

        trContent=""): 

    """Generate a table head - TBS style 

 

    **Key Arguments:** 

        - ``trContent`` -- the table row content 

 

    **Return:** 

        - ``thead`` -- the table head 

    """ 

    thead = """ 

        <thead class=""> 

            %s 

        </thead>""" % (trContent,) 

 

    return thead 

 

 

## LAST MODIFIED : April 16, 2013 

## CREATED : April 16, 2013 

## AUTHOR : DRYX 

def tbody( 

        trContent=""): 

    """Generate a table body - TBS style 

 

    **Key Arguments:** 

        - ``trContent`` -- the table row content 

 

    **Return:** 

        - ``tbody`` -- the table body 

    """ 

    tbody = """ 

        <tbody class=""> 

            %s 

        </tbody>""" % (trContent,) 

 

    return tbody 

 

 

## LAST MODIFIED : April 16, 2013 

## CREATED : April 16, 2013 

## AUTHOR : DRYX 

def table( 

        caption="", 

        thead="", 

        tbody="", 

        stripped=True, 

        bordered=False, 

        hover=True, 

        condensed=False): 

    """Generate a table - TBS style 

 

    **Key Arguments:** 

        - ``caption`` -- the table caption 

        - ``thead`` -- the table head 

        - ``tbody`` -- the table body 

        - ``stripped`` -- Adds zebra-striping to any odd table row 

        - ``bordered`` -- Add borders and rounded corners to the table. 

        - ``hover`` -- Enable a hover state on table rows within a <tbody> 

        - ``condensed`` -- Makes tables more compact by cutting cell padding in half. 

 

    **Return:** 

        - ``table`` -- the table 

    """ 

    if stripped is True: 

        stripped = "table-stripped" 

    else: 

        stripped = "" 

 

    if bordered is True: 

        bordered = "table-bordered" 

    else: 

        bordered = "" 

 

    if hover is True: 

        hover = "table-hover" 

    else: 

        hover = "" 

 

    if condensed is True: 

        condensed = "table-condensed" 

    else: 

        condensed = "" 

 

    table = """ 

        <table class="table %s %s %s %s"> 

            %s 

            %s 

            %s 

        </table>""" % (stripped, bordered, hover, condensed, caption, thead, tbody) 

 

    return table 

 

################################################################### 

# PRIVATE (HELPER) FUNCTIONS                                      # 

################################################################### 

 

 

################################################################### 

# TEMPLATE FUNCTIONS                                              # 

###################################################################