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 

5 

6def ul( 

7 itemList=[], 

8 unstyled=False, 

9 inline=False, 

10 dropDownMenu=False, 

11 navStyle=False, 

12 navPull=False, 

13 navDirection="horizontal", 

14 breadcrumb=False, 

15 pager=False, 

16 thumbnails=False, 

17 mediaList=False, 

18 htmlId=False 

19): 

20 """ 

21 *Get An unordered list -- can be used for navigation, stacked tab and pill* 

22 

23 **Key Arguments** 

24 

25 - ``itemList`` -- a list of items to be included in the unordered list 

26 - ``unstyled`` -- is the list to be unstyled (first children only) 

27 - ``inline`` -- place all list items on a single line with inline-block and some light padding. 

28 - ``dropDownMenu`` -- is this ul to be used in a dropdown menu? [ false | true ] 

29 - ``navStyle`` -- set the navigation style if used for tabs & pills etc [ nav | tabs | pills | list ] 

30 - ``navPull`` -- set the alignment of the navigation links [ false | left | right ] 

31 - ``navDirection`` -- set the direction of the navigation [ 'default' | 'stacked' ] 

32 - ``breadcrumb`` -- display breadcrumb across muliple pages? [ False | True ] 

33 - ``pager`` -- use `<ul>` for a pager 

34 - ``thumbnails`` -- use the `<ul>` for a thumnail block? 

35 - ``mediaList`` -- use the `<ul>` for a media object list? 

36 - ``htmlId`` -- the html id of the ul 

37 

38 **Return** 

39 

40 - ``ul`` 

41 

42 """ 

43 role = False 

44 falseList = [unstyled, inline, dropDownMenu, role, navStyle, 

45 navPull, navDirection, breadcrumb, pager, thumbnails, mediaList] 

46 

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

48 if not falseList[i]: 

49 falseList[i] = "" 

50 

51 [unstyled, inline, dropDownMenu, role, navStyle, navPull, 

52 navDirection, breadcrumb, pager, thumbnails, mediaList] = falseList 

53 

54 thisList = "" 

55 for i, item in enumerate(itemList): 

56 if "<li" in item: 

57 thisList = """%(thisList)s %(item)s""" % locals() 

58 else: 

59 thisList = """%(thisList)s <li>%(item)s</li>""" % locals() 

60 if i + 1 != len(itemList) and breadcrumb: 

61 thisList = thisList[:-5] + \ 

62 """ <span class="divider">/</span></li>""" % locals() 

63 

64 if unstyled: 

65 unstyled = "unstyled" 

66 

67 if inline: 

68 inline = "inline" 

69 

70 if dropDownMenu is True: 

71 dropDownMenu = "dropdown-menu" 

72 role = "menu" 

73 

74 navStyleList = ["tabs", "pills", "list"] 

75 if navStyle: 

76 thisNavStyle = "nav" 

77 if navStyle in navStyleList: 

78 thisNavStyle = "%(thisNavStyle)s nav-%(navStyle)s" % locals() 

79 else: 

80 thisNavStyle = "" 

81 

82 if navPull: 

83 navPull = "pull-%(navPull)s" % locals() 

84 

85 if navDirection == "stacked": 

86 navDirection = "nav-stacked" 

87 elif navDirection == "horizontal": 

88 navDirection = "" 

89 else: 

90 navDirection = "" 

91 

92 if breadcrumb is True: 

93 breadcrumb = "breadcrumb" 

94 

95 if pager is True: 

96 pager = "pager" 

97 

98 if thumbnails is True: 

99 thumbnails = "thumbnails" 

100 

101 if mediaList is True: 

102 mediaList = "media-list" 

103 

104 if not htmlId: 

105 htmlId = "" 

106 else: 

107 htmlId = 'id="%(htmlId)s"' % locals() 

108 

109 ul = """<ul class="%(unstyled)s %(inline)s %(dropDownMenu)s %(role)s %(navPull)s %(thisNavStyle)s %(navDirection)s %(breadcrumb)s %(pager)s %(thumbnails)s %(mediaList)s" %(htmlId)s>%(thisList)s</ul>""" % locals( 

110 ) 

111 

112 return ul