From 5685d3f387d60484b24769844488a866a08c6e6b Mon Sep 17 00:00:00 2001 From: Sean O'Brien Date: Sat, 10 Mar 2012 11:18:49 -0500 Subject: fixes to boostrap, new icons, mobile view works --- menu.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'menu.py') diff --git a/menu.py b/menu.py index 3e682e4..79f2205 100644 --- a/menu.py +++ b/menu.py @@ -5,11 +5,15 @@ import cfg class Menu(): """One menu item.""" - def __init__(self, label="", url="#", order=50): + def __init__(self, label="", icon="", url="#", order=50): """label is the text that is displayed on the menu. + icon is the icon to be displayed next to the label. + Choose from the Glyphicon set: + http://twitter.github.com/bootstrap/base-css.html#icons + url is the url location that will be activated when the menu - item is selected + item is selected. order is the numerical rank of this item within the menu. Lower order items appear closest to the top/left of the menu. @@ -20,14 +24,15 @@ class Menu(): """ self.label = label - self.order = order + self.icon = icon self.url = url + self.order = order self.items = [] def sort_items(self): """Sort the items in self.items by order.""" self.items = sorted(self.items, key=lambda x: x.order, reverse=False) - def add_item(self, label, url, order=50, basehref=True): + def add_item(self, label, icon, url, order=50, basehref=True): """This method creates a menu item with the parameters, adds that menu item to this menu, and returns the item. @@ -36,7 +41,7 @@ class Menu(): if basehref and url.startswith("/"): url = cfg.base_href + url - item = Menu(label=label, url=url, order=order) + item = Menu(label=label, icon=icon, url=url, order=order) self.items.append(item) self.sort_items() return item @@ -61,7 +66,7 @@ class Menu(): so = [] for item in self.items: - i = { 'label':item.label, 'url':item.url} + i = { 'label':item.label, 'icon':item.icon, 'url':item.url} if item.active_p(): i['active']=True if item.items and render_subs: @@ -74,7 +79,7 @@ class Menu(): if render_subs is True, we render submenus too""" - return ('') + + ';\n // -->\n ') -- cgit v1.2.3