mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Merge 2daabd34be
into 2fce8aeb3e
This commit is contained in:
commit
cbd5d5fba0
13 changed files with 4936 additions and 4392 deletions
68
eslint.config.mjs
Normal file
68
eslint.config.mjs
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
const { browser: browserGlobals, node: nodeGlobals, jquery: jqueryGlobals } = (await import('globals')).default;
|
||||||
|
|
||||||
|
// File patterns to ignore
|
||||||
|
const IGNORED_FILES = [
|
||||||
|
'phpBB/assets/javascript/cropper.js',
|
||||||
|
'phpBB/assets/javascript/hermite.js',
|
||||||
|
'phpBB/assets/javascript/jquery-cropper.js',
|
||||||
|
'phpBB/ext/**/*.js',
|
||||||
|
'phpBB/**/*.min.js',
|
||||||
|
'phpBB/vendor/**/*.js',
|
||||||
|
'phpBB/vendor-ext/**/*.js',
|
||||||
|
'phpBB/phpbb/**/*.js',
|
||||||
|
'phpBB/tests/**/*.js',
|
||||||
|
];
|
||||||
|
|
||||||
|
// ESLint rule configurations
|
||||||
|
const FORMATTING_RULES = {
|
||||||
|
'quotes': ['error', 'single'],
|
||||||
|
'comma-dangle': ['error', 'always-multiline'],
|
||||||
|
'block-spacing': 'error',
|
||||||
|
'array-bracket-spacing': ['error', 'always'],
|
||||||
|
'object-curly-spacing': ['error', 'always'],
|
||||||
|
'space-before-function-paren': ['error', 'never'],
|
||||||
|
'space-in-parens': 'off',
|
||||||
|
};
|
||||||
|
|
||||||
|
const CODE_QUALITY_RULES = {
|
||||||
|
'semi': ['error', 'always'],
|
||||||
|
'eqeqeq': ['error', 'always'],
|
||||||
|
'curly': ['error', 'multi-line'],
|
||||||
|
'no-var': 'error',
|
||||||
|
'prefer-const': 'error',
|
||||||
|
'no-console': 'off',
|
||||||
|
'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
|
||||||
|
};
|
||||||
|
|
||||||
|
const DISABLED_STYLE_RULES = {
|
||||||
|
'multiline-comment-style': 'off',
|
||||||
|
'computed-property-spacing': 'off',
|
||||||
|
'capitalized-comments': 'off',
|
||||||
|
'no-lonely-if': 'off',
|
||||||
|
};
|
||||||
|
|
||||||
|
const mainConfig = {
|
||||||
|
files: ['**/*.js', '**/*.js.twig'],
|
||||||
|
linterOptions: {
|
||||||
|
reportUnusedDisableDirectives: false,
|
||||||
|
},
|
||||||
|
languageOptions: {
|
||||||
|
ecmaVersion: 'latest',
|
||||||
|
sourceType: 'module',
|
||||||
|
globals: {
|
||||||
|
...browserGlobals,
|
||||||
|
...nodeGlobals,
|
||||||
|
...jqueryGlobals,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
...FORMATTING_RULES,
|
||||||
|
...CODE_QUALITY_RULES,
|
||||||
|
...DISABLED_STYLE_RULES,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{ ignores: IGNORED_FILES },
|
||||||
|
mainConfig,
|
||||||
|
];
|
1780
package-lock.json
generated
1780
package-lock.json
generated
File diff suppressed because it is too large
Load diff
63
package.json
63
package.json
|
@ -6,65 +6,6 @@
|
||||||
"directories": {
|
"directories": {
|
||||||
"doc": "docs"
|
"doc": "docs"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
|
||||||
"extends": "xo",
|
|
||||||
"ignorePatterns": [
|
|
||||||
"phpBB/adm/style/admin.js",
|
|
||||||
"phpBB/adm/style/ajax.js",
|
|
||||||
"phpBB/adm/style/permissions.js",
|
|
||||||
"phpBB/adm/style/tooltip.js",
|
|
||||||
"phpBB/assets/javascript/core.js",
|
|
||||||
"phpBB/assets/javascript/cropper.js",
|
|
||||||
"phpBB/assets/javascript/editor.js",
|
|
||||||
"phpBB/assets/javascript/hermite.js",
|
|
||||||
"phpBB/assets/javascript/installer.js",
|
|
||||||
"phpBB/assets/javascript/jquery-cropper.js",
|
|
||||||
"phpBB/assets/javascript/plupload.js",
|
|
||||||
"phpBB/ext/**/*.js",
|
|
||||||
"phpBB/styles/prosilver/template/ajax.js",
|
|
||||||
"phpBB/styles/prosilver/template/forum_fn.js",
|
|
||||||
"phpBB/**/*.min.js",
|
|
||||||
"phpBB/vendor/**/*.js",
|
|
||||||
"phpBB/vendor-ext/**/*.js",
|
|
||||||
"phpBB/phpbb/**/*.js",
|
|
||||||
"phpBB/tests/**/*.js"
|
|
||||||
],
|
|
||||||
"rules": {
|
|
||||||
"quotes": [
|
|
||||||
"error",
|
|
||||||
"single"
|
|
||||||
],
|
|
||||||
"comma-dangle": [
|
|
||||||
"error",
|
|
||||||
"always-multiline"
|
|
||||||
],
|
|
||||||
"block-spacing": "error",
|
|
||||||
"array-bracket-spacing": [
|
|
||||||
"error",
|
|
||||||
"always"
|
|
||||||
],
|
|
||||||
"multiline-comment-style": "off",
|
|
||||||
"computed-property-spacing": "off",
|
|
||||||
"space-before-function-paren": [
|
|
||||||
"error",
|
|
||||||
"never"
|
|
||||||
],
|
|
||||||
"space-in-parens": "off",
|
|
||||||
"capitalized-comments": "off",
|
|
||||||
"object-curly-spacing": [
|
|
||||||
"error",
|
|
||||||
"always"
|
|
||||||
],
|
|
||||||
"no-lonely-if": "off",
|
|
||||||
"unicorn/prefer-module": "off"
|
|
||||||
},
|
|
||||||
"env": {
|
|
||||||
"es6": true,
|
|
||||||
"browser": true,
|
|
||||||
"node": true,
|
|
||||||
"jquery": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"> 1%",
|
"> 1%",
|
||||||
"not ie 11",
|
"not ie 11",
|
||||||
|
@ -101,8 +42,8 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"autoprefixer": "^10.4.4",
|
"autoprefixer": "^10.4.4",
|
||||||
"cssnano": "^5.1.7",
|
"cssnano": "^5.1.7",
|
||||||
"eslint": "^8.13.0",
|
"eslint": "^9.28.0",
|
||||||
"eslint-config-xo": "^0.40.0",
|
"globals": "^16.2.0",
|
||||||
"gulp": "^5.0.0",
|
"gulp": "^5.0.0",
|
||||||
"gulp-concat": "^2.6.1",
|
"gulp-concat": "^2.6.1",
|
||||||
"gulp-postcss": "^9.0.1",
|
"gulp-postcss": "^9.0.1",
|
||||||
|
|
|
@ -7,19 +7,16 @@
|
||||||
/**
|
/**
|
||||||
* Parse document block
|
* Parse document block
|
||||||
*/
|
*/
|
||||||
function parse_document(container)
|
function parseDocument(container) {
|
||||||
{
|
const test = document.createElement('div');
|
||||||
var test = document.createElement('div'),
|
|
||||||
oldBrowser = (typeof test.style.borderRadius == 'undefined');
|
|
||||||
|
|
||||||
test.remove();
|
test.remove();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigation
|
* Navigation
|
||||||
*/
|
*/
|
||||||
container.find('#menu').each(function() {
|
container.find('#menu').each(function() {
|
||||||
var menu = $(this),
|
const menu = $(this);
|
||||||
blocks = menu.children('.menu-block');
|
const blocks = menu.children('.menu-block');
|
||||||
|
|
||||||
if (!blocks.length) {
|
if (!blocks.length) {
|
||||||
return;
|
return;
|
||||||
|
@ -27,10 +24,11 @@ function parse_document(container)
|
||||||
|
|
||||||
// Set onclick event
|
// Set onclick event
|
||||||
blocks.children('a.header').click(function() {
|
blocks.children('a.header').click(function() {
|
||||||
var parent = $(this).parent();
|
const parent = $(this).parent();
|
||||||
if (!parent.hasClass('active')) {
|
if (!parent.hasClass('active')) {
|
||||||
parent.siblings().removeClass('active');
|
parent.siblings().removeClass('active');
|
||||||
}
|
}
|
||||||
|
|
||||||
parent.toggleClass('active');
|
parent.toggleClass('active');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -47,23 +45,22 @@ function parse_document(container)
|
||||||
* Responsive tables
|
* Responsive tables
|
||||||
*/
|
*/
|
||||||
container.find('table').not('.not-responsive').each(function() {
|
container.find('table').not('.not-responsive').each(function() {
|
||||||
var $this = $(this),
|
const $this = $(this);
|
||||||
th = $this.find('thead > tr > th'),
|
const th = $this.find('thead > tr > th');
|
||||||
columns = th.length,
|
const headers = [];
|
||||||
headers = [],
|
let totalHeaders = 0;
|
||||||
totalHeaders = 0,
|
let i;
|
||||||
i, headersLength;
|
|
||||||
|
|
||||||
// Find columns
|
// Find columns
|
||||||
$this.find('colgroup:first').children().each(function(i) {
|
$this.find('colgroup:first').children().each(function(i) {
|
||||||
var column = $(this);
|
const column = $(this);
|
||||||
$this.find('td:nth-child(' + (i + 1) + ')').addClass(column.prop('className'));
|
$this.find('td:nth-child(' + (i + 1) + ')').addClass(column.prop('className'));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Styles table
|
// Styles table
|
||||||
if ($this.hasClass('styles')) {
|
if ($this.hasClass('styles')) {
|
||||||
$this.find('td:first-child[style]').each(function() {
|
$this.find('td:first-child[style]').each(function() {
|
||||||
var style = $(this).attr('style');
|
const style = $(this).attr('style');
|
||||||
if (style.length) {
|
if (style.length) {
|
||||||
$(this).parent('tr').attr('style', style.toLowerCase().replace('padding', 'margin')).addClass('responsive-style-row');
|
$(this).parent('tr').attr('style', style.toLowerCase().replace('padding', 'margin')).addClass('responsive-style-row');
|
||||||
}
|
}
|
||||||
|
@ -71,21 +68,24 @@ function parse_document(container)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find each header
|
// Find each header
|
||||||
if (!$this.data('no-responsive-header'))
|
if (!$this.data('no-responsive-header')) {
|
||||||
{
|
|
||||||
th.each(function(column) {
|
th.each(function(column) {
|
||||||
var cell = $(this),
|
const cell = $(this);
|
||||||
colspan = parseInt(cell.attr('colspan')),
|
let colspan = parseInt(cell.attr('colspan'), 10);
|
||||||
dfn = cell.attr('data-dfn'),
|
const dfn = cell.attr('data-dfn');
|
||||||
text = dfn ? dfn : $.trim(cell.text());
|
let text = dfn ? dfn : $.trim(cell.text());
|
||||||
|
|
||||||
|
if (text === ' ') {
|
||||||
|
text = '';
|
||||||
|
}
|
||||||
|
|
||||||
if (text == ' ') text = '';
|
|
||||||
colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan;
|
colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan;
|
||||||
|
|
||||||
for (i=0; i<colspan; i++) {
|
for (i = 0; i < colspan; i++) {
|
||||||
headers.push(text);
|
headers.push(text);
|
||||||
}
|
}
|
||||||
totalHeaders ++;
|
|
||||||
|
totalHeaders++;
|
||||||
|
|
||||||
if (dfn && !column) {
|
if (dfn && !column) {
|
||||||
$this.addClass('show-header');
|
$this.addClass('show-header');
|
||||||
|
@ -93,7 +93,7 @@ function parse_document(container)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
headersLength = headers.length;
|
const headersLength = headers.length;
|
||||||
|
|
||||||
// Add header text to each cell as <dfn>
|
// Add header text to each cell as <dfn>
|
||||||
$this.addClass('responsive');
|
$this.addClass('responsive');
|
||||||
|
@ -104,19 +104,19 @@ function parse_document(container)
|
||||||
}
|
}
|
||||||
|
|
||||||
$this.find('tbody > tr').each(function() {
|
$this.find('tbody > tr').each(function() {
|
||||||
var row = $(this),
|
const row = $(this);
|
||||||
cells = row.children('td'),
|
const cells = row.children('td');
|
||||||
column = 0;
|
let column = 0;
|
||||||
|
|
||||||
if (cells.length == 1) {
|
if (cells.length === 1) {
|
||||||
row.addClass('big-column');
|
row.addClass('big-column');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cells.each(function() {
|
cells.each(function() {
|
||||||
var cell = $(this),
|
const cell = $(this);
|
||||||
colspan = parseInt(cell.attr('colspan')),
|
let colspan = parseInt(cell.attr('colspan'), 10);
|
||||||
text = $.trim(cell.text());
|
const text = $.trim(cell.text());
|
||||||
|
|
||||||
if (headersLength <= column) {
|
if (headersLength <= column) {
|
||||||
return;
|
return;
|
||||||
|
@ -124,10 +124,9 @@ function parse_document(container)
|
||||||
|
|
||||||
if ((text.length && text !== '-') || cell.children().length) {
|
if ((text.length && text !== '-') || cell.children().length) {
|
||||||
if (headers[column].length) {
|
if (headers[column].length) {
|
||||||
cell.prepend($("<dfn>").css('display', 'none').text(headers[column]));
|
cell.prepend($('<dfn>').css('display', 'none').text(headers[column]));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
cell.addClass('empty');
|
cell.addClass('empty');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,9 +143,8 @@ function parse_document(container)
|
||||||
* Hide empty responsive tables
|
* Hide empty responsive tables
|
||||||
*/
|
*/
|
||||||
container.find('table.responsive > tbody').each(function() {
|
container.find('table.responsive > tbody').each(function() {
|
||||||
var items = $(this).children('tr');
|
const items = $(this).children('tr');
|
||||||
if (!items.length)
|
if (!items.length) {
|
||||||
{
|
|
||||||
$(this).parent('table:first').addClass('responsive-hide');
|
$(this).parent('table:first').addClass('responsive-hide');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -155,8 +153,8 @@ function parse_document(container)
|
||||||
* Fieldsets with empty <span>
|
* Fieldsets with empty <span>
|
||||||
*/
|
*/
|
||||||
container.find('fieldset dt > span:last-child').each(function() {
|
container.find('fieldset dt > span:last-child').each(function() {
|
||||||
var $this = $(this);
|
const $this = $(this);
|
||||||
if ($this.html() == ' ') {
|
if ($this.html() === ' ') {
|
||||||
$this.addClass('responsive-hide');
|
$this.addClass('responsive-hide');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -166,7 +164,7 @@ function parse_document(container)
|
||||||
*/
|
*/
|
||||||
container.find('#sitename_short').each(function() {
|
container.find('#sitename_short').each(function() {
|
||||||
const $this = this;
|
const $this = this;
|
||||||
const maxLength = $this.maxLength;
|
const { maxLength } = $this;
|
||||||
$this.maxLength = maxLength * 2;
|
$this.maxLength = maxLength * 2;
|
||||||
$this.addEventListener('input', () => {
|
$this.addEventListener('input', () => {
|
||||||
const inputChars = Array.from($this.value);
|
const inputChars = Array.from($this.value);
|
||||||
|
@ -180,25 +178,25 @@ function parse_document(container)
|
||||||
* Responsive tabs
|
* Responsive tabs
|
||||||
*/
|
*/
|
||||||
container.find('#tabs').not('[data-skip-responsive]').each(function() {
|
container.find('#tabs').not('[data-skip-responsive]').each(function() {
|
||||||
var $this = $(this),
|
const $this = $(this);
|
||||||
$body = $('body'),
|
const $body = $('body');
|
||||||
ul = $this.children(),
|
const ul = $this.children();
|
||||||
tabs = ul.children().not('[data-skip-responsive]'),
|
const tabs = ul.children().not('[data-skip-responsive]');
|
||||||
links = tabs.children('a'),
|
const 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'),
|
const 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'),
|
const menu = item.find('.dropdown-contents');
|
||||||
maxHeight = 0,
|
let maxHeight = 0;
|
||||||
lastWidth = false,
|
let lastWidth = false;
|
||||||
responsive = false;
|
let responsive = false;
|
||||||
|
|
||||||
links.each(function() {
|
links.each(function() {
|
||||||
var link = $(this);
|
const link = $(this);
|
||||||
maxHeight = Math.max(maxHeight, Math.max(link.outerHeight(true), link.parent().outerHeight(true)));
|
maxHeight = Math.max(maxHeight, Math.max(link.outerHeight(true), link.parent().outerHeight(true)));
|
||||||
})
|
});
|
||||||
|
|
||||||
function check() {
|
function check() {
|
||||||
var width = $body.width(),
|
const width = $body.width();
|
||||||
height = $this.height();
|
let height = $this.height();
|
||||||
|
|
||||||
if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) {
|
if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) {
|
||||||
return;
|
return;
|
||||||
|
@ -214,6 +212,7 @@ function parse_document(container)
|
||||||
if (item.hasClass('dropdown-visible')) {
|
if (item.hasClass('dropdown-visible')) {
|
||||||
phpbb.toggleDropdown.call(item.find('a.responsive-tab-link').get(0));
|
phpbb.toggleDropdown.call(item.find('a.responsive-tab-link').get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,23 +220,29 @@ function parse_document(container)
|
||||||
item.show();
|
item.show();
|
||||||
menu.html('');
|
menu.html('');
|
||||||
|
|
||||||
var availableTabs = tabs.filter(':not(.activetab, .responsive-tab)'),
|
const availableTabs = tabs.filter(':not(.activetab, .responsive-tab)');
|
||||||
total = availableTabs.length,
|
const total = availableTabs.length;
|
||||||
i, tab;
|
let i;
|
||||||
|
let tab;
|
||||||
|
|
||||||
for (i = total - 1; i >= 0; i --) {
|
for (i = total - 1; i >= 0; i--) {
|
||||||
tab = availableTabs.eq(i);
|
tab = availableTabs.eq(i);
|
||||||
menu.prepend(tab.clone(true).removeClass('tab'));
|
menu.prepend(tab.clone(true).removeClass('tab'));
|
||||||
tab.hide();
|
tab.hide();
|
||||||
if ($this.height() <= maxHeight) {
|
if ($this.height() <= maxHeight) {
|
||||||
menu.find('a').click(function() { check(true); });
|
menu.find('a').click(() => {
|
||||||
|
check(true);
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
menu.find('a').click(function() { check(true); });
|
|
||||||
|
menu.find('a').click(() => {
|
||||||
|
check(true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
phpbb.registerDropdown(item.find('a.responsive-tab-link'), item.find('.dropdown'), {visibleClass: 'activetab', verticalDirection: 'down'});
|
phpbb.registerDropdown(item.find('a.responsive-tab-link'), item.find('.dropdown'), { visibleClass: 'activetab', verticalDirection: 'down' });
|
||||||
|
|
||||||
check(true);
|
check(true);
|
||||||
$(window).resize(check);
|
$(window).resize(check);
|
||||||
|
@ -248,7 +253,7 @@ function parse_document(container)
|
||||||
* Run onload functions
|
* Run onload functions
|
||||||
*/
|
*/
|
||||||
(function($) {
|
(function($) {
|
||||||
$(document).ready(function() {
|
$(document).ready(() => {
|
||||||
// Swap .nojs and .hasjs
|
// Swap .nojs and .hasjs
|
||||||
$('body.nojs').toggleClass('nojs hasjs');
|
$('body.nojs').toggleClass('nojs hasjs');
|
||||||
|
|
||||||
|
@ -257,13 +262,13 @@ function parse_document(container)
|
||||||
$('#' + this.getAttribute('data-focus')).focus();
|
$('#' + this.getAttribute('data-focus')).focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
parse_document($('body'));
|
parseDocument($('body'));
|
||||||
|
|
||||||
$('#questionnaire-form').css('display', 'none');
|
$('#questionnaire-form').css('display', 'none');
|
||||||
var $triggerConfiglist = $('#trigger-configlist');
|
const $triggerConfiglist = $('#trigger-configlist');
|
||||||
|
|
||||||
$triggerConfiglist.on('click', function () {
|
$triggerConfiglist.on('click', function() {
|
||||||
var $configlist = $('#configlist');
|
const $configlist = $('#configlist');
|
||||||
$configlist.closest('.send-stats-data-row').toggleClass('send-stats-data-hidden');
|
$configlist.closest('.send-stats-data-row').toggleClass('send-stats-data-hidden');
|
||||||
$configlist.closest('.send-stats-row').find('.send-stats-data-row:first-child').toggleClass('send-stats-data-only-row');
|
$configlist.closest('.send-stats-row').find('.send-stats-data-row:first-child').toggleClass('send-stats-data-only-row');
|
||||||
$(this).find('i').toggleClass('fa-angle-down fa-angle-up');
|
$(this).find('i').toggleClass('fa-angle-down fa-angle-up');
|
||||||
|
@ -272,8 +277,8 @@ function parse_document(container)
|
||||||
$('#configlist').closest('.send-stats-data-row').addClass('send-stats-data-hidden');
|
$('#configlist').closest('.send-stats-data-row').addClass('send-stats-data-hidden');
|
||||||
|
|
||||||
// Do not underline actions icons on hover (could not be done via CSS)
|
// Do not underline actions icons on hover (could not be done via CSS)
|
||||||
$('.actions a:has(i.acp-icon)').mouseover(function () {
|
$('.actions a:has(i.acp-icon)').mouseover(function() {
|
||||||
$(this).css("text-decoration", "none");
|
$(this).css('text-decoration', 'none');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Live update BBCode font icon preview
|
// Live update BBCode font icon preview
|
||||||
|
@ -296,11 +301,11 @@ function parse_document(container)
|
||||||
const pageIconFont = document.getElementById('bbcode_font_icon');
|
const pageIconFont = document.getElementById('bbcode_font_icon');
|
||||||
|
|
||||||
if (pageIconFont) {
|
if (pageIconFont) {
|
||||||
pageIconFont.addEventListener('keyup', function () {
|
pageIconFont.addEventListener('keyup', function() {
|
||||||
updateIconClass(this.nextElementSibling, this.value);
|
updateIconClass(this.nextElementSibling, this.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
pageIconFont.addEventListener('blur', function () {
|
pageIconFont.addEventListener('blur', function() {
|
||||||
updateIconClass(this.nextElementSibling, this.value);
|
updateIconClass(this.nextElementSibling, this.value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,27 @@
|
||||||
/* global phpbb, statsData */
|
/* global phpbb, statsData */
|
||||||
|
|
||||||
(function($) { // Avoid conflicts with other libraries
|
(function($) { // Avoid conflicts with other libraries
|
||||||
|
'use strict';
|
||||||
|
|
||||||
'use strict';
|
phpbb.prepareSendStats = function() {
|
||||||
|
const $form = $('#acp_help_phpbb');
|
||||||
|
const $dark = $('#darkenwrapper');
|
||||||
|
let $loadingIndicator;
|
||||||
|
|
||||||
|
$form.on('submit', function(event) {
|
||||||
phpbb.prepareSendStats = function () {
|
const $this = $(this);
|
||||||
var $form = $('#acp_help_phpbb');
|
const currentTime = Math.floor(new Date().getTime() / 1000);
|
||||||
var $dark = $('#darkenwrapper');
|
const statsTime = parseInt($this.find('input[name=help_send_statistics_time]').val(), 10);
|
||||||
var $loadingIndicator;
|
|
||||||
|
|
||||||
$form.on('submit', function (event) {
|
|
||||||
var $this = $(this),
|
|
||||||
currentTime = Math.floor(new Date().getTime() / 1000),
|
|
||||||
statsTime = parseInt($this.find('input[name=help_send_statistics_time]').val(), 10);
|
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
$this.unbind('submit');
|
$this.unbind('submit');
|
||||||
|
|
||||||
// Skip ajax request if form is submitted too early or send stats
|
// Skip ajax request if form is submitted too early or send stats
|
||||||
// checkbox is not checked
|
// checkbox is not checked
|
||||||
if (!$this.find('input[name=help_send_statistics]').is(':checked') ||
|
if (!$this.find('input[name=help_send_statistics]').is(':checked')
|
||||||
statsTime > currentTime) {
|
|| statsTime > currentTime) {
|
||||||
$form.find('input[type=submit]').click();
|
$form.find('input[type=submit]').click();
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
$form.find('input[type=submit]').click();
|
$form.find('input[type=submit]').click();
|
||||||
}, 300);
|
}, 300);
|
||||||
return;
|
return;
|
||||||
|
@ -36,8 +34,9 @@ phpbb.prepareSendStats = function () {
|
||||||
if (typeof console !== 'undefined' && console.log) {
|
if (typeof console !== 'undefined' && console.log) {
|
||||||
console.log('AJAX error. status: ' + textStatus + ', message: ' + errorThrown);
|
console.log('AJAX error. status: ' + textStatus + ', message: ' + errorThrown);
|
||||||
}
|
}
|
||||||
|
|
||||||
phpbb.clearLoadingTimeout();
|
phpbb.clearLoadingTimeout();
|
||||||
var errorText = '';
|
let errorText = '';
|
||||||
|
|
||||||
if (typeof errorThrown === 'string' && errorThrown.length > 0) {
|
if (typeof errorThrown === 'string' && errorThrown.length > 0) {
|
||||||
errorText = errorThrown;
|
errorText = errorThrown;
|
||||||
|
@ -47,6 +46,7 @@ phpbb.prepareSendStats = function () {
|
||||||
errorText = $dark.attr('data-ajax-error-text');
|
errorText = $dark.attr('data-ajax-error-text');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
phpbb.alert($dark.attr('data-ajax-error-title'), errorText);
|
phpbb.alert($dark.attr('data-ajax-error-title'), errorText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,10 +71,10 @@ phpbb.prepareSendStats = function () {
|
||||||
$loadingIndicator.fadeOut(phpbb.alertTime);
|
$loadingIndicator.fadeOut(phpbb.alertTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
var $sendStatisticsSuccess = $('<input />', {
|
const $sendStatisticsSuccess = $('<input />', {
|
||||||
type: 'hidden',
|
type: 'hidden',
|
||||||
name: 'send_statistics_response',
|
name: 'send_statistics_response',
|
||||||
value: JSON.stringify(res)
|
value: JSON.stringify(res),
|
||||||
});
|
});
|
||||||
$sendStatisticsSuccess.appendTo('p.submit-buttons');
|
$sendStatisticsSuccess.appendTo('p.submit-buttons');
|
||||||
|
|
||||||
|
@ -90,78 +90,77 @@ phpbb.prepareSendStats = function () {
|
||||||
data: statsData,
|
data: statsData,
|
||||||
success: returnHandler,
|
success: returnHandler,
|
||||||
error: errorHandler,
|
error: errorHandler,
|
||||||
cache: false
|
cache: false,
|
||||||
}).always(function() {
|
}).always(() => {
|
||||||
if ($loadingIndicator && $loadingIndicator.is(':visible')) {
|
if ($loadingIndicator && $loadingIndicator.is(':visible')) {
|
||||||
$loadingIndicator.fadeOut(phpbb.alertTime);
|
$loadingIndicator.fadeOut(phpbb.alertTime);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The following callbacks are for reording items. row_down
|
* The following callbacks are for reording items. row_down
|
||||||
* is triggered when an item is moved down, and row_up is triggered when
|
* is triggered when an item is moved down, and row_up is triggered when
|
||||||
* an item is moved up. It moves the row up or down, and deactivates /
|
* an item is moved up. It moves the row up or down, and deactivates /
|
||||||
* activates any up / down icons that require it (the ones at the top or bottom).
|
* activates any up / down icons that require it (the ones at the top or bottom).
|
||||||
*/
|
*/
|
||||||
phpbb.addAjaxCallback('row_down', function(res) {
|
phpbb.addAjaxCallback('row_down', function(res) {
|
||||||
if (typeof res.success === 'undefined' || !res.success) {
|
if (typeof res.success === 'undefined' || !res.success) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $firstTr = $(this).parents('tr'),
|
const $firstTr = $(this).parents('tr');
|
||||||
$secondTr = $firstTr.next();
|
const $secondTr = $firstTr.next();
|
||||||
|
|
||||||
$firstTr.insertAfter($secondTr);
|
$firstTr.insertAfter($secondTr);
|
||||||
});
|
});
|
||||||
|
|
||||||
phpbb.addAjaxCallback('row_up', function(res) {
|
phpbb.addAjaxCallback('row_up', function(res) {
|
||||||
if (typeof res.success === 'undefined' || !res.success) {
|
if (typeof res.success === 'undefined' || !res.success) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $secondTr = $(this).parents('tr'),
|
const $secondTr = $(this).parents('tr');
|
||||||
$firstTr = $secondTr.prev();
|
const $firstTr = $secondTr.prev();
|
||||||
|
|
||||||
$secondTr.insertBefore($firstTr);
|
$secondTr.insertBefore($firstTr);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This callback replaces activate links with deactivate links and vice versa.
|
* This callback replaces activate links with deactivate links and vice versa.
|
||||||
* It does this by replacing the text, and replacing all instances of "activate"
|
* It does this by replacing the text, and replacing all instances of "activate"
|
||||||
* in the href with "deactivate", and vice versa.
|
* in the href with "deactivate", and vice versa.
|
||||||
*/
|
*/
|
||||||
phpbb.addAjaxCallback('activate_deactivate', function(res) {
|
phpbb.addAjaxCallback('activate_deactivate', function(res) {
|
||||||
var $this = $(this),
|
const $this = $(this);
|
||||||
newHref = $this.attr('href');
|
let newHref = $this.attr('href');
|
||||||
|
|
||||||
$this.text(res.text);
|
$this.text(res.text);
|
||||||
|
|
||||||
if (newHref.indexOf('deactivate') !== -1) {
|
if (newHref.indexOf('deactivate') === -1) {
|
||||||
newHref = newHref.replace('deactivate', 'activate');
|
|
||||||
} else {
|
|
||||||
newHref = newHref.replace('activate', 'deactivate');
|
newHref = newHref.replace('activate', 'deactivate');
|
||||||
|
} else {
|
||||||
|
newHref = newHref.replace('deactivate', 'activate');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this.attr('href', newHref);
|
$this.attr('href', newHref);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The removes the parent row of the link or form that triggered the callback,
|
* The removes the parent row of the link or form that triggered the callback,
|
||||||
* and is good for stuff like the removal of forums.
|
* and is good for stuff like the removal of forums.
|
||||||
*/
|
*/
|
||||||
phpbb.addAjaxCallback('row_delete', function(res) {
|
phpbb.addAjaxCallback('row_delete', function(res) {
|
||||||
if (res.SUCCESS !== false) {
|
if (res.SUCCESS !== false) {
|
||||||
$(this).parents('tr').remove();
|
$(this).parents('tr').remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This callback generates the VAPID keys for the web push notification service.
|
* This callback generates the VAPID keys for the web push notification service.
|
||||||
*/
|
*/
|
||||||
phpbb.addAjaxCallback('generate_vapid_keys', () => {
|
phpbb.addAjaxCallback('generate_vapid_keys', () => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate VAPID keypair with public and private key string
|
* Generate VAPID keypair with public and private key string
|
||||||
*
|
*
|
||||||
|
@ -176,7 +175,7 @@ phpbb.addAjaxCallback('generate_vapid_keys', () => {
|
||||||
namedCurve: 'P-256',
|
namedCurve: 'P-256',
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
['deriveKey', 'deriveBits']
|
[ 'deriveKey', 'deriveBits' ],
|
||||||
);
|
);
|
||||||
|
|
||||||
const privateKeyJwk = await crypto.subtle.exportKey('jwk', keyPair.privateKey);
|
const privateKeyJwk = await crypto.subtle.exportKey('jwk', keyPair.privateKey);
|
||||||
|
@ -187,7 +186,7 @@ phpbb.addAjaxCallback('generate_vapid_keys', () => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
privateKey: privateKeyString,
|
privateKey: privateKeyString,
|
||||||
publicKey: publicKeyString
|
publicKey: publicKeyString,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error generating keys with SubtleCrypto:', error);
|
console.error('Error generating keys with SubtleCrypto:', error);
|
||||||
|
@ -199,40 +198,40 @@ phpbb.addAjaxCallback('generate_vapid_keys', () => {
|
||||||
if (!keyPair) {
|
if (!keyPair) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const publicKeyInput = document.querySelector('#webpush_vapid_public');
|
const publicKeyInput = document.querySelector('#webpush_vapid_public');
|
||||||
const privateKeyInput = document.querySelector('#webpush_vapid_private');
|
const privateKeyInput = document.querySelector('#webpush_vapid_private');
|
||||||
publicKeyInput.value = keyPair.publicKey;
|
publicKeyInput.value = keyPair.publicKey;
|
||||||
privateKeyInput.value = keyPair.privateKey;
|
privateKeyInput.value = keyPair.privateKey;
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for submitting permissions form in chunks
|
* Handler for submitting permissions form in chunks
|
||||||
* This call will submit permissions forms in chunks of 5 fieldsets.
|
* This call will submit permissions forms in chunks of 5 fieldsets.
|
||||||
*/
|
*/
|
||||||
function submitPermissions() {
|
function submitPermissions() {
|
||||||
var $form = $('form#set-permissions'),
|
const $form = $('form#set-permissions');
|
||||||
fieldsetList = $form.find('fieldset[id^=perm]'),
|
let fieldsetList = $form.find('fieldset[id^=perm]');
|
||||||
formDataSets = [],
|
const formDataSets = [];
|
||||||
dataSetIndex = 0,
|
let dataSetIndex = 0;
|
||||||
$submitAllButton = $form.find('input[type=submit][name^=action]')[0],
|
const $submitAllButton = $form.find('input[type=submit][name^=action]')[0];
|
||||||
$submitButton = $form.find('input[type=submit][data-clicked=true]')[0];
|
const $submitButton = $form.find('input[type=submit][data-clicked=true]')[0];
|
||||||
|
|
||||||
// Set proper start values for handling refresh of page
|
// Set proper start values for handling refresh of page
|
||||||
var permissionSubmitSize = 0,
|
let permissionSubmitSize = 0;
|
||||||
permissionRequestCount = 0,
|
let permissionRequestCount = 0;
|
||||||
forumIds = [],
|
const forumIds = [];
|
||||||
permissionSubmitFailed = false,
|
let permissionSubmitFailed = false;
|
||||||
clearIndicator = true,
|
let clearIndicator = true;
|
||||||
$loadingIndicator;
|
|
||||||
|
|
||||||
if ($submitAllButton !== $submitButton) {
|
if ($submitAllButton !== $submitButton) {
|
||||||
fieldsetList = $form.find('fieldset#' + $submitButton.closest('fieldset.permissions').id);
|
fieldsetList = $form.find('fieldset#' + $submitButton.closest('fieldset.permissions').id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$.each(fieldsetList, function (key, value) {
|
$.each(fieldsetList, (key, value) => {
|
||||||
dataSetIndex = Math.floor(key / 5);
|
dataSetIndex = Math.floor(key / 5);
|
||||||
var $fieldset = $('fieldset#' + value.id);
|
const $fieldset = $('fieldset#' + value.id);
|
||||||
if (key % 5 === 0) {
|
if (key % 5 === 0) {
|
||||||
formDataSets[dataSetIndex] = $fieldset.find('select:visible, input:not([data-name])').serialize();
|
formDataSets[dataSetIndex] = $fieldset.find('select:visible, input:not([data-name])').serialize();
|
||||||
} else {
|
} else {
|
||||||
|
@ -240,25 +239,25 @@ function submitPermissions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find proper role value
|
// Find proper role value
|
||||||
var roleInput = $fieldset.find('input[name^=role][data-name]');
|
const roleInput = $fieldset.find('input[name^=role][data-name]');
|
||||||
if (roleInput.val()) {
|
if (roleInput.val()) {
|
||||||
formDataSets[dataSetIndex] += '&' + roleInput.attr('name') + '=' + roleInput.val();
|
formDataSets[dataSetIndex] += '&' + roleInput.attr('name') + '=' + roleInput.val();
|
||||||
} else {
|
} else {
|
||||||
formDataSets[dataSetIndex] += '&' + roleInput.attr('name') + '=' +
|
formDataSets[dataSetIndex] += '&' + roleInput.attr('name') + '='
|
||||||
$fieldset.find('select[name="' + roleInput.attr('name') + '"]').val();
|
+ $fieldset.find('select[name="' + roleInput.attr('name') + '"]').val();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
permissionSubmitSize = formDataSets.length;
|
permissionSubmitSize = formDataSets.length;
|
||||||
|
|
||||||
// Add each forum ID to forum ID list to preserve selected forums
|
// Add each forum ID to forum ID list to preserve selected forums
|
||||||
$.each($form.find('input[type=hidden][name^=forum_id]'), function (key, value) {
|
$.each($form.find('input[type=hidden][name^=forum_id]'), (key, value) => {
|
||||||
if (value.name.match(/^forum_id\[([0-9]+)\]$/)) {
|
if (value.name.match(/^forum_id\[([0-9]+)\]$/)) {
|
||||||
forumIds.push(value.value);
|
forumIds.push(value.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$loadingIndicator = phpbb.loadingIndicator();
|
const $loadingIndicator = phpbb.loadingIndicator();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for submitted permissions form chunk
|
* Handler for submitted permissions form chunk
|
||||||
|
@ -267,7 +266,7 @@ function submitPermissions() {
|
||||||
*/
|
*/
|
||||||
function handlePermissionReturn(res) {
|
function handlePermissionReturn(res) {
|
||||||
permissionRequestCount++;
|
permissionRequestCount++;
|
||||||
var $dark = $('#darkenwrapper');
|
const $dark = $('#darkenwrapper');
|
||||||
|
|
||||||
if (res.S_USER_WARNING) {
|
if (res.S_USER_WARNING) {
|
||||||
phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
|
phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
|
||||||
|
@ -277,8 +276,8 @@ function submitPermissions() {
|
||||||
if (permissionRequestCount >= permissionSubmitSize) {
|
if (permissionRequestCount >= permissionSubmitSize) {
|
||||||
clearIndicator = true;
|
clearIndicator = true;
|
||||||
|
|
||||||
var $alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
|
const $alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT);
|
||||||
var $alertBoxLink = $alert.find('p.alert_text > a');
|
const $alertBoxLink = $alert.find('p.alert_text > a');
|
||||||
|
|
||||||
// Create form to submit instead of normal "Back to previous page" link
|
// Create form to submit instead of normal "Back to previous page" link
|
||||||
if ($alertBoxLink) {
|
if ($alertBoxLink) {
|
||||||
|
@ -286,18 +285,18 @@ function submitPermissions() {
|
||||||
$alertBoxLink.attr('href', $alertBoxLink.attr('href').replace(/(&forum_id\[\]=[0-9]+)/g, ''));
|
$alertBoxLink.attr('href', $alertBoxLink.attr('href').replace(/(&forum_id\[\]=[0-9]+)/g, ''));
|
||||||
const $previousPageForm = $('<form>').attr({
|
const $previousPageForm = $('<form>').attr({
|
||||||
action: $alertBoxLink.attr('href'),
|
action: $alertBoxLink.attr('href'),
|
||||||
method: 'post'
|
method: 'post',
|
||||||
});
|
});
|
||||||
|
|
||||||
$.each(forumIds, function (key, value) {
|
$.each(forumIds, (key, value) => {
|
||||||
$previousPageForm.append($('<input>').attr({
|
$previousPageForm.append($('<input>').attr({
|
||||||
type: 'text',
|
type: 'text',
|
||||||
name: 'forum_id[]',
|
name: 'forum_id[]',
|
||||||
value: value
|
value,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
$alertBoxLink.on('click', function (e) {
|
$alertBoxLink.on('click', e => {
|
||||||
$('body').append($previousPageForm);
|
$('body').append($previousPageForm);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$previousPageForm.submit();
|
$previousPageForm.submit();
|
||||||
|
@ -309,19 +308,19 @@ function submitPermissions() {
|
||||||
$alert.find('.alert_close').hide();
|
$alert.find('.alert_close').hide();
|
||||||
|
|
||||||
if (typeof res.REFRESH_DATA !== 'undefined') {
|
if (typeof res.REFRESH_DATA !== 'undefined') {
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
// Create forum to submit using POST. This will prevent
|
// Create forum to submit using POST. This will prevent
|
||||||
// exceeding the maximum length of URLs
|
// exceeding the maximum length of URLs
|
||||||
const $form = $('<form>').attr({
|
const $form = $('<form>').attr({
|
||||||
action: res.REFRESH_DATA.url.replace(/(&forum_id\[\]=[0-9]+)/g, ''),
|
action: res.REFRESH_DATA.url.replace(/(&forum_id\[\]=[0-9]+)/g, ''),
|
||||||
method: 'post'
|
method: 'post',
|
||||||
});
|
});
|
||||||
|
|
||||||
$.each(forumIds, function (key, value) {
|
$.each(forumIds, (key, value) => {
|
||||||
$form.append($('<input>').attr({
|
$form.append($('<input>').attr({
|
||||||
type: 'text',
|
type: 'text',
|
||||||
name: 'forum_id[]',
|
name: 'forum_id[]',
|
||||||
value: value
|
value,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -329,7 +328,7 @@ function submitPermissions() {
|
||||||
|
|
||||||
// Hide the alert even if we refresh the page, in case the user
|
// Hide the alert even if we refresh the page, in case the user
|
||||||
// presses the back button.
|
// presses the back button.
|
||||||
$dark.fadeOut(phpbb.alertTime, function () {
|
$dark.fadeOut(phpbb.alertTime, () => {
|
||||||
if (typeof $alert !== 'undefined') {
|
if (typeof $alert !== 'undefined') {
|
||||||
$alert.hide();
|
$alert.hide();
|
||||||
}
|
}
|
||||||
|
@ -355,44 +354,44 @@ function submitPermissions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create AJAX request for each form data set
|
// Create AJAX request for each form data set
|
||||||
$.each(formDataSets, function (key, formData) {
|
$.each(formDataSets, (key, formData) => {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: $form.action,
|
url: $form.action,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: formData + '&' + $submitButton.name + '=' + encodeURIComponent($submitButton.value) +
|
data: formData + '&' + $submitButton.name + '=' + encodeURIComponent($submitButton.value)
|
||||||
'&creation_time=' + $form.find('input[type=hidden][name=creation_time]')[0].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_token=' + $form.find('input[type=hidden][name=form_token]')[0].value
|
||||||
'&' + $form.children('input[type=hidden]').serialize() +
|
+ '&' + $form.children('input[type=hidden]').serialize()
|
||||||
'&' + $form.find('input[type=checkbox][name^=inherit]').serialize(),
|
+ '&' + $form.find('input[type=checkbox][name^=inherit]').serialize(),
|
||||||
success: handlePermissionReturn,
|
success: handlePermissionReturn,
|
||||||
error: handlePermissionReturn
|
error: handlePermissionReturn,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$('[data-ajax]').each(function() {
|
$('[data-ajax]').each(function() {
|
||||||
var $this = $(this),
|
const $this = $(this);
|
||||||
ajax = $this.attr('data-ajax');
|
const ajax = $this.attr('data-ajax');
|
||||||
|
|
||||||
if (ajax !== 'false') {
|
if (ajax !== 'false') {
|
||||||
var fn = (ajax !== 'true') ? ajax : null;
|
const fn = (ajax === 'true') ? null : ajax;
|
||||||
phpbb.ajaxify({
|
phpbb.ajaxify({
|
||||||
selector: this,
|
selector: this,
|
||||||
refresh: $this.attr('data-refresh') !== undefined,
|
refresh: $this.attr('data-refresh') !== undefined,
|
||||||
callback: fn
|
callback: fn,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically resize textarea
|
* Automatically resize textarea
|
||||||
*/
|
*/
|
||||||
$(function() {
|
$(() => {
|
||||||
phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), {minHeight: 75});
|
phpbb.resizeTextArea($('textarea:not(.no-auto-resize)'), { minHeight: 75 });
|
||||||
|
|
||||||
var $setPermissionsForm = $('form#set-permissions');
|
const $setPermissionsForm = $('form#set-permissions');
|
||||||
if ($setPermissionsForm.length) {
|
if ($setPermissionsForm.length) {
|
||||||
$setPermissionsForm.on('submit', function (e) {
|
$setPermissionsForm.on('submit', e => {
|
||||||
submitPermissions();
|
submitPermissions();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
@ -412,13 +411,11 @@ $(function() {
|
||||||
} else {
|
} else {
|
||||||
dateoptionInput.value = this.value;
|
dateoptionInput.value = this.value;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('#acp_help_phpbb')) {
|
if ($('#acp_help_phpbb')) {
|
||||||
phpbb.prepareSendStats();
|
phpbb.prepareSendStats();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
})(jQuery); // Avoid conflicts with other libraries
|
})(jQuery); // Avoid conflicts with other libraries
|
||||||
|
|
|
@ -1,24 +1,26 @@
|
||||||
/* global phpbb */
|
/* global phpbb */
|
||||||
|
/* eslint camelcase: 0 */
|
||||||
|
/* eslint no-undef: 0 */
|
||||||
|
/* eslint no-unused-vars: 0 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide and show all checkboxes
|
* Hide and show all checkboxes
|
||||||
* status = true (show boxes), false (hide boxes)
|
* status = true (show boxes), false (hide boxes)
|
||||||
*/
|
*/
|
||||||
function display_checkboxes(status) {
|
function display_checkboxes(status) {
|
||||||
var form = document.getElementById('set-permissions');
|
const form = document.getElementById('set-permissions');
|
||||||
var cb = document.getElementsByTagName('input');
|
const cb = document.getElementsByTagName('input');
|
||||||
var display;
|
let display;
|
||||||
|
|
||||||
//show
|
|
||||||
if (status) {
|
if (status) {
|
||||||
|
// show
|
||||||
display = 'inline';
|
display = 'inline';
|
||||||
}
|
} else {
|
||||||
//hide
|
// hide
|
||||||
else {
|
|
||||||
display = 'none';
|
display = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < cb.length; i++ ) {
|
for (let i = 0; i < cb.length; i++ ) {
|
||||||
if (cb[i].className === 'permissions-checkbox') {
|
if (cb[i].className === 'permissions-checkbox') {
|
||||||
cb[i].style.display = display;
|
cb[i].style.display = display;
|
||||||
}
|
}
|
||||||
|
@ -31,10 +33,10 @@ function display_checkboxes(status) {
|
||||||
* value = 0 (hidden) till 10 (fully visible)
|
* value = 0 (hidden) till 10 (fully visible)
|
||||||
*/
|
*/
|
||||||
function set_opacity(e, value) {
|
function set_opacity(e, value) {
|
||||||
e.style.opacity = value/10;
|
e.style.opacity = value / 10;
|
||||||
|
|
||||||
//IE opacity currently turned off, because of its astronomical stupidity
|
// IE opacity currently turned off, because of its astronomical stupidity
|
||||||
//e.style.filter = 'alpha(opacity=' + value*10 + ')';
|
// e.style.filter = 'alpha(opacity=' + value*10 + ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,8 +44,8 @@ function set_opacity(e, value) {
|
||||||
* block_id = id of the element that needs to be toggled
|
* block_id = id of the element that needs to be toggled
|
||||||
*/
|
*/
|
||||||
function toggle_opacity(block_id) {
|
function toggle_opacity(block_id) {
|
||||||
var cb = document.getElementById('checkbox' + block_id);
|
const cb = document.getElementById('checkbox' + block_id);
|
||||||
var fs = document.getElementById('perm' + block_id);
|
const fs = document.getElementById('perm' + block_id);
|
||||||
|
|
||||||
if (cb.checked) {
|
if (cb.checked) {
|
||||||
set_opacity(fs, 5);
|
set_opacity(fs, 5);
|
||||||
|
@ -58,25 +60,25 @@ function toggle_opacity(block_id) {
|
||||||
* except_id = id of the element not to hide
|
* except_id = id of the element not to hide
|
||||||
*/
|
*/
|
||||||
function reset_opacity(status, except_id) {
|
function reset_opacity(status, except_id) {
|
||||||
var perm = document.getElementById('set-permissions');
|
const perm = document.getElementById('set-permissions');
|
||||||
var fs = perm.getElementsByTagName('fieldset');
|
const fs = perm.getElementsByTagName('fieldset');
|
||||||
var opacity = 5;
|
let opacity = 5;
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
opacity = 10;
|
opacity = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < fs.length; i++ ) {
|
for (let i = 0; i < fs.length; i++ ) {
|
||||||
if (fs[i].className !== 'quick') {
|
if (fs[i].className !== 'quick') {
|
||||||
set_opacity(fs[i], opacity);
|
set_opacity(fs[i], opacity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof(except_id) !== 'undefined') {
|
if (typeof (except_id) !== 'undefined') {
|
||||||
set_opacity(document.getElementById('perm' + except_id), 10);
|
set_opacity(document.getElementById('perm' + except_id), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
//reset checkboxes too
|
// reset checkboxes too
|
||||||
marklist('set-permissions', 'inherit', !status);
|
marklist('set-permissions', 'inherit', !status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,13 +88,14 @@ function reset_opacity(status, except_id) {
|
||||||
* rb = array of radiobuttons
|
* rb = array of radiobuttons
|
||||||
*/
|
*/
|
||||||
function get_radio_status(index, rb) {
|
function get_radio_status(index, rb) {
|
||||||
for (var i = index; i < rb.length; i = i + 3 ) {
|
for (let i = index; i < rb.length; i += 3 ) {
|
||||||
if (rb[i].checked !== true) {
|
if (rb[i].checked !== true) {
|
||||||
if (i > index) {
|
if (i > index) {
|
||||||
//at least one is true, but not all (custom)
|
// at least one is true, but not all (custom)
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
//first one is not true
|
|
||||||
|
// first one is not true
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,18 +111,18 @@ function get_radio_status(index, rb) {
|
||||||
* quick = If no calculation needed, this contains the colour
|
* quick = If no calculation needed, this contains the colour
|
||||||
*/
|
*/
|
||||||
function set_colours(id, init, quick) {
|
function set_colours(id, init, quick) {
|
||||||
var table = document.getElementById('table' + id);
|
const table = document.getElementById('table' + id);
|
||||||
var tab = document.getElementById('tab' + id);
|
const tab = document.getElementById('tab' + id);
|
||||||
|
|
||||||
if (typeof(quick) !== 'undefined') {
|
if (typeof (quick) !== 'undefined') {
|
||||||
tab.className = 'permissions-preset-' + quick + ' activetab';
|
tab.className = 'permissions-preset-' + quick + ' activetab';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rb = table.getElementsByTagName('input');
|
const rb = table.getElementsByTagName('input');
|
||||||
var colour = 'custom';
|
let colour = 'custom';
|
||||||
|
|
||||||
var status = get_radio_status(0, rb);
|
let status = get_radio_status(0, rb);
|
||||||
|
|
||||||
if (status === 1) {
|
if (status === 1) {
|
||||||
colour = 'yes';
|
colour = 'yes';
|
||||||
|
@ -151,17 +154,17 @@ function set_colours(id, init, quick) {
|
||||||
* block_id = block that is opened
|
* block_id = block that is opened
|
||||||
*/
|
*/
|
||||||
function init_colours(block_id) {
|
function init_colours(block_id) {
|
||||||
var block = document.getElementById('advanced' + block_id);
|
const block = document.getElementById('advanced' + block_id);
|
||||||
var panels = block.getElementsByTagName('div');
|
const panels = block.getElementsByTagName('div');
|
||||||
var tab = document.getElementById('tab' + id);
|
const tab = document.getElementById('tab' + id);
|
||||||
|
|
||||||
for (var i = 0; i < panels.length; i++) {
|
for (let i = 0; i < panels.length; i++) {
|
||||||
if (panels[i].className === 'permissions-panel') {
|
if (panels[i].className === 'permissions-panel') {
|
||||||
set_colours(panels[i].id.replace(/options/, ''), true);
|
set_colours(panels[i].id.replace(/options/, ''), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tab.className = tab.className + ' activetab';
|
tab.className += ' activetab';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,13 +173,14 @@ function init_colours(block_id) {
|
||||||
* adv = we are opening advanced permissions
|
* adv = we are opening advanced permissions
|
||||||
* view = called from view permissions
|
* view = called from view permissions
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line max-params
|
||||||
function swap_options(pmask, fmask, cat, adv, view) {
|
function swap_options(pmask, fmask, cat, adv, view) {
|
||||||
id = pmask + fmask + cat;
|
id = pmask + fmask + cat;
|
||||||
active_option = active_pmask + active_fmask + active_cat;
|
active_option = active_pmask + active_fmask + active_cat;
|
||||||
|
|
||||||
var old_tab = document.getElementById('tab' + active_option);
|
const old_tab = document.getElementById('tab' + active_option);
|
||||||
var new_tab = document.getElementById('tab' + id);
|
const new_tab = document.getElementById('tab' + id);
|
||||||
var adv_block = document.getElementById('advanced' + pmask + fmask);
|
const adv_block = document.getElementById('advanced' + pmask + fmask);
|
||||||
|
|
||||||
if (adv_block.style.display === 'block' && adv === true) {
|
if (adv_block.style.display === 'block' && adv === true) {
|
||||||
phpbb.toggleDisplay('advanced' + pmask + fmask, -1);
|
phpbb.toggleDisplay('advanced' + pmask + fmask, -1);
|
||||||
|
@ -196,14 +200,14 @@ function swap_options(pmask, fmask, cat, adv, view) {
|
||||||
display_checkboxes(true);
|
display_checkboxes(true);
|
||||||
reset_opacity(1);
|
reset_opacity(1);
|
||||||
} else if (adv) {
|
} else if (adv) {
|
||||||
//Checkbox might have been clicked, but we need full visibility
|
// Checkbox might have been clicked, but we need full visibility
|
||||||
display_checkboxes(true);
|
display_checkboxes(true);
|
||||||
reset_opacity(1);
|
reset_opacity(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// set active tab
|
// set active tab
|
||||||
old_tab.className = old_tab.className.replace(/\ activetab/g, '');
|
old_tab.className = old_tab.className.replace(/ activetab/g, '');
|
||||||
new_tab.className = new_tab.className + ' activetab';
|
new_tab.className += ' activetab';
|
||||||
|
|
||||||
if (id === active_option && adv !== true) {
|
if (id === active_option && adv !== true) {
|
||||||
return;
|
return;
|
||||||
|
@ -211,7 +215,7 @@ function swap_options(pmask, fmask, cat, adv, view) {
|
||||||
|
|
||||||
phpbb.toggleDisplay('options' + active_option, -1);
|
phpbb.toggleDisplay('options' + active_option, -1);
|
||||||
|
|
||||||
//hiding and showing the checkbox
|
// hiding and showing the checkbox
|
||||||
if (document.getElementById('checkbox' + active_pmask + active_fmask)) {
|
if (document.getElementById('checkbox' + active_pmask + active_fmask)) {
|
||||||
phpbb.toggleDisplay('checkbox' + pmask + fmask, -1);
|
phpbb.toggleDisplay('checkbox' + pmask + fmask, -1);
|
||||||
|
|
||||||
|
@ -227,6 +231,7 @@ function swap_options(pmask, fmask, cat, adv, view) {
|
||||||
if (!view) {
|
if (!view) {
|
||||||
phpbb.toggleDisplay('advanced' + pmask + fmask, 1);
|
phpbb.toggleDisplay('advanced' + pmask + fmask, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
phpbb.toggleDisplay('options' + id, 1);
|
phpbb.toggleDisplay('options' + id, 1);
|
||||||
|
|
||||||
active_pmask = pmask;
|
active_pmask = pmask;
|
||||||
|
@ -239,32 +244,32 @@ function swap_options(pmask, fmask, cat, adv, view) {
|
||||||
* id = table ID container, s = status ['y'/'u'/'n']
|
* id = table ID container, s = status ['y'/'u'/'n']
|
||||||
*/
|
*/
|
||||||
function mark_options(id, s) {
|
function mark_options(id, s) {
|
||||||
var t = document.getElementById(id);
|
const t = document.getElementById(id);
|
||||||
|
|
||||||
if (!t) {
|
if (!t) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rb = t.getElementsByTagName('input');
|
const rb = t.getElementsByTagName('input');
|
||||||
|
|
||||||
for (var r = 0; r < rb.length; r++) {
|
for (let r = 0; r < rb.length; r++) {
|
||||||
if (rb[r].id.substr(rb[r].id.length-1) === s) {
|
if (rb[r].id.substr(rb[r].id.length - 1) === s) {
|
||||||
rb[r].checked = true;
|
rb[r].checked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mark_one_option(id, field_name, s) {
|
function mark_one_option(id, field_name, s) {
|
||||||
var t = document.getElementById(id);
|
const t = document.getElementById(id);
|
||||||
|
|
||||||
if (!t) {
|
if (!t) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rb = t.getElementsByTagName('input');
|
const rb = t.getElementsByTagName('input');
|
||||||
|
|
||||||
for (var r = 0; r < rb.length; r++) {
|
for (let r = 0; r < rb.length; r++) {
|
||||||
if (rb[r].id.substr(rb[r].id.length-field_name.length-3, field_name.length) === field_name && rb[r].id.substr(rb[r].id.length-1) === s) {
|
if (rb[r].id.substr(rb[r].id.length - field_name.length - 3, field_name.length) === field_name && rb[r].id.substr(rb[r].id.length - 1) === s) {
|
||||||
rb[r].checked = true;
|
rb[r].checked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -280,21 +285,21 @@ function mark_one_option(id, field_name, s) {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function reset_role(id) {
|
function reset_role(id) {
|
||||||
var t = document.getElementById(id);
|
const t = document.getElementById(id);
|
||||||
|
|
||||||
if (!t) {
|
if (!t) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Before resetting the role dropdown, try and match any permission role
|
// Before resetting the role dropdown, try and match any permission role
|
||||||
var parent = t.parentNode,
|
const parent = t.parentNode;
|
||||||
roleId = match_role_settings(id.replace('role', 'perm')),
|
const roleId = match_role_settings(id.replace('role', 'perm'));
|
||||||
text = no_role_assigned,
|
let text = no_role_assigned;
|
||||||
index = 0;
|
let index = 0;
|
||||||
|
|
||||||
// If a role permissions was matched, grab that option's value and index
|
// If a role permissions was matched, grab that option's value and index
|
||||||
if (roleId) {
|
if (roleId) {
|
||||||
for (var i = 0; i < t.options.length; i++) {
|
for (let i = 0; i < t.options.length; i++) {
|
||||||
if (parseInt(t.options[i].value, 10) === roleId) {
|
if (parseInt(t.options[i].value, 10) === roleId) {
|
||||||
text = t.options[i].text;
|
text = t.options[i].text;
|
||||||
index = i;
|
index = i;
|
||||||
|
@ -316,7 +321,7 @@ function reset_role(id) {
|
||||||
* Load role and set options accordingly
|
* Load role and set options accordingly
|
||||||
*/
|
*/
|
||||||
function set_role_settings(role_id, target_id) {
|
function set_role_settings(role_id, target_id) {
|
||||||
var settings = role_options[role_id];
|
const settings = role_options[role_id];
|
||||||
|
|
||||||
if (!settings) {
|
if (!settings) {
|
||||||
return;
|
return;
|
||||||
|
@ -325,9 +330,11 @@ function set_role_settings(role_id, target_id) {
|
||||||
// Mark all options to no (unset) first...
|
// Mark all options to no (unset) first...
|
||||||
mark_options(target_id, 'u');
|
mark_options(target_id, 'u');
|
||||||
|
|
||||||
for (var r in settings) {
|
for (const r in settings) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(settings, r)) {
|
||||||
mark_one_option(target_id, r, (settings[r] === 1) ? 'y' : 'n');
|
mark_one_option(target_id, r, (settings[r] === 1) ? 'y' : 'n');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -337,13 +344,13 @@ function set_role_settings(role_id, target_id) {
|
||||||
* @return {number} The permission role identifier
|
* @return {number} The permission role identifier
|
||||||
*/
|
*/
|
||||||
function match_role_settings(id) {
|
function match_role_settings(id) {
|
||||||
var fieldset = document.getElementById(id),
|
const fieldset = document.getElementById(id);
|
||||||
radios = fieldset.getElementsByTagName('input'),
|
const radios = fieldset.getElementsByTagName('input');
|
||||||
set = {};
|
let set = {};
|
||||||
|
|
||||||
// Iterate over all the radio buttons
|
// Iterate over all the radio buttons
|
||||||
for (var i = 0; i < radios.length; i++) {
|
for (let i = 0; i < radios.length; i++) {
|
||||||
var matches = radios[i].id.match(/setting\[\d+]\[\d+]\[([a-z_]+)]/);
|
const matches = radios[i].id.match(/setting\[\d+]\[\d+]\[([a-z_]+)]/);
|
||||||
|
|
||||||
// Make sure the name attribute matches, the radio is checked and it is not the "No" (-1) value.
|
// Make sure the name attribute matches, the radio is checked and it is not the "No" (-1) value.
|
||||||
if (matches !== null && radios[i].checked && radios[i].value !== '-1') {
|
if (matches !== null && radios[i].checked && radios[i].value !== '-1') {
|
||||||
|
@ -355,8 +362,7 @@ function match_role_settings(id) {
|
||||||
set = sort_and_stringify(set);
|
set = sort_and_stringify(set);
|
||||||
|
|
||||||
// Iterate over the available role options and return the first match
|
// Iterate over the available role options and return the first match
|
||||||
for (var r in role_options)
|
for (const r in role_options) {
|
||||||
{
|
|
||||||
if (sort_and_stringify(role_options[r]) === set) {
|
if (sort_and_stringify(role_options[r]) === set) {
|
||||||
return parseInt(r, 10);
|
return parseInt(r, 10);
|
||||||
}
|
}
|
||||||
|
@ -372,7 +378,7 @@ function match_role_settings(id) {
|
||||||
* @return {string} The sorted object as a string
|
* @return {string} The sorted object as a string
|
||||||
*/
|
*/
|
||||||
function sort_and_stringify(obj) {
|
function sort_and_stringify(obj) {
|
||||||
return JSON.stringify(Object.keys(obj).sort().reduce(function (result, key) {
|
return JSON.stringify(Object.keys(obj).sort().reduce((result, key) => {
|
||||||
result[key] = obj[key];
|
result[key] = obj[key];
|
||||||
return result;
|
return result;
|
||||||
}, {}));
|
}, {}));
|
||||||
|
|
|
@ -13,37 +13,36 @@ phpBB Development Team:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function($) { // Avoid conflicts with other libraries
|
(function($) { // Avoid conflicts with other libraries
|
||||||
|
'use strict';
|
||||||
|
|
||||||
'use strict';
|
const tooltips = [];
|
||||||
|
|
||||||
var tooltips = [];
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable tooltip replacements for selects
|
* Enable tooltip replacements for selects
|
||||||
* @param {string} id ID tag of select
|
* @param {string} id ID tag of select
|
||||||
* @param {string} headline Text that should appear on top of tooltip
|
* @param {string} headline Text that should appear on top of tooltip
|
||||||
* @param {string} [subId] Sub ID that should only be using tooltips (optional)
|
* @param {string} [subId] Sub ID that should only be using tooltips (optional)
|
||||||
*/
|
*/
|
||||||
phpbb.enableTooltipsSelect = function (id, headline, subId) {
|
phpbb.enableTooltipsSelect = function(id, headline, subId) {
|
||||||
var $links, hold;
|
let $links;
|
||||||
|
|
||||||
hold = $('<span />', {
|
const hold = $('<span />', {
|
||||||
id: '_tooltip_container',
|
id: '_tooltip_container',
|
||||||
css: {
|
css: {
|
||||||
position: 'absolute'
|
position: 'absolute',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').append(hold);
|
$('body').append(hold);
|
||||||
|
|
||||||
if (!id) {
|
if (id) {
|
||||||
$links = $('.roles-options li');
|
|
||||||
} else {
|
|
||||||
$links = $('.roles-options li', '#' + id);
|
$links = $('.roles-options li', '#' + id);
|
||||||
|
} else {
|
||||||
|
$links = $('.roles-options li');
|
||||||
}
|
}
|
||||||
|
|
||||||
$links.each(function () {
|
$links.each(function() {
|
||||||
var $this = $(this);
|
const $this = $(this);
|
||||||
|
|
||||||
if (subId) {
|
if (subId) {
|
||||||
if ($this.parent().attr('id').substr(0, subId.length) === subId) {
|
if ($this.parent().attr('id').substr(0, subId.length) === subId) {
|
||||||
|
@ -53,44 +52,42 @@ phpbb.enableTooltipsSelect = function (id, headline, subId) {
|
||||||
phpbb.prepareTooltips($this, headline);
|
phpbb.prepareTooltips($this, headline);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare elements to replace
|
* Prepare elements to replace
|
||||||
*
|
*
|
||||||
* @param {jQuery} $element Element to prepare for tooltips
|
* @param {jQuery} $element Element to prepare for tooltips
|
||||||
* @param {string} headText Text heading to display
|
* @param {string} headText Text heading to display
|
||||||
*/
|
*/
|
||||||
phpbb.prepareTooltips = function ($element, headText) {
|
phpbb.prepareTooltips = function($element, headText) {
|
||||||
var $tooltip, text, $desc, $title;
|
const text = $element.attr('data-title');
|
||||||
|
|
||||||
text = $element.attr('data-title');
|
|
||||||
|
|
||||||
if (text === null || text.length === 0) {
|
if (text === null || text.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = $('<span />', {
|
const $title = $('<span />', {
|
||||||
class: 'top',
|
class: 'top',
|
||||||
css: {
|
css: {
|
||||||
display: 'block'
|
display: 'block',
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
.append(document.createTextNode(headText));
|
.append(document.createTextNode(headText));
|
||||||
|
|
||||||
$desc = $('<span />', {
|
const $desc = $('<span />', {
|
||||||
class: 'bottom',
|
class: 'bottom',
|
||||||
html: text,
|
html: text,
|
||||||
css: {
|
css: {
|
||||||
display: 'block'
|
display: 'block',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
$tooltip = $('<span />', {
|
const $tooltip = $('<span />', {
|
||||||
class: 'tooltip',
|
class: 'tooltip',
|
||||||
css: {
|
css: {
|
||||||
display: 'block'
|
display: 'block',
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
.append($title)
|
.append($title)
|
||||||
.append($desc);
|
.append($desc);
|
||||||
|
@ -98,64 +95,62 @@ phpbb.prepareTooltips = function ($element, headText) {
|
||||||
tooltips[$element.attr('data-id')] = $tooltip;
|
tooltips[$element.attr('data-id')] = $tooltip;
|
||||||
$element.on('mouseover', phpbb.showTooltip);
|
$element.on('mouseover', phpbb.showTooltip);
|
||||||
$element.on('mouseout', phpbb.hideTooltip);
|
$element.on('mouseout', phpbb.hideTooltip);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show tooltip
|
* Show tooltip
|
||||||
*
|
*
|
||||||
* @param {object} $element Element passed by .on()
|
* @param {object} $element Element passed by .on()
|
||||||
*/
|
*/
|
||||||
phpbb.showTooltip = function ($element) {
|
phpbb.showTooltip = function($element) {
|
||||||
var $this = $($element.target);
|
const $this = $($element.target);
|
||||||
$('#_tooltip_container').append(tooltips[$this.attr('data-id')]);
|
$('#_tooltip_container').append(tooltips[$this.attr('data-id')]);
|
||||||
phpbb.positionTooltip($this);
|
phpbb.positionTooltip($this);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide tooltip
|
* Hide tooltip
|
||||||
*/
|
*/
|
||||||
phpbb.hideTooltip = function () {
|
phpbb.hideTooltip = function() {
|
||||||
var d = document.getElementById('_tooltip_container');
|
const d = document.getElementById('_tooltip_container');
|
||||||
if (d.childNodes.length > 0) {
|
if (d.childNodes.length > 0) {
|
||||||
d.removeChild(d.firstChild);
|
d.removeChild(d.firstChild);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Correct positioning of tooltip container
|
* Correct positioning of tooltip container
|
||||||
*
|
*
|
||||||
* @param {jQuery} $element Tooltip element that should be positioned
|
* @param {jQuery} $element Tooltip element that should be positioned
|
||||||
*/
|
*/
|
||||||
phpbb.positionTooltip = function ($element) {
|
phpbb.positionTooltip = function($element) {
|
||||||
var offset;
|
|
||||||
|
|
||||||
$element = $element.parent();
|
$element = $element.parent();
|
||||||
offset = $element.offset();
|
const offset = $element.offset();
|
||||||
|
|
||||||
if ($('body').hasClass('rtl')) {
|
if ($('body').hasClass('rtl')) {
|
||||||
$('#_tooltip_container').css({
|
$('#_tooltip_container').css({
|
||||||
top: offset.top + 30,
|
top: offset.top + 30,
|
||||||
left: offset.left + 255
|
left: offset.left + 255,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$('#_tooltip_container').css({
|
$('#_tooltip_container').css({
|
||||||
top: offset.top + 30,
|
top: offset.top + 30,
|
||||||
left: offset.left - 205
|
left: offset.left - 205,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare roles drop down select
|
* Prepare roles drop down select
|
||||||
*/
|
*/
|
||||||
phpbb.prepareRolesDropdown = function () {
|
phpbb.prepareRolesDropdown = function() {
|
||||||
var $options = $('.roles-options li');
|
const $options = $('.roles-options li');
|
||||||
|
|
||||||
// Display span and hide select
|
// Display span and hide select
|
||||||
$('.roles-options > span').css('display', 'block');
|
$('.roles-options > span').css('display', 'block');
|
||||||
$('.roles-options > select').hide();
|
$('.roles-options > select').hide();
|
||||||
$('.roles-options > input[type=hidden]').each(function () {
|
$('.roles-options > input[type=hidden]').each(function() {
|
||||||
var $this = $(this);
|
const $this = $(this);
|
||||||
|
|
||||||
if ($this.attr('data-name') && !$this.attr('name')) {
|
if ($this.attr('data-name') && !$this.attr('name')) {
|
||||||
$this.attr('name', $this.attr('data-name'));
|
$this.attr('name', $this.attr('data-name'));
|
||||||
|
@ -163,10 +158,10 @@ phpbb.prepareRolesDropdown = function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Prepare highlighting of select options and settings update
|
// Prepare highlighting of select options and settings update
|
||||||
$options.each(function () {
|
$options.each(function() {
|
||||||
var $this = $(this);
|
const $this = $(this);
|
||||||
var $rolesOptions = $this.closest('.roles-options');
|
const $rolesOptions = $this.closest('.roles-options');
|
||||||
var $span = $rolesOptions.children('span');
|
const $span = $rolesOptions.children('span');
|
||||||
|
|
||||||
// Correctly show selected option
|
// Correctly show selected option
|
||||||
if (typeof $this.attr('data-selected') !== 'undefined') {
|
if (typeof $this.attr('data-selected') !== 'undefined') {
|
||||||
|
@ -182,23 +177,25 @@ phpbb.prepareRolesDropdown = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare resetting drop down on form reset
|
// Prepare resetting drop down on form reset
|
||||||
$this.closest('form').on('reset', function () {
|
$this.closest('form').on('reset', () => {
|
||||||
$span.text($span.attr('data-default'));
|
$span.text($span.attr('data-default'));
|
||||||
$rolesOptions.children('input[type=hidden]')
|
$rolesOptions.children('input[type=hidden]')
|
||||||
.val($span.attr('data-default-val'));
|
.val($span.attr('data-default-val'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$this.on('mouseover', function () {
|
$this.on('mouseover', function() {
|
||||||
var $this = $(this);
|
const $this = $(this);
|
||||||
$options.removeClass('roles-highlight');
|
$options.removeClass('roles-highlight');
|
||||||
$this.addClass('roles-highlight');
|
$this.addClass('roles-highlight');
|
||||||
}).on('click', function () {
|
}).on('click', function() {
|
||||||
var $this = $(this);
|
const $this = $(this);
|
||||||
var $rolesOptions = $this.closest('.roles-options');
|
const $rolesOptions = $this.closest('.roles-options');
|
||||||
|
|
||||||
// Update settings
|
// Update settings
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
set_role_settings($this.attr('data-id'), $this.attr('data-target-id'));
|
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', ''));
|
init_colours($this.attr('data-target-id').replace('advanced', ''));
|
||||||
|
|
||||||
// Set selected setting
|
// Set selected setting
|
||||||
|
@ -211,15 +208,14 @@ phpbb.prepareRolesDropdown = function () {
|
||||||
$('body').trigger('click');
|
$('body').trigger('click');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Run onload functions for RolesDropdown and tooltips
|
// Run onload functions for RolesDropdown and tooltips
|
||||||
$(function() {
|
$(() => {
|
||||||
// Enable tooltips
|
// Enable tooltips
|
||||||
phpbb.enableTooltipsSelect('set-permissions', $('#set-permissions').attr('data-role-description'), 'role');
|
phpbb.enableTooltipsSelect('set-permissions', $('#set-permissions').attr('data-role-description'), 'role');
|
||||||
|
|
||||||
// Prepare dropdown
|
// Prepare dropdown
|
||||||
phpbb.prepareRolesDropdown();
|
phpbb.prepareRolesDropdown();
|
||||||
});
|
});
|
||||||
|
|
||||||
})(jQuery); // Avoid conflicts with other libraries
|
})(jQuery); // Avoid conflicts with other libraries
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,7 @@
|
||||||
/* global phpbb */
|
/* global phpbb */
|
||||||
|
/* eslint camelcase: 0 */
|
||||||
|
/* eslint no-undef: 0 */
|
||||||
|
/* eslint no-unused-vars: 0 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bbCode control by subBlue design [ www.subBlue.com ]
|
* bbCode control by subBlue design [ www.subBlue.com ]
|
||||||
|
@ -6,25 +9,25 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Startup variables
|
// Startup variables
|
||||||
var imageTag = false;
|
const imageTag = false;
|
||||||
var theSelection = false;
|
let theSelection = false;
|
||||||
var bbcodeEnabled = true;
|
const bbcodeEnabled = true;
|
||||||
|
|
||||||
// Check for Browser & Platform for PC & IE specific bits
|
// Check for Browser & Platform for PC & IE specific bits
|
||||||
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
|
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
|
||||||
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
|
const clientPC = navigator.userAgent.toLowerCase(); // Get client info
|
||||||
var clientVer = parseInt(navigator.appVersion, 10); // Get browser version
|
const clientVer = parseInt(navigator.appVersion, 10); // Get browser version
|
||||||
|
|
||||||
var is_ie = ((clientPC.indexOf('msie') !== -1) && (clientPC.indexOf('opera') === -1));
|
const is_ie = ((clientPC.indexOf('msie') !== -1) && (clientPC.indexOf('opera') === -1));
|
||||||
var is_win = ((clientPC.indexOf('win') !== -1) || (clientPC.indexOf('16bit') !== -1));
|
const is_win = ((clientPC.indexOf('win') !== -1) || (clientPC.indexOf('16bit') !== -1));
|
||||||
var baseHeight;
|
let baseHeight;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fix a bug involving the TextRange object. From
|
* Fix a bug involving the TextRange object. From
|
||||||
* http://www.frostjedi.com/terra/scripts/demo/caretBug.html
|
* http://www.frostjedi.com/terra/scripts/demo/caretBug.html
|
||||||
*/
|
*/
|
||||||
function initInsertions() {
|
function initInsertions() {
|
||||||
var doc;
|
let doc;
|
||||||
|
|
||||||
if (document.forms[form_name]) {
|
if (document.forms[form_name]) {
|
||||||
doc = document;
|
doc = document;
|
||||||
|
@ -32,9 +35,9 @@ function initInsertions() {
|
||||||
doc = opener.document;
|
doc = opener.document;
|
||||||
}
|
}
|
||||||
|
|
||||||
var textarea = doc.forms[form_name].elements[text_name];
|
const textarea = doc.forms[form_name].elements[text_name];
|
||||||
|
|
||||||
if (is_ie && typeof(baseHeight) !== 'number') {
|
if (is_ie && typeof (baseHeight) !== 'number') {
|
||||||
textarea.focus();
|
textarea.focus();
|
||||||
baseHeight = doc.selection.createRange().duplicate().boundingHeight;
|
baseHeight = doc.selection.createRange().duplicate().boundingHeight;
|
||||||
|
|
||||||
|
@ -48,11 +51,11 @@ function initInsertions() {
|
||||||
* bbstyle
|
* bbstyle
|
||||||
*/
|
*/
|
||||||
function bbstyle(bbnumber) {
|
function bbstyle(bbnumber) {
|
||||||
if (bbnumber !== -1) {
|
if (bbnumber === -1) {
|
||||||
bbfontstyle(bbtags[bbnumber], bbtags[bbnumber+1]);
|
|
||||||
} else {
|
|
||||||
insert_text('[*]');
|
insert_text('[*]');
|
||||||
document.forms[form_name].elements[text_name].focus();
|
document.forms[form_name].elements[text_name].focus();
|
||||||
|
} else {
|
||||||
|
bbfontstyle(bbtags[bbnumber], bbtags[bbnumber + 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +65,7 @@ function bbstyle(bbnumber) {
|
||||||
function bbfontstyle(bbopen, bbclose) {
|
function bbfontstyle(bbopen, bbclose) {
|
||||||
theSelection = false;
|
theSelection = false;
|
||||||
|
|
||||||
var textarea = document.forms[form_name].elements[text_name];
|
const textarea = document.forms[form_name].elements[text_name];
|
||||||
|
|
||||||
textarea.focus();
|
textarea.focus();
|
||||||
|
|
||||||
|
@ -84,9 +87,9 @@ function bbfontstyle(bbopen, bbclose) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//The new position for the cursor after adding the bbcode
|
// The new position for the cursor after adding the bbcode
|
||||||
var caret_pos = getCaretPosition(textarea).start;
|
const caret_pos = getCaretPosition(textarea).start;
|
||||||
var new_pos = caret_pos + bbopen.length;
|
const new_pos = caret_pos + bbopen.length;
|
||||||
|
|
||||||
// Open tag
|
// Open tag
|
||||||
insert_text(bbopen + bbclose);
|
insert_text(bbopen + bbclose);
|
||||||
|
@ -96,11 +99,10 @@ function bbfontstyle(bbopen, bbclose) {
|
||||||
if (!isNaN(textarea.selectionStart)) {
|
if (!isNaN(textarea.selectionStart)) {
|
||||||
textarea.selectionStart = new_pos;
|
textarea.selectionStart = new_pos;
|
||||||
textarea.selectionEnd = new_pos;
|
textarea.selectionEnd = new_pos;
|
||||||
}
|
} else if (document.selection) {
|
||||||
// IE
|
// IE
|
||||||
else if (document.selection) {
|
const range = textarea.createTextRange();
|
||||||
var range = textarea.createTextRange();
|
range.move('character', new_pos);
|
||||||
range.move("character", new_pos);
|
|
||||||
range.select();
|
range.select();
|
||||||
storeCaret(textarea);
|
storeCaret(textarea);
|
||||||
}
|
}
|
||||||
|
@ -112,12 +114,12 @@ function bbfontstyle(bbopen, bbclose) {
|
||||||
* Insert text at position
|
* Insert text at position
|
||||||
*/
|
*/
|
||||||
function insert_text(text, spaces, popup) {
|
function insert_text(text, spaces, popup) {
|
||||||
var textarea;
|
let textarea;
|
||||||
|
|
||||||
if (!popup) {
|
if (popup) {
|
||||||
textarea = document.forms[form_name].elements[text_name];
|
|
||||||
} else {
|
|
||||||
textarea = opener.document.forms[form_name].elements[text_name];
|
textarea = opener.document.forms[form_name].elements[text_name];
|
||||||
|
} else {
|
||||||
|
textarea = document.forms[form_name].elements[text_name];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spaces) {
|
if (spaces) {
|
||||||
|
@ -127,8 +129,8 @@ function insert_text(text, spaces, popup) {
|
||||||
// Since IE9, IE also has textarea.selectionStart, but it still needs to be treated the old way.
|
// Since IE9, IE also has textarea.selectionStart, but it still needs to be treated the old way.
|
||||||
// Therefore we simply add a !is_ie here until IE fixes the text-selection completely.
|
// Therefore we simply add a !is_ie here until IE fixes the text-selection completely.
|
||||||
if (!isNaN(textarea.selectionStart) && !is_ie) {
|
if (!isNaN(textarea.selectionStart) && !is_ie) {
|
||||||
var sel_start = textarea.selectionStart;
|
const sel_start = textarea.selectionStart;
|
||||||
var sel_end = textarea.selectionEnd;
|
const sel_end = textarea.selectionEnd;
|
||||||
|
|
||||||
mozWrap(textarea, text, '');
|
mozWrap(textarea, text, '');
|
||||||
textarea.selectionStart = sel_start + text.length;
|
textarea.selectionStart = sel_start + text.length;
|
||||||
|
@ -139,10 +141,10 @@ function insert_text(text, spaces, popup) {
|
||||||
storeCaret(textarea);
|
storeCaret(textarea);
|
||||||
}
|
}
|
||||||
|
|
||||||
var caret_pos = textarea.caretPos;
|
const caret_pos = textarea.caretPos;
|
||||||
caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) === ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
|
caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) === ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
|
||||||
} else {
|
} else {
|
||||||
textarea.value = textarea.value + text;
|
textarea.value += text;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!popup) {
|
if (!popup) {
|
||||||
|
@ -162,15 +164,16 @@ function attachInline(index, filename) {
|
||||||
* Add quote text to message
|
* Add quote text to message
|
||||||
*/
|
*/
|
||||||
function addquote(post_id, username, l_wrote, attributes) {
|
function addquote(post_id, username, l_wrote, attributes) {
|
||||||
var message_name = 'message_' + post_id;
|
const message_name = 'message_' + post_id;
|
||||||
var theSelection = '';
|
let theSelection = '';
|
||||||
var divarea = false;
|
let divarea = false;
|
||||||
var i;
|
let i;
|
||||||
|
|
||||||
if (l_wrote === undefined) {
|
if (l_wrote === undefined) {
|
||||||
// Backwards compatibility
|
// Backwards compatibility
|
||||||
l_wrote = 'wrote';
|
l_wrote = 'wrote';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof attributes !== 'object') {
|
if (typeof attributes !== 'object') {
|
||||||
attributes = {};
|
attributes = {};
|
||||||
}
|
}
|
||||||
|
@ -195,10 +198,10 @@ function addquote(post_id, username, l_wrote, attributes) {
|
||||||
if (divarea.innerHTML) {
|
if (divarea.innerHTML) {
|
||||||
theSelection = divarea.innerHTML.replace(/<br>/ig, '\n');
|
theSelection = divarea.innerHTML.replace(/<br>/ig, '\n');
|
||||||
theSelection = theSelection.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) {
|
} else if (document.all) {
|
||||||
theSelection = divarea.innerText;
|
theSelection = divarea.innerText;
|
||||||
} else if (divarea.textContent) {
|
} else if (divarea.textContent) {
|
||||||
|
@ -213,8 +216,8 @@ function addquote(post_id, username, l_wrote, attributes) {
|
||||||
attributes.author = username;
|
attributes.author = username;
|
||||||
insert_text(generateQuote(theSelection, attributes));
|
insert_text(generateQuote(theSelection, attributes));
|
||||||
} else {
|
} else {
|
||||||
insert_text(username + ' ' + l_wrote + ':' + '\n');
|
insert_text(username + ' ' + l_wrote + ':\n');
|
||||||
var lines = split_lines(theSelection);
|
const lines = split_lines(theSelection);
|
||||||
for (i = 0; i < lines.length; i++) {
|
for (i = 0; i < lines.length; i++) {
|
||||||
insert_text('> ' + lines[i] + '\n');
|
insert_text('> ' + lines[i] + '\n');
|
||||||
}
|
}
|
||||||
|
@ -237,20 +240,22 @@ function addquote(post_id, username, l_wrote, attributes) {
|
||||||
*/
|
*/
|
||||||
function generateQuote(text, attributes) {
|
function generateQuote(text, attributes) {
|
||||||
text = text.replace(/^\s+/, '').replace(/\s+$/, '');
|
text = text.replace(/^\s+/, '').replace(/\s+$/, '');
|
||||||
var quote = '[quote';
|
let quote = '[quote';
|
||||||
if (attributes.author) {
|
if (attributes.author) {
|
||||||
// Add the author as the BBCode's default attribute
|
// Add the author as the BBCode's default attribute
|
||||||
quote += '=' + formatAttributeValue(attributes.author);
|
quote += '=' + formatAttributeValue(attributes.author);
|
||||||
delete attributes.author;
|
delete attributes.author;
|
||||||
}
|
}
|
||||||
for (var name in attributes) {
|
|
||||||
if (attributes.hasOwnProperty(name)) {
|
for (const name in attributes) {
|
||||||
var value = attributes[name];
|
if (Object.hasOwn(attributes, name)) {
|
||||||
|
const value = attributes[name];
|
||||||
quote += ' ' + name + '=' + formatAttributeValue(value.toString());
|
quote += ' ' + name + '=' + formatAttributeValue(value.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
quote += ']';
|
quote += ']';
|
||||||
var newline = ((quote + text + '[/quote]').length > 80 || text.indexOf('\n') > -1) ? '\n' : '';
|
const newline = ((quote + text + '[/quote]').length > 80 || text.indexOf('\n') > -1) ? '\n' : '';
|
||||||
quote += newline + text + newline + '[/quote]';
|
quote += newline + text + newline + '[/quote]';
|
||||||
|
|
||||||
return quote;
|
return quote;
|
||||||
|
@ -271,25 +276,26 @@ function formatAttributeValue(str) {
|
||||||
// Return as-is if it contains none of: space, ' " \ or ]
|
// Return as-is if it contains none of: space, ' " \ or ]
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
var singleQuoted = "'" + str.replace(/[\\']/g, '\\$&') + "'",
|
|
||||||
doubleQuoted = '"' + str.replace(/[\\"]/g, '\\$&') + '"';
|
const singleQuoted = '\'' + str.replace(/[\\']/g, '\\$&') + '\'';
|
||||||
|
const doubleQuoted = '"' + str.replace(/[\\"]/g, '\\$&') + '"';
|
||||||
|
|
||||||
return (singleQuoted.length < doubleQuoted.length) ? singleQuoted : doubleQuoted;
|
return (singleQuoted.length < doubleQuoted.length) ? singleQuoted : doubleQuoted;
|
||||||
}
|
}
|
||||||
|
|
||||||
function split_lines(text) {
|
function split_lines(text) {
|
||||||
var lines = text.split('\n');
|
const lines = text.split('\n');
|
||||||
var splitLines = new Array();
|
const splitLines = [];
|
||||||
var j = 0;
|
let j = 0;
|
||||||
var i;
|
let i;
|
||||||
|
|
||||||
for(i = 0; i < lines.length; i++) {
|
for (i = 0; i < lines.length; i++) {
|
||||||
if (lines[i].length <= 80) {
|
if (lines[i].length <= 80) {
|
||||||
splitLines[j] = lines[i];
|
splitLines[j] = lines[i];
|
||||||
j++;
|
j++;
|
||||||
} else {
|
} else {
|
||||||
var line = lines[i];
|
let line = lines[i];
|
||||||
var splitAt;
|
let splitAt;
|
||||||
do {
|
do {
|
||||||
splitAt = line.indexOf(' ', 80);
|
splitAt = line.indexOf(' ', 80);
|
||||||
|
|
||||||
|
@ -302,9 +308,10 @@ function split_lines(text) {
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(splitAt !== -1);
|
while (splitAt !== -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return splitLines;
|
return splitLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,22 +319,20 @@ function split_lines(text) {
|
||||||
* From http://www.massless.org/mozedit/
|
* From http://www.massless.org/mozedit/
|
||||||
*/
|
*/
|
||||||
function mozWrap(txtarea, open, close) {
|
function mozWrap(txtarea, open, close) {
|
||||||
var selLength = (typeof(txtarea.textLength) === 'undefined') ? txtarea.value.length : txtarea.textLength;
|
const selLength = (typeof (txtarea.textLength) === 'undefined') ? txtarea.value.length : txtarea.textLength;
|
||||||
var selStart = txtarea.selectionStart;
|
const selStart = txtarea.selectionStart;
|
||||||
var selEnd = txtarea.selectionEnd;
|
const selEnd = txtarea.selectionEnd;
|
||||||
var scrollTop = txtarea.scrollTop;
|
const { scrollTop } = txtarea;
|
||||||
|
|
||||||
var s1 = (txtarea.value).substring(0,selStart);
|
const s1 = (txtarea.value).substring(0, selStart);
|
||||||
var s2 = (txtarea.value).substring(selStart, selEnd);
|
const s2 = (txtarea.value).substring(selStart, selEnd);
|
||||||
var s3 = (txtarea.value).substring(selEnd, selLength);
|
const s3 = (txtarea.value).substring(selEnd, selLength);
|
||||||
|
|
||||||
txtarea.value = s1 + open + s2 + close + s3;
|
txtarea.value = s1 + open + s2 + close + s3;
|
||||||
txtarea.selectionStart = selStart + open.length;
|
txtarea.selectionStart = selStart + open.length;
|
||||||
txtarea.selectionEnd = selEnd + open.length;
|
txtarea.selectionEnd = selEnd + open.length;
|
||||||
txtarea.focus();
|
txtarea.focus();
|
||||||
txtarea.scrollTop = scrollTop;
|
txtarea.scrollTop = scrollTop;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -343,33 +348,32 @@ function storeCaret(textEl) {
|
||||||
/**
|
/**
|
||||||
* Caret Position object
|
* Caret Position object
|
||||||
*/
|
*/
|
||||||
function caretPosition() {
|
function CaretPosition() {
|
||||||
var start = null;
|
const start = null;
|
||||||
var end = null;
|
const end = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the caret position in an textarea
|
* Get the caret position in an textarea
|
||||||
*/
|
*/
|
||||||
function getCaretPosition(txtarea) {
|
function getCaretPosition(txtarea) {
|
||||||
var caretPos = new caretPosition();
|
const caretPos = new CaretPosition();
|
||||||
|
|
||||||
// simple Gecko/Opera way
|
// simple Gecko/Opera way
|
||||||
if (txtarea.selectionStart || txtarea.selectionStart === 0) {
|
if (txtarea.selectionStart || txtarea.selectionStart === 0) {
|
||||||
caretPos.start = txtarea.selectionStart;
|
caretPos.start = txtarea.selectionStart;
|
||||||
caretPos.end = txtarea.selectionEnd;
|
caretPos.end = txtarea.selectionEnd;
|
||||||
}
|
} else if (document.selection) {
|
||||||
// dirty and slow IE way
|
// dirty and slow IE way
|
||||||
else if (document.selection) {
|
|
||||||
// get current selection
|
// get current selection
|
||||||
var range = document.selection.createRange();
|
const range = document.selection.createRange();
|
||||||
|
|
||||||
// a new selection of the whole textarea
|
// a new selection of the whole textarea
|
||||||
var range_all = document.body.createTextRange();
|
const range_all = document.body.createTextRange();
|
||||||
range_all.moveToElementText(txtarea);
|
range_all.moveToElementText(txtarea);
|
||||||
|
|
||||||
// calculate selection start point by moving beginning of range_all to beginning of range
|
// calculate selection start point by moving beginning of range_all to beginning of range
|
||||||
var sel_start;
|
let sel_start;
|
||||||
for (sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start++) {
|
for (sel_start = 0; range_all.compareEndPoints('StartToStart', range) < 0; sel_start++) {
|
||||||
range_all.moveStart('character', 1);
|
range_all.moveStart('character', 1);
|
||||||
}
|
}
|
||||||
|
@ -404,7 +408,7 @@ function getCaretPosition(txtarea) {
|
||||||
phpbb.showDragNDrop(textarea);
|
phpbb.showDragNDrop(textarea);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('textarea').on('keydown', function (e) {
|
$('textarea').on('keydown', function(e) {
|
||||||
if (e.which === 13 && (e.metaKey || e.ctrlKey)) {
|
if (e.which === 13 && (e.metaKey || e.ctrlKey)) {
|
||||||
$(this).closest('form').find(':submit').click();
|
$(this).closest('form').find(':submit').click();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,21 +2,22 @@
|
||||||
* Installer's AJAX frontend handler
|
* Installer's AJAX frontend handler
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* eslint no-prototype-builtins: 0 */
|
||||||
(function($) { // Avoid conflicts with other libraries
|
(function($) { // Avoid conflicts with other libraries
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Installer variables
|
// Installer variables
|
||||||
var pollTimer = null;
|
let pollTimer = null;
|
||||||
var nextReadPosition = 0;
|
let nextReadPosition = 0;
|
||||||
var progressBarTriggered = false;
|
let progressBarTriggered = false;
|
||||||
var progressTimer = null;
|
let progressTimer = null;
|
||||||
var currentProgress = 0;
|
let currentProgress = 0;
|
||||||
var refreshRequested = false;
|
let refreshRequested = false;
|
||||||
var transmissionOver = false;
|
let transmissionOver = false;
|
||||||
var statusCount = 0;
|
let statusCount = 0;
|
||||||
|
|
||||||
// Template related variables
|
// Template related variables
|
||||||
var $contentWrapper = $('.install-body').find('.main');
|
const $contentWrapper = $('.install-body').find('.main');
|
||||||
|
|
||||||
// Intercept form submits
|
// Intercept form submits
|
||||||
interceptFormSubmit($('#install_install'));
|
interceptFormSubmit($('#install_install'));
|
||||||
|
@ -42,12 +43,15 @@
|
||||||
*/
|
*/
|
||||||
function addMessage(type, messages) {
|
function addMessage(type, messages) {
|
||||||
// Get message containers
|
// Get message containers
|
||||||
var $errorContainer = $('#error-container');
|
const $errorContainer = $('#error-container');
|
||||||
var $warningContainer = $('#warning-container');
|
const $warningContainer = $('#warning-container');
|
||||||
var $logContainer = $('#log-container');
|
const $logContainer = $('#log-container');
|
||||||
|
|
||||||
var $title, $description, $msgElement, arraySize = messages.length;
|
let $title;
|
||||||
for (var i = 0; i < arraySize; i++) {
|
let $description;
|
||||||
|
let $msgElement;
|
||||||
|
const arraySize = messages.length;
|
||||||
|
for (let i = 0; i < arraySize; i++) {
|
||||||
$msgElement = $('<div />');
|
$msgElement = $('<div />');
|
||||||
$title = $('<strong />');
|
$title = $('<strong />');
|
||||||
$title.text(messages[i].title);
|
$title.text(messages[i].title);
|
||||||
|
@ -59,24 +63,19 @@
|
||||||
$msgElement.append($description);
|
$msgElement.append($description);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
if (type === 'error') {
|
||||||
case 'error':
|
|
||||||
$msgElement.addClass('errorbox');
|
$msgElement.addClass('errorbox');
|
||||||
$errorContainer.append($msgElement);
|
$errorContainer.append($msgElement);
|
||||||
break;
|
} else if (type === 'warning') {
|
||||||
case 'warning':
|
|
||||||
$msgElement.addClass('warningbox');
|
$msgElement.addClass('warningbox');
|
||||||
$warningContainer.append($msgElement);
|
$warningContainer.append($msgElement);
|
||||||
break;
|
} else if (type === 'log') {
|
||||||
case 'log':
|
|
||||||
$msgElement.addClass('log');
|
$msgElement.addClass('log');
|
||||||
$logContainer.prepend($msgElement);
|
$logContainer.prepend($msgElement);
|
||||||
$logContainer.addClass('show_log_container');
|
$logContainer.addClass('show_log_container');
|
||||||
break;
|
} else if (type === 'success') {
|
||||||
case 'success':
|
|
||||||
$msgElement.addClass('successbox');
|
$msgElement.addClass('successbox');
|
||||||
$errorContainer.prepend($msgElement);
|
$errorContainer.prepend($msgElement);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,12 +83,14 @@
|
||||||
/**
|
/**
|
||||||
* Render a download box
|
* Render a download box
|
||||||
*/
|
*/
|
||||||
function addDownloadBox(downloadArray)
|
function addDownloadBox(downloadArray) {
|
||||||
{
|
const $downloadContainer = $('#download-wrapper');
|
||||||
var $downloadContainer = $('#download-wrapper');
|
let $downloadBox;
|
||||||
var $downloadBox, $title, $content, $link;
|
let $title;
|
||||||
|
let $content;
|
||||||
|
let $link;
|
||||||
|
|
||||||
for (var i = 0; i < downloadArray.length; i++) {
|
for (let i = 0; i < downloadArray.length; i++) {
|
||||||
$downloadBox = $('<div />');
|
$downloadBox = $('<div />');
|
||||||
$downloadBox.addClass('download-box');
|
$downloadBox.addClass('download-box');
|
||||||
|
|
||||||
|
@ -116,9 +117,8 @@
|
||||||
/**
|
/**
|
||||||
* Render update files' status
|
* Render update files' status
|
||||||
*/
|
*/
|
||||||
function addUpdateFileStatus(fileStatus)
|
function addUpdateFileStatus(fileStatus) {
|
||||||
{
|
const $statusContainer = $('#file-status-wrapper');
|
||||||
var $statusContainer = $('#file-status-wrapper');
|
|
||||||
$statusContainer.html(fileStatus);
|
$statusContainer.html(fileStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,9 +128,9 @@
|
||||||
* @param formHtml
|
* @param formHtml
|
||||||
*/
|
*/
|
||||||
function addForm(formHtml) {
|
function addForm(formHtml) {
|
||||||
var $formContainer = $('#form-wrapper');
|
const $formContainer = $('#form-wrapper');
|
||||||
$formContainer.html(formHtml);
|
$formContainer.html(formHtml);
|
||||||
var $form = $('#install_install');
|
const $form = $('#install_install');
|
||||||
interceptFormSubmit($form);
|
interceptFormSubmit($form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,14 +140,16 @@
|
||||||
* @param navObj
|
* @param navObj
|
||||||
*/
|
*/
|
||||||
function updateNavbarStatus(navObj) {
|
function updateNavbarStatus(navObj) {
|
||||||
var navID, $stage, $stageListItem, $active;
|
let navID;
|
||||||
$active = $('#activemenu');
|
let $stage;
|
||||||
|
let $stageListItem;
|
||||||
|
const $active = $('#activemenu');
|
||||||
|
|
||||||
if (navObj.hasOwnProperty('finished')) {
|
if (navObj.hasOwnProperty('finished')) {
|
||||||
// This should be an Array
|
// This should be an Array
|
||||||
var navItems = navObj.finished;
|
const navItems = navObj.finished;
|
||||||
|
|
||||||
for (var i = 0; i < navItems.length; i++) {
|
for (let i = 0; i < navItems.length; i++) {
|
||||||
navID = 'installer-stage-' + navItems[i];
|
navID = 'installer-stage-' + navItems[i];
|
||||||
$stage = $('#' + navID);
|
$stage = $('#' + navID);
|
||||||
$stageListItem = $stage.parent();
|
$stageListItem = $stage.parent();
|
||||||
|
@ -179,12 +181,16 @@
|
||||||
* @param progressObject
|
* @param progressObject
|
||||||
*/
|
*/
|
||||||
function setProgress(progressObject) {
|
function setProgress(progressObject) {
|
||||||
var $statusText, $progressBar, $progressText, $progressFiller, $progressFillerText;
|
let $statusText;
|
||||||
|
let $progressBar;
|
||||||
|
let $progressText;
|
||||||
|
let $progressFiller;
|
||||||
|
let $progressFillerText;
|
||||||
|
|
||||||
if (progressObject.task_name.length) {
|
if (progressObject.task_name.length) {
|
||||||
if (!progressBarTriggered) {
|
if (!progressBarTriggered) {
|
||||||
// Create progress bar
|
// Create progress bar
|
||||||
var $progressBarWrapper = $('#progress-bar-container');
|
const $progressBarWrapper = $('#progress-bar-container');
|
||||||
|
|
||||||
// Create progress bar elements
|
// Create progress bar elements
|
||||||
$progressBar = $('<div />');
|
$progressBar = $('<div />');
|
||||||
|
@ -234,9 +240,9 @@
|
||||||
|
|
||||||
// Set cookies
|
// Set cookies
|
||||||
function setCookies(cookies) {
|
function setCookies(cookies) {
|
||||||
var cookie;
|
let cookie;
|
||||||
|
|
||||||
for (var i = 0; i < cookies.length; i++) {
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
// Set cookie name and value
|
// Set cookie name and value
|
||||||
cookie = encodeURIComponent(cookies[i].name) + '=' + encodeURIComponent(cookies[i].value);
|
cookie = encodeURIComponent(cookies[i].name) + '=' + encodeURIComponent(cookies[i].value);
|
||||||
// Set path
|
// Set path
|
||||||
|
@ -246,11 +252,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirects user
|
// Redirects user
|
||||||
function redirect(url, use_ajax) {
|
function redirect(url, useAjax) {
|
||||||
if (use_ajax) {
|
if (useAjax) {
|
||||||
resetPolling();
|
resetPolling();
|
||||||
|
|
||||||
var xhReq = createXhrObject();
|
const xhReq = createXhrObject();
|
||||||
xhReq.open('GET', url, true);
|
xhReq.open('GET', url, true);
|
||||||
xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||||
xhReq.send();
|
xhReq.send();
|
||||||
|
@ -268,7 +274,7 @@
|
||||||
*/
|
*/
|
||||||
function parseMessage(messageJSON) {
|
function parseMessage(messageJSON) {
|
||||||
$('#loading_indicator').css('display', 'none');
|
$('#loading_indicator').css('display', 'none');
|
||||||
var responseObject;
|
let responseObject;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
responseObject = JSON.parse(messageJSON);
|
responseObject = JSON.parse(messageJSON);
|
||||||
|
@ -276,6 +282,7 @@
|
||||||
if (window.console) {
|
if (window.console) {
|
||||||
console.log('Failed to parse JSON object\n\nMessage: ' + err.message + '\n\nServer Response: ' + messageJSON);
|
console.log('Failed to parse JSON object\n\nMessage: ' + err.message + '\n\nServer Response: ' + messageJSON);
|
||||||
} else {
|
} else {
|
||||||
|
// eslint-disable-next-line no-alert
|
||||||
alert('Failed to parse JSON object\n\nMessage: ' + err.message + '\n\nServer Response: ' + messageJSON);
|
alert('Failed to parse JSON object\n\nMessage: ' + err.message + '\n\nServer Response: ' + messageJSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,10 +366,12 @@
|
||||||
} else {
|
} else {
|
||||||
$('#loading_indicator').css('display', 'none');
|
$('#loading_indicator').css('display', 'none');
|
||||||
addMessage('error',
|
addMessage('error',
|
||||||
[{
|
[ {
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
title: installLang.title,
|
title: installLang.title,
|
||||||
description: installLang.msg
|
// eslint-disable-next-line no-undef
|
||||||
}]
|
description: installLang.msg,
|
||||||
|
} ],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -371,9 +380,9 @@
|
||||||
* Queries the installer's status
|
* Queries the installer's status
|
||||||
*/
|
*/
|
||||||
function queryInstallerStatus() {
|
function queryInstallerStatus() {
|
||||||
var url = $(location).attr('pathname');
|
let url = $(location).attr('pathname');
|
||||||
var lookUp = 'install/app.php';
|
let lookUp = 'install/app.php';
|
||||||
var position = url.indexOf(lookUp);
|
let position = url.indexOf(lookUp);
|
||||||
|
|
||||||
if (position === -1) {
|
if (position === -1) {
|
||||||
lookUp = 'install';
|
lookUp = 'install';
|
||||||
|
@ -385,7 +394,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
url = url.substring(0, position) + lookUp + '/installer/status';
|
url = url.substring(0, position) + lookUp + '/installer/status';
|
||||||
$.getJSON(url, function(data) {
|
$.getJSON(url, data => {
|
||||||
processTimeoutResponse(data.status);
|
processTimeoutResponse(data.status);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -396,9 +405,12 @@
|
||||||
* @param xhReq XHR object
|
* @param xhReq XHR object
|
||||||
*/
|
*/
|
||||||
function pollContent(xhReq) {
|
function pollContent(xhReq) {
|
||||||
var messages = xhReq.responseText;
|
const messages = xhReq.responseText;
|
||||||
var msgSeparator = '}\n\n';
|
const msgSeparator = '}\n\n';
|
||||||
var unprocessed, messageEndIndex, endOfMessageIndex, message;
|
let unprocessed;
|
||||||
|
let messageEndIndex;
|
||||||
|
let endOfMessageIndex;
|
||||||
|
let message;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
unprocessed = messages.substring(nextReadPosition);
|
unprocessed = messages.substring(nextReadPosition);
|
||||||
|
@ -416,7 +428,7 @@
|
||||||
$('#loading_indicator').css('display', 'none');
|
$('#loading_indicator').css('display', 'none');
|
||||||
resetPolling();
|
resetPolling();
|
||||||
|
|
||||||
var timeoutDetected = !transmissionOver;
|
const timeoutDetected = !transmissionOver;
|
||||||
|
|
||||||
if (refreshRequested) {
|
if (refreshRequested) {
|
||||||
refreshRequested = false;
|
refreshRequested = false;
|
||||||
|
@ -444,7 +456,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $progressBar = $('#progress-bar');
|
const $progressBar = $('#progress-bar');
|
||||||
|
|
||||||
currentProgress++;
|
currentProgress++;
|
||||||
$progressFillerText.css('width', $progressBar.width());
|
$progressFillerText.css('width', $progressBar.width());
|
||||||
|
@ -459,14 +471,14 @@
|
||||||
* @param progressLimit
|
* @param progressLimit
|
||||||
*/
|
*/
|
||||||
function incrementProgressBar(progressLimit) {
|
function incrementProgressBar(progressLimit) {
|
||||||
var $progressFiller = $('#progress-bar-filler');
|
const $progressFiller = $('#progress-bar-filler');
|
||||||
var $progressFillerText = $('#progress-bar-filler-text');
|
const $progressFillerText = $('#progress-bar-filler-text');
|
||||||
var $progressText = $('#progress-bar-text');
|
const $progressText = $('#progress-bar-text');
|
||||||
var progressStart = $progressFiller.width() / $progressFiller.offsetParent().width() * 100;
|
const progressStart = $progressFiller.width() / $progressFiller.offsetParent().width() * 100;
|
||||||
currentProgress = Math.floor(progressStart);
|
currentProgress = Math.floor(progressStart);
|
||||||
|
|
||||||
clearInterval(progressTimer);
|
clearInterval(progressTimer);
|
||||||
progressTimer = setInterval(function() {
|
progressTimer = setInterval(() => {
|
||||||
incrementFiller($progressText, $progressFiller, $progressFillerText, progressLimit);
|
incrementFiller($progressText, $progressFiller, $progressFillerText, progressLimit);
|
||||||
}, 10);
|
}, 10);
|
||||||
}
|
}
|
||||||
|
@ -487,7 +499,7 @@
|
||||||
function startPolling(xhReq) {
|
function startPolling(xhReq) {
|
||||||
resetPolling();
|
resetPolling();
|
||||||
transmissionOver = false;
|
transmissionOver = false;
|
||||||
pollTimer = setInterval(function () {
|
pollTimer = setInterval(() => {
|
||||||
pollContent(xhReq);
|
pollContent(xhReq);
|
||||||
}, 250);
|
}, 250);
|
||||||
}
|
}
|
||||||
|
@ -498,7 +510,7 @@
|
||||||
function doRefresh() {
|
function doRefresh() {
|
||||||
resetPolling();
|
resetPolling();
|
||||||
|
|
||||||
var xhReq = createXhrObject();
|
const xhReq = createXhrObject();
|
||||||
xhReq.open('GET', $(location).attr('pathname'), true);
|
xhReq.open('GET', $(location).attr('pathname'), true);
|
||||||
xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||||
xhReq.send();
|
xhReq.send();
|
||||||
|
@ -515,47 +527,47 @@
|
||||||
// Clear content
|
// Clear content
|
||||||
$contentWrapper.html('');
|
$contentWrapper.html('');
|
||||||
|
|
||||||
var $header = $('<div />');
|
const $header = $('<div />');
|
||||||
$header.attr('id', 'header-container');
|
$header.attr('id', 'header-container');
|
||||||
$contentWrapper.append($header);
|
$contentWrapper.append($header);
|
||||||
|
|
||||||
var $description = $('<div />');
|
const $description = $('<div />');
|
||||||
$description.attr('id', 'description-container');
|
$description.attr('id', 'description-container');
|
||||||
$contentWrapper.append($description);
|
$contentWrapper.append($description);
|
||||||
|
|
||||||
var $errorContainer = $('<div />');
|
const $errorContainer = $('<div />');
|
||||||
$errorContainer.attr('id', 'error-container');
|
$errorContainer.attr('id', 'error-container');
|
||||||
$contentWrapper.append($errorContainer);
|
$contentWrapper.append($errorContainer);
|
||||||
|
|
||||||
var $warningContainer = $('<div />');
|
const $warningContainer = $('<div />');
|
||||||
$warningContainer.attr('id', 'warning-container');
|
$warningContainer.attr('id', 'warning-container');
|
||||||
$contentWrapper.append($warningContainer);
|
$contentWrapper.append($warningContainer);
|
||||||
|
|
||||||
var $progressContainer = $('<div />');
|
const $progressContainer = $('<div />');
|
||||||
$progressContainer.attr('id', 'progress-bar-container');
|
$progressContainer.attr('id', 'progress-bar-container');
|
||||||
$contentWrapper.append($progressContainer);
|
$contentWrapper.append($progressContainer);
|
||||||
|
|
||||||
var $logContainer = $('<div />');
|
const $logContainer = $('<div />');
|
||||||
$logContainer.attr('id', 'log-container');
|
$logContainer.attr('id', 'log-container');
|
||||||
$contentWrapper.append($logContainer);
|
$contentWrapper.append($logContainer);
|
||||||
|
|
||||||
var $installerContentWrapper = $('<div />');
|
const $installerContentWrapper = $('<div />');
|
||||||
$installerContentWrapper.attr('id', 'content-container');
|
$installerContentWrapper.attr('id', 'content-container');
|
||||||
$contentWrapper.append($installerContentWrapper);
|
$contentWrapper.append($installerContentWrapper);
|
||||||
|
|
||||||
var $installerDownloadWrapper = $('<div />');
|
const $installerDownloadWrapper = $('<div />');
|
||||||
$installerDownloadWrapper.attr('id', 'download-wrapper');
|
$installerDownloadWrapper.attr('id', 'download-wrapper');
|
||||||
$installerContentWrapper.append($installerDownloadWrapper);
|
$installerContentWrapper.append($installerDownloadWrapper);
|
||||||
|
|
||||||
var $updaterFileStatusWrapper = $('<div />');
|
const $updaterFileStatusWrapper = $('<div />');
|
||||||
$updaterFileStatusWrapper.attr('id', 'file-status-wrapper');
|
$updaterFileStatusWrapper.attr('id', 'file-status-wrapper');
|
||||||
$installerContentWrapper.append($updaterFileStatusWrapper);
|
$installerContentWrapper.append($updaterFileStatusWrapper);
|
||||||
|
|
||||||
var $formWrapper = $('<div />');
|
const $formWrapper = $('<div />');
|
||||||
$formWrapper.attr('id', 'form-wrapper');
|
$formWrapper.attr('id', 'form-wrapper');
|
||||||
$installerContentWrapper.append($formWrapper);
|
$installerContentWrapper.append($formWrapper);
|
||||||
|
|
||||||
var $spinner = $('<div />');
|
const $spinner = $('<div />');
|
||||||
$spinner.attr('id', 'loading_indicator');
|
$spinner.attr('id', 'loading_indicator');
|
||||||
$spinner.html(' ');
|
$spinner.html(' ');
|
||||||
$contentWrapper.append($spinner);
|
$contentWrapper.append($spinner);
|
||||||
|
@ -565,7 +577,7 @@
|
||||||
function submitForm($form, $submitBtn) {
|
function submitForm($form, $submitBtn) {
|
||||||
$form.css('display', 'none');
|
$form.css('display', 'none');
|
||||||
|
|
||||||
var xhReq = createXhrObject();
|
const xhReq = createXhrObject();
|
||||||
xhReq.open('POST', $form.attr('action'), true);
|
xhReq.open('POST', $form.attr('action'), true);
|
||||||
xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
xhReq.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||||
xhReq.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
xhReq.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
||||||
|
@ -590,7 +602,7 @@
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
function getFormFields($form, $submitBtn) {
|
function getFormFields($form, $submitBtn) {
|
||||||
var formData = $form.serialize();
|
let formData = $form.serialize();
|
||||||
formData += ((formData.length) ? '&' : '') + encodeURIComponent($submitBtn.attr('name')) + '=';
|
formData += ((formData.length) ? '&' : '') + encodeURIComponent($submitBtn.attr('name')) + '=';
|
||||||
formData += encodeURIComponent($submitBtn.attr('value'));
|
formData += encodeURIComponent($submitBtn.attr('value'));
|
||||||
|
|
||||||
|
@ -605,11 +617,13 @@
|
||||||
function interceptFormSubmit($form) {
|
function interceptFormSubmit($form) {
|
||||||
if (!$form.length) {
|
if (!$form.length) {
|
||||||
return;
|
return;
|
||||||
} else if ($form.find('input[name="admin_name"]').length > 0) {
|
}
|
||||||
|
|
||||||
|
if ($form.find('input[name="admin_name"]').length > 0) {
|
||||||
setAdminTimezone($form);
|
setAdminTimezone($form);
|
||||||
}
|
}
|
||||||
|
|
||||||
$form.find(':submit').bind('click', function (event) {
|
$form.find(':submit').bind('click', function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
submitForm($form, $(this));
|
submitForm($form, $(this));
|
||||||
});
|
});
|
||||||
|
@ -623,7 +637,8 @@
|
||||||
function setAdminTimezone($form) {
|
function setAdminTimezone($form) {
|
||||||
// Set admin timezone if it does not exist yet
|
// Set admin timezone if it does not exist yet
|
||||||
if ($form.find('input[name="admin_timezone"]').length === 0) {
|
if ($form.find('input[name="admin_timezone"]').length === 0) {
|
||||||
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
// eslint-disable-next-line new-cap
|
||||||
|
const { timeZone } = Intl.DateTimeFormat().resolvedOptions();
|
||||||
|
|
||||||
// Add timezone as form entry
|
// Add timezone as form entry
|
||||||
const timezoneEntry = $('<input type="hidden" name="admin_timezone" value="' + timeZone + '">');
|
const timezoneEntry = $('<input type="hidden" name="admin_timezone" value="' + timeZone + '">');
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
/* global phpbb, plupload, attachInline */
|
/* global phpbb, plupload, attachInline, activateSubPanel */
|
||||||
|
/* eslint camelcase: 0 */
|
||||||
|
|
||||||
plupload.addI18n(phpbb.plupload.i18n);
|
plupload.addI18n(phpbb.plupload.i18n);
|
||||||
phpbb.plupload.ids = [];
|
phpbb.plupload.ids = [];
|
||||||
|
|
||||||
(function($) { // Avoid conflicts with other libraries
|
(function($) { // Avoid conflicts with other libraries
|
||||||
|
'use strict';
|
||||||
|
|
||||||
'use strict';
|
/**
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up the uploader.
|
* Set up the uploader.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.initialize = function() {
|
phpbb.plupload.initialize = function() {
|
||||||
// Initialize the Plupload uploader.
|
// Initialize the Plupload uploader.
|
||||||
phpbb.plupload.uploader.init();
|
phpbb.plupload.uploader.init();
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@ phpbb.plupload.initialize = function() {
|
||||||
phpbb.plupload.updateMultipartParams(phpbb.plupload.getSerializedData());
|
phpbb.plupload.updateMultipartParams(phpbb.plupload.getSerializedData());
|
||||||
|
|
||||||
// Only execute if Plupload initialized successfully.
|
// Only execute if Plupload initialized successfully.
|
||||||
phpbb.plupload.uploader.bind('Init', function() {
|
phpbb.plupload.uploader.bind('Init', () => {
|
||||||
phpbb.plupload.form = $(phpbb.plupload.config.form_hook)[0];
|
phpbb.plupload.form = $(phpbb.plupload.config.form_hook)[0];
|
||||||
let $attachRowTemplate = $('#attach-row-tpl');
|
const $attachRowTemplate = $('#attach-row-tpl');
|
||||||
$attachRowTemplate.removeClass('attach-row-tpl');
|
$attachRowTemplate.removeClass('attach-row-tpl');
|
||||||
phpbb.plupload.rowTpl = $attachRowTemplate[0].outerHTML;
|
phpbb.plupload.rowTpl = $attachRowTemplate[0].outerHTML;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ phpbb.plupload.initialize = function() {
|
||||||
$('#attach-panel-multi').show();
|
$('#attach-panel-multi').show();
|
||||||
});
|
});
|
||||||
|
|
||||||
phpbb.plupload.uploader.bind('PostInit', function() {
|
phpbb.plupload.uploader.bind('PostInit', () => {
|
||||||
// Point out the drag-and-drop zone if it's supported.
|
// Point out the drag-and-drop zone if it's supported.
|
||||||
if (phpbb.plupload.uploader.features.dragdrop) {
|
if (phpbb.plupload.uploader.features.dragdrop) {
|
||||||
$('#drag-n-drop-message').show();
|
$('#drag-n-drop-message').show();
|
||||||
|
@ -41,49 +41,50 @@ phpbb.plupload.initialize = function() {
|
||||||
if ($('#attach-panel-multi').is(':visible')) {
|
if ($('#attach-panel-multi').is(':visible')) {
|
||||||
phpbb.plupload.uploader.refresh();
|
phpbb.plupload.uploader.refresh();
|
||||||
}
|
}
|
||||||
$('[data-subpanel="attach-panel"]').one('click', function() {
|
|
||||||
|
$('[data-subpanel="attach-panel"]').one('click', () => {
|
||||||
phpbb.plupload.uploader.refresh();
|
phpbb.plupload.uploader.refresh();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsets all elements in the object uploader.settings.multipart_params whose keys
|
* Unsets all elements in the object uploader.settings.multipart_params whose keys
|
||||||
* begin with 'attachment_data['
|
* begin with 'attachment_data['
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.clearParams = function() {
|
phpbb.plupload.clearParams = function() {
|
||||||
var obj = phpbb.plupload.uploader.settings.multipart_params;
|
const obj = phpbb.plupload.uploader.settings.multipart_params;
|
||||||
for (var key in obj) {
|
for (const key in obj) {
|
||||||
if (!obj.hasOwnProperty(key) || key.indexOf('attachment_data[') !== 0) {
|
if (!Object.prototype.hasOwnProperty.call(obj, key) || key.indexOf('attachment_data[') !== 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete phpbb.plupload.uploader.settings.multipart_params[key];
|
delete phpbb.plupload.uploader.settings.multipart_params[key];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update uploader.settings.multipart_params object with new data.
|
* Update uploader.settings.multipart_params object with new data.
|
||||||
*
|
*
|
||||||
* @param {object} obj
|
* @param {object} obj
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.updateMultipartParams = function(obj) {
|
phpbb.plupload.updateMultipartParams = function(obj) {
|
||||||
var settings = phpbb.plupload.uploader.settings;
|
const { settings } = phpbb.plupload.uploader;
|
||||||
settings.multipart_params = $.extend(settings.multipart_params, obj);
|
settings.multipart_params = $.extend(settings.multipart_params, obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the array of attachment objects into an object that PHP would expect as POST data.
|
* Convert the array of attachment objects into an object that PHP would expect as POST data.
|
||||||
*
|
*
|
||||||
* @returns {object} An object in the form 'attachment_data[i][key]': value as
|
* @returns {object} An object in the form 'attachment_data[i][key]': value as
|
||||||
* expected by the server
|
* expected by the server
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.getSerializedData = function() {
|
phpbb.plupload.getSerializedData = function() {
|
||||||
var obj = {};
|
const obj = {};
|
||||||
for (var i = 0; i < phpbb.plupload.data.length; i++) {
|
for (let i = 0; i < phpbb.plupload.data.length; i++) {
|
||||||
var datum = phpbb.plupload.data[i];
|
const datum = phpbb.plupload.data[i];
|
||||||
for (var key in datum) {
|
for (const key in datum) {
|
||||||
if (!datum.hasOwnProperty(key)) {
|
if (!Object.prototype.hasOwnProperty.call(datum, key)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,42 +93,43 @@ phpbb.plupload.getSerializedData = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert form data
|
// Insert form data
|
||||||
var $pluploadForm = $(phpbb.plupload.config.form_hook).first();
|
const $pluploadForm = $(phpbb.plupload.config.form_hook).first();
|
||||||
obj.creation_time = $pluploadForm.find('input[type=hidden][name="creation_time"]').val();
|
obj.creation_time = $pluploadForm.find('input[type=hidden][name="creation_time"]').val();
|
||||||
obj.form_token = $pluploadForm.find('input[type=hidden][name="form_token"]').val();
|
obj.form_token = $pluploadForm.find('input[type=hidden][name="form_token"]').val();
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the index from the phpbb.plupload.data array where the given
|
* Get the index from the phpbb.plupload.data array where the given
|
||||||
* attachment id appears.
|
* attachment id appears.
|
||||||
*
|
*
|
||||||
* @param {int} attachId The attachment id of the file.
|
* @param {int} attachId The attachment id of the file.
|
||||||
* @returns {bool|int} Index of the file if exists, otherwise false.
|
* @returns {bool|int} Index of the file if exists, otherwise false.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.getIndex = function(attachId) {
|
phpbb.plupload.getIndex = function(attachId) {
|
||||||
var index = $.inArray(Number(attachId), phpbb.plupload.ids);
|
const index = $.inArray(Number(attachId), phpbb.plupload.ids);
|
||||||
return (index !== -1) ? index : false;
|
return index === -1 ? false : index;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the data in phpbb.plupload.data and phpbb.plupload.ids arrays.
|
* Set the data in phpbb.plupload.data and phpbb.plupload.ids arrays.
|
||||||
*
|
*
|
||||||
* @param {Array} data Array containing the new data to use. In the form of
|
* @param {Array} data Array containing the new data to use. In the form of
|
||||||
* array(index => object(property: value). Requires attach_id to be one of the object properties.
|
* array(index => object(property: value). Requires attach_id to be one of the object properties.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.setData = function(data) {
|
phpbb.plupload.setData = function(data) {
|
||||||
// Make sure that the array keys are reset.
|
// Make sure that the array keys are reset.
|
||||||
phpbb.plupload.ids = phpbb.plupload.data = [];
|
phpbb.plupload.ids = [];
|
||||||
|
phpbb.plupload.data = [];
|
||||||
phpbb.plupload.data = data;
|
phpbb.plupload.data = data;
|
||||||
|
|
||||||
for (var i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
phpbb.plupload.ids.push(Number(data[i].attach_id));
|
phpbb.plupload.ids.push(Number(data[i].attach_id));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the attachment data in the HTML and the phpbb & phpbb.plupload objects.
|
* Update the attachment data in the HTML and the phpbb & phpbb.plupload objects.
|
||||||
*
|
*
|
||||||
* @param {Array} data Array containing the new data to use.
|
* @param {Array} data Array containing the new data to use.
|
||||||
|
@ -135,27 +137,26 @@ phpbb.plupload.setData = function(data) {
|
||||||
* @param {int} index The index from phpbb.plupload_ids that was affected by the action.
|
* @param {int} index The index from phpbb.plupload_ids that was affected by the action.
|
||||||
* @param {Array} downloadUrl Optional array of download urls to update.
|
* @param {Array} downloadUrl Optional array of download urls to update.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.update = function(data, action, index, downloadUrl) {
|
phpbb.plupload.update = function(data, action, index, downloadUrl) {
|
||||||
|
|
||||||
phpbb.plupload.updateBbcode(action, index);
|
phpbb.plupload.updateBbcode(action, index);
|
||||||
phpbb.plupload.setData(data);
|
phpbb.plupload.setData(data);
|
||||||
phpbb.plupload.updateRows(downloadUrl);
|
phpbb.plupload.updateRows(downloadUrl);
|
||||||
phpbb.plupload.clearParams();
|
phpbb.plupload.clearParams();
|
||||||
phpbb.plupload.updateMultipartParams(phpbb.plupload.getSerializedData());
|
phpbb.plupload.updateMultipartParams(phpbb.plupload.getSerializedData());
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the relevant elements and hidden data for all attachments.
|
* Update the relevant elements and hidden data for all attachments.
|
||||||
*
|
*
|
||||||
* @param {Array} downloadUrl Optional array of download urls to update.
|
* @param {Array} downloadUrl Optional array of download urls to update.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.updateRows = function(downloadUrl) {
|
phpbb.plupload.updateRows = function(downloadUrl) {
|
||||||
for (var i = 0; i < phpbb.plupload.ids.length; i++) {
|
for (let i = 0; i < phpbb.plupload.ids.length; i++) {
|
||||||
phpbb.plupload.updateRow(i, downloadUrl);
|
phpbb.plupload.updateRow(i, downloadUrl);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert a row for a new attachment. This expects an HTML snippet in the HTML
|
* Insert a row for a new attachment. This expects an HTML snippet in the HTML
|
||||||
* using the id "attach-row-tpl" to be present. This snippet is cloned and the
|
* using the id "attach-row-tpl" to be present. This snippet is cloned and the
|
||||||
* data for the file inserted into it. The row is then appended or prepended to
|
* data for the file inserted into it. The row is then appended or prepended to
|
||||||
|
@ -163,8 +164,8 @@ phpbb.plupload.updateRows = function(downloadUrl) {
|
||||||
*
|
*
|
||||||
* @param {object} file Plupload file object for the new attachment.
|
* @param {object} file Plupload file object for the new attachment.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.insertRow = function(file) {
|
phpbb.plupload.insertRow = function(file) {
|
||||||
var row = $(phpbb.plupload.rowTpl);
|
const row = $(phpbb.plupload.rowTpl);
|
||||||
|
|
||||||
row.attr('id', file.id);
|
row.attr('id', file.id);
|
||||||
row.find('.file-name').html(plupload.xmlEncode(file.name));
|
row.find('.file-name').html(plupload.xmlEncode(file.name));
|
||||||
|
@ -175,22 +176,22 @@ phpbb.plupload.insertRow = function(file) {
|
||||||
} else {
|
} else {
|
||||||
$('#file-list').append(row);
|
$('#file-list').append(row);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the relevant elements and hidden data for an attachment.
|
* Update the relevant elements and hidden data for an attachment.
|
||||||
*
|
*
|
||||||
* @param {int} index The index from phpbb.plupload.ids of the attachment to edit.
|
* @param {int} index The index from phpbb.plupload.ids of the attachment to edit.
|
||||||
* @param {Array} downloadUrl Optional array of download urls to update.
|
* @param {Array} downloadUrl Optional array of download urls to update.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.updateRow = function(index, downloadUrl) {
|
phpbb.plupload.updateRow = function(index, downloadUrl) {
|
||||||
var attach = phpbb.plupload.data[index],
|
const attach = phpbb.plupload.data[index];
|
||||||
row = $('[data-attach-id="' + attach.attach_id + '"]');
|
const row = $('[data-attach-id="' + attach.attach_id + '"]');
|
||||||
|
|
||||||
// Add the link to the file
|
// Add the link to the file
|
||||||
if (typeof downloadUrl !== 'undefined' && typeof downloadUrl[index] !== 'undefined') {
|
if (typeof downloadUrl !== 'undefined' && typeof downloadUrl[index] !== 'undefined') {
|
||||||
var url = downloadUrl[index].replace('&', '&'),
|
const url = downloadUrl[index].replace('&', '&');
|
||||||
link = $('<a></a>');
|
const link = $('<a></a>');
|
||||||
|
|
||||||
link.attr('href', url).html(attach.real_filename);
|
link.attr('href', url).html(attach.real_filename);
|
||||||
row.find('.file-name').html(link);
|
row.find('.file-name').html(link);
|
||||||
|
@ -198,32 +199,32 @@ phpbb.plupload.updateRow = function(index, downloadUrl) {
|
||||||
|
|
||||||
row.find('textarea').attr('name', 'comment_list[' + index + ']');
|
row.find('textarea').attr('name', 'comment_list[' + index + ']');
|
||||||
phpbb.plupload.updateHiddenData(row, attach, index);
|
phpbb.plupload.updateHiddenData(row, attach, index);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update hidden input data for an attachment.
|
* Update hidden input data for an attachment.
|
||||||
*
|
*
|
||||||
* @param {object} row jQuery object for the attachment row.
|
* @param {object} row jQuery object for the attachment row.
|
||||||
* @param {object} attach Attachment data object from phpbb.plupload.data
|
* @param {object} attach Attachment data object from phpbb.plupload.data
|
||||||
* @param {int} index Attachment index from phpbb.plupload.ids
|
* @param {int} index Attachment index from phpbb.plupload.ids
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.updateHiddenData = function(row, attach, index) {
|
phpbb.plupload.updateHiddenData = function(row, attach, index) {
|
||||||
row.find('input[type="hidden"]').remove();
|
row.find('input[type="hidden"]').remove();
|
||||||
|
|
||||||
for (var key in attach) {
|
for (const key in attach) {
|
||||||
if (!attach.hasOwnProperty(key)) {
|
if (!Object.prototype.hasOwnProperty.call(attach, key)) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var input = $('<input />')
|
const input = $('<input />')
|
||||||
.attr('type', 'hidden')
|
.attr('type', 'hidden')
|
||||||
.attr('name', 'attachment_data[' + index + '][' + key + ']')
|
.attr('name', 'attachment_data[' + index + '][' + key + ']')
|
||||||
.attr('value', attach[key]);
|
.attr('value', attach[key]);
|
||||||
$(row).append(input);
|
$(row).append(input);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deleting a file removes it from the queue and fires an AJAX event to the
|
* Deleting a file removes it from the queue and fires an AJAX event to the
|
||||||
* server to tell it to remove the temporary attachment. The server
|
* server to tell it to remove the temporary attachment. The server
|
||||||
* responds with the updated attachment data list so that any future
|
* responds with the updated attachment data list so that any future
|
||||||
|
@ -232,32 +233,33 @@ phpbb.plupload.updateHiddenData = function(row, attach, index) {
|
||||||
* @param {object} row jQuery object for the attachment row.
|
* @param {object} row jQuery object for the attachment row.
|
||||||
* @param {int} attachId Attachment id of the file to be removed.
|
* @param {int} attachId Attachment id of the file to be removed.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.deleteFile = function(row, attachId) {
|
phpbb.plupload.deleteFile = function(row, attachId) {
|
||||||
// If there's no attach id, then the file hasn't been uploaded. Simply delete the row.
|
// If there's no attach id, then the file hasn't been uploaded. Simply delete the row.
|
||||||
if (typeof attachId === 'undefined') {
|
if (typeof attachId === 'undefined') {
|
||||||
var file = phpbb.plupload.uploader.getFile(row.attr('id'));
|
const file = phpbb.plupload.uploader.getFile(row.attr('id'));
|
||||||
phpbb.plupload.uploader.removeFile(file);
|
phpbb.plupload.uploader.removeFile(file);
|
||||||
|
|
||||||
row.slideUp(100, function() {
|
row.slideUp(100, () => {
|
||||||
row.remove();
|
row.remove();
|
||||||
phpbb.plupload.hideEmptyList();
|
phpbb.plupload.hideEmptyList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var index = phpbb.plupload.getIndex(attachId);
|
const index = phpbb.plupload.getIndex(attachId);
|
||||||
row.find('.file-status').toggleClass('file-uploaded file-working');
|
row.find('.file-status').toggleClass('file-uploaded file-working');
|
||||||
|
|
||||||
if (index === false) {
|
if (index === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var fields = {};
|
|
||||||
|
const fields = {};
|
||||||
fields['delete_file[' + index + ']'] = 1;
|
fields['delete_file[' + index + ']'] = 1;
|
||||||
|
|
||||||
var always = function() {
|
const always = function() {
|
||||||
row.find('.file-status').removeClass('file-working');
|
row.find('.file-status').removeClass('file-working');
|
||||||
};
|
};
|
||||||
|
|
||||||
var done = function(response) {
|
const done = function(response) {
|
||||||
if (typeof response !== 'object') {
|
if (typeof response !== 'object') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -286,10 +288,11 @@ phpbb.plupload.deleteFile = function(row, attachId) {
|
||||||
phpbb.plupload.handleMaxFilesReached();
|
phpbb.plupload.handleMaxFilesReached();
|
||||||
|
|
||||||
if (row.attr('id')) {
|
if (row.attr('id')) {
|
||||||
var file = phpbb.plupload.uploader.getFile(row.attr('id'));
|
const file = phpbb.plupload.uploader.getFile(row.attr('id'));
|
||||||
phpbb.plupload.uploader.removeFile(file);
|
phpbb.plupload.uploader.removeFile(file);
|
||||||
}
|
}
|
||||||
row.slideUp(100, function() {
|
|
||||||
|
row.slideUp(100, () => {
|
||||||
row.remove();
|
row.remove();
|
||||||
// Hide the file list if it's empty now.
|
// Hide the file list if it's empty now.
|
||||||
phpbb.plupload.hideEmptyList();
|
phpbb.plupload.hideEmptyList();
|
||||||
|
@ -300,22 +303,22 @@ phpbb.plupload.deleteFile = function(row, attachId) {
|
||||||
$.ajax(phpbb.plupload.config.url, {
|
$.ajax(phpbb.plupload.config.url, {
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: $.extend(fields, phpbb.plupload.getSerializedData()),
|
data: $.extend(fields, phpbb.plupload.getSerializedData()),
|
||||||
headers: phpbb.plupload.config.headers
|
headers: phpbb.plupload.config.headers,
|
||||||
})
|
})
|
||||||
.always(always)
|
.always(always)
|
||||||
.done(done);
|
.done(done);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the attachment list and hide its container if it's empty.
|
* Check the attachment list and hide its container if it's empty.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.hideEmptyList = function() {
|
phpbb.plupload.hideEmptyList = function() {
|
||||||
if (!$('#file-list').children().length) {
|
if (!$('#file-list').children().length) {
|
||||||
$('#file-list-container').slideUp(100);
|
$('#file-list-container').slideUp(100);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the indices used in inline attachment bbcodes. This ensures that the
|
* Update the indices used in inline attachment bbcodes. This ensures that the
|
||||||
* bbcodes correspond to the correct file after a file is added or removed.
|
* bbcodes correspond to the correct file after a file is added or removed.
|
||||||
* This should be called before the phpbb.plupload,data and phpbb.plupload.ids
|
* This should be called before the phpbb.plupload,data and phpbb.plupload.ids
|
||||||
|
@ -324,10 +327,10 @@ phpbb.plupload.hideEmptyList = function() {
|
||||||
* @param {string} action The action that occurred -- either "addition" or "removal"
|
* @param {string} action The action that occurred -- either "addition" or "removal"
|
||||||
* @param {int} index The index of the attachment from phpbb.plupload.ids that was affected.
|
* @param {int} index The index of the attachment from phpbb.plupload.ids that was affected.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.updateBbcode = function(action, index) {
|
phpbb.plupload.updateBbcode = function(action, index) {
|
||||||
var textarea = $('#message', phpbb.plupload.form),
|
const textarea = $('#message', phpbb.plupload.form);
|
||||||
text = textarea.val(),
|
let text = textarea.val();
|
||||||
removal = (action === 'removal');
|
const removal = (action === 'removal');
|
||||||
|
|
||||||
// Return if the bbcode isn't used at all.
|
// Return if the bbcode isn't used at all.
|
||||||
if (text.indexOf('[attachment=') === -1) {
|
if (text.indexOf('[attachment=') === -1) {
|
||||||
|
@ -335,20 +338,21 @@ phpbb.plupload.updateBbcode = function(action, index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function runUpdate(i) {
|
function runUpdate(i) {
|
||||||
var regex = new RegExp('\\[attachment=' + i + '\\](.*?)\\[\\/attachment\\]', 'g');
|
const regex = new RegExp('\\[attachment=' + i + '\\](.*?)\\[\\/attachment\\]', 'g');
|
||||||
text = text.replace(regex, function updateBbcode(_, fileName) {
|
text = text.replace(regex, (_, fileName) => {
|
||||||
// Remove the bbcode if the file was removed.
|
// Remove the bbcode if the file was removed.
|
||||||
if (removal && index === i) {
|
if (removal && index === i) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
var newIndex = i + ((removal) ? -1 : 1);
|
|
||||||
|
const newIndex = i + ((removal) ? -1 : 1);
|
||||||
return '[attachment=' + newIndex + ']' + fileName + '[/attachment]';
|
return '[attachment=' + newIndex + ']' + fileName + '[/attachment]';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop forwards when removing and backwards when adding ensures we don't
|
// Loop forwards when removing and backwards when adding ensures we don't
|
||||||
// corrupt the bbcode index.
|
// corrupt the bbcode index.
|
||||||
var i;
|
let i;
|
||||||
if (removal) {
|
if (removal) {
|
||||||
for (i = index; i < phpbb.plupload.ids.length; i++) {
|
for (i = index; i < phpbb.plupload.ids.length; i++) {
|
||||||
runUpdate(i);
|
runUpdate(i);
|
||||||
|
@ -360,9 +364,9 @@ phpbb.plupload.updateBbcode = function(action, index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
textarea.val(text);
|
textarea.val(text);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Plupload file objects based on their upload status.
|
* Get Plupload file objects based on their upload status.
|
||||||
*
|
*
|
||||||
* @param {int} status Plupload status - plupload.DONE, plupload.FAILED,
|
* @param {int} status Plupload status - plupload.DONE, plupload.FAILED,
|
||||||
|
@ -370,25 +374,25 @@ phpbb.plupload.updateBbcode = function(action, index) {
|
||||||
*
|
*
|
||||||
* @returns {Array} The Plupload file objects matching the status.
|
* @returns {Array} The Plupload file objects matching the status.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.getFilesByStatus = function(status) {
|
phpbb.plupload.getFilesByStatus = function(status) {
|
||||||
var files = [];
|
const files = [];
|
||||||
|
|
||||||
$.each(phpbb.plupload.uploader.files, function(i, file) {
|
$.each(phpbb.plupload.uploader.files, (i, file) => {
|
||||||
if (file.status === status) {
|
if (file.status === status) {
|
||||||
files.push(file);
|
files.push(file);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return files;
|
return files;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the user has reached the maximun number of files that he's allowed
|
* Check whether the user has reached the maximun number of files that he's allowed
|
||||||
* to upload. If so, disables the uploader and marks the queued files as failed. Otherwise
|
* to upload. If so, disables the uploader and marks the queued files as failed. Otherwise
|
||||||
* makes sure that the uploader is enabled.
|
* makes sure that the uploader is enabled.
|
||||||
*
|
*
|
||||||
* @returns {bool} True if the limit has been reached. False if otherwise.
|
* @returns {bool} True if the limit has been reached. False if otherwise.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.handleMaxFilesReached = function() {
|
phpbb.plupload.handleMaxFilesReached = function() {
|
||||||
// If there is no limit, the user is an admin or moderator.
|
// If there is no limit, the user is an admin or moderator.
|
||||||
if (!phpbb.plupload.maxFiles) {
|
if (!phpbb.plupload.maxFiles) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -402,81 +406,87 @@ phpbb.plupload.handleMaxFilesReached = function() {
|
||||||
phpbb.plupload.uploader.trigger('Error', { message: phpbb.plupload.lang.TOO_MANY_ATTACHMENTS });
|
phpbb.plupload.uploader.trigger('Error', { message: phpbb.plupload.lang.TOO_MANY_ATTACHMENTS });
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if (phpbb.plupload.maxFiles > phpbb.plupload.ids.length) {
|
}
|
||||||
|
|
||||||
|
if (phpbb.plupload.maxFiles > phpbb.plupload.ids.length) {
|
||||||
// Enable the uploader if the user is under the limit
|
// Enable the uploader if the user is under the limit
|
||||||
phpbb.plupload.enableUploader();
|
phpbb.plupload.enableUploader();
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
* Disable the uploader
|
* Disable the uploader
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.disableUploader = function() {
|
phpbb.plupload.disableUploader = function() {
|
||||||
$('#add_files').addClass('disabled');
|
$('#add_files').addClass('disabled');
|
||||||
phpbb.plupload.uploader.disableBrowse();
|
phpbb.plupload.uploader.disableBrowse();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable the uploader
|
* Enable the uploader
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.enableUploader = function() {
|
phpbb.plupload.enableUploader = function() {
|
||||||
$('#add_files').removeClass('disabled');
|
$('#add_files').removeClass('disabled');
|
||||||
phpbb.plupload.uploader.disableBrowse(false);
|
phpbb.plupload.uploader.disableBrowse(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark all queued files as failed.
|
* Mark all queued files as failed.
|
||||||
*
|
*
|
||||||
* @param {string} error Error message to present to the user.
|
* @param {string} error Error message to present to the user.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.markQueuedFailed = function(error) {
|
phpbb.plupload.markQueuedFailed = function(error) {
|
||||||
var files = phpbb.plupload.getFilesByStatus(plupload.QUEUED);
|
const files = phpbb.plupload.getFilesByStatus(plupload.QUEUED);
|
||||||
|
|
||||||
$.each(files, function(i, file) {
|
$.each(files, (i, file) => {
|
||||||
$('#' + file.id).find('.file-progress').hide();
|
$('#' + file.id).find('.file-progress').hide();
|
||||||
phpbb.plupload.fileError(file, error);
|
phpbb.plupload.fileError(file, error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks a file as failed and sets the error message for it.
|
* Marks a file as failed and sets the error message for it.
|
||||||
*
|
*
|
||||||
* @param {object} file Plupload file object that failed.
|
* @param {object} file Plupload file object that failed.
|
||||||
* @param {string} error Error message to present to the user.
|
* @param {string} error Error message to present to the user.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.fileError = function(file, error) {
|
phpbb.plupload.fileError = function(file, error) {
|
||||||
file.status = plupload.FAILED;
|
file.status = plupload.FAILED;
|
||||||
file.error = error;
|
file.error = error;
|
||||||
$('#' + file.id).find('.file-status')
|
$('#' + file.id).find('.file-status')
|
||||||
.addClass('file-error')
|
.addClass('file-error')
|
||||||
.attr({
|
.attr({
|
||||||
'data-error-title': phpbb.plupload.lang.ERROR,
|
'data-error-title': phpbb.plupload.lang.ERROR,
|
||||||
'data-error-message': error
|
'data-error-message': error,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
|
||||||
* Set up the Plupload object and get some basic data.
|
* Set up the Plupload object and get some basic data.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.uploader = new plupload.Uploader(phpbb.plupload.config);
|
phpbb.plupload.uploader = new plupload.Uploader(phpbb.plupload.config);
|
||||||
phpbb.plupload.initialize();
|
phpbb.plupload.initialize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a file filter to check for max file sizes per mime type.
|
* Add a file filter to check for max file sizes per mime type.
|
||||||
*/
|
*/
|
||||||
plupload.addFileFilter('mime_types_max_file_size', function(types, file, callback) {
|
plupload.addFileFilter('mime_types_max_file_size', (types, file, callback) => {
|
||||||
if (file.size !== 'undefined') {
|
if (file.size !== 'undefined') {
|
||||||
$(types).each(function(i, type) {
|
$(types).each((i, type) => {
|
||||||
let extensions = [],
|
const extensions = [];
|
||||||
extsArray = type.extensions.split(',');
|
const extsArray = type.extensions.split(',');
|
||||||
|
|
||||||
$(extsArray).each(function(i, extension) {
|
$(extsArray).each((i, extension) => {
|
||||||
/^\s*\*\s*$/.test(extension) ? extensions.push("\\.*") : extensions.push("\\." + extension.replace(new RegExp("[" + "/^$.*+?|()[]{}\\".replace(/./g, "\\$&") + "]", "g"), "\\$&"));
|
if (/^\s*\*\s*$/.test(extension)) {
|
||||||
|
extensions.push('\\.*');
|
||||||
|
} else {
|
||||||
|
extensions.push('\\.' + extension.replace(new RegExp('[' + '/^$.*+?|()[]{}\\'.replace(/./g, '\\$&') + ']', 'g'), '\\$&'));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let regex = new RegExp("(" + extensions.join("|") + ")$", "i");
|
const regex = new RegExp('(' + extensions.join('|') + ')$', 'i');
|
||||||
|
|
||||||
if (regex.test(file.name)) {
|
if (regex.test(file.name)) {
|
||||||
if (type.max_file_size !== 'undefined' && type.max_file_size) {
|
if (type.max_file_size !== 'undefined' && type.max_file_size) {
|
||||||
|
@ -484,7 +494,7 @@ plupload.addFileFilter('mime_types_max_file_size', function(types, file, callbac
|
||||||
phpbb.plupload.uploader.trigger('Error', {
|
phpbb.plupload.uploader.trigger('Error', {
|
||||||
code: plupload.FILE_SIZE_ERROR,
|
code: plupload.FILE_SIZE_ERROR,
|
||||||
message: plupload.translate('File size error.'),
|
message: plupload.translate('File size error.'),
|
||||||
file: file
|
file,
|
||||||
});
|
});
|
||||||
|
|
||||||
callback(false);
|
callback(false);
|
||||||
|
@ -499,44 +509,44 @@ plupload.addFileFilter('mime_types_max_file_size', function(types, file, callbac
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var $fileList = $('#file-list');
|
const $fileList = $('#file-list');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert inline attachment bbcode.
|
* Insert inline attachment bbcode.
|
||||||
*/
|
*/
|
||||||
$fileList.on('click', '.file-inline-bbcode', function(e) {
|
$fileList.on('click', '.file-inline-bbcode', function(e) {
|
||||||
var attachId = $(this).parents('.attach-row').attr('data-attach-id'),
|
const attachId = $(this).parents('.attach-row').attr('data-attach-id');
|
||||||
index = phpbb.plupload.getIndex(attachId);
|
const index = phpbb.plupload.getIndex(attachId);
|
||||||
|
|
||||||
attachInline(index, phpbb.plupload.data[index].real_filename);
|
attachInline(index, phpbb.plupload.data[index].real_filename);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a file.
|
* Delete a file.
|
||||||
*/
|
*/
|
||||||
$fileList.on('click', '.file-delete', function(e) {
|
$fileList.on('click', '.file-delete', function(e) {
|
||||||
var row = $(this).parents('.attach-row'),
|
const row = $(this).parents('.attach-row');
|
||||||
attachId = row.attr('data-attach-id');
|
const attachId = row.attr('data-attach-id');
|
||||||
|
|
||||||
phpbb.plupload.deleteFile(row, attachId);
|
phpbb.plupload.deleteFile(row, attachId);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the error message for a particular file when the error icon is clicked.
|
* Display the error message for a particular file when the error icon is clicked.
|
||||||
*/
|
*/
|
||||||
$fileList.on('click', '.file-error', function(e) {
|
$fileList.on('click', '.file-error', function(e) {
|
||||||
phpbb.alert($(this).attr('data-error-title'), $(this).attr('data-error-message'));
|
phpbb.alert($(this).attr('data-error-title'), $(this).attr('data-error-message'));
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires when an error occurs.
|
* Fires when an error occurs.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.uploader.bind('Error', function(up, error) {
|
phpbb.plupload.uploader.bind('Error', (up, error) => {
|
||||||
error.file.name = plupload.xmlEncode(error.file.name);
|
error.file.name = plupload.xmlEncode(error.file.name);
|
||||||
|
|
||||||
// The error message that Plupload provides for these is vague, so we'll be more specific.
|
// The error message that Plupload provides for these is vague, so we'll be more specific.
|
||||||
|
@ -545,10 +555,11 @@ phpbb.plupload.uploader.bind('Error', function(up, error) {
|
||||||
} else if (error.code === plupload.FILE_SIZE_ERROR) {
|
} else if (error.code === plupload.FILE_SIZE_ERROR) {
|
||||||
error.message = plupload.translate('File too large:') + ' ' + error.file.name;
|
error.message = plupload.translate('File too large:') + ' ' + error.file.name;
|
||||||
}
|
}
|
||||||
phpbb.alert(phpbb.plupload.lang.ERROR, error.message);
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
phpbb.alert(phpbb.plupload.lang.ERROR, error.message);
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
* Fires before a given file is about to be uploaded. This allows us to
|
* Fires before a given file is about to be uploaded. This allows us to
|
||||||
* send the real filename along with the chunk. This is necessary because
|
* send the real filename along with the chunk. This is necessary because
|
||||||
* for some reason the filename is set to 'blob' whenever a file is chunked
|
* for some reason the filename is set to 'blob' whenever a file is chunked
|
||||||
|
@ -556,15 +567,15 @@ phpbb.plupload.uploader.bind('Error', function(up, error) {
|
||||||
* @param {object} up The plupload.Uploader object
|
* @param {object} up The plupload.Uploader object
|
||||||
* @param {object} file The plupload.File object that is about to be uploaded
|
* @param {object} file The plupload.File object that is about to be uploaded
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.uploader.bind('BeforeUpload', function(up, file) {
|
phpbb.plupload.uploader.bind('BeforeUpload', (up, file) => {
|
||||||
if (phpbb.plupload.handleMaxFilesReached()) {
|
if (phpbb.plupload.handleMaxFilesReached()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
phpbb.plupload.updateMultipartParams({ real_filename: file.name });
|
phpbb.plupload.updateMultipartParams({ real_filename: file.name });
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fired when a single chunk of any given file is uploaded. This parses the
|
* Fired when a single chunk of any given file is uploaded. This parses the
|
||||||
* response from the server and checks for an error. If an error occurs it
|
* response from the server and checks for an error. If an error occurs it
|
||||||
* is reported to the user and the upload of this particular file is halted
|
* is reported to the user and the upload of this particular file is halted
|
||||||
|
@ -574,22 +585,22 @@ phpbb.plupload.uploader.bind('BeforeUpload', function(up, file) {
|
||||||
* been uploaded
|
* been uploaded
|
||||||
* @param {object} response The response object from the server
|
* @param {object} response The response object from the server
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.uploader.bind('ChunkUploaded', function(up, file, response) {
|
phpbb.plupload.uploader.bind('ChunkUploaded', (up, file, response) => {
|
||||||
if (response.chunk >= response.chunks - 1) {
|
if (response.chunk >= response.chunks - 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var json = {};
|
let json = {};
|
||||||
try {
|
try {
|
||||||
json = $.parseJSON(response.response);
|
json = $.parseJSON(response.response);
|
||||||
} catch (e) {
|
} catch {
|
||||||
file.status = plupload.FAILED;
|
file.status = plupload.FAILED;
|
||||||
up.trigger('FileUploaded', file, {
|
up.trigger('FileUploaded', file, {
|
||||||
response: JSON.stringify({
|
response: JSON.stringify({
|
||||||
error: {
|
error: {
|
||||||
message: 'Error parsing server response.'
|
message: 'Error parsing server response.',
|
||||||
}
|
},
|
||||||
})
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -603,17 +614,17 @@ phpbb.plupload.uploader.bind('ChunkUploaded', function(up, file, response) {
|
||||||
up.trigger('FileUploaded', file, {
|
up.trigger('FileUploaded', file, {
|
||||||
response: JSON.stringify({
|
response: JSON.stringify({
|
||||||
error: {
|
error: {
|
||||||
message: json.error.message
|
message: json.error.message,
|
||||||
}
|
},
|
||||||
})
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires when files are added to the queue.
|
* Fires when files are added to the queue.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.uploader.bind('FilesAdded', function(up, files) {
|
phpbb.plupload.uploader.bind('FilesAdded', (up, files) => {
|
||||||
// Prevent unnecessary requests to the server if the user already uploaded
|
// Prevent unnecessary requests to the server if the user already uploaded
|
||||||
// the maximum number of files allowed.
|
// the maximum number of files allowed.
|
||||||
if (phpbb.plupload.handleMaxFilesReached()) {
|
if (phpbb.plupload.handleMaxFilesReached()) {
|
||||||
|
@ -626,16 +637,16 @@ phpbb.plupload.uploader.bind('FilesAdded', function(up, files) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show the file list if there aren't any files currently.
|
// Show the file list if there aren't any files currently.
|
||||||
var $fileListContainer = $('#file-list-container');
|
const $fileListContainer = $('#file-list-container');
|
||||||
if (!$fileListContainer.is(':visible')) {
|
if (!$fileListContainer.is(':visible')) {
|
||||||
$fileListContainer.show(100);
|
$fileListContainer.show(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
$.each(files, function(i, file) {
|
$.each(files, (i, file) => {
|
||||||
phpbb.plupload.insertRow(file);
|
phpbb.plupload.insertRow(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
up.bind('UploadProgress', function(up, file) {
|
up.bind('UploadProgress', (up, file) => {
|
||||||
$('.file-progress-bar', '#' + file.id).css('width', file.percent + '%');
|
$('.file-progress-bar', '#' + file.id).css('width', file.percent + '%');
|
||||||
$('#file-total-progress-bar').css('width', up.total.percent + '%');
|
$('#file-total-progress-bar').css('width', up.total.percent + '%');
|
||||||
});
|
});
|
||||||
|
@ -645,10 +656,9 @@ phpbb.plupload.uploader.bind('FilesAdded', function(up, files) {
|
||||||
|
|
||||||
// Start uploading the files once the user has selected them.
|
// Start uploading the files once the user has selected them.
|
||||||
up.start();
|
up.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
|
||||||
* Fires when an entire file has been uploaded. It checks for errors
|
* Fires when an entire file has been uploaded. It checks for errors
|
||||||
* returned by the server otherwise parses the list of attachment data and
|
* returned by the server otherwise parses the list of attachment data and
|
||||||
* appends it to the next file upload so that the server can maintain state
|
* appends it to the next file upload so that the server can maintain state
|
||||||
|
@ -659,17 +669,17 @@ phpbb.plupload.uploader.bind('FilesAdded', function(up, files) {
|
||||||
* uploaded
|
* uploaded
|
||||||
* @param {string} response The response string from the server
|
* @param {string} response The response string from the server
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.uploader.bind('FileUploaded', function(up, file, response) {
|
phpbb.plupload.uploader.bind('FileUploaded', (up, file, response) => {
|
||||||
var json = {},
|
let json = {};
|
||||||
row = $('#' + file.id),
|
const row = $('#' + file.id);
|
||||||
error;
|
let error;
|
||||||
|
|
||||||
// Hide the progress indicator.
|
// Hide the progress indicator.
|
||||||
row.find('.file-progress').hide();
|
row.find('.file-progress').hide();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
json = JSON.parse(response.response);
|
json = JSON.parse(response.response);
|
||||||
} catch (e) {
|
} catch {
|
||||||
error = 'Error parsing server response.';
|
error = 'Error parsing server response.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,16 +702,16 @@ phpbb.plupload.uploader.bind('FileUploaded', function(up, file, response) {
|
||||||
row.attr('data-attach-id', file.attachment_data.attach_id);
|
row.attr('data-attach-id', file.attachment_data.attach_id);
|
||||||
row.find('.file-inline-bbcode').show();
|
row.find('.file-inline-bbcode').show();
|
||||||
row.find('.file-status').addClass('file-uploaded');
|
row.find('.file-status').addClass('file-uploaded');
|
||||||
phpbb.plupload.update(json.data, 'addition', 0, [json.download_url]);
|
phpbb.plupload.update(json.data, 'addition', 0, [ json.download_url ]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires when the entire queue of files have been uploaded.
|
* Fires when the entire queue of files have been uploaded.
|
||||||
*/
|
*/
|
||||||
phpbb.plupload.uploader.bind('UploadComplete', function() {
|
phpbb.plupload.uploader.bind('UploadComplete', () => {
|
||||||
// Hide the progress bar
|
// Hide the progress bar
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
$('#file-total-progress-bar').fadeOut(500, function() {
|
$('#file-total-progress-bar').fadeOut(500, function() {
|
||||||
$(this).css('width', 0).show();
|
$(this).css('width', 0).show();
|
||||||
});
|
});
|
||||||
|
@ -709,6 +719,5 @@ phpbb.plupload.uploader.bind('UploadComplete', function() {
|
||||||
|
|
||||||
// Re-enable the uploader
|
// Re-enable the uploader
|
||||||
phpbb.plupload.enableUploader();
|
phpbb.plupload.enableUploader();
|
||||||
});
|
});
|
||||||
|
|
||||||
})(jQuery); // Avoid conflicts with other libraries
|
})(jQuery); // Avoid conflicts with other libraries
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
/* global phpbb */
|
/* global phpbb */
|
||||||
|
/* eslint camelcase: 0 */
|
||||||
|
|
||||||
(function($) { // Avoid conflicts with other libraries
|
(function($) { // Avoid conflicts with other libraries
|
||||||
|
'use strict';
|
||||||
|
|
||||||
'use strict';
|
// This callback will mark all forum icons read
|
||||||
|
phpbb.addAjaxCallback('mark_forums_read', function(res) {
|
||||||
// This callback will mark all forum icons read
|
const readTitle = res.NO_UNREAD_POSTS;
|
||||||
phpbb.addAjaxCallback('mark_forums_read', function(res) {
|
const unreadTitle = res.UNREAD_POSTS;
|
||||||
var readTitle = res.NO_UNREAD_POSTS;
|
const iconsArray = {
|
||||||
var unreadTitle = res.UNREAD_POSTS;
|
|
||||||
var iconsArray = {
|
|
||||||
forum_unread: 'forum_read',
|
forum_unread: 'forum_read',
|
||||||
forum_unread_subforum: 'forum_read_subforum',
|
forum_unread_subforum: 'forum_read_subforum',
|
||||||
forum_unread_locked: 'forum_read_locked'
|
forum_unread_locked: 'forum_read_locked',
|
||||||
};
|
};
|
||||||
|
|
||||||
$('li.row').find('dl[class*="forum_unread"]').each(function() {
|
$('li.row').find('dl[class*="forum_unread"]').each(function() {
|
||||||
var $this = $(this);
|
const $this = $(this);
|
||||||
|
|
||||||
$.each(iconsArray, function(unreadClass, readClass) {
|
$.each(iconsArray, (unreadClass, readClass) => {
|
||||||
if ($this.hasClass(unreadClass)) {
|
if ($this.hasClass(unreadClass)) {
|
||||||
$this.removeClass(unreadClass).addClass(readClass);
|
$this.removeClass(unreadClass).addClass(readClass);
|
||||||
}
|
}
|
||||||
|
@ -37,48 +37,48 @@ phpbb.addAjaxCallback('mark_forums_read', function(res) {
|
||||||
$('[data-ajax="mark_forums_read"]').attr('href', res.U_MARK_FORUMS);
|
$('[data-ajax="mark_forums_read"]').attr('href', res.U_MARK_FORUMS);
|
||||||
|
|
||||||
phpbb.closeDarkenWrapper(3000);
|
phpbb.closeDarkenWrapper(3000);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This callback will mark all topic icons read
|
* This callback will mark all topic icons read
|
||||||
*
|
*
|
||||||
* @param {bool} [update_topic_links=true] Whether "Mark topics read" links
|
* @param {bool} [update_topic_links=true] Whether "Mark topics read" links
|
||||||
* should be updated. Defaults to true.
|
* should be updated. Defaults to true.
|
||||||
*/
|
*/
|
||||||
phpbb.addAjaxCallback('mark_topics_read', function(res, updateTopicLinks) {
|
phpbb.addAjaxCallback('mark_topics_read', (res, updateTopicLinks) => {
|
||||||
var readTitle = res.NO_UNREAD_POSTS;
|
const readTitle = res.NO_UNREAD_POSTS;
|
||||||
var unreadTitle = res.UNREAD_POSTS;
|
const unreadTitle = res.UNREAD_POSTS;
|
||||||
var iconsArray = {
|
const iconsArray = {
|
||||||
global_unread: 'global_read',
|
global_unread: 'global_read',
|
||||||
announce_unread: 'announce_read',
|
announce_unread: 'announce_read',
|
||||||
sticky_unread: 'sticky_read',
|
sticky_unread: 'sticky_read',
|
||||||
topic_unread: 'topic_read'
|
topic_unread: 'topic_read',
|
||||||
};
|
};
|
||||||
var iconsState = ['', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine'];
|
const iconsState = [ '', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine' ];
|
||||||
var unreadClassSelectors;
|
const classMap = {};
|
||||||
var classMap = {};
|
const classNames = [];
|
||||||
var classNames = [];
|
|
||||||
|
|
||||||
if (typeof updateTopicLinks === 'undefined') {
|
if (typeof updateTopicLinks === 'undefined') {
|
||||||
updateTopicLinks = true;
|
updateTopicLinks = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$.each(iconsArray, function(unreadClass, readClass) {
|
$.each(iconsArray, (unreadClass, readClass) => {
|
||||||
$.each(iconsState, function(key, value) {
|
$.each(iconsState, (key, value) => {
|
||||||
// Only topics can be hot
|
// Only topics can be hot
|
||||||
if ((value === '_hot' || value === '_hot_mine') && unreadClass !== 'topic_unread') {
|
if ((value === '_hot' || value === '_hot_mine') && unreadClass !== 'topic_unread') {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
classMap[unreadClass + value] = readClass + value;
|
classMap[unreadClass + value] = readClass + value;
|
||||||
classNames.push(unreadClass + value);
|
classNames.push(unreadClass + value);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
unreadClassSelectors = '.' + classNames.join(',.');
|
const unreadClassSelectors = '.' + classNames.join(',.');
|
||||||
|
|
||||||
$('li.row').find(unreadClassSelectors).each(function() {
|
$('li.row').find(unreadClassSelectors).each(function() {
|
||||||
var $this = $(this);
|
const $this = $(this);
|
||||||
$.each(classMap, function(unreadClass, readClass) {
|
$.each(classMap, (unreadClass, readClass) => {
|
||||||
if ($this.hasClass(unreadClass)) {
|
if ($this.hasClass(unreadClass)) {
|
||||||
$this.removeClass(unreadClass).addClass(readClass);
|
$this.removeClass(unreadClass).addClass(readClass);
|
||||||
}
|
}
|
||||||
|
@ -95,39 +95,39 @@ phpbb.addAjaxCallback('mark_topics_read', function(res, updateTopicLinks) {
|
||||||
}
|
}
|
||||||
|
|
||||||
phpbb.closeDarkenWrapper(3000);
|
phpbb.closeDarkenWrapper(3000);
|
||||||
});
|
});
|
||||||
|
|
||||||
// This callback will mark all notifications read
|
// This callback will mark all notifications read
|
||||||
phpbb.addAjaxCallback('notification.mark_all_read', function(res) {
|
phpbb.addAjaxCallback('notification.mark_all_read', res => {
|
||||||
if (typeof res.success !== 'undefined') {
|
if (typeof res.success !== 'undefined') {
|
||||||
phpbb.markNotifications($('[data-notification-unread="true"]'), 0);
|
phpbb.markNotifications($('[data-notification-unread="true"]'), 0);
|
||||||
phpbb.toggleDropdown.call($('#notification-button'));
|
phpbb.toggleDropdown.call($('#notification-button'));
|
||||||
phpbb.closeDarkenWrapper(3000);
|
phpbb.closeDarkenWrapper(3000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// This callback will mark a notification read
|
// This callback will mark a notification read
|
||||||
phpbb.addAjaxCallback('notification.mark_read', function(res) {
|
phpbb.addAjaxCallback('notification.mark_read', function(res) {
|
||||||
if (typeof res.success !== 'undefined') {
|
if (typeof res.success !== 'undefined') {
|
||||||
var unreadCount = Number($('#notification-button strong').html()) - 1;
|
const unreadCount = Number($('#notification-button strong').html()) - 1;
|
||||||
phpbb.markNotifications($(this).parent('[data-notification-unread="true"]'), unreadCount);
|
phpbb.markNotifications($(this).parent('[data-notification-unread="true"]'), unreadCount);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark notification popup rows as read.
|
* Mark notification popup rows as read.
|
||||||
*
|
*
|
||||||
* @param {jQuery} $popup jQuery object(s) to mark read.
|
* @param {jQuery} $popup jQuery object(s) to mark read.
|
||||||
* @param {int} unreadCount The new unread notifications count.
|
* @param {int} unreadCount The new unread notifications count.
|
||||||
*/
|
*/
|
||||||
phpbb.markNotifications = function($popup, unreadCount) {
|
phpbb.markNotifications = function($popup, unreadCount) {
|
||||||
// Remove the unread status.
|
// Remove the unread status.
|
||||||
$popup.removeClass('bg2');
|
$popup.removeClass('bg2');
|
||||||
$popup.find('a.mark_read').remove();
|
$popup.find('a.mark_read').remove();
|
||||||
|
|
||||||
// Update the notification link to the real URL.
|
// Update the notification link to the real URL.
|
||||||
$popup.each(function() {
|
$popup.each(function() {
|
||||||
var link = $(this).find('a');
|
const link = $(this).find('a');
|
||||||
link.attr('href', link.attr('data-real-url'));
|
link.attr('href', link.attr('data-real-url'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -140,33 +140,34 @@ phpbb.markNotifications = function($popup, unreadCount) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update page title
|
// Update page title
|
||||||
var $title = $('title');
|
const $title = $('title');
|
||||||
var originalTitle = $title.text().replace(/(\((\d+)\))/, '');
|
const originalTitle = $title.text().replace(/(\((\d+)\))/, '');
|
||||||
$title.text((unreadCount ? '(' + unreadCount + ')' : '') + originalTitle);
|
$title.text((unreadCount ? '(' + unreadCount + ')' : '') + originalTitle);
|
||||||
};
|
};
|
||||||
|
|
||||||
// This callback finds the post from the delete link, and removes it.
|
// This callback finds the post from the delete link, and removes it.
|
||||||
phpbb.addAjaxCallback('post_delete', function() {
|
phpbb.addAjaxCallback('post_delete', function() {
|
||||||
var $this = $(this),
|
const $this = $(this);
|
||||||
postId;
|
let postId;
|
||||||
|
|
||||||
if ($this.attr('data-refresh') === undefined) {
|
if ($this.attr('data-refresh') === undefined) {
|
||||||
postId = $this[0].href.split('&p=')[1];
|
postId = $this[0].href.split('&p=')[1];
|
||||||
var post = $this.parents('#p' + postId).css('pointer-events', 'none');
|
const post = $this.parents('#p' + postId).css('pointer-events', 'none');
|
||||||
if (post.hasClass('bg1') || post.hasClass('bg2')) {
|
if (post.hasClass('bg1') || post.hasClass('bg2')) {
|
||||||
var posts1 = post.nextAll('.bg1');
|
const posts1 = post.nextAll('.bg1');
|
||||||
post.nextAll('.bg2').removeClass('bg2').addClass('bg1');
|
post.nextAll('.bg2').removeClass('bg2').addClass('bg1');
|
||||||
posts1.removeClass('bg1').addClass('bg2');
|
posts1.removeClass('bg1').addClass('bg2');
|
||||||
}
|
}
|
||||||
|
|
||||||
post.fadeOut(function() {
|
post.fadeOut(function() {
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// This callback removes the approve / disapprove div or link.
|
// This callback removes the approve / disapprove div or link.
|
||||||
phpbb.addAjaxCallback('post_visibility', function(res) {
|
phpbb.addAjaxCallback('post_visibility', function(res) {
|
||||||
var remove = (res.visible) ? $(this) : $(this).parents('.post');
|
const remove = (res.visible) ? $(this) : $(this).parents('.post');
|
||||||
$(remove).css('pointer-events', 'none').fadeOut(function() {
|
$(remove).css('pointer-events', 'none').fadeOut(function() {
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
});
|
});
|
||||||
|
@ -177,39 +178,40 @@ phpbb.addAjaxCallback('post_visibility', function(res) {
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// This removes the parent row of the link or form that fired the callback.
|
// This removes the parent row of the link or form that fired the callback.
|
||||||
phpbb.addAjaxCallback('row_delete', function() {
|
phpbb.addAjaxCallback('row_delete', function() {
|
||||||
$(this).parents('tr').remove();
|
$(this).parents('tr').remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
// This handles friend / foe additions removals.
|
// This handles friend / foe additions removals.
|
||||||
phpbb.addAjaxCallback('zebra', function(res) {
|
phpbb.addAjaxCallback('zebra', res => {
|
||||||
var zebra;
|
let zebra;
|
||||||
|
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
zebra = $('.zebra');
|
zebra = $('.zebra');
|
||||||
zebra.first().html(res.MESSAGE_TEXT);
|
zebra.first().html(res.MESSAGE_TEXT);
|
||||||
zebra.not(':first').html(' ').prev().html(' ');
|
zebra.not(':first').html(' ').prev().html(' ');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This callback updates the poll results after voting.
|
* This callback updates the poll results after voting.
|
||||||
*/
|
*/
|
||||||
phpbb.addAjaxCallback('vote_poll', function(res) {
|
phpbb.addAjaxCallback('vote_poll', function(res) {
|
||||||
if (typeof res.success !== 'undefined') {
|
if (typeof res.success !== 'undefined') {
|
||||||
var poll = $(this).closest('.topic_poll');
|
const poll = $(this).closest('.topic_poll');
|
||||||
var panel = poll.find('.panel');
|
const panel = poll.find('.panel');
|
||||||
var resultsVisible = poll.find('dl:first-child .resultbar').is(':visible');
|
const resultsVisible = poll.find('dl:first-child .resultbar').is(':visible');
|
||||||
var mostVotes = 0;
|
let mostVotes = 0;
|
||||||
|
|
||||||
// Set min-height to prevent the page from jumping when the content changes
|
// Set min-height to prevent the page from jumping when the content changes
|
||||||
var updatePanelHeight = function (height) {
|
const updatePanelHeight = function(height) {
|
||||||
height = (typeof height === 'undefined') ? panel.find('.inner').outerHeight() : height;
|
height = (typeof height === 'undefined') ? panel.find('.inner').outerHeight() : height;
|
||||||
panel.css('min-height', height);
|
panel.css('min-height', height);
|
||||||
};
|
};
|
||||||
|
|
||||||
updatePanelHeight();
|
updatePanelHeight();
|
||||||
|
|
||||||
// Remove the View results link
|
// Remove the View results link
|
||||||
|
@ -217,19 +219,19 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
|
||||||
poll.find('.poll_view_results').hide(500);
|
poll.find('.poll_view_results').hide(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!res.can_vote) {
|
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
|
// If the user can still vote, simply slide down the results
|
||||||
poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500);
|
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, () => {
|
||||||
|
poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the votes count of the highest poll option
|
// Get the votes count of the highest poll option
|
||||||
poll.find('[data-poll-option-id]').each(function() {
|
poll.find('[data-poll-option-id]').each(function() {
|
||||||
var option = $(this);
|
const option = $(this);
|
||||||
var optionId = option.attr('data-poll-option-id');
|
const optionId = option.attr('data-poll-option-id');
|
||||||
mostVotes = (res.vote_counts[optionId] >= mostVotes) ? res.vote_counts[optionId] : mostVotes;
|
mostVotes = (res.vote_counts[optionId] >= mostVotes) ? res.vote_counts[optionId] : mostVotes;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -238,35 +240,35 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
|
||||||
|
|
||||||
// Update each option
|
// Update each option
|
||||||
poll.find('[data-poll-option-id]').each(function() {
|
poll.find('[data-poll-option-id]').each(function() {
|
||||||
var $this = $(this);
|
const $this = $(this);
|
||||||
var optionId = $this.attr('data-poll-option-id');
|
const optionId = $this.attr('data-poll-option-id');
|
||||||
var voted = (typeof res.user_votes[optionId] !== 'undefined');
|
const voted = (typeof res.user_votes[optionId] !== 'undefined');
|
||||||
var mostVoted = (res.vote_counts[optionId] === mostVotes);
|
const mostVoted = (res.vote_counts[optionId] === mostVotes);
|
||||||
var percent = (!res.total_votes) ? 0 : Math.round((res.vote_counts[optionId] / res.total_votes) * 100);
|
const percent = res.total_votes ? Math.round((res.vote_counts[optionId] / res.total_votes) * 100) : 0;
|
||||||
var percentRel = (mostVotes === 0) ? 0 : Math.round((res.vote_counts[optionId] / mostVotes) * 100);
|
const percentRel = (mostVotes === 0) ? 0 : Math.round((res.vote_counts[optionId] / mostVotes) * 100);
|
||||||
var altText;
|
|
||||||
|
|
||||||
altText = $this.attr('data-alt-text');
|
const altText = $this.attr('data-alt-text');
|
||||||
if (voted) {
|
if (voted) {
|
||||||
$this.attr('title', $.trim(altText));
|
$this.attr('title', $.trim(altText));
|
||||||
} else {
|
} else {
|
||||||
$this.attr('title', '');
|
$this.attr('title', '');
|
||||||
};
|
}
|
||||||
|
|
||||||
$this.toggleClass('voted', voted);
|
$this.toggleClass('voted', voted);
|
||||||
$this.toggleClass('most-votes', mostVoted);
|
$this.toggleClass('most-votes', mostVoted);
|
||||||
|
|
||||||
// Update the bars
|
// Update the bars
|
||||||
var bar = $this.find('.resultbar div');
|
const bar = $this.find('.resultbar div');
|
||||||
var barTimeLapse = (res.can_vote) ? 500 : 1500;
|
const barTimeLapse = (res.can_vote) ? 500 : 1500;
|
||||||
var newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1);
|
const newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1);
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
bar.animate({ width: percentRel + '%' }, 500)
|
bar.animate({ width: percentRel + '%' }, 500)
|
||||||
.removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5')
|
.removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5')
|
||||||
.addClass(newBarClass)
|
.addClass(newBarClass)
|
||||||
.html(res.vote_counts[optionId]);
|
.html(res.vote_counts[optionId]);
|
||||||
|
|
||||||
var percentText = percent ? percent + '%' : res.NO_VOTES;
|
const percentText = percent ? percent + '%' : res.NO_VOTES;
|
||||||
$this.find('.poll_option_percent').html(percentText);
|
$this.find('.poll_option_percent').html(percentText);
|
||||||
}, barTimeLapse);
|
}, barTimeLapse);
|
||||||
});
|
});
|
||||||
|
@ -276,111 +278,108 @@ phpbb.addAjaxCallback('vote_poll', function(res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display "Your vote has been cast." message. Disappears after 5 seconds.
|
// Display "Your vote has been cast." message. Disappears after 5 seconds.
|
||||||
var confirmationDelay = (res.can_vote) ? 300 : 900;
|
const confirmationDelay = (res.can_vote) ? 300 : 900;
|
||||||
poll.find('.vote-submitted').delay(confirmationDelay).slideDown(200, function() {
|
poll.find('.vote-submitted').delay(confirmationDelay).slideDown(200, function() {
|
||||||
if (resultsVisible) {
|
if (resultsVisible) {
|
||||||
updatePanelHeight();
|
updatePanelHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
$(this).delay(5000).fadeOut(500, function() {
|
$(this).delay(5000).fadeOut(500, () => {
|
||||||
resizePanel(300);
|
resizePanel(300);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Remove the gap resulting from removing options
|
// Remove the gap resulting from removing options
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
resizePanel(500);
|
resizePanel(500);
|
||||||
}, 1500);
|
}, 1500);
|
||||||
|
|
||||||
var resizePanel = function (time) {
|
const resizePanel = function(time) {
|
||||||
var panelHeight = panel.height();
|
const panelHeight = panel.height();
|
||||||
var innerHeight = panel.find('.inner').outerHeight();
|
const innerHeight = panel.find('.inner').outerHeight();
|
||||||
|
|
||||||
if (panelHeight !== innerHeight) {
|
if (panelHeight !== innerHeight) {
|
||||||
panel.css({ minHeight: '', height: panelHeight })
|
panel.css({ minHeight: '', height: panelHeight })
|
||||||
.animate({ height: innerHeight }, time, function () {
|
.animate({ height: innerHeight }, time, () => {
|
||||||
panel.css({ minHeight: innerHeight, height: '' });
|
panel.css({ minHeight: innerHeight, height: '' });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show poll results when clicking View results link.
|
* Show poll results when clicking View results link.
|
||||||
*/
|
*/
|
||||||
$('.poll_view_results a').click(function(e) {
|
$('.poll_view_results a').click(function(e) {
|
||||||
// Do not follow the link
|
// Do not follow the link
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var $poll = $(this).parents('.topic_poll');
|
const $poll = $(this).parents('.topic_poll');
|
||||||
|
|
||||||
$poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500);
|
$poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500);
|
||||||
$poll.find('.poll_view_results').hide(500);
|
$poll.find('.poll_view_results').hide(500);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('[data-ajax]').each(function() {
|
$('[data-ajax]').each(function() {
|
||||||
var $this = $(this);
|
const $this = $(this);
|
||||||
var ajax = $this.attr('data-ajax');
|
const ajax = $this.attr('data-ajax');
|
||||||
var filter = $this.attr('data-filter');
|
let filter = $this.attr('data-filter');
|
||||||
|
|
||||||
if (ajax !== 'false') {
|
if (ajax !== 'false') {
|
||||||
var fn = (ajax !== 'true') ? ajax : null;
|
const fn = ajax === 'true' ? null : ajax;
|
||||||
filter = (filter !== undefined) ? phpbb.getFunctionByName(filter) : null;
|
filter = filter === undefined ? null : phpbb.getFunctionByName(filter);
|
||||||
|
|
||||||
phpbb.ajaxify({
|
phpbb.ajaxify({
|
||||||
selector: this,
|
selector: this,
|
||||||
refresh: $this.attr('data-refresh') !== undefined,
|
refresh: $this.attr('data-refresh') !== undefined,
|
||||||
filter: filter,
|
filter,
|
||||||
callback: fn
|
callback: fn,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This simply appends #preview to the action of the
|
* This simply appends #preview to the action of the
|
||||||
* QR action when you click the Full Editor & Preview button
|
* QR action when you click the Full Editor & Preview button
|
||||||
*/
|
*/
|
||||||
$('#qr_full_editor').click(function() {
|
$('#qr_full_editor').click(() => {
|
||||||
$('#qr_postform').attr('action', function(i, val) {
|
$('#qr_postform').attr('action', (i, val) => val + '#preview');
|
||||||
return val + '#preview';
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
|
||||||
* Make the display post links to use JS
|
* Make the display post links to use JS
|
||||||
*/
|
*/
|
||||||
$('.display_post').click(function(e) {
|
$('.display_post').click(function(e) {
|
||||||
// Do not follow the link
|
// Do not follow the link
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var postId = $(this).attr('data-post-id');
|
const postId = $(this).attr('data-post-id');
|
||||||
$('#post_content' + postId).show();
|
$('#post_content' + postId).show();
|
||||||
$('#profile' + postId).show();
|
$('#profile' + postId).show();
|
||||||
$('#post_hidden' + postId).hide();
|
$('#post_hidden' + postId).hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display hidden post on post review page
|
* Display hidden post on post review page
|
||||||
*/
|
*/
|
||||||
$('.display_post_review').on('click', function(e) {
|
$('.display_post_review').on('click', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
let $displayPostLink = $(this);
|
const $displayPostLink = $(this);
|
||||||
$displayPostLink.closest('.post-ignore').removeClass('post-ignore');
|
$displayPostLink.closest('.post-ignore').removeClass('post-ignore');
|
||||||
$displayPostLink.hide();
|
$displayPostLink.hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle the member search panel in memberlist.php.
|
* Toggle the member search panel in memberlist.php.
|
||||||
*
|
*
|
||||||
* If user returns to search page after viewing results the search panel is automatically displayed.
|
* If user returns to search page after viewing results the search panel is automatically displayed.
|
||||||
* In any case the link will toggle the display status of the search panel and link text will be
|
* In any case the link will toggle the display status of the search panel and link text will be
|
||||||
* appropriately changed based on the status of the search panel.
|
* appropriately changed based on the status of the search panel.
|
||||||
*/
|
*/
|
||||||
$('#member_search').click(function () {
|
$('#member_search').click(function() {
|
||||||
var $memberlistSearch = $('#memberlist_search');
|
const $memberlistSearch = $('#memberlist_search');
|
||||||
|
|
||||||
$memberlistSearch.slideToggle('fast');
|
$memberlistSearch.slideToggle('fast');
|
||||||
phpbb.ajaxCallbacks.alt_text.call(this);
|
phpbb.ajaxCallbacks.alt_text.call(this);
|
||||||
|
@ -389,17 +388,18 @@ $('#member_search').click(function () {
|
||||||
if ($memberlistSearch.is(':visible')) {
|
if ($memberlistSearch.is(':visible')) {
|
||||||
$('#username').focus();
|
$('#username').focus();
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
* Show to top button if available on page
|
* Show to top button if available on page
|
||||||
*/
|
*/
|
||||||
const $scrollTopButton = $('.to-top-button');
|
const $scrollTopButton = $('.to-top-button');
|
||||||
|
|
||||||
if ($scrollTopButton.length) {
|
if ($scrollTopButton.length) {
|
||||||
// Show or hide the button based on scroll position
|
// Show or hide the button based on scroll position
|
||||||
$(window).scroll(function () {
|
$(window).scroll(function() {
|
||||||
if ($(this).scrollTop() > 300) {
|
if ($(this).scrollTop() > 300) {
|
||||||
$scrollTopButton.fadeIn(); // Fade in the button
|
$scrollTopButton.fadeIn(); // Fade in the button
|
||||||
} else {
|
} else {
|
||||||
|
@ -408,20 +408,18 @@ if ($scrollTopButton.length) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Scroll smoothly to the top when the button is clicked
|
// Scroll smoothly to the top when the button is clicked
|
||||||
$scrollTopButton.click(function (e) {
|
$scrollTopButton.click(e => {
|
||||||
e.preventDefault(); // Prevent the default anchor link behavior
|
e.preventDefault(); // Prevent the default anchor link behavior
|
||||||
$('html, body').animate({scrollTop: 0}, 500); // Smooth scroll to top
|
$('html, body').animate({ scrollTop: 0 }, 500); // Smooth scroll to top
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically resize textarea
|
* Automatically resize textarea
|
||||||
*/
|
*/
|
||||||
$(function() {
|
$(() => {
|
||||||
var $textarea = $('textarea:not(#message-box textarea, .no-auto-resize)');
|
const $textarea = $('textarea:not(#message-box textarea, .no-auto-resize)');
|
||||||
phpbb.resizeTextArea($textarea, { minHeight: 75, maxHeight: 250 });
|
phpbb.resizeTextArea($textarea, { minHeight: 75, maxHeight: 250 });
|
||||||
phpbb.resizeTextArea($('textarea', '#message-box'));
|
phpbb.resizeTextArea($('textarea', '#message-box'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
})(jQuery); // Avoid conflicts with other libraries
|
})(jQuery); // Avoid conflicts with other libraries
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
/* global phpbb */
|
/* global phpbb */
|
||||||
|
/* eslint camelcase: 0 */
|
||||||
|
/* eslint no-unused-vars: 0 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* phpBB forum functions
|
* phpBB forum functions
|
||||||
|
@ -34,10 +36,10 @@ function popup(url, width, height, name) {
|
||||||
function pageJump(item) {
|
function pageJump(item) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var page = parseInt(item.val(), 10),
|
const page = parseInt(item.val(), 10);
|
||||||
perPage = item.attr('data-per-page'),
|
const perPage = item.attr('data-per-page');
|
||||||
baseUrl = item.attr('data-base-url'),
|
const baseUrl = item.attr('data-base-url');
|
||||||
startName = item.attr('data-start-name');
|
const startName = item.attr('data-start-name');
|
||||||
|
|
||||||
if (page !== null && !isNaN(page) && page === Math.floor(page) && page > 0) {
|
if (page !== null && !isNaN(page) && page === Math.floor(page) && page > 0) {
|
||||||
if (baseUrl.indexOf('?') === -1) {
|
if (baseUrl.indexOf('?') === -1) {
|
||||||
|
@ -56,7 +58,7 @@ function marklist(id, name, state) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jQuery('#' + id + ' input[type=checkbox][name]').each(function() {
|
jQuery('#' + id + ' input[type=checkbox][name]').each(function() {
|
||||||
var $this = jQuery(this);
|
const $this = jQuery(this);
|
||||||
if ($this.attr('name').substr(0, name.length) === name && !$this.prop('disabled')) {
|
if ($this.attr('name').substr(0, name.length) === name && !$this.prop('disabled')) {
|
||||||
$this.prop('checked', state);
|
$this.prop('checked', state);
|
||||||
}
|
}
|
||||||
|
@ -78,39 +80,38 @@ function viewableArea(e, itself) {
|
||||||
e = e.parentNode;
|
e = e.parentNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!e.vaHeight) {
|
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 {
|
||||||
// Store viewable area height before changing style to auto
|
// Store viewable area height before changing style to auto
|
||||||
e.vaHeight = e.offsetHeight;
|
e.vaHeight = e.offsetHeight;
|
||||||
e.vaMaxHeight = e.style.maxHeight;
|
e.vaMaxHeight = e.style.maxHeight;
|
||||||
e.style.height = 'auto';
|
e.style.height = 'auto';
|
||||||
e.style.maxHeight = 'none';
|
e.style.maxHeight = 'none';
|
||||||
e.style.overflow = 'visible';
|
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
|
* Alternate display of subPanels
|
||||||
*/
|
*/
|
||||||
jQuery(function($) {
|
jQuery($ => {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
$('.sub-panels').each(function() {
|
$('.sub-panels').each(function() {
|
||||||
|
const $childNodes = $('a[data-subpanel]', this);
|
||||||
var $childNodes = $('a[data-subpanel]', this),
|
const panels = $childNodes.map(function() {
|
||||||
panels = $childNodes.map(function () {
|
|
||||||
return this.getAttribute('data-subpanel');
|
return this.getAttribute('data-subpanel');
|
||||||
}),
|
});
|
||||||
showPanel = this.getAttribute('data-show-panel');
|
const showPanel = this.getAttribute('data-show-panel');
|
||||||
|
|
||||||
if (panels.length) {
|
if (panels.length) {
|
||||||
activateSubPanel(showPanel, panels);
|
activateSubPanel(showPanel, panels);
|
||||||
$childNodes.click(function () {
|
$childNodes.click(function() {
|
||||||
activateSubPanel(this.getAttribute('data-subpanel'), panels);
|
activateSubPanel(this.getAttribute('data-subpanel'), panels);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
@ -124,11 +125,13 @@ jQuery(function($) {
|
||||||
function activateSubPanel(p, panels) {
|
function activateSubPanel(p, panels) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var i, showPanel;
|
let i;
|
||||||
|
let showPanel;
|
||||||
|
|
||||||
if (typeof p === 'string') {
|
if (typeof p === 'string') {
|
||||||
showPanel = p;
|
showPanel = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('input[name="show_panel"]').val(showPanel);
|
$('input[name="show_panel"]').val(showPanel);
|
||||||
|
|
||||||
if (typeof panels === 'undefined') {
|
if (typeof panels === 'undefined') {
|
||||||
|
@ -147,15 +150,16 @@ function selectCode(a) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Get ID of code block
|
// Get ID of code block
|
||||||
var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
|
const e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
|
||||||
var s, r;
|
let s;
|
||||||
|
let r;
|
||||||
|
|
||||||
// Not IE and IE9+
|
// Not IE and IE9+
|
||||||
if (window.getSelection) {
|
if (window.getSelection) {
|
||||||
s = window.getSelection();
|
s = window.getSelection();
|
||||||
// Safari and Chrome
|
// Safari and Chrome
|
||||||
if (s.setBaseAndExtent) {
|
if (s.setBaseAndExtent) {
|
||||||
var l = (e.innerText.length > 1) ? e.innerText.length - 1 : 1;
|
const l = (e.innerText.length > 1) ? e.innerText.length - 1 : 1;
|
||||||
try {
|
try {
|
||||||
s.setBaseAndExtent(e, 0, e, l);
|
s.setBaseAndExtent(e, 0, e, l);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -164,12 +168,11 @@ function selectCode(a) {
|
||||||
s.removeAllRanges();
|
s.removeAllRanges();
|
||||||
s.addRange(r);
|
s.addRange(r);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
// Firefox and Opera
|
// Firefox and Opera
|
||||||
else {
|
|
||||||
// workaround for bug # 42885
|
// workaround for bug # 42885
|
||||||
if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) === '<BR>') {
|
if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) === '<BR>') {
|
||||||
e.innerHTML = e.innerHTML + ' ';
|
e.innerHTML += ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
r = document.createRange();
|
r = document.createRange();
|
||||||
|
@ -177,25 +180,23 @@ function selectCode(a) {
|
||||||
s.removeAllRanges();
|
s.removeAllRanges();
|
||||||
s.addRange(r);
|
s.addRange(r);
|
||||||
}
|
}
|
||||||
}
|
} else if (document.getSelection) {
|
||||||
// Some older browsers
|
// Some older browsers
|
||||||
else if (document.getSelection) {
|
|
||||||
s = document.getSelection();
|
s = document.getSelection();
|
||||||
r = document.createRange();
|
r = document.createRange();
|
||||||
r.selectNodeContents(e);
|
r.selectNodeContents(e);
|
||||||
s.removeAllRanges();
|
s.removeAllRanges();
|
||||||
s.addRange(r);
|
s.addRange(r);
|
||||||
}
|
} else if (document.selection) {
|
||||||
// IE
|
// IE
|
||||||
else if (document.selection) {
|
|
||||||
r = document.body.createTextRange();
|
r = document.body.createTextRange();
|
||||||
r.moveToElementText(e);
|
r.moveToElementText(e);
|
||||||
r.select();
|
r.select();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var inAutocomplete = false;
|
let inAutocomplete = false;
|
||||||
var lastKeyEntered = '';
|
let lastKeyEntered = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check event key
|
* Check event key
|
||||||
|
@ -229,11 +230,11 @@ function phpbbCheckKey(event) {
|
||||||
/**
|
/**
|
||||||
* Apply onkeypress event for forcing default submit button on ENTER key press
|
* Apply onkeypress event for forcing default submit button on ENTER key press
|
||||||
*/
|
*/
|
||||||
jQuery(function($) {
|
jQuery($ => {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
$('form input[type=text], form input[type=password]').on('keypress', function (e) {
|
$('form input[type=text], form input[type=password]').on('keypress', function(e) {
|
||||||
var defaultButton = $(this).parents('form').find('input[type=submit].default-submit-action');
|
const defaultButton = $(this).parents('form').find('input[type=submit].default-submit-action');
|
||||||
|
|
||||||
if (!defaultButton || defaultButton.length <= 0) {
|
if (!defaultButton || defaultButton.length <= 0) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -258,10 +259,10 @@ jQuery(function($) {
|
||||||
function insertUser(formId, value) {
|
function insertUser(formId, value) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var $form = jQuery(formId),
|
const $form = jQuery(formId);
|
||||||
formName = $form.attr('data-form-name'),
|
const formName = $form.attr('data-form-name');
|
||||||
fieldName = $form.attr('data-field-name'),
|
const fieldName = $form.attr('data-field-name');
|
||||||
item = opener.document.forms[formName][fieldName];
|
const item = opener.document.forms[formName][fieldName];
|
||||||
|
|
||||||
if (item.value.length && item.type === 'textarea') {
|
if (item.value.length && item.type === 'textarea') {
|
||||||
value = item.value + '\n' + value;
|
value = item.value + '\n' + value;
|
||||||
|
@ -293,9 +294,9 @@ function insert_single_user(formId, user) {
|
||||||
function parseDocument($container) {
|
function parseDocument($container) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var test = document.createElement('div'),
|
const test = document.createElement('div');
|
||||||
oldBrowser = (typeof test.style.borderRadius === 'undefined'),
|
const oldBrowser = (typeof test.style.borderRadius === 'undefined');
|
||||||
$body = $('body');
|
const $body = $('body');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset avatar dimensions when changing URL or EMAIL
|
* Reset avatar dimensions when changing URL or EMAIL
|
||||||
|
@ -308,7 +309,7 @@ function parseDocument($container) {
|
||||||
* Pagination
|
* Pagination
|
||||||
*/
|
*/
|
||||||
$container.find('.pagination .page-jump-form :button').click(function() {
|
$container.find('.pagination .page-jump-form :button').click(function() {
|
||||||
var $input = $(this).siblings('input.inputbox');
|
const $input = $(this).siblings('input.inputbox');
|
||||||
pageJump($input);
|
pageJump($input);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -320,9 +321,9 @@ function parseDocument($container) {
|
||||||
});
|
});
|
||||||
|
|
||||||
$container.find('.pagination .dropdown-trigger').click(function() {
|
$container.find('.pagination .dropdown-trigger').click(function() {
|
||||||
var $dropdownContainer = $(this).parent();
|
const $dropdownContainer = $(this).parent();
|
||||||
// Wait a little bit to make sure the dropdown has activated
|
// Wait a little bit to make sure the dropdown has activated
|
||||||
setTimeout(function() {
|
setTimeout(() => {
|
||||||
if ($dropdownContainer.hasClass('dropdown-visible')) {
|
if ($dropdownContainer.hasClass('dropdown-visible')) {
|
||||||
$dropdownContainer.find('input.inputbox').focus();
|
$dropdownContainer.find('input.inputbox').focus();
|
||||||
}
|
}
|
||||||
|
@ -333,28 +334,27 @@ function parseDocument($container) {
|
||||||
* Resize navigation (breadcrumbs) block to keep all links on same line
|
* Resize navigation (breadcrumbs) block to keep all links on same line
|
||||||
*/
|
*/
|
||||||
$container.find('.navlinks').each(function() {
|
$container.find('.navlinks').each(function() {
|
||||||
var $this = $(this),
|
const $this = $(this);
|
||||||
$left = $this.children().not('.rightside'),
|
const $left = $this.children().not('.rightside');
|
||||||
$right = $this.children('.rightside');
|
const $right = $this.children('.rightside');
|
||||||
|
|
||||||
if ($left.length !== 1 || !$right.length) {
|
if ($left.length !== 1 || !$right.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function resize() {
|
function resize() {
|
||||||
var width = 0,
|
let width = 0;
|
||||||
diff = $left.outerWidth(true) - $left.width(),
|
const diff = $left.outerWidth(true) - $left.width();
|
||||||
minWidth = Math.max($this.width() / 3, 240),
|
const minWidth = Math.max($this.width() / 3, 240);
|
||||||
maxWidth;
|
|
||||||
|
|
||||||
$right.each(function() {
|
$right.each(function() {
|
||||||
var $this = $(this);
|
const $this = $(this);
|
||||||
if ($this.is(':visible')) {
|
if ($this.is(':visible')) {
|
||||||
width += $this.outerWidth(true);
|
width += $this.outerWidth(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
maxWidth = $this.width() - width - diff;
|
const maxWidth = $this.width() - width - diff;
|
||||||
$left.css('max-width', Math.floor(Math.max(maxWidth, minWidth)) + 'px');
|
$left.css('max-width', Math.floor(Math.max(maxWidth, minWidth)) + 'px');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,25 +366,25 @@ function parseDocument($container) {
|
||||||
* Makes breadcrumbs responsive
|
* Makes breadcrumbs responsive
|
||||||
*/
|
*/
|
||||||
$container.find('.breadcrumbs:not([data-skip-responsive])').each(function() {
|
$container.find('.breadcrumbs:not([data-skip-responsive])').each(function() {
|
||||||
var $this = $(this),
|
const $this = $(this);
|
||||||
$links = $this.find('.crumb'),
|
const $links = $this.find('.crumb');
|
||||||
length = $links.length,
|
const { length } = $links;
|
||||||
classes = ['wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny'],
|
const classes = [ 'wrapped-max', 'wrapped-wide', 'wrapped-medium', 'wrapped-small', 'wrapped-tiny' ];
|
||||||
classesLength = classes.length,
|
const classesLength = classes.length;
|
||||||
maxHeight = 0,
|
let maxHeight = 0;
|
||||||
lastWidth = false,
|
let lastWidth = false;
|
||||||
wrapped = false;
|
let wrapped = false;
|
||||||
|
|
||||||
// Set tooltips
|
// Set tooltips
|
||||||
$this.find('a').each(function() {
|
$this.find('a').each(function() {
|
||||||
var $link = $(this);
|
const $link = $(this);
|
||||||
$link.attr('title', $link.text());
|
$link.attr('title', $link.text());
|
||||||
});
|
});
|
||||||
|
|
||||||
// Function that checks breadcrumbs
|
// Function that checks breadcrumbs
|
||||||
function check() {
|
function check() {
|
||||||
var height = $this.height(),
|
const height = $this.height();
|
||||||
width;
|
let width;
|
||||||
|
|
||||||
// Test max-width set in code for .navlinks above
|
// Test max-width set in code for .navlinks above
|
||||||
width = parseInt($this.css('max-width'), 10);
|
width = parseInt($this.css('max-width'), 10);
|
||||||
|
@ -404,6 +404,7 @@ function parseDocument($container) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lastWidth = width;
|
lastWidth = width;
|
||||||
|
|
||||||
if (wrapped) {
|
if (wrapped) {
|
||||||
|
@ -419,8 +420,8 @@ function parseDocument($container) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < classesLength; i++) {
|
for (let i = 0; i < classesLength; i++) {
|
||||||
for (var j = length - 1; j >= 0; j--) {
|
for (let j = length - 1; j >= 0; j--) {
|
||||||
$links.eq(j).addClass('wrapped ' + classes[i]);
|
$links.eq(j).addClass('wrapped ' + classes[i]);
|
||||||
if ($this.height() <= maxHeight) {
|
if ($this.height() <= maxHeight) {
|
||||||
return;
|
return;
|
||||||
|
@ -454,23 +455,23 @@ function parseDocument($container) {
|
||||||
* responsive-show-all to list of classes
|
* responsive-show-all to list of classes
|
||||||
*/
|
*/
|
||||||
$container.find('.topiclist.responsive-show-all > li > dl').each(function() {
|
$container.find('.topiclist.responsive-show-all > li > dl').each(function() {
|
||||||
var $this = $(this),
|
const $this = $(this);
|
||||||
$block = $this.find('dt .responsive-show:last-child'),
|
let $block = $this.find('dt .responsive-show:last-child');
|
||||||
first = true;
|
let first = true;
|
||||||
|
|
||||||
// Create block that is visible only on mobile devices
|
// Create block that is visible only on mobile devices
|
||||||
if (!$block.length) {
|
if ($block.length) {
|
||||||
|
first = ($.trim($block.text()).length === 0);
|
||||||
|
} else {
|
||||||
$this.find('dt > .list-inner').append('<div class="responsive-show" style="display:none;" />');
|
$this.find('dt > .list-inner').append('<div class="responsive-show" style="display:none;" />');
|
||||||
$block = $this.find('dt .responsive-show:last-child');
|
$block = $this.find('dt .responsive-show:last-child');
|
||||||
} else {
|
|
||||||
first = ($.trim($block.text()).length === 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy contents of each column
|
// Copy contents of each column
|
||||||
$this.find('dd').not('.mark').each(function() {
|
$this.find('dd').not('.mark').each(function() {
|
||||||
var column = $(this),
|
const column = $(this);
|
||||||
$children = column.children(),
|
const $children = column.children();
|
||||||
html = column.html();
|
let html = column.html();
|
||||||
|
|
||||||
if ($children.length === 1 && $children.text() === column.text()) {
|
if ($children.length === 1 && $children.text() === column.text()) {
|
||||||
html = $children.html();
|
html = $children.html();
|
||||||
|
@ -490,13 +491,13 @@ function parseDocument($container) {
|
||||||
* responsive-show-columns to list of classes
|
* responsive-show-columns to list of classes
|
||||||
*/
|
*/
|
||||||
$container.find('.topiclist.responsive-show-columns').each(function() {
|
$container.find('.topiclist.responsive-show-columns').each(function() {
|
||||||
var $list = $(this),
|
const $list = $(this);
|
||||||
headers = [],
|
const headers = [];
|
||||||
headersLength = 0;
|
let headersLength = 0;
|
||||||
|
|
||||||
// Find all headers, get contents
|
// Find all headers, get contents
|
||||||
$list.prev('.topiclist').find('li.header dd').not('.mark').each(function() {
|
$list.prev('.topiclist').find('li.header dd').not('.mark').each(function() {
|
||||||
headers.push($("<div>").text($(this).text()).html());
|
headers.push($('<div>').text($(this).text()).html());
|
||||||
headersLength++;
|
headersLength++;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -506,23 +507,23 @@ function parseDocument($container) {
|
||||||
|
|
||||||
// Parse each row
|
// Parse each row
|
||||||
$list.find('dl').each(function() {
|
$list.find('dl').each(function() {
|
||||||
var $this = $(this),
|
const $this = $(this);
|
||||||
$block = $this.find('dt .responsive-show:last-child'),
|
let $block = $this.find('dt .responsive-show:last-child');
|
||||||
first = true;
|
let first = true;
|
||||||
|
|
||||||
// Create block that is visible only on mobile devices
|
// Create block that is visible only on mobile devices
|
||||||
if (!$block.length) {
|
if ($block.length) {
|
||||||
|
first = ($.trim($block.text()).length === 0);
|
||||||
|
} else {
|
||||||
$this.find('dt > .list-inner').append('<div class="responsive-show" style="display:none;" />');
|
$this.find('dt > .list-inner').append('<div class="responsive-show" style="display:none;" />');
|
||||||
$block = $this.find('dt .responsive-show:last-child');
|
$block = $this.find('dt .responsive-show:last-child');
|
||||||
} else {
|
|
||||||
first = ($.trim($block.text()).length === 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy contents of each column
|
// Copy contents of each column
|
||||||
$this.find('dd').not('.mark').each(function(i) {
|
$this.find('dd').not('.mark').each(function(i) {
|
||||||
var column = $(this),
|
const column = $(this);
|
||||||
children = column.children(),
|
const children = column.children();
|
||||||
html = column.html();
|
let html = column.html();
|
||||||
|
|
||||||
if (children.length === 1 && children.text() === column.text()) {
|
if (children.length === 1 && children.text() === column.text()) {
|
||||||
html = children.html();
|
html = children.html();
|
||||||
|
@ -544,24 +545,25 @@ function parseDocument($container) {
|
||||||
* Responsive tables
|
* Responsive tables
|
||||||
*/
|
*/
|
||||||
$container.find('table.table1').not('.not-responsive').each(function() {
|
$container.find('table.table1').not('.not-responsive').each(function() {
|
||||||
var $this = $(this),
|
const $this = $(this);
|
||||||
$th = $this.find('thead > tr > th'),
|
const $th = $this.find('thead > tr > th');
|
||||||
headers = [],
|
const headers = [];
|
||||||
totalHeaders = 0,
|
let totalHeaders = 0;
|
||||||
i, headersLength;
|
let i;
|
||||||
|
|
||||||
// Find each header
|
// Find each header
|
||||||
$th.each(function(column) {
|
$th.each(function(column) {
|
||||||
var cell = $(this),
|
const cell = $(this);
|
||||||
colspan = parseInt(cell.attr('colspan'), 10),
|
let colspan = parseInt(cell.attr('colspan'), 10);
|
||||||
dfn = cell.attr('data-dfn'),
|
const dfn = cell.attr('data-dfn');
|
||||||
text = dfn ? dfn : cell.text();
|
const text = dfn ? dfn : cell.text();
|
||||||
|
|
||||||
colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan;
|
colspan = isNaN(colspan) || colspan < 1 ? 1 : colspan;
|
||||||
|
|
||||||
for (i = 0; i < colspan; i++) {
|
for (i = 0; i < colspan; i++) {
|
||||||
headers.push(text);
|
headers.push(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
totalHeaders++;
|
totalHeaders++;
|
||||||
|
|
||||||
if (dfn && !column) {
|
if (dfn && !column) {
|
||||||
|
@ -569,7 +571,7 @@ function parseDocument($container) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
headersLength = headers.length;
|
const headersLength = headers.length;
|
||||||
|
|
||||||
// Add header text to each cell as <dfn>
|
// Add header text to each cell as <dfn>
|
||||||
$this.addClass('responsive');
|
$this.addClass('responsive');
|
||||||
|
@ -580,9 +582,9 @@ function parseDocument($container) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this.find('tbody > tr').each(function() {
|
$this.find('tbody > tr').each(function() {
|
||||||
var row = $(this),
|
const row = $(this);
|
||||||
cells = row.children('td'),
|
const cells = row.children('td');
|
||||||
column = 0;
|
let column = 0;
|
||||||
|
|
||||||
if (cells.length === 1) {
|
if (cells.length === 1) {
|
||||||
row.addClass('big-column');
|
row.addClass('big-column');
|
||||||
|
@ -590,9 +592,9 @@ function parseDocument($container) {
|
||||||
}
|
}
|
||||||
|
|
||||||
cells.each(function() {
|
cells.each(function() {
|
||||||
var cell = $(this),
|
const cell = $(this);
|
||||||
colspan = parseInt(cell.attr('colspan'), 10),
|
let colspan = parseInt(cell.attr('colspan'), 10);
|
||||||
text = $.trim(cell.text());
|
const text = $.trim(cell.text());
|
||||||
|
|
||||||
if (headersLength <= column) {
|
if (headersLength <= column) {
|
||||||
return;
|
return;
|
||||||
|
@ -600,7 +602,7 @@ function parseDocument($container) {
|
||||||
|
|
||||||
if ((text.length && text !== '-') || cell.children().length) {
|
if ((text.length && text !== '-') || cell.children().length) {
|
||||||
if (headers[column].length) {
|
if (headers[column].length) {
|
||||||
cell.prepend($("<dfn>").css('display', 'none').text(headers[column]));
|
cell.prepend($('<dfn>').css('display', 'none').text(headers[column]));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cell.addClass('empty');
|
cell.addClass('empty');
|
||||||
|
@ -616,7 +618,7 @@ function parseDocument($container) {
|
||||||
* Hide empty responsive tables
|
* Hide empty responsive tables
|
||||||
*/
|
*/
|
||||||
$container.find('table.responsive > tbody').not('.responsive-skip-empty').each(function() {
|
$container.find('table.responsive > tbody').not('.responsive-skip-empty').each(function() {
|
||||||
var $items = $(this).children('tr');
|
const $items = $(this).children('tr');
|
||||||
if (!$items.length) {
|
if (!$items.length) {
|
||||||
$(this).parent('table:first').addClass('responsive-hide');
|
$(this).parent('table:first').addClass('responsive-hide');
|
||||||
}
|
}
|
||||||
|
@ -626,24 +628,24 @@ function parseDocument($container) {
|
||||||
* Responsive tabs
|
* Responsive tabs
|
||||||
*/
|
*/
|
||||||
$container.find('#tabs, #minitabs').not('[data-skip-responsive]').each(function() {
|
$container.find('#tabs, #minitabs').not('[data-skip-responsive]').each(function() {
|
||||||
var $this = $(this),
|
const $this = $(this);
|
||||||
$ul = $this.children(),
|
const $ul = $this.children();
|
||||||
$tabs = $ul.children().not('[data-skip-responsive]'),
|
const $tabs = $ul.children().not('[data-skip-responsive]');
|
||||||
$links = $tabs.children('a'),
|
const $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'),
|
const $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'),
|
const $menu = $item.find('.dropdown-contents');
|
||||||
maxHeight = 0,
|
let maxHeight = 0;
|
||||||
lastWidth = false,
|
let lastWidth = false;
|
||||||
responsive = false;
|
let responsive = false;
|
||||||
|
|
||||||
$links.each(function() {
|
$links.each(function() {
|
||||||
var $this = $(this);
|
const $this = $(this);
|
||||||
maxHeight = Math.max(maxHeight, Math.max($this.outerHeight(true), $this.parent().outerHeight(true)));
|
maxHeight = Math.max(maxHeight, Math.max($this.outerHeight(true), $this.parent().outerHeight(true)));
|
||||||
});
|
});
|
||||||
|
|
||||||
function check() {
|
function check() {
|
||||||
var width = $body.width(),
|
const width = $body.width();
|
||||||
height = $this.height();
|
let height = $this.height();
|
||||||
|
|
||||||
if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) {
|
if (!arguments.length && (!responsive || width <= lastWidth) && height <= maxHeight) {
|
||||||
return;
|
return;
|
||||||
|
@ -658,6 +660,7 @@ function parseDocument($container) {
|
||||||
if ($item.hasClass('dropdown-visible')) {
|
if ($item.hasClass('dropdown-visible')) {
|
||||||
phpbb.toggleDropdown.call($item.find('a.responsive-tab-link').get(0));
|
phpbb.toggleDropdown.call($item.find('a.responsive-tab-link').get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -665,29 +668,31 @@ function parseDocument($container) {
|
||||||
$item.show();
|
$item.show();
|
||||||
$menu.html('');
|
$menu.html('');
|
||||||
|
|
||||||
var $availableTabs = $tabs.filter(':not(.activetab, .responsive-tab)'),
|
const $availableTabs = $tabs.filter(':not(.activetab, .responsive-tab)');
|
||||||
total = $availableTabs.length,
|
const total = $availableTabs.length;
|
||||||
i, $tab;
|
let i;
|
||||||
|
let $tab;
|
||||||
|
|
||||||
for (i = total - 1; i >= 0; i--) {
|
for (i = total - 1; i >= 0; i--) {
|
||||||
$tab = $availableTabs.eq(i);
|
$tab = $availableTabs.eq(i);
|
||||||
$menu.prepend($tab.clone(true).removeClass('tab'));
|
$menu.prepend($tab.clone(true).removeClass('tab'));
|
||||||
$tab.hide();
|
$tab.hide();
|
||||||
if ($this.height() <= maxHeight) {
|
if ($this.height() <= maxHeight) {
|
||||||
$menu.find('a').click(function() {
|
$menu.find('a').click(() => {
|
||||||
check(true);
|
check(true);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$menu.find('a').click(function() {
|
|
||||||
|
$menu.find('a').click(() => {
|
||||||
check(true);
|
check(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var $tabLink = $item.find('a.responsive-tab-link');
|
const $tabLink = $item.find('a.responsive-tab-link');
|
||||||
phpbb.registerDropdown($tabLink, $item.find('.dropdown'), {
|
phpbb.registerDropdown($tabLink, $item.find('.dropdown'), {
|
||||||
visibleClass: 'activetab'
|
visibleClass: 'activetab',
|
||||||
});
|
});
|
||||||
|
|
||||||
check(true);
|
check(true);
|
||||||
|
@ -698,7 +703,7 @@ function parseDocument($container) {
|
||||||
* Hide UCP/MCP navigation if there is only 1 item
|
* Hide UCP/MCP navigation if there is only 1 item
|
||||||
*/
|
*/
|
||||||
$container.find('#navigation').each(function() {
|
$container.find('#navigation').each(function() {
|
||||||
var $items = $(this).children('ol, ul').children('li');
|
const $items = $(this).children('ol, ul').children('li');
|
||||||
if ($items.length === 1) {
|
if ($items.length === 1) {
|
||||||
$(this).addClass('responsive-hide');
|
$(this).addClass('responsive-hide');
|
||||||
}
|
}
|
||||||
|
@ -708,23 +713,26 @@ function parseDocument($container) {
|
||||||
* Replace responsive text
|
* Replace responsive text
|
||||||
*/
|
*/
|
||||||
$container.find('[data-responsive-text]').each(function() {
|
$container.find('[data-responsive-text]').each(function() {
|
||||||
var $this = $(this),
|
const $this = $(this);
|
||||||
fullText = $this.text(),
|
const fullText = $this.text();
|
||||||
responsiveText = $this.attr('data-responsive-text'),
|
const responsiveText = $this.attr('data-responsive-text');
|
||||||
responsive = false;
|
let responsive = false;
|
||||||
|
|
||||||
function check() {
|
function check() {
|
||||||
if ($(window).width() > 700) {
|
if ($(window).width() > 700) {
|
||||||
if (!responsive) {
|
if (!responsive) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this.text(fullText);
|
$this.text(fullText);
|
||||||
responsive = false;
|
responsive = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (responsive) {
|
if (responsive) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this.text(responsiveText);
|
$this.text(responsiveText);
|
||||||
responsive = true;
|
responsive = true;
|
||||||
}
|
}
|
||||||
|
@ -737,7 +745,7 @@ function parseDocument($container) {
|
||||||
/**
|
/**
|
||||||
* Run onload functions
|
* Run onload functions
|
||||||
*/
|
*/
|
||||||
jQuery(function($) {
|
jQuery($ => {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Swap .nojs and .hasjs
|
// Swap .nojs and .hasjs
|
||||||
|
|
Loading…
Add table
Reference in a new issue