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
commit 3cc7076513
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 1356 additions and 847 deletions

4
.github/check-js.sh vendored
View file

@ -14,6 +14,6 @@ set +x
sudo npm install -g > /dev/null sudo npm install -g > /dev/null
npm ci > /dev/null npm ci > /dev/null
set -x set -x
node_modules/eslint/bin/eslint.js "phpBB/**/*.js" node_modules/eslint/bin/eslint.js "phpBB/**/*.js" --ignore-pattern "phpBB/ext/"
node_modules/eslint/bin/eslint.js "phpBB/**/*.js.twig" node_modules/eslint/bin/eslint.js "phpBB/**/*.js.twig" --ignore-pattern "phpBB/ext/"
node_modules/eslint/bin/eslint.js "gulpfile.js" node_modules/eslint/bin/eslint.js "gulpfile.js"

67
eslint.config.mjs Normal file
View file

@ -0,0 +1,67 @@
const { browser: browserGlobals, node: nodeGlobals, jquery: jqueryGlobals } = (await import('globals')).default;
// File patterns to ignore
const IGNORED_FILES = [
'phpBB/assets/javascript/cropper.js',
'phpBB/assets/javascript/hermite.js',
'phpBB/assets/javascript/jquery-cropper.js',
'phpBB/**/*.min.js',
'phpBB/vendor/**/*.js',
'phpBB/vendor-ext/**/*.js',
'phpBB/phpbb/**/*.js',
'phpBB/tests/**/*.js',
];
// ESLint rule configurations
const FORMATTING_RULES = {
'quotes': ['error', 'single'],
'comma-dangle': ['error', 'always-multiline'],
'block-spacing': 'error',
'array-bracket-spacing': ['error', 'always'],
'object-curly-spacing': ['error', 'always'],
'space-before-function-paren': ['error', 'never'],
'space-in-parens': 'off',
};
const CODE_QUALITY_RULES = {
'semi': ['error', 'always'],
'eqeqeq': ['error', 'always'],
'curly': ['error', 'multi-line'],
'no-var': 'error',
'prefer-const': 'error',
'no-console': 'off',
'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
};
const DISABLED_STYLE_RULES = {
'multiline-comment-style': 'off',
'computed-property-spacing': 'off',
'capitalized-comments': 'off',
'no-lonely-if': 'off',
};
const mainConfig = {
files: ['**/*.js', '**/*.js.twig'],
linterOptions: {
reportUnusedDisableDirectives: false,
},
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
...browserGlobals,
...nodeGlobals,
...jqueryGlobals,
},
},
rules: {
...FORMATTING_RULES,
...CODE_QUALITY_RULES,
...DISABLED_STYLE_RULES,
},
};
export default [
{ ignores: IGNORED_FILES },
mainConfig,
];

