{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{< core/popover_region }}
    {{$classes}}popover-region-mail{{/classes}}

    {{$attributes}}
        id="nav-mail-popover-container"
    {{/attributes}}

    {{$togglelabel}}{{#str}} togglemailmenu, local_mail {{/str}}{{/togglelabel}}

    {{$togglecontent}}
        {{#pix}} icon, local_mail, {{#str}} togglemailmenu, local_mail {{/str}} {{/pix}}
        {{#count}}
        <div class="count-container">{{.}}</div>
        {{/count}}
    {{/togglecontent}}

    {{$containerlabel}}{{#str}} mailmenu, local_mail {{/str}}{{/containerlabel}}

    {{$headertext}}{{#str}} pluginname, local_mail {{/str}}{{/headertext}}

    {{$headeractions}}
        <a href="{{{composeurl}}}" class="mail-navbar-menu-compose-link">
            {{#str}} compose, local_mail {{/str}}
        </a>
        <a href="{{{preferencesurl}}}" title="{{#str}} preferences, core {{/str}}">
            {{#pix}} i/settings, core, {{#str}} preferences, core {{/str}} {{/pix}}
        </a>
    {{/headeractions}}

    {{$content}}
        <div class="mail-navbar-menu">
            {{#items}}
            <a href="{{{url}}}" {{#title}}title="{{.}}"{{/title}}
                class="mail-navbar-menu-item
                    {{#active}}mail-navbar-menu-item-active{{/active}}
                    {{#dimmed}}dimmed_text{{/dimmed}}">
                {{#unread}}<span class="badge badge-important">{{.}}</span>{{/unread}}
                {{#drafts}}<span class="badge">{{.}}</span>{{/drafts}}
                {{#icon}}{{#pix}} {{.}}, local_mail, {{/pix}}{{/icon}}
                {{#text}}{{.}}{{/text}}
            </a>
            {{/items}}
        </div>
    {{/content}}
{{/ core/popover_region }}

{{#js}}
require(['jquery', 'core/popover_region_controller'], function($, controller) {
    var container = $('#nav-mail-popover-container');
    var controller = new controller(container);
    controller.registerListNavigationEventListeners();
});
{{/js}}
