Updated Navigation menu for allowing for more than one row of hyperlinks...
svn: r18648
This commit is contained in:
parent
a0a19bce77
commit
b57f1b25cc
@ -1539,67 +1539,83 @@ class BasePage(object):
|
|||||||
('repositories', _("Repositories"), inc_repos),
|
('repositories', _("Repositories"), inc_repos),
|
||||||
("addressbook", _("Address Book"), self.report.inc_addressbook),
|
("addressbook", _("Address Book"), self.report.inc_addressbook),
|
||||||
('download', _("Download"), self.report.inc_download),
|
('download', _("Download"), self.report.inc_download),
|
||||||
('contact', _("Contact"), self.report.use_contact),
|
('contact', _("Contact"), self.report.use_contact)
|
||||||
]
|
]
|
||||||
|
|
||||||
# Remove menu sections if they are not being created?
|
# Remove menu sections if they are not being created?
|
||||||
navs = ((u, n) for u, n, c in navs if c)
|
navs = ((u, n) for u, n, c in navs if c)
|
||||||
|
menu_items = [[url, text] for url, text in navs]
|
||||||
|
|
||||||
|
number_items = len(menu_items)
|
||||||
|
num_cols = 9
|
||||||
|
num_rows = (number_items // num_cols) + 1
|
||||||
|
|
||||||
with Html("div", id ="navigation") as navigation:
|
with Html("div", id ="navigation") as navigation:
|
||||||
unordered = Html("ul")
|
|
||||||
navigation += unordered
|
index = 0
|
||||||
|
for rows in range(num_rows):
|
||||||
|
unordered = Html("ul")
|
||||||
|
navigation += unordered
|
||||||
|
|
||||||
for url_fname, nav_text in navs:
|
cols = 0
|
||||||
if not _has_webpage_extension(url_fname):
|
while (cols != num_cols and index < number_items):
|
||||||
url_fname += self.ext
|
url_fname, nav_text = menu_items[index]
|
||||||
|
|
||||||
url = self.report.build_url_fname(url_fname, None, self.up)
|
print(index, number_items, num_rows, url_fname, nav_text)
|
||||||
|
|
||||||
# Define 'currentsection' to correctly set navlink item CSS id
|
if not _has_webpage_extension(url_fname):
|
||||||
# 'CurrentSection' for Navigation styling.
|
url_fname += self.ext
|
||||||
# Use 'self.report.cur_fname' to determine 'CurrentSection' for individual
|
|
||||||
# elements for Navigation styling.
|
|
||||||
|
|
||||||
# Figure out if we need <li class="CurrentSection"> of just <li>
|
url = self.report.build_url_fname(url_fname, None, self.up)
|
||||||
cs = False
|
|
||||||
if nav_text == currentsection:
|
# Define 'currentsection' to correctly set navlink item CSS id
|
||||||
cs = True
|
# 'CurrentSection' for Navigation styling.
|
||||||
elif nav_text == _("Surnames"):
|
# Use 'self.report.cur_fname' to determine 'CurrentSection' for individual
|
||||||
if "srn" in self.report.cur_fname:
|
# elements for Navigation styling.
|
||||||
cs = True
|
|
||||||
elif _("Surnames") in currentsection:
|
# Figure out if we need <li class="CurrentSection"> of just <li>
|
||||||
cs = True
|
cs = False
|
||||||
elif nav_text == _("Individuals"):
|
if nav_text == currentsection:
|
||||||
if "ppl" in self.report.cur_fname:
|
cs = True
|
||||||
cs = True
|
elif nav_text == _("Surnames"):
|
||||||
elif nav_text == _("Families"):
|
if "srn" in self.report.cur_fname:
|
||||||
if "fam" in self.report.cur_fname:
|
cs = True
|
||||||
cs = True
|
elif _("Surnames") in currentsection:
|
||||||
elif nav_text == _("Sources"):
|
cs = True
|
||||||
if "src" in self.report.cur_fname:
|
elif nav_text == _("Individuals"):
|
||||||
cs = True
|
if "ppl" in self.report.cur_fname:
|
||||||
elif nav_text == _("Places"):
|
cs = True
|
||||||
if "plc" in self.report.cur_fname:
|
elif nav_text == _("Families"):
|
||||||
cs = True
|
if "fam" in self.report.cur_fname:
|
||||||
elif nav_text == _("Events"):
|
cs = True
|
||||||
if "evt" in self.report.cur_fname:
|
elif nav_text == _("Sources"):
|
||||||
cs = True
|
if "src" in self.report.cur_fname:
|
||||||
elif nav_text == _("Media"):
|
cs = True
|
||||||
if "img" in self.report.cur_fname:
|
elif nav_text == _("Places"):
|
||||||
cs = True
|
if "plc" in self.report.cur_fname:
|
||||||
elif nav_text == _("Address Book"):
|
cs = True
|
||||||
if "addr" in self.report.cur_fname:
|
elif nav_text == _("Events"):
|
||||||
cs = True
|
if "evt" in self.report.cur_fname:
|
||||||
|
cs = True
|
||||||
|
elif nav_text == _("Media"):
|
||||||
|
if "img" in self.report.cur_fname:
|
||||||
|
cs = True
|
||||||
|
elif nav_text == _("Address Book"):
|
||||||
|
if "addr" in self.report.cur_fname:
|
||||||
|
cs = True
|
||||||
|
|
||||||
|
cs = 'class = "CurrentSection"' if cs else False
|
||||||
|
if not cs:
|
||||||
|
unordered += Html("li", inline =True) + (
|
||||||
|
Html("a", nav_text, href =url, title =nav_text)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
unordered += Html("li", attr =cs, inline =True) + (
|
||||||
|
Html("a", nav_text, href =url, title =nav_text)
|
||||||
|
)
|
||||||
|
index += 1
|
||||||
|
cols += 1
|
||||||
|
|
||||||
cs = 'class = "CurrentSection"' if cs else False
|
|
||||||
if not cs:
|
|
||||||
unordered += Html("li", inline =True) + (
|
|
||||||
Html("a", nav_text, href =url, title =nav_text)
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
unordered += Html("li", attr =cs, inline =True) + (
|
|
||||||
Html("a", nav_text, href =url, title =nav_text)
|
|
||||||
)
|
|
||||||
# return navigation menu bar to its caller
|
# return navigation menu bar to its caller
|
||||||
return navigation
|
return navigation
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user