1784
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -6,65 +6,6 @@
"directories": { "directories": {
"doc": "docs" "doc": "docs"
}, },
"eslintConfig": {
"extends": "xo",
"ignorePatterns": [
"phpBB/adm/style/admin.js",
"phpBB/adm/style/ajax.js",
"phpBB/adm/style/permissions.js",
"phpBB/adm/style/tooltip.js",
"phpBB/assets/javascript/core.js",
"phpBB/assets/javascript/cropper.js",
"phpBB/assets/javascript/editor.js",
"phpBB/assets/javascript/hermite.js",
"phpBB/assets/javascript/installer.js",
"phpBB/assets/javascript/jquery-cropper.js",
"phpBB/assets/javascript/plupload.js",
"phpBB/ext/**/*.js",
"phpBB/styles/prosilver/template/ajax.js",
"phpBB/styles/prosilver/template/forum_fn.js",
"phpBB/**/*.min.js",
"phpBB/vendor/**/*.js",
"phpBB/vendor-ext/**/*.js",
"phpBB/phpbb/**/*.js",
"phpBB/tests/**/*.js"
],
"rules": {
"quotes": [
"error",
"single"
],
"comma-dangle": [
"error",
"always-multiline"
],
"block-spacing": "error",
"array-bracket-spacing": [
"error",
"always"
],
"multiline-comment-style": "off",
"computed-property-spacing": "off",
"space-before-function-paren": [
"error",
"never"
],
"space-in-parens": "off",
"capitalized-comments": "off",
"object-curly-spacing": [
"error",
"always"
],
"no-lonely-if": "off",
"unicorn/prefer-module": "off"
},
"env": {
"es6": true,
"browser": true,
"node": true,
"jquery": true
}
},
"browserslist": [ "browserslist": [
"> 1%", "> 1%",
"not ie 11", "not ie 11",
@ -101,8 +42,8 @@
"devDependencies": { "devDependencies": {
"autoprefixer": "^10.4.4", "autoprefixer": "^10.4.4",
"cssnano": "^5.1.7", "cssnano": "^5.1.7",
"eslint": "^8.13.0", "eslint": "^9.28.0",
"eslint-config-xo": "^0.40.0", "globals": "^16.2.0",
"gulp": "^5.0.0", "gulp": "^5.0.0",
"gulp-concat": "^2.6.1", "gulp-concat": "^2.6.1",
"gulp-postcss": "^9.0.1", "gulp-postcss": "^9.0.1",

View file

@ -1,4 +1,6 @@
/* global phpbb */ /* global phpbb */
/* eslint no-var: 0 */
/* eslint no-unused-vars: 0 */
/** /**
* phpBB ACP functions * phpBB ACP functions
@ -10,7 +12,7 @@
function parse_document(container) function parse_document(container)
{ {
var test = document.createElement('div'), var test = document.createElement('div'),
oldBrowser = (typeof test.style.borderRadius == 'undefined'); oldBrowser = (typeof test.style.borderRadius === 'undefined');
test.remove(); test.remove();
@ -79,7 +81,7 @@ function parse_document(container)
dfn = cell.attr('data-dfn'), dfn = cell.attr('data-dfn'),
text = dfn ? dfn : $.trim(cell.text()); text = dfn ? dfn : $.trim(cell.text());
if (text == ' ') text = ''; if (text === ' ') text = '';
colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan; colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan;
for (i=0; i<colspan; i++) { for (i=0; i<colspan; i++) {
@ -108,7 +110,7 @@ function parse_document(container)
cells = row.children('td'), cells = row.children('td'),
column = 0; column = 0;
if (cells.length == 1) { if (cells.length === 1) {
row.addClass('big-column'); row.addClass('big-column');
return; return;
} }
@ -124,7 +126,7 @@ function parse_document(container)
if ((text.length && text !== '-') || cell.children().length) { if ((text.length && text !== '-') || cell.children().length) {
if (headers[column].length) { if (headers[column].length) {
cell.prepend($("<dfn>").css('display', 'none').text(headers[column])); cell.prepend($('<dfn>').css('display', 'none').text(headers[column]));
} }
} }
else { else {
@ -156,7 +158,7 @@ function parse_document(container)
*/ */
container.find('fieldset dt > span:last-child').each(function() { container.find('fieldset dt > span:last-child').each(function() {
var $this = $(this); var $this = $(this);
if ($this.html() == '&nbsp;') { if ($this.html() === '&nbsp;') {
$this.addClass('responsive-hide'); $this.addClass('responsive-hide');
} }
}); });
@ -194,7 +196,7 @@ function parse_document(container)
links.each(function() { links.each(function() {
var link = $(this); var link = $(this);
maxHeight = Math.max(maxHeight, Math.max(link.outerHeight(true), link.parent().outerHeight(true))); maxHeight = Math.max(maxHeight, Math.max(link.outerHeight(true), link.parent().outerHeight(true)));
}) });
function check() { function check() {
var width = $body.width(), var width = $body.width(),
@ -237,7 +239,7 @@ function parse_document(container)
menu.find('a').click(function() { check(true); }); menu.find('a').click(function() { check(true); });
} }
phpbb.registerDropdown(item.find('a.responsive-tab-link'), item.find('.dropdown'), {visibleClass: 'activetab', verticalDirection: 'down'}); phpbb.registerDropdown(item.find('a.responsive-tab-link'), item.find('.dropdown'), { visibleClass: 'activetab', verticalDirection: 'down' });
check(true); check(true);
$(window).resize(check); $(window).resize(check);
@ -262,7 +264,7 @@ function parse_document(container)
$('#questionnaire-form').css('display', 'none'); $('#questionnaire-form').css('display', 'none');
var $triggerConfiglist = $('#trigger-configlist'); var $triggerConfiglist = $('#trigger-configlist');
$triggerConfiglist.on('click', function () { $triggerConfiglist.on('click', function() {
var $configlist = $('#configlist'); var $configlist = $('#configlist');
$configlist.closest('.send-stats-data-row').toggleClass('send-stats-data-hidden'); $configlist.closest('.send-stats-data-row').toggleClass('send-stats-data-hidden');
$configlist.closest('.send-stats-row').find('.send-stats-data-row:first-child').toggleClass('send-stats-data-only-row'); $configlist.closest('.send-stats-row').find('.send-stats-data-row:first-child').toggleClass('send-stats-data-only-row');
@ -272,8 +274,8 @@ function parse_document(container)
$('#configlist').closest('.send-stats-data-row').addClass('send-stats-data-hidden'); $('#configlist').closest('.send-stats-data-row').addClass('send-stats-data-hidden');
// Do not underline actions icons on hover (could not be done via CSS) // Do not underline actions icons on hover (could not be done via CSS)
$('.actions a:has(i.acp-icon)').mouseover(function () { $('.actions a:has(i.acp-icon)').mouseover(function() {
$(this).css("text-decoration", "none"); $(this).css('text-decoration', 'none');
}); });
// Live update BBCode font icon preview // Live update BBCode font icon preview
@ -296,11 +298,11 @@ function parse_document(container)
const pageIconFont = document.getElementById('bbcode_font_icon'); const pageIconFont = document.getElementById('bbcode_font_icon');
if (pageIconFont) { if (pageIconFont) {
pageIconFont.addEventListener('keyup', function () { pageIconFont.addEventListener('keyup', function() {
updateIconClass(this.nextElementSibling, this.value); updateIconClass(this.nextElementSibling, this.value);
}); });
pageIconFont.addEventListener('blur', function () { pageIconFont.addEventListener('blur', function() {
updateIconClass(this.nextElementSibling, this.value); updateIconClass(this.nextElementSibling, this.value);
}); });
} }

View file

@ -1,16 +1,17 @@
/* global phpbb, statsData */ /* global phpbb, statsData */
/* eslint no-var: 0 */
(function($) { // Avoid conflicts with other libraries (function($) { // Avoid conflicts with other libraries
'use strict'; 'use strict';
phpbb.prepareSendStats = function () { phpbb.prepareSendStats = function() {
var $form = $('#acp_help_phpbb'); var $form = $('#acp_help_phpbb');
var $dark = $('#darkenwrapper'); var $dark = $('#darkenwrapper');
var $loadingIndicator; var $loadingIndicator;
$form.on('submit', function (event) { $form.on('submit', function(event) {
var $this = $(this), var $this = $(this),
currentTime = Math.floor(new Date().getTime() / 1000), currentTime = Math.floor(new Date().getTime() / 1000),
statsTime = parseInt($this.find('input[name=help_send_statistics_time]').val(), 10); statsTime = parseInt($this.find('input[name=help_send_statistics_time]').val(), 10);
@ -23,7 +24,7 @@ phpbb.prepareSendStats = function () {
if (!$this.find('input[name=help_send_statistics]').is(':checked') || if (!$this.find('input[name=help_send_statistics]').is(':checked') ||
statsTime > currentTime) { statsTime > currentTime) {
$form.find('input[type=submit]').click(); $form.find('input[type=submit]').click();
setTimeout(function () { setTimeout(function() {
$form.find('input[type=submit]').click(); $form.find('input[type=submit]').click();
}, 300); }, 300);
return; return;
@ -74,7 +75,7 @@ phpbb.prepareSendStats = function () {
var $sendStatisticsSuccess = $('<input />', { var $sendStatisticsSuccess = $('<input />', {
type: 'hidden', type: 'hidden',
name: 'send_statistics_response', name: 'send_statistics_response',
value: JSON.stringify(res) value: JSON.stringify(res),
}); });
$sendStatisticsSuccess.appendTo('p.submit-buttons'); $sendStatisticsSuccess.appendTo('p.submit-buttons');
@ -90,7 +91,7 @@ phpbb.prepareSendStats = function () {
data: statsData, data: statsData,
success: returnHandler, success: returnHandler,
error: errorHandler, error: errorHandler,
cache: false cache: false,
}).always(function() { }).always(function() {
if ($loadingIndicator && $loadingIndicator.is(':visible')) { if ($loadingIndicator && $loadingIndicator.is(':visible')) {
$loadingIndicator.fadeOut(phpbb.alertTime); $loadingIndicator.fadeOut(phpbb.alertTime);
@ -176,7 +177,7 @@ phpbb.addAjaxCallback('generate_vapid_keys', () => {
namedCurve: 'P-256', namedCurve: 'P-256',
}, },
true, true,
['deriveKey', 'deriveBits'] [ 'deriveKey', 'deriveBits' ],
); );
const privateKeyJwk = await crypto.subtle.exportKey('jwk', keyPair.privateKey); const privateKeyJwk = await crypto.subtle.exportKey('jwk', keyPair.privateKey);
@ -187,7 +188,7 @@ phpbb.addAjaxCallback('generate_vapid_keys', () => {
return { return {
privateKey: privateKeyString, privateKey: privateKeyString,
publicKey: publicKeyString publicKey: publicKeyString,
}; };
} catch (error) { } catch (error) {
console.error('Error generating keys with SubtleCrypto:', error); console.error('Error generating keys with SubtleCrypto:', error);
@ -203,8 +204,8 @@ phpbb.addAjaxCallback('generate_vapid_keys', () => {
const privateKeyInput = document.querySelector('#webpush_vapid_private'); const privateKeyInput = document.querySelector('#webpush_vapid_private');
publicKeyInput.value = keyPair.publicKey; publicKeyInput.value = keyPair.publicKey;
privateKeyInput.value = keyPair.privateKey; privateKeyInput.value = keyPair.privateKey;
}) });
}) });
/** /**
* Handler for submitting permissions form in chunks * Handler for submitting permissions form in chunks
@ -230,7 +231,7 @@ function submitPermissions() {
fieldsetList = $form.find('fieldset#' + $submitButton.closest('fieldset.permissions').id); fieldsetList = $form.find('fieldset#' + $submitButton.closest('fieldset.permissions').id);
} }
$.each(fieldsetList, function (key, value) { $.each(fieldsetList, function(key, value) {
dataSetIndex = Math.floor(key / 5); dataSetIndex = Math.floor(key / 5);
var $fieldset = $('fieldset#' + value.id); var $fieldset = $('fieldset#' + value.id);
if (key % 5 === 0) { if (key % 5 === 0) {
@ -252,7 +253,7 @@ function submitPermissions() {
permissionSubmitSize = formDataSets.length; permissionSubmitSize = formDataSets.length;
// Add each forum ID to forum ID list to preserve selected forums // Add each forum ID to forum ID list to preserve selected forums
$.each($form.find('input[type=hidden][name^=forum_id]'), function (key, value) { $.each($form.find('input[type=hidden][name^=forum_id]'), function(key, value) {
if (value.name.match(/^forum_id\[([0-9]+)\]$/)) { if (value.name.match(/^forum_id\[([0-9]+)\]$/)) {
forumIds.push(value.value); forumIds.push(value.value);
} }
@ -286,18 +287,18 @@ function submitPermissions() {
$alertBoxLink.attr('href', $alertBoxLink.attr('href').replace(/(&forum_id\[\]=[0-9]+)/g, '')); $alertBoxLink.attr('href', $alertBoxLink.attr('href').replace(/(&forum_id\[\]=[0-9]+)/g, ''));
const $previousPageForm = $('<form>').attr({ const $previousPageForm = $('<form>').attr({
action: $alertBoxLink.attr('href'), action: $alertBoxLink.attr('href'),
method: 'post' method: 'post',
}); });
$.each(forumIds, function (key, value) { $.each(forumIds, function(key, value) {
$previousPageForm.append($('<input>').attr({ $previousPageForm.append($('<input>').attr({
type: 'text', type: 'text',
name: 'forum_id[]', name: 'forum_id[]',
value: value value: value,
})); }));
}); });
$alertBoxLink.on('click', function (e) { $alertBoxLink.on('click', function(e) {
$('body').append($previousPageForm); $('body').append($previousPageForm);
e.preventDefault(); e.preventDefault();
$previousPageForm.submit(); $previousPageForm.submit();
@ -309,19 +310,19 @@ function submitPermissions() {
$alert.find('.alert_close').hide(); $alert.find('.alert_close').hide();
if (typeof res.REFRESH_DATA !== 'undefined') { if (typeof res.REFRESH_DATA !== 'undefined') {
setTimeout(function () { setTimeout(function() {
// Create forum to submit using POST. This will prevent // Create forum to submit using POST. This will prevent
// exceeding the maximum length of URLs // exceeding the maximum length of URLs
const $form = $('<form>').attr({ const $form = $('<form>').attr({
action: res.REFRESH_DATA.url.replace(/(&forum_id\[\]=[0-9]+)/g, ''), action: res.REFRESH_DATA.url.replace(/(&forum_id\[\]=[0-9]+)/g, ''),
method: 'post' method: 'post',
}); });
$.each(forumIds, function (key, value) { $.each(forumIds, function(key, value) {
$form.append($('<input>').attr({ $form.append($('<input>').attr({
type: 'text', type: 'text',
name: 'forum_id[]', name: 'forum_id[]',
value: value value: value,
})); }));
}); });
@ -329,7 +330,7 @@ function submitPermissions() {
// Hide the alert even if we refresh the page, in case the user // Hide the alert even if we refresh the page, in case the user
// presses the back button. // presses the back button.
$dark.fadeOut(phpbb.alertTime, function () { $dark.fadeOut(phpbb.alertTime, function() {
if (typeof $alert !== 'undefined') { if (typeof $alert !== 'undefined') {
$alert.hide(); $alert.hide();
} }
@ -355,7 +356,7 @@ function submitPermissions() {
} }
// Create AJAX request for each form data set // Create AJAX request for each form data set
$.each(formDataSets, function (key, formData) { $.each(formDataSets, function(key, formData) {
$.ajax({ $.ajax({
url: $form.action, url: $form.action,
type: 'POST', type: 'POST',
@ -365,7 +366,7 @@ function submitPermissions() {
'&' + $form.children('input[type=hidden]').serialize() + '&' + $form.children('input[type=hidden]').serialize() +
'&' + $form.find('input[type=checkbox][name^=inherit]').serialize(), '&' + $form.find('input[type=checkbox][name^=inherit]').serialize(),
success: handlePermissionReturn, success: handlePermissionReturn,
error: handlePermissionReturn error: handlePermissionReturn,
}); });
}); });
} }
@ -379,7 +380,7 @@ $('[data-ajax]').each(function() {
phpbb.ajaxify({ phpbb.ajaxify({
selector: this, selector: this,
refresh: $this.attr('data-refresh') !== undefined, refresh: $this.attr('data-refresh') !== undefined,
callback: fn callback: fn,
}); });
} }
}); });
@ -388,11 +389,11 @@ $('[data-ajax]').each(function() {
* Automatically resize textarea * Automatically resize textarea
*/ */
$(function() { $(function() {
phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), {minHeight: 75}); phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), { minHeight: 75 });
var $setPermissionsForm = $('form#set-permissions'); var $setPermissionsForm = $('form#set-permissions');
if ($setPermissionsForm.length) { if ($setPermissionsForm.length) {
$setPermissionsForm.on('submit', function (e) { $setPermissionsForm.on('submit', function(e) {
submitPermissions(); submitPermissions();
e.preventDefault(); e.preventDefault();
}); });
@ -412,7 +413,7 @@ $(function() {
} else { } else {
dateoptionInput.value = this.value; dateoptionInput.value = this.value;
} }
}) });
} }
if ($('#acp_help_phpbb')) { if ($('#acp_help_phpbb')) {

View file

@ -1,4 +1,8 @@
/* global phpbb */ /* global phpbb */
/* eslint camelcase: 0 */
/* eslint no-undef: 0 */
/* eslint no-unused-vars: 0 */
/* eslint no-var: 0 */
/** /**
* Hide and show all checkboxes * Hide and show all checkboxes
@ -372,7 +376,7 @@ function match_role_settings(id) {
* @return {string} The sorted object as a string * @return {string} The sorted object as a string
*/ */
function sort_and_stringify(obj) { function sort_and_stringify(obj) {
return JSON.stringify(Object.keys(obj).sort().reduce(function (result, key) { return JSON.stringify(Object.keys(obj).sort().reduce(function(result, key) {
result[key] = obj[key]; result[key] = obj[key];
return result; return result;
}, {})); }, {}));

View file

@ -1,4 +1,5 @@
/* global phpbb */ /* global phpbb */
/* eslint no-var: 0 */
/* /*
javascript for Bubble Tooltips by Alessandro Fulciniti javascript for Bubble Tooltips by Alessandro Fulciniti
@ -24,14 +25,14 @@ var tooltips = [];
* @param {string} headline Text that should appear on top of tooltip * @param {string} headline Text that should appear on top of tooltip
* @param {string} [subId] Sub ID that should only be using tooltips (optional) * @param {string} [subId] Sub ID that should only be using tooltips (optional)
*/ */
phpbb.enableTooltipsSelect = function (id, headline, subId) { phpbb.enableTooltipsSelect = function(id, headline, subId) {
var $links, hold; var $links, hold;
hold = $('<span />', { hold = $('<span />', {
id: '_tooltip_container', id: '_tooltip_container',
css: { css: {
position: 'absolute' position: 'absolute',
} },
}); });
$('body').append(hold); $('body').append(hold);
@ -42,7 +43,7 @@ phpbb.enableTooltipsSelect = function (id, headline, subId) {
$links = $('.roles-options li', '#' + id); $links = $('.roles-options li', '#' + id);
} }
$links.each(function () { $links.each(function() {
var $this = $(this); var $this = $(this);
if (subId) { if (subId) {
@ -61,7 +62,7 @@ phpbb.enableTooltipsSelect = function (id, headline, subId) {
* @param {jQuery} $element Element to prepare for tooltips * @param {jQuery} $element Element to prepare for tooltips
* @param {string} headText Text heading to display * @param {string} headText Text heading to display
*/ */
phpbb.prepareTooltips = function ($element, headText) { phpbb.prepareTooltips = function($element, headText) {
var $tooltip, text, $desc, $title; var $tooltip, text, $desc, $title;
text = $element.attr('data-title'); text = $element.attr('data-title');
@ -73,8 +74,8 @@ phpbb.prepareTooltips = function ($element, headText) {
$title = $('<span />', { $title = $('<span />', {
class: 'top', class: 'top',
css: { css: {
display: 'block' display: 'block',
} },
}) })
.append(document.createTextNode(headText)); .append(document.createTextNode(headText));
@ -82,15 +83,15 @@ phpbb.prepareTooltips = function ($element, headText) {
class: 'bottom', class: 'bottom',
html: text, html: text,
css: { css: {
display: 'block' display: 'block',
} },
}); });
$tooltip = $('<span />', { $tooltip = $('<span />', {
class: 'tooltip', class: 'tooltip',
css: { css: {
display: 'block' display: 'block',
} },
}) })
.append($title) .append($title)
.append($desc); .append($desc);
@ -105,7 +106,7 @@ phpbb.prepareTooltips = function ($element, headText) {
* *
* @param {object} $element Element passed by .on() * @param {object} $element Element passed by .on()
*/ */
phpbb.showTooltip = function ($element) { phpbb.showTooltip = function($element) {
var $this = $($element.target); var $this = $($element.target);
$('#_tooltip_container').append(tooltips[$this.attr('data-id')]); $('#_tooltip_container').append(tooltips[$this.attr('data-id')]);
phpbb.positionTooltip($this); phpbb.positionTooltip($this);
@ -114,7 +115,7 @@ phpbb.showTooltip = function ($element) {
/** /**
* Hide tooltip * Hide tooltip
*/ */
phpbb.hideTooltip = function () { phpbb.hideTooltip = function() {
var d = document.getElementById('_tooltip_container'); var d = document.getElementById('_tooltip_container');
if (d.childNodes.length > 0) { if (d.childNodes.length > 0) {
d.removeChild(d.firstChild); d.removeChild(d.firstChild);
@ -126,7 +127,7 @@ phpbb.hideTooltip = function () {
* *
* @param {jQuery} $element Tooltip element that should be positioned * @param {jQuery} $element Tooltip element that should be positioned
*/ */
phpbb.positionTooltip = function ($element) { phpbb.positionTooltip = function($element) {
var offset; var offset;
$element = $element.parent(); $element = $element.parent();
@ -135,12 +136,12 @@ phpbb.positionTooltip = function ($element) {
if ($('body').hasClass('rtl')) { if ($('body').hasClass('rtl')) {
$('#_tooltip_container').css({ $('#_tooltip_container').css({
top: offset.top + 30, top: offset.top + 30,
left: offset.left + 255 left: offset.left + 255,
}); });
} else { } else {
$('#_tooltip_container').css({ $('#_tooltip_container').css({
top: offset.top + 30, top: offset.top + 30,
left: offset.left - 205 left: offset.left - 205,
}); });
} }
}; };
@ -148,13 +149,13 @@ phpbb.positionTooltip = function ($element) {
/** /**
* Prepare roles drop down select * Prepare roles drop down select
*/ */
phpbb.prepareRolesDropdown = function () { phpbb.prepareRolesDropdown = function() {
var $options = $('.roles-options li'); var $options = $('.roles-options li');
// Display span and hide select // Display span and hide select
$('.roles-options > span').css('display', 'block'); $('.roles-options > span').css('display', 'block');
$('.roles-options > select').hide(); $('.roles-options > select').hide();
$('.roles-options > input[type=hidden]').each(function () { $('.roles-options > input[type=hidden]').each(function() {
var $this = $(this); var $this = $(this);
if ($this.attr('data-name') && !$this.attr('name')) { if ($this.attr('data-name') && !$this.attr('name')) {
@ -163,7 +164,7 @@ phpbb.prepareRolesDropdown = function () {
}); });
// Prepare highlighting of select options and settings update // Prepare highlighting of select options and settings update
$options.each(function () { $options.each(function() {
var $this = $(this); var $this = $(this);
var $rolesOptions = $this.closest('.roles-options'); var $rolesOptions = $this.closest('.roles-options');
var $span = $rolesOptions.children('span'); var $span = $rolesOptions.children('span');
@ -182,18 +183,18 @@ phpbb.prepareRolesDropdown = function () {
} }
// Prepare resetting drop down on form reset // Prepare resetting drop down on form reset
$this.closest('form').on('reset', function () { $this.closest('form').on('reset', function() {
$span.text($span.attr('data-default')); $span.text($span.attr('data-default'));
$rolesOptions.children('input[type=hidden]') $rolesOptions.children('input[type=hidden]')
.val($span.attr('data-default-val')); .val($span.attr('data-default-val'));
}); });
} }
$this.on('mouseover', function () { $this.on('mouseover', function() {
var $this = $(this); var $this = $(this);
$options.removeClass('roles-highlight'); $options.removeClass('roles-highlight');
$this.addClass('roles-highlight'); $this.addClass('roles-highlight');
}).on('click', function () { }).on('click', function() {
var $this = $(this); var $this = $(this);
var $rolesOptions = $this.closest('.roles-options'); var $rolesOptions = $this.closest('.roles-options');

View file

@ -1,4 +1,6 @@
/* global bbfontstyle */ /* global bbfontstyle */
/* eslint no-var: 0 */
/* eslint no-unused-vars: 0 */
var phpbb = {}; var phpbb = {};
phpbb.alertTime = 100; phpbb.alertTime = 100;
@ -13,7 +15,7 @@ var keymap = {
ENTER: 13, ENTER: 13,
ESC: 27, ESC: 27,
ARROW_UP: 38, ARROW_UP: 38,
ARROW_DOWN: 40 ARROW_DOWN: 40,
}; };
var $dark = $('#darkenwrapper'); var $dark = $('#darkenwrapper');
@ -54,7 +56,7 @@ phpbb.loadingIndicator = function() {
/** /**
* Show timeout message * Show timeout message
*/ */
phpbb.showTimeoutMessage = function () { phpbb.showTimeoutMessage = function() {
var $alert = $('#phpbb_alert'); var $alert = $('#phpbb_alert');
if ($loadingIndicator.is(':visible')) { if ($loadingIndicator.is(':visible')) {
@ -363,7 +365,7 @@ phpbb.ajaxify = function(options) {
type: 'POST', type: 'POST',
data: data + '&confirm=' + res.YES_VALUE + '&' + $('form', '#phpbb_confirm').serialize(), data: data + '&confirm=' + res.YES_VALUE + '&' + $('form', '#phpbb_confirm').serialize(),
success: returnHandler, success: returnHandler,
error: errorHandler error: errorHandler,
}); });
}, false); }, false);
} }
@ -383,7 +385,7 @@ phpbb.ajaxify = function(options) {
submit = $this.find('input[type="submit"][data-clicked]'); submit = $this.find('input[type="submit"][data-clicked]');
data.push({ data.push({
name: submit.attr('name'), name: submit.attr('name'),
value: submit.val() value: submit.val(),
}); });
} }
} else if (isText) { } else if (isText) {
@ -409,7 +411,7 @@ phpbb.ajaxify = function(options) {
data: data, data: data,
success: returnHandler, success: returnHandler,
error: errorHandler, error: errorHandler,
cache: false cache: false,
}); });
request.always(function() { request.always(function() {
@ -430,7 +432,7 @@ phpbb.ajaxify = function(options) {
}); });
if (isForm) { if (isForm) {
$elements.find('input:submit').click(function () { $elements.find('input:submit').click(function() {
var $this = $(this); var $this = $(this);
// Remove data-clicked attribute from any submit button of form // Remove data-clicked attribute from any submit button of form
@ -445,10 +447,10 @@ phpbb.ajaxify = function(options) {
phpbb.search = { phpbb.search = {
cache: { cache: {
data: [] data: [],
}, },
tpl: [], tpl: [],
container: [] container: [],
}; };
/** /**
@ -524,7 +526,7 @@ phpbb.search.getKeyword = function($input, keyword, multiline) {
* @param {jQuery} $textarea Search textarea. * @param {jQuery} $textarea Search textarea.
* @returns {int} The line number. * @returns {int} The line number.
*/ */
phpbb.search.getKeywordLine = function ($textarea) { phpbb.search.getKeywordLine = function($textarea) {
var selectionStart = $textarea.get(0).selectionStart; var selectionStart = $textarea.get(0).selectionStart;
return $textarea.val().substr(0, selectionStart).split('\n').length - 1; return $textarea.val().substr(0, selectionStart).split('\n').length - 1;
}; };
@ -609,7 +611,7 @@ phpbb.search.filter = function(data, event, sendRequest) {
if (cache.results[keyword]) { if (cache.results[keyword]) {
var response = { var response = {
keyword: keyword, keyword: keyword,
results: cache.results[keyword] results: cache.results[keyword],
}; };
phpbb.search.handleResponse(response, $this, true); phpbb.search.handleResponse(response, $this, true);
proceed = false; proceed = false;
@ -1079,7 +1081,7 @@ phpbb.addAjaxCallback('toggle_link', function() {
$this.attr('href', toggleUrl); $this.attr('href', toggleUrl);
// Toggle Icon // Toggle Icon
$this.children().first().toggleClass('is-active').next().toggleClass('is-active') $this.children().first().toggleClass('is-active').next().toggleClass('is-active');
}); });
}); });
@ -1113,7 +1115,7 @@ phpbb.resizeTextArea = function($items, options) {
maxHeight: 500, maxHeight: 500,
heightDiff: 200, heightDiff: 200,
resizeCallback: function() {}, resizeCallback: function() {},
resetCallback: function() {} resetCallback: function() {},
}; };
if (phpbb.isTouch) { if (phpbb.isTouch) {
@ -1152,7 +1154,7 @@ phpbb.resizeTextArea = function($items, options) {
var maxHeight = Math.min( var maxHeight = Math.min(
Math.max(windowHeight - configuration.heightDiff, configuration.minHeight), Math.max(windowHeight - configuration.heightDiff, configuration.minHeight),
configuration.maxHeight configuration.maxHeight,
), ),
$item = $(item), $item = $(item),
height = parseInt($item.innerHeight(), 10), height = parseInt($item.innerHeight(), 10),
@ -1243,9 +1245,9 @@ phpbb.inBBCodeTag = function(textarea, startTags, endTags) {
*/ */
phpbb.applyCodeEditor = function(textarea) { phpbb.applyCodeEditor = function(textarea) {
// list of allowed start and end bbcode code tags, in lower case // list of allowed start and end bbcode code tags, in lower case
var startTags = ['[code]', '[code='], var startTags = [ '[code]', '[code=' ],
startTagsEnd = ']', startTagsEnd = ']',
endTags = ['[/code]']; endTags = [ '[/code]' ];
if (!textarea || typeof textarea.selectionStart !== 'number') { if (!textarea || typeof textarea.selectionStart !== 'number') {
return; return;
@ -1353,12 +1355,12 @@ phpbb.showDragNDrop = function(textarea) {
return; return;
} }
$('body').on('dragenter dragover', function () { $('body').on('dragenter dragover', function() {
$(textarea).addClass('drag-n-drop'); $(textarea).addClass('drag-n-drop');
}).on('dragleave dragout dragend drop', function() { }).on('dragleave dragout dragend drop', function() {
$(textarea).removeClass('drag-n-drop'); $(textarea).removeClass('drag-n-drop');
}); });
$(textarea).on('dragenter dragover', function () { $(textarea).on('dragenter dragover', function() {
$(textarea).addClass('drag-n-drop-highlight'); $(textarea).addClass('drag-n-drop-highlight');
}).on('dragleave dragout dragend drop', function() { }).on('dragleave dragout dragend drop', function() {
$(textarea).removeClass('drag-n-drop-highlight'); $(textarea).removeClass('drag-n-drop-highlight');
@ -1434,7 +1436,7 @@ phpbb.toggleDropdown = function(event_) {
marginLeft: 0, marginLeft: 0,
left: 0, left: 0,
marginRight: 0, marginRight: 0,
maxWidth: (windowWidth - 4) + 'px' maxWidth: (windowWidth - 4) + 'px',
}); });
var offset = $this.offset().left, var offset = $this.offset().left,
@ -1468,7 +1470,7 @@ phpbb.toggleDropdown = function(event_) {
var maxOffset = Math.min(contentWidth, fullFreeSpace) + 'px'; var maxOffset = Math.min(contentWidth, fullFreeSpace) + 'px';
options.dropdown.css({ options.dropdown.css({
width: maxOffset, width: maxOffset,
marginLeft: -maxOffset marginLeft: -maxOffset,
}); });
} }
} else { } else {
@ -1512,7 +1514,7 @@ phpbb.registerDropdown = function(toggle, dropdown, options) {
leftClass: 'dropdown-left', // Class to add to parent item when dropdown opens to left side leftClass: 'dropdown-left', // Class to add to parent item when dropdown opens to left side
rightClass: 'dropdown-right', // Class to add to parent item when dropdown opens to right side rightClass: 'dropdown-right', // Class to add to parent item when dropdown opens to right side
upClass: 'dropdown-up', // Class to add to parent item when dropdown opens above menu item upClass: 'dropdown-up', // Class to add to parent item when dropdown opens above menu item
downClass: 'dropdown-down' // Class to add to parent item when dropdown opens below menu item downClass: 'dropdown-down', // Class to add to parent item when dropdown opens below menu item
}; };
if (options) { if (options) {
ops = $.extend(ops, options); ops = $.extend(ops, options);
@ -1666,7 +1668,7 @@ phpbb.toggleSelectSettings = function(el) {
* @param {string} functionName Function to get. * @param {string} functionName Function to get.
* @returns function * @returns function
*/ */
phpbb.getFunctionByName = function (functionName) { phpbb.getFunctionByName = function(functionName) {
var namespaces = functionName.split('.'), var namespaces = functionName.split('.'),
func = namespaces.pop(), func = namespaces.pop(),
context = window; context = window;
@ -1716,7 +1718,7 @@ phpbb.registerPageDropdowns = function() {
$contents = $this.find('.dropdown'), $contents = $this.find('.dropdown'),
options = { options = {
direction: 'auto', direction: 'auto',
verticalDirection: 'auto' verticalDirection: 'auto',
}, },
data; data;
@ -1763,7 +1765,7 @@ phpbb.registerPageDropdowns = function() {
* Handle avatars to be lazy loaded. * Handle avatars to be lazy loaded.
*/ */
phpbb.lazyLoadAvatars = function loadAvatars() { phpbb.lazyLoadAvatars = function loadAvatars() {
$('.avatar[data-src]').each(function () { $('.avatar[data-src]').each(function() {
var $avatar = $(this); var $avatar = $(this);
$avatar $avatar
@ -1795,7 +1797,7 @@ phpbb.getEditorTextArea = function(formName, textareaName) {
} }
return doc.forms[formName].elements[textareaName]; return doc.forms[formName].elements[textareaName];
} };
phpbb.recaptcha = { phpbb.recaptcha = {
button: null, button: null,
@ -1826,7 +1828,7 @@ phpbb.recaptcha = {
if (phpbb.recaptcha.v3.length) { if (phpbb.recaptcha.v3.length) {
grecaptcha.execute( grecaptcha.execute(
phpbb.recaptcha.v3.data('recaptcha-v3'), phpbb.recaptcha.v3.data('recaptcha-v3'),
{action: phpbb.recaptcha.v3.val()} { action: phpbb.recaptcha.v3.val() },
).then(function(token) { ).then(function(token) {
// Place the token inside the form // Place the token inside the form
phpbb.recaptcha.token.val(token); phpbb.recaptcha.token.val(token);
@ -1860,7 +1862,7 @@ phpbb.recaptcha = {
phpbb.recaptcha.form.submit(); phpbb.recaptcha.form.submit();
} }
} },
}; };
// reCAPTCHA v2 doesn't accept callback functions nested inside objects // reCAPTCHA v2 doesn't accept callback functions nested inside objects

View file

@ -1,4 +1,8 @@
/* global phpbb */ /* global phpbb */
/* eslint camelcase: 0 */
/* eslint no-undef: 0 */
/* eslint no-unused-vars: 0 */
/* eslint no-var: 0 */
/** /**
* bbCode control by subBlue design [ www.subBlue.com ] * bbCode control by subBlue design [ www.subBlue.com ]
@ -100,7 +104,7 @@ function bbfontstyle(bbopen, bbclose) {
// IE // IE
else if (document.selection) { else if (document.selection) {
var range = textarea.createTextRange(); var range = textarea.createTextRange();
range.move("character", new_pos); range.move('character', new_pos);
range.select(); range.select();
storeCaret(textarea); storeCaret(textarea);
} }
@ -271,7 +275,7 @@ function formatAttributeValue(str) {
// Return as-is if it contains none of: space, ' " \ or ] // Return as-is if it contains none of: space, ' " \ or ]
return str; return str;
} }
var singleQuoted = "'" + str.replace(/[\\']/g, '\\$&') + "'", var singleQuoted = '\'' + str.replace(/[\\']/g, '\\$&') + '\'',
doubleQuoted = '"' + str.replace(/[\\"]/g, '\\$&') + '"'; doubleQuoted = '"' + str.replace(/[\\"]/g, '\\$&') + '"';
return (singleQuoted.length < doubleQuoted.length) ? singleQuoted : doubleQuoted; return (singleQuoted.length < doubleQuoted.length) ? singleQuoted : doubleQuoted;
@ -404,7 +408,7 @@ function getCaretPosition(txtarea) {
phpbb.showDragNDrop(textarea); phpbb.showDragNDrop(textarea);
} }
$('textarea').on('keydown', function (e) { $('textarea').on('keydown', function(e) {
if (e.which === 13 && (e.metaKey || e.ctrlKey)) { if (e.which === 13 && (e.metaKey || e.ctrlKey)) {
$(this).closest('form').find(':submit').click(); $(this).closest('form').find(':submit').click();
} }

View file

@ -2,6 +2,9 @@
* Installer's AJAX frontend handler * Installer's AJAX frontend handler
*/ */
/* eslint no-prototype-builtins: 0 */
/* eslint no-var: 0 */
(function($) { // Avoid conflicts with other libraries (function($) { // Avoid conflicts with other libraries
'use strict'; 'use strict';
@ -359,10 +362,10 @@
} else { } else {
$('#loading_indicator').css('display', 'none'); $('#loading_indicator').css('display', 'none');
addMessage('error', addMessage('error',
[{ [ {
title: installLang.title, title: installLang.title,
description: installLang.msg description: installLang.msg,
}] } ],
); );
} }
} }
@ -487,7 +490,7 @@
function startPolling(xhReq) { function startPolling(xhReq) {
resetPolling(); resetPolling();
transmissionOver = false; transmissionOver = false;
pollTimer = setInterval(function () { pollTimer = setInterval(function() {
pollContent(xhReq); pollContent(xhReq);
}, 250); }, 250);
} }
@ -609,7 +612,7 @@
setAdminTimezone($form); setAdminTimezone($form);
} }
$form.find(':submit').bind('click', function (event) { $form.find(':submit').bind('click', function(event) {
event.preventDefault(); event.preventDefault();
submitForm($form, $(this)); submitForm($form, $(this));
}); });

View file

@ -1,4 +1,7 @@
/* global phpbb, plupload, attachInline */ /* global phpbb, plupload, attachInline */
/* eslint camelcase: 0 */
/* eslint no-var: 0 */
/* eslint no-unused-vars: 0 */
plupload.addI18n(phpbb.plupload.i18n); plupload.addI18n(phpbb.plupload.i18n);
phpbb.plupload.ids = []; phpbb.plupload.ids = [];
@ -21,7 +24,7 @@ phpbb.plupload.initialize = function() {
// Only execute if Plupload initialized successfully. // Only execute if Plupload initialized successfully.
phpbb.plupload.uploader.bind('Init', function() { phpbb.plupload.uploader.bind('Init', function() {
phpbb.plupload.form = $(phpbb.plupload.config.form_hook)[0]; phpbb.plupload.form = $(phpbb.plupload.config.form_hook)[0];
let $attachRowTemplate = $('#attach-row-tpl'); const $attachRowTemplate = $('#attach-row-tpl');
$attachRowTemplate.removeClass('attach-row-tpl'); $attachRowTemplate.removeClass('attach-row-tpl');
phpbb.plupload.rowTpl = $attachRowTemplate[0].outerHTML; phpbb.plupload.rowTpl = $attachRowTemplate[0].outerHTML;
@ -300,7 +303,7 @@ phpbb.plupload.deleteFile = function(row, attachId) {
$.ajax(phpbb.plupload.config.url, { $.ajax(phpbb.plupload.config.url, {
type: 'POST', type: 'POST',
data: $.extend(fields, phpbb.plupload.getSerializedData()), data: $.extend(fields, phpbb.plupload.getSerializedData()),
headers: phpbb.plupload.config.headers headers: phpbb.plupload.config.headers,
}) })
.always(always) .always(always)
.done(done); .done(done);
@ -452,7 +455,7 @@ phpbb.plupload.fileError = function(file, error) {
.addClass('file-error') .addClass('file-error')
.attr({ .attr({
'data-error-title': phpbb.plupload.lang.ERROR, 'data-error-title': phpbb.plupload.lang.ERROR,
'data-error-message': error 'data-error-message': error,
}); });
}; };
@ -469,14 +472,14 @@ phpbb.plupload.initialize();
plupload.addFileFilter('mime_types_max_file_size', function(types, file, callback) { plupload.addFileFilter('mime_types_max_file_size', function(types, file, callback) {
if (file.size !== 'undefined') { if (file.size !== 'undefined') {
$(types).each(function(i, type) { $(types).each(function(i, type) {
let extensions = [], const extensions = [],
extsArray = type.extensions.split(','); extsArray = type.extensions.split(',');
$(extsArray).each(function(i, extension) { $(extsArray).each(function(i, extension) {
/^\s*\*\s*$/.test(extension) ? extensions.push("\\.*") : extensions.push("\\." + extension.replace(new RegExp("[" + "/^$.*+?|()[]{}\\".replace(/./g, "\\$&") + "]", "g"), "\\$&")); /^\s*\*\s*$/.test(extension) ? extensions.push('\\.*') : extensions.push('\\.' + extension.replace(new RegExp('[' + '/^$.*+?|()[]{}\\'.replace(/./g, '\\$&') + ']', 'g'), '\\$&'));
}); });
let regex = new RegExp("(" + extensions.join("|") + ")$", "i"); const regex = new RegExp('(' + extensions.join('|') + ')$', 'i');
if (regex.test(file.name)) { if (regex.test(file.name)) {
if (type.max_file_size !== 'undefined' && type.max_file_size) { if (type.max_file_size !== 'undefined' && type.max_file_size) {
@ -484,7 +487,7 @@ plupload.addFileFilter('mime_types_max_file_size', function(types, file, callbac
phpbb.plupload.uploader.trigger('Error', { phpbb.plupload.uploader.trigger('Error', {
code: plupload.FILE_SIZE_ERROR, code: plupload.FILE_SIZE_ERROR,
message: plupload.translate('File size error.'), message: plupload.translate('File size error.'),
file: file file: file,
}); });
callback(false); callback(false);
@ -587,9 +590,9 @@ phpbb.plupload.uploader.bind('ChunkUploaded', function(up, file, response) {
up.trigger('FileUploaded', file, { up.trigger('FileUploaded', file, {
response: JSON.stringify({ response: JSON.stringify({
error: { error: {
message: 'Error parsing server response.' message: 'Error parsing server response.',
} },
}) }),
}); });
} }
@ -603,9 +606,9 @@ phpbb.plupload.uploader.bind('ChunkUploaded', function(up, file, response) {
up.trigger('FileUploaded', file, { up.trigger('FileUploaded', file, {
response: JSON.stringify({ response: JSON.stringify({
error: { error: {
message: json.error.message message: json.error.message,
} },
}) }),
}); });
} }
}); });
@ -692,7 +695,7 @@ phpbb.plupload.uploader.bind('FileUploaded', function(up, file, response) {
row.attr('data-attach-id', file.attachment_data.attach_id); row.attr('data-attach-id', file.attachment_data.attach_id);
row.find('.file-inline-bbcode').show(); row.find('.file-inline-bbcode').show();
row.find('.file-status').addClass('file-uploaded'); row.find('.file-status').addClass('file-uploaded');
phpbb.plupload.update(json.data, 'addition', 0, [json.download_url]); phpbb.plupload.update(json.data, 'addition', 0, [ json.download_url ]);
} }
}); });

View file

@ -1,4 +1,6 @@
/* global phpbb */ /* global phpbb */
/* eslint camelcase: 0 */
/* eslint no-var: 0 */
(function($) { // Avoid conflicts with other libraries (function($) { // Avoid conflicts with other libraries
@ -11,7 +13,7 @@ phpbb.addAjaxCallback('mark_forums_read', function(res) {
var iconsArray = { var iconsArray = {
forum_unread: 'forum_read', forum_unread: 'forum_read',
forum_unread_subforum: 'forum_read_subforum', 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() { $('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', global_unread: 'global_read',
announce_unread: 'announce_read', announce_unread: 'announce_read',
sticky_unread: 'sticky_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 unreadClassSelectors;
var classMap = {}; var classMap = {};
var classNames = []; var classNames = [];
@ -206,7 +208,7 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
var mostVotes = 0; var mostVotes = 0;
// Set min-height to prevent the page from jumping when the content changes // 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; height = (typeof height === 'undefined') ? panel.find('.inner').outerHeight() : height;
panel.css('min-height', height); panel.css('min-height', height);
}; };
@ -218,7 +220,7 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
} }
if (!res.can_vote) { 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(); poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show();
}); });
} else { } else {
@ -260,7 +262,7 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
var barTimeLapse = (res.can_vote) ? 500 : 1500; var barTimeLapse = (res.can_vote) ? 500 : 1500;
var newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1); var newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1);
setTimeout(function () { setTimeout(function() {
bar.animate({ width: percentRel + '%' }, 500) bar.animate({ width: percentRel + '%' }, 500)
.removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5') .removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5')
.addClass(newBarClass) .addClass(newBarClass)
@ -292,13 +294,13 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
resizePanel(500); resizePanel(500);
}, 1500); }, 1500);
var resizePanel = function (time) { var resizePanel = function(time) {
var panelHeight = panel.height(); var panelHeight = panel.height();
var innerHeight = panel.find('.inner').outerHeight(); var innerHeight = panel.find('.inner').outerHeight();
if (panelHeight !== innerHeight) { if (panelHeight !== innerHeight) {
panel.css({ minHeight: '', height: panelHeight }) panel.css({ minHeight: '', height: panelHeight })
.animate({ height: innerHeight }, time, function () { .animate({ height: innerHeight }, time, function() {
panel.css({ minHeight: innerHeight, height: '' }); panel.css({ minHeight: innerHeight, height: '' });
}); });
} }
@ -332,7 +334,7 @@ $('[data-ajax]').each(function() {
selector: this, selector: this,
refresh: $this.attr('data-refresh') !== undefined, refresh: $this.attr('data-refresh') !== undefined,
filter: filter, filter: filter,
callback: fn callback: fn,
}); });
} }
}); });
@ -367,7 +369,7 @@ $('.display_post').click(function(e) {
$('.display_post_review').on('click', function(e) { $('.display_post_review').on('click', function(e) {
e.preventDefault(); e.preventDefault();
let $displayPostLink = $(this); const $displayPostLink = $(this);
$displayPostLink.closest('.post-ignore').removeClass('post-ignore'); $displayPostLink.closest('.post-ignore').removeClass('post-ignore');
$displayPostLink.hide(); $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 * 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. * appropriately changed based on the status of the search panel.
*/ */
$('#member_search').click(function () { $('#member_search').click(function() {
var $memberlistSearch = $('#memberlist_search'); var $memberlistSearch = $('#memberlist_search');
$memberlistSearch.slideToggle('fast'); $memberlistSearch.slideToggle('fast');
@ -399,7 +401,7 @@ const $scrollTopButton = $('.to-top-button');
if ($scrollTopButton.length) { if ($scrollTopButton.length) {
// Show or hide the button based on scroll position // Show or hide the button based on scroll position
$(window).scroll(function () { $(window).scroll(function() {
if ($(this).scrollTop() > 300) { if ($(this).scrollTop() > 300) {
$scrollTopButton.fadeIn(); // Fade in the button $scrollTopButton.fadeIn(); // Fade in the button
} else { } else {
@ -408,9 +410,9 @@ if ($scrollTopButton.length) {
}); });
// Scroll smoothly to the top when the button is clicked // 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 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 */ /* global phpbb */
/* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */
/* eslint no-var:0 */
/** /**
* phpBB forum functions * phpBB forum functions
@ -103,14 +106,14 @@ jQuery(function($) {
$('.sub-panels').each(function() { $('.sub-panels').each(function() {
var $childNodes = $('a[data-subpanel]', this), var $childNodes = $('a[data-subpanel]', this),
panels = $childNodes.map(function () { panels = $childNodes.map(function() {
return this.getAttribute('data-subpanel'); return this.getAttribute('data-subpanel');
}), }),
showPanel = this.getAttribute('data-show-panel'); showPanel = this.getAttribute('data-show-panel');
if (panels.length) { if (panels.length) {
activateSubPanel(showPanel, panels); activateSubPanel(showPanel, panels);
$childNodes.click(function () { $childNodes.click(function() {
activateSubPanel(this.getAttribute('data-subpanel'), panels); activateSubPanel(this.getAttribute('data-subpanel'), panels);
return false; return false;
}); });
@ -232,7 +235,7 @@ function phpbbCheckKey(event) {
jQuery(function($) { jQuery(function($) {
'use strict'; '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'); var defaultButton = $(this).parents('form').find('input[type=submit].default-submit-action');
if (!defaultButton || defaultButton.length <= 0) { if (!defaultButton || defaultButton.length <= 0) {
@ -369,7 +372,7 @@ function parseDocument($container) {
var $this = $(this), var $this = $(this),
$links = $this.find('.crumb'), $links = $this.find('.crumb'),
length = $links.length, 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, classesLength = classes.length,
maxHeight = 0, maxHeight = 0,
lastWidth = false, lastWidth = false,
@ -496,7 +499,7 @@ function parseDocument($container) {
// Find all headers, get contents // Find all headers, get contents
$list.prev('.topiclist').find('li.header dd').not('.mark').each(function() { $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++; headersLength++;
}); });
@ -600,7 +603,7 @@ function parseDocument($container) {
if ((text.length && text !== '-') || cell.children().length) { if ((text.length && text !== '-') || cell.children().length) {
if (headers[column].length) { if (headers[column].length) {
cell.prepend($("<dfn>").css('display', 'none').text(headers[column])); cell.prepend($('<dfn>').css('display', 'none').text(headers[column]));
} }
} else { } else {
cell.addClass('empty'); cell.addClass('empty');
@ -687,7 +690,7 @@ function parseDocument($container) {
var $tabLink = $item.find('a.responsive-tab-link'); var $tabLink = $item.find('a.responsive-tab-link');
phpbb.registerDropdown($tabLink, $item.find('.dropdown'), { phpbb.registerDropdown($tabLink, $item.find('.dropdown'), {
visibleClass: 'activetab' visibleClass: 'activetab',
}); });
check(true); check(true);