Compare commits

..

No commits in common. "b82d7d3f473372f31dd97c09fc93f7adec72fc84" and "2daabd34be38d0bdf41147e6094384bba6b89e01" have entirely different histories.

12 changed files with 629 additions and 641 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" --ignore-pattern "phpBB/ext/" node_modules/eslint/bin/eslint.js "phpBB/**/*.js"
node_modules/eslint/bin/eslint.js "phpBB/**/*.js.twig" --ignore-pattern "phpBB/ext/" node_modules/eslint/bin/eslint.js "phpBB/**/*.js.twig"
node_modules/eslint/bin/eslint.js "gulpfile.js" node_modules/eslint/bin/eslint.js "gulpfile.js"

View file

@ -5,6 +5,7 @@ const IGNORED_FILES = [
'phpBB/assets/javascript/cropper.js', 'phpBB/assets/javascript/cropper.js',
'phpBB/assets/javascript/hermite.js', 'phpBB/assets/javascript/hermite.js',
'phpBB/assets/javascript/jquery-cropper.js', 'phpBB/assets/javascript/jquery-cropper.js',
'phpBB/ext/**/*.js',
'phpBB/**/*.min.js', 'phpBB/**/*.min.js',
'phpBB/vendor/**/*.js', 'phpBB/vendor/**/*.js',
'phpBB/vendor-ext/**/*.js', 'phpBB/vendor-ext/**/*.js',

View file

@ -1,5 +1,4 @@
/* global phpbb */ /* global phpbb */
/* eslint no-var: 0 */
/** /**
* phpBB3 ACP functions * phpBB3 ACP functions
@ -9,15 +8,15 @@
* Parse document block * Parse document block
*/ */
function parseDocument(container) { function parseDocument(container) {
var test = document.createElement('div'); const test = document.createElement('div');
test.remove(); test.remove();
/** /**
* Navigation * Navigation
*/ */
container.find('#menu').each(function() { container.find('#menu').each(function() {
var menu = $(this); const menu = $(this);
var blocks = menu.children('.menu-block'); const blocks = menu.children('.menu-block');
if (!blocks.length) { if (!blocks.length) {
return; return;
@ -25,7 +24,7 @@ function parseDocument(container) {
// Set onclick event // Set onclick event
blocks.children('a.header').click(function() { blocks.children('a.header').click(function() {
var parent = $(this).parent(); const parent = $(this).parent();
if (!parent.hasClass('active')) { if (!parent.hasClass('active')) {
parent.siblings().removeClass('active'); parent.siblings().removeClass('active');
} }
@ -46,22 +45,22 @@ function parseDocument(container) {
* Responsive tables * Responsive tables
*/ */
container.find('table').not('.not-responsive').each(function() { container.find('table').not('.not-responsive').each(function() {
var $this = $(this); const $this = $(this);
var th = $this.find('thead > tr > th'); const th = $this.find('thead > tr > th');
var headers = []; const headers = [];
var totalHeaders = 0; let totalHeaders = 0;
var i; let i;
// Find columns // Find columns
$this.find('colgroup:first').children().each(function(i) { $this.find('colgroup:first').children().each(function(i) {
var column = $(this); const column = $(this);
$this.find('td:nth-child(' + (i + 1) + ')').addClass(column.prop('className')); $this.find('td:nth-child(' + (i + 1) + ')').addClass(column.prop('className'));
}); });
// Styles table // Styles table
if ($this.hasClass('styles')) { if ($this.hasClass('styles')) {
$this.find('td:first-child[style]').each(function() { $this.find('td:first-child[style]').each(function() {
var style = $(this).attr('style'); const style = $(this).attr('style');
if (style.length) { if (style.length) {
$(this).parent('tr').attr('style', style.toLowerCase().replace('padding', 'margin')).addClass('responsive-style-row'); $(this).parent('tr').attr('style', style.toLowerCase().replace('padding', 'margin')).addClass('responsive-style-row');
} }
@ -71,10 +70,10 @@ function parseDocument(container) {
// Find each header // Find each header
if (!$this.data('no-responsive-header')) { if (!$this.data('no-responsive-header')) {
th.each(function(column) { th.each(function(column) {
var cell = $(this); const cell = $(this);
var colspan = parseInt(cell.attr('colspan'), 10); let colspan = parseInt(cell.attr('colspan'), 10);
var dfn = cell.attr('data-dfn'); const dfn = cell.attr('data-dfn');
var text = dfn ? dfn : $.trim(cell.text()); let text = dfn ? dfn : $.trim(cell.text());
if (text === ' ') { if (text === ' ') {
text = ''; text = '';
@ -94,7 +93,7 @@ function parseDocument(container) {
}); });
} }
headersLength = headers.length; const headersLength = headers.length;
// Add header text to each cell as <dfn> // Add header text to each cell as <dfn>
$this.addClass('responsive'); $this.addClass('responsive');
@ -105,9 +104,9 @@ function parseDocument(container) {
} }
$this.find('tbody > tr').each(function() { $this.find('tbody > tr').each(function() {
var row = $(this); const row = $(this);
var cells = row.children('td'); const cells = row.children('td');
var column = 0; let column = 0;
if (cells.length === 1) { if (cells.length === 1) {
row.addClass('big-column'); row.addClass('big-column');
@ -115,9 +114,9 @@ function parseDocument(container) {
} }
cells.each(function() { cells.each(function() {
var cell = $(this); const cell = $(this);
var colspan = parseInt(cell.attr('colspan'), 10); let colspan = parseInt(cell.attr('colspan'), 10);
var text = $.trim(cell.text()); const text = $.trim(cell.text());
if (headersLength <= column) { if (headersLength <= column) {
return; return;
@ -144,7 +143,7 @@ function parseDocument(container) {
* Hide empty responsive tables * Hide empty responsive tables
*/ */
container.find('table.responsive > tbody').each(function() { container.find('table.responsive > tbody').each(function() {
var items = $(this).children('tr'); const items = $(this).children('tr');
if (!items.length) { if (!items.length) {
$(this).parent('table:first').addClass('responsive-hide'); $(this).parent('table:first').addClass('responsive-hide');
} }
@ -154,7 +153,7 @@ function parseDocument(container) {
* Fieldsets with empty <span> * Fieldsets with empty <span>
*/ */
container.find('fieldset dt > span:last-child').each(function() { container.find('fieldset dt > span:last-child').each(function() {
var $this = $(this); const $this = $(this);
if ($this.html() === '&nbsp;') { if ($this.html() === '&nbsp;') {
$this.addClass('responsive-hide'); $this.addClass('responsive-hide');
} }
@ -165,7 +164,7 @@ function parseDocument(container) {
*/ */
container.find('#sitename_short').each(function() { container.find('#sitename_short').each(function() {
const $this = this; const $this = this;
const maxLength = $this.maxLength; const { maxLength } = $this;
$this.maxLength = maxLength * 2; $this.maxLength = maxLength * 2;
$this.addEventListener('input', () => { $this.addEventListener('input', () => {
const inputChars = Array.from($this.value); const inputChars = Array.from($this.value);
@ -179,25 +178,25 @@ function parseDocument(container) {
* Responsive tabs * Responsive tabs
*/ */
container.find('#tabs').not('[data-skip-responsive]').each(function() { container.find('#tabs').not('[data-skip-responsive]').each(function() {
var $this = $(this); const $this = $(this);
var $body = $('body'); const $body = $('body');
var ul = $this.children(); const ul = $this.children();
var tabs = ul.children().not('[data-skip-responsive]'); const tabs = ul.children().not('[data-skip-responsive]');
var links = tabs.children('a'); const links = tabs.children('a');
var item = ul.append('<li class="tab responsive-tab" style="display:none;"><a href="javascript:void(0);" class="responsive-tab-link">&nbsp;</a><div class="dropdown tab-dropdown" style="display: none;"><div class="pointer"><div class="pointer-inner"></div></div><ul class="dropdown-contents" /></div></li>').find('li.responsive-tab'); const item = ul.append('<li class="tab responsive-tab" style="display:none;"><a href="javascript:void(0);" class="responsive-tab-link">&nbsp;</a><div class="dropdown tab-dropdown" style="display: none;"><div class="pointer"><div class="pointer-inner"></div></div><ul class="dropdown-contents" /></div></li>').find('li.responsive-tab');
var menu = item.find('.dropdown-contents'); const menu = item.find('.dropdown-contents');
var maxHeight = 0; let maxHeight = 0;
var lastWidth = false; let lastWidth = false;
var responsive = false; let responsive = false;
links.each(function() { links.each(function() {
var link = $(this); const 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(); const width = $body.width();
var height = $this.height(); let height = $this.height();
if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) { if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) {
return; return;
@ -221,10 +220,10 @@ function parseDocument(container) {
item.show(); item.show();
menu.html(''); menu.html('');
var availableTabs = tabs.filter(':not(.activetab, .responsive-tab)'); const availableTabs = tabs.filter(':not(.activetab, .responsive-tab)');
var total = availableTabs.length; const total = availableTabs.length;
var i; let i;
var tab; let tab;
for (i = total - 1; i >= 0; i--) { for (i = total - 1; i >= 0; i--) {
tab = availableTabs.eq(i); tab = availableTabs.eq(i);
@ -266,10 +265,10 @@ function parseDocument(container) {
parseDocument($('body')); parseDocument($('body'));
$('#questionnaire-form').css('display', 'none'); $('#questionnaire-form').css('display', 'none');
var $triggerConfiglist = $('#trigger-configlist'); const $triggerConfiglist = $('#trigger-configlist');
$triggerConfiglist.on('click', function() { $triggerConfiglist.on('click', function() {
var $configlist = $('#configlist'); const $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');
$(this).find('i').toggleClass('fa-angle-down fa-angle-up'); $(this).find('i').toggleClass('fa-angle-down fa-angle-up');

View file

@ -1,25 +1,25 @@
/* 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'); const $form = $('#acp_help_phpbb');
var $dark = $('#darkenwrapper'); const $dark = $('#darkenwrapper');
var $loadingIndicator; let $loadingIndicator;
$form.on('submit', function(event) { $form.on('submit', function(event) {
var $this = $(this); const $this = $(this);
var currentTime = Math.floor(new Date().getTime() / 1000); const currentTime = Math.floor(new Date().getTime() / 1000);
var statsTime = parseInt($this.find('input[name=help_send_statistics_time]').val(), 10); const statsTime = parseInt($this.find('input[name=help_send_statistics_time]').val(), 10);
event.preventDefault(); event.preventDefault();
$this.unbind('submit'); $this.unbind('submit');
// Skip ajax request if form is submitted too early or send stats // Skip ajax request if form is submitted too early or send stats
// checkbox is not checked // checkbox is not checked
if (!$this.find('input[name=help_send_statistics]').is(':checked') || statsTime > currentTime) { if (!$this.find('input[name=help_send_statistics]').is(':checked')
|| statsTime > currentTime) {
$form.find('input[type=submit]').click(); $form.find('input[type=submit]').click();
setTimeout(() => { setTimeout(() => {
$form.find('input[type=submit]').click(); $form.find('input[type=submit]').click();
@ -36,7 +36,7 @@
} }
phpbb.clearLoadingTimeout(); phpbb.clearLoadingTimeout();
var errorText = ''; let errorText = '';
if (typeof errorThrown === 'string' && errorThrown.length > 0) { if (typeof errorThrown === 'string' && errorThrown.length > 0) {
errorText = errorThrown; errorText = errorThrown;
@ -71,7 +71,7 @@
$loadingIndicator.fadeOut(phpbb.alertTime); $loadingIndicator.fadeOut(phpbb.alertTime);
} }
var $sendStatisticsSuccess = $('<input />', { const $sendStatisticsSuccess = $('<input />', {
type: 'hidden', type: 'hidden',
name: 'send_statistics_response', name: 'send_statistics_response',
value: JSON.stringify(res), value: JSON.stringify(res),
@ -110,8 +110,8 @@
return; return;
} }
var $firstTr = $(this).parents('tr'); const $firstTr = $(this).parents('tr');
var $secondTr = $firstTr.next(); const $secondTr = $firstTr.next();
$firstTr.insertAfter($secondTr); $firstTr.insertAfter($secondTr);
}); });
@ -121,8 +121,8 @@
return; return;
} }
var $secondTr = $(this).parents('tr'); const $secondTr = $(this).parents('tr');
var $firstTr = $secondTr.prev(); const $firstTr = $secondTr.prev();
$secondTr.insertBefore($firstTr); $secondTr.insertBefore($firstTr);
}); });
@ -133,8 +133,8 @@
* in the href with "deactivate", and vice versa. * in the href with "deactivate", and vice versa.
*/ */
phpbb.addAjaxCallback('activate_deactivate', function(res) { phpbb.addAjaxCallback('activate_deactivate', function(res) {
var $this = $(this); const $this = $(this);
var newHref = $this.attr('href'); let newHref = $this.attr('href');
$this.text(res.text); $this.text(res.text);
@ -211,19 +211,19 @@
* This call will submit permissions forms in chunks of 5 fieldsets. * This call will submit permissions forms in chunks of 5 fieldsets.
*/ */
function submitPermissions() { function submitPermissions() {
var $form = $('form#set-permissions'); const $form = $('form#set-permissions');
var fieldsetList = $form.find('fieldset[id^=perm]'); let fieldsetList = $form.find('fieldset[id^=perm]');
var formDataSets = []; const formDataSets = [];
var dataSetIndex = 0; let dataSetIndex = 0;
var $submitAllButton = $form.find('input[type=submit][name^=action]')[0]; const $submitAllButton = $form.find('input[type=submit][name^=action]')[0];
var $submitButton = $form.find('input[type=submit][data-clicked=true]')[0]; const $submitButton = $form.find('input[type=submit][data-clicked=true]')[0];
// Set proper start values for handling refresh of page // Set proper start values for handling refresh of page
var permissionSubmitSize = 0; let permissionSubmitSize = 0;
var permissionRequestCount = 0; let permissionRequestCount = 0;
var forumIds = []; const forumIds = [];
var permissionSubmitFailed = false; let permissionSubmitFailed = false;
var clearIndicator = true; let clearIndicator = true;
if ($submitAllButton !== $submitButton) { if ($submitAllButton !== $submitButton) {
fieldsetList = $form.find('fieldset#' + $submitButton.closest('fieldset.permissions').id); fieldsetList = $form.find('fieldset#' + $submitButton.closest('fieldset.permissions').id);
@ -231,7 +231,7 @@
$.each(fieldsetList, (key, value) => { $.each(fieldsetList, (key, value) => {
dataSetIndex = Math.floor(key / 5); dataSetIndex = Math.floor(key / 5);
var $fieldset = $('fieldset#' + value.id); const $fieldset = $('fieldset#' + value.id);
if (key % 5 === 0) { if (key % 5 === 0) {
formDataSets[dataSetIndex] = $fieldset.find('select:visible, input:not([data-name])').serialize(); formDataSets[dataSetIndex] = $fieldset.find('select:visible, input:not([data-name])').serialize();
} else { } else {
@ -239,7 +239,7 @@
} }
// Find proper role value // Find proper role value
var roleInput = $fieldset.find('input[name^=role][data-name]'); const roleInput = $fieldset.find('input[name^=role][data-name]');
if (roleInput.val()) { if (roleInput.val()) {
formDataSets[dataSetIndex] += '&' + roleInput.attr('name') + '=' + roleInput.val(); formDataSets[dataSetIndex] += '&' + roleInput.attr('name') + '=' + roleInput.val();
} else { } else {
@ -257,7 +257,7 @@
} }
}); });
var $loadingIndicator = phpbb.loadingIndicator(); const $loadingIndicator = phpbb.loadingIndicator();
/** /**
* Handler for submitted permissions form chunk * Handler for submitted permissions form chunk
@ -266,7 +266,7 @@
*/ */
function handlePermissionReturn(res) { function handlePermissionReturn(res) {
permissionRequestCount++; permissionRequestCount++;
var $dark = $('#darkenwrapper'); const $dark = $('#darkenwrapper');
if (res.S_USER_WARNING) { if (res.S_USER_WARNING) {
phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
@ -276,8 +276,8 @@
if (permissionRequestCount >= permissionSubmitSize) { if (permissionRequestCount >= permissionSubmitSize) {
clearIndicator = true; clearIndicator = true;
var $alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); const $alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
var $alertBoxLink = $alert.find('p.alert_text > a'); const $alertBoxLink = $alert.find('p.alert_text > a');
// Create form to submit instead of normal "Back to previous page" link // Create form to submit instead of normal "Back to previous page" link
if ($alertBoxLink) { if ($alertBoxLink) {
@ -370,11 +370,11 @@
} }
$('[data-ajax]').each(function() { $('[data-ajax]').each(function() {
var $this = $(this); const $this = $(this);
var ajax = $this.attr('data-ajax'); const ajax = $this.attr('data-ajax');
if (ajax !== 'false') { if (ajax !== 'false') {
var fn = (ajax === 'true') ? null : ajax; const fn = (ajax === 'true') ? null : ajax;
phpbb.ajaxify({ phpbb.ajaxify({
selector: this, selector: this,
refresh: $this.attr('data-refresh') !== undefined, refresh: $this.attr('data-refresh') !== undefined,
@ -389,7 +389,7 @@
$(() => { $(() => {
phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), { minHeight: 75 }); phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), { minHeight: 75 });
var $setPermissionsForm = $('form#set-permissions'); const $setPermissionsForm = $('form#set-permissions');
if ($setPermissionsForm.length) { if ($setPermissionsForm.length) {
$setPermissionsForm.on('submit', e => { $setPermissionsForm.on('submit', e => {
submitPermissions(); submitPermissions();

View file

@ -2,16 +2,15 @@
/* eslint camelcase: 0 */ /* eslint camelcase: 0 */
/* eslint no-undef: 0 */ /* eslint no-undef: 0 */
/* eslint no-unused-vars: 0 */ /* eslint no-unused-vars: 0 */
/* eslint no-var: 0 */
/** /**
* Hide and show all checkboxes * Hide and show all checkboxes
* status = true (show boxes), false (hide boxes) * status = true (show boxes), false (hide boxes)
*/ */
function display_checkboxes(status) { function display_checkboxes(status) {
var form = document.getElementById('set-permissions'); const form = document.getElementById('set-permissions');
var cb = document.getElementsByTagName('input'); const cb = document.getElementsByTagName('input');
var display; let display;
if (status) { if (status) {
// show // show
@ -21,7 +20,7 @@ function display_checkboxes(status) {
display = 'none'; display = 'none';
} }
for (var i = 0; i < cb.length; i++ ) { for (let i = 0; i < cb.length; i++ ) {
if (cb[i].className === 'permissions-checkbox') { if (cb[i].className === 'permissions-checkbox') {
cb[i].style.display = display; cb[i].style.display = display;
} }
@ -45,8 +44,8 @@ function set_opacity(e, value) {
* block_id = id of the element that needs to be toggled * block_id = id of the element that needs to be toggled
*/ */
function toggle_opacity(block_id) { function toggle_opacity(block_id) {
var cb = document.getElementById('checkbox' + block_id); const cb = document.getElementById('checkbox' + block_id);
var fs = document.getElementById('perm' + block_id); const fs = document.getElementById('perm' + block_id);
if (cb.checked) { if (cb.checked) {
set_opacity(fs, 5); set_opacity(fs, 5);
@ -61,15 +60,15 @@ function toggle_opacity(block_id) {
* except_id = id of the element not to hide * except_id = id of the element not to hide
*/ */
function reset_opacity(status, except_id) { function reset_opacity(status, except_id) {
var perm = document.getElementById('set-permissions'); const perm = document.getElementById('set-permissions');
var fs = perm.getElementsByTagName('fieldset'); const fs = perm.getElementsByTagName('fieldset');
var opacity = 5; let opacity = 5;
if (status) { if (status) {
opacity = 10; opacity = 10;
} }
for (var i = 0; i < fs.length; i++ ) { for (let i = 0; i < fs.length; i++ ) {
if (fs[i].className !== 'quick') { if (fs[i].className !== 'quick') {
set_opacity(fs[i], opacity); set_opacity(fs[i], opacity);
} }
@ -89,7 +88,7 @@ function reset_opacity(status, except_id) {
* rb = array of radiobuttons * rb = array of radiobuttons
*/ */
function get_radio_status(index, rb) { function get_radio_status(index, rb) {
for (var i = index; i < rb.length; i += 3 ) { for (let i = index; i < rb.length; i += 3 ) {
if (rb[i].checked !== true) { if (rb[i].checked !== true) {
if (i > index) { if (i > index) {
// at least one is true, but not all (custom) // at least one is true, but not all (custom)
@ -112,18 +111,18 @@ function get_radio_status(index, rb) {
* quick = If no calculation needed, this contains the colour * quick = If no calculation needed, this contains the colour
*/ */
function set_colours(id, init, quick) { function set_colours(id, init, quick) {
var table = document.getElementById('table' + id); const table = document.getElementById('table' + id);
var tab = document.getElementById('tab' + id); const tab = document.getElementById('tab' + id);
if (typeof (quick) !== 'undefined') { if (typeof (quick) !== 'undefined') {
tab.className = 'permissions-preset-' + quick + ' activetab'; tab.className = 'permissions-preset-' + quick + ' activetab';
return; return;
} }
var rb = table.getElementsByTagName('input'); const rb = table.getElementsByTagName('input');
var colour = 'custom'; let colour = 'custom';
var status = get_radio_status(0, rb); let status = get_radio_status(0, rb);
if (status === 1) { if (status === 1) {
colour = 'yes'; colour = 'yes';
@ -155,11 +154,11 @@ function set_colours(id, init, quick) {
* block_id = block that is opened * block_id = block that is opened
*/ */
function init_colours(block_id) { function init_colours(block_id) {
var block = document.getElementById('advanced' + block_id); const block = document.getElementById('advanced' + block_id);
var panels = block.getElementsByTagName('div'); const panels = block.getElementsByTagName('div');
var tab = document.getElementById('tab' + id); const tab = document.getElementById('tab' + id);
for (var i = 0; i < panels.length; i++) { for (let i = 0; i < panels.length; i++) {
if (panels[i].className === 'permissions-panel') { if (panels[i].className === 'permissions-panel') {
set_colours(panels[i].id.replace(/options/, ''), true); set_colours(panels[i].id.replace(/options/, ''), true);
} }
@ -179,9 +178,9 @@ function swap_options(pmask, fmask, cat, adv, view) {
id = pmask + fmask + cat; id = pmask + fmask + cat;
active_option = active_pmask + active_fmask + active_cat; active_option = active_pmask + active_fmask + active_cat;
var old_tab = document.getElementById('tab' + active_option); const old_tab = document.getElementById('tab' + active_option);
var new_tab = document.getElementById('tab' + id); const new_tab = document.getElementById('tab' + id);
var adv_block = document.getElementById('advanced' + pmask + fmask); const adv_block = document.getElementById('advanced' + pmask + fmask);
if (adv_block.style.display === 'block' && adv === true) { if (adv_block.style.display === 'block' && adv === true) {
phpbb.toggleDisplay('advanced' + pmask + fmask, -1); phpbb.toggleDisplay('advanced' + pmask + fmask, -1);
@ -245,15 +244,15 @@ function swap_options(pmask, fmask, cat, adv, view) {
* id = table ID container, s = status ['y'/'u'/'n'] * id = table ID container, s = status ['y'/'u'/'n']
*/ */
function mark_options(id, s) { function mark_options(id, s) {
var t = document.getElementById(id); const t = document.getElementById(id);
if (!t) { if (!t) {
return; return;
} }
var rb = t.getElementsByTagName('input'); const rb = t.getElementsByTagName('input');
for (var r = 0; r < rb.length; r++) { for (let r = 0; r < rb.length; r++) {
if (rb[r].id.substr(rb[r].id.length - 1) === s) { if (rb[r].id.substr(rb[r].id.length - 1) === s) {
rb[r].checked = true; rb[r].checked = true;
} }
@ -261,15 +260,15 @@ function mark_options(id, s) {
} }
function mark_one_option(id, field_name, s) { function mark_one_option(id, field_name, s) {
var t = document.getElementById(id); const t = document.getElementById(id);
if (!t) { if (!t) {
return; return;
} }
var rb = t.getElementsByTagName('input'); const rb = t.getElementsByTagName('input');
for (var r = 0; r < rb.length; r++) { for (let r = 0; r < rb.length; r++) {
if (rb[r].id.substr(rb[r].id.length - field_name.length - 3, field_name.length) === field_name && rb[r].id.substr(rb[r].id.length - 1) === s) { if (rb[r].id.substr(rb[r].id.length - field_name.length - 3, field_name.length) === field_name && rb[r].id.substr(rb[r].id.length - 1) === s) {
rb[r].checked = true; rb[r].checked = true;
} }
@ -286,21 +285,21 @@ function mark_one_option(id, field_name, s) {
* @returns {void} * @returns {void}
*/ */
function reset_role(id) { function reset_role(id) {
var t = document.getElementById(id); const t = document.getElementById(id);
if (!t) { if (!t) {
return; return;
} }
// Before resetting the role dropdown, try and match any permission role // Before resetting the role dropdown, try and match any permission role
var parent = t.parentNode; const parent = t.parentNode;
var roleId = match_role_settings(id.replace('role', 'perm')); const roleId = match_role_settings(id.replace('role', 'perm'));
var text = no_role_assigned; let text = no_role_assigned;
var index = 0; let index = 0;
// If a role permissions was matched, grab that option's value and index // If a role permissions was matched, grab that option's value and index
if (roleId) { if (roleId) {
for (var i = 0; i < t.options.length; i++) { for (let i = 0; i < t.options.length; i++) {
if (parseInt(t.options[i].value, 10) === roleId) { if (parseInt(t.options[i].value, 10) === roleId) {
text = t.options[i].text; text = t.options[i].text;
index = i; index = i;
@ -322,7 +321,7 @@ function reset_role(id) {
* Load role and set options accordingly * Load role and set options accordingly
*/ */
function set_role_settings(role_id, target_id) { function set_role_settings(role_id, target_id) {
var settings = role_options[role_id]; const settings = role_options[role_id];
if (!settings) { if (!settings) {
return; return;
@ -331,7 +330,7 @@ function set_role_settings(role_id, target_id) {
// Mark all options to no (unset) first... // Mark all options to no (unset) first...
mark_options(target_id, 'u'); mark_options(target_id, 'u');
for (var r in settings) { for (const r in settings) {
if (Object.prototype.hasOwnProperty.call(settings, r)) { if (Object.prototype.hasOwnProperty.call(settings, r)) {
mark_one_option(target_id, r, (settings[r] === 1) ? 'y' : 'n'); mark_one_option(target_id, r, (settings[r] === 1) ? 'y' : 'n');
} }
@ -345,13 +344,13 @@ function set_role_settings(role_id, target_id) {
* @return {number} The permission role identifier * @return {number} The permission role identifier
*/ */
function match_role_settings(id) { function match_role_settings(id) {
var fieldset = document.getElementById(id); const fieldset = document.getElementById(id);
var radios = fieldset.getElementsByTagName('input'); const radios = fieldset.getElementsByTagName('input');
var set = {}; let set = {};
// Iterate over all the radio buttons // Iterate over all the radio buttons
for (var i = 0; i < radios.length; i++) { for (let i = 0; i < radios.length; i++) {
var matches = radios[i].id.match(/setting\[\d+]\[\d+]\[([a-z_]+)]/); const matches = radios[i].id.match(/setting\[\d+]\[\d+]\[([a-z_]+)]/);
// Make sure the name attribute matches, the radio is checked and it is not the "No" (-1) value. // Make sure the name attribute matches, the radio is checked and it is not the "No" (-1) value.
if (matches !== null && radios[i].checked && radios[i].value !== '-1') { if (matches !== null && radios[i].checked && radios[i].value !== '-1') {
@ -363,7 +362,7 @@ function match_role_settings(id) {
set = sort_and_stringify(set); set = sort_and_stringify(set);
// Iterate over the available role options and return the first match // Iterate over the available role options and return the first match
for (var r in role_options) { for (const r in role_options) {
if (sort_and_stringify(role_options[r]) === set) { if (sort_and_stringify(role_options[r]) === set) {
return parseInt(r, 10); return parseInt(r, 10);
} }

View file

@ -1,5 +1,4 @@
/* global phpbb */ /* global phpbb */
/* eslint no-var: 0 */
/* /*
javascript for Bubble Tooltips by Alessandro Fulciniti javascript for Bubble Tooltips by Alessandro Fulciniti
@ -16,7 +15,7 @@ phpBB Development Team:
(function($) { // Avoid conflicts with other libraries (function($) { // Avoid conflicts with other libraries
'use strict'; 'use strict';
var tooltips = []; const tooltips = [];
/** /**
* Enable tooltip replacements for selects * Enable tooltip replacements for selects
@ -25,9 +24,9 @@ phpBB Development Team:
* @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; let $links;
var hold = $('<span />', { const hold = $('<span />', {
id: '_tooltip_container', id: '_tooltip_container',
css: { css: {
position: 'absolute', position: 'absolute',
@ -43,7 +42,7 @@ phpBB Development Team:
} }
$links.each(function() { $links.each(function() {
var $this = $(this); const $this = $(this);
if (subId) { if (subId) {
if ($this.parent().attr('id').substr(0, subId.length) === subId) { if ($this.parent().attr('id').substr(0, subId.length) === subId) {
@ -62,13 +61,13 @@ phpBB Development Team:
* @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 text = $element.attr('data-title'); const text = $element.attr('data-title');
if (text === null || text.length === 0) { if (text === null || text.length === 0) {
return; return;
} }
var $title = $('<span />', { const $title = $('<span />', {
class: 'top', class: 'top',
css: { css: {
display: 'block', display: 'block',
@ -76,7 +75,7 @@ phpBB Development Team:
}) })
.append(document.createTextNode(headText)); .append(document.createTextNode(headText));
var $desc = $('<span />', { const $desc = $('<span />', {
class: 'bottom', class: 'bottom',
html: text, html: text,
css: { css: {
@ -84,7 +83,7 @@ phpBB Development Team:
}, },
}); });
var $tooltip = $('<span />', { const $tooltip = $('<span />', {
class: 'tooltip', class: 'tooltip',
css: { css: {
display: 'block', display: 'block',
@ -104,7 +103,7 @@ phpBB Development Team:
* @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); const $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);
}; };
@ -113,7 +112,7 @@ phpBB Development Team:
* Hide tooltip * Hide tooltip
*/ */
phpbb.hideTooltip = function() { phpbb.hideTooltip = function() {
var d = document.getElementById('_tooltip_container'); const 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 +125,7 @@ phpBB Development Team:
*/ */
phpbb.positionTooltip = function($element) { phpbb.positionTooltip = function($element) {
$element = $element.parent(); $element = $element.parent();
var offset = $element.offset(); const offset = $element.offset();
if ($('body').hasClass('rtl')) { if ($('body').hasClass('rtl')) {
$('#_tooltip_container').css({ $('#_tooltip_container').css({
@ -145,13 +144,13 @@ phpBB Development Team:
* Prepare roles drop down select * Prepare roles drop down select
*/ */
phpbb.prepareRolesDropdown = function() { phpbb.prepareRolesDropdown = function() {
var $options = $('.roles-options li'); const $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); const $this = $(this);
if ($this.attr('data-name') && !$this.attr('name')) { if ($this.attr('data-name') && !$this.attr('name')) {
$this.attr('name', $this.attr('data-name')); $this.attr('name', $this.attr('data-name'));
@ -160,9 +159,9 @@ phpBB Development Team:
// 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); const $this = $(this);
var $rolesOptions = $this.closest('.roles-options'); const $rolesOptions = $this.closest('.roles-options');
var $span = $rolesOptions.children('span'); const $span = $rolesOptions.children('span');
// Correctly show selected option // Correctly show selected option
if (typeof $this.attr('data-selected') !== 'undefined') { if (typeof $this.attr('data-selected') !== 'undefined') {
@ -186,12 +185,12 @@ phpBB Development Team:
} }
$this.on('mouseover', function() { $this.on('mouseover', function() {
var $this = $(this); const $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); const $this = $(this);
var $rolesOptions = $this.closest('.roles-options'); const $rolesOptions = $this.closest('.roles-options');
// Update settings // Update settings
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef

View file

@ -1,14 +1,13 @@
/* global bbfontstyle */ /* global bbfontstyle */
/* eslint no-var: 0 */
var phpbb = {}; const phpbb = {};
phpbb.alertTime = 100; phpbb.alertTime = 100;
(function($) { // Avoid conflicts with other libraries (function($) { // Avoid conflicts with other libraries
'use strict'; 'use strict';
// define a couple constants for keydown functions. // define a couple constants for keydown functions.
var keymap = { const keymap = {
TAB: 9, TAB: 9,
ENTER: 13, ENTER: 13,
ESC: 27, ESC: 27,
@ -16,9 +15,9 @@ phpbb.alertTime = 100;
ARROW_DOWN: 40, ARROW_DOWN: 40,
}; };
var $dark = $('#darkenwrapper'); const $dark = $('#darkenwrapper');
var $loadingIndicator; let $loadingIndicator;
var phpbbAlertTimer = null; let phpbbAlertTimer = null;
phpbb.isTouch = (window && typeof window.ontouchstart !== 'undefined'); phpbb.isTouch = (window && typeof window.ontouchstart !== 'undefined');
@ -55,7 +54,7 @@ phpbb.alertTime = 100;
* Show timeout message * Show timeout message
*/ */
phpbb.showTimeoutMessage = function() { phpbb.showTimeoutMessage = function() {
var $alert = $('#phpbb_alert'); const $alert = $('#phpbb_alert');
if ($loadingIndicator.is(':visible')) { if ($loadingIndicator.is(':visible')) {
phpbb.alert($alert.attr('data-l-err'), $alert.attr('data-l-timeout-processing-req')); phpbb.alert($alert.attr('data-l-err'), $alert.attr('data-l-timeout-processing-req'));
@ -94,7 +93,7 @@ phpbb.alertTime = 100;
* @returns {object} Returns the div created. * @returns {object} Returns the div created.
*/ */
phpbb.alert = function(title, msg) { phpbb.alert = function(title, msg) {
var $alert = $('#phpbb_alert'); const $alert = $('#phpbb_alert');
$alert.find('.alert_title').html(title); $alert.find('.alert_title').html(title);
$alert.find('.alert_text').html(msg); $alert.find('.alert_text').html(msg);
@ -157,7 +156,7 @@ phpbb.alertTime = 100;
* @param {bool} fadedark Whether to remove dark background. * @param {bool} fadedark Whether to remove dark background.
*/ */
phpbb.alert.close = function($alert, fadedark) { phpbb.alert.close = function($alert, fadedark) {
var $fade = (fadedark) ? $dark : $alert; const $fade = (fadedark) ? $dark : $alert;
$fade.fadeOut(phpbb.alertTime, () => { $fade.fadeOut(phpbb.alertTime, () => {
$alert.hide(); $alert.hide();
@ -181,13 +180,13 @@ phpbb.alertTime = 100;
* @returns {object} Returns the div created. * @returns {object} Returns the div created.
*/ */
phpbb.confirm = function(msg, callback, fadedark) { phpbb.confirm = function(msg, callback, fadedark) {
var $confirmDiv = $('#phpbb_confirm'); const $confirmDiv = $('#phpbb_confirm');
$confirmDiv.find('.alert_text').html(msg); $confirmDiv.find('.alert_text').html(msg);
fadedark = typeof fadedark === 'undefined' ? true : fadedark; fadedark = typeof fadedark === 'undefined' ? true : fadedark;
$(document).on('keydown.phpbb.alert', e => { $(document).on('keydown.phpbb.alert', e => {
if (e.keyCode === keymap.ENTER || e.keyCode === keymap.ESC) { if (e.keyCode === keymap.ENTER || e.keyCode === keymap.ESC) {
var name = (e.keyCode === keymap.ENTER) ? 'confirm' : 'cancel'; const name = (e.keyCode === keymap.ENTER) ? 'confirm' : 'cancel';
$('input[name="' + name + '"]').trigger('click'); $('input[name="' + name + '"]').trigger('click');
e.preventDefault(); e.preventDefault();
@ -196,7 +195,7 @@ phpbb.alertTime = 100;
}); });
$confirmDiv.find('input[type="button"]').one('click.phpbb.confirmbox', function(e) { $confirmDiv.find('input[type="button"]').one('click.phpbb.confirmbox', function(e) {
var confirmed = this.name === 'confirm'; const confirmed = this.name === 'confirm';
callback(confirmed); callback(confirmed);
$confirmDiv.find('input[type="button"]').off('click.phpbb.confirmbox'); $confirmDiv.find('input[type="button"]').off('click.phpbb.confirmbox');
@ -218,9 +217,9 @@ phpbb.alertTime = 100;
* @returns {object} The object created. * @returns {object} The object created.
*/ */
phpbb.parseQuerystring = function(string) { phpbb.parseQuerystring = function(string) {
var params = {}; const params = {};
var i; let i;
var split; let split;
string = string.split('&'); string = string.split('&');
for (i = 0; i < string.length; i++) { for (i = 0; i < string.length; i++) {
@ -245,13 +244,13 @@ phpbb.alertTime = 100;
* @param {object} options Options. * @param {object} options Options.
*/ */
phpbb.ajaxify = function(options) { phpbb.ajaxify = function(options) {
var $elements = $(options.selector); const $elements = $(options.selector);
var refresh = options.refresh; let { refresh } = options;
var callback = options.callback; const { callback } = options;
var overlay = typeof options.overlay === 'undefined' ? true : options.overlay; const overlay = typeof options.overlay === 'undefined' ? true : options.overlay;
var isForm = $elements.is('form'); const isForm = $elements.is('form');
var isText = $elements.is('input[type="text"], textarea'); const isText = $elements.is('input[type="text"], textarea');
var eventName; let eventName;
if (isForm) { if (isForm) {
eventName = 'submit'; eventName = 'submit';
@ -262,12 +261,12 @@ phpbb.alertTime = 100;
} }
$elements.on(eventName, function(event) { $elements.on(eventName, function(event) {
var action; let action;
var method; let method;
var data; let data;
var submit; let submit;
var that = this; const that = this;
var $this = $(this); const $this = $(this);
if ($this.find('input[type="submit"][data-clicked]').attr('data-ajax') === 'false') { if ($this.find('input[type="submit"][data-clicked]').attr('data-ajax') === 'false') {
return; return;
@ -282,8 +281,8 @@ phpbb.alertTime = 100;
} }
phpbb.clearLoadingTimeout(); phpbb.clearLoadingTimeout();
var responseText; let responseText;
var errorText = false; let errorText = false;
try { try {
responseText = JSON.parse(jqXHR.responseText); responseText = JSON.parse(jqXHR.responseText);
responseText = responseText.message; responseText = responseText.message;
@ -314,7 +313,7 @@ phpbb.alertTime = 100;
* @param {object} res The object sent back by the server. * @param {object} res The object sent back by the server.
*/ */
function returnHandler(res) { function returnHandler(res) {
var alert; let alert;
phpbb.clearLoadingTimeout(); phpbb.clearLoadingTimeout();
@ -381,7 +380,7 @@ phpbb.alertTime = 100;
// If the element is a form, POST must be used and some extra data must // If the element is a form, POST must be used and some extra data must
// be taken from the form. // be taken from the form.
var runFilter = (typeof options.filter === 'function'); const runFilter = (typeof options.filter === 'function');
data = {}; data = {};
if (isForm) { if (isForm) {
@ -397,7 +396,7 @@ phpbb.alertTime = 100;
}); });
} }
} else if (isText) { } else if (isText) {
var name = $this.attr('data-name') || this.name; const name = $this.attr('data-name') || this.name;
action = $this.attr('data-url').replace('&amp;', '&'); action = $this.attr('data-url').replace('&amp;', '&');
data[name] = this.value; data[name] = this.value;
method = 'POST'; method = 'POST';
@ -407,13 +406,13 @@ phpbb.alertTime = 100;
method = 'GET'; method = 'GET';
} }
var sendRequest = function() { const sendRequest = function() {
var dataOverlay = $this.attr('data-overlay'); const dataOverlay = $this.attr('data-overlay');
if (overlay && (typeof dataOverlay === 'undefined' || dataOverlay === 'true')) { if (overlay && (typeof dataOverlay === 'undefined' || dataOverlay === 'true')) {
phpbb.loadingIndicator(); phpbb.loadingIndicator();
} }
var request = $.ajax({ const request = $.ajax({
url: action, url: action,
type: method, type: method,
data, data,
@ -441,7 +440,7 @@ phpbb.alertTime = 100;
if (isForm) { if (isForm) {
$elements.find('input:submit').click(function() { $elements.find('input:submit').click(function() {
var $this = $(this); const $this = $(this);
// Remove data-clicked attribute from any submit button of form // Remove data-clicked attribute from any submit button of form
$this.parents('form:first').find('input:submit[data-clicked]').removeAttr('data-clicked'); $this.parents('form:first').find('input:submit[data-clicked]').removeAttr('data-clicked');
@ -523,7 +522,7 @@ phpbb.alertTime = 100;
*/ */
phpbb.search.getKeyword = function($input, keyword, multiline) { phpbb.search.getKeyword = function($input, keyword, multiline) {
if (multiline) { if (multiline) {
var line = phpbb.search.getKeywordLine($input); const line = phpbb.search.getKeywordLine($input);
keyword = keyword.split('\n').splice(line, 1); keyword = keyword.split('\n').splice(line, 1);
} }
@ -538,7 +537,7 @@ phpbb.alertTime = 100;
* @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); const { selectionStart } = $textarea.get(0);
return $textarea.val().substr(0, selectionStart).split('\n').length - 1; return $textarea.val().substr(0, selectionStart).split('\n').length - 1;
}; };
@ -552,8 +551,8 @@ phpbb.alertTime = 100;
*/ */
phpbb.search.setValue = function($input, value, multiline) { phpbb.search.setValue = function($input, value, multiline) {
if (multiline) { if (multiline) {
var line = phpbb.search.getKeywordLine($input); const line = phpbb.search.getKeywordLine($input);
var lines = $input.val().split('\n'); const lines = $input.val().split('\n');
lines[line] = value; lines[line] = value;
value = lines.join('\n'); value = lines.join('\n');
} }
@ -590,14 +589,14 @@ phpbb.alertTime = 100;
* @returns {boolean} Returns false. * @returns {boolean} Returns false.
*/ */
phpbb.search.filter = function(data, event, sendRequest) { phpbb.search.filter = function(data, event, sendRequest) {
var $this = $(this); const $this = $(this);
var dataName = $this.attr('data-name') === undefined ? $this.attr('name') : $this.attr('data-name'); const dataName = $this.attr('data-name') === undefined ? $this.attr('name') : $this.attr('data-name');
var minLength = parseInt($this.attr('data-min-length'), 10); const minLength = parseInt($this.attr('data-min-length'), 10);
var searchID = $this.attr('data-results'); const searchID = $this.attr('data-results');
var keyword = phpbb.search.getKeyword($this, data[dataName], $this.attr('data-multiline')); const keyword = phpbb.search.getKeyword($this, data[dataName], $this.attr('data-multiline'));
var cache = phpbb.search.cache.get(searchID); const cache = phpbb.search.cache.get(searchID);
var key = event.keyCode || event.which; const key = event.keyCode || event.which;
var proceed = true; let proceed = true;
data[dataName] = keyword; data[dataName] = keyword;
// No need to search if enter was pressed // No need to search if enter was pressed
@ -610,7 +609,7 @@ phpbb.alertTime = 100;
clearTimeout(cache.timeout); clearTimeout(cache.timeout);
} }
var timeout = setTimeout(function() { const timeout = setTimeout(function() {
// Check min length and existence of cache. // Check min length and existence of cache.
if (minLength > keyword.length) { if (minLength > keyword.length) {
proceed = false; proceed = false;
@ -621,7 +620,7 @@ phpbb.alertTime = 100;
} else { } else {
// Do we already have results for this? // Do we already have results for this?
if (cache.results[keyword]) { if (cache.results[keyword]) {
var response = { const response = {
keyword, keyword,
results: cache.results[keyword], results: cache.results[keyword],
}; };
@ -661,8 +660,8 @@ phpbb.alertTime = 100;
return; return;
} }
var searchID = $input.attr('data-results'); const searchID = $input.attr('data-results');
var $container = $(searchID); const $container = $(searchID);
if (this.cache.get(searchID).callback) { if (this.cache.get(searchID).callback) {
callback = this.cache.get(searchID).callback; callback = this.cache.get(searchID).callback;
@ -687,7 +686,7 @@ phpbb.alertTime = 100;
* @param {function} callback Optional callback to run when assigning each search result. * @param {function} callback Optional callback to run when assigning each search result.
*/ */
phpbb.search.showResults = function(results, $input, $container, callback) { phpbb.search.showResults = function(results, $input, $container, callback) {
var $resultContainer = $('.search-results', $container); const $resultContainer = $('.search-results', $container);
this.clearResults($resultContainer); this.clearResults($resultContainer);
if (!results.length) { if (!results.length) {
@ -695,9 +694,9 @@ phpbb.alertTime = 100;
return; return;
} }
var searchID = $container.attr('id'); const searchID = $container.attr('id');
var tpl; let tpl;
var row; let row;
if (!this.tpl[searchID]) { if (!this.tpl[searchID]) {
tpl = $('.search-result-tpl', $container); tpl = $('.search-result-tpl', $container);
@ -755,14 +754,14 @@ phpbb.alertTime = 100;
// Rebind it, to ensure the event is 'dynamic'. // Rebind it, to ensure the event is 'dynamic'.
$input.off('.phpbb.search'); $input.off('.phpbb.search');
$input.on('keydown.phpbb.search', event => { $input.on('keydown.phpbb.search', event => {
var key = event.keyCode || event.which; const key = event.keyCode || event.which;
var $active = $resultContainer.children('.active'); const $active = $resultContainer.children('.active');
if (key === keymap.ESC) { if (key === keymap.ESC) {
phpbb.search.closeResults($input, $container); phpbb.search.closeResults($input, $container);
} else if (key === keymap.ENTER) { } else if (key === keymap.ENTER) {
if ($active.length) { if ($active.length) {
var value = $active.find('.search-result > span').text(); const value = $active.find('.search-result > span').text();
phpbb.search.setValue($input, value, $input.attr('data-multiline')); phpbb.search.setValue($input, value, $input.attr('data-multiline'));
} }
@ -772,8 +771,8 @@ phpbb.alertTime = 100;
// Do not submit the form // Do not submit the form
event.preventDefault(); event.preventDefault();
} else if (key === keymap.ARROW_DOWN || key === keymap.ARROW_UP) { } else if (key === keymap.ARROW_DOWN || key === keymap.ARROW_UP) {
var up = key === keymap.ARROW_UP; const up = key === keymap.ARROW_UP;
var $children = $resultContainer.children(); const $children = $resultContainer.children();
if (!$active.length) { if (!$active.length) {
if (up) { if (up) {
@ -806,7 +805,7 @@ phpbb.alertTime = 100;
}; };
$('#phpbb').click(function() { $('#phpbb').click(function() {
var $this = $(this); const $this = $(this);
if (!$this.is('.live-search') && !$this.parents().is('.live-search')) { if (!$this.is('.live-search') && !$this.parents().is('.live-search')) {
phpbb.search.closeResults($('input, textarea'), $('.live-search')); phpbb.search.closeResults($('input, textarea'), $('.live-search'));
@ -835,7 +834,7 @@ phpbb.alertTime = 100;
* @param {object} [obj] Optional state object. * @param {object} [obj] Optional state object.
*/ */
phpbb.history.alterUrl = function(mode, url, title, obj) { phpbb.history.alterUrl = function(mode, url, title, obj) {
var fn = mode + 'State'; const fn = mode + 'State';
if (!url || !phpbb.history.isSupported(fn)) { if (!url || !phpbb.history.isSupported(fn)) {
return; return;
@ -881,10 +880,10 @@ phpbb.alertTime = 100;
* user be forced to repick one. * user be forced to repick one.
*/ */
phpbb.timezoneSwitchDate = function(keepSelection) { phpbb.timezoneSwitchDate = function(keepSelection) {
var $timezoneCopy = $('#timezone_copy'); const $timezoneCopy = $('#timezone_copy');
var $timezone = $('#timezone'); const $timezone = $('#timezone');
var $tzDate = $('#tz_date'); const $tzDate = $('#tz_date');
var $tzSelectDateSuggest = $('#tz_select_date_suggest'); const $tzSelectDateSuggest = $('#tz_select_date_suggest');
if ($timezoneCopy.length === 0) { if ($timezoneCopy.length === 0) {
// We make a backup of the original dropdown, so we can remove optgroups // We make a backup of the original dropdown, so we can remove optgroups
@ -910,7 +909,7 @@ phpbb.alertTime = 100;
$tzSelectDateSuggest.css('display', 'inline'); $tzSelectDateSuggest.css('display', 'inline');
} }
var $tzOptions = $timezone.children('optgroup[data-tz-value="' + $tzDate.val() + '"]').children('option'); const $tzOptions = $timezone.children('optgroup[data-tz-value="' + $tzDate.val() + '"]').children('option');
if ($tzOptions.length === 1) { if ($tzOptions.length === 1) {
// If there is only one timezone for the selected date, we just select that automatically. // If there is only one timezone for the selected date, we just select that automatically.
@ -919,7 +918,7 @@ phpbb.alertTime = 100;
} }
if (typeof keepSelection !== 'undefined' && !keepSelection) { if (typeof keepSelection !== 'undefined' && !keepSelection) {
var $timezoneOptions = $timezone.find('optgroup option'); const $timezoneOptions = $timezone.find('optgroup option');
if ($timezoneOptions.filter(':selected').length <= 0) { if ($timezoneOptions.filter(':selected').length <= 0) {
$timezoneOptions.filter(':first').prop('selected', true); $timezoneOptions.filter(':first').prop('selected', true);
} }
@ -940,16 +939,16 @@ phpbb.alertTime = 100;
*/ */
phpbb.timezonePreselectSelect = function(forceSelector) { phpbb.timezonePreselectSelect = function(forceSelector) {
// The offset returned here is in minutes and negated. // The offset returned here is in minutes and negated.
var offset = (new Date()).getTimezoneOffset(); let offset = (new Date()).getTimezoneOffset();
var sign = '-'; let sign = '-';
if (offset < 0) { if (offset < 0) {
sign = '+'; sign = '+';
offset = -offset; offset = -offset;
} }
var minutes = offset % 60; let minutes = offset % 60;
var hours = (offset - minutes) / 60; let hours = (offset - minutes) / 60;
if (hours === 0) { if (hours === 0) {
hours = '00'; hours = '00';
@ -966,15 +965,15 @@ phpbb.alertTime = 100;
minutes = minutes.toString(); minutes = minutes.toString();
} }
var prefix = 'UTC' + sign + hours + ':' + minutes; const prefix = 'UTC' + sign + hours + ':' + minutes;
var prefixLength = prefix.length; const prefixLength = prefix.length;
var selectorOptions = $('option', '#tz_date'); const selectorOptions = $('option', '#tz_date');
var i; let i;
var $tzSelectDateSuggest = $('#tz_select_date_suggest'); const $tzSelectDateSuggest = $('#tz_select_date_suggest');
for (i = 0; i < selectorOptions.length; ++i) { for (i = 0; i < selectorOptions.length; ++i) {
var option = selectorOptions[i]; const option = selectorOptions[i];
if (option.value.substring(0, prefixLength) === prefix) { if (option.value.substring(0, prefixLength) === prefix) {
if ($('#tz_date').val() !== option.value && !forceSelector) { if ($('#tz_date').val() !== option.value && !forceSelector) {
@ -988,7 +987,7 @@ phpbb.alertTime = 100;
$tzSelectDateSuggest.css('display', 'none'); $tzSelectDateSuggest.css('display', 'none');
} }
var suggestion = $tzSelectDateSuggest.attr('data-l-suggestion'); const suggestion = $tzSelectDateSuggest.attr('data-l-suggestion');
$tzSelectDateSuggest.attr('title', suggestion.replace('%s', option.innerHTML)); $tzSelectDateSuggest.attr('title', suggestion.replace('%s', option.innerHTML));
$tzSelectDateSuggest.attr('value', suggestion.replace('%s', option.innerHTML.substring(0, 9))); $tzSelectDateSuggest.attr('value', suggestion.replace('%s', option.innerHTML.substring(0, 9)));
@ -1031,9 +1030,9 @@ phpbb.alertTime = 100;
* current text so that the process can be repeated. * current text so that the process can be repeated.
*/ */
phpbb.addAjaxCallback('alt_text', function() { phpbb.addAjaxCallback('alt_text', function() {
var $anchor; let $anchor;
var updateAll = $(this).data('update-all'); const updateAll = $(this).data('update-all');
var altText; let altText;
if (updateAll !== undefined && updateAll.length) { if (updateAll !== undefined && updateAll.length) {
$anchor = $(updateAll); $anchor = $(updateAll);
@ -1042,7 +1041,7 @@ phpbb.alertTime = 100;
} }
$anchor.each(function() { $anchor.each(function() {
var $this = $(this); const $this = $(this);
altText = $this.attr('data-alt-text'); altText = $this.attr('data-alt-text');
$this.attr('data-alt-text', $.trim($this.text())); $this.attr('data-alt-text', $.trim($this.text()));
$this.attr('title', altText); $this.attr('title', altText);
@ -1060,10 +1059,10 @@ phpbb.alertTime = 100;
* and changes the link itself. * and changes the link itself.
*/ */
phpbb.addAjaxCallback('toggle_link', function() { phpbb.addAjaxCallback('toggle_link', function() {
var $anchor; let $anchor;
var updateAll = $(this).data('update-all'); const updateAll = $(this).data('update-all');
var toggleText; let toggleText;
var toggleUrl; let toggleUrl;
if (updateAll !== undefined && updateAll.length) { if (updateAll !== undefined && updateAll.length) {
$anchor = $(updateAll); $anchor = $(updateAll);
@ -1072,7 +1071,7 @@ phpbb.alertTime = 100;
} }
$anchor.each(function() { $anchor.each(function() {
var $this = $(this); const $this = $(this);
// Toggle link text // Toggle link text
toggleText = $.trim($this.attr('data-toggle-text')); toggleText = $.trim($this.attr('data-toggle-text'));
@ -1114,7 +1113,7 @@ phpbb.alertTime = 100;
*/ */
phpbb.resizeTextArea = function($items, options) { phpbb.resizeTextArea = function($items, options) {
// Configuration // Configuration
var configuration = { let configuration = {
minWindowHeight: 500, minWindowHeight: 500,
minHeight: 200, minHeight: 200,
maxHeight: 500, maxHeight: 500,
@ -1132,7 +1131,7 @@ phpbb.alertTime = 100;
} }
function resetAutoResize(item) { function resetAutoResize(item) {
var $item = $(item); const $item = $(item);
if ($item.hasClass('auto-resized')) { if ($item.hasClass('auto-resized')) {
$(item) $(item)
.css({ height: '', resize: '' }) .css({ height: '', resize: '' })
@ -1150,20 +1149,20 @@ phpbb.alertTime = 100;
configuration.resizeCallback.call(item, $item); configuration.resizeCallback.call(item, $item);
} }
var windowHeight = $(window).height(); const windowHeight = $(window).height();
if (windowHeight < configuration.minWindowHeight) { if (windowHeight < configuration.minWindowHeight) {
resetAutoResize(item); resetAutoResize(item);
return; return;
} }
var maxHeight = Math.min( const maxHeight = Math.min(
Math.max(windowHeight - configuration.heightDiff, configuration.minHeight), Math.max(windowHeight - configuration.heightDiff, configuration.minHeight),
configuration.maxHeight, configuration.maxHeight,
); );
var $item = $(item); const $item = $(item);
var height = parseInt($item.innerHeight(), 10); const height = parseInt($item.innerHeight(), 10);
var scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0; const scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0;
if (height < 0) { if (height < 0) {
return; return;
@ -1203,20 +1202,20 @@ phpbb.alertTime = 100;
* @returns {boolean} True if cursor is in bbcode tag * @returns {boolean} True if cursor is in bbcode tag
*/ */
phpbb.inBBCodeTag = function(textarea, startTags, endTags) { phpbb.inBBCodeTag = function(textarea, startTags, endTags) {
var start = textarea.selectionStart; const start = textarea.selectionStart;
var lastEnd = -1; let lastEnd = -1;
var lastStart = -1; let lastStart = -1;
var i; let i;
var index; let index;
if (typeof start !== 'number') { if (typeof start !== 'number') {
return false; return false;
} }
var value = textarea.value.toLowerCase(); const value = textarea.value.toLowerCase();
for (i = 0; i < startTags.length; i++) { for (i = 0; i < startTags.length; i++) {
var tagLength = startTags[i].length; const tagLength = startTags[i].length;
if (start >= tagLength) { if (start >= tagLength) {
index = value.lastIndexOf(startTags[i], start - tagLength); index = value.lastIndexOf(startTags[i], start - tagLength);
lastStart = Math.max(lastStart, index); lastStart = Math.max(lastStart, index);
@ -1251,9 +1250,9 @@ phpbb.alertTime = 100;
*/ */
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=' ]; const startTags = [ '[code]', '[code=' ];
var startTagsEnd = ']'; const startTagsEnd = ']';
var endTags = [ '[/code]' ]; const endTags = [ '[/code]' ];
if (!textarea || typeof textarea.selectionStart !== 'number') { if (!textarea || typeof textarea.selectionStart !== 'number') {
return; return;
@ -1276,17 +1275,17 @@ phpbb.alertTime = 100;
* @returns {string} Line of text * @returns {string} Line of text
*/ */
function getLastLine(stripCodeStart) { function getLastLine(stripCodeStart) {
var start = textarea.selectionStart; const start = textarea.selectionStart;
var value = textarea.value; let { value } = textarea;
var index = value.lastIndexOf('\n', start - 1); let index = value.lastIndexOf('\n', start - 1);
value = value.substring(index + 1, start); value = value.substring(index + 1, start);
if (stripCodeStart) { if (stripCodeStart) {
for (var i = 0; i < startTags.length; i++) { for (let i = 0; i < startTags.length; i++) {
index = value.lastIndexOf(startTags[i]); index = value.lastIndexOf(startTags[i]);
if (index >= 0) { if (index >= 0) {
var tagLength = startTags[i].length; const tagLength = startTags[i].length;
value = value.substring(index + tagLength); value = value.substring(index + tagLength);
if (startTags[i].lastIndexOf(startTagsEnd) !== tagLength) { if (startTags[i].lastIndexOf(startTagsEnd) !== tagLength) {
@ -1310,9 +1309,9 @@ phpbb.alertTime = 100;
* @param {string} text Text to append * @param {string} text Text to append
*/ */
function appendText(text) { function appendText(text) {
var start = textarea.selectionStart; const start = textarea.selectionStart;
var end = textarea.selectionEnd; const end = textarea.selectionEnd;
var value = textarea.value; const { value } = textarea;
textarea.value = value.substr(0, start) + text + value.substr(end); textarea.value = value.substr(0, start) + text + value.substr(end);
textarea.selectionStart = start + text.length; textarea.selectionStart = start + text.length;
@ -1320,7 +1319,7 @@ phpbb.alertTime = 100;
} }
$(textarea).data('code-editor', true).on('keydown', event => { $(textarea).data('code-editor', true).on('keydown', event => {
var key = event.keyCode || event.which; const key = event.keyCode || event.which;
// intercept tabs // intercept tabs
if (key === keymap.TAB if (key === keymap.TAB
@ -1338,8 +1337,8 @@ phpbb.alertTime = 100;
// intercept new line characters // intercept new line characters
if (key === keymap.ENTER) { if (key === keymap.ENTER) {
if (inTag()) { if (inTag()) {
var lastLine = getLastLine(true); const lastLine = getLastLine(true);
var code = String(/^\s*/g.exec(lastLine)); const code = String(/^\s*/g.exec(lastLine));
if (code.length > 0) { if (code.length > 0) {
appendText('\n' + code); appendText('\n' + code);
@ -1390,11 +1389,11 @@ phpbb.alertTime = 100;
* This handler is used by phpBB.registerDropdown() and other functions * This handler is used by phpBB.registerDropdown() and other functions
*/ */
phpbb.toggleDropdown = function(event_) { phpbb.toggleDropdown = function(event_) {
var $this = $(this); const $this = $(this);
var options = $this.data('dropdown-options'); const options = $this.data('dropdown-options');
var parent = options.parent; const { parent } = options;
var visible = parent.hasClass('dropdown-visible'); const visible = parent.hasClass('dropdown-visible');
var direction; let direction;
if (!visible) { if (!visible) {
// Prevent link default action // Prevent link default action
@ -1405,8 +1404,8 @@ phpbb.alertTime = 100;
// Figure out direction of dropdown // Figure out direction of dropdown
direction = options.direction; direction = options.direction;
var verticalDirection = options.verticalDirection; let { verticalDirection } = options;
var offset = $this.offset(); const offset = $this.offset();
if (direction === 'auto') { if (direction === 'auto') {
if (($(window).width() - $this.outerWidth(true)) / 2 > offset.left) { if (($(window).width() - $this.outerWidth(true)) / 2 > offset.left) {
@ -1420,8 +1419,8 @@ phpbb.alertTime = 100;
.toggleClass(options.rightClass, direction === 'right'); .toggleClass(options.rightClass, direction === 'right');
if (verticalDirection === 'auto') { if (verticalDirection === 'auto') {
var height = $(window).height(); const height = $(window).height();
var top = offset.top - $(window).scrollTop(); const top = offset.top - $(window).scrollTop();
verticalDirection = (top < height * 0.7) ? 'down' : 'up'; verticalDirection = (top < height * 0.7) ? 'down' : 'up';
} }
@ -1437,10 +1436,10 @@ phpbb.alertTime = 100;
// Check dimensions when showing dropdown // Check dimensions when showing dropdown
// !visible because variable shows state of dropdown before it was toggled // !visible because variable shows state of dropdown before it was toggled
if (!visible) { if (!visible) {
var windowWidth = $(window).width(); const windowWidth = $(window).width();
options.dropdown.find('.dropdown-contents').each(function() { options.dropdown.find('.dropdown-contents').each(function() {
var $this = $(this); const $this = $(this);
$this.css({ $this.css({
marginLeft: 0, marginLeft: 0,
@ -1449,8 +1448,8 @@ phpbb.alertTime = 100;
maxWidth: (windowWidth - 4) + 'px', maxWidth: (windowWidth - 4) + 'px',
}); });
var offset = $this.offset().left; const offset = $this.offset().left;
var width = $this.outerWidth(true); const width = $this.outerWidth(true);
if (offset < 2) { if (offset < 2) {
$this.css('left', (2 - offset) + 'px'); $this.css('left', (2 - offset) + 'px');
@ -1461,22 +1460,22 @@ phpbb.alertTime = 100;
// Check whether the vertical scrollbar is present. // Check whether the vertical scrollbar is present.
$this.toggleClass('dropdown-nonscroll', this.scrollHeight === $this.innerHeight()); $this.toggleClass('dropdown-nonscroll', this.scrollHeight === $this.innerHeight());
}); });
var freeSpace = parent.offset().left - 4; const freeSpace = parent.offset().left - 4;
if (direction === 'left') { if (direction === 'left') {
options.dropdown.css('margin-left', '-' + freeSpace + 'px'); options.dropdown.css('margin-left', '-' + freeSpace + 'px');
// Try to position the notification dropdown correctly in RTL-responsive mode // Try to position the notification dropdown correctly in RTL-responsive mode
if (options.dropdown.hasClass('dropdown-extended')) { if (options.dropdown.hasClass('dropdown-extended')) {
var contentWidth; let contentWidth;
var fullFreeSpace = freeSpace + parent.outerWidth(); const fullFreeSpace = freeSpace + parent.outerWidth();
options.dropdown.find('.dropdown-contents').each(function() { options.dropdown.find('.dropdown-contents').each(function() {
contentWidth = parseInt($(this).outerWidth(), 10); contentWidth = parseInt($(this).outerWidth(), 10);
$(this).css({ marginLeft: 0, left: 0 }); $(this).css({ marginLeft: 0, left: 0 });
}); });
var maxOffset = Math.min(contentWidth, fullFreeSpace) + 'px'; const maxOffset = Math.min(contentWidth, fullFreeSpace) + 'px';
options.dropdown.css({ options.dropdown.css({
width: maxOffset, width: maxOffset,
marginLeft: -maxOffset, marginLeft: -maxOffset,
@ -1491,7 +1490,7 @@ phpbb.alertTime = 100;
if (arguments.length > 0) { if (arguments.length > 0) {
try { try {
// eslint-disable-next-line prefer-rest-params // eslint-disable-next-line prefer-rest-params
var e = arguments[0]; const e = arguments[0];
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
} catch { } } catch { }
@ -1517,7 +1516,7 @@ phpbb.alertTime = 100;
* @param {Object} options List of options. Optional. * @param {Object} options List of options. Optional.
*/ */
phpbb.registerDropdown = function(toggle, dropdown, options) { phpbb.registerDropdown = function(toggle, dropdown, options) {
var ops = { let ops = {
parent: toggle.parent(), // Parent item to add classes to parent: toggle.parent(), // Parent item to add classes to
direction: 'auto', // Direction of dropdown menu. Possible values: auto, left, right direction: 'auto', // Direction of dropdown menu. Possible values: auto, left, right
verticalDirection: 'auto', // Vertical direction. Possible values: auto, up, down verticalDirection: 'auto', // Vertical direction. Possible values: auto, up, down
@ -1550,12 +1549,12 @@ phpbb.alertTime = 100;
* @param {int} height Palette cell height. * @param {int} height Palette cell height.
*/ */
phpbb.colorPalette = function(dir, width, height) { phpbb.colorPalette = function(dir, width, height) {
var r; let r;
var g; let g;
var b; let b;
var numberList = new Array(6); const numberList = new Array(6);
var color = ''; let color = '';
var html = ''; let html = '';
numberList[0] = '00'; numberList[0] = '00';
numberList[1] = '40'; numberList[1] = '40';
@ -1563,7 +1562,7 @@ phpbb.alertTime = 100;
numberList[3] = 'BF'; numberList[3] = 'BF';
numberList[4] = 'FF'; numberList[4] = 'FF';
var tableClass = (dir === 'h') ? 'horizontal-palette' : 'vertical-palette'; const tableClass = (dir === 'h') ? 'horizontal-palette' : 'vertical-palette';
html += '<table class="not-responsive colour-palette ' + tableClass + '" style="width: auto;">'; html += '<table class="not-responsive colour-palette ' + tableClass + '" style="width: auto;">';
for (r = 0; r < 5; r++) { for (r = 0; r < 5; r++) {
@ -1605,10 +1604,10 @@ phpbb.alertTime = 100;
*/ */
phpbb.registerPalette = function(el) { phpbb.registerPalette = function(el) {
const orientation = el.attr('data-color-palette') || el.attr('data-orientation'); // data-orientation kept for backwards compat. const orientation = el.attr('data-color-palette') || el.attr('data-orientation'); // data-orientation kept for backwards compat.
var height = el.attr('data-height'); const height = el.attr('data-height');
var width = el.attr('data-width'); const width = el.attr('data-width');
var target = el.attr('data-target'); const target = el.attr('data-target');
var bbcode = el.attr('data-bbcode'); const bbcode = el.attr('data-bbcode');
// Insert the palette HTML into the container. // Insert the palette HTML into the container.
el.html(phpbb.colorPalette(orientation, width, height)); el.html(phpbb.colorPalette(orientation, width, height));
@ -1621,7 +1620,7 @@ phpbb.alertTime = 100;
// Attach event handler when a palette cell is clicked. // Attach event handler when a palette cell is clicked.
$(el).on('click', 'a', function(e) { $(el).on('click', 'a', function(e) {
var color = $(this).attr('data-color'); const color = $(this).attr('data-color');
if (bbcode) { if (bbcode) {
bbfontstyle('[color=#' + color + ']', '[/color]'); bbfontstyle('[color=#' + color + ']', '[/color]');
@ -1647,9 +1646,9 @@ phpbb.alertTime = 100;
type = 'block'; type = 'block';
} }
var $element = $('#' + id); const $element = $('#' + id);
var display = $element.css('display'); const display = $element.css('display');
if (!action) { if (!action) {
action = (display === '' || display === type) ? -1 : 1; action = (display === '' || display === type) ? -1 : 1;
} }
@ -1665,8 +1664,8 @@ phpbb.alertTime = 100;
*/ */
phpbb.toggleSelectSettings = function(el) { phpbb.toggleSelectSettings = function(el) {
el.children().each(function() { el.children().each(function() {
var $this = $(this); const $this = $(this);
var $setting = $($this.data('toggle-setting')); const $setting = $($this.data('toggle-setting'));
$setting.toggle($this.is(':selected')); $setting.toggle($this.is(':selected'));
// Disable any input elements that are not visible right now // Disable any input elements that are not visible right now
@ -1686,11 +1685,11 @@ phpbb.alertTime = 100;
* @returns function * @returns function
*/ */
phpbb.getFunctionByName = function(functionName) { phpbb.getFunctionByName = function(functionName) {
var namespaces = functionName.split('.'); const namespaces = functionName.split('.');
var func = namespaces.pop(); const func = namespaces.pop();
var context = window; let context = window;
for (var i = 0; i < namespaces.length; i++) { for (let i = 0; i < namespaces.length; i++) {
context = context[namespaces[i]]; context = context[namespaces[i]];
} }
@ -1726,17 +1725,17 @@ phpbb.alertTime = 100;
* Register page dropdowns. * Register page dropdowns.
*/ */
phpbb.registerPageDropdowns = function() { phpbb.registerPageDropdowns = function() {
var $body = $('body'); const $body = $('body');
$body.find('.dropdown-container').each(function() { $body.find('.dropdown-container').each(function() {
var $this = $(this); const $this = $(this);
var $trigger = $this.find('.dropdown-trigger:first'); let $trigger = $this.find('.dropdown-trigger:first');
var $contents = $this.find('.dropdown'); let $contents = $this.find('.dropdown');
var options = { const options = {
direction: 'auto', direction: 'auto',
verticalDirection: 'auto', verticalDirection: 'auto',
}; };
var data; let data;
if (!$trigger.length) { if (!$trigger.length) {
data = $this.attr('data-dropdown-trigger'); data = $this.attr('data-dropdown-trigger');
@ -1773,7 +1772,7 @@ phpbb.alertTime = 100;
// Hide active dropdowns when click event happens outside // Hide active dropdowns when click event happens outside
$body.click(e => { $body.click(e => {
var $parents = $(e.target).parents(); const $parents = $(e.target).parents();
if (!$parents.is(phpbb.dropdownVisibleContainers)) { if (!$parents.is(phpbb.dropdownVisibleContainers)) {
$(phpbb.dropdownHandles).each(phpbb.toggleDropdown); $(phpbb.dropdownHandles).each(phpbb.toggleDropdown);
} }
@ -1785,7 +1784,7 @@ phpbb.alertTime = 100;
*/ */
phpbb.lazyLoadAvatars = () => { phpbb.lazyLoadAvatars = () => {
$('.avatar[data-src]').each(function() { $('.avatar[data-src]').each(function() {
var $avatar = $(this); const $avatar = $(this);
$avatar $avatar
.attr('src', $avatar.data('src')) .attr('src', $avatar.data('src'))
@ -1923,7 +1922,7 @@ phpbb.alertTime = 100;
// Hide settings that are not selected via select element. // Hide settings that are not selected via select element.
$('select[data-togglable-settings]').each(function() { $('select[data-togglable-settings]').each(function() {
var $this = $(this); const $this = $(this);
$this.change(() => { $this.change(() => {
phpbb.toggleSelectSettings($this); phpbb.toggleSelectSettings($this);

View file

@ -2,10 +2,6 @@
/* eslint camelcase: 0 */ /* eslint camelcase: 0 */
/* eslint no-undef: 0 */ /* eslint no-undef: 0 */
/* eslint no-unused-vars: 0 */ /* eslint no-unused-vars: 0 */
/* eslint no-var: 0 */
var form_name = 'postform';
var text_name = 'message';
/** /**
* bbCode control by subBlue design [ www.subBlue.com ] * bbCode control by subBlue design [ www.subBlue.com ]
@ -13,25 +9,25 @@ var text_name = 'message';
*/ */
// Startup variables // Startup variables
var imageTag = false; const imageTag = false;
var theSelection = false; let theSelection = false;
var bbcodeEnabled = true; const bbcodeEnabled = true;
// Check for Browser & Platform for PC & IE specific bits // Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html // More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info const clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion, 10); // Get browser version const clientVer = parseInt(navigator.appVersion, 10); // Get browser version
var is_ie = ((clientPC.indexOf('msie') !== -1) && (clientPC.indexOf('opera') === -1)); const is_ie = ((clientPC.indexOf('msie') !== -1) && (clientPC.indexOf('opera') === -1));
var is_win = ((clientPC.indexOf('win') !== -1) || (clientPC.indexOf('16bit') !== -1)); const is_win = ((clientPC.indexOf('win') !== -1) || (clientPC.indexOf('16bit') !== -1));
var baseHeight; let baseHeight;
/** /**
* Fix a bug involving the TextRange object. From * Fix a bug involving the TextRange object. From
* http://www.frostjedi.com/terra/scripts/demo/caretBug.html * http://www.frostjedi.com/terra/scripts/demo/caretBug.html
*/ */
function initInsertions() { function initInsertions() {
var doc; let doc;
if (document.forms[form_name]) { if (document.forms[form_name]) {
doc = document; doc = document;
@ -39,7 +35,7 @@ function initInsertions() {
doc = opener.document; doc = opener.document;
} }
var textarea = doc.forms[form_name].elements[text_name]; const textarea = doc.forms[form_name].elements[text_name];
if (is_ie && typeof (baseHeight) !== 'number') { if (is_ie && typeof (baseHeight) !== 'number') {
textarea.focus(); textarea.focus();
@ -69,7 +65,7 @@ function bbstyle(bbnumber) {
function bbfontstyle(bbopen, bbclose) { function bbfontstyle(bbopen, bbclose) {
theSelection = false; theSelection = false;
var textarea = document.forms[form_name].elements[text_name]; const textarea = document.forms[form_name].elements[text_name];
textarea.focus(); textarea.focus();
@ -92,8 +88,8 @@ function bbfontstyle(bbopen, bbclose) {
} }
// The new position for the cursor after adding the bbcode // The new position for the cursor after adding the bbcode
var caret_pos = getCaretPosition(textarea).start; const caret_pos = getCaretPosition(textarea).start;
var new_pos = caret_pos + bbopen.length; const new_pos = caret_pos + bbopen.length;
// Open tag // Open tag
insert_text(bbopen + bbclose); insert_text(bbopen + bbclose);
@ -105,7 +101,7 @@ function bbfontstyle(bbopen, bbclose) {
textarea.selectionEnd = new_pos; textarea.selectionEnd = new_pos;
} else if (document.selection) { } else if (document.selection) {
// IE // IE
var range = textarea.createTextRange(); const range = textarea.createTextRange();
range.move('character', new_pos); range.move('character', new_pos);
range.select(); range.select();
storeCaret(textarea); storeCaret(textarea);
@ -118,7 +114,7 @@ function bbfontstyle(bbopen, bbclose) {
* Insert text at position * Insert text at position
*/ */
function insert_text(text, spaces, popup) { function insert_text(text, spaces, popup) {
var textarea; let textarea;
if (popup) { if (popup) {
textarea = opener.document.forms[form_name].elements[text_name]; textarea = opener.document.forms[form_name].elements[text_name];
@ -133,8 +129,8 @@ function insert_text(text, spaces, popup) {
// Since IE9, IE also has textarea.selectionStart, but it still needs to be treated the old way. // Since IE9, IE also has textarea.selectionStart, but it still needs to be treated the old way.
// Therefore we simply add a !is_ie here until IE fixes the text-selection completely. // Therefore we simply add a !is_ie here until IE fixes the text-selection completely.
if (!isNaN(textarea.selectionStart) && !is_ie) { if (!isNaN(textarea.selectionStart) && !is_ie) {
var sel_start = textarea.selectionStart; const sel_start = textarea.selectionStart;
var sel_end = textarea.selectionEnd; const sel_end = textarea.selectionEnd;
mozWrap(textarea, text, ''); mozWrap(textarea, text, '');
textarea.selectionStart = sel_start + text.length; textarea.selectionStart = sel_start + text.length;
@ -145,7 +141,7 @@ function insert_text(text, spaces, popup) {
storeCaret(textarea); storeCaret(textarea);
} }
var caret_pos = textarea.caretPos; const caret_pos = textarea.caretPos;
caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) === ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text; caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) === ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
} else { } else {
textarea.value += text; textarea.value += text;
@ -168,10 +164,10 @@ function attachInline(index, filename) {
* Add quote text to message * Add quote text to message
*/ */
function addquote(post_id, username, l_wrote, attributes) { function addquote(post_id, username, l_wrote, attributes) {
var message_name = 'message_' + post_id; const message_name = 'message_' + post_id;
var theSelection = ''; let theSelection = '';
var divarea = false; let divarea = false;
var i; let i;
if (l_wrote === undefined) { if (l_wrote === undefined) {
// Backwards compatibility // Backwards compatibility
@ -221,7 +217,7 @@ function addquote(post_id, username, l_wrote, attributes) {
insert_text(generateQuote(theSelection, attributes)); insert_text(generateQuote(theSelection, attributes));
} else { } else {
insert_text(username + ' ' + l_wrote + ':\n'); insert_text(username + ' ' + l_wrote + ':\n');
var lines = split_lines(theSelection); const lines = split_lines(theSelection);
for (i = 0; i < lines.length; i++) { for (i = 0; i < lines.length; i++) {
insert_text('> ' + lines[i] + '\n'); insert_text('> ' + lines[i] + '\n');
} }
@ -244,22 +240,22 @@ function addquote(post_id, username, l_wrote, attributes) {
*/ */
function generateQuote(text, attributes) { function generateQuote(text, attributes) {
text = text.replace(/^\s+/, '').replace(/\s+$/, ''); text = text.replace(/^\s+/, '').replace(/\s+$/, '');
var quote = '[quote'; let quote = '[quote';
if (attributes.author) { if (attributes.author) {
// Add the author as the BBCode's default attribute // Add the author as the BBCode's default attribute
quote += '=' + formatAttributeValue(attributes.author); quote += '=' + formatAttributeValue(attributes.author);
delete attributes.author; delete attributes.author;
} }
for (var name in attributes) { for (const name in attributes) {
if (Object.hasOwn(attributes, name)) { if (Object.hasOwn(attributes, name)) {
var value = attributes[name]; const value = attributes[name];
quote += ' ' + name + '=' + formatAttributeValue(value.toString()); quote += ' ' + name + '=' + formatAttributeValue(value.toString());
} }
} }
quote += ']'; quote += ']';
var newline = ((quote + text + '[/quote]').length > 80 || text.indexOf('\n') > -1) ? '\n' : ''; const newline = ((quote + text + '[/quote]').length > 80 || text.indexOf('\n') > -1) ? '\n' : '';
quote += newline + text + newline + '[/quote]'; quote += newline + text + newline + '[/quote]';
return quote; return quote;
@ -281,25 +277,25 @@ function formatAttributeValue(str) {
return str; return str;
} }
var singleQuoted = '\'' + str.replace(/[\\']/g, '\\$&') + '\''; const singleQuoted = '\'' + str.replace(/[\\']/g, '\\$&') + '\'';
var doubleQuoted = '"' + str.replace(/[\\"]/g, '\\$&') + '"'; const doubleQuoted = '"' + str.replace(/[\\"]/g, '\\$&') + '"';
return (singleQuoted.length < doubleQuoted.length) ? singleQuoted : doubleQuoted; return (singleQuoted.length < doubleQuoted.length) ? singleQuoted : doubleQuoted;
} }
function split_lines(text) { function split_lines(text) {
var lines = text.split('\n'); const lines = text.split('\n');
var splitLines = []; const splitLines = [];
var j = 0; let j = 0;
var i; let i;
for (i = 0; i < lines.length; i++) { for (i = 0; i < lines.length; i++) {
if (lines[i].length <= 80) { if (lines[i].length <= 80) {
splitLines[j] = lines[i]; splitLines[j] = lines[i];
j++; j++;
} else { } else {
var line = lines[i]; let line = lines[i];
var splitAt; let splitAt;
do { do {
splitAt = line.indexOf(' ', 80); splitAt = line.indexOf(' ', 80);
@ -323,14 +319,14 @@ function split_lines(text) {
* From http://www.massless.org/mozedit/ * From http://www.massless.org/mozedit/
*/ */
function mozWrap(txtarea, open, close) { function mozWrap(txtarea, open, close) {
var selLength = (typeof (txtarea.textLength) === 'undefined') ? txtarea.value.length : txtarea.textLength; const selLength = (typeof (txtarea.textLength) === 'undefined') ? txtarea.value.length : txtarea.textLength;
var selStart = txtarea.selectionStart; const selStart = txtarea.selectionStart;
var selEnd = txtarea.selectionEnd; const selEnd = txtarea.selectionEnd;
var scrollTop = txtarea.scrollTop; const { scrollTop } = txtarea;
var s1 = (txtarea.value).substring(0, selStart); const s1 = (txtarea.value).substring(0, selStart);
var s2 = (txtarea.value).substring(selStart, selEnd); const s2 = (txtarea.value).substring(selStart, selEnd);
var s3 = (txtarea.value).substring(selEnd, selLength); const s3 = (txtarea.value).substring(selEnd, selLength);
txtarea.value = s1 + open + s2 + close + s3; txtarea.value = s1 + open + s2 + close + s3;
txtarea.selectionStart = selStart + open.length; txtarea.selectionStart = selStart + open.length;
@ -352,16 +348,16 @@ function storeCaret(textEl) {
/** /**
* Caret Position object * Caret Position object
*/ */
function caretPosition() { function CaretPosition() {
var start = null; const start = null;
var end = null; const end = null;
} }
/** /**
* Get the caret position in an textarea * Get the caret position in an textarea
*/ */
function getCaretPosition(txtarea) { function getCaretPosition(txtarea) {
var caretPos = new caretPosition(); const caretPos = new CaretPosition();
// simple Gecko/Opera way // simple Gecko/Opera way
if (txtarea.selectionStart || txtarea.selectionStart === 0) { if (txtarea.selectionStart || txtarea.selectionStart === 0) {
@ -370,14 +366,14 @@ function getCaretPosition(txtarea) {
} else if (document.selection) { } else if (document.selection) {
// dirty and slow IE way // dirty and slow IE way
// get current selection // get current selection
var range = document.selection.createRange(); const range = document.selection.createRange();
// a new selection of the whole textarea // a new selection of the whole textarea
var range_all = document.body.createTextRange(); const range_all = document.body.createTextRange();
range_all.moveToElementText(txtarea); range_all.moveToElementText(txtarea);
// calculate selection start point by moving beginning of range_all to beginning of range // calculate selection start point by moving beginning of range_all to beginning of range
var sel_start; let sel_start;
for (sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start++) { for (sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start++) {
range_all.moveStart('character', 1); range_all.moveStart('character', 1);
} }

View file

@ -3,23 +3,21 @@
*/ */
/* eslint no-prototype-builtins: 0 */ /* 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';
// Installer variables // Installer variables
var pollTimer = null; let pollTimer = null;
var nextReadPosition = 0; let nextReadPosition = 0;
var progressBarTriggered = false; let progressBarTriggered = false;
var progressTimer = null; let progressTimer = null;
var currentProgress = 0; let currentProgress = 0;
var refreshRequested = false; let refreshRequested = false;
var transmissionOver = false; let transmissionOver = false;
var statusCount = 0; let statusCount = 0;
// Template related variables // Template related variables
var $contentWrapper = $('.install-body').find('.main'); const $contentWrapper = $('.install-body').find('.main');
// Intercept form submits // Intercept form submits
interceptFormSubmit($('#install_install')); interceptFormSubmit($('#install_install'));
@ -45,15 +43,15 @@
*/ */
function addMessage(type, messages) { function addMessage(type, messages) {
// Get message containers // Get message containers
var $errorContainer = $('#error-container'); const $errorContainer = $('#error-container');
var $warningContainer = $('#warning-container'); const $warningContainer = $('#warning-container');
var $logContainer = $('#log-container'); const $logContainer = $('#log-container');
var $title; let $title;
var $description; let $description;
var $msgElement; let $msgElement;
var arraySize = messages.length; const arraySize = messages.length;
for (var i = 0; i < arraySize; i++) { for (let i = 0; i < arraySize; i++) {
$msgElement = $('<div />'); $msgElement = $('<div />');
$title = $('<strong />'); $title = $('<strong />');
$title.text(messages[i].title); $title.text(messages[i].title);
@ -86,13 +84,13 @@
* Render a download box * Render a download box
*/ */
function addDownloadBox(downloadArray) { function addDownloadBox(downloadArray) {
var $downloadContainer = $('#download-wrapper'); const $downloadContainer = $('#download-wrapper');
var $downloadBox; let $downloadBox;
var $title; let $title;
var $content; let $content;
var $link; let $link;
for (var i = 0; i < downloadArray.length; i++) { for (let i = 0; i < downloadArray.length; i++) {
$downloadBox = $('<div />'); $downloadBox = $('<div />');
$downloadBox.addClass('download-box'); $downloadBox.addClass('download-box');
@ -120,7 +118,7 @@
* Render update files' status * Render update files' status
*/ */
function addUpdateFileStatus(fileStatus) { function addUpdateFileStatus(fileStatus) {
var $statusContainer = $('#file-status-wrapper'); const $statusContainer = $('#file-status-wrapper');
$statusContainer.html(fileStatus); $statusContainer.html(fileStatus);
} }
@ -130,9 +128,9 @@
* @param formHtml * @param formHtml
*/ */
function addForm(formHtml) { function addForm(formHtml) {
var $formContainer = $('#form-wrapper'); const $formContainer = $('#form-wrapper');
$formContainer.html(formHtml); $formContainer.html(formHtml);
var $form = $('#install_install'); const $form = $('#install_install');
interceptFormSubmit($form); interceptFormSubmit($form);
} }
@ -142,16 +140,16 @@
* @param navObj * @param navObj
*/ */
function updateNavbarStatus(navObj) { function updateNavbarStatus(navObj) {
var navID; let navID;
var $stage; let $stage;
var $stageListItem; let $stageListItem;
var $active = $('#activemenu'); const $active = $('#activemenu');
if (navObj.hasOwnProperty('finished')) { if (navObj.hasOwnProperty('finished')) {
// This should be an Array // This should be an Array
var navItems = navObj.finished; const navItems = navObj.finished;
for (var i = 0; i < navItems.length; i++) { for (let i = 0; i < navItems.length; i++) {
navID = 'installer-stage-' + navItems[i]; navID = 'installer-stage-' + navItems[i];
$stage = $('#' + navID); $stage = $('#' + navID);
$stageListItem = $stage.parent(); $stageListItem = $stage.parent();
@ -183,16 +181,16 @@
* @param progressObject * @param progressObject
*/ */
function setProgress(progressObject) { function setProgress(progressObject) {
var $statusText; let $statusText;
var $progressBar; let $progressBar;
var $progressText; let $progressText;
var $progressFiller; let $progressFiller;
var $progressFillerText; let $progressFillerText;
if (progressObject.task_name.length) { if (progressObject.task_name.length) {
if (!progressBarTriggered) { if (!progressBarTriggered) {
// Create progress bar // Create progress bar
var $progressBarWrapper = $('#progress-bar-container'); const $progressBarWrapper = $('#progress-bar-container');
// Create progress bar elements // Create progress bar elements
$progressBar = $('<div />'); $progressBar = $('<div />');
@ -242,9 +240,9 @@
// Set cookies // Set cookies
function setCookies(cookies) { function setCookies(cookies) {
var cookie; let cookie;
for (var i = 0; i < cookies.length; i++) { for (let i = 0; i < cookies.length; i++) {
// Set cookie name and value // Set cookie name and value
cookie = encodeURIComponent(cookies[i].name) + '=' + encodeURIComponent(cookies[i].value); cookie = encodeURIComponent(cookies[i].name) + '=' + encodeURIComponent(cookies[i].value);
// Set path // Set path
@ -258,7 +256,7 @@
if (useAjax) { if (useAjax) {
resetPolling(); resetPolling();
var xhReq = createXhrObject(); const xhReq = createXhrObject();
xhReq.open('GET', url, true); xhReq.open('GET', url, true);
xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhReq.send(); xhReq.send();
@ -276,7 +274,7 @@
*/ */
function parseMessage(messageJSON) { function parseMessage(messageJSON) {
$('#loading_indicator').css('display', 'none'); $('#loading_indicator').css('display', 'none');
var responseObject; let responseObject;
try { try {
responseObject = JSON.parse(messageJSON); responseObject = JSON.parse(messageJSON);
@ -367,14 +365,14 @@
setTimeout(queryInstallerStatus, 5000); setTimeout(queryInstallerStatus, 5000);
} else { } else {
$('#loading_indicator').css('display', 'none'); $('#loading_indicator').css('display', 'none');
addMessage('error', [ addMessage('error',
{ [ {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
title: installLang.title, title: installLang.title,
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
description: installLang.msg, description: installLang.msg,
}, } ],
]); );
} }
} }
@ -382,9 +380,9 @@
* Queries the installer's status * Queries the installer's status
*/ */
function queryInstallerStatus() { function queryInstallerStatus() {
var url = $(location).attr('pathname'); let url = $(location).attr('pathname');
var lookUp = 'install/app.php'; let lookUp = 'install/app.php';
var position = url.indexOf(lookUp); let position = url.indexOf(lookUp);
if (position === -1) { if (position === -1) {
lookUp = 'install'; lookUp = 'install';
@ -407,12 +405,12 @@
* @param xhReq XHR object * @param xhReq XHR object
*/ */
function pollContent(xhReq) { function pollContent(xhReq) {
var messages = xhReq.responseText; const messages = xhReq.responseText;
var msgSeparator = '}\n\n'; const msgSeparator = '}\n\n';
var unprocessed; let unprocessed;
var messageEndIndex; let messageEndIndex;
var endOfMessageIndex; let endOfMessageIndex;
var message; let message;
do { do {
unprocessed = messages.substring(nextReadPosition); unprocessed = messages.substring(nextReadPosition);
@ -430,7 +428,7 @@
$('#loading_indicator').css('display', 'none'); $('#loading_indicator').css('display', 'none');
resetPolling(); resetPolling();
var timeoutDetected = !transmissionOver; const timeoutDetected = !transmissionOver;
if (refreshRequested) { if (refreshRequested) {
refreshRequested = false; refreshRequested = false;
@ -458,7 +456,7 @@
return; return;
} }
var $progressBar = $('#progress-bar'); const $progressBar = $('#progress-bar');
currentProgress++; currentProgress++;
$progressFillerText.css('width', $progressBar.width()); $progressFillerText.css('width', $progressBar.width());
@ -473,10 +471,10 @@
* @param progressLimit * @param progressLimit
*/ */
function incrementProgressBar(progressLimit) { function incrementProgressBar(progressLimit) {
var $progressFiller = $('#progress-bar-filler'); const $progressFiller = $('#progress-bar-filler');
var $progressFillerText = $('#progress-bar-filler-text'); const $progressFillerText = $('#progress-bar-filler-text');
var $progressText = $('#progress-bar-text'); const $progressText = $('#progress-bar-text');
var progressStart = $progressFiller.width() / $progressFiller.offsetParent().width() * 100; const progressStart = $progressFiller.width() / $progressFiller.offsetParent().width() * 100;
currentProgress = Math.floor(progressStart); currentProgress = Math.floor(progressStart);
clearInterval(progressTimer); clearInterval(progressTimer);
@ -512,7 +510,7 @@
function doRefresh() { function doRefresh() {
resetPolling(); resetPolling();
var xhReq = createXhrObject(); const xhReq = createXhrObject();
xhReq.open('GET', $(location).attr('pathname'), true); xhReq.open('GET', $(location).attr('pathname'), true);
xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhReq.send(); xhReq.send();
@ -529,47 +527,47 @@
// Clear content // Clear content
$contentWrapper.html(''); $contentWrapper.html('');
var $header = $('<div />'); const $header = $('<div />');
$header.attr('id', 'header-container'); $header.attr('id', 'header-container');
$contentWrapper.append($header); $contentWrapper.append($header);
var $description = $('<div />'); const $description = $('<div />');
$description.attr('id', 'description-container'); $description.attr('id', 'description-container');
$contentWrapper.append($description); $contentWrapper.append($description);
var $errorContainer = $('<div />'); const $errorContainer = $('<div />');
$errorContainer.attr('id', 'error-container'); $errorContainer.attr('id', 'error-container');
$contentWrapper.append($errorContainer); $contentWrapper.append($errorContainer);
var $warningContainer = $('<div />'); const $warningContainer = $('<div />');
$warningContainer.attr('id', 'warning-container'); $warningContainer.attr('id', 'warning-container');
$contentWrapper.append($warningContainer); $contentWrapper.append($warningContainer);
var $progressContainer = $('<div />'); const $progressContainer = $('<div />');
$progressContainer.attr('id', 'progress-bar-container'); $progressContainer.attr('id', 'progress-bar-container');
$contentWrapper.append($progressContainer); $contentWrapper.append($progressContainer);
var $logContainer = $('<div />'); const $logContainer = $('<div />');
$logContainer.attr('id', 'log-container'); $logContainer.attr('id', 'log-container');
$contentWrapper.append($logContainer); $contentWrapper.append($logContainer);
var $installerContentWrapper = $('<div />'); const $installerContentWrapper = $('<div />');
$installerContentWrapper.attr('id', 'content-container'); $installerContentWrapper.attr('id', 'content-container');
$contentWrapper.append($installerContentWrapper); $contentWrapper.append($installerContentWrapper);
var $installerDownloadWrapper = $('<div />'); const $installerDownloadWrapper = $('<div />');
$installerDownloadWrapper.attr('id', 'download-wrapper'); $installerDownloadWrapper.attr('id', 'download-wrapper');
$installerContentWrapper.append($installerDownloadWrapper); $installerContentWrapper.append($installerDownloadWrapper);
var $updaterFileStatusWrapper = $('<div />'); const $updaterFileStatusWrapper = $('<div />');
$updaterFileStatusWrapper.attr('id', 'file-status-wrapper'); $updaterFileStatusWrapper.attr('id', 'file-status-wrapper');
$installerContentWrapper.append($updaterFileStatusWrapper); $installerContentWrapper.append($updaterFileStatusWrapper);
var $formWrapper = $('<div />'); const $formWrapper = $('<div />');
$formWrapper.attr('id', 'form-wrapper'); $formWrapper.attr('id', 'form-wrapper');
$installerContentWrapper.append($formWrapper); $installerContentWrapper.append($formWrapper);
var $spinner = $('<div />'); const $spinner = $('<div />');
$spinner.attr('id', 'loading_indicator'); $spinner.attr('id', 'loading_indicator');
$spinner.html('&nbsp;'); $spinner.html('&nbsp;');
$contentWrapper.append($spinner); $contentWrapper.append($spinner);
@ -579,7 +577,7 @@
function submitForm($form, $submitBtn) { function submitForm($form, $submitBtn) {
$form.css('display', 'none'); $form.css('display', 'none');
var xhReq = createXhrObject(); const xhReq = createXhrObject();
xhReq.open('POST', $form.attr('action'), true); xhReq.open('POST', $form.attr('action'), true);
xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhReq.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhReq.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
@ -604,7 +602,7 @@
* @returns {*} * @returns {*}
*/ */
function getFormFields($form, $submitBtn) { function getFormFields($form, $submitBtn) {
var formData = $form.serialize(); let formData = $form.serialize();
formData += ((formData.length) ? '&' : '') + encodeURIComponent($submitBtn.attr('name')) + '='; formData += ((formData.length) ? '&' : '') + encodeURIComponent($submitBtn.attr('name')) + '=';
formData += encodeURIComponent($submitBtn.attr('value')); formData += encodeURIComponent($submitBtn.attr('value'));

View file

@ -1,6 +1,5 @@
/* global phpbb, plupload, attachInline, activateSubPanel */ /* global phpbb, plupload, attachInline, activateSubPanel */
/* eslint camelcase: 0 */ /* eslint camelcase: 0 */
/* eslint no-var: 0 */
plupload.addI18n(phpbb.plupload.i18n); plupload.addI18n(phpbb.plupload.i18n);
phpbb.plupload.ids = []; phpbb.plupload.ids = [];
@ -54,8 +53,8 @@ phpbb.plupload.ids = [];
* begin with 'attachment_data[' * begin with 'attachment_data['
*/ */
phpbb.plupload.clearParams = function() { phpbb.plupload.clearParams = function() {
var obj = phpbb.plupload.uploader.settings.multipart_params; const obj = phpbb.plupload.uploader.settings.multipart_params;
for (var key in obj) { for (const key in obj) {
if (!Object.prototype.hasOwnProperty.call(obj, key) || key.indexOf('attachment_data[') !== 0) { if (!Object.prototype.hasOwnProperty.call(obj, key) || key.indexOf('attachment_data[') !== 0) {
continue; continue;
} }
@ -70,7 +69,7 @@ phpbb.plupload.ids = [];
* @param {object} obj * @param {object} obj
*/ */
phpbb.plupload.updateMultipartParams = function(obj) { phpbb.plupload.updateMultipartParams = function(obj) {
var { settings } = phpbb.plupload.uploader; const { settings } = phpbb.plupload.uploader;
settings.multipart_params = $.extend(settings.multipart_params, obj); settings.multipart_params = $.extend(settings.multipart_params, obj);
}; };
@ -81,10 +80,10 @@ phpbb.plupload.ids = [];
* expected by the server * expected by the server
*/ */
phpbb.plupload.getSerializedData = function() { phpbb.plupload.getSerializedData = function() {
var obj = {}; const obj = {};
for (var i = 0; i < phpbb.plupload.data.length; i++) { for (let i = 0; i < phpbb.plupload.data.length; i++) {
var datum = phpbb.plupload.data[i]; const datum = phpbb.plupload.data[i];
for (var key in datum) { for (const key in datum) {
if (!Object.prototype.hasOwnProperty.call(datum, key)) { if (!Object.prototype.hasOwnProperty.call(datum, key)) {
continue; continue;
} }
@ -94,7 +93,7 @@ phpbb.plupload.ids = [];
} }
// Insert form data // Insert form data
var $pluploadForm = $(phpbb.plupload.config.form_hook).first(); const $pluploadForm = $(phpbb.plupload.config.form_hook).first();
obj.creation_time = $pluploadForm.find('input[type=hidden][name="creation_time"]').val(); obj.creation_time = $pluploadForm.find('input[type=hidden][name="creation_time"]').val();
obj.form_token = $pluploadForm.find('input[type=hidden][name="form_token"]').val(); obj.form_token = $pluploadForm.find('input[type=hidden][name="form_token"]').val();
@ -109,7 +108,7 @@ phpbb.plupload.ids = [];
* @returns {bool|int} Index of the file if exists, otherwise false. * @returns {bool|int} Index of the file if exists, otherwise false.
*/ */
phpbb.plupload.getIndex = function(attachId) { phpbb.plupload.getIndex = function(attachId) {
var index = $.inArray(Number(attachId), phpbb.plupload.ids); const index = $.inArray(Number(attachId), phpbb.plupload.ids);
return index === -1 ? false : index; return index === -1 ? false : index;
}; };
@ -125,7 +124,7 @@ phpbb.plupload.ids = [];
phpbb.plupload.data = []; phpbb.plupload.data = [];
phpbb.plupload.data = data; phpbb.plupload.data = data;
for (var i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
phpbb.plupload.ids.push(Number(data[i].attach_id)); phpbb.plupload.ids.push(Number(data[i].attach_id));
} }
}; };
@ -152,7 +151,7 @@ phpbb.plupload.ids = [];
* @param {Array} downloadUrl Optional array of download urls to update. * @param {Array} downloadUrl Optional array of download urls to update.
*/ */
phpbb.plupload.updateRows = function(downloadUrl) { phpbb.plupload.updateRows = function(downloadUrl) {
for (var i = 0; i < phpbb.plupload.ids.length; i++) { for (let i = 0; i < phpbb.plupload.ids.length; i++) {
phpbb.plupload.updateRow(i, downloadUrl); phpbb.plupload.updateRow(i, downloadUrl);
} }
}; };
@ -166,7 +165,7 @@ phpbb.plupload.ids = [];
* @param {object} file Plupload file object for the new attachment. * @param {object} file Plupload file object for the new attachment.
*/ */
phpbb.plupload.insertRow = function(file) { phpbb.plupload.insertRow = function(file) {
var row = $(phpbb.plupload.rowTpl); const row = $(phpbb.plupload.rowTpl);
row.attr('id', file.id); row.attr('id', file.id);
row.find('.file-name').html(plupload.xmlEncode(file.name)); row.find('.file-name').html(plupload.xmlEncode(file.name));
@ -186,13 +185,13 @@ phpbb.plupload.ids = [];
* @param {Array} downloadUrl Optional array of download urls to update. * @param {Array} downloadUrl Optional array of download urls to update.
*/ */
phpbb.plupload.updateRow = function(index, downloadUrl) { phpbb.plupload.updateRow = function(index, downloadUrl) {
var attach = phpbb.plupload.data[index]; const attach = phpbb.plupload.data[index];
var row = $('[data-attach-id="' + attach.attach_id + '"]'); const row = $('[data-attach-id="' + attach.attach_id + '"]');
// Add the link to the file // Add the link to the file
if (typeof downloadUrl !== 'undefined' && typeof downloadUrl[index] !== 'undefined') { if (typeof downloadUrl !== 'undefined' && typeof downloadUrl[index] !== 'undefined') {
var url = downloadUrl[index].replace('&amp;', '&'); const url = downloadUrl[index].replace('&amp;', '&');
var link = $('<a></a>'); const link = $('<a></a>');
link.attr('href', url).html(attach.real_filename); link.attr('href', url).html(attach.real_filename);
row.find('.file-name').html(link); row.find('.file-name').html(link);
@ -212,12 +211,12 @@ phpbb.plupload.ids = [];
phpbb.plupload.updateHiddenData = function(row, attach, index) { phpbb.plupload.updateHiddenData = function(row, attach, index) {
row.find('input[type="hidden"]').remove(); row.find('input[type="hidden"]').remove();
for (var key in attach) { for (const key in attach) {
if (!Object.prototype.hasOwnProperty.call(attach, key)) { if (!Object.prototype.hasOwnProperty.call(attach, key)) {
continue; continue;
} }
var input = $('<input />') const input = $('<input />')
.attr('type', 'hidden') .attr('type', 'hidden')
.attr('name', 'attachment_data[' + index + '][' + key + ']') .attr('name', 'attachment_data[' + index + '][' + key + ']')
.attr('value', attach[key]); .attr('value', attach[key]);
@ -237,7 +236,7 @@ phpbb.plupload.ids = [];
phpbb.plupload.deleteFile = function(row, attachId) { phpbb.plupload.deleteFile = function(row, attachId) {
// If there's no attach id, then the file hasn't been uploaded. Simply delete the row. // If there's no attach id, then the file hasn't been uploaded. Simply delete the row.
if (typeof attachId === 'undefined') { if (typeof attachId === 'undefined') {
var file = phpbb.plupload.uploader.getFile(row.attr('id')); const file = phpbb.plupload.uploader.getFile(row.attr('id'));
phpbb.plupload.uploader.removeFile(file); phpbb.plupload.uploader.removeFile(file);
row.slideUp(100, () => { row.slideUp(100, () => {
@ -246,21 +245,21 @@ phpbb.plupload.ids = [];
}); });
} }
var index = phpbb.plupload.getIndex(attachId); const index = phpbb.plupload.getIndex(attachId);
row.find('.file-status').toggleClass('file-uploaded file-working'); row.find('.file-status').toggleClass('file-uploaded file-working');
if (index === false) { if (index === false) {
return; return;
} }
var fields = {}; const fields = {};
fields['delete_file[' + index + ']'] = 1; fields['delete_file[' + index + ']'] = 1;
var always = function() { const always = function() {
row.find('.file-status').removeClass('file-working'); row.find('.file-status').removeClass('file-working');
}; };
var done = function(response) { const done = function(response) {
if (typeof response !== 'object') { if (typeof response !== 'object') {
return; return;
} }
@ -289,7 +288,7 @@ phpbb.plupload.ids = [];
phpbb.plupload.handleMaxFilesReached(); phpbb.plupload.handleMaxFilesReached();
if (row.attr('id')) { if (row.attr('id')) {
var file = phpbb.plupload.uploader.getFile(row.attr('id')); const file = phpbb.plupload.uploader.getFile(row.attr('id'));
phpbb.plupload.uploader.removeFile(file); phpbb.plupload.uploader.removeFile(file);
} }
@ -330,8 +329,8 @@ phpbb.plupload.ids = [];
*/ */
phpbb.plupload.updateBbcode = function(action, index) { phpbb.plupload.updateBbcode = function(action, index) {
const textarea = $('#message', phpbb.plupload.form); const textarea = $('#message', phpbb.plupload.form);
var text = textarea.val(); let text = textarea.val();
var removal = (action === 'removal'); const removal = (action === 'removal');
// Return if the bbcode isn't used at all. // Return if the bbcode isn't used at all.
if (text.indexOf('[attachment=') === -1) { if (text.indexOf('[attachment=') === -1) {
@ -339,21 +338,21 @@ phpbb.plupload.ids = [];
} }
function runUpdate(i) { function runUpdate(i) {
var regex = new RegExp('\\[attachment=' + i + '\\](.*?)\\[\\/attachment\\]', 'g'); const regex = new RegExp('\\[attachment=' + i + '\\](.*?)\\[\\/attachment\\]', 'g');
text = text.replace(regex, (_, fileName) => { text = text.replace(regex, (_, fileName) => {
// Remove the bbcode if the file was removed. // Remove the bbcode if the file was removed.
if (removal && index === i) { if (removal && index === i) {
return ''; return '';
} }
var newIndex = i + ((removal) ? -1 : 1); const newIndex = i + ((removal) ? -1 : 1);
return '[attachment=' + newIndex + ']' + fileName + '[/attachment]'; return '[attachment=' + newIndex + ']' + fileName + '[/attachment]';
}); });
} }
// Loop forwards when removing and backwards when adding ensures we don't // Loop forwards when removing and backwards when adding ensures we don't
// corrupt the bbcode index. // corrupt the bbcode index.
var i; let i;
if (removal) { if (removal) {
for (i = index; i < phpbb.plupload.ids.length; i++) { for (i = index; i < phpbb.plupload.ids.length; i++) {
runUpdate(i); runUpdate(i);
@ -376,7 +375,7 @@ phpbb.plupload.ids = [];
* @returns {Array} The Plupload file objects matching the status. * @returns {Array} The Plupload file objects matching the status.
*/ */
phpbb.plupload.getFilesByStatus = function(status) { phpbb.plupload.getFilesByStatus = function(status) {
var files = []; const files = [];
$.each(phpbb.plupload.uploader.files, (i, file) => { $.each(phpbb.plupload.uploader.files, (i, file) => {
if (file.status === status) { if (file.status === status) {
@ -439,7 +438,7 @@ phpbb.plupload.ids = [];
* @param {string} error Error message to present to the user. * @param {string} error Error message to present to the user.
*/ */
phpbb.plupload.markQueuedFailed = function(error) { phpbb.plupload.markQueuedFailed = function(error) {
var files = phpbb.plupload.getFilesByStatus(plupload.QUEUED); const files = phpbb.plupload.getFilesByStatus(plupload.QUEUED);
$.each(files, (i, file) => { $.each(files, (i, file) => {
$('#' + file.id).find('.file-progress').hide(); $('#' + file.id).find('.file-progress').hide();
@ -512,14 +511,14 @@ phpbb.plupload.ids = [];
} }
}); });
var $fileList = $('#file-list'); const $fileList = $('#file-list');
/** /**
* Insert inline attachment bbcode. * Insert inline attachment bbcode.
*/ */
$fileList.on('click', '.file-inline-bbcode', function(e) { $fileList.on('click', '.file-inline-bbcode', function(e) {
var attachId = $(this).parents('.attach-row').attr('data-attach-id'); const attachId = $(this).parents('.attach-row').attr('data-attach-id');
var index = phpbb.plupload.getIndex(attachId); const index = phpbb.plupload.getIndex(attachId);
attachInline(index, phpbb.plupload.data[index].real_filename); attachInline(index, phpbb.plupload.data[index].real_filename);
e.preventDefault(); e.preventDefault();
@ -529,8 +528,8 @@ phpbb.plupload.ids = [];
* Delete a file. * Delete a file.
*/ */
$fileList.on('click', '.file-delete', function(e) { $fileList.on('click', '.file-delete', function(e) {
var row = $(this).parents('.attach-row'); const row = $(this).parents('.attach-row');
var attachId = row.attr('data-attach-id'); const attachId = row.attr('data-attach-id');
phpbb.plupload.deleteFile(row, attachId); phpbb.plupload.deleteFile(row, attachId);
e.preventDefault(); e.preventDefault();
@ -591,7 +590,7 @@ phpbb.plupload.ids = [];
return; return;
} }
var json = {}; let json = {};
try { try {
json = $.parseJSON(response.response); json = $.parseJSON(response.response);
} catch { } catch {
@ -638,7 +637,7 @@ phpbb.plupload.ids = [];
} }
// Show the file list if there aren't any files currently. // Show the file list if there aren't any files currently.
var $fileListContainer = $('#file-list-container'); const $fileListContainer = $('#file-list-container');
if (!$fileListContainer.is(':visible')) { if (!$fileListContainer.is(':visible')) {
$fileListContainer.show(100); $fileListContainer.show(100);
} }
@ -671,9 +670,9 @@ phpbb.plupload.ids = [];
* @param {string} response The response string from the server * @param {string} response The response string from the server
*/ */
phpbb.plupload.uploader.bind('FileUploaded', (up, file, response) => { phpbb.plupload.uploader.bind('FileUploaded', (up, file, response) => {
var json = {}; let json = {};
var row = $('#' + file.id); const row = $('#' + file.id);
var error; let error;
// Hide the progress indicator. // Hide the progress indicator.
row.find('.file-progress').hide(); row.find('.file-progress').hide();

View file

@ -1,22 +1,21 @@
/* global phpbb */ /* global phpbb */
/* eslint camelcase: 0 */ /* eslint camelcase: 0 */
/* eslint no-var: 0 */
(function($) { // Avoid conflicts with other libraries (function($) { // Avoid conflicts with other libraries
'use strict'; 'use strict';
// This callback will mark all forum icons read // This callback will mark all forum icons read
phpbb.addAjaxCallback('mark_forums_read', function(res) { phpbb.addAjaxCallback('mark_forums_read', function(res) {
var readTitle = res.NO_UNREAD_POSTS; const readTitle = res.NO_UNREAD_POSTS;
var unreadTitle = res.UNREAD_POSTS; const unreadTitle = res.UNREAD_POSTS;
var iconsArray = { const 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() {
var $this = $(this); const $this = $(this);
$.each(iconsArray, (unreadClass, readClass) => { $.each(iconsArray, (unreadClass, readClass) => {
if ($this.hasClass(unreadClass)) { if ($this.hasClass(unreadClass)) {
@ -47,17 +46,17 @@
* should be updated. Defaults to true. * should be updated. Defaults to true.
*/ */
phpbb.addAjaxCallback('mark_topics_read', (res, updateTopicLinks) => { phpbb.addAjaxCallback('mark_topics_read', (res, updateTopicLinks) => {
var readTitle = res.NO_UNREAD_POSTS; const readTitle = res.NO_UNREAD_POSTS;
var unreadTitle = res.UNREAD_POSTS; const unreadTitle = res.UNREAD_POSTS;
var iconsArray = { const iconsArray = {
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' ]; const iconsState = [ '', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine' ];
var classMap = {}; const classMap = {};
var classNames = []; const classNames = [];
if (typeof updateTopicLinks === 'undefined') { if (typeof updateTopicLinks === 'undefined') {
updateTopicLinks = true; updateTopicLinks = true;
@ -75,10 +74,10 @@
}); });
}); });
var unreadClassSelectors = '.' + classNames.join(',.'); const unreadClassSelectors = '.' + classNames.join(',.');
$('li.row').find(unreadClassSelectors).each(function() { $('li.row').find(unreadClassSelectors).each(function() {
var $this = $(this); const $this = $(this);
$.each(classMap, (unreadClass, readClass) => { $.each(classMap, (unreadClass, readClass) => {
if ($this.hasClass(unreadClass)) { if ($this.hasClass(unreadClass)) {
$this.removeClass(unreadClass).addClass(readClass); $this.removeClass(unreadClass).addClass(readClass);
@ -110,7 +109,7 @@
// This callback will mark a notification read // This callback will mark a notification read
phpbb.addAjaxCallback('notification.mark_read', function(res) { phpbb.addAjaxCallback('notification.mark_read', function(res) {
if (typeof res.success !== 'undefined') { if (typeof res.success !== 'undefined') {
var unreadCount = Number($('#notification-button strong').html()) - 1; const unreadCount = Number($('#notification-button strong').html()) - 1;
phpbb.markNotifications($(this).parent('[data-notification-unread="true"]'), unreadCount); phpbb.markNotifications($(this).parent('[data-notification-unread="true"]'), unreadCount);
} }
}); });
@ -128,7 +127,7 @@
// Update the notification link to the real URL. // Update the notification link to the real URL.
$popup.each(function() { $popup.each(function() {
var link = $(this).find('a'); const link = $(this).find('a');
link.attr('href', link.attr('data-real-url')); link.attr('href', link.attr('data-real-url'));
}); });
@ -141,21 +140,21 @@
} }
// Update page title // Update page title
var $title = $('title'); const $title = $('title');
var originalTitle = $title.text().replace(/(\((\d+)\))/, ''); const originalTitle = $title.text().replace(/(\((\d+)\))/, '');
$title.text((unreadCount ? '(' + unreadCount + ')' : '') + originalTitle); $title.text((unreadCount ? '(' + unreadCount + ')' : '') + originalTitle);
}; };
// This callback finds the post from the delete link, and removes it. // This callback finds the post from the delete link, and removes it.
phpbb.addAjaxCallback('post_delete', function() { phpbb.addAjaxCallback('post_delete', function() {
var $this = $(this); const $this = $(this);
var postId; let postId;
if ($this.attr('data-refresh') === undefined) { if ($this.attr('data-refresh') === undefined) {
postId = $this[0].href.split('&p=')[1]; postId = $this[0].href.split('&p=')[1];
var post = $this.parents('#p' + postId).css('pointer-events', 'none'); const post = $this.parents('#p' + postId).css('pointer-events', 'none');
if (post.hasClass('bg1') || post.hasClass('bg2')) { if (post.hasClass('bg1') || post.hasClass('bg2')) {
var posts1 = post.nextAll('.bg1'); const posts1 = post.nextAll('.bg1');
post.nextAll('.bg2').removeClass('bg2').addClass('bg1'); post.nextAll('.bg2').removeClass('bg2').addClass('bg1');
posts1.removeClass('bg1').addClass('bg2'); posts1.removeClass('bg1').addClass('bg2');
} }
@ -168,7 +167,7 @@
// This callback removes the approve / disapprove div or link. // This callback removes the approve / disapprove div or link.
phpbb.addAjaxCallback('post_visibility', function(res) { phpbb.addAjaxCallback('post_visibility', function(res) {
var remove = (res.visible) ? $(this) : $(this).parents('.post'); const remove = (res.visible) ? $(this) : $(this).parents('.post');
$(remove).css('pointer-events', 'none').fadeOut(function() { $(remove).css('pointer-events', 'none').fadeOut(function() {
$(this).remove(); $(this).remove();
}); });
@ -188,7 +187,7 @@
// This handles friend / foe additions removals. // This handles friend / foe additions removals.
phpbb.addAjaxCallback('zebra', res => { phpbb.addAjaxCallback('zebra', res => {
var zebra; let zebra;
if (res.success) { if (res.success) {
zebra = $('.zebra'); zebra = $('.zebra');
@ -202,13 +201,13 @@
*/ */
phpbb.addAjaxCallback('vote_poll', function(res) { phpbb.addAjaxCallback('vote_poll', function(res) {
if (typeof res.success !== 'undefined') { if (typeof res.success !== 'undefined') {
var poll = $(this).closest('.topic_poll'); const poll = $(this).closest('.topic_poll');
var panel = poll.find('.panel'); const panel = poll.find('.panel');
var resultsVisible = poll.find('dl:first-child .resultbar').is(':visible'); const resultsVisible = poll.find('dl:first-child .resultbar').is(':visible');
var mostVotes = 0; let 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) { const 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);
}; };
@ -231,8 +230,8 @@
// Get the votes count of the highest poll option // Get the votes count of the highest poll option
poll.find('[data-poll-option-id]').each(function() { poll.find('[data-poll-option-id]').each(function() {
var option = $(this); const option = $(this);
var optionId = option.attr('data-poll-option-id'); const optionId = option.attr('data-poll-option-id');
mostVotes = (res.vote_counts[optionId] >= mostVotes) ? res.vote_counts[optionId] : mostVotes; mostVotes = (res.vote_counts[optionId] >= mostVotes) ? res.vote_counts[optionId] : mostVotes;
}); });
@ -241,14 +240,14 @@
// Update each option // Update each option
poll.find('[data-poll-option-id]').each(function() { poll.find('[data-poll-option-id]').each(function() {
var $this = $(this); const $this = $(this);
var optionId = $this.attr('data-poll-option-id'); const optionId = $this.attr('data-poll-option-id');
var voted = (typeof res.user_votes[optionId] !== 'undefined'); const voted = (typeof res.user_votes[optionId] !== 'undefined');
var mostVoted = (res.vote_counts[optionId] === mostVotes); const mostVoted = (res.vote_counts[optionId] === mostVotes);
var percent = res.total_votes ? Math.round((res.vote_counts[optionId] / res.total_votes) * 100) : 0; const percent = res.total_votes ? Math.round((res.vote_counts[optionId] / res.total_votes) * 100) : 0;
var percentRel = (mostVotes === 0) ? 0 : Math.round((res.vote_counts[optionId] / mostVotes) * 100); const percentRel = (mostVotes === 0) ? 0 : Math.round((res.vote_counts[optionId] / mostVotes) * 100);
var altText = $this.attr('data-alt-text'); const altText = $this.attr('data-alt-text');
if (voted) { if (voted) {
$this.attr('title', $.trim(altText)); $this.attr('title', $.trim(altText));
} else { } else {
@ -259,9 +258,9 @@
$this.toggleClass('most-votes', mostVoted); $this.toggleClass('most-votes', mostVoted);
// Update the bars // Update the bars
var bar = $this.find('.resultbar div'); const bar = $this.find('.resultbar div');
var barTimeLapse = (res.can_vote) ? 500 : 1500; const barTimeLapse = (res.can_vote) ? 500 : 1500;
var newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1); const newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1);
setTimeout(() => { setTimeout(() => {
bar.animate({ width: percentRel + '%' }, 500) bar.animate({ width: percentRel + '%' }, 500)
@ -269,7 +268,7 @@
.addClass(newBarClass) .addClass(newBarClass)
.html(res.vote_counts[optionId]); .html(res.vote_counts[optionId]);
var percentText = percent ? percent + '%' : res.NO_VOTES; const percentText = percent ? percent + '%' : res.NO_VOTES;
$this.find('.poll_option_percent').html(percentText); $this.find('.poll_option_percent').html(percentText);
}, barTimeLapse); }, barTimeLapse);
}); });
@ -279,7 +278,7 @@
} }
// Display "Your vote has been cast." message. Disappears after 5 seconds. // Display "Your vote has been cast." message. Disappears after 5 seconds.
var confirmationDelay = (res.can_vote) ? 300 : 900; const confirmationDelay = (res.can_vote) ? 300 : 900;
poll.find('.vote-submitted').delay(confirmationDelay).slideDown(200, function() { poll.find('.vote-submitted').delay(confirmationDelay).slideDown(200, function() {
if (resultsVisible) { if (resultsVisible) {
updatePanelHeight(); updatePanelHeight();
@ -295,9 +294,9 @@
resizePanel(500); resizePanel(500);
}, 1500); }, 1500);
var resizePanel = function(time) { const resizePanel = function(time) {
var panelHeight = panel.height(); const panelHeight = panel.height();
var innerHeight = panel.find('.inner').outerHeight(); const innerHeight = panel.find('.inner').outerHeight();
if (panelHeight !== innerHeight) { if (panelHeight !== innerHeight) {
panel.css({ minHeight: '', height: panelHeight }) panel.css({ minHeight: '', height: panelHeight })
@ -316,19 +315,19 @@
// Do not follow the link // Do not follow the link
e.preventDefault(); e.preventDefault();
var $poll = $(this).parents('.topic_poll'); const $poll = $(this).parents('.topic_poll');
$poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500); $poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500);
$poll.find('.poll_view_results').hide(500); $poll.find('.poll_view_results').hide(500);
}); });
$('[data-ajax]').each(function() { $('[data-ajax]').each(function() {
var $this = $(this); const $this = $(this);
var ajax = $this.attr('data-ajax'); const ajax = $this.attr('data-ajax');
var filter = $this.attr('data-filter'); let filter = $this.attr('data-filter');
if (ajax !== 'false') { if (ajax !== 'false') {
var fn = ajax === 'true' ? null : ajax; const fn = ajax === 'true' ? null : ajax;
filter = filter === undefined ? null : phpbb.getFunctionByName(filter); filter = filter === undefined ? null : phpbb.getFunctionByName(filter);
phpbb.ajaxify({ phpbb.ajaxify({
@ -355,7 +354,7 @@
// Do not follow the link // Do not follow the link
e.preventDefault(); e.preventDefault();
var postId = $(this).attr('data-post-id'); const postId = $(this).attr('data-post-id');
$('#post_content' + postId).show(); $('#post_content' + postId).show();
$('#profile' + postId).show(); $('#profile' + postId).show();
$('#post_hidden' + postId).hide(); $('#post_hidden' + postId).hide();
@ -380,7 +379,7 @@
* 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'); const $memberlistSearch = $('#memberlist_search');
$memberlistSearch.slideToggle('fast'); $memberlistSearch.slideToggle('fast');
phpbb.ajaxCallbacks.alt_text.call(this); phpbb.ajaxCallbacks.alt_text.call(this);
@ -419,7 +418,7 @@
* Automatically resize textarea * Automatically resize textarea
*/ */
$(() => { $(() => {
var $textarea = $('textarea:not(#message-box textarea, .no-auto-resize)'); const $textarea = $('textarea:not(#message-box textarea, .no-auto-resize)');
phpbb.resizeTextArea($textarea, { minHeight: 75, maxHeight: 250 }); phpbb.resizeTextArea($textarea, { minHeight: 75, maxHeight: 250 });
phpbb.resizeTextArea($('textarea', '#message-box')); phpbb.resizeTextArea($('textarea', '#message-box'));
}); });

View file

@ -1,7 +1,6 @@
/* global phpbb */ /* global phpbb */
/* eslint camelcase: 0 */ /* eslint camelcase: 0 */
/* eslint no-unused-vars: 0 */ /* eslint no-unused-vars: 0 */
/* eslint no-var:0 */
/** /**
* phpBB3 forum functions * phpBB3 forum functions
@ -37,10 +36,10 @@ function popup(url, width, height, name) {
function pageJump(item) { function pageJump(item) {
'use strict'; 'use strict';
var page = parseInt(item.val(), 10); const page = parseInt(item.val(), 10);
var perPage = item.attr('data-per-page'); const perPage = item.attr('data-per-page');
var baseUrl = item.attr('data-base-url'); const baseUrl = item.attr('data-base-url');
var startName = item.attr('data-start-name'); const startName = item.attr('data-start-name');
if (page !== null && !isNaN(page) && page === Math.floor(page) && page > 0) { if (page !== null && !isNaN(page) && page === Math.floor(page) && page > 0) {
if (baseUrl.indexOf('?') === -1) { if (baseUrl.indexOf('?') === -1) {
@ -59,7 +58,7 @@ function marklist(id, name, state) {
'use strict'; 'use strict';
jQuery('#' + id + ' input[type=checkbox][name]').each(function() { jQuery('#' + id + ' input[type=checkbox][name]').each(function() {
var $this = jQuery(this); const $this = jQuery(this);
if ($this.attr('name').substr(0, name.length) === name && !$this.prop('disabled')) { if ($this.attr('name').substr(0, name.length) === name && !$this.prop('disabled')) {
$this.prop('checked', state); $this.prop('checked', state);
} }
@ -104,11 +103,11 @@ jQuery($ => {
'use strict'; 'use strict';
$('.sub-panels').each(function() { $('.sub-panels').each(function() {
var $childNodes = $('a[data-subpanel]', this); const $childNodes = $('a[data-subpanel]', this);
var panels = $childNodes.map(function() { const panels = $childNodes.map(function() {
return this.getAttribute('data-subpanel'); return this.getAttribute('data-subpanel');
}); });
var showPanel = this.getAttribute('data-show-panel'); const showPanel = this.getAttribute('data-show-panel');
if (panels.length) { if (panels.length) {
activateSubPanel(showPanel, panels); activateSubPanel(showPanel, panels);
@ -126,8 +125,8 @@ jQuery($ => {
function activateSubPanel(p, panels) { function activateSubPanel(p, panels) {
'use strict'; 'use strict';
var i; let i;
var showPanel; let showPanel;
if (typeof p === 'string') { if (typeof p === 'string') {
showPanel = p; showPanel = p;
@ -151,16 +150,16 @@ function selectCode(a) {
'use strict'; 'use strict';
// Get ID of code block // Get ID of code block
var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0]; const e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
var s; let s;
var r; let r;
// Not IE and IE9+ // Not IE and IE9+
if (window.getSelection) { if (window.getSelection) {
s = window.getSelection(); s = window.getSelection();
// Safari and Chrome // Safari and Chrome
if (s.setBaseAndExtent) { if (s.setBaseAndExtent) {
var l = (e.innerText.length > 1) ? e.innerText.length - 1 : 1; const l = (e.innerText.length > 1) ? e.innerText.length - 1 : 1;
try { try {
s.setBaseAndExtent(e, 0, e, l); s.setBaseAndExtent(e, 0, e, l);
} catch (error) { } catch (error) {
@ -196,8 +195,8 @@ function selectCode(a) {
} }
} }
var inAutocomplete = false; let inAutocomplete = false;
var lastKeyEntered = ''; let lastKeyEntered = '';
/** /**
* Check event key * Check event key
@ -235,7 +234,7 @@ jQuery($ => {
'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'); const defaultButton = $(this).parents('form').find('input[type=submit].default-submit-action');
if (!defaultButton || defaultButton.length <= 0) { if (!defaultButton || defaultButton.length <= 0) {
return true; return true;
@ -260,10 +259,10 @@ jQuery($ => {
function insertUser(formId, value) { function insertUser(formId, value) {
'use strict'; 'use strict';
var $form = jQuery(formId); const $form = jQuery(formId);
var formName = $form.attr('data-form-name'); const formName = $form.attr('data-form-name');
var fieldName = $form.attr('data-field-name'); const fieldName = $form.attr('data-field-name');
var item = opener.document.forms[formName][fieldName]; const item = opener.document.forms[formName][fieldName];
if (item.value.length && item.type === 'textarea') { if (item.value.length && item.type === 'textarea') {
value = item.value + '\n' + value; value = item.value + '\n' + value;
@ -295,9 +294,9 @@ function insert_single_user(formId, user) {
function parseDocument($container) { function parseDocument($container) {
'use strict'; 'use strict';
var test = document.createElement('div'); const test = document.createElement('div');
var oldBrowser = (typeof test.style.borderRadius === 'undefined'); const oldBrowser = (typeof test.style.borderRadius === 'undefined');
var $body = $('body'); const $body = $('body');
/** /**
* Reset avatar dimensions when changing URL or EMAIL * Reset avatar dimensions when changing URL or EMAIL
@ -310,7 +309,7 @@ function parseDocument($container) {
* Pagination * Pagination
*/ */
$container.find('.pagination .page-jump-form :button').click(function() { $container.find('.pagination .page-jump-form :button').click(function() {
var $input = $(this).siblings('input.inputbox'); const $input = $(this).siblings('input.inputbox');
pageJump($input); pageJump($input);
}); });
@ -322,7 +321,7 @@ function parseDocument($container) {
}); });
$container.find('.pagination .dropdown-trigger').click(function() { $container.find('.pagination .dropdown-trigger').click(function() {
var $dropdownContainer = $(this).parent(); const $dropdownContainer = $(this).parent();
// Wait a little bit to make sure the dropdown has activated // Wait a little bit to make sure the dropdown has activated
setTimeout(() => { setTimeout(() => {
if ($dropdownContainer.hasClass('dropdown-visible')) { if ($dropdownContainer.hasClass('dropdown-visible')) {
@ -335,27 +334,27 @@ function parseDocument($container) {
* Resize navigation (breadcrumbs) block to keep all links on same line * Resize navigation (breadcrumbs) block to keep all links on same line
*/ */
$container.find('.navlinks').each(function() { $container.find('.navlinks').each(function() {
var $this = $(this); const $this = $(this);
var $left = $this.children().not('.rightside'); const $left = $this.children().not('.rightside');
var $right = $this.children('.rightside'); const $right = $this.children('.rightside');
if ($left.length !== 1 || !$right.length) { if ($left.length !== 1 || !$right.length) {
return; return;
} }
function resize() { function resize() {
var width = 0; let width = 0;
var diff = $left.outerWidth(true) - $left.width(); const diff = $left.outerWidth(true) - $left.width();
var minWidth = Math.max($this.width() / 3, 240); const minWidth = Math.max($this.width() / 3, 240);
$right.each(function() { $right.each(function() {
var $this = $(this); const $this = $(this);
if ($this.is(':visible')) { if ($this.is(':visible')) {
width += $this.outerWidth(true); width += $this.outerWidth(true);
} }
}); });
var maxWidth = $this.width() - width - diff; const maxWidth = $this.width() - width - diff;
$left.css('max-width', Math.floor(Math.max(maxWidth, minWidth)) + 'px'); $left.css('max-width', Math.floor(Math.max(maxWidth, minWidth)) + 'px');
} }
@ -367,25 +366,25 @@ function parseDocument($container) {
* Makes breadcrumbs responsive * Makes breadcrumbs responsive
*/ */
$container.find('.breadcrumbs:not([data-skip-responsive])').each(function() { $container.find('.breadcrumbs:not([data-skip-responsive])').each(function() {
var $this = $(this); const $this = $(this);
var $links = $this.find('.crumb'); const $links = $this.find('.crumb');
var { length } = $links; const { length } = $links;
var classes = [ 'wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny' ]; const classes = [ 'wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny' ];
var classesLength = classes.length; const classesLength = classes.length;
var maxHeight = 0; let maxHeight = 0;
var lastWidth = false; let lastWidth = false;
var wrapped = false; let wrapped = false;
// Set tooltips // Set tooltips
$this.find('a').each(function() { $this.find('a').each(function() {
var $link = $(this); const $link = $(this);
$link.attr('title', $link.text()); $link.attr('title', $link.text());
}); });
// Function that checks breadcrumbs // Function that checks breadcrumbs
function check() { function check() {
var height = $this.height(); const height = $this.height();
var width; let width;
// Test max-width set in code for .navlinks above // Test max-width set in code for .navlinks above
width = parseInt($this.css('max-width'), 10); width = parseInt($this.css('max-width'), 10);
@ -421,8 +420,8 @@ function parseDocument($container) {
return; return;
} }
for (var i = 0; i < classesLength; i++) { for (let i = 0; i < classesLength; i++) {
for (var j = length - 1; j >= 0; j--) { for (let j = length - 1; j >= 0; j--) {
$links.eq(j).addClass('wrapped ' + classes[i]); $links.eq(j).addClass('wrapped ' + classes[i]);
if ($this.height() <= maxHeight) { if ($this.height() <= maxHeight) {
return; return;
@ -456,9 +455,9 @@ function parseDocument($container) {
* responsive-show-all to list of classes * responsive-show-all to list of classes
*/ */
$container.find('.topiclist.responsive-show-all > li > dl').each(function() { $container.find('.topiclist.responsive-show-all > li > dl').each(function() {
var $this = $(this); const $this = $(this);
var $block = $this.find('dt .responsive-show:last-child'); let $block = $this.find('dt .responsive-show:last-child');
var first = true; let first = true;
// Create block that is visible only on mobile devices // Create block that is visible only on mobile devices
if ($block.length) { if ($block.length) {
@ -470,9 +469,9 @@ function parseDocument($container) {
// Copy contents of each column // Copy contents of each column
$this.find('dd').not('.mark').each(function() { $this.find('dd').not('.mark').each(function() {
var column = $(this); const column = $(this);
var $children = column.children(); const $children = column.children();
var html = column.html(); let html = column.html();
if ($children.length === 1 && $children.text() === column.text()) { if ($children.length === 1 && $children.text() === column.text()) {
html = $children.html(); html = $children.html();
@ -492,9 +491,9 @@ function parseDocument($container) {
* responsive-show-columns to list of classes * responsive-show-columns to list of classes
*/ */
$container.find('.topiclist.responsive-show-columns').each(function() { $container.find('.topiclist.responsive-show-columns').each(function() {
var $list = $(this); const $list = $(this);
var headers = []; const headers = [];
var headersLength = 0; let headersLength = 0;
// 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() {
@ -508,9 +507,9 @@ function parseDocument($container) {
// Parse each row // Parse each row
$list.find('dl').each(function() { $list.find('dl').each(function() {
var $this = $(this); const $this = $(this);
var $block = $this.find('dt .responsive-show:last-child'); let $block = $this.find('dt .responsive-show:last-child');
var first = true; let first = true;
// Create block that is visible only on mobile devices // Create block that is visible only on mobile devices
if ($block.length) { if ($block.length) {
@ -522,9 +521,9 @@ function parseDocument($container) {
// Copy contents of each column // Copy contents of each column
$this.find('dd').not('.mark').each(function(i) { $this.find('dd').not('.mark').each(function(i) {
var column = $(this); const column = $(this);
var children = column.children(); const children = column.children();
var html = column.html(); let html = column.html();
if (children.length === 1 && children.text() === column.text()) { if (children.length === 1 && children.text() === column.text()) {
html = children.html(); html = children.html();
@ -546,18 +545,18 @@ function parseDocument($container) {
* Responsive tables * Responsive tables
*/ */
$container.find('table.table1').not('.not-responsive').each(function() { $container.find('table.table1').not('.not-responsive').each(function() {
var $this = $(this); const $this = $(this);
var $th = $this.find('thead > tr > th'); const $th = $this.find('thead > tr > th');
var headers = []; const headers = [];
var totalHeaders = 0; let totalHeaders = 0;
var i; let i;
// Find each header // Find each header
$th.each(function(column) { $th.each(function(column) {
var cell = $(this); const cell = $(this);
var colspan = parseInt(cell.attr('colspan'), 10); let colspan = parseInt(cell.attr('colspan'), 10);
var dfn = cell.attr('data-dfn'); const dfn = cell.attr('data-dfn');
var text = dfn ? dfn : cell.text(); const text = dfn ? dfn : cell.text();
colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan; colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan;
@ -572,7 +571,7 @@ function parseDocument($container) {
} }
}); });
var headersLength = headers.length; const headersLength = headers.length;
// Add header text to each cell as <dfn> // Add header text to each cell as <dfn>
$this.addClass('responsive'); $this.addClass('responsive');
@ -583,9 +582,9 @@ function parseDocument($container) {
} }
$this.find('tbody > tr').each(function() { $this.find('tbody > tr').each(function() {
var row = $(this); const row = $(this);
var cells = row.children('td'); const cells = row.children('td');
var column = 0; let column = 0;
if (cells.length === 1) { if (cells.length === 1) {
row.addClass('big-column'); row.addClass('big-column');
@ -593,9 +592,9 @@ function parseDocument($container) {
} }
cells.each(function() { cells.each(function() {
var cell = $(this); const cell = $(this);
var colspan = parseInt(cell.attr('colspan'), 10); let colspan = parseInt(cell.attr('colspan'), 10);
var text = $.trim(cell.text()); const text = $.trim(cell.text());
if (headersLength <= column) { if (headersLength <= column) {
return; return;
@ -619,7 +618,7 @@ function parseDocument($container) {
* Hide empty responsive tables * Hide empty responsive tables
*/ */
$container.find('table.responsive > tbody').not('.responsive-skip-empty').each(function() { $container.find('table.responsive > tbody').not('.responsive-skip-empty').each(function() {
var $items = $(this).children('tr'); const $items = $(this).children('tr');
if (!$items.length) { if (!$items.length) {
$(this).parent('table:first').addClass('responsive-hide'); $(this).parent('table:first').addClass('responsive-hide');
} }
@ -629,24 +628,24 @@ function parseDocument($container) {
* Responsive tabs * Responsive tabs
*/ */
$container.find('#tabs, #minitabs').not('[data-skip-responsive]').each(function() { $container.find('#tabs, #minitabs').not('[data-skip-responsive]').each(function() {
var $this = $(this); const $this = $(this);
var $ul = $this.children(); const $ul = $this.children();
var $tabs = $ul.children().not('[data-skip-responsive]'); const $tabs = $ul.children().not('[data-skip-responsive]');
var $links = $tabs.children('a'); const $links = $tabs.children('a');
var $item = $ul.append('<li class="tab responsive-tab" style="display:none;"><a href="javascript:void(0);" class="responsive-tab-link">&nbsp;</a><div class="dropdown tab-dropdown" style="display: none;"><div class="pointer"><div class="pointer-inner"></div></div><ul class="dropdown-contents" /></div></li>').find('li.responsive-tab'); const $item = $ul.append('<li class="tab responsive-tab" style="display:none;"><a href="javascript:void(0);" class="responsive-tab-link">&nbsp;</a><div class="dropdown tab-dropdown" style="display: none;"><div class="pointer"><div class="pointer-inner"></div></div><ul class="dropdown-contents" /></div></li>').find('li.responsive-tab');
var $menu = $item.find('.dropdown-contents'); const $menu = $item.find('.dropdown-contents');
var maxHeight = 0; let maxHeight = 0;
var lastWidth = false; let lastWidth = false;
var responsive = false; let responsive = false;
$links.each(function() { $links.each(function() {
var $this = $(this); const $this = $(this);
maxHeight = Math.max(maxHeight, Math.max($this.outerHeight(true), $this.parent().outerHeight(true))); maxHeight = Math.max(maxHeight, Math.max($this.outerHeight(true), $this.parent().outerHeight(true)));
}); });
function check() { function check() {
var width = $body.width(); const width = $body.width();
var height = $this.height(); let height = $this.height();
if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) { if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) {
return; return;
@ -669,10 +668,10 @@ function parseDocument($container) {
$item.show(); $item.show();
$menu.html(''); $menu.html('');
var $availableTabs = $tabs.filter(':not(.activetab, .responsive-tab)'); const $availableTabs = $tabs.filter(':not(.activetab, .responsive-tab)');
var total = $availableTabs.length; const total = $availableTabs.length;
var i; let i;
var $tab; let $tab;
for (i = total - 1; i >= 0; i--) { for (i = total - 1; i >= 0; i--) {
$tab = $availableTabs.eq(i); $tab = $availableTabs.eq(i);
@ -691,7 +690,7 @@ function parseDocument($container) {
}); });
} }
var $tabLink = $item.find('a.responsive-tab-link'); const $tabLink = $item.find('a.responsive-tab-link');
phpbb.registerDropdown($tabLink, $item.find('.dropdown'), { phpbb.registerDropdown($tabLink, $item.find('.dropdown'), {
visibleClass: 'activetab', visibleClass: 'activetab',
}); });
@ -704,7 +703,7 @@ function parseDocument($container) {
* Hide UCP/MCP navigation if there is only 1 item * Hide UCP/MCP navigation if there is only 1 item
*/ */
$container.find('#navigation').each(function() { $container.find('#navigation').each(function() {
var $items = $(this).children('ol, ul').children('li'); const $items = $(this).children('ol, ul').children('li');
if ($items.length === 1) { if ($items.length === 1) {
$(this).addClass('responsive-hide'); $(this).addClass('responsive-hide');
} }
@ -714,10 +713,10 @@ function parseDocument($container) {
* Replace responsive text * Replace responsive text
*/ */
$container.find('[data-responsive-text]').each(function() { $container.find('[data-responsive-text]').each(function() {
var $this = $(this); const $this = $(this);
var fullText = $this.text(); const fullText = $this.text();
var responsiveText = $this.attr('data-responsive-text'); const responsiveText = $this.attr('data-responsive-text');
var responsive = false; let responsive = false;
function check() { function check() {
if ($(window).width() > 700) { if ($(window).width() > 700) {