[ticket/17517] Revert back to var

PHPBB-17517
This commit is contained in:
Matt Friedman 2025-06-01 08:41:18 -07:00
parent 5553e7ae19
commit b82d7d3f47
No known key found for this signature in database
10 changed files with 638 additions and 625 deletions

View file

@ -1,4 +1,5 @@
/* global phpbb */ /* global phpbb */
/* eslint no-var: 0 */
/** /**
* phpBB3 ACP functions * phpBB3 ACP functions
@ -8,15 +9,15 @@
* Parse document block * Parse document block
*/ */
function parseDocument(container) { function parseDocument(container) {
const test = document.createElement('div'); var test = document.createElement('div');
test.remove(); test.remove();
/** /**
* Navigation * Navigation
*/ */
container.find('#menu').each(function() { container.find('#menu').each(function() {
const menu = $(this); var menu = $(this);
const blocks = menu.children('.menu-block'); var blocks = menu.children('.menu-block');
if (!blocks.length) { if (!blocks.length) {
return; return;
@ -24,7 +25,7 @@ function parseDocument(container) {
// Set onclick event // Set onclick event
blocks.children('a.header').click(function() { blocks.children('a.header').click(function() {
const parent = $(this).parent(); var parent = $(this).parent();
if (!parent.hasClass('active')) { if (!parent.hasClass('active')) {
parent.siblings().removeClass('active'); parent.siblings().removeClass('active');
} }
@ -45,22 +46,22 @@ function parseDocument(container) {
* Responsive tables * Responsive tables
*/ */
container.find('table').not('.not-responsive').each(function() { container.find('table').not('.not-responsive').each(function() {
const $this = $(this); var $this = $(this);
const th = $this.find('thead > tr > th'); var th = $this.find('thead > tr > th');
const headers = []; var headers = [];
let totalHeaders = 0; var totalHeaders = 0;
let i; var i;
// Find columns // Find columns
$this.find('colgroup:first').children().each(function(i) { $this.find('colgroup:first').children().each(function(i) {
const column = $(this); var 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() {
const style = $(this).attr('style'); var 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');
} }
@ -70,10 +71,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) {
const cell = $(this); var cell = $(this);
let colspan = parseInt(cell.attr('colspan'), 10); var colspan = parseInt(cell.attr('colspan'), 10);
const dfn = cell.attr('data-dfn'); var dfn = cell.attr('data-dfn');
let text = dfn ? dfn : $.trim(cell.text()); var text = dfn ? dfn : $.trim(cell.text());
if (text === ' ') { if (text === ' ') {
text = ''; text = '';
@ -93,7 +94,7 @@ function parseDocument(container) {
}); });
} }
const headersLength = headers.length; 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');
@ -104,9 +105,9 @@ function parseDocument(container) {
} }
$this.find('tbody > tr').each(function() { $this.find('tbody > tr').each(function() {
const row = $(this); var row = $(this);
const cells = row.children('td'); var cells = row.children('td');
let column = 0; var column = 0;
if (cells.length === 1) { if (cells.length === 1) {
row.addClass('big-column'); row.addClass('big-column');
@ -114,9 +115,9 @@ function parseDocument(container) {
} }
cells.each(function() { cells.each(function() {
const cell = $(this); var cell = $(this);
let colspan = parseInt(cell.attr('colspan'), 10); var colspan = parseInt(cell.attr('colspan'), 10);
const text = $.trim(cell.text()); var text = $.trim(cell.text());
if (headersLength <= column) { if (headersLength <= column) {
return; return;
@ -143,7 +144,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() {
const items = $(this).children('tr'); var items = $(this).children('tr');
if (!items.length) { if (!items.length) {
$(this).parent('table:first').addClass('responsive-hide'); $(this).parent('table:first').addClass('responsive-hide');
} }
@ -153,7 +154,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() {
const $this = $(this); var $this = $(this);
if ($this.html() === '&nbsp;') { if ($this.html() === '&nbsp;') {
$this.addClass('responsive-hide'); $this.addClass('responsive-hide');
} }
@ -164,7 +165,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; const maxLength = $this.maxLength;
$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);
@ -178,25 +179,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() {
const $this = $(this); var $this = $(this);
const $body = $('body'); var $body = $('body');
const ul = $this.children(); var ul = $this.children();
const tabs = ul.children().not('[data-skip-responsive]'); var tabs = ul.children().not('[data-skip-responsive]');
const links = tabs.children('a'); var links = tabs.children('a');
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 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 menu = item.find('.dropdown-contents'); var menu = item.find('.dropdown-contents');
let maxHeight = 0; var maxHeight = 0;
let lastWidth = false; var lastWidth = false;
let responsive = false; var responsive = false;
links.each(function() { links.each(function() {
const link = $(this); var link = $(this);
maxHeight = Math.max(maxHeight, Math.max(link.outerHeight(true), link.parent().outerHeight(true))); maxHeight = Math.max(maxHeight, Math.max(link.outerHeight(true), link.parent().outerHeight(true)));
}); });
function check() { function check() {
const width = $body.width(); var width = $body.width();
let height = $this.height(); var height = $this.height();
if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) { if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) {
return; return;
@ -220,10 +221,10 @@ function parseDocument(container) {
item.show(); item.show();
menu.html(''); menu.html('');
const availableTabs = tabs.filter(':not(.activetab, .responsive-tab)'); var availableTabs = tabs.filter(':not(.activetab, .responsive-tab)');
const total = availableTabs.length; var total = availableTabs.length;
let i; var i;
let tab; var tab;
for (i = total - 1; i >= 0; i--) { for (i = total - 1; i >= 0; i--) {
tab = availableTabs.eq(i); tab = availableTabs.eq(i);
@ -265,10 +266,10 @@ function parseDocument(container) {
parseDocument($('body')); parseDocument($('body'));
$('#questionnaire-form').css('display', 'none'); $('#questionnaire-form').css('display', 'none');
const $triggerConfiglist = $('#trigger-configlist'); var $triggerConfiglist = $('#trigger-configlist');
$triggerConfiglist.on('click', function() { $triggerConfiglist.on('click', function() {
const $configlist = $('#configlist'); var $configlist = $('#configlist');
$configlist.closest('.send-stats-data-row').toggleClass('send-stats-data-hidden'); $configlist.closest('.send-stats-data-row').toggleClass('send-stats-data-hidden');
$configlist.closest('.send-stats-row').find('.send-stats-data-row:first-child').toggleClass('send-stats-data-only-row'); $configlist.closest('.send-stats-row').find('.send-stats-data-row:first-child').toggleClass('send-stats-data-only-row');
$(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() {
const $form = $('#acp_help_phpbb'); var $form = $('#acp_help_phpbb');
const $dark = $('#darkenwrapper'); var $dark = $('#darkenwrapper');
let $loadingIndicator; var $loadingIndicator;
$form.on('submit', function(event) { $form.on('submit', function(event) {
const $this = $(this); var $this = $(this);
const currentTime = Math.floor(new Date().getTime() / 1000); var currentTime = Math.floor(new Date().getTime() / 1000);
const statsTime = parseInt($this.find('input[name=help_send_statistics_time]').val(), 10); var 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') if (!$this.find('input[name=help_send_statistics]').is(':checked') || statsTime > currentTime) {
|| statsTime > currentTime) {
$form.find('input[type=submit]').click(); $form.find('input[type=submit]').click();
setTimeout(() => { setTimeout(() => {
$form.find('input[type=submit]').click(); $form.find('input[type=submit]').click();
@ -36,7 +36,7 @@
} }
phpbb.clearLoadingTimeout(); phpbb.clearLoadingTimeout();
let errorText = ''; var 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);
} }
const $sendStatisticsSuccess = $('<input />', { var $sendStatisticsSuccess = $('<input />', {
type: 'hidden', type: 'hidden',
name: 'send_statistics_response', name: 'send_statistics_response',
value: JSON.stringify(res), value: JSON.stringify(res),
@ -110,8 +110,8 @@
return; return;
} }
const $firstTr = $(this).parents('tr'); var $firstTr = $(this).parents('tr');
const $secondTr = $firstTr.next(); var $secondTr = $firstTr.next();
$firstTr.insertAfter($secondTr); $firstTr.insertAfter($secondTr);
}); });
@ -121,8 +121,8 @@
return; return;
} }
const $secondTr = $(this).parents('tr'); var $secondTr = $(this).parents('tr');
const $firstTr = $secondTr.prev(); var $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) {
const $this = $(this); var $this = $(this);
let newHref = $this.attr('href'); var 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() {
const $form = $('form#set-permissions'); var $form = $('form#set-permissions');
let fieldsetList = $form.find('fieldset[id^=perm]'); var fieldsetList = $form.find('fieldset[id^=perm]');
const formDataSets = []; var formDataSets = [];
let dataSetIndex = 0; var dataSetIndex = 0;
const $submitAllButton = $form.find('input[type=submit][name^=action]')[0]; var $submitAllButton = $form.find('input[type=submit][name^=action]')[0];
const $submitButton = $form.find('input[type=submit][data-clicked=true]')[0]; var $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
let permissionSubmitSize = 0; var permissionSubmitSize = 0;
let permissionRequestCount = 0; var permissionRequestCount = 0;
const forumIds = []; var forumIds = [];
let permissionSubmitFailed = false; var permissionSubmitFailed = false;
let clearIndicator = true; var 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);
const $fieldset = $('fieldset#' + value.id); var $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
const roleInput = $fieldset.find('input[name^=role][data-name]'); var 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 @@
} }
}); });
const $loadingIndicator = phpbb.loadingIndicator(); var $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++;
const $dark = $('#darkenwrapper'); var $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;
const $alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); var $alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
const $alertBoxLink = $alert.find('p.alert_text > a'); var $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() {
const $this = $(this); var $this = $(this);
const ajax = $this.attr('data-ajax'); var ajax = $this.attr('data-ajax');
if (ajax !== 'false') { if (ajax !== 'false') {
const fn = (ajax === 'true') ? null : ajax; var 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 });
const $setPermissionsForm = $('form#set-permissions'); var $setPermissionsForm = $('form#set-permissions');
if ($setPermissionsForm.length) { if ($setPermissionsForm.length) {
$setPermissionsForm.on('submit', e => { $setPermissionsForm.on('submit', e => {
submitPermissions(); submitPermissions();

View file

@ -2,15 +2,16 @@
/* 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) {
const form = document.getElementById('set-permissions'); var form = document.getElementById('set-permissions');
const cb = document.getElementsByTagName('input'); var cb = document.getElementsByTagName('input');
let display; var display;
if (status) { if (status) {
// show // show
@ -20,7 +21,7 @@ function display_checkboxes(status) {
display = 'none'; display = 'none';
} }
for (let i = 0; i < cb.length; i++ ) { for (var 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;
} }
@ -44,8 +45,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) {
const cb = document.getElementById('checkbox' + block_id); var cb = document.getElementById('checkbox' + block_id);
const fs = document.getElementById('perm' + block_id); var fs = document.getElementById('perm' + block_id);
if (cb.checked) { if (cb.checked) {
set_opacity(fs, 5); set_opacity(fs, 5);
@ -60,15 +61,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) {
const perm = document.getElementById('set-permissions'); var perm = document.getElementById('set-permissions');
const fs = perm.getElementsByTagName('fieldset'); var fs = perm.getElementsByTagName('fieldset');
let opacity = 5; var opacity = 5;
if (status) { if (status) {
opacity = 10; opacity = 10;
} }
for (let i = 0; i < fs.length; i++ ) { for (var 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);
} }
@ -88,7 +89,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 (let i = index; i < rb.length; i += 3 ) { for (var 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)
@ -111,18 +112,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) {
const table = document.getElementById('table' + id); var table = document.getElementById('table' + id);
const tab = document.getElementById('tab' + id); var 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;
} }
const rb = table.getElementsByTagName('input'); var rb = table.getElementsByTagName('input');
let colour = 'custom'; var colour = 'custom';
let status = get_radio_status(0, rb); var status = get_radio_status(0, rb);
if (status === 1) { if (status === 1) {
colour = 'yes'; colour = 'yes';
@ -154,11 +155,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) {
const block = document.getElementById('advanced' + block_id); var block = document.getElementById('advanced' + block_id);
const panels = block.getElementsByTagName('div'); var panels = block.getElementsByTagName('div');
const tab = document.getElementById('tab' + id); var tab = document.getElementById('tab' + id);
for (let i = 0; i < panels.length; i++) { for (var 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);
} }
@ -178,9 +179,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;
const old_tab = document.getElementById('tab' + active_option); var old_tab = document.getElementById('tab' + active_option);
const new_tab = document.getElementById('tab' + id); var new_tab = document.getElementById('tab' + id);
const adv_block = document.getElementById('advanced' + pmask + fmask); var 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);
@ -244,15 +245,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) {
const t = document.getElementById(id); var t = document.getElementById(id);
if (!t) { if (!t) {
return; return;
} }
const rb = t.getElementsByTagName('input'); var rb = t.getElementsByTagName('input');
for (let r = 0; r < rb.length; r++) { for (var 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;
} }
@ -260,15 +261,15 @@ function mark_options(id, s) {
} }
function mark_one_option(id, field_name, s) { function mark_one_option(id, field_name, s) {
const t = document.getElementById(id); var t = document.getElementById(id);
if (!t) { if (!t) {
return; return;
} }
const rb = t.getElementsByTagName('input'); var rb = t.getElementsByTagName('input');
for (let r = 0; r < rb.length; r++) { for (var 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;
} }
@ -285,21 +286,21 @@ function mark_one_option(id, field_name, s) {
* @returns {void} * @returns {void}
*/ */
function reset_role(id) { function reset_role(id) {
const t = document.getElementById(id); var 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
const parent = t.parentNode; var parent = t.parentNode;
const roleId = match_role_settings(id.replace('role', 'perm')); var roleId = match_role_settings(id.replace('role', 'perm'));
let text = no_role_assigned; var text = no_role_assigned;
let index = 0; var 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 (let i = 0; i < t.options.length; i++) { for (var 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;
@ -321,7 +322,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) {
const settings = role_options[role_id]; var settings = role_options[role_id];
if (!settings) { if (!settings) {
return; return;
@ -330,7 +331,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 (const r in settings) { for (var 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');
} }
@ -344,13 +345,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) {
const fieldset = document.getElementById(id); var fieldset = document.getElementById(id);
const radios = fieldset.getElementsByTagName('input'); var radios = fieldset.getElementsByTagName('input');
let set = {}; var set = {};
// Iterate over all the radio buttons // Iterate over all the radio buttons
for (let i = 0; i < radios.length; i++) { for (var i = 0; i < radios.length; i++) {
const matches = radios[i].id.match(/setting\[\d+]\[\d+]\[([a-z_]+)]/); var 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') {
@ -362,7 +363,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 (const r in role_options) { for (var 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,4 +1,5 @@
/* global phpbb */ /* global phpbb */
/* eslint no-var: 0 */
/* /*
javascript for Bubble Tooltips by Alessandro Fulciniti javascript for Bubble Tooltips by Alessandro Fulciniti
@ -15,7 +16,7 @@ phpBB Development Team:
(function($) { // Avoid conflicts with other libraries (function($) { // Avoid conflicts with other libraries
'use strict'; 'use strict';
const tooltips = []; var tooltips = [];
/** /**
* Enable tooltip replacements for selects * Enable tooltip replacements for selects
@ -24,9 +25,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) {
let $links; var $links;
const hold = $('<span />', { var hold = $('<span />', {
id: '_tooltip_container', id: '_tooltip_container',
css: { css: {
position: 'absolute', position: 'absolute',
@ -42,7 +43,7 @@ phpBB Development Team:
} }
$links.each(function() { $links.each(function() {
const $this = $(this); var $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) {
@ -61,13 +62,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) {
const text = $element.attr('data-title'); var text = $element.attr('data-title');
if (text === null || text.length === 0) { if (text === null || text.length === 0) {
return; return;
} }
const $title = $('<span />', { var $title = $('<span />', {
class: 'top', class: 'top',
css: { css: {
display: 'block', display: 'block',
@ -75,7 +76,7 @@ phpBB Development Team:
}) })
.append(document.createTextNode(headText)); .append(document.createTextNode(headText));
const $desc = $('<span />', { var $desc = $('<span />', {
class: 'bottom', class: 'bottom',
html: text, html: text,
css: { css: {
@ -83,7 +84,7 @@ phpBB Development Team:
}, },
}); });
const $tooltip = $('<span />', { var $tooltip = $('<span />', {
class: 'tooltip', class: 'tooltip',
css: { css: {
display: 'block', display: 'block',
@ -103,7 +104,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) {
const $this = $($element.target); var $this = $($element.target);
$('#_tooltip_container').append(tooltips[$this.attr('data-id')]); $('#_tooltip_container').append(tooltips[$this.attr('data-id')]);
phpbb.positionTooltip($this); phpbb.positionTooltip($this);
}; };
@ -112,7 +113,7 @@ phpBB Development Team:
* Hide tooltip * Hide tooltip
*/ */
phpbb.hideTooltip = function() { phpbb.hideTooltip = function() {
const d = document.getElementById('_tooltip_container'); var d = document.getElementById('_tooltip_container');
if (d.childNodes.length > 0) { if (d.childNodes.length > 0) {
d.removeChild(d.firstChild); d.removeChild(d.firstChild);
} }
@ -125,7 +126,7 @@ phpBB Development Team:
*/ */
phpbb.positionTooltip = function($element) { phpbb.positionTooltip = function($element) {
$element = $element.parent(); $element = $element.parent();
const offset = $element.offset(); var offset = $element.offset();
if ($('body').hasClass('rtl')) { if ($('body').hasClass('rtl')) {
$('#_tooltip_container').css({ $('#_tooltip_container').css({
@ -144,13 +145,13 @@ phpBB Development Team:
* Prepare roles drop down select * Prepare roles drop down select
*/ */
phpbb.prepareRolesDropdown = function() { phpbb.prepareRolesDropdown = function() {
const $options = $('.roles-options li'); var $options = $('.roles-options li');
// Display span and hide select // Display span and hide select
$('.roles-options > span').css('display', 'block'); $('.roles-options > span').css('display', 'block');
$('.roles-options > select').hide(); $('.roles-options > select').hide();
$('.roles-options > input[type=hidden]').each(function() { $('.roles-options > input[type=hidden]').each(function() {
const $this = $(this); var $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'));
@ -159,9 +160,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() {
const $this = $(this); var $this = $(this);
const $rolesOptions = $this.closest('.roles-options'); var $rolesOptions = $this.closest('.roles-options');
const $span = $rolesOptions.children('span'); var $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') {
@ -185,12 +186,12 @@ phpBB Development Team:
} }
$this.on('mouseover', function() { $this.on('mouseover', function() {
const $this = $(this); var $this = $(this);
$options.removeClass('roles-highlight'); $options.removeClass('roles-highlight');
$this.addClass('roles-highlight'); $this.addClass('roles-highlight');
}).on('click', function() { }).on('click', function() {
const $this = $(this); var $this = $(this);
const $rolesOptions = $this.closest('.roles-options'); var $rolesOptions = $this.closest('.roles-options');
// Update settings // Update settings
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef

View file

@ -1,13 +1,14 @@
/* global bbfontstyle */ /* global bbfontstyle */
/* eslint no-var: 0 */
const phpbb = {}; var 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.
const keymap = { var keymap = {
TAB: 9, TAB: 9,
ENTER: 13, ENTER: 13,
ESC: 27, ESC: 27,
@ -15,9 +16,9 @@ phpbb.alertTime = 100;
ARROW_DOWN: 40, ARROW_DOWN: 40,
}; };
const $dark = $('#darkenwrapper'); var $dark = $('#darkenwrapper');
let $loadingIndicator; var $loadingIndicator;
let phpbbAlertTimer = null; var phpbbAlertTimer = null;
phpbb.isTouch = (window && typeof window.ontouchstart !== 'undefined'); phpbb.isTouch = (window && typeof window.ontouchstart !== 'undefined');
@ -54,7 +55,7 @@ phpbb.alertTime = 100;
* Show timeout message * Show timeout message
*/ */
phpbb.showTimeoutMessage = function() { phpbb.showTimeoutMessage = function() {
const $alert = $('#phpbb_alert'); var $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'));
@ -93,7 +94,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) {
const $alert = $('#phpbb_alert'); var $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);
@ -156,7 +157,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) {
const $fade = (fadedark) ? $dark : $alert; var $fade = (fadedark) ? $dark : $alert;
$fade.fadeOut(phpbb.alertTime, () => { $fade.fadeOut(phpbb.alertTime, () => {
$alert.hide(); $alert.hide();
@ -180,13 +181,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) {
const $confirmDiv = $('#phpbb_confirm'); var $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) {
const name = (e.keyCode === keymap.ENTER) ? 'confirm' : 'cancel'; var name = (e.keyCode === keymap.ENTER) ? 'confirm' : 'cancel';
$('input[name="' + name + '"]').trigger('click'); $('input[name="' + name + '"]').trigger('click');
e.preventDefault(); e.preventDefault();
@ -195,7 +196,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) {
const confirmed = this.name === 'confirm'; var 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');
@ -217,9 +218,9 @@ phpbb.alertTime = 100;
* @returns {object} The object created. * @returns {object} The object created.
*/ */
phpbb.parseQuerystring = function(string) { phpbb.parseQuerystring = function(string) {
const params = {}; var params = {};
let i; var i;
let split; var split;
string = string.split('&'); string = string.split('&');
for (i = 0; i < string.length; i++) { for (i = 0; i < string.length; i++) {
@ -244,13 +245,13 @@ phpbb.alertTime = 100;
* @param {object} options Options. * @param {object} options Options.
*/ */
phpbb.ajaxify = function(options) { phpbb.ajaxify = function(options) {
const $elements = $(options.selector); var $elements = $(options.selector);
let { refresh } = options; var refresh = options.refresh;
const { callback } = options; var callback = options.callback;
const overlay = typeof options.overlay === 'undefined' ? true : options.overlay; var overlay = typeof options.overlay === 'undefined' ? true : options.overlay;
const isForm = $elements.is('form'); var isForm = $elements.is('form');
const isText = $elements.is('input[type="text"], textarea'); var isText = $elements.is('input[type="text"], textarea');
let eventName; var eventName;
if (isForm) { if (isForm) {
eventName = 'submit'; eventName = 'submit';
@ -261,12 +262,12 @@ phpbb.alertTime = 100;
} }
$elements.on(eventName, function(event) { $elements.on(eventName, function(event) {
let action; var action;
let method; var method;
let data; var data;
let submit; var submit;
const that = this; var that = this;
const $this = $(this); var $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;
@ -281,8 +282,8 @@ phpbb.alertTime = 100;
} }
phpbb.clearLoadingTimeout(); phpbb.clearLoadingTimeout();
let responseText; var responseText;
let errorText = false; var errorText = false;
try { try {
responseText = JSON.parse(jqXHR.responseText); responseText = JSON.parse(jqXHR.responseText);
responseText = responseText.message; responseText = responseText.message;
@ -313,7 +314,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) {
let alert; var alert;
phpbb.clearLoadingTimeout(); phpbb.clearLoadingTimeout();
@ -380,7 +381,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.
const runFilter = (typeof options.filter === 'function'); var runFilter = (typeof options.filter === 'function');
data = {}; data = {};
if (isForm) { if (isForm) {
@ -396,7 +397,7 @@ phpbb.alertTime = 100;
}); });
} }
} else if (isText) { } else if (isText) {
const name = $this.attr('data-name') || this.name; var 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';
@ -406,13 +407,13 @@ phpbb.alertTime = 100;
method = 'GET'; method = 'GET';
} }
const sendRequest = function() { var sendRequest = function() {
const dataOverlay = $this.attr('data-overlay'); var dataOverlay = $this.attr('data-overlay');
if (overlay && (typeof dataOverlay === 'undefined' || dataOverlay === 'true')) { if (overlay && (typeof dataOverlay === 'undefined' || dataOverlay === 'true')) {
phpbb.loadingIndicator(); phpbb.loadingIndicator();
} }
const request = $.ajax({ var request = $.ajax({
url: action, url: action,
type: method, type: method,
data, data,
@ -440,7 +441,7 @@ phpbb.alertTime = 100;
if (isForm) { if (isForm) {
$elements.find('input:submit').click(function() { $elements.find('input:submit').click(function() {
const $this = $(this); var $this = $(this);
// Remove data-clicked attribute from any submit button of form // Remove data-clicked attribute from any submit button of form
$this.parents('form:first').find('input:submit[data-clicked]').removeAttr('data-clicked'); $this.parents('form:first').find('input:submit[data-clicked]').removeAttr('data-clicked');
@ -522,7 +523,7 @@ phpbb.alertTime = 100;
*/ */
phpbb.search.getKeyword = function($input, keyword, multiline) { phpbb.search.getKeyword = function($input, keyword, multiline) {
if (multiline) { if (multiline) {
const line = phpbb.search.getKeywordLine($input); var line = phpbb.search.getKeywordLine($input);
keyword = keyword.split('\n').splice(line, 1); keyword = keyword.split('\n').splice(line, 1);
} }
@ -537,7 +538,7 @@ phpbb.alertTime = 100;
* @returns {int} The line number. * @returns {int} The line number.
*/ */
phpbb.search.getKeywordLine = function($textarea) { phpbb.search.getKeywordLine = function($textarea) {
const { selectionStart } = $textarea.get(0); var { selectionStart } = $textarea.get(0);
return $textarea.val().substr(0, selectionStart).split('\n').length - 1; return $textarea.val().substr(0, selectionStart).split('\n').length - 1;
}; };
@ -551,8 +552,8 @@ phpbb.alertTime = 100;
*/ */
phpbb.search.setValue = function($input, value, multiline) { phpbb.search.setValue = function($input, value, multiline) {
if (multiline) { if (multiline) {
const line = phpbb.search.getKeywordLine($input); var line = phpbb.search.getKeywordLine($input);
const lines = $input.val().split('\n'); var lines = $input.val().split('\n');
lines[line] = value; lines[line] = value;
value = lines.join('\n'); value = lines.join('\n');
} }
@ -589,14 +590,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) {
const $this = $(this); var $this = $(this);
const dataName = $this.attr('data-name') === undefined ? $this.attr('name') : $this.attr('data-name'); var dataName = $this.attr('data-name') === undefined ? $this.attr('name') : $this.attr('data-name');
const minLength = parseInt($this.attr('data-min-length'), 10); var minLength = parseInt($this.attr('data-min-length'), 10);
const searchID = $this.attr('data-results'); var searchID = $this.attr('data-results');
const keyword = phpbb.search.getKeyword($this, data[dataName], $this.attr('data-multiline')); var keyword = phpbb.search.getKeyword($this, data[dataName], $this.attr('data-multiline'));
const cache = phpbb.search.cache.get(searchID); var cache = phpbb.search.cache.get(searchID);
const key = event.keyCode || event.which; var key = event.keyCode || event.which;
let proceed = true; var proceed = true;
data[dataName] = keyword; data[dataName] = keyword;
// No need to search if enter was pressed // No need to search if enter was pressed
@ -609,7 +610,7 @@ phpbb.alertTime = 100;
clearTimeout(cache.timeout); clearTimeout(cache.timeout);
} }
const timeout = setTimeout(function() { var 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;
@ -620,7 +621,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]) {
const response = { var response = {
keyword, keyword,
results: cache.results[keyword], results: cache.results[keyword],
}; };
@ -660,8 +661,8 @@ phpbb.alertTime = 100;
return; return;
} }
const searchID = $input.attr('data-results'); var searchID = $input.attr('data-results');
const $container = $(searchID); var $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;
@ -686,7 +687,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) {
const $resultContainer = $('.search-results', $container); var $resultContainer = $('.search-results', $container);
this.clearResults($resultContainer); this.clearResults($resultContainer);
if (!results.length) { if (!results.length) {
@ -694,9 +695,9 @@ phpbb.alertTime = 100;
return; return;
} }
const searchID = $container.attr('id'); var searchID = $container.attr('id');
let tpl; var tpl;
let row; var row;
if (!this.tpl[searchID]) { if (!this.tpl[searchID]) {
tpl = $('.search-result-tpl', $container); tpl = $('.search-result-tpl', $container);
@ -754,14 +755,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 => {
const key = event.keyCode || event.which; var key = event.keyCode || event.which;
const $active = $resultContainer.children('.active'); var $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) {
const value = $active.find('.search-result > span').text(); var 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'));
} }
@ -771,8 +772,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) {
const up = key === keymap.ARROW_UP; var up = key === keymap.ARROW_UP;
const $children = $resultContainer.children(); var $children = $resultContainer.children();
if (!$active.length) { if (!$active.length) {
if (up) { if (up) {
@ -805,7 +806,7 @@ phpbb.alertTime = 100;
}; };
$('#phpbb').click(function() { $('#phpbb').click(function() {
const $this = $(this); var $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'));
@ -834,7 +835,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) {
const fn = mode + 'State'; var fn = mode + 'State';
if (!url || !phpbb.history.isSupported(fn)) { if (!url || !phpbb.history.isSupported(fn)) {
return; return;
@ -880,10 +881,10 @@ phpbb.alertTime = 100;
* user be forced to repick one. * user be forced to repick one.
*/ */
phpbb.timezoneSwitchDate = function(keepSelection) { phpbb.timezoneSwitchDate = function(keepSelection) {
const $timezoneCopy = $('#timezone_copy'); var $timezoneCopy = $('#timezone_copy');
const $timezone = $('#timezone'); var $timezone = $('#timezone');
const $tzDate = $('#tz_date'); var $tzDate = $('#tz_date');
const $tzSelectDateSuggest = $('#tz_select_date_suggest'); var $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
@ -909,7 +910,7 @@ phpbb.alertTime = 100;
$tzSelectDateSuggest.css('display', 'inline'); $tzSelectDateSuggest.css('display', 'inline');
} }
const $tzOptions = $timezone.children('optgroup[data-tz-value="' + $tzDate.val() + '"]').children('option'); var $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.
@ -918,7 +919,7 @@ phpbb.alertTime = 100;
} }
if (typeof keepSelection !== 'undefined' && !keepSelection) { if (typeof keepSelection !== 'undefined' && !keepSelection) {
const $timezoneOptions = $timezone.find('optgroup option'); var $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);
} }
@ -939,16 +940,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.
let offset = (new Date()).getTimezoneOffset(); var offset = (new Date()).getTimezoneOffset();
let sign = '-'; var sign = '-';
if (offset < 0) { if (offset < 0) {
sign = '+'; sign = '+';
offset = -offset; offset = -offset;
} }
let minutes = offset % 60; var minutes = offset % 60;
let hours = (offset - minutes) / 60; var hours = (offset - minutes) / 60;
if (hours === 0) { if (hours === 0) {
hours = '00'; hours = '00';
@ -965,15 +966,15 @@ phpbb.alertTime = 100;
minutes = minutes.toString(); minutes = minutes.toString();
} }
const prefix = 'UTC' + sign + hours + ':' + minutes; var prefix = 'UTC' + sign + hours + ':' + minutes;
const prefixLength = prefix.length; var prefixLength = prefix.length;
const selectorOptions = $('option', '#tz_date'); var selectorOptions = $('option', '#tz_date');
let i; var i;
const $tzSelectDateSuggest = $('#tz_select_date_suggest'); var $tzSelectDateSuggest = $('#tz_select_date_suggest');
for (i = 0; i < selectorOptions.length; ++i) { for (i = 0; i < selectorOptions.length; ++i) {
const option = selectorOptions[i]; var 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) {
@ -987,7 +988,7 @@ phpbb.alertTime = 100;
$tzSelectDateSuggest.css('display', 'none'); $tzSelectDateSuggest.css('display', 'none');
} }
const suggestion = $tzSelectDateSuggest.attr('data-l-suggestion'); var 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)));
@ -1030,9 +1031,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() {
let $anchor; var $anchor;
const updateAll = $(this).data('update-all'); var updateAll = $(this).data('update-all');
let altText; var altText;
if (updateAll !== undefined && updateAll.length) { if (updateAll !== undefined && updateAll.length) {
$anchor = $(updateAll); $anchor = $(updateAll);
@ -1041,7 +1042,7 @@ phpbb.alertTime = 100;
} }
$anchor.each(function() { $anchor.each(function() {
const $this = $(this); var $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);
@ -1059,10 +1060,10 @@ phpbb.alertTime = 100;
* and changes the link itself. * and changes the link itself.
*/ */
phpbb.addAjaxCallback('toggle_link', function() { phpbb.addAjaxCallback('toggle_link', function() {
let $anchor; var $anchor;
const updateAll = $(this).data('update-all'); var updateAll = $(this).data('update-all');
let toggleText; var toggleText;
let toggleUrl; var toggleUrl;
if (updateAll !== undefined && updateAll.length) { if (updateAll !== undefined && updateAll.length) {
$anchor = $(updateAll); $anchor = $(updateAll);
@ -1071,7 +1072,7 @@ phpbb.alertTime = 100;
} }
$anchor.each(function() { $anchor.each(function() {
const $this = $(this); var $this = $(this);
// Toggle link text // Toggle link text
toggleText = $.trim($this.attr('data-toggle-text')); toggleText = $.trim($this.attr('data-toggle-text'));
@ -1113,7 +1114,7 @@ phpbb.alertTime = 100;
*/ */
phpbb.resizeTextArea = function($items, options) { phpbb.resizeTextArea = function($items, options) {
// Configuration // Configuration
let configuration = { var configuration = {
minWindowHeight: 500, minWindowHeight: 500,
minHeight: 200, minHeight: 200,
maxHeight: 500, maxHeight: 500,
@ -1131,7 +1132,7 @@ phpbb.alertTime = 100;
} }
function resetAutoResize(item) { function resetAutoResize(item) {
const $item = $(item); var $item = $(item);
if ($item.hasClass('auto-resized')) { if ($item.hasClass('auto-resized')) {
$(item) $(item)
.css({ height: '', resize: '' }) .css({ height: '', resize: '' })
@ -1149,20 +1150,20 @@ phpbb.alertTime = 100;
configuration.resizeCallback.call(item, $item); configuration.resizeCallback.call(item, $item);
} }
const windowHeight = $(window).height(); var windowHeight = $(window).height();
if (windowHeight < configuration.minWindowHeight) { if (windowHeight < configuration.minWindowHeight) {
resetAutoResize(item); resetAutoResize(item);
return; return;
} }
const maxHeight = Math.min( var maxHeight = Math.min(
Math.max(windowHeight - configuration.heightDiff, configuration.minHeight), Math.max(windowHeight - configuration.heightDiff, configuration.minHeight),
configuration.maxHeight, configuration.maxHeight,
); );
const $item = $(item); var $item = $(item);
const height = parseInt($item.innerHeight(), 10); var height = parseInt($item.innerHeight(), 10);
const scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0; var scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0;
if (height < 0) { if (height < 0) {
return; return;
@ -1202,20 +1203,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) {
const start = textarea.selectionStart; var start = textarea.selectionStart;
let lastEnd = -1; var lastEnd = -1;
let lastStart = -1; var lastStart = -1;
let i; var i;
let index; var index;
if (typeof start !== 'number') { if (typeof start !== 'number') {
return false; return false;
} }
const value = textarea.value.toLowerCase(); var value = textarea.value.toLowerCase();
for (i = 0; i < startTags.length; i++) { for (i = 0; i < startTags.length; i++) {
const tagLength = startTags[i].length; var 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);
@ -1250,9 +1251,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
const startTags = [ '[code]', '[code=' ]; var startTags = [ '[code]', '[code=' ];
const startTagsEnd = ']'; var startTagsEnd = ']';
const endTags = [ '[/code]' ]; var endTags = [ '[/code]' ];
if (!textarea || typeof textarea.selectionStart !== 'number') { if (!textarea || typeof textarea.selectionStart !== 'number') {
return; return;
@ -1275,17 +1276,17 @@ phpbb.alertTime = 100;
* @returns {string} Line of text * @returns {string} Line of text
*/ */
function getLastLine(stripCodeStart) { function getLastLine(stripCodeStart) {
const start = textarea.selectionStart; var start = textarea.selectionStart;
let { value } = textarea; var value = textarea.value;
let index = value.lastIndexOf('\n', start - 1); var index = value.lastIndexOf('\n', start - 1);
value = value.substring(index + 1, start); value = value.substring(index + 1, start);
if (stripCodeStart) { if (stripCodeStart) {
for (let i = 0; i < startTags.length; i++) { for (var i = 0; i < startTags.length; i++) {
index = value.lastIndexOf(startTags[i]); index = value.lastIndexOf(startTags[i]);
if (index >= 0) { if (index >= 0) {
const tagLength = startTags[i].length; var 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) {
@ -1309,9 +1310,9 @@ phpbb.alertTime = 100;
* @param {string} text Text to append * @param {string} text Text to append
*/ */
function appendText(text) { function appendText(text) {
const start = textarea.selectionStart; var start = textarea.selectionStart;
const end = textarea.selectionEnd; var end = textarea.selectionEnd;
const { value } = textarea; var value = textarea.value;
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;
@ -1319,7 +1320,7 @@ phpbb.alertTime = 100;
} }
$(textarea).data('code-editor', true).on('keydown', event => { $(textarea).data('code-editor', true).on('keydown', event => {
const key = event.keyCode || event.which; var key = event.keyCode || event.which;
// intercept tabs // intercept tabs
if (key === keymap.TAB if (key === keymap.TAB
@ -1337,8 +1338,8 @@ phpbb.alertTime = 100;
// intercept new line characters // intercept new line characters
if (key === keymap.ENTER) { if (key === keymap.ENTER) {
if (inTag()) { if (inTag()) {
const lastLine = getLastLine(true); var lastLine = getLastLine(true);
const code = String(/^\s*/g.exec(lastLine)); var code = String(/^\s*/g.exec(lastLine));
if (code.length > 0) { if (code.length > 0) {
appendText('\n' + code); appendText('\n' + code);
@ -1389,11 +1390,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_) {
const $this = $(this); var $this = $(this);
const options = $this.data('dropdown-options'); var options = $this.data('dropdown-options');
const { parent } = options; var parent = options.parent;
const visible = parent.hasClass('dropdown-visible'); var visible = parent.hasClass('dropdown-visible');
let direction; var direction;
if (!visible) { if (!visible) {
// Prevent link default action // Prevent link default action
@ -1404,8 +1405,8 @@ phpbb.alertTime = 100;
// Figure out direction of dropdown // Figure out direction of dropdown
direction = options.direction; direction = options.direction;
let { verticalDirection } = options; var verticalDirection = options.verticalDirection;
const offset = $this.offset(); var 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) {
@ -1419,8 +1420,8 @@ phpbb.alertTime = 100;
.toggleClass(options.rightClass, direction === 'right'); .toggleClass(options.rightClass, direction === 'right');
if (verticalDirection === 'auto') { if (verticalDirection === 'auto') {
const height = $(window).height(); var height = $(window).height();
const top = offset.top - $(window).scrollTop(); var top = offset.top - $(window).scrollTop();
verticalDirection = (top < height * 0.7) ? 'down' : 'up'; verticalDirection = (top < height * 0.7) ? 'down' : 'up';
} }
@ -1436,10 +1437,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) {
const windowWidth = $(window).width(); var windowWidth = $(window).width();
options.dropdown.find('.dropdown-contents').each(function() { options.dropdown.find('.dropdown-contents').each(function() {
const $this = $(this); var $this = $(this);
$this.css({ $this.css({
marginLeft: 0, marginLeft: 0,
@ -1448,8 +1449,8 @@ phpbb.alertTime = 100;
maxWidth: (windowWidth - 4) + 'px', maxWidth: (windowWidth - 4) + 'px',
}); });
const offset = $this.offset().left; var offset = $this.offset().left;
const width = $this.outerWidth(true); var width = $this.outerWidth(true);
if (offset < 2) { if (offset < 2) {
$this.css('left', (2 - offset) + 'px'); $this.css('left', (2 - offset) + 'px');
@ -1460,22 +1461,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());
}); });
const freeSpace = parent.offset().left - 4; var 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')) {
let contentWidth; var contentWidth;
const fullFreeSpace = freeSpace + parent.outerWidth(); var 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 });
}); });
const maxOffset = Math.min(contentWidth, fullFreeSpace) + 'px'; var maxOffset = Math.min(contentWidth, fullFreeSpace) + 'px';
options.dropdown.css({ options.dropdown.css({
width: maxOffset, width: maxOffset,
marginLeft: -maxOffset, marginLeft: -maxOffset,
@ -1490,7 +1491,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
const e = arguments[0]; var e = arguments[0];
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
} catch { } } catch { }
@ -1516,7 +1517,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) {
let ops = { var 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
@ -1549,12 +1550,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) {
let r; var r;
let g; var g;
let b; var b;
const numberList = new Array(6); var numberList = new Array(6);
let color = ''; var color = '';
let html = ''; var html = '';
numberList[0] = '00'; numberList[0] = '00';
numberList[1] = '40'; numberList[1] = '40';
@ -1562,7 +1563,7 @@ phpbb.alertTime = 100;
numberList[3] = 'BF'; numberList[3] = 'BF';
numberList[4] = 'FF'; numberList[4] = 'FF';
const tableClass = (dir === 'h') ? 'horizontal-palette' : 'vertical-palette'; var 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++) {
@ -1604,10 +1605,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.
const height = el.attr('data-height'); var height = el.attr('data-height');
const width = el.attr('data-width'); var width = el.attr('data-width');
const target = el.attr('data-target'); var target = el.attr('data-target');
const bbcode = el.attr('data-bbcode'); var 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));
@ -1620,7 +1621,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) {
const color = $(this).attr('data-color'); var color = $(this).attr('data-color');
if (bbcode) { if (bbcode) {
bbfontstyle('[color=#' + color + ']', '[/color]'); bbfontstyle('[color=#' + color + ']', '[/color]');
@ -1646,9 +1647,9 @@ phpbb.alertTime = 100;
type = 'block'; type = 'block';
} }
const $element = $('#' + id); var $element = $('#' + id);
const display = $element.css('display'); var display = $element.css('display');
if (!action) { if (!action) {
action = (display === '' || display === type) ? -1 : 1; action = (display === '' || display === type) ? -1 : 1;
} }
@ -1664,8 +1665,8 @@ phpbb.alertTime = 100;
*/ */
phpbb.toggleSelectSettings = function(el) { phpbb.toggleSelectSettings = function(el) {
el.children().each(function() { el.children().each(function() {
const $this = $(this); var $this = $(this);
const $setting = $($this.data('toggle-setting')); var $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
@ -1685,11 +1686,11 @@ phpbb.alertTime = 100;
* @returns function * @returns function
*/ */
phpbb.getFunctionByName = function(functionName) { phpbb.getFunctionByName = function(functionName) {
const namespaces = functionName.split('.'); var namespaces = functionName.split('.');
const func = namespaces.pop(); var func = namespaces.pop();
let context = window; var context = window;
for (let i = 0; i < namespaces.length; i++) { for (var i = 0; i < namespaces.length; i++) {
context = context[namespaces[i]]; context = context[namespaces[i]];
} }
@ -1725,17 +1726,17 @@ phpbb.alertTime = 100;
* Register page dropdowns. * Register page dropdowns.
*/ */
phpbb.registerPageDropdowns = function() { phpbb.registerPageDropdowns = function() {
const $body = $('body'); var $body = $('body');
$body.find('.dropdown-container').each(function() { $body.find('.dropdown-container').each(function() {
const $this = $(this); var $this = $(this);
let $trigger = $this.find('.dropdown-trigger:first'); var $trigger = $this.find('.dropdown-trigger:first');
let $contents = $this.find('.dropdown'); var $contents = $this.find('.dropdown');
const options = { var options = {
direction: 'auto', direction: 'auto',
verticalDirection: 'auto', verticalDirection: 'auto',
}; };
let data; var data;
if (!$trigger.length) { if (!$trigger.length) {
data = $this.attr('data-dropdown-trigger'); data = $this.attr('data-dropdown-trigger');
@ -1772,7 +1773,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 => {
const $parents = $(e.target).parents(); var $parents = $(e.target).parents();
if (!$parents.is(phpbb.dropdownVisibleContainers)) { if (!$parents.is(phpbb.dropdownVisibleContainers)) {
$(phpbb.dropdownHandles).each(phpbb.toggleDropdown); $(phpbb.dropdownHandles).each(phpbb.toggleDropdown);
} }
@ -1784,7 +1785,7 @@ phpbb.alertTime = 100;
*/ */
phpbb.lazyLoadAvatars = () => { phpbb.lazyLoadAvatars = () => {
$('.avatar[data-src]').each(function() { $('.avatar[data-src]').each(function() {
const $avatar = $(this); var $avatar = $(this);
$avatar $avatar
.attr('src', $avatar.data('src')) .attr('src', $avatar.data('src'))
@ -1922,7 +1923,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() {
const $this = $(this); var $this = $(this);
$this.change(() => { $this.change(() => {
phpbb.toggleSelectSettings($this); phpbb.toggleSelectSettings($this);

View file

@ -2,6 +2,10 @@
/* 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 ]
@ -9,25 +13,25 @@
*/ */
// Startup variables // Startup variables
const imageTag = false; var imageTag = false;
let theSelection = false; var theSelection = false;
const bbcodeEnabled = true; var 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
const clientPC = navigator.userAgent.toLowerCase(); // Get client info var clientPC = navigator.userAgent.toLowerCase(); // Get client info
const clientVer = parseInt(navigator.appVersion, 10); // Get browser version var clientVer = parseInt(navigator.appVersion, 10); // Get browser version
const is_ie = ((clientPC.indexOf('msie') !== -1) && (clientPC.indexOf('opera') === -1)); var is_ie = ((clientPC.indexOf('msie') !== -1) && (clientPC.indexOf('opera') === -1));
const is_win = ((clientPC.indexOf('win') !== -1) || (clientPC.indexOf('16bit') !== -1)); var is_win = ((clientPC.indexOf('win') !== -1) || (clientPC.indexOf('16bit') !== -1));
let baseHeight; var 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() {
let doc; var doc;
if (document.forms[form_name]) { if (document.forms[form_name]) {
doc = document; doc = document;
@ -35,7 +39,7 @@ function initInsertions() {
doc = opener.document; doc = opener.document;
} }
const textarea = doc.forms[form_name].elements[text_name]; var textarea = doc.forms[form_name].elements[text_name];
if (is_ie && typeof (baseHeight) !== 'number') { if (is_ie && typeof (baseHeight) !== 'number') {
textarea.focus(); textarea.focus();
@ -65,7 +69,7 @@ function bbstyle(bbnumber) {
function bbfontstyle(bbopen, bbclose) { function bbfontstyle(bbopen, bbclose) {
theSelection = false; theSelection = false;
const textarea = document.forms[form_name].elements[text_name]; var textarea = document.forms[form_name].elements[text_name];
textarea.focus(); textarea.focus();
@ -88,8 +92,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
const caret_pos = getCaretPosition(textarea).start; var caret_pos = getCaretPosition(textarea).start;
const new_pos = caret_pos + bbopen.length; var new_pos = caret_pos + bbopen.length;
// Open tag // Open tag
insert_text(bbopen + bbclose); insert_text(bbopen + bbclose);
@ -101,7 +105,7 @@ function bbfontstyle(bbopen, bbclose) {
textarea.selectionEnd = new_pos; textarea.selectionEnd = new_pos;
} else if (document.selection) { } else if (document.selection) {
// IE // IE
const range = textarea.createTextRange(); var range = textarea.createTextRange();
range.move('character', new_pos); range.move('character', new_pos);
range.select(); range.select();
storeCaret(textarea); storeCaret(textarea);
@ -114,7 +118,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) {
let textarea; var textarea;
if (popup) { if (popup) {
textarea = opener.document.forms[form_name].elements[text_name]; textarea = opener.document.forms[form_name].elements[text_name];
@ -129,8 +133,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) {
const sel_start = textarea.selectionStart; var sel_start = textarea.selectionStart;
const sel_end = textarea.selectionEnd; var sel_end = textarea.selectionEnd;
mozWrap(textarea, text, ''); mozWrap(textarea, text, '');
textarea.selectionStart = sel_start + text.length; textarea.selectionStart = sel_start + text.length;
@ -141,7 +145,7 @@ function insert_text(text, spaces, popup) {
storeCaret(textarea); storeCaret(textarea);
} }
const caret_pos = textarea.caretPos; var 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;
@ -164,10 +168,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) {
const message_name = 'message_' + post_id; var message_name = 'message_' + post_id;
let theSelection = ''; var theSelection = '';
let divarea = false; var divarea = false;
let i; var i;
if (l_wrote === undefined) { if (l_wrote === undefined) {
// Backwards compatibility // Backwards compatibility
@ -217,7 +221,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');
const lines = split_lines(theSelection); var 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');
} }
@ -240,22 +244,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+$/, '');
let quote = '[quote'; var 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 (const name in attributes) { for (var name in attributes) {
if (Object.hasOwn(attributes, name)) { if (Object.hasOwn(attributes, name)) {
const value = attributes[name]; var value = attributes[name];
quote += ' ' + name + '=' + formatAttributeValue(value.toString()); quote += ' ' + name + '=' + formatAttributeValue(value.toString());
} }
} }
quote += ']'; quote += ']';
const newline = ((quote + text + '[/quote]').length > 80 || text.indexOf('\n') > -1) ? '\n' : ''; var 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;
@ -277,25 +281,25 @@ function formatAttributeValue(str) {
return str; return str;
} }
const singleQuoted = '\'' + str.replace(/[\\']/g, '\\$&') + '\''; var singleQuoted = '\'' + str.replace(/[\\']/g, '\\$&') + '\'';
const doubleQuoted = '"' + str.replace(/[\\"]/g, '\\$&') + '"'; var 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) {
const lines = text.split('\n'); var lines = text.split('\n');
const splitLines = []; var splitLines = [];
let j = 0; var j = 0;
let i; var 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 {
let line = lines[i]; var line = lines[i];
let splitAt; var splitAt;
do { do {
splitAt = line.indexOf(' ', 80); splitAt = line.indexOf(' ', 80);
@ -319,14 +323,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) {
const selLength = (typeof (txtarea.textLength) === 'undefined') ? txtarea.value.length : txtarea.textLength; var selLength = (typeof (txtarea.textLength) === 'undefined') ? txtarea.value.length : txtarea.textLength;
const selStart = txtarea.selectionStart; var selStart = txtarea.selectionStart;
const selEnd = txtarea.selectionEnd; var selEnd = txtarea.selectionEnd;
const { scrollTop } = txtarea; var scrollTop = txtarea.scrollTop;
const s1 = (txtarea.value).substring(0, selStart); var s1 = (txtarea.value).substring(0, selStart);
const s2 = (txtarea.value).substring(selStart, selEnd); var s2 = (txtarea.value).substring(selStart, selEnd);
const s3 = (txtarea.value).substring(selEnd, selLength); var 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;
@ -349,15 +353,15 @@ function storeCaret(textEl) {
* Caret Position object * Caret Position object
*/ */
function caretPosition() { function caretPosition() {
const start = null; var start = null;
const end = null; var end = null;
} }
/** /**
* Get the caret position in an textarea * Get the caret position in an textarea
*/ */
function getCaretPosition(txtarea) { function getCaretPosition(txtarea) {
const caretPos = new caretPosition(); var caretPos = new caretPosition();
// simple Gecko/Opera way // simple Gecko/Opera way
if (txtarea.selectionStart || txtarea.selectionStart === 0) { if (txtarea.selectionStart || txtarea.selectionStart === 0) {
@ -366,14 +370,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
const range = document.selection.createRange(); var range = document.selection.createRange();
// a new selection of the whole textarea // a new selection of the whole textarea
const range_all = document.body.createTextRange(); var 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
let sel_start; var 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,21 +3,23 @@
*/ */
/* 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
let pollTimer = null; var pollTimer = null;
let nextReadPosition = 0; var nextReadPosition = 0;
let progressBarTriggered = false; var progressBarTriggered = false;
let progressTimer = null; var progressTimer = null;
let currentProgress = 0; var currentProgress = 0;
let refreshRequested = false; var refreshRequested = false;
let transmissionOver = false; var transmissionOver = false;
let statusCount = 0; var statusCount = 0;
// Template related variables // Template related variables
const $contentWrapper = $('.install-body').find('.main'); var $contentWrapper = $('.install-body').find('.main');
// Intercept form submits // Intercept form submits
interceptFormSubmit($('#install_install')); interceptFormSubmit($('#install_install'));
@ -43,15 +45,15 @@
*/ */
function addMessage(type, messages) { function addMessage(type, messages) {
// Get message containers // Get message containers
const $errorContainer = $('#error-container'); var $errorContainer = $('#error-container');
const $warningContainer = $('#warning-container'); var $warningContainer = $('#warning-container');
const $logContainer = $('#log-container'); var $logContainer = $('#log-container');
let $title; var $title;
let $description; var $description;
let $msgElement; var $msgElement;
const arraySize = messages.length; var arraySize = messages.length;
for (let i = 0; i < arraySize; i++) { for (var i = 0; i < arraySize; i++) {
$msgElement = $('<div />'); $msgElement = $('<div />');
$title = $('<strong />'); $title = $('<strong />');
$title.text(messages[i].title); $title.text(messages[i].title);
@ -84,13 +86,13 @@
* Render a download box * Render a download box
*/ */
function addDownloadBox(downloadArray) { function addDownloadBox(downloadArray) {
const $downloadContainer = $('#download-wrapper'); var $downloadContainer = $('#download-wrapper');
let $downloadBox; var $downloadBox;
let $title; var $title;
let $content; var $content;
let $link; var $link;
for (let i = 0; i < downloadArray.length; i++) { for (var i = 0; i < downloadArray.length; i++) {
$downloadBox = $('<div />'); $downloadBox = $('<div />');
$downloadBox.addClass('download-box'); $downloadBox.addClass('download-box');
@ -118,7 +120,7 @@
* Render update files' status * Render update files' status
*/ */
function addUpdateFileStatus(fileStatus) { function addUpdateFileStatus(fileStatus) {
const $statusContainer = $('#file-status-wrapper'); var $statusContainer = $('#file-status-wrapper');
$statusContainer.html(fileStatus); $statusContainer.html(fileStatus);
} }
@ -128,9 +130,9 @@
* @param formHtml * @param formHtml
*/ */
function addForm(formHtml) { function addForm(formHtml) {
const $formContainer = $('#form-wrapper'); var $formContainer = $('#form-wrapper');
$formContainer.html(formHtml); $formContainer.html(formHtml);
const $form = $('#install_install'); var $form = $('#install_install');
interceptFormSubmit($form); interceptFormSubmit($form);
} }
@ -140,16 +142,16 @@
* @param navObj * @param navObj
*/ */
function updateNavbarStatus(navObj) { function updateNavbarStatus(navObj) {
let navID; var navID;
let $stage; var $stage;
let $stageListItem; var $stageListItem;
const $active = $('#activemenu'); var $active = $('#activemenu');
if (navObj.hasOwnProperty('finished')) { if (navObj.hasOwnProperty('finished')) {
// This should be an Array // This should be an Array
const navItems = navObj.finished; var navItems = navObj.finished;
for (let i = 0; i < navItems.length; i++) { for (var 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();
@ -181,16 +183,16 @@
* @param progressObject * @param progressObject
*/ */
function setProgress(progressObject) { function setProgress(progressObject) {
let $statusText; var $statusText;
let $progressBar; var $progressBar;
let $progressText; var $progressText;
let $progressFiller; var $progressFiller;
let $progressFillerText; var $progressFillerText;
if (progressObject.task_name.length) { if (progressObject.task_name.length) {
if (!progressBarTriggered) { if (!progressBarTriggered) {
// Create progress bar // Create progress bar
const $progressBarWrapper = $('#progress-bar-container'); var $progressBarWrapper = $('#progress-bar-container');
// Create progress bar elements // Create progress bar elements
$progressBar = $('<div />'); $progressBar = $('<div />');
@ -240,9 +242,9 @@
// Set cookies // Set cookies
function setCookies(cookies) { function setCookies(cookies) {
let cookie; var cookie;
for (let i = 0; i < cookies.length; i++) { for (var 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
@ -256,7 +258,7 @@
if (useAjax) { if (useAjax) {
resetPolling(); resetPolling();
const xhReq = createXhrObject(); var 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();
@ -274,7 +276,7 @@
*/ */
function parseMessage(messageJSON) { function parseMessage(messageJSON) {
$('#loading_indicator').css('display', 'none'); $('#loading_indicator').css('display', 'none');
let responseObject; var responseObject;
try { try {
responseObject = JSON.parse(messageJSON); responseObject = JSON.parse(messageJSON);
@ -365,14 +367,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,
} ], },
); ]);
} }
} }
@ -380,9 +382,9 @@
* Queries the installer's status * Queries the installer's status
*/ */
function queryInstallerStatus() { function queryInstallerStatus() {
let url = $(location).attr('pathname'); var url = $(location).attr('pathname');
let lookUp = 'install/app.php'; var lookUp = 'install/app.php';
let position = url.indexOf(lookUp); var position = url.indexOf(lookUp);
if (position === -1) { if (position === -1) {
lookUp = 'install'; lookUp = 'install';
@ -405,12 +407,12 @@
* @param xhReq XHR object * @param xhReq XHR object
*/ */
function pollContent(xhReq) { function pollContent(xhReq) {
const messages = xhReq.responseText; var messages = xhReq.responseText;
const msgSeparator = '}\n\n'; var msgSeparator = '}\n\n';
let unprocessed; var unprocessed;
let messageEndIndex; var messageEndIndex;
let endOfMessageIndex; var endOfMessageIndex;
let message; var message;
do { do {
unprocessed = messages.substring(nextReadPosition); unprocessed = messages.substring(nextReadPosition);
@ -428,7 +430,7 @@
$('#loading_indicator').css('display', 'none'); $('#loading_indicator').css('display', 'none');
resetPolling(); resetPolling();
const timeoutDetected = !transmissionOver; var timeoutDetected = !transmissionOver;
if (refreshRequested) { if (refreshRequested) {
refreshRequested = false; refreshRequested = false;
@ -456,7 +458,7 @@
return; return;
} }
const $progressBar = $('#progress-bar'); var $progressBar = $('#progress-bar');
currentProgress++; currentProgress++;
$progressFillerText.css('width', $progressBar.width()); $progressFillerText.css('width', $progressBar.width());
@ -471,10 +473,10 @@
* @param progressLimit * @param progressLimit
*/ */
function incrementProgressBar(progressLimit) { function incrementProgressBar(progressLimit) {
const $progressFiller = $('#progress-bar-filler'); var $progressFiller = $('#progress-bar-filler');
const $progressFillerText = $('#progress-bar-filler-text'); var $progressFillerText = $('#progress-bar-filler-text');
const $progressText = $('#progress-bar-text'); var $progressText = $('#progress-bar-text');
const progressStart = $progressFiller.width() / $progressFiller.offsetParent().width() * 100; var progressStart = $progressFiller.width() / $progressFiller.offsetParent().width() * 100;
currentProgress = Math.floor(progressStart); currentProgress = Math.floor(progressStart);
clearInterval(progressTimer); clearInterval(progressTimer);
@ -510,7 +512,7 @@
function doRefresh() { function doRefresh() {
resetPolling(); resetPolling();
const xhReq = createXhrObject(); var 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();
@ -527,47 +529,47 @@
// Clear content // Clear content
$contentWrapper.html(''); $contentWrapper.html('');
const $header = $('<div />'); var $header = $('<div />');
$header.attr('id', 'header-container'); $header.attr('id', 'header-container');
$contentWrapper.append($header); $contentWrapper.append($header);
const $description = $('<div />'); var $description = $('<div />');
$description.attr('id', 'description-container'); $description.attr('id', 'description-container');
$contentWrapper.append($description); $contentWrapper.append($description);
const $errorContainer = $('<div />'); var $errorContainer = $('<div />');
$errorContainer.attr('id', 'error-container'); $errorContainer.attr('id', 'error-container');
$contentWrapper.append($errorContainer); $contentWrapper.append($errorContainer);
const $warningContainer = $('<div />'); var $warningContainer = $('<div />');
$warningContainer.attr('id', 'warning-container'); $warningContainer.attr('id', 'warning-container');
$contentWrapper.append($warningContainer); $contentWrapper.append($warningContainer);
const $progressContainer = $('<div />'); var $progressContainer = $('<div />');
$progressContainer.attr('id', 'progress-bar-container'); $progressContainer.attr('id', 'progress-bar-container');
$contentWrapper.append($progressContainer); $contentWrapper.append($progressContainer);
const $logContainer = $('<div />'); var $logContainer = $('<div />');
$logContainer.attr('id', 'log-container'); $logContainer.attr('id', 'log-container');
$contentWrapper.append($logContainer); $contentWrapper.append($logContainer);
const $installerContentWrapper = $('<div />'); var $installerContentWrapper = $('<div />');
$installerContentWrapper.attr('id', 'content-container'); $installerContentWrapper.attr('id', 'content-container');
$contentWrapper.append($installerContentWrapper); $contentWrapper.append($installerContentWrapper);
const $installerDownloadWrapper = $('<div />'); var $installerDownloadWrapper = $('<div />');
$installerDownloadWrapper.attr('id', 'download-wrapper'); $installerDownloadWrapper.attr('id', 'download-wrapper');
$installerContentWrapper.append($installerDownloadWrapper); $installerContentWrapper.append($installerDownloadWrapper);
const $updaterFileStatusWrapper = $('<div />'); var $updaterFileStatusWrapper = $('<div />');
$updaterFileStatusWrapper.attr('id', 'file-status-wrapper'); $updaterFileStatusWrapper.attr('id', 'file-status-wrapper');
$installerContentWrapper.append($updaterFileStatusWrapper); $installerContentWrapper.append($updaterFileStatusWrapper);
const $formWrapper = $('<div />'); var $formWrapper = $('<div />');
$formWrapper.attr('id', 'form-wrapper'); $formWrapper.attr('id', 'form-wrapper');
$installerContentWrapper.append($formWrapper); $installerContentWrapper.append($formWrapper);
const $spinner = $('<div />'); var $spinner = $('<div />');
$spinner.attr('id', 'loading_indicator'); $spinner.attr('id', 'loading_indicator');
$spinner.html('&nbsp;'); $spinner.html('&nbsp;');
$contentWrapper.append($spinner); $contentWrapper.append($spinner);
@ -577,7 +579,7 @@
function submitForm($form, $submitBtn) { function submitForm($form, $submitBtn) {
$form.css('display', 'none'); $form.css('display', 'none');
const xhReq = createXhrObject(); var 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');
@ -602,7 +604,7 @@
* @returns {*} * @returns {*}
*/ */
function getFormFields($form, $submitBtn) { function getFormFields($form, $submitBtn) {
let formData = $form.serialize(); var 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,5 +1,6 @@
/* 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 = [];
@ -53,8 +54,8 @@ phpbb.plupload.ids = [];
* begin with 'attachment_data[' * begin with 'attachment_data['
*/ */
phpbb.plupload.clearParams = function() { phpbb.plupload.clearParams = function() {
const obj = phpbb.plupload.uploader.settings.multipart_params; var obj = phpbb.plupload.uploader.settings.multipart_params;
for (const key in obj) { for (var 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;
} }
@ -69,7 +70,7 @@ phpbb.plupload.ids = [];
* @param {object} obj * @param {object} obj
*/ */
phpbb.plupload.updateMultipartParams = function(obj) { phpbb.plupload.updateMultipartParams = function(obj) {
const { settings } = phpbb.plupload.uploader; var { settings } = phpbb.plupload.uploader;
settings.multipart_params = $.extend(settings.multipart_params, obj); settings.multipart_params = $.extend(settings.multipart_params, obj);
}; };
@ -80,10 +81,10 @@ phpbb.plupload.ids = [];
* expected by the server * expected by the server
*/ */
phpbb.plupload.getSerializedData = function() { phpbb.plupload.getSerializedData = function() {
const obj = {}; var obj = {};
for (let i = 0; i < phpbb.plupload.data.length; i++) { for (var i = 0; i < phpbb.plupload.data.length; i++) {
const datum = phpbb.plupload.data[i]; var datum = phpbb.plupload.data[i];
for (const key in datum) { for (var key in datum) {
if (!Object.prototype.hasOwnProperty.call(datum, key)) { if (!Object.prototype.hasOwnProperty.call(datum, key)) {
continue; continue;
} }
@ -93,7 +94,7 @@ phpbb.plupload.ids = [];
} }
// Insert form data // Insert form data
const $pluploadForm = $(phpbb.plupload.config.form_hook).first(); var $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();
@ -108,7 +109,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) {
const index = $.inArray(Number(attachId), phpbb.plupload.ids); var index = $.inArray(Number(attachId), phpbb.plupload.ids);
return index === -1 ? false : index; return index === -1 ? false : index;
}; };
@ -124,7 +125,7 @@ phpbb.plupload.ids = [];
phpbb.plupload.data = []; phpbb.plupload.data = [];
phpbb.plupload.data = data; phpbb.plupload.data = data;
for (let i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
phpbb.plupload.ids.push(Number(data[i].attach_id)); phpbb.plupload.ids.push(Number(data[i].attach_id));
} }
}; };
@ -151,7 +152,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 (let i = 0; i < phpbb.plupload.ids.length; i++) { for (var i = 0; i < phpbb.plupload.ids.length; i++) {
phpbb.plupload.updateRow(i, downloadUrl); phpbb.plupload.updateRow(i, downloadUrl);
} }
}; };
@ -165,7 +166,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) {
const row = $(phpbb.plupload.rowTpl); var 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));
@ -185,13 +186,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) {
const attach = phpbb.plupload.data[index]; var attach = phpbb.plupload.data[index];
const row = $('[data-attach-id="' + attach.attach_id + '"]'); var 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') {
const url = downloadUrl[index].replace('&amp;', '&'); var url = downloadUrl[index].replace('&amp;', '&');
const link = $('<a></a>'); var 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);
@ -211,12 +212,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 (const key in attach) { for (var key in attach) {
if (!Object.prototype.hasOwnProperty.call(attach, key)) { if (!Object.prototype.hasOwnProperty.call(attach, key)) {
continue; continue;
} }
const input = $('<input />') var 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]);
@ -236,7 +237,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') {
const file = phpbb.plupload.uploader.getFile(row.attr('id')); var file = phpbb.plupload.uploader.getFile(row.attr('id'));
phpbb.plupload.uploader.removeFile(file); phpbb.plupload.uploader.removeFile(file);
row.slideUp(100, () => { row.slideUp(100, () => {
@ -245,21 +246,21 @@ phpbb.plupload.ids = [];
}); });
} }
const index = phpbb.plupload.getIndex(attachId); var 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;
} }
const fields = {}; var fields = {};
fields['delete_file[' + index + ']'] = 1; fields['delete_file[' + index + ']'] = 1;
const always = function() { var always = function() {
row.find('.file-status').removeClass('file-working'); row.find('.file-status').removeClass('file-working');
}; };
const done = function(response) { var done = function(response) {
if (typeof response !== 'object') { if (typeof response !== 'object') {
return; return;
} }
@ -288,7 +289,7 @@ phpbb.plupload.ids = [];
phpbb.plupload.handleMaxFilesReached(); phpbb.plupload.handleMaxFilesReached();
if (row.attr('id')) { if (row.attr('id')) {
const file = phpbb.plupload.uploader.getFile(row.attr('id')); var file = phpbb.plupload.uploader.getFile(row.attr('id'));
phpbb.plupload.uploader.removeFile(file); phpbb.plupload.uploader.removeFile(file);
} }
@ -329,8 +330,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);
let text = textarea.val(); var text = textarea.val();
const removal = (action === 'removal'); var 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) {
@ -338,21 +339,21 @@ phpbb.plupload.ids = [];
} }
function runUpdate(i) { function runUpdate(i) {
const regex = new RegExp('\\[attachment=' + i + '\\](.*?)\\[\\/attachment\\]', 'g'); var 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 '';
} }
const newIndex = i + ((removal) ? -1 : 1); var 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.
let i; var 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);
@ -375,7 +376,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) {
const files = []; var files = [];
$.each(phpbb.plupload.uploader.files, (i, file) => { $.each(phpbb.plupload.uploader.files, (i, file) => {
if (file.status === status) { if (file.status === status) {
@ -438,7 +439,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) {
const files = phpbb.plupload.getFilesByStatus(plupload.QUEUED); var 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();
@ -511,14 +512,14 @@ phpbb.plupload.ids = [];
} }
}); });
const $fileList = $('#file-list'); var $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) {
const attachId = $(this).parents('.attach-row').attr('data-attach-id'); var attachId = $(this).parents('.attach-row').attr('data-attach-id');
const index = phpbb.plupload.getIndex(attachId); var 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();
@ -528,8 +529,8 @@ phpbb.plupload.ids = [];
* Delete a file. * Delete a file.
*/ */
$fileList.on('click', '.file-delete', function(e) { $fileList.on('click', '.file-delete', function(e) {
const row = $(this).parents('.attach-row'); var row = $(this).parents('.attach-row');
const attachId = row.attr('data-attach-id'); var attachId = row.attr('data-attach-id');
phpbb.plupload.deleteFile(row, attachId); phpbb.plupload.deleteFile(row, attachId);
e.preventDefault(); e.preventDefault();
@ -590,7 +591,7 @@ phpbb.plupload.ids = [];
return; return;
} }
let json = {}; var json = {};
try { try {
json = $.parseJSON(response.response); json = $.parseJSON(response.response);
} catch { } catch {
@ -637,7 +638,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.
const $fileListContainer = $('#file-list-container'); var $fileListContainer = $('#file-list-container');
if (!$fileListContainer.is(':visible')) { if (!$fileListContainer.is(':visible')) {
$fileListContainer.show(100); $fileListContainer.show(100);
} }
@ -670,9 +671,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) => {
let json = {}; var json = {};
const row = $('#' + file.id); var row = $('#' + file.id);
let error; var error;
// Hide the progress indicator. // Hide the progress indicator.
row.find('.file-progress').hide(); row.find('.file-progress').hide();

View file

@ -1,21 +1,22 @@
/* 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) {
const readTitle = res.NO_UNREAD_POSTS; var readTitle = res.NO_UNREAD_POSTS;
const unreadTitle = res.UNREAD_POSTS; var unreadTitle = res.UNREAD_POSTS;
const iconsArray = { var iconsArray = {
forum_unread: 'forum_read', forum_unread: 'forum_read',
forum_unread_subforum: 'forum_read_subforum', forum_unread_subforum: 'forum_read_subforum',
forum_unread_locked: 'forum_read_locked', forum_unread_locked: 'forum_read_locked',
}; };
$('li.row').find('dl[class*="forum_unread"]').each(function() { $('li.row').find('dl[class*="forum_unread"]').each(function() {
const $this = $(this); var $this = $(this);
$.each(iconsArray, (unreadClass, readClass) => { $.each(iconsArray, (unreadClass, readClass) => {
if ($this.hasClass(unreadClass)) { if ($this.hasClass(unreadClass)) {
@ -46,17 +47,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) => {
const readTitle = res.NO_UNREAD_POSTS; var readTitle = res.NO_UNREAD_POSTS;
const unreadTitle = res.UNREAD_POSTS; var unreadTitle = res.UNREAD_POSTS;
const iconsArray = { var 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',
}; };
const iconsState = [ '', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine' ]; var iconsState = [ '', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine' ];
const classMap = {}; var classMap = {};
const classNames = []; var classNames = [];
if (typeof updateTopicLinks === 'undefined') { if (typeof updateTopicLinks === 'undefined') {
updateTopicLinks = true; updateTopicLinks = true;
@ -74,10 +75,10 @@
}); });
}); });
const unreadClassSelectors = '.' + classNames.join(',.'); var unreadClassSelectors = '.' + classNames.join(',.');
$('li.row').find(unreadClassSelectors).each(function() { $('li.row').find(unreadClassSelectors).each(function() {
const $this = $(this); var $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);
@ -109,7 +110,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') {
const unreadCount = Number($('#notification-button strong').html()) - 1; var 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);
} }
}); });
@ -127,7 +128,7 @@
// Update the notification link to the real URL. // Update the notification link to the real URL.
$popup.each(function() { $popup.each(function() {
const link = $(this).find('a'); var link = $(this).find('a');
link.attr('href', link.attr('data-real-url')); link.attr('href', link.attr('data-real-url'));
}); });
@ -140,21 +141,21 @@
} }
// Update page title // Update page title
const $title = $('title'); var $title = $('title');
const originalTitle = $title.text().replace(/(\((\d+)\))/, ''); var 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() {
const $this = $(this); var $this = $(this);
let postId; var 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];
const post = $this.parents('#p' + postId).css('pointer-events', 'none'); var post = $this.parents('#p' + postId).css('pointer-events', 'none');
if (post.hasClass('bg1') || post.hasClass('bg2')) { if (post.hasClass('bg1') || post.hasClass('bg2')) {
const posts1 = post.nextAll('.bg1'); var 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');
} }
@ -167,7 +168,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) {
const remove = (res.visible) ? $(this) : $(this).parents('.post'); var 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();
}); });
@ -187,7 +188,7 @@
// This handles friend / foe additions removals. // This handles friend / foe additions removals.
phpbb.addAjaxCallback('zebra', res => { phpbb.addAjaxCallback('zebra', res => {
let zebra; var zebra;
if (res.success) { if (res.success) {
zebra = $('.zebra'); zebra = $('.zebra');
@ -201,13 +202,13 @@
*/ */
phpbb.addAjaxCallback('vote_poll', function(res) { phpbb.addAjaxCallback('vote_poll', function(res) {
if (typeof res.success !== 'undefined') { if (typeof res.success !== 'undefined') {
const poll = $(this).closest('.topic_poll'); var poll = $(this).closest('.topic_poll');
const panel = poll.find('.panel'); var panel = poll.find('.panel');
const resultsVisible = poll.find('dl:first-child .resultbar').is(':visible'); var resultsVisible = poll.find('dl:first-child .resultbar').is(':visible');
let mostVotes = 0; var mostVotes = 0;
// Set min-height to prevent the page from jumping when the content changes // Set min-height to prevent the page from jumping when the content changes
const updatePanelHeight = function(height) { var updatePanelHeight = function(height) {
height = (typeof height === 'undefined') ? panel.find('.inner').outerHeight() : height; height = (typeof height === 'undefined') ? panel.find('.inner').outerHeight() : height;
panel.css('min-height', height); panel.css('min-height', height);
}; };
@ -230,8 +231,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() {
const option = $(this); var option = $(this);
const optionId = option.attr('data-poll-option-id'); var 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;
}); });
@ -240,14 +241,14 @@
// Update each option // Update each option
poll.find('[data-poll-option-id]').each(function() { poll.find('[data-poll-option-id]').each(function() {
const $this = $(this); var $this = $(this);
const optionId = $this.attr('data-poll-option-id'); var optionId = $this.attr('data-poll-option-id');
const voted = (typeof res.user_votes[optionId] !== 'undefined'); var voted = (typeof res.user_votes[optionId] !== 'undefined');
const mostVoted = (res.vote_counts[optionId] === mostVotes); var mostVoted = (res.vote_counts[optionId] === mostVotes);
const percent = res.total_votes ? Math.round((res.vote_counts[optionId] / res.total_votes) * 100) : 0; var percent = res.total_votes ? Math.round((res.vote_counts[optionId] / res.total_votes) * 100) : 0;
const percentRel = (mostVotes === 0) ? 0 : Math.round((res.vote_counts[optionId] / mostVotes) * 100); var percentRel = (mostVotes === 0) ? 0 : Math.round((res.vote_counts[optionId] / mostVotes) * 100);
const altText = $this.attr('data-alt-text'); var altText = $this.attr('data-alt-text');
if (voted) { if (voted) {
$this.attr('title', $.trim(altText)); $this.attr('title', $.trim(altText));
} else { } else {
@ -258,9 +259,9 @@
$this.toggleClass('most-votes', mostVoted); $this.toggleClass('most-votes', mostVoted);
// Update the bars // Update the bars
const bar = $this.find('.resultbar div'); var bar = $this.find('.resultbar div');
const barTimeLapse = (res.can_vote) ? 500 : 1500; var barTimeLapse = (res.can_vote) ? 500 : 1500;
const newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1); var newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1);
setTimeout(() => { setTimeout(() => {
bar.animate({ width: percentRel + '%' }, 500) bar.animate({ width: percentRel + '%' }, 500)
@ -268,7 +269,7 @@
.addClass(newBarClass) .addClass(newBarClass)
.html(res.vote_counts[optionId]); .html(res.vote_counts[optionId]);
const percentText = percent ? percent + '%' : res.NO_VOTES; var percentText = percent ? percent + '%' : res.NO_VOTES;
$this.find('.poll_option_percent').html(percentText); $this.find('.poll_option_percent').html(percentText);
}, barTimeLapse); }, barTimeLapse);
}); });
@ -278,7 +279,7 @@
} }
// Display "Your vote has been cast." message. Disappears after 5 seconds. // Display "Your vote has been cast." message. Disappears after 5 seconds.
const confirmationDelay = (res.can_vote) ? 300 : 900; var 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();
@ -294,9 +295,9 @@
resizePanel(500); resizePanel(500);
}, 1500); }, 1500);
const resizePanel = function(time) { var resizePanel = function(time) {
const panelHeight = panel.height(); var panelHeight = panel.height();
const innerHeight = panel.find('.inner').outerHeight(); var innerHeight = panel.find('.inner').outerHeight();
if (panelHeight !== innerHeight) { if (panelHeight !== innerHeight) {
panel.css({ minHeight: '', height: panelHeight }) panel.css({ minHeight: '', height: panelHeight })
@ -315,19 +316,19 @@
// Do not follow the link // Do not follow the link
e.preventDefault(); e.preventDefault();
const $poll = $(this).parents('.topic_poll'); var $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() {
const $this = $(this); var $this = $(this);
const ajax = $this.attr('data-ajax'); var ajax = $this.attr('data-ajax');
let filter = $this.attr('data-filter'); var filter = $this.attr('data-filter');
if (ajax !== 'false') { if (ajax !== 'false') {
const fn = ajax === 'true' ? null : ajax; var fn = ajax === 'true' ? null : ajax;
filter = filter === undefined ? null : phpbb.getFunctionByName(filter); filter = filter === undefined ? null : phpbb.getFunctionByName(filter);
phpbb.ajaxify({ phpbb.ajaxify({
@ -354,7 +355,7 @@
// Do not follow the link // Do not follow the link
e.preventDefault(); e.preventDefault();
const postId = $(this).attr('data-post-id'); var 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();
@ -379,7 +380,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() {
const $memberlistSearch = $('#memberlist_search'); var $memberlistSearch = $('#memberlist_search');
$memberlistSearch.slideToggle('fast'); $memberlistSearch.slideToggle('fast');
phpbb.ajaxCallbacks.alt_text.call(this); phpbb.ajaxCallbacks.alt_text.call(this);
@ -418,7 +419,7 @@
* Automatically resize textarea * Automatically resize textarea
*/ */
$(() => { $(() => {
const $textarea = $('textarea:not(#message-box textarea, .no-auto-resize)'); var $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,6 +1,7 @@
/* 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
@ -36,10 +37,10 @@ function popup(url, width, height, name) {
function pageJump(item) { function pageJump(item) {
'use strict'; 'use strict';
const page = parseInt(item.val(), 10); var page = parseInt(item.val(), 10);
const perPage = item.attr('data-per-page'); var perPage = item.attr('data-per-page');
const baseUrl = item.attr('data-base-url'); var baseUrl = item.attr('data-base-url');
const startName = item.attr('data-start-name'); var 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) {
@ -58,7 +59,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() {
const $this = jQuery(this); var $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);
} }
@ -103,11 +104,11 @@ jQuery($ => {
'use strict'; 'use strict';
$('.sub-panels').each(function() { $('.sub-panels').each(function() {
const $childNodes = $('a[data-subpanel]', this); var $childNodes = $('a[data-subpanel]', this);
const panels = $childNodes.map(function() { var panels = $childNodes.map(function() {
return this.getAttribute('data-subpanel'); return this.getAttribute('data-subpanel');
}); });
const showPanel = this.getAttribute('data-show-panel'); var showPanel = this.getAttribute('data-show-panel');
if (panels.length) { if (panels.length) {
activateSubPanel(showPanel, panels); activateSubPanel(showPanel, panels);
@ -125,8 +126,8 @@ jQuery($ => {
function activateSubPanel(p, panels) { function activateSubPanel(p, panels) {
'use strict'; 'use strict';
let i; var i;
let showPanel; var showPanel;
if (typeof p === 'string') { if (typeof p === 'string') {
showPanel = p; showPanel = p;
@ -150,16 +151,16 @@ function selectCode(a) {
'use strict'; 'use strict';
// Get ID of code block // Get ID of code block
const e = a.parentNode.parentNode.getElementsByTagName('CODE')[0]; var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
let s; var s;
let r; var 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) {
const l = (e.innerText.length > 1) ? e.innerText.length - 1 : 1; var 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) {
@ -195,8 +196,8 @@ function selectCode(a) {
} }
} }
let inAutocomplete = false; var inAutocomplete = false;
let lastKeyEntered = ''; var lastKeyEntered = '';
/** /**
* Check event key * Check event key
@ -234,7 +235,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) {
const defaultButton = $(this).parents('form').find('input[type=submit].default-submit-action'); var defaultButton = $(this).parents('form').find('input[type=submit].default-submit-action');
if (!defaultButton || defaultButton.length <= 0) { if (!defaultButton || defaultButton.length <= 0) {
return true; return true;
@ -259,10 +260,10 @@ jQuery($ => {
function insertUser(formId, value) { function insertUser(formId, value) {
'use strict'; 'use strict';
const $form = jQuery(formId); var $form = jQuery(formId);
const formName = $form.attr('data-form-name'); var formName = $form.attr('data-form-name');
const fieldName = $form.attr('data-field-name'); var fieldName = $form.attr('data-field-name');
const item = opener.document.forms[formName][fieldName]; var 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;
@ -294,9 +295,9 @@ function insert_single_user(formId, user) {
function parseDocument($container) { function parseDocument($container) {
'use strict'; 'use strict';
const test = document.createElement('div'); var test = document.createElement('div');
const oldBrowser = (typeof test.style.borderRadius === 'undefined'); var oldBrowser = (typeof test.style.borderRadius === 'undefined');
const $body = $('body'); var $body = $('body');
/** /**
* Reset avatar dimensions when changing URL or EMAIL * Reset avatar dimensions when changing URL or EMAIL
@ -309,7 +310,7 @@ function parseDocument($container) {
* Pagination * Pagination
*/ */
$container.find('.pagination .page-jump-form :button').click(function() { $container.find('.pagination .page-jump-form :button').click(function() {
const $input = $(this).siblings('input.inputbox'); var $input = $(this).siblings('input.inputbox');
pageJump($input); pageJump($input);
}); });
@ -321,7 +322,7 @@ function parseDocument($container) {
}); });
$container.find('.pagination .dropdown-trigger').click(function() { $container.find('.pagination .dropdown-trigger').click(function() {
const $dropdownContainer = $(this).parent(); var $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')) {
@ -334,27 +335,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() {
const $this = $(this); var $this = $(this);
const $left = $this.children().not('.rightside'); var $left = $this.children().not('.rightside');
const $right = $this.children('.rightside'); var $right = $this.children('.rightside');
if ($left.length !== 1 || !$right.length) { if ($left.length !== 1 || !$right.length) {
return; return;
} }
function resize() { function resize() {
let width = 0; var width = 0;
const diff = $left.outerWidth(true) - $left.width(); var diff = $left.outerWidth(true) - $left.width();
const minWidth = Math.max($this.width() / 3, 240); var minWidth = Math.max($this.width() / 3, 240);
$right.each(function() { $right.each(function() {
const $this = $(this); var $this = $(this);
if ($this.is(':visible')) { if ($this.is(':visible')) {
width += $this.outerWidth(true); width += $this.outerWidth(true);
} }
}); });
const maxWidth = $this.width() - width - diff; var 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');
} }
@ -366,25 +367,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() {
const $this = $(this); var $this = $(this);
const $links = $this.find('.crumb'); var $links = $this.find('.crumb');
const { length } = $links; var { length } = $links;
const classes = [ 'wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny' ]; var classes = [ 'wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny' ];
const classesLength = classes.length; var classesLength = classes.length;
let maxHeight = 0; var maxHeight = 0;
let lastWidth = false; var lastWidth = false;
let wrapped = false; var wrapped = false;
// Set tooltips // Set tooltips
$this.find('a').each(function() { $this.find('a').each(function() {
const $link = $(this); var $link = $(this);
$link.attr('title', $link.text()); $link.attr('title', $link.text());
}); });
// Function that checks breadcrumbs // Function that checks breadcrumbs
function check() { function check() {
const height = $this.height(); var height = $this.height();
let width; var 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);
@ -420,8 +421,8 @@ function parseDocument($container) {
return; return;
} }
for (let i = 0; i < classesLength; i++) { for (var i = 0; i < classesLength; i++) {
for (let j = length - 1; j >= 0; j--) { for (var 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;
@ -455,9 +456,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() {
const $this = $(this); var $this = $(this);
let $block = $this.find('dt .responsive-show:last-child'); var $block = $this.find('dt .responsive-show:last-child');
let first = true; var 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) {
@ -469,9 +470,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() {
const column = $(this); var column = $(this);
const $children = column.children(); var $children = column.children();
let html = column.html(); var 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();
@ -491,9 +492,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() {
const $list = $(this); var $list = $(this);
const headers = []; var headers = [];
let headersLength = 0; var 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() {
@ -507,9 +508,9 @@ function parseDocument($container) {
// Parse each row // Parse each row
$list.find('dl').each(function() { $list.find('dl').each(function() {
const $this = $(this); var $this = $(this);
let $block = $this.find('dt .responsive-show:last-child'); var $block = $this.find('dt .responsive-show:last-child');
let first = true; var 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) {
@ -521,9 +522,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) {
const column = $(this); var column = $(this);
const children = column.children(); var children = column.children();
let html = column.html(); var 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();
@ -545,18 +546,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() {
const $this = $(this); var $this = $(this);
const $th = $this.find('thead > tr > th'); var $th = $this.find('thead > tr > th');
const headers = []; var headers = [];
let totalHeaders = 0; var totalHeaders = 0;
let i; var i;
// Find each header // Find each header
$th.each(function(column) { $th.each(function(column) {
const cell = $(this); var cell = $(this);
let colspan = parseInt(cell.attr('colspan'), 10); var colspan = parseInt(cell.attr('colspan'), 10);
const dfn = cell.attr('data-dfn'); var dfn = cell.attr('data-dfn');
const text = dfn ? dfn : cell.text(); var text = dfn ? dfn : cell.text();
colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan; colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan;
@ -571,7 +572,7 @@ function parseDocument($container) {
} }
}); });
const headersLength = headers.length; var 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');
@ -582,9 +583,9 @@ function parseDocument($container) {
} }
$this.find('tbody > tr').each(function() { $this.find('tbody > tr').each(function() {
const row = $(this); var row = $(this);
const cells = row.children('td'); var cells = row.children('td');
let column = 0; var column = 0;
if (cells.length === 1) { if (cells.length === 1) {
row.addClass('big-column'); row.addClass('big-column');
@ -592,9 +593,9 @@ function parseDocument($container) {
} }
cells.each(function() { cells.each(function() {
const cell = $(this); var cell = $(this);
let colspan = parseInt(cell.attr('colspan'), 10); var colspan = parseInt(cell.attr('colspan'), 10);
const text = $.trim(cell.text()); var text = $.trim(cell.text());
if (headersLength <= column) { if (headersLength <= column) {
return; return;
@ -618,7 +619,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() {
const $items = $(this).children('tr'); var $items = $(this).children('tr');
if (!$items.length) { if (!$items.length) {
$(this).parent('table:first').addClass('responsive-hide'); $(this).parent('table:first').addClass('responsive-hide');
} }
@ -628,24 +629,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() {
const $this = $(this); var $this = $(this);
const $ul = $this.children(); var $ul = $this.children();
const $tabs = $ul.children().not('[data-skip-responsive]'); var $tabs = $ul.children().not('[data-skip-responsive]');
const $links = $tabs.children('a'); var $links = $tabs.children('a');
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 $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 $menu = $item.find('.dropdown-contents'); var $menu = $item.find('.dropdown-contents');
let maxHeight = 0; var maxHeight = 0;
let lastWidth = false; var lastWidth = false;
let responsive = false; var responsive = false;
$links.each(function() { $links.each(function() {
const $this = $(this); var $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() {
const width = $body.width(); var width = $body.width();
let height = $this.height(); var height = $this.height();
if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) { if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) {
return; return;
@ -668,10 +669,10 @@ function parseDocument($container) {
$item.show(); $item.show();
$menu.html(''); $menu.html('');
const $availableTabs = $tabs.filter(':not(.activetab, .responsive-tab)'); var $availableTabs = $tabs.filter(':not(.activetab, .responsive-tab)');
const total = $availableTabs.length; var total = $availableTabs.length;
let i; var i;
let $tab; var $tab;
for (i = total - 1; i >= 0; i--) { for (i = total - 1; i >= 0; i--) {
$tab = $availableTabs.eq(i); $tab = $availableTabs.eq(i);
@ -690,7 +691,7 @@ function parseDocument($container) {
}); });
} }
const $tabLink = $item.find('a.responsive-tab-link'); var $tabLink = $item.find('a.responsive-tab-link');
phpbb.registerDropdown($tabLink, $item.find('.dropdown'), { phpbb.registerDropdown($tabLink, $item.find('.dropdown'), {
visibleClass: 'activetab', visibleClass: 'activetab',
}); });
@ -703,7 +704,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() {
const $items = $(this).children('ol, ul').children('li'); var $items = $(this).children('ol, ul').children('li');
if ($items.length === 1) { if ($items.length === 1) {
$(this).addClass('responsive-hide'); $(this).addClass('responsive-hide');
} }
@ -713,10 +714,10 @@ function parseDocument($container) {
* Replace responsive text * Replace responsive text
*/ */
$container.find('[data-responsive-text]').each(function() { $container.find('[data-responsive-text]').each(function() {
const $this = $(this); var $this = $(this);
const fullText = $this.text(); var fullText = $this.text();
const responsiveText = $this.attr('data-responsive-text'); var responsiveText = $this.attr('data-responsive-text');
let responsive = false; var responsive = false;
function check() { function check() {
if ($(window).width() > 700) { if ($(window).width() > 700) {