mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-28 12:58:52 +00:00
Compare commits
2 commits
2eea8b7c0b
...
01f9bdeb62
Author | SHA1 | Date | |
---|---|---|---|
|
01f9bdeb62 | ||
|
158a561651 |
10 changed files with 3490 additions and 3537 deletions
|
@ -1,5 +1,6 @@
|
|||
/* global phpbb */
|
||||
/* eslint no-var: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
/**
|
||||
* phpBB ACP functions
|
||||
|
@ -8,16 +9,19 @@
|
|||
/**
|
||||
* Parse document block
|
||||
*/
|
||||
function parseDocument(container) {
|
||||
var test = document.createElement('div');
|
||||
function parse_document(container)
|
||||
{
|
||||
var test = document.createElement('div'),
|
||||
oldBrowser = (typeof test.style.borderRadius === 'undefined');
|
||||
|
||||
test.remove();
|
||||
|
||||
/**
|
||||
* Navigation
|
||||
*/
|
||||
container.find('#menu').each(function() {
|
||||
var menu = $(this);
|
||||
var blocks = menu.children('.menu-block');
|
||||
var menu = $(this),
|
||||
blocks = menu.children('.menu-block');
|
||||
|
||||
if (!blocks.length) {
|
||||
return;
|
||||
|
@ -29,7 +33,6 @@ function parseDocument(container) {
|
|||
if (!parent.hasClass('active')) {
|
||||
parent.siblings().removeClass('active');
|
||||
}
|
||||
|
||||
parent.toggleClass('active');
|
||||
});
|
||||
|
||||
|
@ -46,11 +49,12 @@ function parseDocument(container) {
|
|||
* Responsive tables
|
||||
*/
|
||||
container.find('table').not('.not-responsive').each(function() {
|
||||
var $this = $(this);
|
||||
var th = $this.find('thead > tr > th');
|
||||
var headers = [];
|
||||
var totalHeaders = 0;
|
||||
var i;
|
||||
var $this = $(this),
|
||||
th = $this.find('thead > tr > th'),
|
||||
columns = th.length,
|
||||
headers = [],
|
||||
totalHeaders = 0,
|
||||
i, headersLength;
|
||||
|
||||
// Find columns
|
||||
$this.find('colgroup:first').children().each(function(i) {
|
||||
|
@ -69,23 +73,20 @@ function parseDocument(container) {
|
|||
}
|
||||
|
||||
// Find each header
|
||||
if (!$this.data('no-responsive-header')) {
|
||||
if (!$this.data('no-responsive-header'))
|
||||
{
|
||||
th.each(function(column) {
|
||||
var cell = $(this);
|
||||
var colspan = parseInt(cell.attr('colspan'), 10);
|
||||
var dfn = cell.attr('data-dfn');
|
||||
var text = dfn ? dfn : $.trim(cell.text());
|
||||
|
||||
if (text === ' ') {
|
||||
text = '';
|
||||
}
|
||||
var cell = $(this),
|
||||
colspan = parseInt(cell.attr('colspan')),
|
||||
dfn = cell.attr('data-dfn'),
|
||||
text = dfn ? dfn : $.trim(cell.text());
|
||||
|
||||
if (text === ' ') text = '';
|
||||
colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan;
|
||||
|
||||
for (i=0; i<colspan; i++) {
|
||||
headers.push(text);
|
||||
}
|
||||
|
||||
totalHeaders ++;
|
||||
|
||||
if (dfn && !column) {
|
||||
|
@ -105,9 +106,9 @@ function parseDocument(container) {
|
|||
}
|
||||
|
||||
$this.find('tbody > tr').each(function() {
|
||||
var row = $(this);
|
||||
var cells = row.children('td');
|
||||
var column = 0;
|
||||
var row = $(this),
|
||||
cells = row.children('td'),
|
||||
column = 0;
|
||||
|
||||
if (cells.length === 1) {
|
||||
row.addClass('big-column');
|
||||
|
@ -115,9 +116,9 @@ function parseDocument(container) {
|
|||
}
|
||||
|
||||
cells.each(function() {
|
||||
var cell = $(this);
|
||||
var colspan = parseInt(cell.attr('colspan'), 10);
|
||||
var text = $.trim(cell.text());
|
||||
var cell = $(this),
|
||||
colspan = parseInt(cell.attr('colspan')),
|
||||
text = $.trim(cell.text());
|
||||
|
||||
if (headersLength <= column) {
|
||||
return;
|
||||
|
@ -127,7 +128,8 @@ function parseDocument(container) {
|
|||
if (headers[column].length) {
|
||||
cell.prepend($('<dfn>').css('display', 'none').text(headers[column]));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
cell.addClass('empty');
|
||||
}
|
||||
|
||||
|
@ -145,7 +147,8 @@ function parseDocument(container) {
|
|||
*/
|
||||
container.find('table.responsive > tbody').each(function() {
|
||||
var items = $(this).children('tr');
|
||||
if (!items.length) {
|
||||
if (!items.length)
|
||||
{
|
||||
$(this).parent('table:first').addClass('responsive-hide');
|
||||
}
|
||||
});
|
||||
|
@ -179,16 +182,16 @@ function parseDocument(container) {
|
|||
* Responsive tabs
|
||||
*/
|
||||
container.find('#tabs').not('[data-skip-responsive]').each(function() {
|
||||
var $this = $(this);
|
||||
var $body = $('body');
|
||||
var ul = $this.children();
|
||||
var tabs = ul.children().not('[data-skip-responsive]');
|
||||
var links = tabs.children('a');
|
||||
var item = ul.append('<li class="tab responsive-tab" style="display:none;"><a href="javascript:void(0);" class="responsive-tab-link"> </a><div class="dropdown tab-dropdown" style="display: none;"><div class="pointer"><div class="pointer-inner"></div></div><ul class="dropdown-contents" /></div></li>').find('li.responsive-tab');
|
||||
var menu = item.find('.dropdown-contents');
|
||||
var maxHeight = 0;
|
||||
var lastWidth = false;
|
||||
var responsive = false;
|
||||
var $this = $(this),
|
||||
$body = $('body'),
|
||||
ul = $this.children(),
|
||||
tabs = ul.children().not('[data-skip-responsive]'),
|
||||
links = tabs.children('a'),
|
||||
item = ul.append('<li class="tab responsive-tab" style="display:none;"><a href="javascript:void(0);" class="responsive-tab-link"> </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'),
|
||||
menu = item.find('.dropdown-contents'),
|
||||
maxHeight = 0,
|
||||
lastWidth = false,
|
||||
responsive = false;
|
||||
|
||||
links.each(function() {
|
||||
var link = $(this);
|
||||
|
@ -196,8 +199,8 @@ function parseDocument(container) {
|
|||
});
|
||||
|
||||
function check() {
|
||||
var width = $body.width();
|
||||
var height = $this.height();
|
||||
var width = $body.width(),
|
||||
height = $this.height();
|
||||
|
||||
if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) {
|
||||
return;
|
||||
|
@ -213,7 +216,6 @@ function parseDocument(container) {
|
|||
if (item.hasClass('dropdown-visible')) {
|
||||
phpbb.toggleDropdown.call(item.find('a.responsive-tab-link').get(0));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -221,26 +223,20 @@ function parseDocument(container) {
|
|||
item.show();
|
||||
menu.html('');
|
||||
|
||||
var availableTabs = tabs.filter(':not(.activetab, .responsive-tab)');
|
||||
var total = availableTabs.length;
|
||||
var i;
|
||||
var tab;
|
||||
var availableTabs = tabs.filter(':not(.activetab, .responsive-tab)'),
|
||||
total = availableTabs.length,
|
||||
i, tab;
|
||||
|
||||
for (i = total - 1; i >= 0; i --) {
|
||||
tab = availableTabs.eq(i);
|
||||
menu.prepend(tab.clone(true).removeClass('tab'));
|
||||
tab.hide();
|
||||
if ($this.height() <= maxHeight) {
|
||||
menu.find('a').click(() => {
|
||||
check(true);
|
||||
});
|
||||
menu.find('a').click(function() { check(true); });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
menu.find('a').click(() => {
|
||||
check(true);
|
||||
});
|
||||
menu.find('a').click(function() { check(true); });
|
||||
}
|
||||
|
||||
phpbb.registerDropdown(item.find('a.responsive-tab-link'), item.find('.dropdown'), { visibleClass: 'activetab', verticalDirection: 'down' });
|
||||
|
@ -254,7 +250,7 @@ function parseDocument(container) {
|
|||
* Run onload functions
|
||||
*/
|
||||
(function($) {
|
||||
$(document).ready(() => {
|
||||
$(document).ready(function() {
|
||||
// Swap .nojs and .hasjs
|
||||
$('body.nojs').toggleClass('nojs hasjs');
|
||||
|
||||
|
@ -263,7 +259,7 @@ function parseDocument(container) {
|
|||
$('#' + this.getAttribute('data-focus')).focus();
|
||||
});
|
||||
|
||||
parseDocument($('body'));
|
||||
parse_document($('body'));
|
||||
|
||||
$('#questionnaire-form').css('display', 'none');
|
||||
var $triggerConfiglist = $('#trigger-configlist');
|
||||
|
|
|
@ -2,26 +2,29 @@
|
|||
/* eslint no-var: 0 */
|
||||
|
||||
(function($) { // Avoid conflicts with other libraries
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
phpbb.prepareSendStats = function() {
|
||||
var $form = $('#acp_help_phpbb');
|
||||
var $dark = $('#darkenwrapper');
|
||||
var $loadingIndicator;
|
||||
|
||||
$form.on('submit', function(event) {
|
||||
var $this = $(this);
|
||||
var currentTime = Math.floor(new Date().getTime() / 1000);
|
||||
var statsTime = parseInt($this.find('input[name=help_send_statistics_time]').val(), 10);
|
||||
var $this = $(this),
|
||||
currentTime = Math.floor(new Date().getTime() / 1000),
|
||||
statsTime = parseInt($this.find('input[name=help_send_statistics_time]').val(), 10);
|
||||
|
||||
event.preventDefault();
|
||||
$this.unbind('submit');
|
||||
|
||||
// Skip ajax request if form is submitted too early or send stats
|
||||
// checkbox is not checked
|
||||
if (!$this.find('input[name=help_send_statistics]').is(':checked') || statsTime > currentTime) {
|
||||
if (!$this.find('input[name=help_send_statistics]').is(':checked') ||
|
||||
statsTime > currentTime) {
|
||||
$form.find('input[type=submit]').click();
|
||||
setTimeout(() => {
|
||||
setTimeout(function() {
|
||||
$form.find('input[type=submit]').click();
|
||||
}, 300);
|
||||
return;
|
||||
|
@ -34,7 +37,6 @@
|
|||
if (typeof console !== 'undefined' && console.log) {
|
||||
console.log('AJAX error. status: ' + textStatus + ', message: ' + errorThrown);
|
||||
}
|
||||
|
||||
phpbb.clearLoadingTimeout();
|
||||
var errorText = '';
|
||||
|
||||
|
@ -46,7 +48,6 @@
|
|||
errorText = $dark.attr('data-ajax-error-text');
|
||||
}
|
||||
}
|
||||
|
||||
phpbb.alert($dark.attr('data-ajax-error-title'), errorText);
|
||||
}
|
||||
|
||||
|
@ -91,7 +92,7 @@
|
|||
success: returnHandler,
|
||||
error: errorHandler,
|
||||
cache: false,
|
||||
}).always(() => {
|
||||
}).always(function() {
|
||||
if ($loadingIndicator && $loadingIndicator.is(':visible')) {
|
||||
$loadingIndicator.fadeOut(phpbb.alertTime);
|
||||
}
|
||||
|
@ -110,8 +111,8 @@
|
|||
return;
|
||||
}
|
||||
|
||||
var $firstTr = $(this).parents('tr');
|
||||
var $secondTr = $firstTr.next();
|
||||
var $firstTr = $(this).parents('tr'),
|
||||
$secondTr = $firstTr.next();
|
||||
|
||||
$firstTr.insertAfter($secondTr);
|
||||
});
|
||||
|
@ -121,8 +122,8 @@
|
|||
return;
|
||||
}
|
||||
|
||||
var $secondTr = $(this).parents('tr');
|
||||
var $firstTr = $secondTr.prev();
|
||||
var $secondTr = $(this).parents('tr'),
|
||||
$firstTr = $secondTr.prev();
|
||||
|
||||
$secondTr.insertBefore($firstTr);
|
||||
});
|
||||
|
@ -133,15 +134,15 @@
|
|||
* in the href with "deactivate", and vice versa.
|
||||
*/
|
||||
phpbb.addAjaxCallback('activate_deactivate', function(res) {
|
||||
var $this = $(this);
|
||||
var newHref = $this.attr('href');
|
||||
var $this = $(this),
|
||||
newHref = $this.attr('href');
|
||||
|
||||
$this.text(res.text);
|
||||
|
||||
if (newHref.indexOf('deactivate') === -1) {
|
||||
newHref = newHref.replace('activate', 'deactivate');
|
||||
} else {
|
||||
if (newHref.indexOf('deactivate') !== -1) {
|
||||
newHref = newHref.replace('deactivate', 'activate');
|
||||
} else {
|
||||
newHref = newHref.replace('activate', 'deactivate');
|
||||
}
|
||||
|
||||
$this.attr('href', newHref);
|
||||
|
@ -161,6 +162,7 @@
|
|||
* This callback generates the VAPID keys for the web push notification service.
|
||||
*/
|
||||
phpbb.addAjaxCallback('generate_vapid_keys', () => {
|
||||
|
||||
/**
|
||||
* Generate VAPID keypair with public and private key string
|
||||
*
|
||||
|
@ -198,7 +200,6 @@
|
|||
if (!keyPair) {
|
||||
return;
|
||||
}
|
||||
|
||||
const publicKeyInput = document.querySelector('#webpush_vapid_public');
|
||||
const privateKeyInput = document.querySelector('#webpush_vapid_private');
|
||||
publicKeyInput.value = keyPair.publicKey;
|
||||
|
@ -211,25 +212,26 @@
|
|||
* This call will submit permissions forms in chunks of 5 fieldsets.
|
||||
*/
|
||||
function submitPermissions() {
|
||||
var $form = $('form#set-permissions');
|
||||
var fieldsetList = $form.find('fieldset[id^=perm]');
|
||||
var formDataSets = [];
|
||||
var dataSetIndex = 0;
|
||||
var $submitAllButton = $form.find('input[type=submit][name^=action]')[0];
|
||||
var $submitButton = $form.find('input[type=submit][data-clicked=true]')[0];
|
||||
var $form = $('form#set-permissions'),
|
||||
fieldsetList = $form.find('fieldset[id^=perm]'),
|
||||
formDataSets = [],
|
||||
dataSetIndex = 0,
|
||||
$submitAllButton = $form.find('input[type=submit][name^=action]')[0],
|
||||
$submitButton = $form.find('input[type=submit][data-clicked=true]')[0];
|
||||
|
||||
// Set proper start values for handling refresh of page
|
||||
var permissionSubmitSize = 0;
|
||||
var permissionRequestCount = 0;
|
||||
var forumIds = [];
|
||||
var permissionSubmitFailed = false;
|
||||
var clearIndicator = true;
|
||||
var permissionSubmitSize = 0,
|
||||
permissionRequestCount = 0,
|
||||
forumIds = [],
|
||||
permissionSubmitFailed = false,
|
||||
clearIndicator = true,
|
||||
$loadingIndicator;
|
||||
|
||||
if ($submitAllButton !== $submitButton) {
|
||||
fieldsetList = $form.find('fieldset#' + $submitButton.closest('fieldset.permissions').id);
|
||||
}
|
||||
|
||||
$.each(fieldsetList, (key, value) => {
|
||||
$.each(fieldsetList, function(key, value) {
|
||||
dataSetIndex = Math.floor(key / 5);
|
||||
var $fieldset = $('fieldset#' + value.id);
|
||||
if (key % 5 === 0) {
|
||||
|
@ -243,21 +245,21 @@
|
|||
if (roleInput.val()) {
|
||||
formDataSets[dataSetIndex] += '&' + roleInput.attr('name') + '=' + roleInput.val();
|
||||
} else {
|
||||
formDataSets[dataSetIndex] += '&' + roleInput.attr('name') + '='
|
||||
+ $fieldset.find('select[name="' + roleInput.attr('name') + '"]').val();
|
||||
formDataSets[dataSetIndex] += '&' + roleInput.attr('name') + '=' +
|
||||
$fieldset.find('select[name="' + roleInput.attr('name') + '"]').val();
|
||||
}
|
||||
});
|
||||
|
||||
permissionSubmitSize = formDataSets.length;
|
||||
|
||||
// Add each forum ID to forum ID list to preserve selected forums
|
||||
$.each($form.find('input[type=hidden][name^=forum_id]'), (key, value) => {
|
||||
$.each($form.find('input[type=hidden][name^=forum_id]'), function(key, value) {
|
||||
if (value.name.match(/^forum_id\[([0-9]+)\]$/)) {
|
||||
forumIds.push(value.value);
|
||||
}
|
||||
});
|
||||
|
||||
var $loadingIndicator = phpbb.loadingIndicator();
|
||||
$loadingIndicator = phpbb.loadingIndicator();
|
||||
|
||||
/**
|
||||
* Handler for submitted permissions form chunk
|
||||
|
@ -288,15 +290,15 @@
|
|||
method: 'post',
|
||||
});
|
||||
|
||||
$.each(forumIds, (key, value) => {
|
||||
$.each(forumIds, function(key, value) {
|
||||
$previousPageForm.append($('<input>').attr({
|
||||
type: 'text',
|
||||
name: 'forum_id[]',
|
||||
value,
|
||||
value: value,
|
||||
}));
|
||||
});
|
||||
|
||||
$alertBoxLink.on('click', e => {
|
||||
$alertBoxLink.on('click', function(e) {
|
||||
$('body').append($previousPageForm);
|
||||
e.preventDefault();
|
||||
$previousPageForm.submit();
|
||||
|
@ -308,7 +310,7 @@
|
|||
$alert.find('.alert_close').hide();
|
||||
|
||||
if (typeof res.REFRESH_DATA !== 'undefined') {
|
||||
setTimeout(() => {
|
||||
setTimeout(function() {
|
||||
// Create forum to submit using POST. This will prevent
|
||||
// exceeding the maximum length of URLs
|
||||
const $form = $('<form>').attr({
|
||||
|
@ -316,11 +318,11 @@
|
|||
method: 'post',
|
||||
});
|
||||
|
||||
$.each(forumIds, (key, value) => {
|
||||
$.each(forumIds, function(key, value) {
|
||||
$form.append($('<input>').attr({
|
||||
type: 'text',
|
||||
name: 'forum_id[]',
|
||||
value,
|
||||
value: value,
|
||||
}));
|
||||
});
|
||||
|
||||
|
@ -328,7 +330,7 @@
|
|||
|
||||
// Hide the alert even if we refresh the page, in case the user
|
||||
// presses the back button.
|
||||
$dark.fadeOut(phpbb.alertTime, () => {
|
||||
$dark.fadeOut(phpbb.alertTime, function() {
|
||||
if (typeof $alert !== 'undefined') {
|
||||
$alert.hide();
|
||||
}
|
||||
|
@ -354,15 +356,15 @@
|
|||
}
|
||||
|
||||
// Create AJAX request for each form data set
|
||||
$.each(formDataSets, (key, formData) => {
|
||||
$.each(formDataSets, function(key, formData) {
|
||||
$.ajax({
|
||||
url: $form.action,
|
||||
type: 'POST',
|
||||
data: formData + '&' + $submitButton.name + '=' + encodeURIComponent($submitButton.value)
|
||||
+ '&creation_time=' + $form.find('input[type=hidden][name=creation_time]')[0].value
|
||||
+ '&form_token=' + $form.find('input[type=hidden][name=form_token]')[0].value
|
||||
+ '&' + $form.children('input[type=hidden]').serialize()
|
||||
+ '&' + $form.find('input[type=checkbox][name^=inherit]').serialize(),
|
||||
data: formData + '&' + $submitButton.name + '=' + encodeURIComponent($submitButton.value) +
|
||||
'&creation_time=' + $form.find('input[type=hidden][name=creation_time]')[0].value +
|
||||
'&form_token=' + $form.find('input[type=hidden][name=form_token]')[0].value +
|
||||
'&' + $form.children('input[type=hidden]').serialize() +
|
||||
'&' + $form.find('input[type=checkbox][name^=inherit]').serialize(),
|
||||
success: handlePermissionReturn,
|
||||
error: handlePermissionReturn,
|
||||
});
|
||||
|
@ -370,11 +372,11 @@
|
|||
}
|
||||
|
||||
$('[data-ajax]').each(function() {
|
||||
var $this = $(this);
|
||||
var ajax = $this.attr('data-ajax');
|
||||
var $this = $(this),
|
||||
ajax = $this.attr('data-ajax');
|
||||
|
||||
if (ajax !== 'false') {
|
||||
var fn = (ajax === 'true') ? null : ajax;
|
||||
var fn = (ajax !== 'true') ? ajax : null;
|
||||
phpbb.ajaxify({
|
||||
selector: this,
|
||||
refresh: $this.attr('data-refresh') !== undefined,
|
||||
|
@ -386,12 +388,12 @@
|
|||
/**
|
||||
* Automatically resize textarea
|
||||
*/
|
||||
$(() => {
|
||||
$(function() {
|
||||
phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), { minHeight: 75 });
|
||||
|
||||
var $setPermissionsForm = $('form#set-permissions');
|
||||
if ($setPermissionsForm.length) {
|
||||
$setPermissionsForm.on('submit', e => {
|
||||
$setPermissionsForm.on('submit', function(e) {
|
||||
submitPermissions();
|
||||
e.preventDefault();
|
||||
});
|
||||
|
@ -418,4 +420,6 @@
|
|||
phpbb.prepareSendStats();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
})(jQuery); // Avoid conflicts with other libraries
|
||||
|
|
|
@ -13,11 +13,12 @@ function display_checkboxes(status) {
|
|||
var cb = document.getElementsByTagName('input');
|
||||
var display;
|
||||
|
||||
if (status) {
|
||||
//show
|
||||
if (status) {
|
||||
display = 'inline';
|
||||
} else {
|
||||
}
|
||||
//hide
|
||||
else {
|
||||
display = 'none';
|
||||
}
|
||||
|
||||
|
@ -89,13 +90,12 @@ function reset_opacity(status, except_id) {
|
|||
* rb = array of radiobuttons
|
||||
*/
|
||||
function get_radio_status(index, rb) {
|
||||
for (var i = index; i < rb.length; i += 3 ) {
|
||||
for (var i = index; i < rb.length; i = i + 3 ) {
|
||||
if (rb[i].checked !== true) {
|
||||
if (i > index) {
|
||||
//at least one is true, but not all (custom)
|
||||
return 2;
|
||||
}
|
||||
|
||||
//first one is not true
|
||||
return 0;
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ function init_colours(block_id) {
|
|||
}
|
||||
}
|
||||
|
||||
tab.className += ' activetab';
|
||||
tab.className = tab.className + ' activetab';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -174,7 +174,6 @@ function init_colours(block_id) {
|
|||
* adv = we are opening advanced permissions
|
||||
* view = called from view permissions
|
||||
*/
|
||||
// eslint-disable-next-line max-params
|
||||
function swap_options(pmask, fmask, cat, adv, view) {
|
||||
id = pmask + fmask + cat;
|
||||
active_option = active_pmask + active_fmask + active_cat;
|
||||
|
@ -207,8 +206,8 @@ function swap_options(pmask, fmask, cat, adv, view) {
|
|||
}
|
||||
|
||||
// set active tab
|
||||
old_tab.className = old_tab.className.replace(/ activetab/g, '');
|
||||
new_tab.className += ' activetab';
|
||||
old_tab.className = old_tab.className.replace(/\ activetab/g, '');
|
||||
new_tab.className = new_tab.className + ' activetab';
|
||||
|
||||
if (id === active_option && adv !== true) {
|
||||
return;
|
||||
|
@ -232,7 +231,6 @@ function swap_options(pmask, fmask, cat, adv, view) {
|
|||
if (!view) {
|
||||
phpbb.toggleDisplay('advanced' + pmask + fmask, 1);
|
||||
}
|
||||
|
||||
phpbb.toggleDisplay('options' + id, 1);
|
||||
|
||||
active_pmask = pmask;
|
||||
|
@ -293,10 +291,10 @@ function reset_role(id) {
|
|||
}
|
||||
|
||||
// Before resetting the role dropdown, try and match any permission role
|
||||
var parent = t.parentNode;
|
||||
var roleId = match_role_settings(id.replace('role', 'perm'));
|
||||
var text = no_role_assigned;
|
||||
var index = 0;
|
||||
var parent = t.parentNode,
|
||||
roleId = match_role_settings(id.replace('role', 'perm')),
|
||||
text = no_role_assigned,
|
||||
index = 0;
|
||||
|
||||
// If a role permissions was matched, grab that option's value and index
|
||||
if (roleId) {
|
||||
|
@ -332,11 +330,9 @@ function set_role_settings(role_id, target_id) {
|
|||
mark_options(target_id, 'u');
|
||||
|
||||
for (var r in settings) {
|
||||
if (Object.prototype.hasOwnProperty.call(settings, r)) {
|
||||
mark_one_option(target_id, r, (settings[r] === 1) ? 'y' : 'n');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Match the set permissions against the available roles.
|
||||
|
@ -345,9 +341,9 @@ function set_role_settings(role_id, target_id) {
|
|||
* @return {number} The permission role identifier
|
||||
*/
|
||||
function match_role_settings(id) {
|
||||
var fieldset = document.getElementById(id);
|
||||
var radios = fieldset.getElementsByTagName('input');
|
||||
var set = {};
|
||||
var fieldset = document.getElementById(id),
|
||||
radios = fieldset.getElementsByTagName('input'),
|
||||
set = {};
|
||||
|
||||
// Iterate over all the radio buttons
|
||||
for (var i = 0; i < radios.length; i++) {
|
||||
|
@ -363,7 +359,8 @@ function match_role_settings(id) {
|
|||
set = sort_and_stringify(set);
|
||||
|
||||
// Iterate over the available role options and return the first match
|
||||
for (var r in role_options) {
|
||||
for (var r in role_options)
|
||||
{
|
||||
if (sort_and_stringify(role_options[r]) === set) {
|
||||
return parseInt(r, 10);
|
||||
}
|
||||
|
@ -379,7 +376,7 @@ function match_role_settings(id) {
|
|||
* @return {string} The sorted object as a string
|
||||
*/
|
||||
function sort_and_stringify(obj) {
|
||||
return JSON.stringify(Object.keys(obj).sort().reduce((result, key) => {
|
||||
return JSON.stringify(Object.keys(obj).sort().reduce(function(result, key) {
|
||||
result[key] = obj[key];
|
||||
return result;
|
||||
}, {}));
|
||||
|
|
|
@ -14,6 +14,7 @@ phpBB Development Team:
|
|||
*/
|
||||
|
||||
(function($) { // Avoid conflicts with other libraries
|
||||
|
||||
'use strict';
|
||||
|
||||
var tooltips = [];
|
||||
|
@ -25,9 +26,9 @@ phpBB Development Team:
|
|||
* @param {string} [subId] Sub ID that should only be using tooltips (optional)
|
||||
*/
|
||||
phpbb.enableTooltipsSelect = function(id, headline, subId) {
|
||||
var $links;
|
||||
var $links, hold;
|
||||
|
||||
var hold = $('<span />', {
|
||||
hold = $('<span />', {
|
||||
id: '_tooltip_container',
|
||||
css: {
|
||||
position: 'absolute',
|
||||
|
@ -36,10 +37,10 @@ phpBB Development Team:
|
|||
|
||||
$('body').append(hold);
|
||||
|
||||
if (id) {
|
||||
$links = $('.roles-options li', '#' + id);
|
||||
} else {
|
||||
if (!id) {
|
||||
$links = $('.roles-options li');
|
||||
} else {
|
||||
$links = $('.roles-options li', '#' + id);
|
||||
}
|
||||
|
||||
$links.each(function() {
|
||||
|
@ -62,13 +63,15 @@ phpBB Development Team:
|
|||
* @param {string} headText Text heading to display
|
||||
*/
|
||||
phpbb.prepareTooltips = function($element, headText) {
|
||||
var text = $element.attr('data-title');
|
||||
var $tooltip, text, $desc, $title;
|
||||
|
||||
text = $element.attr('data-title');
|
||||
|
||||
if (text === null || text.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $title = $('<span />', {
|
||||
$title = $('<span />', {
|
||||
class: 'top',
|
||||
css: {
|
||||
display: 'block',
|
||||
|
@ -76,7 +79,7 @@ phpBB Development Team:
|
|||
})
|
||||
.append(document.createTextNode(headText));
|
||||
|
||||
var $desc = $('<span />', {
|
||||
$desc = $('<span />', {
|
||||
class: 'bottom',
|
||||
html: text,
|
||||
css: {
|
||||
|
@ -84,7 +87,7 @@ phpBB Development Team:
|
|||
},
|
||||
});
|
||||
|
||||
var $tooltip = $('<span />', {
|
||||
$tooltip = $('<span />', {
|
||||
class: 'tooltip',
|
||||
css: {
|
||||
display: 'block',
|
||||
|
@ -125,8 +128,10 @@ phpBB Development Team:
|
|||
* @param {jQuery} $element Tooltip element that should be positioned
|
||||
*/
|
||||
phpbb.positionTooltip = function($element) {
|
||||
var offset;
|
||||
|
||||
$element = $element.parent();
|
||||
var offset = $element.offset();
|
||||
offset = $element.offset();
|
||||
|
||||
if ($('body').hasClass('rtl')) {
|
||||
$('#_tooltip_container').css({
|
||||
|
@ -178,7 +183,7 @@ phpBB Development Team:
|
|||
}
|
||||
|
||||
// Prepare resetting drop down on form reset
|
||||
$this.closest('form').on('reset', () => {
|
||||
$this.closest('form').on('reset', function() {
|
||||
$span.text($span.attr('data-default'));
|
||||
$rolesOptions.children('input[type=hidden]')
|
||||
.val($span.attr('data-default-val'));
|
||||
|
@ -194,9 +199,7 @@ phpBB Development Team:
|
|||
var $rolesOptions = $this.closest('.roles-options');
|
||||
|
||||
// Update settings
|
||||
// eslint-disable-next-line no-undef
|
||||
set_role_settings($this.attr('data-id'), $this.attr('data-target-id'));
|
||||
// eslint-disable-next-line no-undef
|
||||
init_colours($this.attr('data-target-id').replace('advanced', ''));
|
||||
|
||||
// Set selected setting
|
||||
|
@ -212,11 +215,12 @@ phpBB Development Team:
|
|||
};
|
||||
|
||||
// Run onload functions for RolesDropdown and tooltips
|
||||
$(() => {
|
||||
$(function() {
|
||||
// Enable tooltips
|
||||
phpbb.enableTooltipsSelect('set-permissions', $('#set-permissions').attr('data-role-description'), 'role');
|
||||
|
||||
// Prepare dropdown
|
||||
phpbb.prepareRolesDropdown();
|
||||
});
|
||||
|
||||
})(jQuery); // Avoid conflicts with other libraries
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
/* global bbfontstyle */
|
||||
/* eslint no-var: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
var phpbb = {};
|
||||
phpbb.alertTime = 100;
|
||||
|
||||
(function($) { // Avoid conflicts with other libraries
|
||||
|
||||
'use strict';
|
||||
|
||||
// define a couple constants for keydown functions.
|
||||
|
@ -23,7 +25,7 @@ phpbb.alertTime = 100;
|
|||
phpbb.isTouch = (window && typeof window.ontouchstart !== 'undefined');
|
||||
|
||||
// Add ajax pre-filter to prevent cross-domain script execution
|
||||
$.ajaxPrefilter(s => {
|
||||
$.ajaxPrefilter(function(s) {
|
||||
if (s.crossDomain) {
|
||||
s.contents.script = false;
|
||||
}
|
||||
|
@ -43,7 +45,7 @@ phpbb.alertTime = 100;
|
|||
$loadingIndicator.fadeIn(phpbb.alertTime);
|
||||
// Wait 60 seconds and display an error if nothing has been returned by then.
|
||||
phpbb.clearLoadingTimeout();
|
||||
phpbbAlertTimer = setTimeout(() => {
|
||||
phpbbAlertTimer = setTimeout(function() {
|
||||
phpbb.showTimeoutMessage();
|
||||
}, 60000);
|
||||
}
|
||||
|
@ -72,13 +74,14 @@ phpbb.alertTime = 100;
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Close popup alert after a specified delay
|
||||
*
|
||||
* @param {int} delay Delay in ms until darkenwrapper's click event is triggered
|
||||
*/
|
||||
phpbb.closeDarkenWrapper = function(delay) {
|
||||
phpbbAlertTimer = setTimeout(() => {
|
||||
phpbbAlertTimer = setTimeout(function() {
|
||||
$('#darkenwrapper').trigger('click');
|
||||
}, delay);
|
||||
};
|
||||
|
@ -98,7 +101,7 @@ phpbb.alertTime = 100;
|
|||
$alert.find('.alert_title').html(title);
|
||||
$alert.find('.alert_text').html(msg);
|
||||
|
||||
$(document).on('keydown.phpbb.alert', e => {
|
||||
$(document).on('keydown.phpbb.alert', function(e) {
|
||||
if (e.keyCode === keymap.ENTER || e.keyCode === keymap.ESC) {
|
||||
phpbb.alert.close($alert, true);
|
||||
e.preventDefault();
|
||||
|
@ -121,7 +124,7 @@ phpbb.alertTime = 100;
|
|||
}
|
||||
|
||||
if ($loadingIndicator && $loadingIndicator.is(':visible')) {
|
||||
$loadingIndicator.fadeOut(phpbb.alertTime, () => {
|
||||
$loadingIndicator.fadeOut(phpbb.alertTime, function() {
|
||||
$dark.append($alert);
|
||||
$alert.fadeIn(phpbb.alertTime);
|
||||
});
|
||||
|
@ -134,17 +137,17 @@ phpbb.alertTime = 100;
|
|||
$dark.fadeIn(phpbb.alertTime);
|
||||
}
|
||||
|
||||
$alert.on('click', e => {
|
||||
$alert.on('click', function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
$dark.one('click', e => {
|
||||
$dark.one('click', function(e) {
|
||||
phpbb.alert.close($alert, true);
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
$alert.find('.alert_close').one('click', e => {
|
||||
$alert.find('.alert_close').one('click', function(e) {
|
||||
phpbb.alert.close($alert, true);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
@ -159,7 +162,7 @@ phpbb.alertTime = 100;
|
|||
phpbb.alert.close = function($alert, fadedark) {
|
||||
var $fade = (fadedark) ? $dark : $alert;
|
||||
|
||||
$fade.fadeOut(phpbb.alertTime, () => {
|
||||
$fade.fadeOut(phpbb.alertTime, function() {
|
||||
$alert.hide();
|
||||
});
|
||||
|
||||
|
@ -183,9 +186,9 @@ phpbb.alertTime = 100;
|
|||
phpbb.confirm = function(msg, callback, fadedark) {
|
||||
var $confirmDiv = $('#phpbb_confirm');
|
||||
$confirmDiv.find('.alert_text').html(msg);
|
||||
fadedark = typeof fadedark === 'undefined' ? true : fadedark;
|
||||
fadedark = typeof fadedark !== 'undefined' ? fadedark : true;
|
||||
|
||||
$(document).on('keydown.phpbb.alert', e => {
|
||||
$(document).on('keydown.phpbb.alert', function(e) {
|
||||
if (e.keyCode === keymap.ENTER || e.keyCode === keymap.ESC) {
|
||||
var name = (e.keyCode === keymap.ENTER) ? 'confirm' : 'cancel';
|
||||
|
||||
|
@ -218,19 +221,17 @@ phpbb.alertTime = 100;
|
|||
* @returns {object} The object created.
|
||||
*/
|
||||
phpbb.parseQuerystring = function(string) {
|
||||
var params = {};
|
||||
var i;
|
||||
var split;
|
||||
var params = {}, i, split;
|
||||
|
||||
string = string.split('&');
|
||||
for (i = 0; i < string.length; i++) {
|
||||
split = string[i].split('=');
|
||||
params[split[0]] = decodeURIComponent(split[1]);
|
||||
}
|
||||
|
||||
return params;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Makes a link use AJAX instead of loading an entire page.
|
||||
*
|
||||
|
@ -245,13 +246,13 @@ phpbb.alertTime = 100;
|
|||
* @param {object} options Options.
|
||||
*/
|
||||
phpbb.ajaxify = function(options) {
|
||||
var $elements = $(options.selector);
|
||||
var refresh = options.refresh;
|
||||
var callback = options.callback;
|
||||
var overlay = typeof options.overlay === 'undefined' ? true : options.overlay;
|
||||
var isForm = $elements.is('form');
|
||||
var isText = $elements.is('input[type="text"], textarea');
|
||||
var eventName;
|
||||
var $elements = $(options.selector),
|
||||
refresh = options.refresh,
|
||||
callback = options.callback,
|
||||
overlay = (typeof options.overlay !== 'undefined') ? options.overlay : true,
|
||||
isForm = $elements.is('form'),
|
||||
isText = $elements.is('input[type="text"], textarea'),
|
||||
eventName;
|
||||
|
||||
if (isForm) {
|
||||
eventName = 'submit';
|
||||
|
@ -262,12 +263,7 @@ phpbb.alertTime = 100;
|
|||
}
|
||||
|
||||
$elements.on(eventName, function(event) {
|
||||
var action;
|
||||
var method;
|
||||
var data;
|
||||
var submit;
|
||||
var that = this;
|
||||
var $this = $(this);
|
||||
var action, method, data, submit, that = this, $this = $(this);
|
||||
|
||||
if ($this.find('input[type="submit"][data-clicked]').attr('data-ajax') === 'false') {
|
||||
return;
|
||||
|
@ -280,15 +276,12 @@ phpbb.alertTime = 100;
|
|||
if (typeof console !== 'undefined' && console.log) {
|
||||
console.log('AJAX error. status: ' + textStatus + ', message: ' + errorThrown);
|
||||
}
|
||||
|
||||
phpbb.clearLoadingTimeout();
|
||||
var responseText;
|
||||
var errorText = false;
|
||||
var responseText, errorText = false;
|
||||
try {
|
||||
responseText = JSON.parse(jqXHR.responseText);
|
||||
responseText = responseText.message;
|
||||
} catch {}
|
||||
|
||||
} catch (e) {}
|
||||
if (typeof responseText === 'string' && responseText.length > 0) {
|
||||
errorText = responseText;
|
||||
} else if (typeof errorThrown === 'string' && errorThrown.length > 0) {
|
||||
|
@ -299,7 +292,6 @@ phpbb.alertTime = 100;
|
|||
errorText = $dark.attr('data-ajax-error-text');
|
||||
}
|
||||
}
|
||||
|
||||
phpbb.alert($dark.attr('data-ajax-error-title'), errorText);
|
||||
}
|
||||
|
||||
|
@ -322,14 +314,14 @@ phpbb.alertTime = 100;
|
|||
if (typeof res.S_CONFIRM_ACTION === 'undefined') {
|
||||
// If a confirmation is not required, display an alert and call the
|
||||
// callbacks.
|
||||
if (typeof res.MESSAGE_TITLE === 'undefined') {
|
||||
if (typeof res.MESSAGE_TITLE !== 'undefined') {
|
||||
alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
|
||||
} else {
|
||||
$dark.fadeOut(phpbb.alertTime);
|
||||
|
||||
if ($loadingIndicator) {
|
||||
$loadingIndicator.fadeOut(phpbb.alertTime);
|
||||
}
|
||||
} else {
|
||||
alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
|
||||
}
|
||||
|
||||
if (typeof phpbb.ajaxCallbacks[callback] === 'function') {
|
||||
|
@ -345,14 +337,14 @@ phpbb.alertTime = 100;
|
|||
refresh = false;
|
||||
}
|
||||
|
||||
phpbbAlertTimer = setTimeout(() => {
|
||||
phpbbAlertTimer = setTimeout(function() {
|
||||
if (refresh) {
|
||||
window.location = res.REFRESH_DATA.url;
|
||||
}
|
||||
|
||||
// Hide the alert even if we refresh the page, in case the user
|
||||
// presses the back button.
|
||||
$dark.fadeOut(phpbb.alertTime, () => {
|
||||
$dark.fadeOut(phpbb.alertTime, function() {
|
||||
if (typeof alert !== 'undefined') {
|
||||
alert.hide();
|
||||
}
|
||||
|
@ -361,7 +353,7 @@ phpbb.alertTime = 100;
|
|||
}
|
||||
} else {
|
||||
// If confirmation is required, display a dialog to the user.
|
||||
phpbb.confirm(res.MESSAGE_BODY, del => {
|
||||
phpbb.confirm(res.MESSAGE_BODY, function(del) {
|
||||
if (!del) {
|
||||
return;
|
||||
}
|
||||
|
@ -416,13 +408,13 @@ phpbb.alertTime = 100;
|
|||
var request = $.ajax({
|
||||
url: action,
|
||||
type: method,
|
||||
data,
|
||||
data: data,
|
||||
success: returnHandler,
|
||||
error: errorHandler,
|
||||
cache: false,
|
||||
});
|
||||
|
||||
request.always(() => {
|
||||
request.always(function() {
|
||||
if ($loadingIndicator && $loadingIndicator.is(':visible')) {
|
||||
$loadingIndicator.fadeOut(phpbb.alertTime);
|
||||
}
|
||||
|
@ -471,7 +463,6 @@ phpbb.alertTime = 100;
|
|||
if (this.data[id]) {
|
||||
return this.data[id];
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
|
@ -486,7 +477,6 @@ phpbb.alertTime = 100;
|
|||
if (!this.data[id]) {
|
||||
this.data[id] = { results: [] };
|
||||
}
|
||||
|
||||
this.data[id][key] = value;
|
||||
};
|
||||
|
||||
|
@ -526,7 +516,6 @@ phpbb.alertTime = 100;
|
|||
var line = phpbb.search.getKeywordLine($input);
|
||||
keyword = keyword.split('\n').splice(line, 1);
|
||||
}
|
||||
|
||||
return phpbb.search.cleanKeyword(keyword);
|
||||
};
|
||||
|
||||
|
@ -538,7 +527,7 @@ phpbb.alertTime = 100;
|
|||
* @returns {int} The line number.
|
||||
*/
|
||||
phpbb.search.getKeywordLine = function($textarea) {
|
||||
var { selectionStart } = $textarea.get(0);
|
||||
var selectionStart = $textarea.get(0).selectionStart;
|
||||
return $textarea.val().substr(0, selectionStart).split('\n').length - 1;
|
||||
};
|
||||
|
||||
|
@ -552,12 +541,11 @@ phpbb.alertTime = 100;
|
|||
*/
|
||||
phpbb.search.setValue = function($input, value, multiline) {
|
||||
if (multiline) {
|
||||
var line = phpbb.search.getKeywordLine($input);
|
||||
var lines = $input.val().split('\n');
|
||||
var line = phpbb.search.getKeywordLine($input),
|
||||
lines = $input.val().split('\n');
|
||||
lines[line] = value;
|
||||
value = lines.join('\n');
|
||||
}
|
||||
|
||||
$input.val(value);
|
||||
};
|
||||
|
||||
|
@ -571,7 +559,7 @@ phpbb.alertTime = 100;
|
|||
* @param {jQuery} $container jQuery object for the search container.
|
||||
*/
|
||||
phpbb.search.setValueOnClick = function($input, value, $row, $container) {
|
||||
$row.click(() => {
|
||||
$row.click(function() {
|
||||
phpbb.search.setValue($input, value.result, $input.attr('data-multiline'));
|
||||
phpbb.search.closeResults($input, $container);
|
||||
});
|
||||
|
@ -590,14 +578,14 @@ phpbb.alertTime = 100;
|
|||
* @returns {boolean} Returns false.
|
||||
*/
|
||||
phpbb.search.filter = function(data, event, sendRequest) {
|
||||
var $this = $(this);
|
||||
var dataName = $this.attr('data-name') === undefined ? $this.attr('name') : $this.attr('data-name');
|
||||
var minLength = parseInt($this.attr('data-min-length'), 10);
|
||||
var searchID = $this.attr('data-results');
|
||||
var keyword = phpbb.search.getKeyword($this, data[dataName], $this.attr('data-multiline'));
|
||||
var cache = phpbb.search.cache.get(searchID);
|
||||
var key = event.keyCode || event.which;
|
||||
var proceed = true;
|
||||
var $this = $(this),
|
||||
dataName = ($this.attr('data-name') !== undefined) ? $this.attr('data-name') : $this.attr('name'),
|
||||
minLength = parseInt($this.attr('data-min-length'), 10),
|
||||
searchID = $this.attr('data-results'),
|
||||
keyword = phpbb.search.getKeyword($this, data[dataName], $this.attr('data-multiline')),
|
||||
cache = phpbb.search.cache.get(searchID),
|
||||
key = event.keyCode || event.which,
|
||||
proceed = true;
|
||||
data[dataName] = keyword;
|
||||
|
||||
// No need to search if enter was pressed
|
||||
|
@ -622,7 +610,7 @@ phpbb.alertTime = 100;
|
|||
// Do we already have results for this?
|
||||
if (cache.results[keyword]) {
|
||||
var response = {
|
||||
keyword,
|
||||
keyword: keyword,
|
||||
results: cache.results[keyword],
|
||||
};
|
||||
phpbb.search.handleResponse(response, $this, true);
|
||||
|
@ -661,8 +649,8 @@ phpbb.alertTime = 100;
|
|||
return;
|
||||
}
|
||||
|
||||
var searchID = $input.attr('data-results');
|
||||
var $container = $(searchID);
|
||||
var searchID = $input.attr('data-results'),
|
||||
$container = $(searchID);
|
||||
|
||||
if (this.cache.get(searchID).callback) {
|
||||
callback = this.cache.get(searchID).callback;
|
||||
|
@ -695,16 +683,15 @@ phpbb.alertTime = 100;
|
|||
return;
|
||||
}
|
||||
|
||||
var searchID = $container.attr('id');
|
||||
var tpl;
|
||||
var row;
|
||||
var searchID = $container.attr('id'),
|
||||
tpl,
|
||||
row;
|
||||
|
||||
if (!this.tpl[searchID]) {
|
||||
tpl = $('.search-result-tpl', $container);
|
||||
this.tpl[searchID] = tpl.clone().removeClass('search-result-tpl');
|
||||
tpl.remove();
|
||||
}
|
||||
|
||||
tpl = this.tpl[searchID];
|
||||
|
||||
$.each(results, function(i, item) {
|
||||
|
@ -714,7 +701,6 @@ phpbb.alertTime = 100;
|
|||
if (typeof callback === 'function') {
|
||||
callback.call(this, $input, item, row, $container);
|
||||
}
|
||||
|
||||
row.appendTo($resultContainer).show();
|
||||
});
|
||||
$container.show();
|
||||
|
@ -754,13 +740,18 @@ phpbb.alertTime = 100;
|
|||
// so it can be unbound specifically later on.
|
||||
// Rebind it, to ensure the event is 'dynamic'.
|
||||
$input.off('.phpbb.search');
|
||||
$input.on('keydown.phpbb.search', event => {
|
||||
var key = event.keyCode || event.which;
|
||||
var $active = $resultContainer.children('.active');
|
||||
$input.on('keydown.phpbb.search', function(event) {
|
||||
var key = event.keyCode || event.which,
|
||||
$active = $resultContainer.children('.active');
|
||||
|
||||
if (key === keymap.ESC) {
|
||||
switch (key) {
|
||||
// Close the results
|
||||
case keymap.ESC:
|
||||
phpbb.search.closeResults($input, $container);
|
||||
} else if (key === keymap.ENTER) {
|
||||
break;
|
||||
|
||||
// Set the value for the selected result
|
||||
case keymap.ENTER:
|
||||
if ($active.length) {
|
||||
var value = $active.find('.search-result > span').text();
|
||||
|
||||
|
@ -771,9 +762,13 @@ phpbb.alertTime = 100;
|
|||
|
||||
// Do not submit the form
|
||||
event.preventDefault();
|
||||
} else if (key === keymap.ARROW_DOWN || key === keymap.ARROW_UP) {
|
||||
var up = key === keymap.ARROW_UP;
|
||||
var $children = $resultContainer.children();
|
||||
break;
|
||||
|
||||
// Navigate the results
|
||||
case keymap.ARROW_DOWN:
|
||||
case keymap.ARROW_UP:
|
||||
var up = key === keymap.ARROW_UP,
|
||||
$children = $resultContainer.children();
|
||||
|
||||
if (!$active.length) {
|
||||
if (up) {
|
||||
|
@ -801,6 +796,7 @@ phpbb.alertTime = 100;
|
|||
|
||||
// Do not change cursor position in the input element
|
||||
event.preventDefault();
|
||||
break;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -840,11 +836,9 @@ phpbb.alertTime = 100;
|
|||
if (!url || !phpbb.history.isSupported(fn)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!title) {
|
||||
title = document.title;
|
||||
}
|
||||
|
||||
if (!obj) {
|
||||
obj = null;
|
||||
}
|
||||
|
@ -939,6 +933,7 @@ phpbb.alertTime = 100;
|
|||
* @param {bool} forceSelector Shall we select the suggestion?
|
||||
*/
|
||||
phpbb.timezonePreselectSelect = function(forceSelector) {
|
||||
|
||||
// The offset returned here is in minutes and negated.
|
||||
var offset = (new Date()).getTimezoneOffset();
|
||||
var sign = '-';
|
||||
|
@ -1014,7 +1009,6 @@ phpbb.alertTime = 100;
|
|||
if (typeof callback === 'function') {
|
||||
phpbb.ajaxCallbacks[id] = callback;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
@ -1031,9 +1025,9 @@ phpbb.alertTime = 100;
|
|||
* current text so that the process can be repeated.
|
||||
*/
|
||||
phpbb.addAjaxCallback('alt_text', function() {
|
||||
var $anchor;
|
||||
var updateAll = $(this).data('update-all');
|
||||
var altText;
|
||||
var $anchor,
|
||||
updateAll = $(this).data('update-all'),
|
||||
altText;
|
||||
|
||||
if (updateAll !== undefined && updateAll.length) {
|
||||
$anchor = $(updateAll);
|
||||
|
@ -1064,6 +1058,7 @@ phpbb.alertTime = 100;
|
|||
var updateAll = $(this).data('update-all');
|
||||
var toggleText;
|
||||
var toggleUrl;
|
||||
var toggleIcon;
|
||||
|
||||
if (updateAll !== undefined && updateAll.length) {
|
||||
$anchor = $(updateAll);
|
||||
|
@ -1119,8 +1114,8 @@ phpbb.alertTime = 100;
|
|||
minHeight: 200,
|
||||
maxHeight: 500,
|
||||
heightDiff: 200,
|
||||
resizeCallback() {},
|
||||
resetCallback() {},
|
||||
resizeCallback: function() {},
|
||||
resetCallback: function() {},
|
||||
};
|
||||
|
||||
if (phpbb.isTouch) {
|
||||
|
@ -1160,10 +1155,10 @@ phpbb.alertTime = 100;
|
|||
var maxHeight = Math.min(
|
||||
Math.max(windowHeight - configuration.heightDiff, configuration.minHeight),
|
||||
configuration.maxHeight,
|
||||
);
|
||||
var $item = $(item);
|
||||
var height = parseInt($item.innerHeight(), 10);
|
||||
var scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0;
|
||||
),
|
||||
$item = $(item),
|
||||
height = parseInt($item.innerHeight(), 10),
|
||||
scrollHeight = (item.scrollHeight) ? item.scrollHeight : 0;
|
||||
|
||||
if (height < 0) {
|
||||
return;
|
||||
|
@ -1182,7 +1177,7 @@ phpbb.alertTime = 100;
|
|||
});
|
||||
}).change();
|
||||
|
||||
$(window).resize(() => {
|
||||
$(window).resize(function() {
|
||||
$items.each(function() {
|
||||
if ($(this).hasClass('auto-resized')) {
|
||||
autoResize(this);
|
||||
|
@ -1203,17 +1198,16 @@ phpbb.alertTime = 100;
|
|||
* @returns {boolean} True if cursor is in bbcode tag
|
||||
*/
|
||||
phpbb.inBBCodeTag = function(textarea, startTags, endTags) {
|
||||
var start = textarea.selectionStart;
|
||||
var lastEnd = -1;
|
||||
var lastStart = -1;
|
||||
var i;
|
||||
var index;
|
||||
var start = textarea.selectionStart,
|
||||
lastEnd = -1,
|
||||
lastStart = -1,
|
||||
i, index, value;
|
||||
|
||||
if (typeof start !== 'number') {
|
||||
return false;
|
||||
}
|
||||
|
||||
var value = textarea.value.toLowerCase();
|
||||
value = textarea.value.toLowerCase();
|
||||
|
||||
for (i = 0; i < startTags.length; i++) {
|
||||
var tagLength = startTags[i].length;
|
||||
|
@ -1222,7 +1216,6 @@ phpbb.alertTime = 100;
|
|||
lastStart = Math.max(lastStart, index);
|
||||
}
|
||||
}
|
||||
|
||||
if (lastStart === -1) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1237,6 +1230,7 @@ phpbb.alertTime = 100;
|
|||
return (lastEnd < lastStart);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Adjust textarea to manage code bbcode
|
||||
*
|
||||
|
@ -1251,9 +1245,9 @@ phpbb.alertTime = 100;
|
|||
*/
|
||||
phpbb.applyCodeEditor = function(textarea) {
|
||||
// list of allowed start and end bbcode code tags, in lower case
|
||||
var startTags = [ '[code]', '[code=' ];
|
||||
var startTagsEnd = ']';
|
||||
var endTags = [ '[/code]' ];
|
||||
var startTags = [ '[code]', '[code=' ],
|
||||
startTagsEnd = ']',
|
||||
endTags = [ '[/code]' ];
|
||||
|
||||
if (!textarea || typeof textarea.selectionStart !== 'number') {
|
||||
return;
|
||||
|
@ -1276,9 +1270,9 @@ phpbb.alertTime = 100;
|
|||
* @returns {string} Line of text
|
||||
*/
|
||||
function getLastLine(stripCodeStart) {
|
||||
var start = textarea.selectionStart;
|
||||
var value = textarea.value;
|
||||
var index = value.lastIndexOf('\n', start - 1);
|
||||
var start = textarea.selectionStart,
|
||||
value = textarea.value,
|
||||
index = value.lastIndexOf('\n', start - 1);
|
||||
|
||||
value = value.substring(index + 1, start);
|
||||
|
||||
|
@ -1292,7 +1286,6 @@ phpbb.alertTime = 100;
|
|||
if (startTags[i].lastIndexOf(startTagsEnd) !== tagLength) {
|
||||
index = value.indexOf(startTagsEnd);
|
||||
|
||||
// eslint-disable-next-line max-depth
|
||||
if (index >= 0) {
|
||||
value = value.substr(index + 1);
|
||||
}
|
||||
|
@ -1310,24 +1303,23 @@ phpbb.alertTime = 100;
|
|||
* @param {string} text Text to append
|
||||
*/
|
||||
function appendText(text) {
|
||||
var start = textarea.selectionStart;
|
||||
var end = textarea.selectionEnd;
|
||||
var value = textarea.value;
|
||||
var start = textarea.selectionStart,
|
||||
end = textarea.selectionEnd,
|
||||
value = textarea.value;
|
||||
|
||||
textarea.value = value.substr(0, start) + text + value.substr(end);
|
||||
textarea.selectionStart = start + text.length;
|
||||
textarea.selectionEnd = textarea.selectionStart;
|
||||
textarea.selectionStart = textarea.selectionEnd = start + text.length;
|
||||
}
|
||||
|
||||
$(textarea).data('code-editor', true).on('keydown', event => {
|
||||
$(textarea).data('code-editor', true).on('keydown', function(event) {
|
||||
var key = event.keyCode || event.which;
|
||||
|
||||
// intercept tabs
|
||||
if (key === keymap.TAB
|
||||
&& !event.ctrlKey
|
||||
&& !event.shiftKey
|
||||
&& !event.altKey
|
||||
&& !event.metaKey) {
|
||||
if (key === keymap.TAB &&
|
||||
!event.ctrlKey &&
|
||||
!event.shiftKey &&
|
||||
!event.altKey &&
|
||||
!event.metaKey) {
|
||||
if (inTag()) {
|
||||
appendText('\t');
|
||||
event.preventDefault();
|
||||
|
@ -1338,8 +1330,8 @@ phpbb.alertTime = 100;
|
|||
// intercept new line characters
|
||||
if (key === keymap.ENTER) {
|
||||
if (inTag()) {
|
||||
var lastLine = getLastLine(true);
|
||||
var code = String(/^\s*/g.exec(lastLine));
|
||||
var lastLine = getLastLine(true),
|
||||
code = '' + /^\s*/g.exec(lastLine);
|
||||
|
||||
if (code.length > 0) {
|
||||
appendText('\n' + code);
|
||||
|
@ -1363,14 +1355,14 @@ phpbb.alertTime = 100;
|
|||
return;
|
||||
}
|
||||
|
||||
$('body').on('dragenter dragover', () => {
|
||||
$('body').on('dragenter dragover', function() {
|
||||
$(textarea).addClass('drag-n-drop');
|
||||
}).on('dragleave dragout dragend drop', () => {
|
||||
}).on('dragleave dragout dragend drop', function() {
|
||||
$(textarea).removeClass('drag-n-drop');
|
||||
});
|
||||
$(textarea).on('dragenter dragover', () => {
|
||||
$(textarea).on('dragenter dragover', function() {
|
||||
$(textarea).addClass('drag-n-drop-highlight');
|
||||
}).on('dragleave dragout dragend drop', () => {
|
||||
}).on('dragleave dragout dragend drop', function() {
|
||||
$(textarea).removeClass('drag-n-drop-highlight');
|
||||
});
|
||||
};
|
||||
|
@ -1390,11 +1382,11 @@ phpbb.alertTime = 100;
|
|||
* This handler is used by phpBB.registerDropdown() and other functions
|
||||
*/
|
||||
phpbb.toggleDropdown = function(event_) {
|
||||
var $this = $(this);
|
||||
var options = $this.data('dropdown-options');
|
||||
var parent = options.parent;
|
||||
var visible = parent.hasClass('dropdown-visible');
|
||||
var direction;
|
||||
var $this = $(this),
|
||||
options = $this.data('dropdown-options'),
|
||||
parent = options.parent,
|
||||
visible = parent.hasClass('dropdown-visible'),
|
||||
direction;
|
||||
|
||||
if (!visible) {
|
||||
// Prevent link default action
|
||||
|
@ -1405,8 +1397,8 @@ phpbb.alertTime = 100;
|
|||
|
||||
// Figure out direction of dropdown
|
||||
direction = options.direction;
|
||||
var verticalDirection = options.verticalDirection;
|
||||
var offset = $this.offset();
|
||||
var verticalDirection = options.verticalDirection,
|
||||
offset = $this.offset();
|
||||
|
||||
if (direction === 'auto') {
|
||||
if (($(window).width() - $this.outerWidth(true)) / 2 > offset.left) {
|
||||
|
@ -1415,17 +1407,15 @@ phpbb.alertTime = 100;
|
|||
direction = 'left';
|
||||
}
|
||||
}
|
||||
|
||||
parent.toggleClass(options.leftClass, direction === 'left')
|
||||
.toggleClass(options.rightClass, direction === 'right');
|
||||
|
||||
if (verticalDirection === 'auto') {
|
||||
var height = $(window).height();
|
||||
var top = offset.top - $(window).scrollTop();
|
||||
var height = $(window).height(),
|
||||
top = offset.top - $(window).scrollTop();
|
||||
|
||||
verticalDirection = (top < height * 0.7) ? 'down' : 'up';
|
||||
}
|
||||
|
||||
parent.toggleClass(options.upClass, verticalDirection === 'up')
|
||||
.toggleClass(options.downClass, verticalDirection === 'down');
|
||||
}
|
||||
|
@ -1449,8 +1439,8 @@ phpbb.alertTime = 100;
|
|||
maxWidth: (windowWidth - 4) + 'px',
|
||||
});
|
||||
|
||||
var offset = $this.offset().left;
|
||||
var width = $this.outerWidth(true);
|
||||
var offset = $this.offset().left,
|
||||
width = $this.outerWidth(true);
|
||||
|
||||
if (offset < 2) {
|
||||
$this.css('left', (2 - offset) + 'px');
|
||||
|
@ -1460,6 +1450,7 @@ phpbb.alertTime = 100;
|
|||
|
||||
// Check whether the vertical scrollbar is present.
|
||||
$this.toggleClass('dropdown-nonscroll', this.scrollHeight === $this.innerHeight());
|
||||
|
||||
});
|
||||
var freeSpace = parent.offset().left - 4;
|
||||
|
||||
|
@ -1468,8 +1459,8 @@ phpbb.alertTime = 100;
|
|||
|
||||
// Try to position the notification dropdown correctly in RTL-responsive mode
|
||||
if (options.dropdown.hasClass('dropdown-extended')) {
|
||||
var contentWidth;
|
||||
var fullFreeSpace = freeSpace + parent.outerWidth();
|
||||
var contentWidth,
|
||||
fullFreeSpace = freeSpace + parent.outerWidth();
|
||||
|
||||
options.dropdown.find('.dropdown-contents').each(function() {
|
||||
contentWidth = parseInt($(this).outerWidth(), 10);
|
||||
|
@ -1490,13 +1481,11 @@ phpbb.alertTime = 100;
|
|||
// Prevent event propagation
|
||||
if (arguments.length > 0) {
|
||||
try {
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
var e = arguments[0];
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
} catch { }
|
||||
} catch (error) { }
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
|
@ -1530,7 +1519,6 @@ phpbb.alertTime = 100;
|
|||
if (options) {
|
||||
ops = $.extend(ops, options);
|
||||
}
|
||||
|
||||
ops.dropdown = dropdown;
|
||||
|
||||
ops.parent.addClass('dropdown-container');
|
||||
|
@ -1550,12 +1538,10 @@ phpbb.alertTime = 100;
|
|||
* @param {int} height Palette cell height.
|
||||
*/
|
||||
phpbb.colorPalette = function(dir, width, height) {
|
||||
var r;
|
||||
var g;
|
||||
var b;
|
||||
var numberList = new Array(6);
|
||||
var color = '';
|
||||
var html = '';
|
||||
var r, g, b,
|
||||
numberList = new Array(6),
|
||||
color = '',
|
||||
html = '';
|
||||
|
||||
numberList[0] = '00';
|
||||
numberList[1] = '40';
|
||||
|
@ -1577,10 +1563,10 @@ phpbb.alertTime = 100;
|
|||
}
|
||||
|
||||
for (b = 0; b < 5; b++) {
|
||||
color = String(numberList[r]) + numberList[g] + numberList[b];
|
||||
html += '<td style="background-color: #' + color + '; width: ' + width + 'px; height: '
|
||||
+ height + 'px;"><a href="#" data-color="' + color + '" style="display: block; width: '
|
||||
+ width + 'px; height: ' + height + 'px; " alt="#' + color + '" title="#' + color + '"></a>';
|
||||
color = '' + numberList[r] + numberList[g] + numberList[b];
|
||||
html += '<td style="background-color: #' + color + '; width: ' + width + 'px; height: ' +
|
||||
height + 'px;"><a href="#" data-color="' + color + '" style="display: block; width: ' +
|
||||
width + 'px; height: ' + height + 'px; " alt="#' + color + '" title="#' + color + '"></a>';
|
||||
html += '</td>';
|
||||
}
|
||||
|
||||
|
@ -1593,7 +1579,6 @@ phpbb.alertTime = 100;
|
|||
html += '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
html += '</table>';
|
||||
return html;
|
||||
};
|
||||
|
@ -1604,17 +1589,17 @@ phpbb.alertTime = 100;
|
|||
* @param {jQuery} el jQuery object for the palette container.
|
||||
*/
|
||||
phpbb.registerPalette = function(el) {
|
||||
const orientation = el.attr('data-color-palette') || el.attr('data-orientation'); // data-orientation kept for backwards compat.
|
||||
var height = el.attr('data-height');
|
||||
var width = el.attr('data-width');
|
||||
var target = el.attr('data-target');
|
||||
var bbcode = el.attr('data-bbcode');
|
||||
var orientation = el.attr('data-color-palette') || el.attr('data-orientation'), // data-orientation kept for backwards compat.
|
||||
height = el.attr('data-height'),
|
||||
width = el.attr('data-width'),
|
||||
target = el.attr('data-target'),
|
||||
bbcode = el.attr('data-bbcode');
|
||||
|
||||
// Insert the palette HTML into the container.
|
||||
el.html(phpbb.colorPalette(orientation, width, height));
|
||||
|
||||
// Add toggle control.
|
||||
$('#color_palette_toggle').click(e => {
|
||||
$('#color_palette_toggle').click(function(e) {
|
||||
el.toggle();
|
||||
e.preventDefault();
|
||||
});
|
||||
|
@ -1628,7 +1613,6 @@ phpbb.alertTime = 100;
|
|||
} else {
|
||||
$(target).val(color);
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
};
|
||||
|
@ -1653,7 +1637,6 @@ phpbb.alertTime = 100;
|
|||
if (!action) {
|
||||
action = (display === '' || display === type) ? -1 : 1;
|
||||
}
|
||||
|
||||
$element.css('display', ((action === 1) ? type : 'none'));
|
||||
};
|
||||
|
||||
|
@ -1665,8 +1648,8 @@ phpbb.alertTime = 100;
|
|||
*/
|
||||
phpbb.toggleSelectSettings = function(el) {
|
||||
el.children().each(function() {
|
||||
var $this = $(this);
|
||||
var $setting = $($this.data('toggle-setting'));
|
||||
var $this = $(this),
|
||||
$setting = $($this.data('toggle-setting'));
|
||||
$setting.toggle($this.is(':selected'));
|
||||
|
||||
// Disable any input elements that are not visible right now
|
||||
|
@ -1686,14 +1669,13 @@ phpbb.alertTime = 100;
|
|||
* @returns function
|
||||
*/
|
||||
phpbb.getFunctionByName = function(functionName) {
|
||||
var namespaces = functionName.split('.');
|
||||
var func = namespaces.pop();
|
||||
var context = window;
|
||||
var namespaces = functionName.split('.'),
|
||||
func = namespaces.pop(),
|
||||
context = window;
|
||||
|
||||
for (var i = 0; i < namespaces.length; i++) {
|
||||
context = context[namespaces[i]];
|
||||
}
|
||||
|
||||
return context[func];
|
||||
};
|
||||
|
||||
|
@ -1703,7 +1685,7 @@ phpbb.alertTime = 100;
|
|||
* @param {ArrayBuffer} rawKey Raw key array buffer as exported by SubtleCrypto exportKey()
|
||||
* @returns {string} Base64 encoded raw key string
|
||||
*/
|
||||
phpbb.rawKeyToBase64 = rawKey => {
|
||||
phpbb.rawKeyToBase64 = (rawKey) => {
|
||||
const keyBuffer = new Uint8Array(rawKey);
|
||||
let keyText = '';
|
||||
const keyLength = keyBuffer.byteLength;
|
||||
|
@ -1720,7 +1702,9 @@ phpbb.alertTime = 100;
|
|||
* @param {string} base64String Base64 encoded string
|
||||
* @returns {string} Base64URL encoded string
|
||||
*/
|
||||
phpbb.base64UrlEncode = base64String => base64String.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
||||
phpbb.base64UrlEncode = (base64String) => {
|
||||
return base64String.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
||||
};
|
||||
|
||||
/**
|
||||
* Register page dropdowns.
|
||||
|
@ -1729,14 +1713,14 @@ phpbb.alertTime = 100;
|
|||
var $body = $('body');
|
||||
|
||||
$body.find('.dropdown-container').each(function() {
|
||||
var $this = $(this);
|
||||
var $trigger = $this.find('.dropdown-trigger:first');
|
||||
var $contents = $this.find('.dropdown');
|
||||
var options = {
|
||||
var $this = $(this),
|
||||
$trigger = $this.find('.dropdown-trigger:first'),
|
||||
$contents = $this.find('.dropdown'),
|
||||
options = {
|
||||
direction: 'auto',
|
||||
verticalDirection: 'auto',
|
||||
};
|
||||
var data;
|
||||
},
|
||||
data;
|
||||
|
||||
if (!$trigger.length) {
|
||||
data = $this.attr('data-dropdown-trigger');
|
||||
|
@ -1755,15 +1739,12 @@ phpbb.alertTime = 100;
|
|||
if ($this.hasClass('dropdown-up')) {
|
||||
options.verticalDirection = 'up';
|
||||
}
|
||||
|
||||
if ($this.hasClass('dropdown-down')) {
|
||||
options.verticalDirection = 'down';
|
||||
}
|
||||
|
||||
if ($this.hasClass('dropdown-left')) {
|
||||
options.direction = 'left';
|
||||
}
|
||||
|
||||
if ($this.hasClass('dropdown-right')) {
|
||||
options.direction = 'right';
|
||||
}
|
||||
|
@ -1772,7 +1753,7 @@ phpbb.alertTime = 100;
|
|||
});
|
||||
|
||||
// Hide active dropdowns when click event happens outside
|
||||
$body.click(e => {
|
||||
$body.click(function(e) {
|
||||
var $parents = $(e.target).parents();
|
||||
if (!$parents.is(phpbb.dropdownVisibleContainers)) {
|
||||
$(phpbb.dropdownHandles).each(phpbb.toggleDropdown);
|
||||
|
@ -1783,7 +1764,7 @@ phpbb.alertTime = 100;
|
|||
/**
|
||||
* Handle avatars to be lazy loaded.
|
||||
*/
|
||||
phpbb.lazyLoadAvatars = () => {
|
||||
phpbb.lazyLoadAvatars = function loadAvatars() {
|
||||
$('.avatar[data-src]').each(function() {
|
||||
var $avatar = $(this);
|
||||
|
||||
|
@ -1826,30 +1807,29 @@ phpbb.alertTime = 100;
|
|||
form: $('.g-recaptcha').parents('form'),
|
||||
v3: $('[data-recaptcha-v3]'),
|
||||
|
||||
load() {
|
||||
load: function() {
|
||||
phpbb.recaptcha.bindButton();
|
||||
phpbb.recaptcha.bindForm();
|
||||
},
|
||||
bindButton() {
|
||||
bindButton: function() {
|
||||
phpbb.recaptcha.form.find('input[type="submit"]').on('click', function() {
|
||||
// Listen to all the submit buttons for the form that has reCAPTCHA protection,
|
||||
// and store it so we can click the exact same button later on when we are ready.
|
||||
phpbb.recaptcha.button = this;
|
||||
});
|
||||
},
|
||||
bindForm() {
|
||||
phpbb.recaptcha.form.on('submit', e => {
|
||||
bindForm: function() {
|
||||
phpbb.recaptcha.form.on('submit', function(e) {
|
||||
// If ready is false, it means the user pressed a submit button.
|
||||
// And the form was not submitted by us, after the token was loaded.
|
||||
if (!phpbb.recaptcha.ready) {
|
||||
// If version 3 is used, we need to make a different execution,
|
||||
// including the action and the site key.
|
||||
if (phpbb.recaptcha.v3.length) {
|
||||
// eslint-disable-next-line no-undef
|
||||
grecaptcha.execute(
|
||||
phpbb.recaptcha.v3.data('recaptcha-v3'),
|
||||
{ action: phpbb.recaptcha.v3.val() },
|
||||
).then(token => {
|
||||
).then(function(token) {
|
||||
// Place the token inside the form
|
||||
phpbb.recaptcha.token.val(token);
|
||||
|
||||
|
@ -1858,7 +1838,6 @@ phpbb.alertTime = 100;
|
|||
});
|
||||
} else {
|
||||
// Regular version 2 execution
|
||||
// eslint-disable-next-line no-undef
|
||||
grecaptcha.execute();
|
||||
}
|
||||
|
||||
|
@ -1867,7 +1846,7 @@ phpbb.alertTime = 100;
|
|||
}
|
||||
});
|
||||
},
|
||||
submitForm() {
|
||||
submitForm: function() {
|
||||
// Now we are ready, so set it to true.
|
||||
// so the 'submit' event doesn't run multiple times.
|
||||
phpbb.recaptcha.ready = true;
|
||||
|
@ -1901,7 +1880,7 @@ phpbb.alertTime = 100;
|
|||
/**
|
||||
* Apply code editor to all textarea elements with data-bbcode attribute
|
||||
*/
|
||||
$(() => {
|
||||
$(function() {
|
||||
// reCAPTCHA v3 needs to be initialized
|
||||
if (phpbb.recaptcha.v3.length) {
|
||||
phpbb.recaptcha.load();
|
||||
|
@ -1925,10 +1904,11 @@ phpbb.alertTime = 100;
|
|||
$('select[data-togglable-settings]').each(function() {
|
||||
var $this = $(this);
|
||||
|
||||
$this.change(() => {
|
||||
$this.change(function() {
|
||||
phpbb.toggleSelectSettings($this);
|
||||
});
|
||||
phpbb.toggleSelectSettings($this);
|
||||
});
|
||||
});
|
||||
|
||||
})(jQuery); // Avoid conflicts with other libraries
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
/* 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 ]
|
||||
* Includes unixsafe colour palette selector by SHS`
|
||||
|
@ -55,11 +52,11 @@ function initInsertions() {
|
|||
* bbstyle
|
||||
*/
|
||||
function bbstyle(bbnumber) {
|
||||
if (bbnumber === -1) {
|
||||
if (bbnumber !== -1) {
|
||||
bbfontstyle(bbtags[bbnumber], bbtags[bbnumber+1]);
|
||||
} else {
|
||||
insert_text('[*]');
|
||||
document.forms[form_name].elements[text_name].focus();
|
||||
} else {
|
||||
bbfontstyle(bbtags[bbnumber], bbtags[bbnumber + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,8 +100,9 @@ function bbfontstyle(bbopen, bbclose) {
|
|||
if (!isNaN(textarea.selectionStart)) {
|
||||
textarea.selectionStart = new_pos;
|
||||
textarea.selectionEnd = new_pos;
|
||||
} else if (document.selection) {
|
||||
}
|
||||
// IE
|
||||
else if (document.selection) {
|
||||
var range = textarea.createTextRange();
|
||||
range.move('character', new_pos);
|
||||
range.select();
|
||||
|
@ -120,10 +118,10 @@ function bbfontstyle(bbopen, bbclose) {
|
|||
function insert_text(text, spaces, popup) {
|
||||
var textarea;
|
||||
|
||||
if (popup) {
|
||||
textarea = opener.document.forms[form_name].elements[text_name];
|
||||
} else {
|
||||
if (!popup) {
|
||||
textarea = document.forms[form_name].elements[text_name];
|
||||
} else {
|
||||
textarea = opener.document.forms[form_name].elements[text_name];
|
||||
}
|
||||
|
||||
if (spaces) {
|
||||
|
@ -148,7 +146,7 @@ function insert_text(text, spaces, popup) {
|
|||
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;
|
||||
} else {
|
||||
textarea.value += text;
|
||||
textarea.value = textarea.value + text;
|
||||
}
|
||||
|
||||
if (!popup) {
|
||||
|
@ -177,7 +175,6 @@ function addquote(post_id, username, l_wrote, attributes) {
|
|||
// Backwards compatibility
|
||||
l_wrote = 'wrote';
|
||||
}
|
||||
|
||||
if (typeof attributes !== 'object') {
|
||||
attributes = {};
|
||||
}
|
||||
|
@ -202,10 +199,10 @@ function addquote(post_id, username, l_wrote, attributes) {
|
|||
if (divarea.innerHTML) {
|
||||
theSelection = divarea.innerHTML.replace(/<br>/ig, '\n');
|
||||
theSelection = theSelection.replace(/<br\/>/ig, '\n');
|
||||
theSelection = theSelection.replace(/</ig, '<');
|
||||
theSelection = theSelection.replace(/>/ig, '>');
|
||||
theSelection = theSelection.replace(/&/ig, '&');
|
||||
theSelection = theSelection.replace(/ /ig, ' ');
|
||||
theSelection = theSelection.replace(/<\;/ig, '<');
|
||||
theSelection = theSelection.replace(/>\;/ig, '>');
|
||||
theSelection = theSelection.replace(/&\;/ig, '&');
|
||||
theSelection = theSelection.replace(/ \;/ig, ' ');
|
||||
} else if (document.all) {
|
||||
theSelection = divarea.innerText;
|
||||
} else if (divarea.textContent) {
|
||||
|
@ -220,7 +217,7 @@ function addquote(post_id, username, l_wrote, attributes) {
|
|||
attributes.author = username;
|
||||
insert_text(generateQuote(theSelection, attributes));
|
||||
} else {
|
||||
insert_text(username + ' ' + l_wrote + ':\n');
|
||||
insert_text(username + ' ' + l_wrote + ':' + '\n');
|
||||
var lines = split_lines(theSelection);
|
||||
for (i = 0; i < lines.length; i++) {
|
||||
insert_text('> ' + lines[i] + '\n');
|
||||
|
@ -250,14 +247,12 @@ function generateQuote(text, attributes) {
|
|||
quote += '=' + formatAttributeValue(attributes.author);
|
||||
delete attributes.author;
|
||||
}
|
||||
|
||||
for (var name in attributes) {
|
||||
if (Object.hasOwn(attributes, name)) {
|
||||
if (attributes.hasOwnProperty(name)) {
|
||||
var value = attributes[name];
|
||||
quote += ' ' + name + '=' + formatAttributeValue(value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
quote += ']';
|
||||
var newline = ((quote + text + '[/quote]').length > 80 || text.indexOf('\n') > -1) ? '\n' : '';
|
||||
quote += newline + text + newline + '[/quote]';
|
||||
|
@ -280,16 +275,15 @@ function formatAttributeValue(str) {
|
|||
// Return as-is if it contains none of: space, ' " \ or ]
|
||||
return str;
|
||||
}
|
||||
|
||||
var singleQuoted = '\'' + str.replace(/[\\']/g, '\\$&') + '\'';
|
||||
var doubleQuoted = '"' + str.replace(/[\\"]/g, '\\$&') + '"';
|
||||
var singleQuoted = '\'' + str.replace(/[\\']/g, '\\$&') + '\'',
|
||||
doubleQuoted = '"' + str.replace(/[\\"]/g, '\\$&') + '"';
|
||||
|
||||
return (singleQuoted.length < doubleQuoted.length) ? singleQuoted : doubleQuoted;
|
||||
}
|
||||
|
||||
function split_lines(text) {
|
||||
var lines = text.split('\n');
|
||||
var splitLines = [];
|
||||
var splitLines = new Array();
|
||||
var j = 0;
|
||||
var i;
|
||||
|
||||
|
@ -315,7 +309,6 @@ function split_lines(text) {
|
|||
while(splitAt !== -1);
|
||||
}
|
||||
}
|
||||
|
||||
return splitLines;
|
||||
}
|
||||
|
||||
|
@ -337,6 +330,8 @@ function mozWrap(txtarea, open, close) {
|
|||
txtarea.selectionEnd = selEnd + open.length;
|
||||
txtarea.focus();
|
||||
txtarea.scrollTop = scrollTop;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -367,8 +362,9 @@ function getCaretPosition(txtarea) {
|
|||
if (txtarea.selectionStart || txtarea.selectionStart === 0) {
|
||||
caretPos.start = txtarea.selectionStart;
|
||||
caretPos.end = txtarea.selectionEnd;
|
||||
} else if (document.selection) {
|
||||
}
|
||||
// dirty and slow IE way
|
||||
else if (document.selection) {
|
||||
// get current selection
|
||||
var range = document.selection.createRange();
|
||||
|
||||
|
|
|
@ -49,10 +49,7 @@
|
|||
var $warningContainer = $('#warning-container');
|
||||
var $logContainer = $('#log-container');
|
||||
|
||||
var $title;
|
||||
var $description;
|
||||
var $msgElement;
|
||||
var arraySize = messages.length;
|
||||
var $title, $description, $msgElement, arraySize = messages.length;
|
||||
for (var i = 0; i < arraySize; i++) {
|
||||
$msgElement = $('<div />');
|
||||
$title = $('<strong />');
|
||||
|
@ -65,19 +62,24 @@
|
|||
$msgElement.append($description);
|
||||
}
|
||||
|
||||
if (type === 'error') {
|
||||
switch (type) {
|
||||
case 'error':
|
||||
$msgElement.addClass('errorbox');
|
||||
$errorContainer.append($msgElement);
|
||||
} else if (type === 'warning') {
|
||||
break;
|
||||
case 'warning':
|
||||
$msgElement.addClass('warningbox');
|
||||
$warningContainer.append($msgElement);
|
||||
} else if (type === 'log') {
|
||||
break;
|
||||
case 'log':
|
||||
$msgElement.addClass('log');
|
||||
$logContainer.prepend($msgElement);
|
||||
$logContainer.addClass('show_log_container');
|
||||
} else if (type === 'success') {
|
||||
break;
|
||||
case 'success':
|
||||
$msgElement.addClass('successbox');
|
||||
$errorContainer.prepend($msgElement);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,12 +87,10 @@
|
|||
/**
|
||||
* Render a download box
|
||||
*/
|
||||
function addDownloadBox(downloadArray) {
|
||||
function addDownloadBox(downloadArray)
|
||||
{
|
||||
var $downloadContainer = $('#download-wrapper');
|
||||
var $downloadBox;
|
||||
var $title;
|
||||
var $content;
|
||||
var $link;
|
||||
var $downloadBox, $title, $content, $link;
|
||||
|
||||
for (var i = 0; i < downloadArray.length; i++) {
|
||||
$downloadBox = $('<div />');
|
||||
|
@ -119,7 +119,8 @@
|
|||
/**
|
||||
* Render update files' status
|
||||
*/
|
||||
function addUpdateFileStatus(fileStatus) {
|
||||
function addUpdateFileStatus(fileStatus)
|
||||
{
|
||||
var $statusContainer = $('#file-status-wrapper');
|
||||
$statusContainer.html(fileStatus);
|
||||
}
|
||||
|
@ -142,10 +143,8 @@
|
|||
* @param navObj
|
||||
*/
|
||||
function updateNavbarStatus(navObj) {
|
||||
var navID;
|
||||
var $stage;
|
||||
var $stageListItem;
|
||||
var $active = $('#activemenu');
|
||||
var navID, $stage, $stageListItem, $active;
|
||||
$active = $('#activemenu');
|
||||
|
||||
if (navObj.hasOwnProperty('finished')) {
|
||||
// This should be an Array
|
||||
|
@ -183,11 +182,7 @@
|
|||
* @param progressObject
|
||||
*/
|
||||
function setProgress(progressObject) {
|
||||
var $statusText;
|
||||
var $progressBar;
|
||||
var $progressText;
|
||||
var $progressFiller;
|
||||
var $progressFillerText;
|
||||
var $statusText, $progressBar, $progressText, $progressFiller, $progressFillerText;
|
||||
|
||||
if (progressObject.task_name.length) {
|
||||
if (!progressBarTriggered) {
|
||||
|
@ -254,8 +249,8 @@
|
|||
}
|
||||
|
||||
// Redirects user
|
||||
function redirect(url, useAjax) {
|
||||
if (useAjax) {
|
||||
function redirect(url, use_ajax) {
|
||||
if (use_ajax) {
|
||||
resetPolling();
|
||||
|
||||
var xhReq = createXhrObject();
|
||||
|
@ -284,7 +279,6 @@
|
|||
if (window.console) {
|
||||
console.log('Failed to parse JSON object\n\nMessage: ' + err.message + '\n\nServer Response: ' + messageJSON);
|
||||
} else {
|
||||
// eslint-disable-next-line no-alert
|
||||
alert('Failed to parse JSON object\n\nMessage: ' + err.message + '\n\nServer Response: ' + messageJSON);
|
||||
}
|
||||
|
||||
|
@ -367,14 +361,12 @@
|
|||
setTimeout(queryInstallerStatus, 5000);
|
||||
} else {
|
||||
$('#loading_indicator').css('display', 'none');
|
||||
addMessage('error', [
|
||||
{
|
||||
// eslint-disable-next-line no-undef
|
||||
addMessage('error',
|
||||
[ {
|
||||
title: installLang.title,
|
||||
// eslint-disable-next-line no-undef
|
||||
description: installLang.msg,
|
||||
},
|
||||
]);
|
||||
} ],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -396,7 +388,7 @@
|
|||
}
|
||||
|
||||
url = url.substring(0, position) + lookUp + '/installer/status';
|
||||
$.getJSON(url, data => {
|
||||
$.getJSON(url, function(data) {
|
||||
processTimeoutResponse(data.status);
|
||||
});
|
||||
}
|
||||
|
@ -409,10 +401,7 @@
|
|||
function pollContent(xhReq) {
|
||||
var messages = xhReq.responseText;
|
||||
var msgSeparator = '}\n\n';
|
||||
var unprocessed;
|
||||
var messageEndIndex;
|
||||
var endOfMessageIndex;
|
||||
var message;
|
||||
var unprocessed, messageEndIndex, endOfMessageIndex, message;
|
||||
|
||||
do {
|
||||
unprocessed = messages.substring(nextReadPosition);
|
||||
|
@ -480,7 +469,7 @@
|
|||
currentProgress = Math.floor(progressStart);
|
||||
|
||||
clearInterval(progressTimer);
|
||||
progressTimer = setInterval(() => {
|
||||
progressTimer = setInterval(function() {
|
||||
incrementFiller($progressText, $progressFiller, $progressFillerText, progressLimit);
|
||||
}, 10);
|
||||
}
|
||||
|
@ -501,7 +490,7 @@
|
|||
function startPolling(xhReq) {
|
||||
resetPolling();
|
||||
transmissionOver = false;
|
||||
pollTimer = setInterval(() => {
|
||||
pollTimer = setInterval(function() {
|
||||
pollContent(xhReq);
|
||||
}, 250);
|
||||
}
|
||||
|
@ -619,9 +608,7 @@
|
|||
function interceptFormSubmit($form) {
|
||||
if (!$form.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($form.find('input[name="admin_name"]').length > 0) {
|
||||
} else if ($form.find('input[name="admin_name"]').length > 0) {
|
||||
setAdminTimezone($form);
|
||||
}
|
||||
|
||||
|
@ -639,8 +626,7 @@
|
|||
function setAdminTimezone($form) {
|
||||
// Set admin timezone if it does not exist yet
|
||||
if ($form.find('input[name="admin_timezone"]').length === 0) {
|
||||
// eslint-disable-next-line new-cap
|
||||
const { timeZone } = Intl.DateTimeFormat().resolvedOptions();
|
||||
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
|
||||
// Add timezone as form entry
|
||||
const timezoneEntry = $('<input type="hidden" name="admin_timezone" value="' + timeZone + '">');
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
/* global phpbb, plupload, attachInline, activateSubPanel */
|
||||
/* global phpbb, plupload, attachInline */
|
||||
/* eslint camelcase: 0 */
|
||||
/* eslint no-var: 0 */
|
||||
/* eslint no-unused-vars: 0 */
|
||||
|
||||
plupload.addI18n(phpbb.plupload.i18n);
|
||||
phpbb.plupload.ids = [];
|
||||
|
||||
(function($) { // Avoid conflicts with other libraries
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
|
@ -20,7 +22,7 @@ phpbb.plupload.ids = [];
|
|||
phpbb.plupload.updateMultipartParams(phpbb.plupload.getSerializedData());
|
||||
|
||||
// Only execute if Plupload initialized successfully.
|
||||
phpbb.plupload.uploader.bind('Init', () => {
|
||||
phpbb.plupload.uploader.bind('Init', function() {
|
||||
phpbb.plupload.form = $(phpbb.plupload.config.form_hook)[0];
|
||||
const $attachRowTemplate = $('#attach-row-tpl');
|
||||
$attachRowTemplate.removeClass('attach-row-tpl');
|
||||
|
@ -32,7 +34,7 @@ phpbb.plupload.ids = [];
|
|||
$('#attach-panel-multi').show();
|
||||
});
|
||||
|
||||
phpbb.plupload.uploader.bind('PostInit', () => {
|
||||
phpbb.plupload.uploader.bind('PostInit', function() {
|
||||
// Point out the drag-and-drop zone if it's supported.
|
||||
if (phpbb.plupload.uploader.features.dragdrop) {
|
||||
$('#drag-n-drop-message').show();
|
||||
|
@ -42,8 +44,7 @@ phpbb.plupload.ids = [];
|
|||
if ($('#attach-panel-multi').is(':visible')) {
|
||||
phpbb.plupload.uploader.refresh();
|
||||
}
|
||||
|
||||
$('[data-subpanel="attach-panel"]').one('click', () => {
|
||||
$('[data-subpanel="attach-panel"]').one('click', function() {
|
||||
phpbb.plupload.uploader.refresh();
|
||||
});
|
||||
});
|
||||
|
@ -56,7 +57,7 @@ phpbb.plupload.ids = [];
|
|||
phpbb.plupload.clearParams = function() {
|
||||
var obj = phpbb.plupload.uploader.settings.multipart_params;
|
||||
for (var key in obj) {
|
||||
if (!Object.prototype.hasOwnProperty.call(obj, key) || key.indexOf('attachment_data[') !== 0) {
|
||||
if (!obj.hasOwnProperty(key) || key.indexOf('attachment_data[') !== 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -70,7 +71,7 @@ phpbb.plupload.ids = [];
|
|||
* @param {object} obj
|
||||
*/
|
||||
phpbb.plupload.updateMultipartParams = function(obj) {
|
||||
var { settings } = phpbb.plupload.uploader;
|
||||
var settings = phpbb.plupload.uploader.settings;
|
||||
settings.multipart_params = $.extend(settings.multipart_params, obj);
|
||||
};
|
||||
|
||||
|
@ -85,7 +86,7 @@ phpbb.plupload.ids = [];
|
|||
for (var i = 0; i < phpbb.plupload.data.length; i++) {
|
||||
var datum = phpbb.plupload.data[i];
|
||||
for (var key in datum) {
|
||||
if (!Object.prototype.hasOwnProperty.call(datum, key)) {
|
||||
if (!datum.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -110,7 +111,7 @@ phpbb.plupload.ids = [];
|
|||
*/
|
||||
phpbb.plupload.getIndex = function(attachId) {
|
||||
var index = $.inArray(Number(attachId), phpbb.plupload.ids);
|
||||
return index === -1 ? false : index;
|
||||
return (index !== -1) ? index : false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -121,8 +122,7 @@ phpbb.plupload.ids = [];
|
|||
*/
|
||||
phpbb.plupload.setData = function(data) {
|
||||
// Make sure that the array keys are reset.
|
||||
phpbb.plupload.ids = [];
|
||||
phpbb.plupload.data = [];
|
||||
phpbb.plupload.ids = phpbb.plupload.data = [];
|
||||
phpbb.plupload.data = data;
|
||||
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
|
@ -139,6 +139,7 @@ phpbb.plupload.ids = [];
|
|||
* @param {Array} downloadUrl Optional array of download urls to update.
|
||||
*/
|
||||
phpbb.plupload.update = function(data, action, index, downloadUrl) {
|
||||
|
||||
phpbb.plupload.updateBbcode(action, index);
|
||||
phpbb.plupload.setData(data);
|
||||
phpbb.plupload.updateRows(downloadUrl);
|
||||
|
@ -186,13 +187,13 @@ phpbb.plupload.ids = [];
|
|||
* @param {Array} downloadUrl Optional array of download urls to update.
|
||||
*/
|
||||
phpbb.plupload.updateRow = function(index, downloadUrl) {
|
||||
var attach = phpbb.plupload.data[index];
|
||||
var row = $('[data-attach-id="' + attach.attach_id + '"]');
|
||||
var attach = phpbb.plupload.data[index],
|
||||
row = $('[data-attach-id="' + attach.attach_id + '"]');
|
||||
|
||||
// Add the link to the file
|
||||
if (typeof downloadUrl !== 'undefined' && typeof downloadUrl[index] !== 'undefined') {
|
||||
var url = downloadUrl[index].replace('&', '&');
|
||||
var link = $('<a></a>');
|
||||
var url = downloadUrl[index].replace('&', '&'),
|
||||
link = $('<a></a>');
|
||||
|
||||
link.attr('href', url).html(attach.real_filename);
|
||||
row.find('.file-name').html(link);
|
||||
|
@ -213,8 +214,8 @@ phpbb.plupload.ids = [];
|
|||
row.find('input[type="hidden"]').remove();
|
||||
|
||||
for (var key in attach) {
|
||||
if (!Object.prototype.hasOwnProperty.call(attach, key)) {
|
||||
continue;
|
||||
if (!attach.hasOwnProperty(key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var input = $('<input />')
|
||||
|
@ -240,7 +241,7 @@ phpbb.plupload.ids = [];
|
|||
var file = phpbb.plupload.uploader.getFile(row.attr('id'));
|
||||
phpbb.plupload.uploader.removeFile(file);
|
||||
|
||||
row.slideUp(100, () => {
|
||||
row.slideUp(100, function() {
|
||||
row.remove();
|
||||
phpbb.plupload.hideEmptyList();
|
||||
});
|
||||
|
@ -252,7 +253,6 @@ phpbb.plupload.ids = [];
|
|||
if (index === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
var fields = {};
|
||||
fields['delete_file[' + index + ']'] = 1;
|
||||
|
||||
|
@ -292,8 +292,7 @@ phpbb.plupload.ids = [];
|
|||
var file = phpbb.plupload.uploader.getFile(row.attr('id'));
|
||||
phpbb.plupload.uploader.removeFile(file);
|
||||
}
|
||||
|
||||
row.slideUp(100, () => {
|
||||
row.slideUp(100, function() {
|
||||
row.remove();
|
||||
// Hide the file list if it's empty now.
|
||||
phpbb.plupload.hideEmptyList();
|
||||
|
@ -329,9 +328,9 @@ phpbb.plupload.ids = [];
|
|||
* @param {int} index The index of the attachment from phpbb.plupload.ids that was affected.
|
||||
*/
|
||||
phpbb.plupload.updateBbcode = function(action, index) {
|
||||
const textarea = $('#message', phpbb.plupload.form);
|
||||
var text = textarea.val();
|
||||
var removal = (action === 'removal');
|
||||
var textarea = $('#message', phpbb.plupload.form),
|
||||
text = textarea.val(),
|
||||
removal = (action === 'removal');
|
||||
|
||||
// Return if the bbcode isn't used at all.
|
||||
if (text.indexOf('[attachment=') === -1) {
|
||||
|
@ -340,12 +339,11 @@ phpbb.plupload.ids = [];
|
|||
|
||||
function runUpdate(i) {
|
||||
var regex = new RegExp('\\[attachment=' + i + '\\](.*?)\\[\\/attachment\\]', 'g');
|
||||
text = text.replace(regex, (_, fileName) => {
|
||||
text = text.replace(regex, function updateBbcode(_, fileName) {
|
||||
// Remove the bbcode if the file was removed.
|
||||
if (removal && index === i) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var newIndex = i + ((removal) ? -1 : 1);
|
||||
return '[attachment=' + newIndex + ']' + fileName + '[/attachment]';
|
||||
});
|
||||
|
@ -378,7 +376,7 @@ phpbb.plupload.ids = [];
|
|||
phpbb.plupload.getFilesByStatus = function(status) {
|
||||
var files = [];
|
||||
|
||||
$.each(phpbb.plupload.uploader.files, (i, file) => {
|
||||
$.each(phpbb.plupload.uploader.files, function(i, file) {
|
||||
if (file.status === status) {
|
||||
files.push(file);
|
||||
}
|
||||
|
@ -407,13 +405,10 @@ phpbb.plupload.ids = [];
|
|||
phpbb.plupload.uploader.trigger('Error', { message: phpbb.plupload.lang.TOO_MANY_ATTACHMENTS });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (phpbb.plupload.maxFiles > phpbb.plupload.ids.length) {
|
||||
} else if (phpbb.plupload.maxFiles > phpbb.plupload.ids.length) {
|
||||
// Enable the uploader if the user is under the limit
|
||||
phpbb.plupload.enableUploader();
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
|
@ -441,7 +436,7 @@ phpbb.plupload.ids = [];
|
|||
phpbb.plupload.markQueuedFailed = function(error) {
|
||||
var files = phpbb.plupload.getFilesByStatus(plupload.QUEUED);
|
||||
|
||||
$.each(files, (i, file) => {
|
||||
$.each(files, function(i, file) {
|
||||
$('#' + file.id).find('.file-progress').hide();
|
||||
phpbb.plupload.fileError(file, error);
|
||||
});
|
||||
|
@ -464,6 +459,7 @@ phpbb.plupload.ids = [];
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set up the Plupload object and get some basic data.
|
||||
*/
|
||||
|
@ -473,18 +469,14 @@ phpbb.plupload.ids = [];
|
|||
/**
|
||||
* Add a file filter to check for max file sizes per mime type.
|
||||
*/
|
||||
plupload.addFileFilter('mime_types_max_file_size', (types, file, callback) => {
|
||||
plupload.addFileFilter('mime_types_max_file_size', function(types, file, callback) {
|
||||
if (file.size !== 'undefined') {
|
||||
$(types).each((i, type) => {
|
||||
const extensions = [];
|
||||
const extsArray = type.extensions.split(',');
|
||||
$(types).each(function(i, type) {
|
||||
const extensions = [],
|
||||
extsArray = type.extensions.split(',');
|
||||
|
||||
$(extsArray).each((i, extension) => {
|
||||
if (/^\s*\*\s*$/.test(extension)) {
|
||||
extensions.push('\\.*');
|
||||
} else {
|
||||
extensions.push('\\.' + extension.replace(new RegExp('[' + '/^$.*+?|()[]{}\\'.replace(/./g, '\\$&') + ']', 'g'), '\\$&'));
|
||||
}
|
||||
$(extsArray).each(function(i, extension) {
|
||||
/^\s*\*\s*$/.test(extension) ? extensions.push('\\.*') : extensions.push('\\.' + extension.replace(new RegExp('[' + '/^$.*+?|()[]{}\\'.replace(/./g, '\\$&') + ']', 'g'), '\\$&'));
|
||||
});
|
||||
|
||||
const regex = new RegExp('(' + extensions.join('|') + ')$', 'i');
|
||||
|
@ -495,7 +487,7 @@ phpbb.plupload.ids = [];
|
|||
phpbb.plupload.uploader.trigger('Error', {
|
||||
code: plupload.FILE_SIZE_ERROR,
|
||||
message: plupload.translate('File size error.'),
|
||||
file,
|
||||
file: file,
|
||||
});
|
||||
|
||||
callback(false);
|
||||
|
@ -518,8 +510,8 @@ phpbb.plupload.ids = [];
|
|||
* Insert inline attachment bbcode.
|
||||
*/
|
||||
$fileList.on('click', '.file-inline-bbcode', function(e) {
|
||||
var attachId = $(this).parents('.attach-row').attr('data-attach-id');
|
||||
var index = phpbb.plupload.getIndex(attachId);
|
||||
var attachId = $(this).parents('.attach-row').attr('data-attach-id'),
|
||||
index = phpbb.plupload.getIndex(attachId);
|
||||
|
||||
attachInline(index, phpbb.plupload.data[index].real_filename);
|
||||
e.preventDefault();
|
||||
|
@ -529,8 +521,8 @@ phpbb.plupload.ids = [];
|
|||
* Delete a file.
|
||||
*/
|
||||
$fileList.on('click', '.file-delete', function(e) {
|
||||
var row = $(this).parents('.attach-row');
|
||||
var attachId = row.attr('data-attach-id');
|
||||
var row = $(this).parents('.attach-row'),
|
||||
attachId = row.attr('data-attach-id');
|
||||
|
||||
phpbb.plupload.deleteFile(row, attachId);
|
||||
e.preventDefault();
|
||||
|
@ -547,7 +539,7 @@ phpbb.plupload.ids = [];
|
|||
/**
|
||||
* Fires when an error occurs.
|
||||
*/
|
||||
phpbb.plupload.uploader.bind('Error', (up, error) => {
|
||||
phpbb.plupload.uploader.bind('Error', function(up, error) {
|
||||
error.file.name = plupload.xmlEncode(error.file.name);
|
||||
|
||||
// The error message that Plupload provides for these is vague, so we'll be more specific.
|
||||
|
@ -556,7 +548,6 @@ phpbb.plupload.ids = [];
|
|||
} else if (error.code === plupload.FILE_SIZE_ERROR) {
|
||||
error.message = plupload.translate('File too large:') + ' ' + error.file.name;
|
||||
}
|
||||
|
||||
phpbb.alert(phpbb.plupload.lang.ERROR, error.message);
|
||||
});
|
||||
|
||||
|
@ -568,7 +559,7 @@ phpbb.plupload.ids = [];
|
|||
* @param {object} up The plupload.Uploader object
|
||||
* @param {object} file The plupload.File object that is about to be uploaded
|
||||
*/
|
||||
phpbb.plupload.uploader.bind('BeforeUpload', (up, file) => {
|
||||
phpbb.plupload.uploader.bind('BeforeUpload', function(up, file) {
|
||||
if (phpbb.plupload.handleMaxFilesReached()) {
|
||||
return;
|
||||
}
|
||||
|
@ -586,7 +577,7 @@ phpbb.plupload.ids = [];
|
|||
* been uploaded
|
||||
* @param {object} response The response object from the server
|
||||
*/
|
||||
phpbb.plupload.uploader.bind('ChunkUploaded', (up, file, response) => {
|
||||
phpbb.plupload.uploader.bind('ChunkUploaded', function(up, file, response) {
|
||||
if (response.chunk >= response.chunks - 1) {
|
||||
return;
|
||||
}
|
||||
|
@ -594,7 +585,7 @@ phpbb.plupload.ids = [];
|
|||
var json = {};
|
||||
try {
|
||||
json = $.parseJSON(response.response);
|
||||
} catch {
|
||||
} catch (e) {
|
||||
file.status = plupload.FAILED;
|
||||
up.trigger('FileUploaded', file, {
|
||||
response: JSON.stringify({
|
||||
|
@ -625,7 +616,7 @@ phpbb.plupload.ids = [];
|
|||
/**
|
||||
* Fires when files are added to the queue.
|
||||
*/
|
||||
phpbb.plupload.uploader.bind('FilesAdded', (up, files) => {
|
||||
phpbb.plupload.uploader.bind('FilesAdded', function(up, files) {
|
||||
// Prevent unnecessary requests to the server if the user already uploaded
|
||||
// the maximum number of files allowed.
|
||||
if (phpbb.plupload.handleMaxFilesReached()) {
|
||||
|
@ -643,11 +634,11 @@ phpbb.plupload.ids = [];
|
|||
$fileListContainer.show(100);
|
||||
}
|
||||
|
||||
$.each(files, (i, file) => {
|
||||
$.each(files, function(i, file) {
|
||||
phpbb.plupload.insertRow(file);
|
||||
});
|
||||
|
||||
up.bind('UploadProgress', (up, file) => {
|
||||
up.bind('UploadProgress', function(up, file) {
|
||||
$('.file-progress-bar', '#' + file.id).css('width', file.percent + '%');
|
||||
$('#file-total-progress-bar').css('width', up.total.percent + '%');
|
||||
});
|
||||
|
@ -659,6 +650,7 @@ phpbb.plupload.ids = [];
|
|||
up.start();
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Fires when an entire file has been uploaded. It checks for errors
|
||||
* returned by the server otherwise parses the list of attachment data and
|
||||
|
@ -670,17 +662,17 @@ phpbb.plupload.ids = [];
|
|||
* uploaded
|
||||
* @param {string} response The response string from the server
|
||||
*/
|
||||
phpbb.plupload.uploader.bind('FileUploaded', (up, file, response) => {
|
||||
var json = {};
|
||||
var row = $('#' + file.id);
|
||||
var error;
|
||||
phpbb.plupload.uploader.bind('FileUploaded', function(up, file, response) {
|
||||
var json = {},
|
||||
row = $('#' + file.id),
|
||||
error;
|
||||
|
||||
// Hide the progress indicator.
|
||||
row.find('.file-progress').hide();
|
||||
|
||||
try {
|
||||
json = JSON.parse(response.response);
|
||||
} catch {
|
||||
} catch (e) {
|
||||
error = 'Error parsing server response.';
|
||||
}
|
||||
|
||||
|
@ -710,9 +702,9 @@ phpbb.plupload.ids = [];
|
|||
/**
|
||||
* Fires when the entire queue of files have been uploaded.
|
||||
*/
|
||||
phpbb.plupload.uploader.bind('UploadComplete', () => {
|
||||
phpbb.plupload.uploader.bind('UploadComplete', function() {
|
||||
// Hide the progress bar
|
||||
setTimeout(() => {
|
||||
setTimeout(function() {
|
||||
$('#file-total-progress-bar').fadeOut(500, function() {
|
||||
$(this).css('width', 0).show();
|
||||
});
|
||||
|
@ -721,4 +713,5 @@ phpbb.plupload.ids = [];
|
|||
// Re-enable the uploader
|
||||
phpbb.plupload.enableUploader();
|
||||
});
|
||||
|
||||
})(jQuery); // Avoid conflicts with other libraries
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
/* eslint no-var: 0 */
|
||||
|
||||
(function($) { // Avoid conflicts with other libraries
|
||||
|
||||
'use strict';
|
||||
|
||||
// This callback will mark all forum icons read
|
||||
|
@ -18,7 +19,7 @@
|
|||
$('li.row').find('dl[class*="forum_unread"]').each(function() {
|
||||
var $this = $(this);
|
||||
|
||||
$.each(iconsArray, (unreadClass, readClass) => {
|
||||
$.each(iconsArray, function(unreadClass, readClass) {
|
||||
if ($this.hasClass(unreadClass)) {
|
||||
$this.removeClass(unreadClass).addClass(readClass);
|
||||
}
|
||||
|
@ -46,7 +47,7 @@
|
|||
* @param {bool} [update_topic_links=true] Whether "Mark topics read" links
|
||||
* should be updated. Defaults to true.
|
||||
*/
|
||||
phpbb.addAjaxCallback('mark_topics_read', (res, updateTopicLinks) => {
|
||||
phpbb.addAjaxCallback('mark_topics_read', function(res, updateTopicLinks) {
|
||||
var readTitle = res.NO_UNREAD_POSTS;
|
||||
var unreadTitle = res.UNREAD_POSTS;
|
||||
var iconsArray = {
|
||||
|
@ -56,6 +57,7 @@
|
|||
topic_unread: 'topic_read',
|
||||
};
|
||||
var iconsState = [ '', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine' ];
|
||||
var unreadClassSelectors;
|
||||
var classMap = {};
|
||||
var classNames = [];
|
||||
|
||||
|
@ -63,23 +65,22 @@
|
|||
updateTopicLinks = true;
|
||||
}
|
||||
|
||||
$.each(iconsArray, (unreadClass, readClass) => {
|
||||
$.each(iconsState, (key, value) => {
|
||||
$.each(iconsArray, function(unreadClass, readClass) {
|
||||
$.each(iconsState, function(key, value) {
|
||||
// Only topics can be hot
|
||||
if ((value === '_hot' || value === '_hot_mine') && unreadClass !== 'topic_unread') {
|
||||
return true;
|
||||
}
|
||||
|
||||
classMap[unreadClass + value] = readClass + value;
|
||||
classNames.push(unreadClass + value);
|
||||
});
|
||||
});
|
||||
|
||||
var unreadClassSelectors = '.' + classNames.join(',.');
|
||||
unreadClassSelectors = '.' + classNames.join(',.');
|
||||
|
||||
$('li.row').find(unreadClassSelectors).each(function() {
|
||||
var $this = $(this);
|
||||
$.each(classMap, (unreadClass, readClass) => {
|
||||
$.each(classMap, function(unreadClass, readClass) {
|
||||
if ($this.hasClass(unreadClass)) {
|
||||
$this.removeClass(unreadClass).addClass(readClass);
|
||||
}
|
||||
|
@ -99,7 +100,7 @@
|
|||
});
|
||||
|
||||
// This callback will mark all notifications read
|
||||
phpbb.addAjaxCallback('notification.mark_all_read', res => {
|
||||
phpbb.addAjaxCallback('notification.mark_all_read', function(res) {
|
||||
if (typeof res.success !== 'undefined') {
|
||||
phpbb.markNotifications($('[data-notification-unread="true"]'), 0);
|
||||
phpbb.toggleDropdown.call($('#notification-button'));
|
||||
|
@ -148,8 +149,8 @@
|
|||
|
||||
// This callback finds the post from the delete link, and removes it.
|
||||
phpbb.addAjaxCallback('post_delete', function() {
|
||||
var $this = $(this);
|
||||
var postId;
|
||||
var $this = $(this),
|
||||
postId;
|
||||
|
||||
if ($this.attr('data-refresh') === undefined) {
|
||||
postId = $this[0].href.split('&p=')[1];
|
||||
|
@ -159,7 +160,6 @@
|
|||
post.nextAll('.bg2').removeClass('bg2').addClass('bg1');
|
||||
posts1.removeClass('bg1').addClass('bg2');
|
||||
}
|
||||
|
||||
post.fadeOut(function() {
|
||||
$(this).remove();
|
||||
});
|
||||
|
@ -187,7 +187,7 @@
|
|||
});
|
||||
|
||||
// This handles friend / foe additions removals.
|
||||
phpbb.addAjaxCallback('zebra', res => {
|
||||
phpbb.addAjaxCallback('zebra', function(res) {
|
||||
var zebra;
|
||||
|
||||
if (res.success) {
|
||||
|
@ -212,7 +212,6 @@
|
|||
height = (typeof height === 'undefined') ? panel.find('.inner').outerHeight() : height;
|
||||
panel.css('min-height', height);
|
||||
};
|
||||
|
||||
updatePanelHeight();
|
||||
|
||||
// Remove the View results link
|
||||
|
@ -220,13 +219,13 @@
|
|||
poll.find('.poll_view_results').hide(500);
|
||||
}
|
||||
|
||||
if (res.can_vote) {
|
||||
// If the user can still vote, simply slide down the results
|
||||
poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500);
|
||||
} else {
|
||||
poll.find('.polls, .poll_max_votes, .poll_vote, .poll_option_select').fadeOut(500, () => {
|
||||
if (!res.can_vote) {
|
||||
poll.find('.polls, .poll_max_votes, .poll_vote, .poll_option_select').fadeOut(500, function() {
|
||||
poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show();
|
||||
});
|
||||
} else {
|
||||
// If the user can still vote, simply slide down the results
|
||||
poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500);
|
||||
}
|
||||
|
||||
// Get the votes count of the highest poll option
|
||||
|
@ -245,16 +244,16 @@
|
|||
var optionId = $this.attr('data-poll-option-id');
|
||||
var voted = (typeof res.user_votes[optionId] !== 'undefined');
|
||||
var mostVoted = (res.vote_counts[optionId] === mostVotes);
|
||||
var percent = res.total_votes ? Math.round((res.vote_counts[optionId] / res.total_votes) * 100) : 0;
|
||||
var percent = (!res.total_votes) ? 0 : Math.round((res.vote_counts[optionId] / res.total_votes) * 100);
|
||||
var percentRel = (mostVotes === 0) ? 0 : Math.round((res.vote_counts[optionId] / mostVotes) * 100);
|
||||
var altText;
|
||||
|
||||
var altText = $this.attr('data-alt-text');
|
||||
altText = $this.attr('data-alt-text');
|
||||
if (voted) {
|
||||
$this.attr('title', $.trim(altText));
|
||||
} else {
|
||||
$this.attr('title', '');
|
||||
}
|
||||
|
||||
};
|
||||
$this.toggleClass('voted', voted);
|
||||
$this.toggleClass('most-votes', mostVoted);
|
||||
|
||||
|
@ -263,7 +262,7 @@
|
|||
var barTimeLapse = (res.can_vote) ? 500 : 1500;
|
||||
var newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1);
|
||||
|
||||
setTimeout(() => {
|
||||
setTimeout(function() {
|
||||
bar.animate({ width: percentRel + '%' }, 500)
|
||||
.removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5')
|
||||
.addClass(newBarClass)
|
||||
|
@ -285,13 +284,13 @@
|
|||
updatePanelHeight();
|
||||
}
|
||||
|
||||
$(this).delay(5000).fadeOut(500, () => {
|
||||
$(this).delay(5000).fadeOut(500, function() {
|
||||
resizePanel(300);
|
||||
});
|
||||
});
|
||||
|
||||
// Remove the gap resulting from removing options
|
||||
setTimeout(() => {
|
||||
setTimeout(function() {
|
||||
resizePanel(500);
|
||||
}, 1500);
|
||||
|
||||
|
@ -301,7 +300,7 @@
|
|||
|
||||
if (panelHeight !== innerHeight) {
|
||||
panel.css({ minHeight: '', height: panelHeight })
|
||||
.animate({ height: innerHeight }, time, () => {
|
||||
.animate({ height: innerHeight }, time, function() {
|
||||
panel.css({ minHeight: innerHeight, height: '' });
|
||||
});
|
||||
}
|
||||
|
@ -328,13 +327,13 @@
|
|||
var filter = $this.attr('data-filter');
|
||||
|
||||
if (ajax !== 'false') {
|
||||
var fn = ajax === 'true' ? null : ajax;
|
||||
filter = filter === undefined ? null : phpbb.getFunctionByName(filter);
|
||||
var fn = (ajax !== 'true') ? ajax : null;
|
||||
filter = (filter !== undefined) ? phpbb.getFunctionByName(filter) : null;
|
||||
|
||||
phpbb.ajaxify({
|
||||
selector: this,
|
||||
refresh: $this.attr('data-refresh') !== undefined,
|
||||
filter,
|
||||
filter: filter,
|
||||
callback: fn,
|
||||
});
|
||||
}
|
||||
|
@ -344,9 +343,12 @@
|
|||
* This simply appends #preview to the action of the
|
||||
* QR action when you click the Full Editor & Preview button
|
||||
*/
|
||||
$('#qr_full_editor').click(() => {
|
||||
$('#qr_postform').attr('action', (i, val) => val + '#preview');
|
||||
$('#qr_full_editor').click(function() {
|
||||
$('#qr_postform').attr('action', function(i, val) {
|
||||
return val + '#preview';
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Make the display post links to use JS
|
||||
|
@ -389,7 +391,6 @@
|
|||
if ($memberlistSearch.is(':visible')) {
|
||||
$('#username').focus();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
@ -409,7 +410,7 @@
|
|||
});
|
||||
|
||||
// Scroll smoothly to the top when the button is clicked
|
||||
$scrollTopButton.click(e => {
|
||||
$scrollTopButton.click(function(e) {
|
||||
e.preventDefault(); // Prevent the default anchor link behavior
|
||||
$('html, body').animate({ scrollTop: 0 }, 500); // Smooth scroll to top
|
||||
});
|
||||
|
@ -418,9 +419,11 @@
|
|||
/**
|
||||
* Automatically resize textarea
|
||||
*/
|
||||
$(() => {
|
||||
$(function() {
|
||||
var $textarea = $('textarea:not(#message-box textarea, .no-auto-resize)');
|
||||
phpbb.resizeTextArea($textarea, { minHeight: 75, maxHeight: 250 });
|
||||
phpbb.resizeTextArea($('textarea', '#message-box'));
|
||||
});
|
||||
|
||||
|
||||
})(jQuery); // Avoid conflicts with other libraries
|
||||
|
|
|
@ -37,10 +37,10 @@ function popup(url, width, height, name) {
|
|||
function pageJump(item) {
|
||||
'use strict';
|
||||
|
||||
var page = parseInt(item.val(), 10);
|
||||
var perPage = item.attr('data-per-page');
|
||||
var baseUrl = item.attr('data-base-url');
|
||||
var startName = item.attr('data-start-name');
|
||||
var page = parseInt(item.val(), 10),
|
||||
perPage = item.attr('data-per-page'),
|
||||
baseUrl = item.attr('data-base-url'),
|
||||
startName = item.attr('data-start-name');
|
||||
|
||||
if (page !== null && !isNaN(page) && page === Math.floor(page) && page > 0) {
|
||||
if (baseUrl.indexOf('?') === -1) {
|
||||
|
@ -81,34 +81,35 @@ function viewableArea(e, itself) {
|
|||
e = e.parentNode;
|
||||
}
|
||||
|
||||
if (e.vaHeight) {
|
||||
// Restore viewable area height to the default
|
||||
e.style.height = e.vaHeight + 'px';
|
||||
e.style.overflow = 'auto';
|
||||
e.style.maxHeight = e.vaMaxHeight;
|
||||
e.vaHeight = false;
|
||||
} else {
|
||||
if (!e.vaHeight) {
|
||||
// Store viewable area height before changing style to auto
|
||||
e.vaHeight = e.offsetHeight;
|
||||
e.vaMaxHeight = e.style.maxHeight;
|
||||
e.style.height = 'auto';
|
||||
e.style.maxHeight = 'none';
|
||||
e.style.overflow = 'visible';
|
||||
} else {
|
||||
// Restore viewable area height to the default
|
||||
e.style.height = e.vaHeight + 'px';
|
||||
e.style.overflow = 'auto';
|
||||
e.style.maxHeight = e.vaMaxHeight;
|
||||
e.vaHeight = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Alternate display of subPanels
|
||||
*/
|
||||
jQuery($ => {
|
||||
jQuery(function($) {
|
||||
'use strict';
|
||||
|
||||
$('.sub-panels').each(function() {
|
||||
var $childNodes = $('a[data-subpanel]', this);
|
||||
var panels = $childNodes.map(function() {
|
||||
|
||||
var $childNodes = $('a[data-subpanel]', this),
|
||||
panels = $childNodes.map(function() {
|
||||
return this.getAttribute('data-subpanel');
|
||||
});
|
||||
var showPanel = this.getAttribute('data-show-panel');
|
||||
}),
|
||||
showPanel = this.getAttribute('data-show-panel');
|
||||
|
||||
if (panels.length) {
|
||||
activateSubPanel(showPanel, panels);
|
||||
|
@ -126,13 +127,11 @@ jQuery($ => {
|
|||
function activateSubPanel(p, panels) {
|
||||
'use strict';
|
||||
|
||||
var i;
|
||||
var showPanel;
|
||||
var i, showPanel;
|
||||
|
||||
if (typeof p === 'string') {
|
||||
showPanel = p;
|
||||
}
|
||||
|
||||
$('input[name="show_panel"]').val(showPanel);
|
||||
|
||||
if (typeof panels === 'undefined') {
|
||||
|
@ -152,8 +151,7 @@ function selectCode(a) {
|
|||
|
||||
// Get ID of code block
|
||||
var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
|
||||
var s;
|
||||
var r;
|
||||
var s, r;
|
||||
|
||||
// Not IE and IE9+
|
||||
if (window.getSelection) {
|
||||
|
@ -169,11 +167,12 @@ function selectCode(a) {
|
|||
s.removeAllRanges();
|
||||
s.addRange(r);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
// Firefox and Opera
|
||||
else {
|
||||
// workaround for bug # 42885
|
||||
if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) === '<BR>') {
|
||||
e.innerHTML += ' ';
|
||||
e.innerHTML = e.innerHTML + ' ';
|
||||
}
|
||||
|
||||
r = document.createRange();
|
||||
|
@ -181,15 +180,17 @@ function selectCode(a) {
|
|||
s.removeAllRanges();
|
||||
s.addRange(r);
|
||||
}
|
||||
} else if (document.getSelection) {
|
||||
}
|
||||
// Some older browsers
|
||||
else if (document.getSelection) {
|
||||
s = document.getSelection();
|
||||
r = document.createRange();
|
||||
r.selectNodeContents(e);
|
||||
s.removeAllRanges();
|
||||
s.addRange(r);
|
||||
} else if (document.selection) {
|
||||
}
|
||||
// IE
|
||||
else if (document.selection) {
|
||||
r = document.body.createTextRange();
|
||||
r.moveToElementText(e);
|
||||
r.select();
|
||||
|
@ -231,7 +232,7 @@ function phpbbCheckKey(event) {
|
|||
/**
|
||||
* Apply onkeypress event for forcing default submit button on ENTER key press
|
||||
*/
|
||||
jQuery($ => {
|
||||
jQuery(function($) {
|
||||
'use strict';
|
||||
|
||||
$('form input[type=text], form input[type=password]').on('keypress', function(e) {
|
||||
|
@ -260,10 +261,10 @@ jQuery($ => {
|
|||
function insertUser(formId, value) {
|
||||
'use strict';
|
||||
|
||||
var $form = jQuery(formId);
|
||||
var formName = $form.attr('data-form-name');
|
||||
var fieldName = $form.attr('data-field-name');
|
||||
var item = opener.document.forms[formName][fieldName];
|
||||
var $form = jQuery(formId),
|
||||
formName = $form.attr('data-form-name'),
|
||||
fieldName = $form.attr('data-field-name'),
|
||||
item = opener.document.forms[formName][fieldName];
|
||||
|
||||
if (item.value.length && item.type === 'textarea') {
|
||||
value = item.value + '\n' + value;
|
||||
|
@ -295,9 +296,9 @@ function insert_single_user(formId, user) {
|
|||
function parseDocument($container) {
|
||||
'use strict';
|
||||
|
||||
var test = document.createElement('div');
|
||||
var oldBrowser = (typeof test.style.borderRadius === 'undefined');
|
||||
var $body = $('body');
|
||||
var test = document.createElement('div'),
|
||||
oldBrowser = (typeof test.style.borderRadius === 'undefined'),
|
||||
$body = $('body');
|
||||
|
||||
/**
|
||||
* Reset avatar dimensions when changing URL or EMAIL
|
||||
|
@ -324,7 +325,7 @@ function parseDocument($container) {
|
|||
$container.find('.pagination .dropdown-trigger').click(function() {
|
||||
var $dropdownContainer = $(this).parent();
|
||||
// Wait a little bit to make sure the dropdown has activated
|
||||
setTimeout(() => {
|
||||
setTimeout(function() {
|
||||
if ($dropdownContainer.hasClass('dropdown-visible')) {
|
||||
$dropdownContainer.find('input.inputbox').focus();
|
||||
}
|
||||
|
@ -335,18 +336,19 @@ function parseDocument($container) {
|
|||
* Resize navigation (breadcrumbs) block to keep all links on same line
|
||||
*/
|
||||
$container.find('.navlinks').each(function() {
|
||||
var $this = $(this);
|
||||
var $left = $this.children().not('.rightside');
|
||||
var $right = $this.children('.rightside');
|
||||
var $this = $(this),
|
||||
$left = $this.children().not('.rightside'),
|
||||
$right = $this.children('.rightside');
|
||||
|
||||
if ($left.length !== 1 || !$right.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
function resize() {
|
||||
var width = 0;
|
||||
var diff = $left.outerWidth(true) - $left.width();
|
||||
var minWidth = Math.max($this.width() / 3, 240);
|
||||
var width = 0,
|
||||
diff = $left.outerWidth(true) - $left.width(),
|
||||
minWidth = Math.max($this.width() / 3, 240),
|
||||
maxWidth;
|
||||
|
||||
$right.each(function() {
|
||||
var $this = $(this);
|
||||
|
@ -355,7 +357,7 @@ function parseDocument($container) {
|
|||
}
|
||||
});
|
||||
|
||||
var maxWidth = $this.width() - width - diff;
|
||||
maxWidth = $this.width() - width - diff;
|
||||
$left.css('max-width', Math.floor(Math.max(maxWidth, minWidth)) + 'px');
|
||||
}
|
||||
|
||||
|
@ -367,14 +369,14 @@ function parseDocument($container) {
|
|||
* Makes breadcrumbs responsive
|
||||
*/
|
||||
$container.find('.breadcrumbs:not([data-skip-responsive])').each(function() {
|
||||
var $this = $(this);
|
||||
var $links = $this.find('.crumb');
|
||||
var { length } = $links;
|
||||
var classes = [ 'wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny' ];
|
||||
var classesLength = classes.length;
|
||||
var maxHeight = 0;
|
||||
var lastWidth = false;
|
||||
var wrapped = false;
|
||||
var $this = $(this),
|
||||
$links = $this.find('.crumb'),
|
||||
length = $links.length,
|
||||
classes = [ 'wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny' ],
|
||||
classesLength = classes.length,
|
||||
maxHeight = 0,
|
||||
lastWidth = false,
|
||||
wrapped = false;
|
||||
|
||||
// Set tooltips
|
||||
$this.find('a').each(function() {
|
||||
|
@ -384,8 +386,8 @@ function parseDocument($container) {
|
|||
|
||||
// Function that checks breadcrumbs
|
||||
function check() {
|
||||
var height = $this.height();
|
||||
var width;
|
||||
var height = $this.height(),
|
||||
width;
|
||||
|
||||
// Test max-width set in code for .navlinks above
|
||||
width = parseInt($this.css('max-width'), 10);
|
||||
|
@ -405,7 +407,6 @@ function parseDocument($container) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
lastWidth = width;
|
||||
|
||||
if (wrapped) {
|
||||
|
@ -456,23 +457,23 @@ function parseDocument($container) {
|
|||
* responsive-show-all to list of classes
|
||||
*/
|
||||
$container.find('.topiclist.responsive-show-all > li > dl').each(function() {
|
||||
var $this = $(this);
|
||||
var $block = $this.find('dt .responsive-show:last-child');
|
||||
var first = true;
|
||||
var $this = $(this),
|
||||
$block = $this.find('dt .responsive-show:last-child'),
|
||||
first = true;
|
||||
|
||||
// Create block that is visible only on mobile devices
|
||||
if ($block.length) {
|
||||
first = ($.trim($block.text()).length === 0);
|
||||
} else {
|
||||
if (!$block.length) {
|
||||
$this.find('dt > .list-inner').append('<div class="responsive-show" style="display:none;" />');
|
||||
$block = $this.find('dt .responsive-show:last-child');
|
||||
} else {
|
||||
first = ($.trim($block.text()).length === 0);
|
||||
}
|
||||
|
||||
// Copy contents of each column
|
||||
$this.find('dd').not('.mark').each(function() {
|
||||
var column = $(this);
|
||||
var $children = column.children();
|
||||
var html = column.html();
|
||||
var column = $(this),
|
||||
$children = column.children(),
|
||||
html = column.html();
|
||||
|
||||
if ($children.length === 1 && $children.text() === column.text()) {
|
||||
html = $children.html();
|
||||
|
@ -492,9 +493,9 @@ function parseDocument($container) {
|
|||
* responsive-show-columns to list of classes
|
||||
*/
|
||||
$container.find('.topiclist.responsive-show-columns').each(function() {
|
||||
var $list = $(this);
|
||||
var headers = [];
|
||||
var headersLength = 0;
|
||||
var $list = $(this),
|
||||
headers = [],
|
||||
headersLength = 0;
|
||||
|
||||
// Find all headers, get contents
|
||||
$list.prev('.topiclist').find('li.header dd').not('.mark').each(function() {
|
||||
|
@ -508,23 +509,23 @@ function parseDocument($container) {
|
|||
|
||||
// Parse each row
|
||||
$list.find('dl').each(function() {
|
||||
var $this = $(this);
|
||||
var $block = $this.find('dt .responsive-show:last-child');
|
||||
var first = true;
|
||||
var $this = $(this),
|
||||
$block = $this.find('dt .responsive-show:last-child'),
|
||||
first = true;
|
||||
|
||||
// Create block that is visible only on mobile devices
|
||||
if ($block.length) {
|
||||
first = ($.trim($block.text()).length === 0);
|
||||
} else {
|
||||
if (!$block.length) {
|
||||
$this.find('dt > .list-inner').append('<div class="responsive-show" style="display:none;" />');
|
||||
$block = $this.find('dt .responsive-show:last-child');
|
||||
} else {
|
||||
first = ($.trim($block.text()).length === 0);
|
||||
}
|
||||
|
||||
// Copy contents of each column
|
||||
$this.find('dd').not('.mark').each(function(i) {
|
||||
var column = $(this);
|
||||
var children = column.children();
|
||||
var html = column.html();
|
||||
var column = $(this),
|
||||
children = column.children(),
|
||||
html = column.html();
|
||||
|
||||
if (children.length === 1 && children.text() === column.text()) {
|
||||
html = children.html();
|
||||
|
@ -546,25 +547,24 @@ function parseDocument($container) {
|
|||
* Responsive tables
|
||||
*/
|
||||
$container.find('table.table1').not('.not-responsive').each(function() {
|
||||
var $this = $(this);
|
||||
var $th = $this.find('thead > tr > th');
|
||||
var headers = [];
|
||||
var totalHeaders = 0;
|
||||
var i;
|
||||
var $this = $(this),
|
||||
$th = $this.find('thead > tr > th'),
|
||||
headers = [],
|
||||
totalHeaders = 0,
|
||||
i, headersLength;
|
||||
|
||||
// Find each header
|
||||
$th.each(function(column) {
|
||||
var cell = $(this);
|
||||
var colspan = parseInt(cell.attr('colspan'), 10);
|
||||
var dfn = cell.attr('data-dfn');
|
||||
var text = dfn ? dfn : cell.text();
|
||||
var cell = $(this),
|
||||
colspan = parseInt(cell.attr('colspan'), 10),
|
||||
dfn = cell.attr('data-dfn'),
|
||||
text = dfn ? dfn : cell.text();
|
||||
|
||||
colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan;
|
||||
|
||||
for (i = 0; i < colspan; i++) {
|
||||
headers.push(text);
|
||||
}
|
||||
|
||||
totalHeaders++;
|
||||
|
||||
if (dfn && !column) {
|
||||
|
@ -572,7 +572,7 @@ function parseDocument($container) {
|
|||
}
|
||||
});
|
||||
|
||||
var headersLength = headers.length;
|
||||
headersLength = headers.length;
|
||||
|
||||
// Add header text to each cell as <dfn>
|
||||
$this.addClass('responsive');
|
||||
|
@ -583,9 +583,9 @@ function parseDocument($container) {
|
|||
}
|
||||
|
||||
$this.find('tbody > tr').each(function() {
|
||||
var row = $(this);
|
||||
var cells = row.children('td');
|
||||
var column = 0;
|
||||
var row = $(this),
|
||||
cells = row.children('td'),
|
||||
column = 0;
|
||||
|
||||
if (cells.length === 1) {
|
||||
row.addClass('big-column');
|
||||
|
@ -593,9 +593,9 @@ function parseDocument($container) {
|
|||
}
|
||||
|
||||
cells.each(function() {
|
||||
var cell = $(this);
|
||||
var colspan = parseInt(cell.attr('colspan'), 10);
|
||||
var text = $.trim(cell.text());
|
||||
var cell = $(this),
|
||||
colspan = parseInt(cell.attr('colspan'), 10),
|
||||
text = $.trim(cell.text());
|
||||
|
||||
if (headersLength <= column) {
|
||||
return;
|
||||
|
@ -629,15 +629,15 @@ function parseDocument($container) {
|
|||
* Responsive tabs
|
||||
*/
|
||||
$container.find('#tabs, #minitabs').not('[data-skip-responsive]').each(function() {
|
||||
var $this = $(this);
|
||||
var $ul = $this.children();
|
||||
var $tabs = $ul.children().not('[data-skip-responsive]');
|
||||
var $links = $tabs.children('a');
|
||||
var $item = $ul.append('<li class="tab responsive-tab" style="display:none;"><a href="javascript:void(0);" class="responsive-tab-link"> </a><div class="dropdown tab-dropdown" style="display: none;"><div class="pointer"><div class="pointer-inner"></div></div><ul class="dropdown-contents" /></div></li>').find('li.responsive-tab');
|
||||
var $menu = $item.find('.dropdown-contents');
|
||||
var maxHeight = 0;
|
||||
var lastWidth = false;
|
||||
var responsive = false;
|
||||
var $this = $(this),
|
||||
$ul = $this.children(),
|
||||
$tabs = $ul.children().not('[data-skip-responsive]'),
|
||||
$links = $tabs.children('a'),
|
||||
$item = $ul.append('<li class="tab responsive-tab" style="display:none;"><a href="javascript:void(0);" class="responsive-tab-link"> </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'),
|
||||
$menu = $item.find('.dropdown-contents'),
|
||||
maxHeight = 0,
|
||||
lastWidth = false,
|
||||
responsive = false;
|
||||
|
||||
$links.each(function() {
|
||||
var $this = $(this);
|
||||
|
@ -645,8 +645,8 @@ function parseDocument($container) {
|
|||
});
|
||||
|
||||
function check() {
|
||||
var width = $body.width();
|
||||
var height = $this.height();
|
||||
var width = $body.width(),
|
||||
height = $this.height();
|
||||
|
||||
if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) {
|
||||
return;
|
||||
|
@ -661,7 +661,6 @@ function parseDocument($container) {
|
|||
if ($item.hasClass('dropdown-visible')) {
|
||||
phpbb.toggleDropdown.call($item.find('a.responsive-tab-link').get(0));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -669,24 +668,22 @@ function parseDocument($container) {
|
|||
$item.show();
|
||||
$menu.html('');
|
||||
|
||||
var $availableTabs = $tabs.filter(':not(.activetab, .responsive-tab)');
|
||||
var total = $availableTabs.length;
|
||||
var i;
|
||||
var $tab;
|
||||
var $availableTabs = $tabs.filter(':not(.activetab, .responsive-tab)'),
|
||||
total = $availableTabs.length,
|
||||
i, $tab;
|
||||
|
||||
for (i = total - 1; i >= 0; i--) {
|
||||
$tab = $availableTabs.eq(i);
|
||||
$menu.prepend($tab.clone(true).removeClass('tab'));
|
||||
$tab.hide();
|
||||
if ($this.height() <= maxHeight) {
|
||||
$menu.find('a').click(() => {
|
||||
$menu.find('a').click(function() {
|
||||
check(true);
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$menu.find('a').click(() => {
|
||||
$menu.find('a').click(function() {
|
||||
check(true);
|
||||
});
|
||||
}
|
||||
|
@ -714,26 +711,23 @@ function parseDocument($container) {
|
|||
* Replace responsive text
|
||||
*/
|
||||
$container.find('[data-responsive-text]').each(function() {
|
||||
var $this = $(this);
|
||||
var fullText = $this.text();
|
||||
var responsiveText = $this.attr('data-responsive-text');
|
||||
var responsive = false;
|
||||
var $this = $(this),
|
||||
fullText = $this.text(),
|
||||
responsiveText = $this.attr('data-responsive-text'),
|
||||
responsive = false;
|
||||
|
||||
function check() {
|
||||
if ($(window).width() > 700) {
|
||||
if (!responsive) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this.text(fullText);
|
||||
responsive = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (responsive) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this.text(responsiveText);
|
||||
responsive = true;
|
||||
}
|
||||
|
@ -746,7 +740,7 @@ function parseDocument($container) {
|
|||
/**
|
||||
* Run onload functions
|
||||
*/
|
||||
jQuery($ => {
|
||||
jQuery(function($) {
|
||||
'use strict';
|
||||
|
||||
// Swap .nojs and .hasjs
|
||||
|
|
Loading…
Add table
Reference in a new issue