40 lines
1.5 KiB
HTML
40 lines
1.5 KiB
HTML
{% if entries|length %}
|
|
<div class="pwa-navigation" id="pwa-navigation"
|
|
{% if include_user_name %}data-pwa-user-name="{% skeleton_extra_placeholder user-name %}{{user.get_full_name}}{% end_skeleton_extra_placeholder %}"{% endif %}>
|
|
<div>
|
|
<ul>
|
|
{% for entry in entries %}
|
|
<li class="{{ entry.css_class_names }}" data-entry-pk="{{ entry.pk }}"
|
|
{% if entry.notification_count %}data-notification-count-url="{{site_base}}/api/notification/count/"{% endif %}
|
|
{% if entry.use_user_name_as_label %}data-include-user-name{% endif %}>
|
|
<a href="{% if entry.link_page_id %}{{ site_base }}{% endif %}{{ entry.get_url }}"
|
|
{% if entry.icon %}style="background-image: url({{site_base}}{{entry.icon.url}});"{% endif %}
|
|
><span>{{ entry.get_label }}</span></a></li>
|
|
{% endfor %}
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
$('li[data-include-user-name]').each(function(idx, elem) {
|
|
var user_name = $(this).parents('#pwa-navigation').data('pwa-user-name');
|
|
if (user_name) {
|
|
$(this).find('span').text(user_name);
|
|
}
|
|
});
|
|
$('body.authenticated-user li[data-notification-count-url]').each(function(idx, elem) {
|
|
var $entry = $(this);
|
|
$.ajax({
|
|
url: $entry.data('notification-count-url'),
|
|
xhrFields: { withCredentials: true },
|
|
async: true,
|
|
dataType: 'json',
|
|
crossDomain: true,
|
|
success: function(data) {
|
|
if (data.new) {
|
|
$entry.find('span').append(' <span class="badge">' + data.new + '</span>');
|
|
}
|
|
}});
|
|
});
|
|
</script>
|
|
{% endif %}
|