Create user setting button in chat (#101)

This commit is contained in:
Phuoc Anh Kha Le 2023-12-30 17:57:37 -06:00 committed by GitHub
parent c9f1d69b47
commit bfe939564b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 71 additions and 47 deletions

View file

@ -139,6 +139,7 @@
.status-row { .status-row {
display: flex; display: flex;
padding: 15px; padding: 15px;
padding-right: 0;
gap: 0.5em; gap: 0.5em;
border-radius: 6px; border-radius: 6px;
} }
@ -195,7 +196,7 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
#setting-content { .setting-content {
display: none; display: none;
position: absolute; position: absolute;
background-color: #f1f1f1; background-color: #f1f1f1;
@ -204,14 +205,14 @@
z-index: 1; z-index: 1;
right: 0; right: 0;
} }
#setting-content li { .setting-content a {
padding: 12px 16px; padding: 12px 16px;
text-decoration: none; text-decoration: none;
display: block; display: block;
color: black;
font-weight: bold; font-weight: bold;
font-size: 1rem;
} }
#setting-content li:hover { .setting-content a:hover {
background-color: #ddd; background-color: #ddd;
cursor: pointer; cursor: pointer;
} }

File diff suppressed because one or more lines are too long

View file

@ -602,7 +602,6 @@ ul.select2-selection__rendered {
} }
.control-button { .control-button {
background: lightgray;
color: black !important; color: black !important;
border: 0; border: 0;
} }

View file

@ -115,7 +115,17 @@
#setting { #setting {
position: relative; position: relative;
} }
#setting-button { .setting-button {
height: 2.3em;
width: 2.5em;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
padding-top: 2px;
}
.user-setting-button {
height: 2.3em; height: 2.3em;
width: 2.5em; width: 2.5em;
border-radius: 50%; border-radius: 50%;

View file

@ -2,6 +2,10 @@
let isMobile = window.matchMedia("only screen and (max-width: 799px)").matches; let isMobile = window.matchMedia("only screen and (max-width: 799px)").matches;
function load_next_page(last_id, refresh_html=false) { function load_next_page(last_id, refresh_html=false) {
if (refresh_html) {
$('#chat-log').html('');
$('#loader').show();
}
var param = { var param = {
'last_id': last_id, 'last_id': last_id,
'only_messages': true, 'only_messages': true,
@ -12,7 +16,6 @@
}) })
.done(function(data) { .done(function(data) {
if (refresh_html) { if (refresh_html) {
$('#chat-log').html('');
$('#chat-box').scrollTop($('#chat-box')[0].scrollHeight); $('#chat-box').scrollTop($('#chat-box')[0].scrollHeight);
window.lock = true; window.lock = true;
} }
@ -78,6 +81,7 @@
register_toggle($(this)); register_toggle($(this));
}); });
register_click_space(); register_click_space();
register_setting(false);
color_selected_room(); color_selected_room();
} }
}) })
@ -93,7 +97,7 @@
.done(function(data) { .done(function(data) {
$('#chat-info').html(data); $('#chat-info').html(data);
register_time($('.time-with-rel')); register_time($('.time-with-rel'));
register_setting(); register_setting(true);
}) })
} }
@ -363,18 +367,22 @@
} }
} }
function register_setting() { function register_setting(is_on_user_status_bar) {
$('#setting-button').on('click', function() { let $setting_button = is_on_user_status_bar ? $('.user-setting-button') : $('.setting-button');
$('#setting-content').toggle(); $setting_button.on('click', function(e) {
e.stopPropagation();
$('.setting-content').not($(this).siblings('.setting-content')).hide();
$(this).siblings('.setting-content').toggle();
}); });
$('#setting-content li').on('click', function() { $('.setting-content a').on('click', function(e) {
$(this).children('a')[0].click(); e.stopPropagation();
})
$('#setting-content a').on('click', function() {
var href = $(this).attr('href'); var href = $(this).attr('href');
href += '?next=' + window.location.pathname; href += '?next=' + window.location.pathname;
$(this).attr('href', href); $(this).attr('href', href);
}) })
$(document).on('click', function() {
$('.setting-content').hide();
});
} }
$(function() { $(function() {
$('#loader').hide(); $('#loader').hide();
@ -547,7 +555,8 @@
characterData: false characterData: false
}) })
} }
register_setting(); register_setting(true);
register_setting(false);
color_selected_room(); color_selected_room();
$('#chat-input').on('input', function() { $('#chat-input').on('input', function() {

View file

@ -25,8 +25,7 @@
<div class="status-container"> <div class="status-container">
<img src="{{ gravatar(user.user, 135) }}" class="status-pic"> <img src="{{ gravatar(user.user, 135) }}" class="status-pic">
<svg style="position:absolute;" height="32" width="32"> <svg style="position:absolute;" height="32" width="32">
<circle class="status-circle" <circle class="status-circle" fill="{{'green' if user.is_online else 'red'}}"/>
fill="{{'green' if user.is_online else 'red'}}"/>
</svg> </svg>
</div> </div>
<div class="status-user"> <div class="status-user">
@ -44,8 +43,19 @@
{{user.unread_count}} {{user.unread_count}}
</span> </span>
{% endif %} {% endif %}
<div style="margin-right: 0.3em; position: relative;">
<div class="control-button small setting-button">
<i class="fa fa-ellipsis-h"></i>
</div>
<div class="setting-content">
<a href="{{url('toggle_ignore', user.user.id)}}" class="red">
{{_('Ignore')}}
</a>
</div>
</div>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
{% endfor %} {% endfor %}

View file

@ -27,22 +27,20 @@
{% endif %} {% endif %}
{% if other_user %} {% if other_user %}
<span style="margin-right: 0.3em" id="setting"> <div style="margin-right: 0.3em; position: relative;">
<div class="control-button small" style="" id="setting-button"> <div class="control-button small user-setting-button">
<i class="fa fa-ellipsis-h"></i> <i class="fa fa-ellipsis-h"></i>
</div> </div>
<div id="setting-content"> <div class="setting-content">
<li> <a href="{{url('toggle_ignore', other_user.id)}}" class=" {{'green' if is_ignored else 'red'}}">
<a href="{{url('toggle_ignore', other_user.id)}}" class=" {{'green' if is_ignored else 'red'}}"> {% if is_ignored %}
{% if is_ignored %} {{_('Unignore')}}
{{_('Unignore')}} {% else %}
{% else %} {{_('Ignore')}}
{{_('Ignore')}} {% endif %}
{% endif %} </a>
</a>
</li>
</div> </div>
</span> </div>
{% else %} {% else %}
<span class="active-span">{{online_count}} {{_('users are online')}}</span> <span class="active-span">{{online_count}} {{_('users are online')}}</span>
{% endif %} {% endif %}