исправлена логика скрытия / показа комментариев
This commit is contained in:
@@ -207,12 +207,20 @@ if ($fileInput.length && $fileInput[0].files.length > 0) {
|
||||
var $commentBlock = $btn.closest('.mod_comment_comment');
|
||||
$commentBlock.fadeOut(300, function() { $(this).remove(); });
|
||||
}
|
||||
if (action === 'unlock' || action === 'lock') {
|
||||
var isLock = (action === 'lock');
|
||||
$btn.toggleClass('mod_comment_lock mod_comment_unlock text-dark text-success')
|
||||
.attr('title', isLock ? 'Разблокировать' : 'Заблокировать')
|
||||
.find('i').toggleClass('bi-lock-fill bi-unlock-fill');
|
||||
}
|
||||
// показать / скрыть комментарий
|
||||
|
||||
if (action === 'unlock' || action === 'lock') {
|
||||
var $icon = $btn.find('i');
|
||||
if (action === 'lock') {
|
||||
// Статус 0: СКРЫТО. Ставим красный перечеркнутый глаз.
|
||||
$icon.attr('class', 'bi bi-eye-slash');
|
||||
$btn.removeClass('text-success text-muted').addClass('text-danger').attr('title', 'Показать');
|
||||
} else {
|
||||
// Статус 1: ВИДИМО. Ставим зеленый открытый глаз.
|
||||
$icon.attr('class', 'bi bi-eye');
|
||||
$btn.removeClass('text-danger text-muted').addClass('text-success').attr('title', 'Скрыть');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -426,11 +434,22 @@ $doc.on('mouseleave', '.rating-edit-block, #rating_wrapper', function() {
|
||||
if (confirm('Удалить этот комментарий?')) cAction(this, 'delete');
|
||||
});
|
||||
|
||||
// Блокировка
|
||||
$doc.off('click', '.mod_comment_lock, .mod_comment_unlock').on('click', '.mod_comment_lock, .mod_comment_unlock', function(e) {
|
||||
e.preventDefault();
|
||||
cAction(this, $(this).hasClass('mod_comment_lock') ? 'lock' : 'unlock');
|
||||
});
|
||||
|
||||
// Универсальный обработчик для переключателя видимости
|
||||
// Оставляем все селекторы для надежности
|
||||
$doc.off('click', '.mod_comment_toggle, .mod_comment_lock, .mod_comment_unlock')
|
||||
.on('click', '.mod_comment_toggle, .mod_comment_lock, .mod_comment_unlock', function(e) {
|
||||
e.preventDefault();
|
||||
var $btn = $(this);
|
||||
var $icon = $btn.find('i');
|
||||
|
||||
// Теперь проверяем перечеркнутый глаз (скрыто) или закрытый замок (на случай если остался в кэше)
|
||||
// Если глаз перечеркнут ИЛИ замок закрыт — значит в базе 0, шлем 'unlock'
|
||||
var isHidden = $icon.hasClass('bi-eye-slash') || $icon.hasClass('bi-lock-fill');
|
||||
var actionToSend = isHidden ? 'unlock' : 'lock';
|
||||
|
||||
cAction(this, actionToSend);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -146,11 +146,14 @@
|
||||
{/if}
|
||||
</span>
|
||||
|
||||
{if $smarty.const.UGROUP==1}
|
||||
<a class="btn btn-sm btn-link text-dark mod_comment_lock px-2" href="javascript:void(0);" data-id="{$c.Id}">
|
||||
<i class="bi bi-{if $c.comment_status!=1}unlock{else}lock{/if}-fill"></i>
|
||||
</a>
|
||||
{/if}
|
||||
{if $smarty.const.UGROUP==1}
|
||||
<a class="btn btn-sm btn-link {if $c.comment_status==1}text-success{else}text-danger{/if} mod_comment_toggle px-2"
|
||||
href="javascript:void(0);"
|
||||
data-id="{$c.Id}"
|
||||
title="{if $c.comment_status==1}Скрыть{else}Показать{/if}">
|
||||
<i class="bi bi-{if $c.comment_status==1}eye{else}eye-slash{/if}"></i>
|
||||
</a>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user