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 navBar( 

6 brand='', 

7 contentList=[], 

8 contentListPull=False, 

9 dividers=False, 

10 forms=False, 

11 fixedOrStatic=False, 

12 location='top', 

13 responsive=False, 

14 dark=False, 

15 transparent=False, 

16 htmlClass=False 

17): 

18 """ *Generate a navBar - TBS style* 

19 

20 **Key Arguments** 

21 

22 - ``brand`` -- the website brand [ image | text ] 

23 - ``contentList`` -- the content list of li and dropdowns 

24 - ``contentListPull`` -- False, right, left 

25 - ``fixedOrStatic`` -- Fix the navbar to the top or bottom of the viewport, or create a static full-width navbar that scrolls away with the page [ False | fixed | static ] 

26 - ``location`` -- location of the navigation bar if fixed or static 

27 - ``dark`` -- Modify the look of the navbar by making it dark 

28 - ``transparent`` -- make the bar see-through 

29  

30 

31 **Return** 

32 

33 - ``navBar`` -- the navBar """ 

34 

35 

36 if brand is not False: 

37 brand = u"""<a class="brand" href="#">%(brand)s</a>""" % locals() 

38 else: 

39 brand = u"" 

40 toggleButton = "" 

41 falseList = [dividers, fixedOrStatic, toggleButton, dark] 

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

43 if not falseList[i]: 

44 falseList[i] = "" 

45 [dividers, fixedOrStatic, toggleButton, dark] = falseList 

46 if dividers: 

47 dividers = u"""<li class="divider-vertical"></li>""" 

48 titleList = '' 

49 # contentList = '' 

50 count = 0 

51 

52 if htmlClass is False: 

53 htmlClass = "" 

54 

55 if contentListPull is not False: 

56 contentListPull = u"pull-%(contentListPull)s" % locals() 

57 

58 for item in contentList: 

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

60 titleList = u"""%(titleList)s %(item)s %(dividers)s""" % locals() 

61 

62 titleList = u""" 

63 <ul class="nav %(contentListPull)s" id=" "> 

64 %(titleList)s 

65 </ul> 

66 """ % locals() 

67 

68 formList = "" 

69 if forms: 

70 formList = forms 

71 

72 if fixedOrStatic: 

73 fixedOrStatic = u'navbar-%(fixedOrStatic)s-%(location)s' % locals() 

74 if responsive: 

75 toggleButton = \ 

76 u""" 

77 <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> 

78 <span class="icon-bar"></span> 

79 <span class="icon-bar"></span> 

80 <span class="icon-bar"></span> 

81 </a> 

82 """ 

83 titleList = u""" 

84 <div class="nav-collapse collapse"> 

85 %(titleList)s 

86 </div>""" \ 

87 % locals() 

88 if dark is True: 

89 dark = "navbar-inverse" 

90 else: 

91 dark = "" 

92 

93 if transparent is True: 

94 transparent = u"navbar-transparent" 

95 else: 

96 transparent = "" 

97 

98 navBar = \ 

99 u""" 

100 <div class="navbar %(fixedOrStatic)s %(dark)s %(transparent)s %(htmlClass)s"> 

101 <div class="navbar-inner"> 

102 %(brand)s 

103 %(titleList)s 

104 %(formList)s 

105 </div> 

106 </div> 

107 """ % locals() 

108 return navBar