<%! from django.utils.translation import ugettext as _ %>
<%! import json %>

<%def name="render_dropdown(map)">
    % for child in map["children"]:
        % if child in map["entries"]:
            ${render_entry(map["entries"], child)}
        %else:
            ${render_category(map["subcategories"], child)}
        %endif
    %endfor
</%def>

<%def name="render_entry(entries, entry)">
    <li><a href="#" class="drop-menu-entry"><span class="board-name" data-discussion_id='${json.dumps(entries[entry])}' cohorted = "${entries[entry]['id'] in cohorted_commentables}">${entry}</span></a></li>
</%def>

<%def name="render_category(categories, category)">
    <li>
        <a href="#" class="drop-menu-parent-category"><span class="board-name">${category}</span></a>
        <ul>
            ${render_dropdown(categories[category])}
        </ul>
    </li>
</%def>

<div class="browse-topic-drop-menu-wrapper">
    <div class="browse-topic-drop-search">
        <label class="sr" for="browse-topic">${_("Filter Topics")}</label>
        <input type="text" id="browse-topic" class="browse-topic-drop-search-input" placeholder="filter topics">
    </div>
    <ul class="browse-topic-drop-menu">
        <li>
            <a href="#" class="drop-menu-meta-category">
                <span class="board-name" data-discussion_id='#all'>${_("Show All Discussions")}</span>
            </a>
        </li>
        %if flag_moderator:
        <li>
            <a href="#">
                <span class="board-name" data-discussion_id='#flagged'><i class="icon-flag" style="padding-right:5px;"></i>${_("Show Flagged Discussions")}</span>
            </a>
        </li>
        
        %endif
        <li>
            <a href="#" class="drop-menu-meta-category">
                <span class="board-name" data-discussion_id='#following'><i class="icon-star" style="padding-right:5px;"></i>${_("Posts I'm Following")}</span>
            </a>
        </li>
        ${render_dropdown(category_map)}
    </ul>
</div>
