{% macro create_event_button(category, classes="", text="") %}
    {% block create_event_button scoped %}
        <ind-menu class="create-event-button">
            <button class="{{ classes }} i-button">{{- text -}}</button>
            <menu>
                <li>{{ create_event_link(category, 'lecture', _('Lecture')) }}</li>
                <li>{{ create_event_link(category, 'meeting', _('Meeting')) }}</li>
                <li>{{ create_event_link(category, 'conference', _('Conference')) }}</li>
            </menu>
        </ind-menu>
    {% endblock %}
{% endmacro %}

{% macro create_event_link(category, type, text) -%}
    {%- set title = {
        'lecture': _('Create new lecture'),
        'meeting': _('Create new meeting'),
        'conference': _('Create new conference')
    }[type] -%}
    {%- set url = url_for('categories.display', category, _anchor='create-event:%s:%d'|format(type, category.id))
                  if category and not category.is_root
                  else url_for_index(_anchor='create-event:%s'|format(type)) -%}
    <a href="{{ url if session.user else url_for_login(url) }}"
       {% if session.user %}
           data-href="{{ url_for('events.create', category, event_type=type) }}"
           data-title="{{ title }}"
           data-ajax-dialog
           data-ignore-href
       {% endif %}
       {{ kwargs | html_params }}>
        {{ text }}
    </a>
{%- endmacro %}
