touch up front end of notification system

This commit is contained in:
iou1name 2018-10-16 13:09:53 -04:00
parent db3d179215
commit ee7eaeabc0
3 changed files with 16 additions and 2 deletions

View File

@ -20,7 +20,7 @@
{% if request.user.is_authenticated %} {% if request.user.is_authenticated %}
<span id="profileLink"><a href="{{ url('user:profile', args=[request.user.id]) }}">{{ request.user.username }}</a></span> <span id="profileLink"><a href="{{ url('user:profile', args=[request.user.id]) }}">{{ request.user.username }}</a></span>
<span id="subscriptions"> <span id="subscriptions">
<button id="subbtn">{{ get_sub_msgs(request=request)|length }}</button> <button id="subbtn" class={% if get_sub_msgs(request=request) %}"newSubs"{% else %}"noNewSubs"{% endif %}>{{ get_sub_msgs(request=request)|length }}</button>
<div id="subscriptionsContent"> <div id="subscriptionsContent">
{% for sub in get_sub_msgs(request=request) %} {% for sub in get_sub_msgs(request=request) %}
<div id="notification-{{ sub.id }}" > <div id="notification-{{ sub.id }}" >
@ -29,6 +29,9 @@
<br> <br>
</div> </div>
{% endfor %} {% endfor %}
{% if not get_sub_msgs(request=request) %}
<span id="noNewSubs">No new notifications</span>
{% endif %}
</div> </div>
</span> </span>
{% endif %} {% endif %}

View File

@ -63,10 +63,18 @@ a:hover {
#subbtn { #subbtn {
width: 1.5em; width: 1.5em;
height: 1.5em; height: 1.5em;
background-color: orange;
border: none; border: none;
} }
.newSubs {
background-color: orange;
}
.noNewSubs {
background-color: #F0F0F0;
}
#subscriptionsContent { #subscriptionsContent {
display: none; display: none;
position: absolute; position: absolute;

View File

@ -28,4 +28,7 @@ function clear_notification(msg_id) {
elem.parentNode.removeChild(elem); elem.parentNode.removeChild(elem);
elem = document.getElementById('subbtn'); elem = document.getElementById('subbtn');
elem.innerText = elem.innerText - 1; elem.innerText = elem.innerText - 1;
if (elem.innerText === '0') {
elem.className = 'noNewSubs';
}
} }