Exemplo n.º 1
0
 def view_nth_level_only(self, params=None):
     n = int(params[0]) if params else 0
     classes = 'nth-level ' + ('horizontal' if not params or len(params) < 2 else params[1])
     hierarchy = section.get_top_level()
     while n:
         for h in hierarchy:
             if section.is_ancestor(self.section.path, h[0]['path']):
                 hierarchy = h[1]
         n -= 1
     parents_only = []
     for item, _ in hierarchy:
         item['is_ancestor'] = section.is_ancestor(self.section.path, item['path'])
         parents_only.append([item, []])
     self.section.css.append('nav-nth-level.css')
     return list_ul(self.section.path, parents_only, classes)
Exemplo n.º 2
0
 def view_nth_level_only(self, params=None):
     n = int(params[0]) if params else 0
     classes = 'nth-level ' + ('horizontal' if not params or len(params) < 2 else params[1])
     hierarchy = section.get_top_level()
     while n:
         for h in hierarchy:
             if section.is_ancestor(self.section.path, h[0]['path']):
                 hierarchy = h[1]
         n -= 1
     parents_only = []
     for item, _ in hierarchy:
         item['is_ancestor'] = section.is_ancestor(self.section.path, item['path'])
         parents_only.append([item, []])
     self.section.css.append('nav-nth-level.css')
     return list_ul(self.section.path, parents_only, classes)
Exemplo n.º 3
0
def set_ancestry(path, items):
    for item in items:
        if section.is_ancestor(path, item[0]['path']):
            item[0]['is_ancestor'] = True 
            item[1] = set_ancestry(path, item[1])
        else:
            item[0]['is_ancestor'] = False
    return items
Exemplo n.º 4
0
def set_ancestry(path, items):
    for item in items:
        if section.is_ancestor(path, item[0]['path']):
            item[0]['is_ancestor'] = True 
            item[1] = set_ancestry(path, item[1])
        else:
            item[0]['is_ancestor'] = False
    return items
Exemplo n.º 5
0
 def view_expanding_hierarchy(self, params=None):
     n = int(params[0]) if params else 0
     classes = 'expanding-hierarchy ' + ('vertical' if not params or len(params) < 2 else params[1])
     hierarchy = section.get_top_level()
     while n:
         for h in hierarchy:
             if section.is_ancestor(self.section.path, h[0]['path']):
                 hierarchy = h[1]
         n -= 1
     for item in hierarchy:
         if section.is_ancestor(self.section.path, item[0]['path']):
             item[0]['is_ancestor'] = True
             item[1] = set_ancestry_hide_others(self.section.path, item[1])
         else:
             item[0]['is_ancestor'] = False
             item[1] = None
     self.section.css.append('nav-expanding-hierarchy.css')
     return list_ul(self.section.path, hierarchy, classes)
Exemplo n.º 6
0
 def view_expanding_hierarchy(self, params=None):
     n = int(params[0]) if params else 0
     classes = 'expanding-hierarchy ' + ('vertical' if not params or len(params) < 2 else params[1])
     hierarchy = section.get_top_level()
     while n:
         for h in hierarchy:
             if section.is_ancestor(self.section.path, h[0]['path']):
                 hierarchy = h[1]
         n -= 1
     for item in hierarchy:
         if section.is_ancestor(self.section.path, item[0]['path']):
             item[0]['is_ancestor'] = True
             item[1] = set_ancestry_hide_others(self.section.path, item[1])
         else:
             item[0]['is_ancestor'] = False
             item[1] = None
     self.section.css.append('nav-expanding-hierarchy.css')
     return list_ul(self.section.path, hierarchy, classes)
Exemplo n.º 7
0
 def view_dropdown(self, params=None):
     n = int(params[0]) if params else 0
     dropdown_type = 'vertical' if not params or len(params) < 2 else params[1]
     classes = 'dropdown-' + dropdown_type
     hierarchy = section.get_top_level()
     while n:
         for h in hierarchy:
             if section.is_ancestor(self.section.path, h[0]['path']):
                 hierarchy = h[1]
         n -= 1
     hierarchy = set_ancestry(self.section.path, hierarchy)
     self.section.yuijs.append('yui/yui.js')
     if dropdown_type == 'horizontal':
         self.section.css.append('nav-dropdown-h.css')
         self.section.js.append('nav-dropdown-h.js')
     else:
         self.section.js.append('nav-dropdown-v.js')
     return list_ul(self.section.path, hierarchy, classes, dropdown_id=self.unique_identifier(), dropdown_type=dropdown_type)
Exemplo n.º 8
0
 def view_dropdown(self, params=None):
     n = int(params[0]) if params else 0
     dropdown_type = 'vertical' if not params or len(params) < 2 else params[1]
     classes = 'dropdown-' + dropdown_type
     hierarchy = section.get_top_level()
     while n:
         for h in hierarchy:
             if section.is_ancestor(self.section.path, h[0]['path']):
                 hierarchy = h[1]
         n -= 1
     hierarchy = set_ancestry(self.section.path, hierarchy)
     self.section.yuijs.append('yui/yui.js')
     if dropdown_type == 'horizontal':
         self.section.css.append('nav-dropdown-h.css')
         self.section.js.append('nav-dropdown-h.js')
     else:
         self.section.js.append('nav-dropdown-v.js')
     return list_ul(self.section.path, hierarchy, classes, dropdown_id=self.unique_identifier(), dropdown_type=dropdown_type)