1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

Merge pull request #6822 from iMattPro/ticket/17517

Ticket/17517 Update eslint and lint all phpbb JS files
This commit is contained in:
Marc Alexander
2025-06-29 09:10:40 +02:00
committed by GitHub
14 changed files with 1356 additions and 847 deletions

View File

@@ -1,4 +1,6 @@
/* global phpbb */
/* eslint camelcase: 0 */
/* eslint no-var: 0 */
(function($) { // Avoid conflicts with other libraries
@@ -11,7 +13,7 @@ phpbb.addAjaxCallback('mark_forums_read', function(res) {
var iconsArray = {
forum_unread: 'forum_read',
forum_unread_subforum: 'forum_read_subforum',
forum_unread_locked: 'forum_read_locked'
forum_unread_locked: 'forum_read_locked',
};
$('li.row').find('dl[class*="forum_unread"]').each(function() {
@@ -52,9 +54,9 @@ phpbb.addAjaxCallback('mark_topics_read', function(res, updateTopicLinks) {
global_unread: 'global_read',
announce_unread: 'announce_read',
sticky_unread: 'sticky_read',
topic_unread: 'topic_read'
topic_unread: 'topic_read',
};
var iconsState = ['', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine'];
var iconsState = [ '', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine' ];
var unreadClassSelectors;
var classMap = {};
var classNames = [];
@@ -206,7 +208,7 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
var mostVotes = 0;
// Set min-height to prevent the page from jumping when the content changes
var updatePanelHeight = function (height) {
var updatePanelHeight = function(height) {
height = (typeof height === 'undefined') ? panel.find('.inner').outerHeight() : height;
panel.css('min-height', height);
};
@@ -218,7 +220,7 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
}
if (!res.can_vote) {
poll.find('.polls, .poll_max_votes, .poll_vote, .poll_option_select').fadeOut(500, function () {
poll.find('.polls, .poll_max_votes, .poll_vote, .poll_option_select').fadeOut(500, function() {
poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show();
});
} else {
@@ -260,7 +262,7 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
var barTimeLapse = (res.can_vote) ? 500 : 1500;
var newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1);
setTimeout(function () {
setTimeout(function() {
bar.animate({ width: percentRel + '%' }, 500)
.removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5')
.addClass(newBarClass)
@@ -292,13 +294,13 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
resizePanel(500);
}, 1500);
var resizePanel = function (time) {
var resizePanel = function(time) {
var panelHeight = panel.height();
var innerHeight = panel.find('.inner').outerHeight();
if (panelHeight !== innerHeight) {
panel.css({ minHeight: '', height: panelHeight })
.animate({ height: innerHeight }, time, function () {
.animate({ height: innerHeight }, time, function() {
panel.css({ minHeight: innerHeight, height: '' });
});
}
@@ -332,7 +334,7 @@ $('[data-ajax]').each(function() {
selector: this,
refresh: $this.attr('data-refresh') !== undefined,
filter: filter,
callback: fn
callback: fn,
});
}
});
@@ -367,7 +369,7 @@ $('.display_post').click(function(e) {
$('.display_post_review').on('click', function(e) {
e.preventDefault();
let $displayPostLink = $(this);
const $displayPostLink = $(this);
$displayPostLink.closest('.post-ignore').removeClass('post-ignore');
$displayPostLink.hide();
});
@@ -379,7 +381,7 @@ $('.display_post_review').on('click', function(e) {
* In any case the link will toggle the display status of the search panel and link text will be
* appropriately changed based on the status of the search panel.
*/
$('#member_search').click(function () {
$('#member_search').click(function() {
var $memberlistSearch = $('#memberlist_search');
$memberlistSearch.slideToggle('fast');
@@ -399,7 +401,7 @@ const $scrollTopButton = $('.to-top-button');
if ($scrollTopButton.length) {
// Show or hide the button based on scroll position
$(window).scroll(function () {
$(window).scroll(function() {
if ($(this).scrollTop() > 300) {
$scrollTopButton.fadeIn(); // Fade in the button
} else {
@@ -408,9 +410,9 @@ if ($scrollTopButton.length) {
});
// Scroll smoothly to the top when the button is clicked
$scrollTopButton.click(function (e) {
$scrollTopButton.click(function(e) {
e.preventDefault(); // Prevent the default anchor link behavior
$('html, body').animate({scrollTop: 0}, 500); // Smooth scroll to top
$('html, body').animate({ scrollTop: 0 }, 500); // Smooth scroll to top
});
}

View File

@@ -1,4 +1,7 @@
/* global phpbb */
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
/* eslint no-var:0 */
/**
* phpBB forum functions
@@ -103,14 +106,14 @@ jQuery(function($) {
$('.sub-panels').each(function() {
var $childNodes = $('a[data-subpanel]', this),
panels = $childNodes.map(function () {
panels = $childNodes.map(function() {
return this.getAttribute('data-subpanel');
}),
showPanel = this.getAttribute('data-show-panel');
if (panels.length) {
activateSubPanel(showPanel, panels);
$childNodes.click(function () {
$childNodes.click(function() {
activateSubPanel(this.getAttribute('data-subpanel'), panels);
return false;
});
@@ -232,7 +235,7 @@ function phpbbCheckKey(event) {
jQuery(function($) {
'use strict';
$('form input[type=text], form input[type=password]').on('keypress', function (e) {
$('form input[type=text], form input[type=password]').on('keypress', function(e) {
var defaultButton = $(this).parents('form').find('input[type=submit].default-submit-action');
if (!defaultButton || defaultButton.length <= 0) {
@@ -369,7 +372,7 @@ function parseDocument($container) {
var $this = $(this),
$links = $this.find('.crumb'),
length = $links.length,
classes = ['wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny'],
classes = [ 'wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny' ],
classesLength = classes.length,
maxHeight = 0,
lastWidth = false,
@@ -496,7 +499,7 @@ function parseDocument($container) {
// Find all headers, get contents
$list.prev('.topiclist').find('li.header dd').not('.mark').each(function() {
headers.push($("<div>").text($(this).text()).html());
headers.push($('<div>').text($(this).text()).html());
headersLength++;
});
@@ -600,7 +603,7 @@ function parseDocument($container) {
if ((text.length && text !== '-') || cell.children().length) {
if (headers[column].length) {
cell.prepend($("<dfn>").css('display', 'none').text(headers[column]));
cell.prepend($('<dfn>').css('display', 'none').text(headers[column]));
}
} else {
cell.addClass('empty');
@@ -687,7 +690,7 @@ function parseDocument($container) {
var $tabLink = $item.find('a.responsive-tab-link');
phpbb.registerDropdown($tabLink, $item.find('.dropdown'), {
visibleClass: 'activetab'
visibleClass: 'activetab',
});
check(true);