Hide keyboard shortcuts

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 * 

4 

5def alert(alertText='', 

6 alertHeading="", 

7 extraPadding=False, 

8 alertLevel="warning"): 

9 """ *Generate a alert - TBS style* 

10 

11 **Key Arguments** 

12 

13 - ``alertText`` -- the text to be displayed in the alert 

14 - ``extraPadding`` -- for longer messages, increase the padding on the top and bottom of the alert wrapper 

15 - ``alertLevel`` -- the level of the alert [ "warning" | "error" | "success" | "info" ] 

16  

17 

18 **Return** 

19 

20 - ``alert`` -- the alert """ 

21 

22 

23 falseList = [extraPadding, ] 

24 for i in range(len(falseList)): 

25 if not falseList[i]: 

26 falseList[i] = "" 

27 [extraPadding, ] = falseList 

28 

29 if alertLevel == "default": 

30 alertLevel = "" 

31 else: 

32 alertLevel = "alert-%(alertLevel)s" % locals() 

33 

34 if extraPadding: 

35 extraPadding = "alert-block" 

36 alertHeading = "<h4>%(alertHeading)s</h4>" % locals() 

37 else: 

38 alertHeading = "<strong>%(alertHeading)s</strong>" % locals() 

39 

40 alert = \ 

41 """ 

42 <div class="alert %(extraPadding)s %(alertLevel)s"> 

43 <button type="button" class="close" data-dismiss="alert">&times;</button> 

44 %(alertHeading)s %(alertText)s 

45 </div>""" \ 

46 % locals() 

47 return alert