refactor: var to const and let (#9885)

* refactor: var to const and let

* fix: missed global bootbox usage

* refactor: align with eslint expectations
This commit is contained in:
gasoved
2021-10-12 17:26:18 +03:00
committed by GitHub
parent eddb98681c
commit b0a24d6dd5
154 changed files with 1850 additions and 1854 deletions

View File

@@ -10,7 +10,7 @@ define('forum/topic/threadTools', [
'hooks',
'bootbox',
], function (components, translator, handleBack, posts, api, hooks, bootbox) {
var ThreadTools = {};
const ThreadTools = {};
ThreadTools.init = function (tid, topicContainer) {
renderMenu(topicContainer);
@@ -86,7 +86,7 @@ define('forum/topic/threadTools', [
});
topicContainer.on('click', '[component="topic/mark-unread-for-all"]', function () {
var btn = $(this);
const btn = $(this);
socket.emit('topics.markAsUnreadForAll', [tid], function (err) {
if (err) {
return app.alertError(err.message);
@@ -135,7 +135,7 @@ define('forum/topic/threadTools', [
function changeWatching(type, state = 1) {
const method = state ? 'put' : 'del';
api[method](`/topics/${tid}/${type}`, {}, () => {
var message = '';
let message = '';
if (type === 'follow') {
message = state ? '[[topic:following_topic.message]]' : '[[topic:not_following_topic.message]]';
} else if (type === 'ignore') {
@@ -173,8 +173,8 @@ define('forum/topic/threadTools', [
function renderMenu(container) {
container.on('show.bs.dropdown', '.thread-tools', function () {
var $this = $(this);
var dropdownMenu = $this.find('.dropdown-menu');
const $this = $(this);
const dropdownMenu = $this.find('.dropdown-menu');
if (dropdownMenu.html()) {
return;
}
@@ -265,17 +265,17 @@ define('forum/topic/threadTools', [
};
ThreadTools.setLockedState = function (data) {
var threadEl = components.get('topic');
const threadEl = components.get('topic');
if (parseInt(data.tid, 10) !== parseInt(threadEl.attr('data-tid'), 10)) {
return;
}
var isLocked = data.isLocked && !ajaxify.data.privileges.isAdminOrMod;
const isLocked = data.isLocked && !ajaxify.data.privileges.isAdminOrMod;
components.get('topic/lock').toggleClass('hidden', data.isLocked).parent().attr('hidden', data.isLocked ? '' : null);
components.get('topic/unlock').toggleClass('hidden', !data.isLocked).parent().attr('hidden', !data.isLocked ? '' : null);
var hideReply = !!((data.isLocked || ajaxify.data.deleted) && !ajaxify.data.privileges.isAdminOrMod);
const hideReply = !!((data.isLocked || ajaxify.data.deleted) && !ajaxify.data.privileges.isAdminOrMod);
components.get('topic/reply/container').toggleClass('hidden', hideReply);
components.get('topic/reply/locked').toggleClass('hidden', ajaxify.data.privileges.isAdminOrMod || !data.isLocked || ajaxify.data.deleted);
@@ -293,7 +293,7 @@ define('forum/topic/threadTools', [
};
ThreadTools.setDeleteState = function (data) {
var threadEl = components.get('topic');
const threadEl = components.get('topic');
if (parseInt(data.tid, 10) !== parseInt(threadEl.attr('data-tid'), 10)) {
return;
}
@@ -313,7 +313,7 @@ define('forum/topic/threadTools', [
html.find('.timeago').timeago();
});
}
var hideReply = data.isDelete && !ajaxify.data.privileges.isAdminOrMod;
const hideReply = data.isDelete && !ajaxify.data.privileges.isAdminOrMod;
components.get('topic/reply/container').toggleClass('hidden', hideReply);
components.get('topic/reply/locked').toggleClass('hidden', ajaxify.data.privileges.isAdminOrMod || !ajaxify.data.locked || data.isDelete);
@@ -327,14 +327,14 @@ define('forum/topic/threadTools', [
ThreadTools.setPinnedState = function (data) {
var threadEl = components.get('topic');
const threadEl = components.get('topic');
if (parseInt(data.tid, 10) !== parseInt(threadEl.attr('data-tid'), 10)) {
return;
}
components.get('topic/pin').toggleClass('hidden', data.pinned).parent().attr('hidden', data.pinned ? '' : null);
components.get('topic/unpin').toggleClass('hidden', !data.pinned).parent().attr('hidden', !data.pinned ? '' : null);
var icon = $('.topic-header [component="topic/pinned"]');
const icon = $('.topic-header [component="topic/pinned"]');
icon.toggleClass('hidden', !data.pinned);
if (data.pinned) {
icon.translateAttr('title', (
@@ -349,7 +349,7 @@ define('forum/topic/threadTools', [
};
function setFollowState(state) {
var titles = {
const titles = {
follow: '[[topic:watching]]',
unfollow: '[[topic:not-watching]]',
ignore: '[[topic:ignoring]]',
@@ -360,7 +360,7 @@ define('forum/topic/threadTools', [
.tooltip('fixTitle');
});
var menu = components.get('topic/following/menu');
let menu = components.get('topic/following/menu');
menu.toggleClass('hidden', state !== 'follow');
components.get('topic/following/check').toggleClass('fa-check', state === 'follow');