mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
refactor: var to const and let (#9885)
* refactor: var to const and let * fix: missed global bootbox usage * refactor: align with eslint expectations
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
(function () {
|
||||
var logoutTimer = 0;
|
||||
var logoutMessage;
|
||||
let logoutTimer = 0;
|
||||
let logoutMessage;
|
||||
function startLogoutTimer() {
|
||||
if (app.config.adminReloginDuration <= 0) {
|
||||
return;
|
||||
@@ -94,11 +94,11 @@
|
||||
}
|
||||
|
||||
url = [config.relative_path, url].join('/');
|
||||
var fallback;
|
||||
let fallback;
|
||||
|
||||
$('#main-menu li').removeClass('active');
|
||||
$('#main-menu a').removeClass('active').filter('[href="' + url + '"]').each(function () {
|
||||
var menu = $(this);
|
||||
const menu = $(this);
|
||||
if (menu.parent().attr('data-link')) {
|
||||
return;
|
||||
}
|
||||
@@ -109,13 +109,13 @@
|
||||
fallback = menu.text();
|
||||
});
|
||||
|
||||
var mainTitle;
|
||||
var pageTitle;
|
||||
let mainTitle;
|
||||
let pageTitle;
|
||||
if (/admin\/plugins\//.test(url)) {
|
||||
mainTitle = fallback;
|
||||
pageTitle = '[[admin/menu:section-plugins]] > ' + mainTitle;
|
||||
} else {
|
||||
var matches = url.match(/admin\/(.+?)\/(.+?)$/);
|
||||
const matches = url.match(/admin\/(.+?)\/(.+?)$/);
|
||||
if (matches) {
|
||||
mainTitle = '[[admin/menu:' + matches[1] + '/' + matches[2] + ']]';
|
||||
pageTitle = '[[admin/menu:section-' +
|
||||
@@ -169,9 +169,9 @@
|
||||
|
||||
function configureSlidemenu() {
|
||||
require(['slideout'], function (Slideout) {
|
||||
var env = utils.findBootstrapEnvironment();
|
||||
let env = utils.findBootstrapEnvironment();
|
||||
|
||||
var slideout = new Slideout({
|
||||
const slideout = new Slideout({
|
||||
panel: document.getElementById('panel'),
|
||||
menu: document.getElementById('menu'),
|
||||
padding: 256,
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
define('admin/advanced/cache', function () {
|
||||
var Cache = {};
|
||||
const Cache = {};
|
||||
Cache.init = function () {
|
||||
require(['admin/settings'], function (Settings) {
|
||||
Settings.prepare();
|
||||
});
|
||||
|
||||
$('.clear').on('click', function () {
|
||||
var name = $(this).attr('data-name');
|
||||
const name = $(this).attr('data-name');
|
||||
socket.emit('admin.cache.clear', { name: name }, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
@@ -18,9 +18,9 @@ define('admin/advanced/cache', function () {
|
||||
});
|
||||
|
||||
$('.checkbox').on('change', function () {
|
||||
var input = $(this).find('input');
|
||||
var flag = input.is(':checked');
|
||||
var name = $(this).attr('data-name');
|
||||
const input = $(this).find('input');
|
||||
const flag = input.is(':checked');
|
||||
const name = $(this).attr('data-name');
|
||||
socket.emit('admin.cache.toggle', { name: name, enabled: flag }, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('admin/advanced/errors', ['bootbox', 'Chart'], function (bootbox, Chart) {
|
||||
var Errors = {};
|
||||
const Errors = {};
|
||||
|
||||
Errors.init = function () {
|
||||
Errors.setupCharts();
|
||||
@@ -26,9 +26,9 @@ define('admin/advanced/errors', ['bootbox', 'Chart'], function (bootbox, Chart)
|
||||
};
|
||||
|
||||
Errors.setupCharts = function () {
|
||||
var notFoundCanvas = document.getElementById('not-found');
|
||||
var tooBusyCanvas = document.getElementById('toobusy');
|
||||
var dailyLabels = utils.getDaysArray();
|
||||
const notFoundCanvas = document.getElementById('not-found');
|
||||
const tooBusyCanvas = document.getElementById('toobusy');
|
||||
let dailyLabels = utils.getDaysArray();
|
||||
|
||||
dailyLabels = dailyLabels.slice(-7);
|
||||
|
||||
@@ -36,7 +36,7 @@ define('admin/advanced/errors', ['bootbox', 'Chart'], function (bootbox, Chart)
|
||||
Chart.defaults.global.tooltips.enabled = false;
|
||||
}
|
||||
|
||||
var data = {
|
||||
const data = {
|
||||
'not-found': {
|
||||
labels: dailyLabels,
|
||||
datasets: [
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
|
||||
define('admin/advanced/logs', function () {
|
||||
var Logs = {};
|
||||
const Logs = {};
|
||||
|
||||
Logs.init = function () {
|
||||
var logsEl = $('.logs pre');
|
||||
const logsEl = $('.logs pre');
|
||||
logsEl.scrollTop(logsEl.prop('scrollHeight'));
|
||||
// Affix menu
|
||||
$('.affix').affix();
|
||||
|
||||
$('.logs').find('button[data-action]').on('click', function () {
|
||||
var btnEl = $(this);
|
||||
var action = btnEl.attr('data-action');
|
||||
const btnEl = $(this);
|
||||
const action = btnEl.attr('data-action');
|
||||
|
||||
switch (action) {
|
||||
case 'reload':
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
define('admin/appearance/customise', ['admin/settings', 'ace/ace'], function (Settings, ace) {
|
||||
var Customise = {};
|
||||
const Customise = {};
|
||||
|
||||
Customise.init = function () {
|
||||
Settings.prepare(function () {
|
||||
@@ -9,9 +9,9 @@ define('admin/appearance/customise', ['admin/settings', 'ace/ace'], function (Se
|
||||
$('#customJS').text($('#customJS-holder').val());
|
||||
$('#customHTML').text($('#customHTML-holder').val());
|
||||
|
||||
var customCSS = ace.edit('customCSS');
|
||||
var customJS = ace.edit('customJS');
|
||||
var customHTML = ace.edit('customHTML');
|
||||
const customCSS = ace.edit('customCSS');
|
||||
const customJS = ace.edit('customJS');
|
||||
const customHTML = ace.edit('customHTML');
|
||||
|
||||
customCSS.setTheme('ace/theme/twilight');
|
||||
customCSS.getSession().setMode('ace/mode/less');
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('admin/appearance/skins', ['translator'], function (translator) {
|
||||
var Skins = {};
|
||||
const Skins = {};
|
||||
|
||||
Skins.init = function () {
|
||||
// Populate skins from Bootswatch API
|
||||
@@ -12,19 +12,19 @@ define('admin/appearance/skins', ['translator'], function (translator) {
|
||||
}).done(Skins.render);
|
||||
|
||||
$('#skins').on('click', function (e) {
|
||||
var target = $(e.target);
|
||||
let target = $(e.target);
|
||||
|
||||
if (!target.attr('data-action')) {
|
||||
target = target.parents('[data-action]');
|
||||
}
|
||||
|
||||
var action = target.attr('data-action');
|
||||
const action = target.attr('data-action');
|
||||
|
||||
if (action && action === 'use') {
|
||||
var parentEl = target.parents('[data-theme]');
|
||||
var themeType = parentEl.attr('data-type');
|
||||
var cssSrc = parentEl.attr('data-css');
|
||||
var themeId = parentEl.attr('data-theme');
|
||||
const parentEl = target.parents('[data-theme]');
|
||||
const themeType = parentEl.attr('data-type');
|
||||
const cssSrc = parentEl.attr('data-css');
|
||||
const themeId = parentEl.attr('data-theme');
|
||||
|
||||
|
||||
socket.emit('admin.themes.set', {
|
||||
@@ -50,7 +50,7 @@ define('admin/appearance/skins', ['translator'], function (translator) {
|
||||
};
|
||||
|
||||
Skins.render = function (bootswatch) {
|
||||
var themeContainer = $('#bootstrap_themes');
|
||||
const themeContainer = $('#bootstrap_themes');
|
||||
|
||||
app.parseAndTranslate('admin/partials/theme_list', {
|
||||
themes: bootswatch.themes.map(function (theme) {
|
||||
@@ -70,7 +70,7 @@ define('admin/appearance/skins', ['translator'], function (translator) {
|
||||
themeContainer.html(html);
|
||||
|
||||
if (config['theme:src']) {
|
||||
var skin = config['theme:src']
|
||||
const skin = config['theme:src']
|
||||
.match(/latest\/(\S+)\/bootstrap.min.css/)[1]
|
||||
.replace(/(^|\s)([a-z])/g, function (m, p1, p2) { return p1 + p2.toUpperCase(); });
|
||||
|
||||
@@ -82,8 +82,8 @@ define('admin/appearance/skins', ['translator'], function (translator) {
|
||||
function highlightSelectedTheme(themeId) {
|
||||
translator.translate('[[admin/appearance/skins:select-skin]] || [[admin/appearance/skins:current-skin]]', function (text) {
|
||||
text = text.split(' || ');
|
||||
var select = text[0];
|
||||
var current = text[1];
|
||||
const select = text[0];
|
||||
const current = text[1];
|
||||
|
||||
$('[data-theme]')
|
||||
.removeClass('selected')
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
|
||||
|
||||
define('admin/appearance/themes', ['bootbox', 'translator'], function (bootbox, translator) {
|
||||
var Themes = {};
|
||||
const Themes = {};
|
||||
|
||||
Themes.init = function () {
|
||||
$('#installed_themes').on('click', function (e) {
|
||||
var target = $(e.target);
|
||||
var action = target.attr('data-action');
|
||||
const target = $(e.target);
|
||||
const action = target.attr('data-action');
|
||||
|
||||
if (action && action === 'use') {
|
||||
var parentEl = target.parents('[data-theme]');
|
||||
var themeType = parentEl.attr('data-type');
|
||||
var cssSrc = parentEl.attr('data-css');
|
||||
var themeId = parentEl.attr('data-theme');
|
||||
const parentEl = target.parents('[data-theme]');
|
||||
const themeType = parentEl.attr('data-type');
|
||||
const cssSrc = parentEl.attr('data-css');
|
||||
const themeId = parentEl.attr('data-theme');
|
||||
|
||||
socket.emit('admin.themes.set', {
|
||||
type: themeType,
|
||||
@@ -70,7 +70,7 @@ define('admin/appearance/themes', ['bootbox', 'translator'], function (bootbox,
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
var instListEl = $('#installed_themes');
|
||||
const instListEl = $('#installed_themes');
|
||||
|
||||
if (!themes.length) {
|
||||
instListEl.append($('<li/ >').addClass('no-themes').translateHtml('[[admin/appearance/themes:no-themes]]'));
|
||||
@@ -88,8 +88,8 @@ define('admin/appearance/themes', ['bootbox', 'translator'], function (bootbox,
|
||||
function highlightSelectedTheme(themeId) {
|
||||
translator.translate('[[admin/appearance/themes:select-theme]] || [[admin/appearance/themes:current-theme]]', function (text) {
|
||||
text = text.split(' || ');
|
||||
var select = text[0];
|
||||
var current = text[1];
|
||||
const select = text[0];
|
||||
const current = text[1];
|
||||
|
||||
$('[data-theme]')
|
||||
.removeClass('selected')
|
||||
|
||||
@@ -2,28 +2,28 @@
|
||||
|
||||
|
||||
define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], function (Chart, translator, Benchpress, bootbox) {
|
||||
var Admin = {};
|
||||
var intervals = {
|
||||
const Admin = {};
|
||||
const intervals = {
|
||||
rooms: false,
|
||||
graphs: false,
|
||||
};
|
||||
var isMobile = false;
|
||||
var graphData = {
|
||||
let isMobile = false;
|
||||
const graphData = {
|
||||
rooms: {},
|
||||
traffic: {},
|
||||
};
|
||||
var currentGraph = {
|
||||
const currentGraph = {
|
||||
units: 'hours',
|
||||
until: undefined,
|
||||
};
|
||||
|
||||
var DEFAULTS = {
|
||||
const DEFAULTS = {
|
||||
roomInterval: 10000,
|
||||
graphInterval: 15000,
|
||||
realtimeInterval: 1500,
|
||||
};
|
||||
|
||||
var usedTopicColors = [];
|
||||
const usedTopicColors = [];
|
||||
|
||||
$(window).on('action:ajaxify.start', function () {
|
||||
clearInterval(intervals.rooms);
|
||||
@@ -62,7 +62,7 @@ define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], func
|
||||
|
||||
graphData.rooms = data;
|
||||
|
||||
var html = '<div class="text-center pull-left">' +
|
||||
const html = '<div class="text-center pull-left">' +
|
||||
'<span class="formatted-number">' + data.onlineRegisteredCount + '</span>' +
|
||||
'<div class="stat">[[admin/dashboard:active-users.users]]</div>' +
|
||||
'</div>' +
|
||||
@@ -86,38 +86,38 @@ define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], func
|
||||
$('#active-users').translateHtml(html);
|
||||
};
|
||||
|
||||
var graphs = {
|
||||
const graphs = {
|
||||
traffic: null,
|
||||
registered: null,
|
||||
presence: null,
|
||||
topics: null,
|
||||
};
|
||||
|
||||
var topicColors = ['#bf616a', '#5B90BF', '#d08770', '#ebcb8b', '#a3be8c', '#96b5b4', '#8fa1b3', '#b48ead', '#ab7967', '#46BFBD'];
|
||||
const topicColors = ['#bf616a', '#5B90BF', '#d08770', '#ebcb8b', '#a3be8c', '#96b5b4', '#8fa1b3', '#b48ead', '#ab7967', '#46BFBD'];
|
||||
|
||||
/* eslint-disable */
|
||||
// from chartjs.org
|
||||
function lighten(col, amt) {
|
||||
var usePound = false;
|
||||
let usePound = false;
|
||||
|
||||
if (col[0] === '#') {
|
||||
col = col.slice(1);
|
||||
usePound = true;
|
||||
}
|
||||
|
||||
var num = parseInt(col, 16);
|
||||
const num = parseInt(col, 16);
|
||||
|
||||
var r = (num >> 16) + amt;
|
||||
let r = (num >> 16) + amt;
|
||||
|
||||
if (r > 255) r = 255;
|
||||
else if (r < 0) r = 0;
|
||||
|
||||
var b = ((num >> 8) & 0x00FF) + amt;
|
||||
let b = ((num >> 8) & 0x00FF) + amt;
|
||||
|
||||
if (b > 255) b = 255;
|
||||
else if (b < 0) b = 0;
|
||||
|
||||
var g = (num & 0x0000FF) + amt;
|
||||
let g = (num & 0x0000FF) + amt;
|
||||
|
||||
if (g > 255) g = 255;
|
||||
else if (g < 0) g = 0;
|
||||
@@ -128,21 +128,21 @@ define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], func
|
||||
|
||||
function setupGraphs(callback) {
|
||||
callback = callback || function () {};
|
||||
var trafficCanvas = document.getElementById('analytics-traffic');
|
||||
var registeredCanvas = document.getElementById('analytics-registered');
|
||||
var presenceCanvas = document.getElementById('analytics-presence');
|
||||
var topicsCanvas = document.getElementById('analytics-topics');
|
||||
var trafficCtx = trafficCanvas.getContext('2d');
|
||||
var registeredCtx = registeredCanvas.getContext('2d');
|
||||
var presenceCtx = presenceCanvas.getContext('2d');
|
||||
var topicsCtx = topicsCanvas.getContext('2d');
|
||||
var trafficLabels = utils.getHoursArray();
|
||||
const trafficCanvas = document.getElementById('analytics-traffic');
|
||||
const registeredCanvas = document.getElementById('analytics-registered');
|
||||
const presenceCanvas = document.getElementById('analytics-presence');
|
||||
const topicsCanvas = document.getElementById('analytics-topics');
|
||||
const trafficCtx = trafficCanvas.getContext('2d');
|
||||
const registeredCtx = registeredCanvas.getContext('2d');
|
||||
const presenceCtx = presenceCanvas.getContext('2d');
|
||||
const topicsCtx = topicsCanvas.getContext('2d');
|
||||
const trafficLabels = utils.getHoursArray();
|
||||
|
||||
if (isMobile) {
|
||||
Chart.defaults.global.tooltips.enabled = false;
|
||||
}
|
||||
|
||||
var t = translator.Translator.create();
|
||||
const t = translator.Translator.create();
|
||||
Promise.all([
|
||||
t.translateKey('admin/dashboard:graphs.page-views', []),
|
||||
t.translateKey('admin/dashboard:graphs.page-views-registered', []),
|
||||
@@ -157,7 +157,7 @@ define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], func
|
||||
t.translateKey('admin/dashboard:recent', []),
|
||||
t.translateKey('admin/dashboard:unread', []),
|
||||
]).then(function (translations) {
|
||||
var data = {
|
||||
const data = {
|
||||
labels: trafficLabels,
|
||||
datasets: [
|
||||
{
|
||||
@@ -323,8 +323,8 @@ define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], func
|
||||
adjustPieCharts();
|
||||
|
||||
$('[data-action="updateGraph"]:not([data-units="custom"])').on('click', function () {
|
||||
var until = new Date();
|
||||
var amount = $(this).attr('data-amount');
|
||||
let until = new Date();
|
||||
const amount = $(this).attr('data-amount');
|
||||
if ($(this).attr('data-units') === 'days') {
|
||||
until.setHours(0, 0, 0, 0);
|
||||
}
|
||||
@@ -339,10 +339,10 @@ define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], func
|
||||
});
|
||||
|
||||
$('[data-action="updateGraph"][data-units="custom"]').on('click', function () {
|
||||
var targetEl = $(this);
|
||||
const targetEl = $(this);
|
||||
|
||||
Benchpress.render('admin/partials/pageviews-range-select', {}).then(function (html) {
|
||||
var modal = bootbox.dialog({
|
||||
const modal = bootbox.dialog({
|
||||
title: '[[admin/dashboard:page-views-custom]]',
|
||||
message: html,
|
||||
buttons: {
|
||||
@@ -353,10 +353,10 @@ define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], func
|
||||
},
|
||||
},
|
||||
}).on('shown.bs.modal', function () {
|
||||
var date = new Date();
|
||||
var today = date.toISOString().substr(0, 10);
|
||||
const date = new Date();
|
||||
const today = date.toISOString().substr(0, 10);
|
||||
date.setDate(date.getDate() - 1);
|
||||
var yesterday = date.toISOString().substr(0, 10);
|
||||
const yesterday = date.toISOString().substr(0, 10);
|
||||
|
||||
modal.find('#startRange').val(targetEl.attr('data-startRange') || yesterday);
|
||||
modal.find('#endRange').val(targetEl.attr('data-endRange') || today);
|
||||
@@ -364,8 +364,8 @@ define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], func
|
||||
|
||||
function submit() {
|
||||
// NEED TO ADD VALIDATION HERE FOR YYYY-MM-DD
|
||||
var formData = modal.find('form').serializeObject();
|
||||
var validRegexp = /\d{4}-\d{2}-\d{2}/;
|
||||
const formData = modal.find('form').serializeObject();
|
||||
const validRegexp = /\d{4}-\d{2}-\d{2}/;
|
||||
|
||||
// Input validation
|
||||
if (!formData.startRange && !formData.endRange) {
|
||||
@@ -378,10 +378,10 @@ define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], func
|
||||
return false;
|
||||
}
|
||||
|
||||
var until = new Date(formData.endRange);
|
||||
let until = new Date(formData.endRange);
|
||||
until.setDate(until.getDate() + 1);
|
||||
until = until.getTime();
|
||||
var amount = (until - new Date(formData.startRange).getTime()) / (1000 * 60 * 60 * 24);
|
||||
const amount = (until - new Date(formData.startRange).getTime()) / (1000 * 60 * 60 * 24);
|
||||
|
||||
updateTrafficGraph('days', until, amount);
|
||||
|
||||
@@ -401,7 +401,7 @@ define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], func
|
||||
|
||||
function adjustPieCharts() {
|
||||
$('.pie-chart.legend-up').each(function () {
|
||||
var $this = $(this);
|
||||
const $this = $(this);
|
||||
|
||||
if ($this.width() < 320) {
|
||||
$this.addClass('compact');
|
||||
@@ -459,8 +459,8 @@ define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], func
|
||||
currentGraph.amount = amount;
|
||||
|
||||
// Update the View as JSON button url
|
||||
var apiEl = $('#view-as-json');
|
||||
var newHref = $.param({
|
||||
const apiEl = $('#view-as-json');
|
||||
const newHref = $.param({
|
||||
units: units || 'hours',
|
||||
until: until,
|
||||
count: amount,
|
||||
@@ -517,10 +517,10 @@ define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], func
|
||||
});
|
||||
|
||||
function buildTopicsLegend() {
|
||||
var html = '';
|
||||
let html = '';
|
||||
topics.forEach(function (t, i) {
|
||||
var link = t.tid ? '<a title="' + t.title + '"href="' + config.relative_path + '/topic/' + t.tid + '" target="_blank"> ' + t.title + '</a>' : t.title;
|
||||
var label = t.count === '0' ? t.title : link;
|
||||
const link = t.tid ? '<a title="' + t.title + '"href="' + config.relative_path + '/topic/' + t.tid + '" target="_blank"> ' + t.title + '</a>' : t.title;
|
||||
const label = t.count === '0' ? t.title : link;
|
||||
|
||||
html += '<li>' +
|
||||
'<div style="background-color: ' + topicColors[i] + ';"></div>' +
|
||||
@@ -536,7 +536,7 @@ define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], func
|
||||
|
||||
function setupRealtimeButton() {
|
||||
$('#toggle-realtime .fa').on('click', function () {
|
||||
var $this = $(this);
|
||||
const $this = $(this);
|
||||
if ($this.hasClass('fa-toggle-on')) {
|
||||
$this.removeClass('fa-toggle-on').addClass('fa-toggle-off');
|
||||
$this.parent().find('strong').html('OFF');
|
||||
@@ -565,11 +565,11 @@ define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], func
|
||||
}
|
||||
|
||||
function setupFullscreen() {
|
||||
var container = document.getElementById('analytics-panel');
|
||||
var $container = $(container);
|
||||
var btn = $container.find('.fa-expand');
|
||||
var fsMethod;
|
||||
var exitMethod;
|
||||
const container = document.getElementById('analytics-panel');
|
||||
const $container = $(container);
|
||||
const btn = $container.find('.fa-expand');
|
||||
let fsMethod;
|
||||
let exitMethod;
|
||||
|
||||
if (container.requestFullscreen) {
|
||||
fsMethod = 'requestFullscreen';
|
||||
|
||||
@@ -7,11 +7,11 @@ define('admin/extend/plugins', [
|
||||
'bootbox',
|
||||
'jquery-ui/widgets/sortable',
|
||||
], function (translator, Benchpress, bootbox) {
|
||||
var Plugins = {};
|
||||
const Plugins = {};
|
||||
Plugins.init = function () {
|
||||
var pluginsList = $('.plugins');
|
||||
var numPlugins = pluginsList[0].querySelectorAll('li').length;
|
||||
var pluginID;
|
||||
const pluginsList = $('.plugins');
|
||||
const numPlugins = pluginsList[0].querySelectorAll('li').length;
|
||||
let pluginID;
|
||||
|
||||
if (!numPlugins) {
|
||||
translator.translate('<li><p><i>[[admin/extend/plugins:none-found]]</i></p></li>', function (html) {
|
||||
@@ -24,11 +24,11 @@ define('admin/extend/plugins', [
|
||||
searchInputEl.value = '';
|
||||
|
||||
pluginsList.on('click', 'button[data-action="toggleActive"]', function () {
|
||||
var pluginEl = $(this).parents('li');
|
||||
const pluginEl = $(this).parents('li');
|
||||
pluginID = pluginEl.attr('data-plugin-id');
|
||||
var btn = $('[id="' + pluginID + '"] [data-action="toggleActive"]');
|
||||
const btn = $('[id="' + pluginID + '"] [data-action="toggleActive"]');
|
||||
|
||||
var pluginData = ajaxify.data.installed[pluginEl.attr('data-plugin-index')];
|
||||
const pluginData = ajaxify.data.installed[pluginEl.attr('data-plugin-index')];
|
||||
|
||||
function toggleActivate() {
|
||||
socket.emit('admin.plugins.toggleActive', pluginID, function (err, status) {
|
||||
@@ -94,7 +94,7 @@ define('admin/extend/plugins', [
|
||||
});
|
||||
|
||||
pluginsList.on('click', 'button[data-action="toggleInstall"]', function () {
|
||||
var btn = $(this);
|
||||
const btn = $(this);
|
||||
btn.attr('disabled', true);
|
||||
pluginID = $(this).parents('li').attr('data-plugin-id');
|
||||
|
||||
@@ -131,8 +131,8 @@ define('admin/extend/plugins', [
|
||||
});
|
||||
|
||||
pluginsList.on('click', 'button[data-action="upgrade"]', function () {
|
||||
var btn = $(this);
|
||||
var parent = btn.parents('li');
|
||||
const btn = $(this);
|
||||
const parent = btn.parents('li');
|
||||
pluginID = parent.attr('data-plugin-id');
|
||||
|
||||
Plugins.suggest(pluginID, function (err, payload) {
|
||||
@@ -141,7 +141,7 @@ define('admin/extend/plugins', [
|
||||
}
|
||||
|
||||
require(['compare-versions'], function (compareVersions) {
|
||||
var currentVersion = parent.find('.currentVersion').text();
|
||||
const currentVersion = parent.find('.currentVersion').text();
|
||||
if (payload.version !== 'latest' && compareVersions.compare(payload.version, currentVersion, '>')) {
|
||||
upgrade(pluginID, btn, payload.version);
|
||||
} else if (payload.version === 'latest') {
|
||||
@@ -156,9 +156,9 @@ define('admin/extend/plugins', [
|
||||
});
|
||||
|
||||
$(searchInputEl).on('input propertychange', function () {
|
||||
var term = $(this).val();
|
||||
const term = $(this).val();
|
||||
$('.plugins li').each(function () {
|
||||
var pluginId = $(this).attr('data-plugin-id');
|
||||
const pluginId = $(this).attr('data-plugin-id');
|
||||
$(this).toggleClass('hide', pluginId && pluginId.indexOf(term) === -1);
|
||||
});
|
||||
});
|
||||
@@ -179,7 +179,7 @@ define('admin/extend/plugins', [
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
var html = '';
|
||||
let html = '';
|
||||
activePlugins.forEach(function (plugin) {
|
||||
html += '<li class="">' + plugin + '<span class="pull-right"><i class="fa fa-chevron-up"></i><i class="fa fa-chevron-down"></i></span></li>';
|
||||
});
|
||||
@@ -189,24 +189,24 @@ define('admin/extend/plugins', [
|
||||
});
|
||||
return;
|
||||
}
|
||||
var list = $('#order-active-plugins-modal .plugin-list');
|
||||
const list = $('#order-active-plugins-modal .plugin-list');
|
||||
list.html(html).sortable();
|
||||
|
||||
list.find('.fa-chevron-up').on('click', function () {
|
||||
var item = $(this).parents('li');
|
||||
const item = $(this).parents('li');
|
||||
item.prev().before(item);
|
||||
});
|
||||
|
||||
list.find('.fa-chevron-down').on('click', function () {
|
||||
var item = $(this).parents('li');
|
||||
const item = $(this).parents('li');
|
||||
item.next().after(item);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('#save-plugin-order').on('click', function () {
|
||||
var plugins = $('#order-active-plugins-modal .plugin-list').children();
|
||||
var data = [];
|
||||
const plugins = $('#order-active-plugins-modal .plugin-list').children();
|
||||
const data = [];
|
||||
plugins.each(function (index, el) {
|
||||
data.push({ name: $(el).text(), order: index });
|
||||
});
|
||||
@@ -252,7 +252,7 @@ define('admin/extend/plugins', [
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
var parent = btn.parents('li');
|
||||
const parent = btn.parents('li');
|
||||
parent.find('.fa-exclamation-triangle').remove();
|
||||
parent.find('.currentVersion').text(version);
|
||||
btn.remove();
|
||||
@@ -274,7 +274,7 @@ define('admin/extend/plugins', [
|
||||
}
|
||||
|
||||
Plugins.toggleInstall = function (pluginID, version, callback) {
|
||||
var btn = $('li[data-plugin-id="' + pluginID + '"] button[data-action="toggleInstall"]');
|
||||
const btn = $('li[data-plugin-id="' + pluginID + '"] button[data-action="toggleInstall"]');
|
||||
btn.find('i').attr('class', 'fa fa-refresh fa-spin');
|
||||
|
||||
socket.emit('admin.plugins.toggleInstall', {
|
||||
@@ -303,7 +303,7 @@ define('admin/extend/plugins', [
|
||||
};
|
||||
|
||||
Plugins.suggest = function (pluginId, callback) {
|
||||
var nbbVersion = app.config.version.match(/^\d+\.\d+\.\d+/);
|
||||
const nbbVersion = app.config.version.match(/^\d+\.\d+\.\d+/);
|
||||
$.ajax((app.config.registry || 'https://packages.nodebb.org') + '/api/v1/suggest', {
|
||||
type: 'GET',
|
||||
data: {
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
|
||||
define('admin/extend/rewards', [], function () {
|
||||
var rewards = {};
|
||||
const rewards = {};
|
||||
|
||||
|
||||
var available;
|
||||
var active;
|
||||
var conditions;
|
||||
var conditionals;
|
||||
let available;
|
||||
let active;
|
||||
let conditions;
|
||||
let conditionals;
|
||||
|
||||
rewards.init = function () {
|
||||
available = ajaxify.data.rewards;
|
||||
@@ -25,8 +25,8 @@ define('admin/extend/rewards', [], function () {
|
||||
update($(this));
|
||||
})
|
||||
.on('click', '.delete', function () {
|
||||
var parent = $(this).parents('[data-id]');
|
||||
var id = parent.attr('data-id');
|
||||
const parent = $(this).parents('[data-id]');
|
||||
const id = parent.attr('data-id');
|
||||
|
||||
socket.emit('admin.rewards.delete', { id: id }, function (err) {
|
||||
if (err) {
|
||||
@@ -40,8 +40,8 @@ define('admin/extend/rewards', [], function () {
|
||||
return false;
|
||||
})
|
||||
.on('click', '.toggle', function () {
|
||||
var btn = $(this);
|
||||
var disabled = btn.hasClass('btn-success');
|
||||
const btn = $(this);
|
||||
const disabled = btn.hasClass('btn-success');
|
||||
btn.toggleClass('btn-warning').toggleClass('btn-success').translateHtml('[[admin/extend/rewards:' + (disabled ? 'disable' : 'enable') + ']]');
|
||||
// send disable api call
|
||||
return false;
|
||||
@@ -72,12 +72,12 @@ define('admin/extend/rewards', [], function () {
|
||||
}
|
||||
|
||||
function selectReward(el) {
|
||||
var parent = el.parents('[data-rid]');
|
||||
var div = parent.find('.inputs');
|
||||
var inputs;
|
||||
var html = '';
|
||||
const parent = el.parents('[data-rid]');
|
||||
const div = parent.find('.inputs');
|
||||
let inputs;
|
||||
let html = '';
|
||||
|
||||
for (var reward in available) {
|
||||
for (const reward in available) {
|
||||
if (available.hasOwnProperty(reward)) {
|
||||
if (available[reward].rid === el.attr('data-selected')) {
|
||||
inputs = available[reward].inputs;
|
||||
@@ -112,10 +112,10 @@ define('admin/extend/rewards', [], function () {
|
||||
|
||||
function populateInputs() {
|
||||
$('[data-rid]').each(function (i) {
|
||||
var div = $(this).find('.inputs');
|
||||
var rewards = active[i].rewards;
|
||||
const div = $(this).find('.inputs');
|
||||
const rewards = active[i].rewards;
|
||||
|
||||
for (var reward in rewards) {
|
||||
for (const reward in rewards) {
|
||||
if (rewards.hasOwnProperty(reward)) {
|
||||
div.find('[name="' + reward + '"]').val(rewards[reward]);
|
||||
}
|
||||
@@ -124,9 +124,9 @@ define('admin/extend/rewards', [], function () {
|
||||
}
|
||||
|
||||
function newReward() {
|
||||
var ul = $('#active');
|
||||
const ul = $('#active');
|
||||
|
||||
var data = {
|
||||
const data = {
|
||||
active: [{
|
||||
disabled: true,
|
||||
value: '',
|
||||
@@ -146,12 +146,12 @@ define('admin/extend/rewards', [], function () {
|
||||
}
|
||||
|
||||
function saveRewards() {
|
||||
var activeRewards = [];
|
||||
const activeRewards = [];
|
||||
|
||||
$('#active li').each(function () {
|
||||
var data = { rewards: {} };
|
||||
var main = $(this).find('form.main').serializeArray();
|
||||
var rewards = $(this).find('form.rewards').serializeArray();
|
||||
const data = { rewards: {} };
|
||||
const main = $(this).find('form.main').serializeArray();
|
||||
const rewards = $(this).find('form.rewards').serializeArray();
|
||||
|
||||
main.forEach(function (obj) {
|
||||
data[obj.name] = obj.value;
|
||||
|
||||
@@ -8,13 +8,13 @@ define('admin/extend/widgets', [
|
||||
'jquery-ui/widgets/droppable',
|
||||
'jquery-ui/widgets/datepicker',
|
||||
], function (bootbox) {
|
||||
var Widgets = {};
|
||||
const Widgets = {};
|
||||
|
||||
Widgets.init = function () {
|
||||
$('#widgets .nav-pills .dropdown-menu a').on('click', function (ev) {
|
||||
var $this = $(this);
|
||||
const $this = $(this);
|
||||
$('#widgets .tab-pane').removeClass('active');
|
||||
var templateName = $this.attr('data-template');
|
||||
const templateName = $this.attr('data-template');
|
||||
$('#widgets .tab-pane[data-template="' + templateName + '"]').addClass('active');
|
||||
$('#widgets .selected-template').text(templateName);
|
||||
$('#widgets .nav-pills .dropdown').trigger('click');
|
||||
@@ -47,7 +47,7 @@ define('admin/extend/widgets', [
|
||||
$('#widgets .available-containers .containers > [data-container-html]')
|
||||
.draggable({
|
||||
helper: function (e) {
|
||||
var target = $(e.target);
|
||||
let target = $(e.target);
|
||||
target = target.attr('data-container-html') ? target : target.parents('[data-container-html]');
|
||||
|
||||
return target.clone().addClass('block').width(target.width()).css('opacity', '0.5');
|
||||
@@ -65,7 +65,7 @@ define('admin/extend/widgets', [
|
||||
},
|
||||
connectWith: 'div',
|
||||
}).on('click', '.delete-widget', function () {
|
||||
var panel = $(this).parents('.widget-panel');
|
||||
const panel = $(this).parents('.widget-panel');
|
||||
|
||||
bootbox.confirm('[[admin/extend/widgets:alert.confirm-delete]]', function (confirm) {
|
||||
if (confirm) {
|
||||
@@ -81,20 +81,20 @@ define('admin/extend/widgets', [
|
||||
$('#save').on('click', saveWidgets);
|
||||
|
||||
function saveWidgets() {
|
||||
var saveData = [];
|
||||
const saveData = [];
|
||||
$('#widgets [data-template][data-location]').each(function (i, el) {
|
||||
el = $(el);
|
||||
|
||||
var template = el.attr('data-template');
|
||||
var location = el.attr('data-location');
|
||||
var area = el.children('.widget-area');
|
||||
var widgets = [];
|
||||
const template = el.attr('data-template');
|
||||
const location = el.attr('data-location');
|
||||
const area = el.children('.widget-area');
|
||||
const widgets = [];
|
||||
|
||||
area.find('.widget-panel[data-widget]').each(function () {
|
||||
var widgetData = {};
|
||||
var data = $(this).find('form').serializeArray();
|
||||
const widgetData = {};
|
||||
const data = $(this).find('form').serializeArray();
|
||||
|
||||
for (var d in data) {
|
||||
for (const d in data) {
|
||||
if (data.hasOwnProperty(d)) {
|
||||
if (data[d].name) {
|
||||
if (widgetData[data[d].name]) {
|
||||
@@ -140,10 +140,10 @@ define('admin/extend/widgets', [
|
||||
}
|
||||
|
||||
$('.color-selector').on('click', '.btn', function () {
|
||||
var btn = $(this);
|
||||
var selector = btn.parents('.color-selector');
|
||||
var container = selector.parents('[data-container-html]');
|
||||
var classList = [];
|
||||
const btn = $(this);
|
||||
const selector = btn.parents('.color-selector');
|
||||
const container = selector.parents('[data-container-html]');
|
||||
const classList = [];
|
||||
|
||||
selector.children().each(function () {
|
||||
classList.push($(this).attr('data-class'));
|
||||
@@ -159,7 +159,7 @@ define('admin/extend/widgets', [
|
||||
}
|
||||
|
||||
function createDatePicker(el) {
|
||||
var currentYear = new Date().getFullYear();
|
||||
const currentYear = new Date().getFullYear();
|
||||
el.find('.date-selector').datepicker({
|
||||
changeMonth: true,
|
||||
changeYear: true,
|
||||
@@ -173,7 +173,7 @@ define('admin/extend/widgets', [
|
||||
.droppable({
|
||||
accept: '[data-container-html]',
|
||||
drop: function (event, ui) {
|
||||
var el = $(this);
|
||||
const el = $(this);
|
||||
|
||||
el.find('.panel-body .container-html').val(ui.draggable.attr('data-container-html'));
|
||||
el.find('.panel-body').removeClass('hidden');
|
||||
@@ -190,13 +190,13 @@ define('admin/extend/widgets', [
|
||||
function loadWidgetData() {
|
||||
function populateWidget(widget, data) {
|
||||
if (data.title) {
|
||||
var title = widget.find('.panel-heading strong');
|
||||
const title = widget.find('.panel-heading strong');
|
||||
title.text(title.text() + ' - ' + data.title);
|
||||
}
|
||||
|
||||
widget.find('input, textarea, select').each(function () {
|
||||
var input = $(this);
|
||||
var value = data[input.attr('name')];
|
||||
const input = $(this);
|
||||
const value = data[input.attr('name')];
|
||||
|
||||
if (input.attr('type') === 'checkbox') {
|
||||
input.prop('checked', !!value).trigger('change');
|
||||
@@ -209,17 +209,17 @@ define('admin/extend/widgets', [
|
||||
}
|
||||
|
||||
$.get(config.relative_path + '/api/admin/extend/widgets', function (data) {
|
||||
var areas = data.areas;
|
||||
const areas = data.areas;
|
||||
|
||||
for (var i = 0; i < areas.length; i += 1) {
|
||||
var area = areas[i];
|
||||
var widgetArea = $('#widgets .area[data-template="' + area.template + '"][data-location="' + area.location + '"]').find('.widget-area');
|
||||
for (let i = 0; i < areas.length; i += 1) {
|
||||
const area = areas[i];
|
||||
const widgetArea = $('#widgets .area[data-template="' + area.template + '"][data-location="' + area.location + '"]').find('.widget-area');
|
||||
|
||||
widgetArea.html('');
|
||||
|
||||
for (var k = 0; k < area.data.length; k += 1) {
|
||||
var widgetData = area.data[k];
|
||||
var widgetEl = $('.available-widgets [data-widget="' + widgetData.widget + '"]').clone(true).removeClass('hide');
|
||||
for (let k = 0; k < area.data.length; k += 1) {
|
||||
const widgetData = area.data[k];
|
||||
const widgetEl = $('.available-widgets [data-widget="' + widgetData.widget + '"]').clone(true).removeClass('hide');
|
||||
|
||||
widgetArea.append(populateWidget(widgetEl, widgetData.data));
|
||||
appendToggle(widgetEl);
|
||||
@@ -232,44 +232,44 @@ define('admin/extend/widgets', [
|
||||
}
|
||||
|
||||
function setupCloneButton() {
|
||||
var clone = $('[component="clone"]');
|
||||
var cloneBtn = $('[component="clone/button"]');
|
||||
const clone = $('[component="clone"]');
|
||||
const cloneBtn = $('[component="clone/button"]');
|
||||
|
||||
clone.find('.dropdown-menu li').on('click', function () {
|
||||
var template = $(this).find('a').text();
|
||||
const template = $(this).find('a').text();
|
||||
cloneBtn.translateHtml('[[admin/extend/widgets:clone-from]] <strong>' + template + '</strong>');
|
||||
cloneBtn.attr('data-template', template);
|
||||
});
|
||||
|
||||
cloneBtn.on('click', function () {
|
||||
var template = cloneBtn.attr('data-template');
|
||||
const template = cloneBtn.attr('data-template');
|
||||
if (!template) {
|
||||
return app.alertError('[[admin/extend/widgets:error.select-clone]]');
|
||||
}
|
||||
|
||||
var currentTemplate = $('#active-widgets .active.tab-pane[data-template] .area');
|
||||
var templateToClone = $('#active-widgets .tab-pane[data-template="' + template + '"] .area');
|
||||
const currentTemplate = $('#active-widgets .active.tab-pane[data-template] .area');
|
||||
const templateToClone = $('#active-widgets .tab-pane[data-template="' + template + '"] .area');
|
||||
|
||||
var currentAreas = currentTemplate.map(function () {
|
||||
const currentAreas = currentTemplate.map(function () {
|
||||
return $(this).attr('data-location');
|
||||
}).get();
|
||||
|
||||
var areasToClone = templateToClone.map(function () {
|
||||
var location = $(this).attr('data-location');
|
||||
const areasToClone = templateToClone.map(function () {
|
||||
const location = $(this).attr('data-location');
|
||||
return currentAreas.indexOf(location) !== -1 ? location : undefined;
|
||||
}).get().filter(function (i) { return i; });
|
||||
|
||||
function clone(location) {
|
||||
$('#active-widgets .tab-pane[data-template="' + template + '"] [data-location="' + location + '"]').each(function () {
|
||||
$(this).find('[data-widget]').each(function () {
|
||||
var widget = $(this).clone(true);
|
||||
const widget = $(this).clone(true);
|
||||
$('#active-widgets .active.tab-pane[data-template]:not([data-template="global"]) [data-location="' + location + '"] .widget-area').append(widget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
for (var i = 0, ii = areasToClone.length; i < ii; i++) {
|
||||
var location = areasToClone[i];
|
||||
for (let i = 0, ii = areasToClone.length; i < ii; i++) {
|
||||
const location = areasToClone[i];
|
||||
clone(location);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
define('admin/manage/admins-mods', [
|
||||
'autocomplete', 'api', 'bootbox', 'categorySelector',
|
||||
], function (autocomplete, api, bootbox, categorySelector) {
|
||||
var AdminsMods = {};
|
||||
const AdminsMods = {};
|
||||
|
||||
AdminsMods.init = function () {
|
||||
autocomplete.user($('#admin-search'), function (ev, ui) {
|
||||
@@ -25,8 +25,8 @@ define('admin/manage/admins-mods', [
|
||||
});
|
||||
|
||||
$('.administrator-area').on('click', '.remove-user-icon', function () {
|
||||
var userCard = $(this).parents('[data-uid]');
|
||||
var uid = userCard.attr('data-uid');
|
||||
const userCard = $(this).parents('[data-uid]');
|
||||
const uid = userCard.attr('data-uid');
|
||||
if (parseInt(uid, 10) === parseInt(app.user.uid, 10)) {
|
||||
return app.alertError('[[admin/manage/users:alerts.no-remove-yourself-admin]]');
|
||||
}
|
||||
@@ -60,8 +60,8 @@ define('admin/manage/admins-mods', [
|
||||
});
|
||||
|
||||
$('.global-moderator-area').on('click', '.remove-user-icon', function () {
|
||||
var userCard = $(this).parents('[data-uid]');
|
||||
var uid = userCard.attr('data-uid');
|
||||
const userCard = $(this).parents('[data-uid]');
|
||||
const uid = userCard.attr('data-uid');
|
||||
|
||||
bootbox.confirm('[[admin/manage/users:alerts.confirm-remove-global-mod]]', function (confirm) {
|
||||
if (confirm) {
|
||||
@@ -85,8 +85,8 @@ define('admin/manage/admins-mods', [
|
||||
});
|
||||
|
||||
autocomplete.user($('.moderator-search'), function (ev, ui) {
|
||||
var input = $(ev.target);
|
||||
var cid = $(ev.target).attr('data-cid');
|
||||
const input = $(ev.target);
|
||||
const cid = $(ev.target).attr('data-cid');
|
||||
socket.emit('admin.categories.setPrivilege', {
|
||||
cid: cid,
|
||||
privilege: ajaxify.data.allPrivileges,
|
||||
@@ -111,10 +111,10 @@ define('admin/manage/admins-mods', [
|
||||
});
|
||||
|
||||
$('.moderator-area').on('click', '.remove-user-icon', function () {
|
||||
var moderatorArea = $(this).parents('[data-cid]');
|
||||
var cid = moderatorArea.attr('data-cid');
|
||||
var userCard = $(this).parents('[data-uid]');
|
||||
var uid = userCard.attr('data-uid');
|
||||
const moderatorArea = $(this).parents('[data-cid]');
|
||||
const cid = moderatorArea.attr('data-cid');
|
||||
const userCard = $(this).parents('[data-uid]');
|
||||
const uid = userCard.attr('data-uid');
|
||||
|
||||
bootbox.confirm('[[admin/manage/users:alerts.confirm-remove-moderator]]', function (confirm) {
|
||||
if (confirm) {
|
||||
|
||||
@@ -8,9 +8,9 @@ define('admin/manage/categories', [
|
||||
'Sortable',
|
||||
'bootbox',
|
||||
], function (translator, Benchpress, categorySelector, api, Sortable, bootbox) {
|
||||
var Categories = {};
|
||||
var newCategoryId = -1;
|
||||
var sortables;
|
||||
const Categories = {};
|
||||
let newCategoryId = -1;
|
||||
let sortables;
|
||||
|
||||
Categories.init = function () {
|
||||
categorySelector.init($('.category [component="category-selector"]'), {
|
||||
@@ -26,12 +26,12 @@ define('admin/manage/categories', [
|
||||
|
||||
// Enable/Disable toggle events
|
||||
$('.categories').on('click', '.category-tools [data-action="toggle"]', function () {
|
||||
var $this = $(this);
|
||||
var cid = $this.attr('data-disable-cid');
|
||||
var parentEl = $this.parents('li[data-cid="' + cid + '"]');
|
||||
var disabled = parentEl.hasClass('disabled');
|
||||
var childrenEls = parentEl.find('li[data-cid]');
|
||||
var childrenCids = childrenEls.map(function () {
|
||||
const $this = $(this);
|
||||
const cid = $this.attr('data-disable-cid');
|
||||
const parentEl = $this.parents('li[data-cid="' + cid + '"]');
|
||||
const disabled = parentEl.hasClass('disabled');
|
||||
const childrenEls = parentEl.find('li[data-cid]');
|
||||
const childrenCids = childrenEls.map(function () {
|
||||
return $(this).attr('data-cid');
|
||||
}).get();
|
||||
|
||||
@@ -39,15 +39,15 @@ define('admin/manage/categories', [
|
||||
});
|
||||
|
||||
$('.categories').on('click', '.toggle', function () {
|
||||
var el = $(this);
|
||||
const el = $(this);
|
||||
el.find('i').toggleClass('fa-minus').toggleClass('fa-plus');
|
||||
el.closest('[data-cid]').find('> ul[data-cid]').toggleClass('hidden');
|
||||
});
|
||||
|
||||
$('.categories').on('click', '.set-order', function () {
|
||||
var cid = $(this).attr('data-cid');
|
||||
var order = $(this).attr('data-order');
|
||||
var modal = bootbox.dialog({
|
||||
const cid = $(this).attr('data-cid');
|
||||
const order = $(this).attr('data-order');
|
||||
const modal = bootbox.dialog({
|
||||
title: '[[admin/manage/categories:set-order]]',
|
||||
message: '<input type="number" min="1" class="form-control input-lg" value=' + order + ' /><p class="help-block">[[admin/manage/categories:set-order-help]]</p>',
|
||||
show: true,
|
||||
@@ -56,9 +56,9 @@ define('admin/manage/categories', [
|
||||
label: '[[modules:bootbox.confirm]]',
|
||||
className: 'btn-primary',
|
||||
callback: function () {
|
||||
var val = modal.find('input').val();
|
||||
const val = modal.find('input').val();
|
||||
if (val && cid) {
|
||||
var modified = {};
|
||||
const modified = {};
|
||||
modified[cid] = { order: Math.max(1, parseInt(val, 10)) };
|
||||
api.put('/categories/' + cid, modified[cid]).then(function () {
|
||||
ajaxify.refresh();
|
||||
@@ -81,7 +81,7 @@ define('admin/manage/categories', [
|
||||
});
|
||||
|
||||
function toggleAll(expand) {
|
||||
var el = $('.categories .toggle');
|
||||
const el = $('.categories .toggle');
|
||||
el.find('i').toggleClass('fa-minus', expand).toggleClass('fa-plus', !expand);
|
||||
el.closest('[data-cid]').find('> ul[data-cid]').toggleClass('hidden', !expand);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ define('admin/manage/categories', [
|
||||
|
||||
Categories.throwCreateModal = function () {
|
||||
Benchpress.render('admin/partials/categories/create', {}).then(function (html) {
|
||||
var modal = bootbox.dialog({
|
||||
const modal = bootbox.dialog({
|
||||
title: '[[admin/manage/categories:alert.create]]',
|
||||
message: html,
|
||||
buttons: {
|
||||
@@ -100,7 +100,7 @@ define('admin/manage/categories', [
|
||||
},
|
||||
},
|
||||
});
|
||||
var options = {
|
||||
const options = {
|
||||
localCategories: [
|
||||
{
|
||||
cid: 0,
|
||||
@@ -109,10 +109,10 @@ define('admin/manage/categories', [
|
||||
},
|
||||
],
|
||||
};
|
||||
var parentSelector = categorySelector.init(modal.find('#parentCidGroup [component="category-selector"]'), options);
|
||||
var cloneFromSelector = categorySelector.init(modal.find('#cloneFromCidGroup [component="category-selector"]'), options);
|
||||
const parentSelector = categorySelector.init(modal.find('#parentCidGroup [component="category-selector"]'), options);
|
||||
const cloneFromSelector = categorySelector.init(modal.find('#cloneFromCidGroup [component="category-selector"]'), options);
|
||||
function submit() {
|
||||
var formData = modal.find('form').serializeObject();
|
||||
const formData = modal.find('form').serializeObject();
|
||||
formData.description = '';
|
||||
formData.icon = 'fa-comments';
|
||||
formData.uid = app.user.uid;
|
||||
@@ -125,8 +125,8 @@ define('admin/manage/categories', [
|
||||
}
|
||||
|
||||
$('#cloneChildren').on('change', function () {
|
||||
var check = $(this);
|
||||
var parentSelect = modal.find('#parentCidGroup [component="category-selector"] .dropdown-toggle');
|
||||
const check = $(this);
|
||||
const parentSelect = modal.find('#parentCidGroup [component="category-selector"] .dropdown-toggle');
|
||||
|
||||
if (check.prop('checked')) {
|
||||
parentSelect.attr('disabled', 'disabled');
|
||||
@@ -159,7 +159,7 @@ define('admin/manage/categories', [
|
||||
};
|
||||
|
||||
Categories.render = function (categories) {
|
||||
var container = $('.categories');
|
||||
const container = $('.categories');
|
||||
|
||||
if (!categories || !categories.length) {
|
||||
translator.translate('[[admin/manage/categories:alert.none-active]]', function (text) {
|
||||
@@ -190,15 +190,15 @@ define('admin/manage/categories', [
|
||||
}
|
||||
|
||||
function itemDragDidEnd(e) {
|
||||
var isCategoryUpdate = parseInt(newCategoryId, 10) !== -1;
|
||||
const isCategoryUpdate = parseInt(newCategoryId, 10) !== -1;
|
||||
|
||||
// Update needed?
|
||||
if ((e.newIndex != null && parseInt(e.oldIndex, 10) !== parseInt(e.newIndex, 10)) || isCategoryUpdate) {
|
||||
var cid = e.item.dataset.cid;
|
||||
var modified = {};
|
||||
const cid = e.item.dataset.cid;
|
||||
const modified = {};
|
||||
// on page 1 baseIndex is 0, on page n baseIndex is (n - 1) * ajaxify.data.categoriesPerPage
|
||||
// this makes sure order is correct when drag & drop is used on pages > 1
|
||||
var baseIndex = (ajaxify.data.pagination.currentPage - 1) * ajaxify.data.categoriesPerPage;
|
||||
const baseIndex = (ajaxify.data.pagination.currentPage - 1) * ajaxify.data.categoriesPerPage;
|
||||
modified[cid] = {
|
||||
order: baseIndex + e.newIndex + 1,
|
||||
};
|
||||
@@ -222,7 +222,7 @@ define('admin/manage/categories', [
|
||||
*/
|
||||
function renderList(categories, container, parentId) {
|
||||
// Translate category names if needed
|
||||
var count = 0;
|
||||
let count = 0;
|
||||
categories.forEach(function (category, idx, parent) {
|
||||
translator.translate(category.name, function (translated) {
|
||||
if (category.name !== translated) {
|
||||
@@ -248,7 +248,7 @@ define('admin/manage/categories', [
|
||||
container.append(html);
|
||||
|
||||
// Handle and children categories in this level have
|
||||
for (var x = 0, numCategories = categories.length; x < numCategories; x += 1) {
|
||||
for (let x = 0, numCategories = categories.length; x < numCategories; x += 1) {
|
||||
renderList(categories[x].children, $('li[data-cid="' + categories[x].cid + '"]'), categories[x].cid);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
|
||||
define('admin/manage/category-analytics', ['Chart'], function (Chart) {
|
||||
var CategoryAnalytics = {};
|
||||
const CategoryAnalytics = {};
|
||||
|
||||
CategoryAnalytics.init = function () {
|
||||
var hourlyCanvas = document.getElementById('pageviews:hourly');
|
||||
var dailyCanvas = document.getElementById('pageviews:daily');
|
||||
var topicsCanvas = document.getElementById('topics:daily');
|
||||
var postsCanvas = document.getElementById('posts:daily');
|
||||
var hourlyLabels = utils.getHoursArray().map(function (text, idx) {
|
||||
const hourlyCanvas = document.getElementById('pageviews:hourly');
|
||||
const dailyCanvas = document.getElementById('pageviews:daily');
|
||||
const topicsCanvas = document.getElementById('topics:daily');
|
||||
const postsCanvas = document.getElementById('posts:daily');
|
||||
const hourlyLabels = utils.getHoursArray().map(function (text, idx) {
|
||||
return idx % 3 ? '' : text;
|
||||
});
|
||||
var dailyLabels = utils.getDaysArray().map(function (text, idx) {
|
||||
const dailyLabels = utils.getDaysArray().map(function (text, idx) {
|
||||
return idx % 3 ? '' : text;
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@ define('admin/manage/category-analytics', ['Chart'], function (Chart) {
|
||||
Chart.defaults.global.tooltips.enabled = false;
|
||||
}
|
||||
|
||||
var data = {
|
||||
const data = {
|
||||
'pageviews:hourly': {
|
||||
labels: hourlyLabels,
|
||||
datasets: [
|
||||
|
||||
@@ -8,12 +8,12 @@ define('admin/manage/category', [
|
||||
'api',
|
||||
'bootbox',
|
||||
], function (uploader, iconSelect, categorySelector, Benchpress, api, bootbox) {
|
||||
var Category = {};
|
||||
var updateHash = {};
|
||||
const Category = {};
|
||||
let updateHash = {};
|
||||
|
||||
Category.init = function () {
|
||||
$('#category-settings select').each(function () {
|
||||
var $this = $(this);
|
||||
const $this = $(this);
|
||||
$this.val($this.attr('data-value'));
|
||||
});
|
||||
|
||||
@@ -35,8 +35,8 @@ define('admin/manage/category', [
|
||||
});
|
||||
|
||||
$('[data-name="bgColor"], [data-name="color"]').on('input', function () {
|
||||
var $inputEl = $(this);
|
||||
var previewEl = $inputEl.parents('[data-cid]').find('.category-preview');
|
||||
const $inputEl = $(this);
|
||||
const previewEl = $inputEl.parents('[data-cid]').find('.category-preview');
|
||||
if ($inputEl.attr('data-name') === 'bgColor') {
|
||||
previewEl.css('background-color', $inputEl.val());
|
||||
} else if ($inputEl.attr('data-name') === 'color') {
|
||||
@@ -47,12 +47,12 @@ define('admin/manage/category', [
|
||||
});
|
||||
|
||||
$('#save').on('click', function () {
|
||||
var tags = $('#tag-whitelist').val() ? $('#tag-whitelist').val().split(',') : [];
|
||||
const tags = $('#tag-whitelist').val() ? $('#tag-whitelist').val().split(',') : [];
|
||||
if (tags.length && tags.length < parseInt($('#cid-min-tags').val(), 10)) {
|
||||
return app.alertError('[[admin/manage/categories:alert.not-enough-whitelisted-tags]]');
|
||||
}
|
||||
|
||||
var cid = ajaxify.data.category.cid;
|
||||
const cid = ajaxify.data.category.cid;
|
||||
api.put('/categories/' + cid, updateHash).then((res) => {
|
||||
app.flags._unsaved = false;
|
||||
app.alert({
|
||||
@@ -74,7 +74,7 @@ define('admin/manage/category', [
|
||||
name: ajaxify.data.category.name,
|
||||
topic_count: ajaxify.data.category.topic_count,
|
||||
}).then(function (html) {
|
||||
var modal = bootbox.dialog({
|
||||
const modal = bootbox.dialog({
|
||||
title: '[[admin/manage/categories:purge]]',
|
||||
message: html,
|
||||
size: 'large',
|
||||
@@ -85,13 +85,13 @@ define('admin/manage/category', [
|
||||
callback: function () {
|
||||
modal.find('.modal-footer button').prop('disabled', true);
|
||||
|
||||
var intervalId = setInterval(function () {
|
||||
const intervalId = setInterval(function () {
|
||||
socket.emit('categories.getTopicCount', ajaxify.data.category.cid, function (err, count) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
|
||||
var percent = 0;
|
||||
let percent = 0;
|
||||
if (ajaxify.data.category.topic_count > 0) {
|
||||
percent = Math.max(0, (1 - (count / ajaxify.data.category.topic_count))) * 100;
|
||||
}
|
||||
@@ -119,8 +119,8 @@ define('admin/manage/category', [
|
||||
|
||||
$('.copy-settings').on('click', function () {
|
||||
Benchpress.render('admin/partials/categories/copy-settings', {}).then(function (html) {
|
||||
var selectedCid;
|
||||
var modal = bootbox.dialog({
|
||||
let selectedCid;
|
||||
const modal = bootbox.dialog({
|
||||
title: '[[modules:composer.select_category]]',
|
||||
message: html,
|
||||
buttons: {
|
||||
@@ -165,8 +165,8 @@ define('admin/manage/category', [
|
||||
});
|
||||
|
||||
$('.upload-button').on('click', function () {
|
||||
var inputEl = $(this);
|
||||
var cid = inputEl.attr('data-cid');
|
||||
const inputEl = $(this);
|
||||
const cid = inputEl.attr('data-cid');
|
||||
|
||||
uploader.show({
|
||||
title: '[[admin/manage/categories:alert.upload-image]]',
|
||||
@@ -174,7 +174,7 @@ define('admin/manage/category', [
|
||||
params: { cid: cid },
|
||||
}, function (imageUrlOnServer) {
|
||||
$('#category-image').val(imageUrlOnServer);
|
||||
var previewBox = inputEl.parent().parent().siblings('.category-preview');
|
||||
const previewBox = inputEl.parent().parent().siblings('.category-preview');
|
||||
previewBox.css('background', 'url(' + imageUrlOnServer + '?' + new Date().getTime() + ')');
|
||||
|
||||
modified($('#category-image'));
|
||||
@@ -189,8 +189,8 @@ define('admin/manage/category', [
|
||||
$('.delete-image').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var inputEl = $('#category-image');
|
||||
var previewBox = $('.category-preview');
|
||||
const inputEl = $('#category-image');
|
||||
const previewBox = $('.category-preview');
|
||||
|
||||
inputEl.val('');
|
||||
previewBox.css('background-image', '');
|
||||
@@ -217,8 +217,8 @@ define('admin/manage/category', [
|
||||
}).catch(app.alertError);
|
||||
});
|
||||
$('button[data-action="toggle"]').on('click', function () {
|
||||
var $this = $(this);
|
||||
var disabled = $this.attr('data-disabled') === '1';
|
||||
const $this = $(this);
|
||||
const disabled = $this.attr('data-disabled') === '1';
|
||||
api.put('/categories/' + ajaxify.data.category.cid, {
|
||||
disabled: disabled ? 0 : 1,
|
||||
}).then(() => {
|
||||
@@ -230,14 +230,14 @@ define('admin/manage/category', [
|
||||
};
|
||||
|
||||
function modified(el) {
|
||||
var value;
|
||||
let value;
|
||||
if ($(el).is(':checkbox')) {
|
||||
value = $(el).is(':checked') ? 1 : 0;
|
||||
} else {
|
||||
value = $(el).val();
|
||||
}
|
||||
var dataName = $(el).attr('data-name');
|
||||
var fields = dataName.match(/[^\][.]+/g);
|
||||
const dataName = $(el).attr('data-name');
|
||||
const fields = dataName.match(/[^\][.]+/g);
|
||||
|
||||
function setNestedFields(obj, index) {
|
||||
if (index === fields.length) {
|
||||
@@ -263,7 +263,7 @@ define('admin/manage/category', [
|
||||
}
|
||||
|
||||
function handleTags() {
|
||||
var tagEl = $('#tag-whitelist');
|
||||
const tagEl = $('#tag-whitelist');
|
||||
tagEl.tagsinput({
|
||||
confirmKeys: [13, 44],
|
||||
trimValue: true,
|
||||
@@ -281,7 +281,7 @@ define('admin/manage/category', [
|
||||
Category.launchParentSelector = function () {
|
||||
categorySelector.modal({
|
||||
onSubmit: function (selectedCategory) {
|
||||
var parentCid = selectedCategory.cid;
|
||||
const parentCid = selectedCategory.cid;
|
||||
if (!parentCid) {
|
||||
return;
|
||||
}
|
||||
@@ -290,7 +290,7 @@ define('admin/manage/category', [
|
||||
}).then(() => {
|
||||
api.get(`/categories/${parentCid}`, {}).then(function (parent) {
|
||||
if (parent && parent.icon && parent.name) {
|
||||
var buttonHtml = '<i class="fa ' + parent.icon + '"></i> ' + parent.name;
|
||||
const buttonHtml = '<i class="fa ' + parent.icon + '"></i> ' + parent.name;
|
||||
$('button[data-action="changeParent"]').html(buttonHtml).parent().removeClass('hide');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
|
||||
define('admin/manage/digest', ['bootbox'], function (bootbox) {
|
||||
var Digest = {};
|
||||
const Digest = {};
|
||||
|
||||
Digest.init = function () {
|
||||
$('table').on('click', '[data-action]', function () {
|
||||
var action = this.getAttribute('data-action');
|
||||
var uid = this.getAttribute('data-uid');
|
||||
const action = this.getAttribute('data-action');
|
||||
const uid = this.getAttribute('data-uid');
|
||||
|
||||
if (action.startsWith('resend-')) {
|
||||
var interval = action.slice(7);
|
||||
const interval = action.slice(7);
|
||||
bootbox.confirm('[[admin/manage/digest:resend-all-confirm]]', function (ok) {
|
||||
if (ok) {
|
||||
Digest.send(action, undefined, function (err) {
|
||||
|
||||
@@ -10,17 +10,17 @@ define('admin/manage/group', [
|
||||
'api',
|
||||
'bootbox',
|
||||
], function (memberList, iconSelect, translator, categorySelector, groupSearch, slugify, api, bootbox) {
|
||||
var Groups = {};
|
||||
const Groups = {};
|
||||
|
||||
Groups.init = function () {
|
||||
var groupIcon = $('#group-icon');
|
||||
var changeGroupUserTitle = $('#change-group-user-title');
|
||||
var changeGroupLabelColor = $('#change-group-label-color');
|
||||
var changeGroupTextColor = $('#change-group-text-color');
|
||||
var groupLabelPreview = $('#group-label-preview');
|
||||
var groupLabelPreviewText = $('#group-label-preview-text');
|
||||
const groupIcon = $('#group-icon');
|
||||
const changeGroupUserTitle = $('#change-group-user-title');
|
||||
const changeGroupLabelColor = $('#change-group-label-color');
|
||||
const changeGroupTextColor = $('#change-group-text-color');
|
||||
const groupLabelPreview = $('#group-label-preview');
|
||||
const groupLabelPreviewText = $('#group-label-preview-text');
|
||||
|
||||
var groupName = ajaxify.data.group.name;
|
||||
const groupName = ajaxify.data.group.name;
|
||||
|
||||
$('#group-selector').on('change', function () {
|
||||
ajaxify.go('admin/manage/groups/' + $(this).val() + window.location.hash);
|
||||
@@ -43,9 +43,9 @@ define('admin/manage/group', [
|
||||
setupGroupMembersMenu();
|
||||
|
||||
$('#group-icon, #group-icon-label').on('click', function () {
|
||||
var currentIcon = groupIcon.attr('value');
|
||||
const currentIcon = groupIcon.attr('value');
|
||||
iconSelect.init(groupIcon, function () {
|
||||
var newIcon = groupIcon.attr('value');
|
||||
let newIcon = groupIcon.attr('value');
|
||||
if (newIcon === currentIcon) {
|
||||
return;
|
||||
}
|
||||
@@ -65,9 +65,9 @@ define('admin/manage/group', [
|
||||
showLinks: true,
|
||||
});
|
||||
|
||||
var cidSelector = categorySelector.init($('.member-post-cids-selector [component="category-selector"]'), {
|
||||
const cidSelector = categorySelector.init($('.member-post-cids-selector [component="category-selector"]'), {
|
||||
onSelect: function (selectedCategory) {
|
||||
var cids = ($('#memberPostCids').val() || '').split(',').map(cid => parseInt(cid, 10));
|
||||
let cids = ($('#memberPostCids').val() || '').split(',').map(cid => parseInt(cid, 10));
|
||||
cids.push(selectedCategory.cid);
|
||||
cids = cids.filter((cid, index, array) => array.indexOf(cid) === index);
|
||||
$('#memberPostCids').val(cids.join(','));
|
||||
@@ -97,7 +97,7 @@ define('admin/manage/group', [
|
||||
disableJoinRequests: $('#group-disableJoinRequests').is(':checked'),
|
||||
disableLeave: $('#group-disableLeave').is(':checked'),
|
||||
}).then(() => {
|
||||
var newName = $('#change-group-name').val();
|
||||
const newName = $('#change-group-name').val();
|
||||
|
||||
// If the group name changed, change url
|
||||
if (groupName !== newName) {
|
||||
@@ -112,12 +112,12 @@ define('admin/manage/group', [
|
||||
|
||||
function setupGroupMembersMenu() {
|
||||
$('[component="groups/members"]').on('click', '[data-action]', function () {
|
||||
var btnEl = $(this);
|
||||
var userRow = btnEl.parents('[data-uid]');
|
||||
var ownerFlagEl = userRow.find('.member-name .user-owner-icon');
|
||||
var isOwner = !ownerFlagEl.hasClass('invisible');
|
||||
var uid = userRow.attr('data-uid');
|
||||
var action = btnEl.attr('data-action');
|
||||
const btnEl = $(this);
|
||||
const userRow = btnEl.parents('[data-uid]');
|
||||
const ownerFlagEl = userRow.find('.member-name .user-owner-icon');
|
||||
const isOwner = !ownerFlagEl.hasClass('invisible');
|
||||
const uid = userRow.attr('data-uid');
|
||||
const action = btnEl.attr('data-action');
|
||||
|
||||
switch (action) {
|
||||
case 'toggleOwnership':
|
||||
@@ -144,7 +144,7 @@ define('admin/manage/group', [
|
||||
|
||||
function navigateToCategory(cid) {
|
||||
if (cid) {
|
||||
var url = 'admin/manage/privileges/' + cid + '?group=' + ajaxify.data.group.nameEncoded;
|
||||
const url = 'admin/manage/privileges/' + cid + '?group=' + ajaxify.data.group.nameEncoded;
|
||||
if (app.flags && app.flags._unsaved === true) {
|
||||
translator.translate('[[global:unsaved-changes]]', function (text) {
|
||||
bootbox.confirm(text, function (navigate) {
|
||||
|
||||
@@ -6,13 +6,13 @@ define('admin/manage/groups', [
|
||||
'api',
|
||||
'bootbox',
|
||||
], function (categorySelector, slugify, api, bootbox) {
|
||||
var Groups = {};
|
||||
const Groups = {};
|
||||
|
||||
Groups.init = function () {
|
||||
var createModal = $('#create-modal');
|
||||
var createGroupName = $('#create-group-name');
|
||||
var createModalGo = $('#create-modal-go');
|
||||
var createModalError = $('#create-modal-error');
|
||||
const createModal = $('#create-modal');
|
||||
const createGroupName = $('#create-group-name');
|
||||
const createModalGo = $('#create-modal-go');
|
||||
const createModalError = $('#create-modal-error');
|
||||
|
||||
handleSearch();
|
||||
|
||||
@@ -30,7 +30,7 @@ define('admin/manage/groups', [
|
||||
});
|
||||
|
||||
createModalGo.on('click', function () {
|
||||
var submitObj = {
|
||||
const submitObj = {
|
||||
name: createGroupName.val(),
|
||||
description: $('#create-group-desc').val(),
|
||||
private: $('#create-group-private').is(':checked') ? 1 : 0,
|
||||
@@ -53,9 +53,9 @@ define('admin/manage/groups', [
|
||||
});
|
||||
|
||||
$('.groups-list').on('click', '[data-action]', function () {
|
||||
var el = $(this);
|
||||
var action = el.attr('data-action');
|
||||
var groupName = el.parents('tr[data-groupname]').attr('data-groupname');
|
||||
const el = $(this);
|
||||
const action = el.attr('data-action');
|
||||
const groupName = el.parents('tr[data-groupname]').attr('data-groupname');
|
||||
|
||||
switch (action) {
|
||||
case 'delete':
|
||||
@@ -73,7 +73,7 @@ define('admin/manage/groups', [
|
||||
|
||||
function enableCategorySelectors() {
|
||||
$('.groups-list [component="category-selector"]').each(function () {
|
||||
var nameEncoded = $(this).parents('[data-name-encoded]').attr('data-name-encoded');
|
||||
const nameEncoded = $(this).parents('[data-name-encoded]').attr('data-name-encoded');
|
||||
categorySelector.init($(this), {
|
||||
onSelect: function (selectedCategory) {
|
||||
ajaxify.go('admin/manage/privileges/' + selectedCategory.cid + '?group=' + nameEncoded);
|
||||
@@ -84,14 +84,14 @@ define('admin/manage/groups', [
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
var queryEl = $('#group-search');
|
||||
const queryEl = $('#group-search');
|
||||
|
||||
function doSearch() {
|
||||
if (!queryEl.val()) {
|
||||
return ajaxify.refresh();
|
||||
}
|
||||
$('.pagination').addClass('hide');
|
||||
var groupsEl = $('.groups-list');
|
||||
const groupsEl = $('.groups-list');
|
||||
socket.emit('groups.search', {
|
||||
query: queryEl.val(),
|
||||
options: {
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
|
||||
define('admin/manage/registration', ['bootbox'], function (bootbox) {
|
||||
var Registration = {};
|
||||
const Registration = {};
|
||||
|
||||
Registration.init = function () {
|
||||
$('.users-list').on('click', '[data-action]', function () {
|
||||
var parent = $(this).parents('[data-username]');
|
||||
var action = $(this).attr('data-action');
|
||||
var username = parent.attr('data-username');
|
||||
var method = action === 'accept' ? 'user.acceptRegistration' : 'user.rejectRegistration';
|
||||
const parent = $(this).parents('[data-username]');
|
||||
const action = $(this).attr('data-action');
|
||||
const username = parent.attr('data-username');
|
||||
const method = action === 'accept' ? 'user.acceptRegistration' : 'user.rejectRegistration';
|
||||
|
||||
socket.emit(method, { username: username }, function (err) {
|
||||
if (err) {
|
||||
@@ -21,16 +21,16 @@ define('admin/manage/registration', ['bootbox'], function (bootbox) {
|
||||
});
|
||||
|
||||
$('.invites-list').on('click', '[data-action]', function () {
|
||||
var parent = $(this).parents('[data-invitation-mail][data-invited-by]');
|
||||
var email = parent.attr('data-invitation-mail');
|
||||
var invitedBy = parent.attr('data-invited-by');
|
||||
var action = $(this).attr('data-action');
|
||||
var method = 'user.deleteInvitation';
|
||||
const parent = $(this).parents('[data-invitation-mail][data-invited-by]');
|
||||
const email = parent.attr('data-invitation-mail');
|
||||
const invitedBy = parent.attr('data-invited-by');
|
||||
const action = $(this).attr('data-action');
|
||||
const method = 'user.deleteInvitation';
|
||||
|
||||
var removeRow = function () {
|
||||
var nextRow = parent.next();
|
||||
var thisRowinvitedBy = parent.find('.invited-by');
|
||||
var nextRowInvitedBy = nextRow.find('.invited-by');
|
||||
const removeRow = function () {
|
||||
const nextRow = parent.next();
|
||||
const thisRowinvitedBy = parent.find('.invited-by');
|
||||
const nextRowInvitedBy = nextRow.find('.invited-by');
|
||||
if (nextRowInvitedBy.html() !== undefined && nextRowInvitedBy.html().length < 2) {
|
||||
nextRowInvitedBy.html(thisRowinvitedBy.html());
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ define('admin/manage/tags', [
|
||||
'forum/infinitescroll',
|
||||
'admin/modules/selectable',
|
||||
], function (bootbox, infinitescroll, selectable) {
|
||||
var Tags = {};
|
||||
const Tags = {};
|
||||
|
||||
Tags.init = function () {
|
||||
selectable.enable('.tag-management', '.tag-row');
|
||||
@@ -18,9 +18,9 @@ define('admin/manage/tags', [
|
||||
};
|
||||
|
||||
function handleCreate() {
|
||||
var createModal = $('#create-modal');
|
||||
var createTagName = $('#create-tag-name');
|
||||
var createModalGo = $('#create-modal-go');
|
||||
const createModal = $('#create-modal');
|
||||
const createTagName = $('#create-tag-name');
|
||||
const createModalGo = $('#create-modal-go');
|
||||
|
||||
createModal.on('keypress', function (e) {
|
||||
if (e.keyCode === 13) {
|
||||
@@ -74,12 +74,12 @@ define('admin/manage/tags', [
|
||||
|
||||
function handleRename() {
|
||||
$('#rename').on('click', function () {
|
||||
var tagsToModify = $('.tag-row.ui-selected');
|
||||
const tagsToModify = $('.tag-row.ui-selected');
|
||||
if (!tagsToModify.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
var modal = bootbox.dialog({
|
||||
const modal = bootbox.dialog({
|
||||
title: '[[admin/manage/tags:alerts.editing]]',
|
||||
message: $('.rename-modal').html(),
|
||||
buttons: {
|
||||
@@ -87,7 +87,7 @@ define('admin/manage/tags', [
|
||||
label: 'Save',
|
||||
className: 'btn-primary save',
|
||||
callback: function () {
|
||||
var data = [];
|
||||
const data = [];
|
||||
tagsToModify.each(function (idx, tag) {
|
||||
tag = $(tag);
|
||||
data.push({
|
||||
@@ -112,7 +112,7 @@ define('admin/manage/tags', [
|
||||
|
||||
function handleDeleteSelected() {
|
||||
$('#deleteSelected').on('click', function () {
|
||||
var tagsToDelete = $('.tag-row.ui-selected');
|
||||
const tagsToDelete = $('.tag-row.ui-selected');
|
||||
if (!tagsToDelete.length) {
|
||||
return;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ define('admin/manage/tags', [
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
var tags = [];
|
||||
const tags = [];
|
||||
tagsToDelete.each(function (index, el) {
|
||||
tags.push($(el).attr('data-tag'));
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
define('admin/manage/uploads', ['api', 'bootbox', 'uploader'], function (api, bootbox, uploader) {
|
||||
var Uploads = {};
|
||||
const Uploads = {};
|
||||
|
||||
Uploads.init = function () {
|
||||
$('#upload').on('click', function () {
|
||||
@@ -15,7 +15,7 @@ define('admin/manage/uploads', ['api', 'bootbox', 'uploader'], function (api, bo
|
||||
});
|
||||
|
||||
$('.delete').on('click', function () {
|
||||
var file = $(this).parents('[data-path]');
|
||||
const file = $(this).parents('[data-path]');
|
||||
bootbox.confirm('[[admin/manage/uploads:confirm-delete]]', function (ok) {
|
||||
if (!ok) {
|
||||
return;
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
define('admin/manage/users', [
|
||||
'translator', 'benchpress', 'autocomplete', 'api', 'slugify', 'bootbox', 'accounts/invite',
|
||||
], function (translator, Benchpress, autocomplete, api, slugify, bootbox, AccountInvite) {
|
||||
var Users = {};
|
||||
const Users = {};
|
||||
|
||||
Users.init = function () {
|
||||
$('#results-per-page').val(ajaxify.data.resultsPerPage).on('change', function () {
|
||||
var query = utils.params();
|
||||
const query = utils.params();
|
||||
query.resultsPerPage = $('#results-per-page').val();
|
||||
var qs = buildSearchQuery(query);
|
||||
const qs = buildSearchQuery(query);
|
||||
ajaxify.go(window.location.pathname + '?' + qs);
|
||||
});
|
||||
|
||||
@@ -42,7 +42,7 @@ define('admin/manage/users', [
|
||||
});
|
||||
|
||||
function getSelectedUids() {
|
||||
var uids = [];
|
||||
const uids = [];
|
||||
|
||||
$('.users-table [component="user/select/single"]').each(function () {
|
||||
if ($(this).is(':checked')) {
|
||||
@@ -99,7 +99,7 @@ define('admin/manage/users', [
|
||||
});
|
||||
|
||||
$('.manage-groups').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
const uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
app.alertError('[[error:no-users-selected]]');
|
||||
return false;
|
||||
@@ -109,14 +109,14 @@ define('admin/manage/users', [
|
||||
return app.alertError(err);
|
||||
}
|
||||
Benchpress.render('admin/partials/manage_user_groups', data).then(function (html) {
|
||||
var modal = bootbox.dialog({
|
||||
const modal = bootbox.dialog({
|
||||
message: html,
|
||||
title: '[[admin/manage/users:manage-groups]]',
|
||||
onEscape: true,
|
||||
});
|
||||
modal.on('shown.bs.modal', function () {
|
||||
autocomplete.group(modal.find('.group-search'), function (ev, ui) {
|
||||
var uid = $(ev.target).attr('data-uid');
|
||||
const uid = $(ev.target).attr('data-uid');
|
||||
api.put('/groups/' + ui.item.group.slug + '/membership/' + uid, undefined).then(() => {
|
||||
ui.item.group.nameEscaped = translator.escape(ui.item.group.displayName);
|
||||
app.parseAndTranslate('admin/partials/manage_user_groups', { users: [{ groups: [ui.item.group] }] }, function (html) {
|
||||
@@ -129,9 +129,9 @@ define('admin/manage/users', [
|
||||
modal.modal('hide');
|
||||
});
|
||||
modal.on('click', '.remove-group-icon', function () {
|
||||
var groupCard = $(this).parents('[data-group-name]');
|
||||
var groupName = groupCard.attr('data-group-name');
|
||||
var uid = $(this).parents('[data-uid]').attr('data-uid');
|
||||
const groupCard = $(this).parents('[data-group-name]');
|
||||
const groupName = groupCard.attr('data-group-name');
|
||||
const uid = $(this).parents('[data-uid]').attr('data-uid');
|
||||
api.del('/groups/' + slugify(groupName) + '/membership/' + uid).then(() => {
|
||||
groupCard.remove();
|
||||
}).catch(app.alertError);
|
||||
@@ -142,7 +142,7 @@ define('admin/manage/users', [
|
||||
});
|
||||
|
||||
$('.ban-user').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
const uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
app.alertError('[[error:no-users-selected]]');
|
||||
return false; // specifically to keep the menu open
|
||||
@@ -160,7 +160,7 @@ define('admin/manage/users', [
|
||||
});
|
||||
|
||||
$('.ban-user-temporary').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
const uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
app.alertError('[[error:no-users-selected]]');
|
||||
return false; // specifically to keep the menu open
|
||||
@@ -180,11 +180,11 @@ define('admin/manage/users', [
|
||||
submit: {
|
||||
label: '[[admin/manage/users:alerts.button-ban-x, ' + uids.length + ']]',
|
||||
callback: function () {
|
||||
var formData = $('.ban-modal form').serializeArray().reduce(function (data, cur) {
|
||||
const formData = $('.ban-modal form').serializeArray().reduce(function (data, cur) {
|
||||
data[cur.name] = cur.value;
|
||||
return data;
|
||||
}, {});
|
||||
var until = formData.length > 0 ? (
|
||||
const until = formData.length > 0 ? (
|
||||
Date.now() + (formData.length * 1000 * 60 * 60 * (parseInt(formData.unit, 10) ? 24 : 1))
|
||||
) : 0;
|
||||
|
||||
@@ -204,7 +204,7 @@ define('admin/manage/users', [
|
||||
});
|
||||
|
||||
$('.unban-user').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
const uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
app.alertError('[[error:no-users-selected]]');
|
||||
return false; // specifically to keep the menu open
|
||||
@@ -218,7 +218,7 @@ define('admin/manage/users', [
|
||||
});
|
||||
|
||||
$('.reset-lockout').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
const uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
return;
|
||||
}
|
||||
@@ -227,7 +227,7 @@ define('admin/manage/users', [
|
||||
});
|
||||
|
||||
$('.validate-email').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
const uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
return;
|
||||
}
|
||||
@@ -249,7 +249,7 @@ define('admin/manage/users', [
|
||||
});
|
||||
|
||||
$('.send-validation-email').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
const uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
return;
|
||||
}
|
||||
@@ -262,7 +262,7 @@ define('admin/manage/users', [
|
||||
});
|
||||
|
||||
$('.password-reset-email').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
const uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
return;
|
||||
}
|
||||
@@ -275,7 +275,7 @@ define('admin/manage/users', [
|
||||
});
|
||||
|
||||
$('.force-password-reset').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
const uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
return;
|
||||
}
|
||||
@@ -304,7 +304,7 @@ define('admin/manage/users', [
|
||||
tableEl.addEventListener('change', (e) => {
|
||||
const subselector = e.target.closest('[component="user/select/single"]') || e.target.closest('[component="user/select/all"]');
|
||||
if (subselector) {
|
||||
var uids = getSelectedUids();
|
||||
const uids = getSelectedUids();
|
||||
if (uids.length) {
|
||||
actionBtn.removeAttribute('disabled');
|
||||
} else {
|
||||
@@ -314,7 +314,7 @@ define('admin/manage/users', [
|
||||
});
|
||||
|
||||
function handleDelete(confirmMsg, path) {
|
||||
var uids = getSelectedUids();
|
||||
const uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
return;
|
||||
}
|
||||
@@ -347,7 +347,7 @@ define('admin/manage/users', [
|
||||
function handleUserCreate() {
|
||||
$('[data-action="create"]').on('click', function () {
|
||||
Benchpress.render('admin/partials/create_user_modal', {}).then(function (html) {
|
||||
var modal = bootbox.dialog({
|
||||
const modal = bootbox.dialog({
|
||||
message: html,
|
||||
title: '[[admin/manage/users:alerts.create]]',
|
||||
onEscape: true,
|
||||
@@ -375,19 +375,19 @@ define('admin/manage/users', [
|
||||
}
|
||||
|
||||
function createUser() {
|
||||
var modal = this;
|
||||
var username = document.getElementById('create-user-name').value;
|
||||
var email = document.getElementById('create-user-email').value;
|
||||
var password = document.getElementById('create-user-password').value;
|
||||
var passwordAgain = document.getElementById('create-user-password-again').value;
|
||||
const modal = this;
|
||||
const username = document.getElementById('create-user-name').value;
|
||||
const email = document.getElementById('create-user-email').value;
|
||||
const password = document.getElementById('create-user-password').value;
|
||||
const passwordAgain = document.getElementById('create-user-password-again').value;
|
||||
|
||||
var errorEl = $('#create-modal-error');
|
||||
const errorEl = $('#create-modal-error');
|
||||
|
||||
if (password !== passwordAgain) {
|
||||
return errorEl.translateHtml('[[admin/manage/users:alerts.error-x, [[admin/manage/users:alerts.error-passwords-different]]]]').removeClass('hide');
|
||||
}
|
||||
|
||||
var user = {
|
||||
const user = {
|
||||
username: username,
|
||||
email: email,
|
||||
password: password,
|
||||
@@ -425,12 +425,12 @@ define('admin/manage/users', [
|
||||
}
|
||||
|
||||
function loadSearchPage(query) {
|
||||
var params = utils.params();
|
||||
const params = utils.params();
|
||||
params.searchBy = query.searchBy;
|
||||
params.query = query.query;
|
||||
params.page = query.page;
|
||||
params.sortBy = params.sortBy || 'lastonline';
|
||||
var qs = decodeURIComponent($.param(params));
|
||||
const qs = decodeURIComponent($.param(params));
|
||||
$.get(config.relative_path + '/api/admin/manage/users?' + qs, function (data) {
|
||||
renderSearchResults(data);
|
||||
const url = config.relative_path + '/admin/manage/users?' + qs;
|
||||
@@ -488,12 +488,12 @@ define('admin/manage/users', [
|
||||
|
||||
function handleSort() {
|
||||
$('.users-table thead th').on('click', function () {
|
||||
var $this = $(this);
|
||||
var sortBy = $this.attr('data-sort');
|
||||
const $this = $(this);
|
||||
const sortBy = $this.attr('data-sort');
|
||||
if (!sortBy) {
|
||||
return;
|
||||
}
|
||||
var params = utils.params();
|
||||
const params = utils.params();
|
||||
params.sortBy = sortBy;
|
||||
if (ajaxify.data.sortBy === sortBy) {
|
||||
params.sortDirection = ajaxify.data.reverse ? 'asc' : 'desc';
|
||||
@@ -501,13 +501,13 @@ define('admin/manage/users', [
|
||||
params.sortDirection = 'desc';
|
||||
}
|
||||
|
||||
var qs = buildSearchQuery(params);
|
||||
const qs = buildSearchQuery(params);
|
||||
ajaxify.go('admin/manage/users?' + qs);
|
||||
});
|
||||
}
|
||||
|
||||
function getFilters() {
|
||||
var filters = [];
|
||||
const filters = [];
|
||||
$('#filter-by').find('[data-filter-by]').each(function () {
|
||||
if ($(this).find('.fa-check').length) {
|
||||
filters.push($(this).attr('data-filter-by'));
|
||||
@@ -517,16 +517,16 @@ define('admin/manage/users', [
|
||||
}
|
||||
|
||||
function handleFilter() {
|
||||
var currentFilters = getFilters();
|
||||
let currentFilters = getFilters();
|
||||
$('#filter-by').on('click', 'li', function () {
|
||||
var $this = $(this);
|
||||
const $this = $(this);
|
||||
$this.find('i').toggleClass('fa-check', !$this.find('i').hasClass('fa-check'));
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#filter-by').on('hidden.bs.dropdown', function () {
|
||||
var filters = getFilters();
|
||||
var changed = filters.length !== currentFilters.length;
|
||||
const filters = getFilters();
|
||||
let changed = filters.length !== currentFilters.length;
|
||||
if (filters.length === currentFilters.length) {
|
||||
filters.forEach(function (filter, i) {
|
||||
if (filter !== currentFilters[i]) {
|
||||
@@ -536,9 +536,9 @@ define('admin/manage/users', [
|
||||
}
|
||||
currentFilters = getFilters();
|
||||
if (changed) {
|
||||
var params = utils.params();
|
||||
const params = utils.params();
|
||||
params.filters = filters;
|
||||
var qs = buildSearchQuery(params);
|
||||
const qs = buildSearchQuery(params);
|
||||
ajaxify.go('admin/manage/users?' + qs);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
// TODO: no longer used remove in 1.19.0
|
||||
define('admin/modules/colorpicker', function () {
|
||||
var colorpicker = {};
|
||||
const colorpicker = {};
|
||||
|
||||
colorpicker.enable = function (inputEl, callback) {
|
||||
(inputEl instanceof jQuery ? inputEl : $(inputEl)).each(function () {
|
||||
var $this = $(this);
|
||||
const $this = $(this);
|
||||
|
||||
$this.ColorPicker({
|
||||
color: $this.val() || '#000',
|
||||
|
||||
@@ -18,7 +18,7 @@ define('admin/modules/dashboard-line-graph', ['Chart', 'translator', 'benchpress
|
||||
|
||||
Graph.handleUpdateControls({ set });
|
||||
|
||||
var t = translator.Translator.create();
|
||||
const t = translator.Translator.create();
|
||||
return new Promise((resolve) => {
|
||||
t.translateKey(`admin/menu:${ajaxify.data.template.name.replace('admin/', '')}`, []).then((key) => {
|
||||
const data = {
|
||||
@@ -81,8 +81,8 @@ define('admin/modules/dashboard-line-graph', ['Chart', 'translator', 'benchpress
|
||||
|
||||
Graph.handleUpdateControls = ({ set }) => {
|
||||
$('[data-action="updateGraph"]:not([data-units="custom"])').on('click', function () {
|
||||
var until = new Date();
|
||||
var amount = $(this).attr('data-amount');
|
||||
let until = new Date();
|
||||
const amount = $(this).attr('data-amount');
|
||||
if ($(this).attr('data-units') === 'days') {
|
||||
until.setHours(0, 0, 0, 0);
|
||||
}
|
||||
@@ -97,10 +97,10 @@ define('admin/modules/dashboard-line-graph', ['Chart', 'translator', 'benchpress
|
||||
});
|
||||
|
||||
$('[data-action="updateGraph"][data-units="custom"]').on('click', function () {
|
||||
var targetEl = $(this);
|
||||
const targetEl = $(this);
|
||||
|
||||
Benchpress.render('admin/partials/pageviews-range-select', {}).then(function (html) {
|
||||
var modal = bootbox.dialog({
|
||||
const modal = bootbox.dialog({
|
||||
title: '[[admin/dashboard:page-views-custom]]',
|
||||
message: html,
|
||||
buttons: {
|
||||
@@ -111,10 +111,10 @@ define('admin/modules/dashboard-line-graph', ['Chart', 'translator', 'benchpress
|
||||
},
|
||||
},
|
||||
}).on('shown.bs.modal', function () {
|
||||
var date = new Date();
|
||||
var today = date.toISOString().substr(0, 10);
|
||||
const date = new Date();
|
||||
const today = date.toISOString().substr(0, 10);
|
||||
date.setDate(date.getDate() - 1);
|
||||
var yesterday = date.toISOString().substr(0, 10);
|
||||
const yesterday = date.toISOString().substr(0, 10);
|
||||
|
||||
modal.find('#startRange').val(targetEl.attr('data-startRange') || yesterday);
|
||||
modal.find('#endRange').val(targetEl.attr('data-endRange') || today);
|
||||
@@ -122,8 +122,8 @@ define('admin/modules/dashboard-line-graph', ['Chart', 'translator', 'benchpress
|
||||
|
||||
function submit() {
|
||||
// NEED TO ADD VALIDATION HERE FOR YYYY-MM-DD
|
||||
var formData = modal.find('form').serializeObject();
|
||||
var validRegexp = /\d{4}-\d{2}-\d{2}/;
|
||||
const formData = modal.find('form').serializeObject();
|
||||
const validRegexp = /\d{4}-\d{2}-\d{2}/;
|
||||
|
||||
// Input validation
|
||||
if (!formData.startRange && !formData.endRange) {
|
||||
@@ -136,10 +136,10 @@ define('admin/modules/dashboard-line-graph', ['Chart', 'translator', 'benchpress
|
||||
return false;
|
||||
}
|
||||
|
||||
var until = new Date(formData.endRange);
|
||||
let until = new Date(formData.endRange);
|
||||
until.setDate(until.getDate() + 1);
|
||||
until = until.getTime();
|
||||
var amount = (until - new Date(formData.startRange).getTime()) / (1000 * 60 * 60 * 24);
|
||||
const amount = (until - new Date(formData.startRange).getTime()) / (1000 * 60 * 60 * 24);
|
||||
|
||||
Graph.update(set, 'days', until, amount);
|
||||
|
||||
@@ -175,8 +175,8 @@ define('admin/modules/dashboard-line-graph', ['Chart', 'translator', 'benchpress
|
||||
Graph._current.update();
|
||||
|
||||
// Update address bar and "View as JSON" button url
|
||||
var apiEl = $('#view-as-json');
|
||||
var newHref = $.param({
|
||||
const apiEl = $('#view-as-json');
|
||||
const newHref = $.param({
|
||||
units: units || 'hours',
|
||||
until: until,
|
||||
count: amount,
|
||||
|
||||
@@ -6,7 +6,7 @@ define('admin/modules/instance', [
|
||||
// the client can't fetch the template file, resulting in an error
|
||||
config.relative_path + '/assets/templates/alert.js',
|
||||
], function () {
|
||||
var instance = {};
|
||||
const instance = {};
|
||||
|
||||
instance.rebuildAndRestart = function (callback) {
|
||||
app.alert({
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
'use strict';
|
||||
|
||||
define('admin/modules/search', ['mousetrap'], function (mousetrap) {
|
||||
var search = {};
|
||||
const search = {};
|
||||
|
||||
function find(dict, term) {
|
||||
var html = dict.filter(function (elem) {
|
||||
const html = dict.filter(function (elem) {
|
||||
return elem.translations.toLowerCase().includes(term);
|
||||
}).map(function (params) {
|
||||
var namespace = params.namespace;
|
||||
var translations = params.translations;
|
||||
var title = params.title;
|
||||
var escaped = utils.escapeRegexChars(term);
|
||||
const namespace = params.namespace;
|
||||
const translations = params.translations;
|
||||
let title = params.title;
|
||||
const escaped = utils.escapeRegexChars(term);
|
||||
|
||||
var results = translations
|
||||
const results = translations
|
||||
// remove all lines without a match
|
||||
.replace(new RegExp('^(?:(?!' + escaped + ').)*$', 'gmi'), '')
|
||||
// remove lines that only match the title
|
||||
@@ -60,9 +60,9 @@ define('admin/modules/search', ['mousetrap'], function (mousetrap) {
|
||||
};
|
||||
|
||||
function setupACPSearch(dict) {
|
||||
var dropdown = $('#acp-search .dropdown');
|
||||
var menu = $('#acp-search .dropdown-menu');
|
||||
var input = $('#acp-search input');
|
||||
const dropdown = $('#acp-search .dropdown');
|
||||
const menu = $('#acp-search .dropdown-menu');
|
||||
const input = $('#acp-search input');
|
||||
|
||||
if (!config.searchEnabled) {
|
||||
menu.addClass('search-disabled');
|
||||
@@ -73,11 +73,11 @@ define('admin/modules/search', ['mousetrap'], function (mousetrap) {
|
||||
});
|
||||
|
||||
$('#acp-search').parents('form').on('submit', function (ev) {
|
||||
var selected = menu.find('li.result > a.focus').attr('href');
|
||||
let selected = menu.find('li.result > a.focus').attr('href');
|
||||
if (!selected.length) {
|
||||
selected = menu.find('li.result > a').first().attr('href');
|
||||
}
|
||||
var href = selected || config.relative_path + '/search?in=titlesposts&term=' + escape(input.val());
|
||||
const href = selected || config.relative_path + '/search?in=titlesposts&term=' + escape(input.val());
|
||||
|
||||
ajaxify.go(href.replace(/^\//, ''));
|
||||
|
||||
@@ -96,7 +96,7 @@ define('admin/modules/search', ['mousetrap'], function (mousetrap) {
|
||||
});
|
||||
|
||||
mousetrap(input[0]).bind(['up', 'down'], function (ev, key) {
|
||||
var next;
|
||||
let next;
|
||||
if (key === 'up') {
|
||||
next = menu.find('li.result > a.focus').removeClass('focus').parent().prev('.result')
|
||||
.children();
|
||||
@@ -122,10 +122,10 @@ define('admin/modules/search', ['mousetrap'], function (mousetrap) {
|
||||
ev.preventDefault();
|
||||
});
|
||||
|
||||
var prevValue;
|
||||
let prevValue;
|
||||
|
||||
input.on('keyup focus', function () {
|
||||
var value = input.val().toLowerCase();
|
||||
const value = input.val().toLowerCase();
|
||||
|
||||
if (value === prevValue) {
|
||||
return;
|
||||
@@ -134,8 +134,8 @@ define('admin/modules/search', ['mousetrap'], function (mousetrap) {
|
||||
|
||||
menu.children('.result').remove();
|
||||
|
||||
var len = /\W/.test(value) ? 3 : value.length;
|
||||
var results;
|
||||
const len = /\W/.test(value) ? 3 : value.length;
|
||||
let results;
|
||||
|
||||
menu.toggleClass('state-start-typing', len === 0);
|
||||
menu.toggleClass('state-keep-typing', len > 0 && len < 3);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
define('admin/modules/selectable', [
|
||||
'jquery-ui/widgets/selectable',
|
||||
], function () {
|
||||
var selectable = {};
|
||||
const selectable = {};
|
||||
|
||||
selectable.enable = function (containerEl, targets) {
|
||||
$(containerEl).selectable({
|
||||
|
||||
@@ -2,21 +2,21 @@
|
||||
|
||||
|
||||
define('admin/settings', ['uploader', 'mousetrap', 'hooks'], function (uploader, mousetrap, hooks) {
|
||||
var Settings = {};
|
||||
const Settings = {};
|
||||
|
||||
Settings.populateTOC = function () {
|
||||
var headers = $('.settings-header');
|
||||
const headers = $('.settings-header');
|
||||
|
||||
if (headers.length > 1) {
|
||||
headers.each(function () {
|
||||
var header = $(this).text();
|
||||
var anchor = header.toLowerCase().replace(/ /g, '-').trim();
|
||||
const header = $(this).text();
|
||||
const anchor = header.toLowerCase().replace(/ /g, '-').trim();
|
||||
|
||||
$(this).prepend('<a name="' + anchor + '"></a>');
|
||||
$('.section-content ul').append('<li><a href="#' + anchor + '">' + header + '</a></li>');
|
||||
});
|
||||
|
||||
var scrollTo = $('a[name="' + window.location.hash.replace('#', '') + '"]');
|
||||
const scrollTo = $('a[name="' + window.location.hash.replace('#', '') + '"]');
|
||||
if (scrollTo.length) {
|
||||
$('html, body').animate({
|
||||
scrollTop: (scrollTo.offset().top) + 'px',
|
||||
@@ -29,28 +29,28 @@ define('admin/settings', ['uploader', 'mousetrap', 'hooks'], function (uploader,
|
||||
|
||||
Settings.prepare = function (callback) {
|
||||
// Populate the fields on the page from the config
|
||||
var fields = $('#content [data-field]');
|
||||
var numFields = fields.length;
|
||||
var saveBtn = $('#save');
|
||||
var revertBtn = $('#revert');
|
||||
var x;
|
||||
var key;
|
||||
var inputType;
|
||||
var field;
|
||||
const fields = $('#content [data-field]');
|
||||
const numFields = fields.length;
|
||||
const saveBtn = $('#save');
|
||||
const revertBtn = $('#revert');
|
||||
let x;
|
||||
let key;
|
||||
let inputType;
|
||||
let field;
|
||||
|
||||
// Handle unsaved changes
|
||||
fields.on('change', function () {
|
||||
app.flags = app.flags || {};
|
||||
app.flags._unsaved = true;
|
||||
});
|
||||
var defaultInputs = ['text', 'hidden', 'password', 'textarea', 'number'];
|
||||
const defaultInputs = ['text', 'hidden', 'password', 'textarea', 'number'];
|
||||
for (x = 0; x < numFields; x += 1) {
|
||||
field = fields.eq(x);
|
||||
key = field.attr('data-field');
|
||||
inputType = field.attr('type');
|
||||
if (app.config.hasOwnProperty(key)) {
|
||||
if (field.is('input') && inputType === 'checkbox') {
|
||||
var checked = parseInt(app.config[key], 10) === 1;
|
||||
const checked = parseInt(app.config[key], 10) === 1;
|
||||
field.prop('checked', checked);
|
||||
field.parents('.mdl-switch').toggleClass('is-checked', checked);
|
||||
} else if (field.is('textarea') || field.is('select') || (field.is('input') && defaultInputs.indexOf(inputType) !== -1)) {
|
||||
@@ -117,7 +117,7 @@ define('admin/settings', ['uploader', 'mousetrap', 'hooks'], function (uploader,
|
||||
|
||||
function handleUploads() {
|
||||
$('#content input[data-action="upload"]').each(function () {
|
||||
var uploadBtn = $(this);
|
||||
const uploadBtn = $(this);
|
||||
uploadBtn.on('click', function () {
|
||||
uploader.show({
|
||||
title: uploadBtn.attr('data-title'),
|
||||
@@ -146,13 +146,13 @@ define('admin/settings', ['uploader', 'mousetrap', 'hooks'], function (uploader,
|
||||
};
|
||||
|
||||
function saveFields(fields, callback) {
|
||||
var data = {};
|
||||
const data = {};
|
||||
|
||||
fields.each(function () {
|
||||
var field = $(this);
|
||||
var key = field.attr('data-field');
|
||||
var value;
|
||||
var inputType;
|
||||
const field = $(this);
|
||||
const key = field.attr('data-field');
|
||||
let value;
|
||||
let inputType;
|
||||
|
||||
if (field.is('input')) {
|
||||
inputType = field.attr('type');
|
||||
@@ -181,7 +181,7 @@ define('admin/settings', ['uploader', 'mousetrap', 'hooks'], function (uploader,
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
for (var field in data) {
|
||||
for (const field in data) {
|
||||
if (data.hasOwnProperty(field)) {
|
||||
app.config[field] = data[field];
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
define('admin/settings/api', ['settings'], function (settings) {
|
||||
var ACP = {};
|
||||
const ACP = {};
|
||||
|
||||
ACP.init = function () {
|
||||
settings.load('core.api', $('.core-api-settings'));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
define('admin/settings/cookies', function () {
|
||||
var Module = {};
|
||||
const Module = {};
|
||||
|
||||
Module.init = function () {
|
||||
$('#delete-all-sessions').on('click', function () {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
|
||||
define('admin/settings/email', ['ace/ace', 'admin/settings'], function (ace) {
|
||||
var module = {};
|
||||
var emailEditor;
|
||||
const module = {};
|
||||
let emailEditor;
|
||||
|
||||
module.init = function () {
|
||||
configureEmailTester();
|
||||
@@ -40,14 +40,14 @@ define('admin/settings/email', ['ace/ace', 'admin/settings'], function (ace) {
|
||||
emailEditor.getSession().setMode('ace/mode/html');
|
||||
|
||||
emailEditor.on('change', function () {
|
||||
var emailPath = $('#email-editor-selector').val();
|
||||
var original;
|
||||
const emailPath = $('#email-editor-selector').val();
|
||||
let original;
|
||||
ajaxify.data.emails.forEach(function (email) {
|
||||
if (email.path === emailPath) {
|
||||
original = email.original;
|
||||
}
|
||||
});
|
||||
var newEmail = emailEditor.getValue();
|
||||
const newEmail = emailEditor.getValue();
|
||||
$('#email-editor-holder').val(newEmail !== original ? newEmail : '');
|
||||
});
|
||||
|
||||
@@ -75,7 +75,7 @@ define('admin/settings/email', ['ace/ace', 'admin/settings'], function (ace) {
|
||||
}
|
||||
|
||||
function handleDigestHourChange() {
|
||||
var hour = parseInt($('#digestHour').val(), 10);
|
||||
let hour = parseInt($('#digestHour').val(), 10);
|
||||
|
||||
if (isNaN(hour)) {
|
||||
hour = 17;
|
||||
@@ -88,8 +88,8 @@ define('admin/settings/email', ['ace/ace', 'admin/settings'], function (ace) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
var date = new Date(now.timestamp);
|
||||
var offset = (new Date().getTimezoneOffset() - now.offset) / 60;
|
||||
const date = new Date(now.timestamp);
|
||||
const offset = (new Date().getTimezoneOffset() - now.offset) / 60;
|
||||
date.setHours(date.getHours() + offset);
|
||||
|
||||
$('#serverTime').text(date.toLocaleTimeString());
|
||||
@@ -106,7 +106,7 @@ define('admin/settings/email', ['ace/ace', 'admin/settings'], function (ace) {
|
||||
}
|
||||
|
||||
function handleSmtpServiceChange() {
|
||||
var isCustom = $('[id="email:smtpTransport:service"]').val() === 'nodebb-custom-smtp';
|
||||
const isCustom = $('[id="email:smtpTransport:service"]').val() === 'nodebb-custom-smtp';
|
||||
$('[id="email:smtpTransport:custom-service"]')[isCustom ? 'slideDown' : 'slideUp'](isCustom);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('admin/settings/general', ['admin/settings'], function () {
|
||||
var Module = {};
|
||||
const Module = {};
|
||||
|
||||
Module.init = function () {
|
||||
$('button[data-action="removeLogo"]').on('click', function () {
|
||||
|
||||
@@ -10,7 +10,7 @@ define('admin/settings/homepage', ['admin/settings'], function () {
|
||||
}
|
||||
}
|
||||
|
||||
var Homepage = {};
|
||||
const Homepage = {};
|
||||
|
||||
Homepage.init = function () {
|
||||
$('[data-field="homePageRoute"]').on('change', toggleCustomRoute);
|
||||
|
||||
@@ -9,8 +9,8 @@ define('admin/settings/navigation', [
|
||||
'jquery-ui/widgets/droppable',
|
||||
'jquery-ui/widgets/sortable',
|
||||
], function (translator, iconSelect, Benchpress) {
|
||||
var navigation = {};
|
||||
var available;
|
||||
const navigation = {};
|
||||
let available;
|
||||
|
||||
navigation.init = function () {
|
||||
available = ajaxify.data.available;
|
||||
@@ -27,10 +27,10 @@ define('admin/settings/navigation', [
|
||||
});
|
||||
|
||||
$('#enabled').on('click', '.iconPicker', function () {
|
||||
var iconEl = $(this).find('i');
|
||||
const iconEl = $(this).find('i');
|
||||
iconSelect.init(iconEl, function (el) {
|
||||
var newIconClass = el.attr('value');
|
||||
var index = iconEl.parents('[data-index]').attr('data-index');
|
||||
const newIconClass = el.attr('value');
|
||||
const index = iconEl.parents('[data-index]').attr('data-index');
|
||||
$('#active-navigation [data-index="' + index + '"] i').attr('class', 'fa fa-fw ' + newIconClass);
|
||||
iconEl.siblings('[name="iconClass"]').val(newIconClass);
|
||||
iconEl.siblings('.change-icon-link').toggleClass('hidden', !!newIconClass);
|
||||
@@ -47,11 +47,11 @@ define('admin/settings/navigation', [
|
||||
};
|
||||
|
||||
function onSelect() {
|
||||
var clickedIndex = $(this).attr('data-index');
|
||||
const clickedIndex = $(this).attr('data-index');
|
||||
$('#active-navigation li').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
|
||||
var detailsForm = $('#enabled').children('[data-index="' + clickedIndex + '"]');
|
||||
const detailsForm = $('#enabled').children('[data-index="' + clickedIndex + '"]');
|
||||
$('#enabled li').addClass('hidden');
|
||||
|
||||
if (detailsForm.length) {
|
||||
@@ -61,9 +61,9 @@ define('admin/settings/navigation', [
|
||||
}
|
||||
|
||||
function drop(ev, ui) {
|
||||
var id = ui.helper.attr('data-id');
|
||||
var el = $('#active-navigation [data-id="' + id + '"]');
|
||||
var data = id === 'custom' ? { iconClass: 'fa-navicon', groups: available[0].groups } : available[id];
|
||||
const id = ui.helper.attr('data-id');
|
||||
const el = $('#active-navigation [data-id="' + id + '"]');
|
||||
const data = id === 'custom' ? { iconClass: 'fa-navicon', groups: available[0].groups } : available[id];
|
||||
|
||||
data.enabled = false;
|
||||
data.index = (parseInt($('#enabled').children().last().attr('data-index'), 10) || 0) + 1;
|
||||
@@ -87,18 +87,18 @@ define('admin/settings/navigation', [
|
||||
}
|
||||
|
||||
function save() {
|
||||
var nav = [];
|
||||
const nav = [];
|
||||
|
||||
var indices = [];
|
||||
const indices = [];
|
||||
$('#active-navigation li').each(function () {
|
||||
indices.push($(this).attr('data-index'));
|
||||
});
|
||||
|
||||
indices.forEach(function (index) {
|
||||
var el = $('#enabled').children('[data-index="' + index + '"]');
|
||||
var form = el.find('form').serializeArray();
|
||||
var data = {};
|
||||
var properties = {};
|
||||
const el = $('#enabled').children('[data-index="' + index + '"]');
|
||||
const form = el.find('form').serializeArray();
|
||||
const data = {};
|
||||
const properties = {};
|
||||
|
||||
form.forEach(function (input) {
|
||||
if (input.name.slice(0, 9) === 'property:' && input.value === 'on') {
|
||||
@@ -117,7 +117,7 @@ define('admin/settings/navigation', [
|
||||
|
||||
data.properties = {};
|
||||
|
||||
for (var prop in properties) {
|
||||
for (const prop in properties) {
|
||||
if (properties.hasOwnProperty(prop)) {
|
||||
data.properties[prop] = properties[prop];
|
||||
}
|
||||
@@ -136,15 +136,15 @@ define('admin/settings/navigation', [
|
||||
}
|
||||
|
||||
function remove() {
|
||||
var index = $(this).parents('[data-index]').attr('data-index');
|
||||
const index = $(this).parents('[data-index]').attr('data-index');
|
||||
$('#active-navigation [data-index="' + index + '"]').remove();
|
||||
$('#enabled [data-index="' + index + '"]').remove();
|
||||
return false;
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
var btn = $(this);
|
||||
var disabled = btn.hasClass('btn-success');
|
||||
const btn = $(this);
|
||||
const disabled = btn.hasClass('btn-success');
|
||||
translator.translate(disabled ? '[[admin/settings/navigation:btn.disable]]' : '[[admin/settings/navigation:btn.enable]]', function (html) {
|
||||
btn.toggleClass('btn-warning').toggleClass('btn-success').html(html);
|
||||
btn.parents('li').find('[name="enabled"]').val(disabled ? 'on' : '');
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
define('admin/settings/notifications', [
|
||||
'autocomplete',
|
||||
], function (autocomplete) {
|
||||
var Notifications = {};
|
||||
const Notifications = {};
|
||||
|
||||
Notifications.init = function () {
|
||||
var searchInput = $('[data-field="welcomeUid"]');
|
||||
const searchInput = $('[data-field="welcomeUid"]');
|
||||
autocomplete.user(searchInput, function (event, selected) {
|
||||
setTimeout(function () {
|
||||
searchInput.val(selected.item.user.uid);
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
|
||||
define('admin/settings/social', [], function () {
|
||||
var social = {};
|
||||
const social = {};
|
||||
|
||||
social.init = function () {
|
||||
$('#save').on('click', function () {
|
||||
var networks = [];
|
||||
const networks = [];
|
||||
$('#postSharingNetworks input[type="checkbox"]').each(function () {
|
||||
if ($(this).prop('checked')) {
|
||||
networks.push($(this).attr('id'));
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
ajaxify = window.ajaxify || {};
|
||||
|
||||
(function () {
|
||||
var apiXHR = null;
|
||||
var ajaxifyTimer;
|
||||
let apiXHR = null;
|
||||
let ajaxifyTimer;
|
||||
|
||||
var retry = true;
|
||||
var previousBodyClass = '';
|
||||
let retry = true;
|
||||
let previousBodyClass = '';
|
||||
|
||||
ajaxify.count = 0;
|
||||
ajaxify.currentPage = null;
|
||||
|
||||
var hooks;
|
||||
let hooks;
|
||||
require(['hooks'], function (_hooks) {
|
||||
hooks = _hooks;
|
||||
});
|
||||
@@ -89,7 +89,7 @@ ajaxify = window.ajaxify || {};
|
||||
|
||||
// this function is called just once from footer on page load
|
||||
ajaxify.coldLoad = function () {
|
||||
var url = ajaxify.start(window.location.pathname.slice(1) + window.location.search + window.location.hash);
|
||||
const url = ajaxify.start(window.location.pathname.slice(1) + window.location.search + window.location.hash);
|
||||
ajaxify.updateHistory(url, true);
|
||||
ajaxify.end(url, ajaxify.data.template.name);
|
||||
hooks.fire('action:ajaxify.coldLoad');
|
||||
@@ -101,8 +101,8 @@ ajaxify = window.ajaxify || {};
|
||||
|
||||
ajaxify.handleRedirects = function (url) {
|
||||
url = ajaxify.removeRelativePath(url.replace(/^\/|\/$/g, '')).toLowerCase();
|
||||
var isClientToAdmin = url.startsWith('admin') && window.location.pathname.indexOf(config.relative_path + '/admin') !== 0;
|
||||
var isAdminToClient = !url.startsWith('admin') && window.location.pathname.indexOf(config.relative_path + '/admin') === 0;
|
||||
const isClientToAdmin = url.startsWith('admin') && window.location.pathname.indexOf(config.relative_path + '/admin') !== 0;
|
||||
const isAdminToClient = !url.startsWith('admin') && window.location.pathname.indexOf(config.relative_path + '/admin') === 0;
|
||||
|
||||
if (isClientToAdmin || isAdminToClient) {
|
||||
window.open(config.relative_path + '/' + url, '_top');
|
||||
@@ -114,7 +114,7 @@ ajaxify = window.ajaxify || {};
|
||||
ajaxify.start = function (url) {
|
||||
url = ajaxify.removeRelativePath(url.replace(/^\/|\/$/g, ''));
|
||||
|
||||
var payload = {
|
||||
const payload = {
|
||||
url: url,
|
||||
};
|
||||
|
||||
@@ -135,11 +135,11 @@ ajaxify = window.ajaxify || {};
|
||||
};
|
||||
|
||||
function onAjaxError(err, url, callback, quiet) {
|
||||
var data = err.data;
|
||||
var textStatus = err.textStatus;
|
||||
const data = err.data;
|
||||
const textStatus = err.textStatus;
|
||||
|
||||
if (data) {
|
||||
var status = parseInt(data.status, 10);
|
||||
let status = parseInt(data.status, 10);
|
||||
if (status === 403 || status === 404 || status === 500 || status === 502 || status === 503) {
|
||||
if (status === 502 && retry) {
|
||||
retry = false;
|
||||
@@ -214,7 +214,7 @@ ajaxify = window.ajaxify || {};
|
||||
|
||||
// Allow translation strings in title on ajaxify (#5927)
|
||||
title = translator.unescape(title);
|
||||
var data = { title: title };
|
||||
const data = { title: title };
|
||||
hooks.fire('action:ajaxify.updateTitle', data);
|
||||
translator.translate(data.title, function (translated) {
|
||||
window.document.title = $('<div></div>').html(translated).text();
|
||||
@@ -223,16 +223,16 @@ ajaxify = window.ajaxify || {};
|
||||
}
|
||||
|
||||
function updateTags() {
|
||||
var metaWhitelist = ['title', 'description', /og:.+/, /article:.+/, 'robots'].map(function (val) {
|
||||
const metaWhitelist = ['title', 'description', /og:.+/, /article:.+/, 'robots'].map(function (val) {
|
||||
return new RegExp(val);
|
||||
});
|
||||
var linkWhitelist = ['canonical', 'alternate', 'up'];
|
||||
const linkWhitelist = ['canonical', 'alternate', 'up'];
|
||||
|
||||
// Delete the old meta tags
|
||||
Array.prototype.slice
|
||||
.call(document.querySelectorAll('head meta'))
|
||||
.filter(function (el) {
|
||||
var name = el.getAttribute('property') || el.getAttribute('name');
|
||||
const name = el.getAttribute('property') || el.getAttribute('name');
|
||||
return metaWhitelist.some(function (exp) {
|
||||
return !!exp.test(name);
|
||||
});
|
||||
@@ -244,7 +244,7 @@ ajaxify = window.ajaxify || {};
|
||||
// Add new meta tags
|
||||
ajaxify.data._header.tags.meta
|
||||
.filter(function (tagObj) {
|
||||
var name = tagObj.name || tagObj.property;
|
||||
const name = tagObj.name || tagObj.property;
|
||||
return metaWhitelist.some(function (exp) {
|
||||
return !!exp.test(name);
|
||||
});
|
||||
@@ -252,7 +252,7 @@ ajaxify = window.ajaxify || {};
|
||||
if (tagObj.content) {
|
||||
tagObj.content = await translator.translate(tagObj.content);
|
||||
}
|
||||
var metaEl = document.createElement('meta');
|
||||
const metaEl = document.createElement('meta');
|
||||
Object.keys(tagObj).forEach(function (prop) {
|
||||
metaEl.setAttribute(prop, tagObj[prop]);
|
||||
});
|
||||
@@ -264,7 +264,7 @@ ajaxify = window.ajaxify || {};
|
||||
Array.prototype.slice
|
||||
.call(document.querySelectorAll('head link'))
|
||||
.filter(function (el) {
|
||||
var name = el.getAttribute('rel');
|
||||
const name = el.getAttribute('rel');
|
||||
return linkWhitelist.some(function (item) {
|
||||
return item === name;
|
||||
});
|
||||
@@ -281,7 +281,7 @@ ajaxify = window.ajaxify || {};
|
||||
});
|
||||
})
|
||||
.forEach(function (tagObj) {
|
||||
var linkEl = document.createElement('link');
|
||||
const linkEl = document.createElement('link');
|
||||
Object.keys(tagObj).forEach(function (prop) {
|
||||
linkEl.setAttribute(prop, tagObj[prop]);
|
||||
});
|
||||
@@ -305,7 +305,7 @@ ajaxify = window.ajaxify || {};
|
||||
};
|
||||
|
||||
ajaxify.parseData = function () {
|
||||
var dataEl = $('#ajaxify-data');
|
||||
const dataEl = $('#ajaxify-data');
|
||||
if (dataEl.length) {
|
||||
ajaxify.data = JSON.parse(dataEl.text());
|
||||
dataEl.remove();
|
||||
@@ -324,7 +324,7 @@ ajaxify = window.ajaxify || {};
|
||||
};
|
||||
|
||||
ajaxify.loadScript = function (tpl_url, callback) {
|
||||
var location = !app.inAdmin ? 'forum/' : '';
|
||||
let location = !app.inAdmin ? 'forum/' : '';
|
||||
|
||||
if (tpl_url.startsWith('admin')) {
|
||||
location = '';
|
||||
@@ -338,7 +338,7 @@ ajaxify = window.ajaxify || {};
|
||||
hooks.fire('action:script.load', data);
|
||||
hooks.fire('filter:script.load', data).then((data) => {
|
||||
// Require and parse modules
|
||||
var outstanding = data.scripts.length;
|
||||
let outstanding = data.scripts.length;
|
||||
|
||||
data.scripts.map(function (script) {
|
||||
if (typeof script === 'function') {
|
||||
@@ -440,7 +440,7 @@ ajaxify = window.ajaxify || {};
|
||||
}());
|
||||
|
||||
$(document).ready(function () {
|
||||
var hooks;
|
||||
let hooks;
|
||||
require(['hooks'], function (_hooks) {
|
||||
hooks = _hooks;
|
||||
});
|
||||
@@ -466,26 +466,26 @@ $(document).ready(function () {
|
||||
// eslint-disable-next-line no-script-url
|
||||
return href === undefined || href === '' || href === 'javascript:;';
|
||||
}
|
||||
var location = document.location || window.location;
|
||||
var rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
|
||||
var contentEl = document.getElementById('content');
|
||||
const location = document.location || window.location;
|
||||
const rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
|
||||
const contentEl = document.getElementById('content');
|
||||
|
||||
// Enhancing all anchors to ajaxify...
|
||||
$(document.body).on('click', 'a', function (e) {
|
||||
var _self = this;
|
||||
const _self = this;
|
||||
if (this.target !== '' || (this.protocol !== 'http:' && this.protocol !== 'https:')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $this = $(this);
|
||||
var href = $this.attr('href');
|
||||
var internalLink = utils.isInternalURI(this, window.location, config.relative_path);
|
||||
const $this = $(this);
|
||||
const href = $this.attr('href');
|
||||
const internalLink = utils.isInternalURI(this, window.location, config.relative_path);
|
||||
|
||||
const rootAndPath = new RegExp(`^${rootUrl}${config.relative_path}/?`);
|
||||
var process = function () {
|
||||
const process = function () {
|
||||
if (!e.ctrlKey && !e.shiftKey && !e.metaKey && e.which === 1) {
|
||||
if (internalLink) {
|
||||
var pathname = this.href.replace(rootAndPath, '');
|
||||
const pathname = this.href.replace(rootAndPath, '');
|
||||
|
||||
// Special handling for urls with hashes
|
||||
if (window.location.pathname === this.pathname && this.hash.length) {
|
||||
@@ -495,13 +495,13 @@ $(document).ready(function () {
|
||||
}
|
||||
} else if (window.location.pathname !== config.relative_path + '/outgoing') {
|
||||
if (config.openOutgoingLinksInNewTab && $.contains(contentEl, this)) {
|
||||
var externalTab = window.open();
|
||||
const externalTab = window.open();
|
||||
externalTab.opener = null;
|
||||
externalTab.location = this.href;
|
||||
e.preventDefault();
|
||||
} else if (config.useOutgoingLinksPage) {
|
||||
var safeUrls = config.outgoingLinksWhitelist.trim().split(/[\s,]+/g).filter(Boolean);
|
||||
var href = this.href;
|
||||
const safeUrls = config.outgoingLinksWhitelist.trim().split(/[\s,]+/g).filter(Boolean);
|
||||
const href = this.href;
|
||||
if (!safeUrls.length || !safeUrls.some(function (url) { return href.indexOf(url) !== -1; })) {
|
||||
ajaxify.go('outgoing?url=' + encodeURIComponent(href));
|
||||
e.preventDefault();
|
||||
|
||||
@@ -10,15 +10,15 @@ app.flags = {};
|
||||
app.cacheBuster = null;
|
||||
|
||||
(function () {
|
||||
var appLoaded = false;
|
||||
var params = utils.params();
|
||||
var showWelcomeMessage = !!params.loggedin;
|
||||
var registerMessage = params.register;
|
||||
var isTouchDevice = utils.isTouchDevice();
|
||||
let appLoaded = false;
|
||||
const params = utils.params();
|
||||
let showWelcomeMessage = !!params.loggedin;
|
||||
let registerMessage = params.register;
|
||||
const isTouchDevice = utils.isTouchDevice();
|
||||
|
||||
app.cacheBuster = config['cache-buster'];
|
||||
|
||||
var hooks;
|
||||
let hooks;
|
||||
require(['hooks'], function (_hooks) {
|
||||
hooks = _hooks;
|
||||
});
|
||||
@@ -46,10 +46,10 @@ app.cacheBuster = null;
|
||||
* e.g. New Topic/Reply, post tools
|
||||
*/
|
||||
if (document.body) {
|
||||
var earlyQueue = []; // once we can ES6, use Set instead
|
||||
var earlyClick = function (ev) {
|
||||
var btnEl = ev.target.closest('button');
|
||||
var anchorEl = ev.target.closest('a');
|
||||
let earlyQueue = []; // once we can ES6, use Set instead
|
||||
const earlyClick = function (ev) {
|
||||
let btnEl = ev.target.closest('button');
|
||||
const anchorEl = ev.target.closest('a');
|
||||
if (!btnEl && anchorEl && (anchorEl.getAttribute('data-ajaxify') === 'false' || anchorEl.href === '#')) {
|
||||
btnEl = anchorEl;
|
||||
}
|
||||
@@ -250,7 +250,7 @@ app.cacheBuster = null;
|
||||
app.enterRoom = function (room, callback) {
|
||||
callback = callback || function () { };
|
||||
if (socket && app.user.uid && app.currentRoom !== room) {
|
||||
var previousRoom = app.currentRoom;
|
||||
const previousRoom = app.currentRoom;
|
||||
app.currentRoom = room;
|
||||
socket.emit('meta.rooms.enter', {
|
||||
enter: room,
|
||||
@@ -269,7 +269,7 @@ app.cacheBuster = null;
|
||||
if (!socket || config.maintenanceMode) {
|
||||
return;
|
||||
}
|
||||
var previousRoom = app.currentRoom;
|
||||
const previousRoom = app.currentRoom;
|
||||
app.currentRoom = '';
|
||||
socket.emit('meta.rooms.leaveCurrent', function (err) {
|
||||
if (err) {
|
||||
@@ -329,7 +329,7 @@ app.cacheBuster = null;
|
||||
};
|
||||
|
||||
app.showMessages = function () {
|
||||
var messages = {
|
||||
const messages = {
|
||||
login: {
|
||||
format: 'alert',
|
||||
title: '[[global:welcome_back]] ' + app.user.username + '!',
|
||||
@@ -456,7 +456,7 @@ app.cacheBuster = null;
|
||||
};
|
||||
|
||||
function createHeaderTooltips() {
|
||||
var env = utils.findBootstrapEnvironment();
|
||||
const env = utils.findBootstrapEnvironment();
|
||||
if (env === 'xs' || env === 'sm' || isTouchDevice) {
|
||||
return;
|
||||
}
|
||||
@@ -488,17 +488,17 @@ app.cacheBuster = null;
|
||||
return;
|
||||
}
|
||||
/* eslint-disable-next-line */
|
||||
var searchOptions = Object.assign({ in: config.searchDefaultInQuick || 'titles' }, options.searchOptions);
|
||||
var quickSearchResults = options.searchElements.resultEl;
|
||||
var inputEl = options.searchElements.inputEl;
|
||||
var oldValue = inputEl.val();
|
||||
var filterCategoryEl = quickSearchResults.find('.filter-category');
|
||||
const searchOptions = Object.assign({ in: config.searchDefaultInQuick || 'titles' }, options.searchOptions);
|
||||
const quickSearchResults = options.searchElements.resultEl;
|
||||
const inputEl = options.searchElements.inputEl;
|
||||
let oldValue = inputEl.val();
|
||||
const filterCategoryEl = quickSearchResults.find('.filter-category');
|
||||
|
||||
function updateCategoryFilterName() {
|
||||
if (ajaxify.data.template.category) {
|
||||
require(['translator'], function (translator) {
|
||||
translator.translate('[[search:search-in-category, ' + ajaxify.data.name + ']]', function (translated) {
|
||||
var name = $('<div></div>').html(translated).text();
|
||||
const name = $('<div></div>').html(translated).text();
|
||||
filterCategoryEl.find('.name').text(name);
|
||||
});
|
||||
});
|
||||
@@ -530,8 +530,8 @@ app.cacheBuster = null;
|
||||
return quickSearchResults.addClass('hidden').find('.quick-search-results-container').html('');
|
||||
}
|
||||
data.posts.forEach(function (p) {
|
||||
var text = $('<div>' + p.content + '</div>').text();
|
||||
var start = Math.max(0, text.toLowerCase().indexOf(inputEl.val().toLowerCase()) - 40);
|
||||
const text = $('<div>' + p.content + '</div>').text();
|
||||
const start = Math.max(0, text.toLowerCase().indexOf(inputEl.val().toLowerCase()) - 40);
|
||||
p.snippet = utils.escapeHTML((start > 0 ? '...' : '') +
|
||||
text.slice(start, start + 80) +
|
||||
(text.length - start > 80 ? '...' : ''));
|
||||
@@ -543,7 +543,7 @@ app.cacheBuster = null;
|
||||
quickSearchResults.toggleClass('hidden', !html.length || !inputEl.is(':focus'))
|
||||
.find('.quick-search-results-container')
|
||||
.html(html.length ? html : '');
|
||||
var highlightEls = quickSearchResults.find(
|
||||
const highlightEls = quickSearchResults.find(
|
||||
'.quick-search-results .quick-search-title, .quick-search-results .snippet'
|
||||
);
|
||||
search.highlightMatches(options.searchOptions.term, highlightEls);
|
||||
@@ -577,7 +577,7 @@ app.cacheBuster = null;
|
||||
doSearch();
|
||||
}, 250));
|
||||
|
||||
var mousedownOnResults = false;
|
||||
let mousedownOnResults = false;
|
||||
quickSearchResults.on('mousedown', function () {
|
||||
$(window).one('mouseup', function () {
|
||||
quickSearchResults.addClass('hidden');
|
||||
@@ -607,10 +607,10 @@ app.cacheBuster = null;
|
||||
|
||||
app.handleSearch = function (searchOptions) {
|
||||
searchOptions = searchOptions || { in: config.searchDefaultInQuick || 'titles' };
|
||||
var searchButton = $('#search-button');
|
||||
var searchFields = $('#search-fields');
|
||||
var searchInput = $('#search-fields input');
|
||||
var quickSearchContainer = $('#quick-search-container');
|
||||
const searchButton = $('#search-button');
|
||||
const searchFields = $('#search-fields');
|
||||
const searchInput = $('#search-fields input');
|
||||
const quickSearchContainer = $('#quick-search-container');
|
||||
|
||||
$('#search-form .advanced-search-link').off('mousedown').on('mousedown', function () {
|
||||
ajaxify.go('/search');
|
||||
@@ -622,7 +622,7 @@ app.cacheBuster = null;
|
||||
searchInput.off('blur').on('blur', dismissSearch);
|
||||
searchInput.off('focus');
|
||||
|
||||
var searchElements = {
|
||||
const searchElements = {
|
||||
inputEl: searchInput,
|
||||
resultEl: quickSearchContainer,
|
||||
};
|
||||
@@ -657,9 +657,9 @@ app.cacheBuster = null;
|
||||
});
|
||||
|
||||
$('#search-form').off('submit').on('submit', function () {
|
||||
var input = $(this).find('input');
|
||||
const input = $(this).find('input');
|
||||
require(['search'], function (search) {
|
||||
var data = search.getSearchPreferences();
|
||||
const data = search.getSearchPreferences();
|
||||
data.term = input.val();
|
||||
hooks.fire('action:search.submit', {
|
||||
searchOptions: data,
|
||||
@@ -681,7 +681,7 @@ app.cacheBuster = null;
|
||||
|
||||
function handleStatusChange() {
|
||||
$('[component="header/usercontrol"] [data-status]').off('click').on('click', function (e) {
|
||||
var status = $(this).attr('data-status');
|
||||
const status = $(this).attr('data-status');
|
||||
socket.emit('user.setStatus', status, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
@@ -758,7 +758,7 @@ app.cacheBuster = null;
|
||||
if (!showModal || !app.user.uid || parseInt(storage.getItem('email-confirm-dismiss'), 10) === 1) {
|
||||
return;
|
||||
}
|
||||
var msg = {
|
||||
const msg = {
|
||||
alert_id: 'email_confirm',
|
||||
type: 'warning',
|
||||
timeout: 0,
|
||||
@@ -837,8 +837,8 @@ app.cacheBuster = null;
|
||||
$(document.body).append(html);
|
||||
$(document.body).addClass('cookie-consent-open');
|
||||
|
||||
var warningEl = $('.cookie-consent');
|
||||
var dismissEl = warningEl.find('button');
|
||||
const warningEl = $('.cookie-consent');
|
||||
const dismissEl = warningEl.find('button');
|
||||
dismissEl.on('click', function () {
|
||||
// Save consent cookie and remove warning element
|
||||
storage.setItem('cookieconsent', '1');
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('forum/account/best', ['forum/account/header', 'forum/account/posts'], function (header, posts) {
|
||||
var Best = {};
|
||||
const Best = {};
|
||||
|
||||
Best.init = function () {
|
||||
header.init();
|
||||
|
||||
@@ -5,13 +5,13 @@ define('forum/account/blocks', [
|
||||
'api',
|
||||
'hooks',
|
||||
], function (header, api, hooks) {
|
||||
var Blocks = {};
|
||||
const Blocks = {};
|
||||
|
||||
Blocks.init = function () {
|
||||
header.init();
|
||||
|
||||
$('#user-search').on('keyup', function () {
|
||||
var username = this.value;
|
||||
const username = this.value;
|
||||
|
||||
api.get('/api/users', {
|
||||
query: username,
|
||||
@@ -36,7 +36,7 @@ define('forum/account/blocks', [
|
||||
});
|
||||
|
||||
$('.block-edit').on('click', '[data-action="toggle"]', function () {
|
||||
var uid = parseInt(this.getAttribute('data-uid'), 10);
|
||||
const uid = parseInt(this.getAttribute('data-uid'), 10);
|
||||
socket.emit('user.toggleBlock', {
|
||||
blockeeUid: uid,
|
||||
blockerUid: ajaxify.data.uid,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('forum/account/bookmarks', ['forum/account/header', 'forum/account/posts'], function (header, posts) {
|
||||
var Bookmarks = {};
|
||||
const Bookmarks = {};
|
||||
|
||||
Bookmarks.init = function () {
|
||||
header.init();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('forum/account/categories', ['forum/account/header'], function (header) {
|
||||
var Categories = {};
|
||||
const Categories = {};
|
||||
|
||||
Categories.init = function () {
|
||||
header.init();
|
||||
@@ -12,8 +12,8 @@ define('forum/account/categories', ['forum/account/header'], function (header) {
|
||||
});
|
||||
|
||||
$('[component="category/watch/all"]').find('[component="category/watching"], [component="category/ignoring"], [component="category/notwatching"]').on('click', function () {
|
||||
var cids = [];
|
||||
var state = $(this).attr('data-state');
|
||||
const cids = [];
|
||||
const state = $(this).attr('data-state');
|
||||
$('[data-parent-cid="0"]').each(function (index, el) {
|
||||
cids.push($(el).attr('data-cid'));
|
||||
});
|
||||
@@ -28,10 +28,10 @@ define('forum/account/categories', ['forum/account/header'], function (header) {
|
||||
};
|
||||
|
||||
function handleIgnoreWatch(cid) {
|
||||
var category = $('[data-cid="' + cid + '"]');
|
||||
const category = $('[data-cid="' + cid + '"]');
|
||||
category.find('[component="category/watching"], [component="category/ignoring"], [component="category/notwatching"]').on('click', function () {
|
||||
var $this = $(this);
|
||||
var state = $this.attr('data-state');
|
||||
const $this = $(this);
|
||||
const state = $this.attr('data-state');
|
||||
|
||||
socket.emit('categories.setWatchState', { cid: cid, state: state, uid: ajaxify.data.uid }, function (err, modified_cids) {
|
||||
if (err) {
|
||||
@@ -46,7 +46,7 @@ define('forum/account/categories', ['forum/account/header'], function (header) {
|
||||
|
||||
function updateDropdowns(modified_cids, state) {
|
||||
modified_cids.forEach(function (cid) {
|
||||
var category = $('[data-cid="' + cid + '"]');
|
||||
const category = $('[data-cid="' + cid + '"]');
|
||||
category.find('[component="category/watching/menu"]').toggleClass('hidden', state !== 'watching');
|
||||
category.find('[component="category/watching/check"]').toggleClass('fa-check', state === 'watching');
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('forum/account/consent', ['forum/account/header'], function (header) {
|
||||
var Consent = {};
|
||||
const Consent = {};
|
||||
|
||||
Consent.init = function () {
|
||||
header.init();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('forum/account/downvoted', ['forum/account/header', 'forum/account/posts'], function (header, posts) {
|
||||
var Downvoted = {};
|
||||
const Downvoted = {};
|
||||
|
||||
Downvoted.init = function () {
|
||||
header.init();
|
||||
|
||||
@@ -8,7 +8,7 @@ define('forum/account/edit', [
|
||||
'hooks',
|
||||
'bootbox',
|
||||
], function (header, picture, translator, api, hooks, bootbox) {
|
||||
var AccountEdit = {};
|
||||
const AccountEdit = {};
|
||||
|
||||
AccountEdit.init = function () {
|
||||
header.init();
|
||||
@@ -64,12 +64,12 @@ define('forum/account/edit', [
|
||||
function handleAccountDelete() {
|
||||
$('#deleteAccountBtn').on('click', function () {
|
||||
translator.translate('[[user:delete_account_confirm]]', function (translated) {
|
||||
var modal = bootbox.confirm(translated + '<p><input type="password" class="form-control" id="confirm-password" /></p>', function (confirm) {
|
||||
const modal = bootbox.confirm(translated + '<p><input type="password" class="form-control" id="confirm-password" /></p>', function (confirm) {
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
|
||||
var confirmBtn = modal.find('.btn-primary');
|
||||
const confirmBtn = modal.find('.btn-primary');
|
||||
confirmBtn.html('<i class="fa fa-spinner fa-spin"></i>');
|
||||
confirmBtn.prop('disabled', true);
|
||||
|
||||
@@ -105,7 +105,7 @@ define('forum/account/edit', [
|
||||
|
||||
function handleEmailConfirm() {
|
||||
$('#confirm-email').on('click', function () {
|
||||
var btn = $(this).attr('disabled', true);
|
||||
const btn = $(this).attr('disabled', true);
|
||||
socket.emit('user.emailConfirm', {}, function (err) {
|
||||
btn.removeAttr('disabled');
|
||||
if (err) {
|
||||
@@ -121,7 +121,7 @@ define('forum/account/edit', [
|
||||
}
|
||||
|
||||
function updateSignature() {
|
||||
var el = $('#signature');
|
||||
const el = $('#signature');
|
||||
$('#signatureCharCountLeft').html(getCharsLeft(el, ajaxify.data.maximumSignatureLength));
|
||||
|
||||
el.on('keyup change', function () {
|
||||
@@ -130,7 +130,7 @@ define('forum/account/edit', [
|
||||
}
|
||||
|
||||
function updateAboutMe() {
|
||||
var el = $('#aboutme');
|
||||
const el = $('#aboutme');
|
||||
$('#aboutMeCharCountLeft').html(getCharsLeft(el, ajaxify.data.maximumAboutMeLength));
|
||||
|
||||
el.on('keyup change', function () {
|
||||
@@ -140,11 +140,11 @@ define('forum/account/edit', [
|
||||
|
||||
function handleGroupSort() {
|
||||
function move(direction) {
|
||||
var selected = $('#groupTitle').val();
|
||||
const selected = $('#groupTitle').val();
|
||||
if (!ajaxify.data.allowMultipleBadges || (Array.isArray(selected) && selected.length > 1)) {
|
||||
return;
|
||||
}
|
||||
var el = $('#groupTitle').find(':selected');
|
||||
const el = $('#groupTitle').find(':selected');
|
||||
if (el.length && el.val()) {
|
||||
if (direction > 0) {
|
||||
el.insertAfter(el.next());
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
define('forum/account/edit/email', ['forum/account/header', 'api'], function (header, api) {
|
||||
var AccountEditEmail = {};
|
||||
const AccountEditEmail = {};
|
||||
|
||||
AccountEditEmail.init = function () {
|
||||
header.init();
|
||||
|
||||
$('#submitBtn').on('click', function () {
|
||||
var curPasswordEl = $('#inputCurrentPassword');
|
||||
var userData = {
|
||||
const curPasswordEl = $('#inputCurrentPassword');
|
||||
const userData = {
|
||||
uid: $('#inputUID').val(),
|
||||
email: $('#inputNewEmail').val(),
|
||||
password: curPasswordEl.val(),
|
||||
@@ -23,7 +23,7 @@ define('forum/account/edit/email', ['forum/account/header', 'api'], function (he
|
||||
return app.alertError('[[user:email_same_as_password]]');
|
||||
}
|
||||
|
||||
var btn = $(this);
|
||||
const btn = $(this);
|
||||
btn.addClass('disabled').find('i').removeClass('hide');
|
||||
|
||||
api.put('/users/' + userData.uid, userData).then((res) => {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
define('forum/account/edit/password', [
|
||||
'forum/account/header', 'translator', 'zxcvbn', 'api',
|
||||
], function (header, translator, zxcvbn, api) {
|
||||
var AccountEditPassword = {};
|
||||
const AccountEditPassword = {};
|
||||
|
||||
AccountEditPassword.init = function () {
|
||||
header.init();
|
||||
@@ -12,16 +12,16 @@ define('forum/account/edit/password', [
|
||||
};
|
||||
|
||||
function handlePasswordChange() {
|
||||
var currentPassword = $('#inputCurrentPassword');
|
||||
var password_notify = $('#password-notify');
|
||||
var password_confirm_notify = $('#password-confirm-notify');
|
||||
var password = $('#inputNewPassword');
|
||||
var password_confirm = $('#inputNewPasswordAgain');
|
||||
var passwordvalid = false;
|
||||
var passwordsmatch = false;
|
||||
const currentPassword = $('#inputCurrentPassword');
|
||||
const password_notify = $('#password-notify');
|
||||
const password_confirm_notify = $('#password-confirm-notify');
|
||||
const password = $('#inputNewPassword');
|
||||
const password_confirm = $('#inputNewPasswordAgain');
|
||||
let passwordvalid = false;
|
||||
let passwordsmatch = false;
|
||||
|
||||
function onPasswordChanged() {
|
||||
var passwordStrength = zxcvbn(password.val());
|
||||
const passwordStrength = zxcvbn(password.val());
|
||||
passwordvalid = false;
|
||||
if (password.val().length < ajaxify.data.minimumPasswordLength) {
|
||||
showError(password_notify, '[[reset_password:password_too_short]]');
|
||||
@@ -65,7 +65,7 @@ define('forum/account/edit/password', [
|
||||
onPasswordChanged();
|
||||
onPasswordConfirmChanged();
|
||||
|
||||
var btn = $(this);
|
||||
const btn = $(this);
|
||||
if (passwordvalid && passwordsmatch) {
|
||||
btn.addClass('disabled').find('i').removeClass('hide');
|
||||
api.put('/users/' + ajaxify.data.theirid + '/password', {
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
define('forum/account/edit/username', [
|
||||
'forum/account/header', 'api', 'slugify',
|
||||
], function (header, api, slugify) {
|
||||
var AccountEditUsername = {};
|
||||
const AccountEditUsername = {};
|
||||
|
||||
AccountEditUsername.init = function () {
|
||||
header.init();
|
||||
|
||||
$('#submitBtn').on('click', function updateUsername() {
|
||||
var userData = {
|
||||
const userData = {
|
||||
uid: $('#inputUID').val(),
|
||||
username: $('#inputNewUsername').val(),
|
||||
password: $('#inputCurrentPassword').val(),
|
||||
@@ -23,11 +23,11 @@ define('forum/account/edit/username', [
|
||||
return app.alertError('[[user:username_same_as_password]]');
|
||||
}
|
||||
|
||||
var btn = $(this);
|
||||
const btn = $(this);
|
||||
btn.addClass('disabled').find('i').removeClass('hide');
|
||||
|
||||
api.put('/users/' + userData.uid, userData).then((response) => {
|
||||
var userslug = slugify(userData.username);
|
||||
const userslug = slugify(userData.username);
|
||||
if (userData.username && userslug && parseInt(userData.uid, 10) === parseInt(app.user.uid, 10)) {
|
||||
$('[component="header/profilelink"]').attr('href', config.relative_path + '/user/' + userslug);
|
||||
$('[component="header/profilelink/edit"]').attr('href', config.relative_path + '/user/' + userslug + '/edit');
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('forum/account/followers', ['forum/account/header'], function (header) {
|
||||
var Followers = {};
|
||||
const Followers = {};
|
||||
|
||||
Followers.init = function () {
|
||||
header.init();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('forum/account/following', ['forum/account/header'], function (header) {
|
||||
var Following = {};
|
||||
const Following = {};
|
||||
|
||||
Following.init = function () {
|
||||
header.init();
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
|
||||
define('forum/account/groups', ['forum/account/header'], function (header) {
|
||||
var AccountTopics = {};
|
||||
const AccountTopics = {};
|
||||
|
||||
AccountTopics.init = function () {
|
||||
header.init();
|
||||
|
||||
var groupsEl = $('#groups-list');
|
||||
const groupsEl = $('#groups-list');
|
||||
|
||||
groupsEl.on('click', '.list-cover', function () {
|
||||
var groupSlug = $(this).parents('[data-slug]').attr('data-slug');
|
||||
const groupSlug = $(this).parents('[data-slug]').attr('data-slug');
|
||||
|
||||
ajaxify.go('groups/' + groupSlug);
|
||||
});
|
||||
|
||||
@@ -11,8 +11,8 @@ define('forum/account/header', [
|
||||
'api',
|
||||
'bootbox',
|
||||
], function (coverPhoto, pictureCropper, components, translator, Benchpress, AccountsDelete, api, bootbox) {
|
||||
var AccountHeader = {};
|
||||
var isAdminOrSelfOrGlobalMod;
|
||||
const AccountHeader = {};
|
||||
let isAdminOrSelfOrGlobalMod;
|
||||
|
||||
AccountHeader.init = function () {
|
||||
isAdminOrSelfOrGlobalMod = ajaxify.data.isAdmin || ajaxify.data.isSelf || ajaxify.data.isGlobalModerator;
|
||||
@@ -78,7 +78,7 @@ define('forum/account/header', [
|
||||
|
||||
function selectActivePill() {
|
||||
$('.account-sub-links li').removeClass('active').each(function () {
|
||||
var href = $(this).find('a').attr('href');
|
||||
const href = $(this).find('a').attr('href');
|
||||
|
||||
if (decodeURIComponent(href) === decodeURIComponent(window.location.pathname)) {
|
||||
$(this).addClass('active');
|
||||
@@ -146,12 +146,12 @@ define('forum/account/header', [
|
||||
submit: {
|
||||
label: '[[user:ban_account]]',
|
||||
callback: function () {
|
||||
var formData = $('.ban-modal form').serializeArray().reduce(function (data, cur) {
|
||||
const formData = $('.ban-modal form').serializeArray().reduce(function (data, cur) {
|
||||
data[cur.name] = cur.value;
|
||||
return data;
|
||||
}, {});
|
||||
|
||||
var until = formData.length > 0 ? (
|
||||
const until = formData.length > 0 ? (
|
||||
Date.now() + (formData.length * 1000 * 60 * 60 * (parseInt(formData.unit, 10) ? 24 : 1))
|
||||
) : 0;
|
||||
|
||||
@@ -188,7 +188,7 @@ define('forum/account/header', [
|
||||
}
|
||||
|
||||
function toggleBlockAccount() {
|
||||
var targetEl = this;
|
||||
const targetEl = this;
|
||||
socket.emit('user.toggleBlock', {
|
||||
blockeeUid: ajaxify.data.uid,
|
||||
blockerUid: app.user.uid,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
define('forum/account/ignored', ['forum/account/header', 'forum/account/topics'], function (header, topics) {
|
||||
var AccountIgnored = {};
|
||||
const AccountIgnored = {};
|
||||
|
||||
AccountIgnored.init = function () {
|
||||
header.init();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('forum/account/info', ['forum/account/header', 'components', 'forum/account/sessions'], function (header, components, sessions) {
|
||||
var Info = {};
|
||||
const Info = {};
|
||||
|
||||
Info.init = function () {
|
||||
header.init();
|
||||
@@ -12,15 +12,15 @@ define('forum/account/info', ['forum/account/header', 'components', 'forum/accou
|
||||
|
||||
function handleModerationNote() {
|
||||
$('[component="account/save-moderation-note"]').on('click', function () {
|
||||
var note = $('[component="account/moderation-note"]').val();
|
||||
const note = $('[component="account/moderation-note"]').val();
|
||||
socket.emit('user.setModerationNote', { uid: ajaxify.data.uid, note: note }, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
$('[component="account/moderation-note"]').val('');
|
||||
app.alertSuccess('[[user:info.moderation-note.success]]');
|
||||
var timestamp = Date.now();
|
||||
var data = [{
|
||||
const timestamp = Date.now();
|
||||
const data = [{
|
||||
note: utils.escapeHTML(note),
|
||||
user: app.user,
|
||||
timestamp: timestamp,
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
|
||||
define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll', 'hooks'], function (header, infinitescroll, hooks) {
|
||||
var AccountPosts = {};
|
||||
const AccountPosts = {};
|
||||
|
||||
var template;
|
||||
var page = 1;
|
||||
let template;
|
||||
let page = 1;
|
||||
|
||||
AccountPosts.init = function () {
|
||||
header.init();
|
||||
@@ -27,7 +27,7 @@ define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll', '
|
||||
if (direction < 0) {
|
||||
return;
|
||||
}
|
||||
var params = utils.params();
|
||||
const params = utils.params();
|
||||
page += 1;
|
||||
params.page = page;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ define('forum/account/profile', [
|
||||
'forum/account/header',
|
||||
'bootbox',
|
||||
], function (header, bootbox) {
|
||||
var Account = {};
|
||||
const Account = {};
|
||||
|
||||
Account.init = function () {
|
||||
header.init();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('forum/account/sessions', ['forum/account/header', 'components', 'api'], function (header, components, api) {
|
||||
var Sessions = {};
|
||||
const Sessions = {};
|
||||
|
||||
Sessions.init = function () {
|
||||
header.init();
|
||||
@@ -11,8 +11,8 @@ define('forum/account/sessions', ['forum/account/header', 'components', 'api'],
|
||||
|
||||
Sessions.prepareSessionRevocation = function () {
|
||||
components.get('user/sessions').on('click', '[data-action]', function () {
|
||||
var parentEl = $(this).parents('[data-uuid]');
|
||||
var uuid = parentEl.attr('data-uuid');
|
||||
const parentEl = $(this).parents('[data-uuid]');
|
||||
const uuid = parentEl.attr('data-uuid');
|
||||
|
||||
if (uuid) {
|
||||
// This is done via DELETE because a user shouldn't be able to
|
||||
@@ -21,7 +21,7 @@ define('forum/account/sessions', ['forum/account/header', 'components', 'api'],
|
||||
parentEl.remove();
|
||||
}).catch((err) => {
|
||||
try {
|
||||
var errorObj = JSON.parse(err.responseText);
|
||||
const errorObj = JSON.parse(err.responseText);
|
||||
if (errorObj.loggedIn === false) {
|
||||
window.location.href = config.relative_path + '/login?error=' + errorObj.title;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('forum/account/settings', ['forum/account/header', 'components', 'translator', 'api'], function (header, components, translator, api) {
|
||||
var AccountSettings = {};
|
||||
const AccountSettings = {};
|
||||
|
||||
// If page skin is changed but not saved, switch the skin back
|
||||
$(window).on('action:ajaxify.start', function () {
|
||||
@@ -15,7 +15,7 @@ define('forum/account/settings', ['forum/account/header', 'components', 'transla
|
||||
header.init();
|
||||
|
||||
$('#submitBtn').on('click', function () {
|
||||
var settings = loadSettings();
|
||||
const settings = loadSettings();
|
||||
|
||||
if (settings.homePageRoute === 'custom' && settings.homePageCustom) {
|
||||
$.get(config.relative_path + '/' + settings.homePageCustom, function () {
|
||||
@@ -42,11 +42,11 @@ define('forum/account/settings', ['forum/account/header', 'components', 'transla
|
||||
};
|
||||
|
||||
function loadSettings() {
|
||||
var settings = {};
|
||||
const settings = {};
|
||||
|
||||
$('.account').find('input, textarea, select').each(function (id, input) {
|
||||
input = $(input);
|
||||
var setting = input.attr('data-property');
|
||||
const setting = input.attr('data-property');
|
||||
if (input.is('select')) {
|
||||
settings[setting] = input.val();
|
||||
return;
|
||||
@@ -68,8 +68,8 @@ define('forum/account/settings', ['forum/account/header', 'components', 'transla
|
||||
function saveSettings(settings) {
|
||||
api.put(`/users/${ajaxify.data.uid}/settings`, { settings }).then((newSettings) => {
|
||||
app.alertSuccess('[[success:settings-saved]]');
|
||||
var languageChanged = false;
|
||||
for (var key in newSettings) {
|
||||
let languageChanged = false;
|
||||
for (const key in newSettings) {
|
||||
if (newSettings.hasOwnProperty(key)) {
|
||||
if (key === 'userLang' && config.userLang !== newSettings.userLang) {
|
||||
languageChanged = true;
|
||||
@@ -82,7 +82,7 @@ define('forum/account/settings', ['forum/account/header', 'components', 'transla
|
||||
|
||||
if (languageChanged && parseInt(app.user.uid, 10) === parseInt(ajaxify.data.theirid, 10)) {
|
||||
translator.translate('[[language:dir]]', config.userLang, function (translated) {
|
||||
var htmlEl = $('html');
|
||||
const htmlEl = $('html');
|
||||
htmlEl.attr('data-dir', translated);
|
||||
htmlEl.css('direction', translated);
|
||||
});
|
||||
@@ -105,20 +105,20 @@ define('forum/account/settings', ['forum/account/header', 'components', 'transla
|
||||
}
|
||||
|
||||
function reskin(skinName) {
|
||||
var clientEl = Array.prototype.filter.call(document.querySelectorAll('link[rel="stylesheet"]'), function (el) {
|
||||
const clientEl = Array.prototype.filter.call(document.querySelectorAll('link[rel="stylesheet"]'), function (el) {
|
||||
return el.href.indexOf(config.relative_path + '/assets/client') !== -1;
|
||||
})[0] || null;
|
||||
if (!clientEl) {
|
||||
return;
|
||||
}
|
||||
|
||||
var currentSkinClassName = $('body').attr('class').split(/\s+/).filter(function (className) {
|
||||
const currentSkinClassName = $('body').attr('class').split(/\s+/).filter(function (className) {
|
||||
return className.startsWith('skin-');
|
||||
});
|
||||
if (!currentSkinClassName[0]) {
|
||||
return;
|
||||
}
|
||||
var currentSkin = currentSkinClassName[0].slice(5);
|
||||
let currentSkin = currentSkinClassName[0].slice(5);
|
||||
currentSkin = currentSkin !== 'noskin' ? currentSkin : '';
|
||||
|
||||
// Stop execution if skin didn't change
|
||||
@@ -126,7 +126,7 @@ define('forum/account/settings', ['forum/account/header', 'components', 'transla
|
||||
return;
|
||||
}
|
||||
|
||||
var linkEl = document.createElement('link');
|
||||
const linkEl = document.createElement('link');
|
||||
linkEl.rel = 'stylesheet';
|
||||
linkEl.type = 'text/css';
|
||||
linkEl.href = config.relative_path + '/assets/client' + (skinName ? '-' + skinName : '') + '.css';
|
||||
|
||||
@@ -6,10 +6,10 @@ define('forum/account/topics', [
|
||||
'forum/infinitescroll',
|
||||
'hooks',
|
||||
], function (header, infinitescroll, hooks) {
|
||||
var AccountTopics = {};
|
||||
const AccountTopics = {};
|
||||
|
||||
var template;
|
||||
var page = 1;
|
||||
let template;
|
||||
let page = 1;
|
||||
|
||||
AccountTopics.init = function () {
|
||||
header.init();
|
||||
@@ -29,7 +29,7 @@ define('forum/account/topics', [
|
||||
if (direction < 0) {
|
||||
return;
|
||||
}
|
||||
var params = utils.params();
|
||||
const params = utils.params();
|
||||
page += 1;
|
||||
params.page = page;
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
define('forum/account/uploads', ['forum/account/header'], function (header) {
|
||||
var AccountUploads = {};
|
||||
const AccountUploads = {};
|
||||
|
||||
AccountUploads.init = function () {
|
||||
header.init();
|
||||
|
||||
$('[data-action="delete"]').on('click', function () {
|
||||
var el = $(this).parents('[data-name]');
|
||||
var name = el.attr('data-name');
|
||||
const el = $(this).parents('[data-name]');
|
||||
const name = el.attr('data-name');
|
||||
|
||||
socket.emit('user.deleteUpload', { name: name, uid: ajaxify.data.uid }, function (err) {
|
||||
if (err) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('forum/account/upvoted', ['forum/account/header', 'forum/account/posts'], function (header, posts) {
|
||||
var Upvoted = {};
|
||||
const Upvoted = {};
|
||||
|
||||
Upvoted.init = function () {
|
||||
header.init();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('forum/account/watched', ['forum/account/header', 'forum/account/topics'], function (header, topics) {
|
||||
var AccountWatched = {};
|
||||
const AccountWatched = {};
|
||||
|
||||
AccountWatched.init = function () {
|
||||
header.init();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('forum/categories', ['components', 'categorySelector', 'hooks'], function (components, categorySelector, hooks) {
|
||||
var categories = {};
|
||||
const categories = {};
|
||||
|
||||
$(window).on('action:ajaxify.start', function (ev, data) {
|
||||
if (ajaxify.currentPage !== data.url) {
|
||||
@@ -34,8 +34,8 @@ define('forum/categories', ['components', 'categorySelector', 'hooks'], function
|
||||
};
|
||||
|
||||
function renderNewPost(cid, post) {
|
||||
var category = components.get('categories/category', 'cid', cid);
|
||||
var numRecentReplies = category.attr('data-numRecentReplies');
|
||||
const category = components.get('categories/category', 'cid', cid);
|
||||
const numRecentReplies = category.attr('data-numRecentReplies');
|
||||
if (!numRecentReplies || !parseInt(numRecentReplies, 10)) {
|
||||
return;
|
||||
}
|
||||
@@ -43,7 +43,7 @@ define('forum/categories', ['components', 'categorySelector', 'hooks'], function
|
||||
return;
|
||||
}
|
||||
|
||||
var recentPosts = category.find('[component="category/posts"]');
|
||||
const recentPosts = category.find('[component="category/posts"]');
|
||||
|
||||
app.parseAndTranslate('partials/categories/lastpost', 'posts', { posts: [post] }, function (html) {
|
||||
html.find('.post-content img:not(.not-responsive)').addClass('img-responsive');
|
||||
|
||||
@@ -9,7 +9,7 @@ define('forum/category', [
|
||||
'categorySelector',
|
||||
'hooks',
|
||||
], function (infinitescroll, share, navigator, topicList, sort, categorySelector, hooks) {
|
||||
var Category = {};
|
||||
const Category = {};
|
||||
|
||||
$(window).on('action:ajaxify.start', function (ev, data) {
|
||||
if (!String(data.url).startsWith('category/')) {
|
||||
@@ -18,7 +18,7 @@ define('forum/category', [
|
||||
});
|
||||
|
||||
Category.init = function () {
|
||||
var cid = ajaxify.data.cid;
|
||||
const cid = ajaxify.data.cid;
|
||||
|
||||
app.enterRoom('category_' + cid);
|
||||
|
||||
@@ -55,7 +55,7 @@ define('forum/category', [
|
||||
};
|
||||
|
||||
function handleScrollToTopicIndex() {
|
||||
var topicIndex = ajaxify.data.topicIndex;
|
||||
let topicIndex = ajaxify.data.topicIndex;
|
||||
if (topicIndex && utils.isNumber(topicIndex)) {
|
||||
topicIndex = Math.max(0, parseInt(topicIndex, 10));
|
||||
if (topicIndex && window.location.search.indexOf('page=') === -1) {
|
||||
@@ -66,8 +66,8 @@ define('forum/category', [
|
||||
|
||||
function handleIgnoreWatch(cid) {
|
||||
$('[component="category/watching"], [component="category/ignoring"], [component="category/notwatching"]').on('click', function () {
|
||||
var $this = $(this);
|
||||
var state = $this.attr('data-state');
|
||||
const $this = $(this);
|
||||
const state = $this.attr('data-state');
|
||||
|
||||
socket.emit('categories.setWatchState', { cid: cid, state: state }, function (err) {
|
||||
if (err) {
|
||||
@@ -90,7 +90,7 @@ define('forum/category', [
|
||||
|
||||
function handleLoadMoreSubcategories() {
|
||||
$('[component="category/load-more-subcategories"]').on('click', function () {
|
||||
var btn = $(this);
|
||||
const btn = $(this);
|
||||
socket.emit('categories.loadMoreSubCategories', {
|
||||
cid: ajaxify.data.cid,
|
||||
start: ajaxify.data.nextSubCategoryStart,
|
||||
@@ -138,7 +138,7 @@ define('forum/category', [
|
||||
callback = callback || function () {};
|
||||
|
||||
hooks.fire('action:category.loading');
|
||||
var params = utils.params();
|
||||
const params = utils.params();
|
||||
infinitescroll.loadMore('categories.loadMore', {
|
||||
cid: ajaxify.data.cid,
|
||||
after: after,
|
||||
|
||||
@@ -10,7 +10,7 @@ define('forum/category/tools', [
|
||||
'api',
|
||||
'bootbox',
|
||||
], function (topicSelect, threadTools, components, translator, api, bootbox) {
|
||||
var CategoryTools = {};
|
||||
const CategoryTools = {};
|
||||
|
||||
CategoryTools.init = function () {
|
||||
topicSelect.init(updateDropdownOptions);
|
||||
@@ -54,7 +54,7 @@ define('forum/category/tools', [
|
||||
|
||||
// todo: should also use categoryCommand, but no write api call exists for this yet
|
||||
components.get('topic/mark-unread-for-all').on('click', function () {
|
||||
var tids = topicSelect.getSelectedTids();
|
||||
const tids = topicSelect.getSelectedTids();
|
||||
if (!tids.length) {
|
||||
return app.alertError('[[error:no-topics-selected]]');
|
||||
}
|
||||
@@ -73,7 +73,7 @@ define('forum/category/tools', [
|
||||
|
||||
components.get('topic/move').on('click', function () {
|
||||
require(['forum/topic/move'], function (move) {
|
||||
var tids = topicSelect.getSelectedTids();
|
||||
const tids = topicSelect.getSelectedTids();
|
||||
|
||||
if (!tids.length) {
|
||||
return app.alertError('[[error:no-topics-selected]]');
|
||||
@@ -85,7 +85,7 @@ define('forum/category/tools', [
|
||||
});
|
||||
|
||||
components.get('topic/move-all').on('click', function () {
|
||||
var cid = ajaxify.data.cid;
|
||||
const cid = ajaxify.data.cid;
|
||||
if (!ajaxify.data.template.category) {
|
||||
return app.alertError('[[error:invalid-data]]');
|
||||
}
|
||||
@@ -101,7 +101,7 @@ define('forum/category/tools', [
|
||||
});
|
||||
|
||||
components.get('topic/merge').on('click', function () {
|
||||
var tids = topicSelect.getSelectedTids();
|
||||
const tids = topicSelect.getSelectedTids();
|
||||
require(['forum/topic/merge'], function (merge) {
|
||||
merge.init(function () {
|
||||
if (tids.length) {
|
||||
@@ -185,11 +185,11 @@ define('forum/category/tools', [
|
||||
}
|
||||
|
||||
function updateDropdownOptions() {
|
||||
var tids = topicSelect.getSelectedTids();
|
||||
var isAnyDeleted = isAny(isTopicDeleted, tids);
|
||||
var areAllDeleted = areAll(isTopicDeleted, tids);
|
||||
var isAnyPinned = isAny(isTopicPinned, tids);
|
||||
var isAnyLocked = isAny(isTopicLocked, tids);
|
||||
const tids = topicSelect.getSelectedTids();
|
||||
const isAnyDeleted = isAny(isTopicDeleted, tids);
|
||||
const areAllDeleted = areAll(isTopicDeleted, tids);
|
||||
const isAnyPinned = isAny(isTopicPinned, tids);
|
||||
const isAnyLocked = isAny(isTopicLocked, tids);
|
||||
const isAnyScheduled = isAny(isTopicScheduled, tids);
|
||||
const areAllScheduled = areAll(isTopicScheduled, tids);
|
||||
|
||||
@@ -207,7 +207,7 @@ define('forum/category/tools', [
|
||||
}
|
||||
|
||||
function isAny(method, tids) {
|
||||
for (var i = 0; i < tids.length; i += 1) {
|
||||
for (let i = 0; i < tids.length; i += 1) {
|
||||
if (method(tids[i])) {
|
||||
return true;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ define('forum/category/tools', [
|
||||
}
|
||||
|
||||
function areAll(method, tids) {
|
||||
for (var i = 0; i < tids.length; i += 1) {
|
||||
for (let i = 0; i < tids.length; i += 1) {
|
||||
if (!method(tids[i])) {
|
||||
return false;
|
||||
}
|
||||
@@ -245,20 +245,20 @@ define('forum/category/tools', [
|
||||
}
|
||||
|
||||
function setDeleteState(data) {
|
||||
var topic = getTopicEl(data.tid);
|
||||
const topic = getTopicEl(data.tid);
|
||||
topic.toggleClass('deleted', data.isDeleted);
|
||||
topic.find('[component="topic/locked"]').toggleClass('hide', !data.isDeleted);
|
||||
}
|
||||
|
||||
function setPinnedState(data) {
|
||||
var topic = getTopicEl(data.tid);
|
||||
const topic = getTopicEl(data.tid);
|
||||
topic.toggleClass('pinned', data.isPinned);
|
||||
topic.find('[component="topic/pinned"]').toggleClass('hide', !data.isPinned);
|
||||
ajaxify.refresh();
|
||||
}
|
||||
|
||||
function setLockedState(data) {
|
||||
var topic = getTopicEl(data.tid);
|
||||
const topic = getTopicEl(data.tid);
|
||||
topic.toggleClass('locked', data.isLocked);
|
||||
topic.find('[component="topic/locked"]').toggleClass('hide', !data.isLocked);
|
||||
}
|
||||
@@ -275,20 +275,20 @@ define('forum/category/tools', [
|
||||
if (!ajaxify.data.topics || !ajaxify.data.template.category) {
|
||||
return;
|
||||
}
|
||||
var numPinned = ajaxify.data.topics.filter(topic => topic.pinned).length;
|
||||
const numPinned = ajaxify.data.topics.filter(topic => topic.pinned).length;
|
||||
if ((!app.user.isAdmin && !app.user.isMod) || numPinned < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
app.loadJQueryUI(function () {
|
||||
var topicListEl = $('[component="category"]').filter(function (i, e) {
|
||||
const topicListEl = $('[component="category"]').filter(function (i, e) {
|
||||
return !$(e).parents('[widget-area],[data-widget-area]').length;
|
||||
});
|
||||
topicListEl.sortable({
|
||||
handle: '[component="topic/pinned"]',
|
||||
items: '[component="category/topic"].pinned',
|
||||
update: function (ev, ui) {
|
||||
var baseIndex = parseInt(topicListEl.find('[component="category/topic"].pinned').first().attr('data-index'), 10);
|
||||
const baseIndex = parseInt(topicListEl.find('[component="category/topic"].pinned').first().attr('data-index'), 10);
|
||||
socket.emit('topics.orderPinnedTopics', {
|
||||
tid: ui.item.attr('data-tid'),
|
||||
order: baseIndex + ui.item.index() - 1,
|
||||
|
||||
@@ -17,14 +17,14 @@ define('forum/chats', [
|
||||
recentChats, search, messages, Benchpress,
|
||||
autocomplete, hooks, bootbox
|
||||
) {
|
||||
var Chats = {
|
||||
const Chats = {
|
||||
initialised: false,
|
||||
};
|
||||
|
||||
var newMessage = false;
|
||||
let newMessage = false;
|
||||
|
||||
Chats.init = function () {
|
||||
var env = utils.findBootstrapEnvironment();
|
||||
const env = utils.findBootstrapEnvironment();
|
||||
|
||||
if (!Chats.initialised) {
|
||||
Chats.addSocketListeners();
|
||||
@@ -75,8 +75,8 @@ define('forum/chats', [
|
||||
|
||||
Chats.addIPHandler = function (container) {
|
||||
container.on('click', '.chat-ip-button', function () {
|
||||
var ipEl = $(this).parent();
|
||||
var mid = ipEl.parents('[data-mid]').attr('data-mid');
|
||||
const ipEl = $(this).parent();
|
||||
const mid = ipEl.parents('[data-mid]').attr('data-mid');
|
||||
socket.emit('modules.chats.getIP', mid, function (err, ip) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
@@ -88,8 +88,8 @@ define('forum/chats', [
|
||||
|
||||
Chats.addPopoutHandler = function () {
|
||||
$('[data-action="pop-out"]').on('click', function () {
|
||||
var text = components.get('chat/input').val();
|
||||
var roomId = ajaxify.data.roomId;
|
||||
const text = components.get('chat/input').val();
|
||||
const roomId = ajaxify.data.roomId;
|
||||
|
||||
if (app.previousUrl && app.previousUrl.match(/chats/)) {
|
||||
ajaxify.go('user/' + ajaxify.data.userslug + '/chats', function () {
|
||||
@@ -107,19 +107,19 @@ define('forum/chats', [
|
||||
};
|
||||
|
||||
Chats.addScrollHandler = function (roomId, uid, el) {
|
||||
var loading = false;
|
||||
let loading = false;
|
||||
el.off('scroll').on('scroll', function () {
|
||||
messages.toggleScrollUpAlert(el);
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
var top = (el[0].scrollHeight - el.height()) * 0.1;
|
||||
const top = (el[0].scrollHeight - el.height()) * 0.1;
|
||||
if (el.scrollTop() >= top) {
|
||||
return;
|
||||
}
|
||||
loading = true;
|
||||
var start = parseInt(el.children('[data-mid]').length, 10);
|
||||
const start = parseInt(el.children('[data-mid]').length, 10);
|
||||
socket.emit('modules.chats.getMessages', {
|
||||
roomId: roomId,
|
||||
uid: uid,
|
||||
@@ -140,8 +140,8 @@ define('forum/chats', [
|
||||
return;
|
||||
}
|
||||
messages.parseMessage(data, function (html) {
|
||||
var currentScrollTop = el.scrollTop();
|
||||
var previousHeight = el[0].scrollHeight;
|
||||
const currentScrollTop = el.scrollTop();
|
||||
const previousHeight = el[0].scrollHeight;
|
||||
html = $(html);
|
||||
el.prepend(html);
|
||||
html.find('.timeago').timeago();
|
||||
@@ -162,7 +162,7 @@ define('forum/chats', [
|
||||
};
|
||||
|
||||
Chats.addCharactersLeftHandler = function (parent) {
|
||||
var element = parent.find('[component="chat/input"]');
|
||||
const element = parent.find('[component="chat/input"]');
|
||||
element.on('change keyup paste', function () {
|
||||
messages.updateRemainingLength(parent);
|
||||
});
|
||||
@@ -170,15 +170,15 @@ define('forum/chats', [
|
||||
|
||||
Chats.addActionHandlers = function (element, roomId) {
|
||||
element.on('click', '[data-action]', function () {
|
||||
var messageId = $(this).parents('[data-mid]').attr('data-mid');
|
||||
var action = this.getAttribute('data-action');
|
||||
const messageId = $(this).parents('[data-mid]').attr('data-mid');
|
||||
const action = this.getAttribute('data-action');
|
||||
|
||||
switch (action) {
|
||||
case 'edit':
|
||||
var inputEl = $('[data-roomid="' + roomId + '"] [component="chat/input"]');
|
||||
case 'edit': {
|
||||
const inputEl = $('[data-roomid="' + roomId + '"] [component="chat/input"]');
|
||||
messages.prepEdit(inputEl, messageId, roomId);
|
||||
break;
|
||||
|
||||
}
|
||||
case 'delete':
|
||||
messages.delete(messageId, roomId);
|
||||
break;
|
||||
@@ -192,16 +192,16 @@ define('forum/chats', [
|
||||
|
||||
Chats.addHotkeys = function () {
|
||||
mousetrap.bind('ctrl+up', function () {
|
||||
var activeContact = $('.chats-list .bg-info');
|
||||
var prev = activeContact.prev();
|
||||
const activeContact = $('.chats-list .bg-info');
|
||||
const prev = activeContact.prev();
|
||||
|
||||
if (prev.length) {
|
||||
Chats.switchChat(prev.attr('data-roomid'));
|
||||
}
|
||||
});
|
||||
mousetrap.bind('ctrl+down', function () {
|
||||
var activeContact = $('.chats-list .bg-info');
|
||||
var next = activeContact.next();
|
||||
const activeContact = $('.chats-list .bg-info');
|
||||
const next = activeContact.next();
|
||||
|
||||
if (next.length) {
|
||||
Chats.switchChat(next.attr('data-roomid'));
|
||||
@@ -210,12 +210,12 @@ define('forum/chats', [
|
||||
mousetrap.bind('up', function (e) {
|
||||
if (e.target === components.get('chat/input').get(0)) {
|
||||
// Retrieve message id from messages list
|
||||
var message = components.get('chat/messages').find('.chat-message[data-self="1"]').last();
|
||||
const message = components.get('chat/messages').find('.chat-message[data-self="1"]').last();
|
||||
if (!message.length) {
|
||||
return;
|
||||
}
|
||||
var lastMid = message.attr('data-mid');
|
||||
var inputEl = components.get('chat/input');
|
||||
const lastMid = message.attr('data-mid');
|
||||
const inputEl = components.get('chat/input');
|
||||
|
||||
messages.prepEdit(inputEl, lastMid, ajaxify.data.roomId);
|
||||
}
|
||||
@@ -223,7 +223,7 @@ define('forum/chats', [
|
||||
};
|
||||
|
||||
Chats.addMemberHandler = function (roomId, buttonEl) {
|
||||
var modal;
|
||||
let modal;
|
||||
|
||||
buttonEl.on('click', function () {
|
||||
app.parseAndTranslate('partials/modals/manage_room', {}, function (html) {
|
||||
@@ -237,8 +237,8 @@ define('forum/chats', [
|
||||
Chats.refreshParticipantsList(roomId, modal);
|
||||
Chats.addKickHandler(roomId, modal);
|
||||
|
||||
var searchInput = modal.find('input');
|
||||
var errorEl = modal.find('.text-danger');
|
||||
const searchInput = modal.find('input');
|
||||
const errorEl = modal.find('.text-danger');
|
||||
require(['autocomplete', 'translator'], function (autocomplete, translator) {
|
||||
autocomplete.user(searchInput, function (event, selected) {
|
||||
errorEl.text('');
|
||||
@@ -263,7 +263,7 @@ define('forum/chats', [
|
||||
|
||||
Chats.addKickHandler = function (roomId, modal) {
|
||||
modal.on('click', '[data-action="kick"]', function () {
|
||||
var uid = parseInt(this.getAttribute('data-uid'), 10);
|
||||
const uid = parseInt(this.getAttribute('data-uid'), 10);
|
||||
|
||||
socket.emit('modules.chats.removeUserFromRoom', {
|
||||
roomId: roomId,
|
||||
@@ -292,7 +292,7 @@ define('forum/chats', [
|
||||
}
|
||||
|
||||
// Return user to chats page. If modal, close modal.
|
||||
var modal = buttonEl.parents('.chat-modal');
|
||||
const modal = buttonEl.parents('.chat-modal');
|
||||
if (modal.length) {
|
||||
require(['chat'], function (chatLib) {
|
||||
chatLib.close(modal);
|
||||
@@ -309,7 +309,7 @@ define('forum/chats', [
|
||||
|
||||
Chats.refreshParticipantsList = function (roomId, modal) {
|
||||
socket.emit('modules.chats.getUsersInRoom', { roomId: roomId }, function (err, users) {
|
||||
var listEl = modal.find('.list-group');
|
||||
const listEl = modal.find('.list-group');
|
||||
|
||||
if (err) {
|
||||
return translator.translate('[[error:invalid-data]]', function (translated) {
|
||||
@@ -326,7 +326,7 @@ define('forum/chats', [
|
||||
};
|
||||
|
||||
Chats.addRenameHandler = function (roomId, buttonEl, roomName) {
|
||||
var modal;
|
||||
let modal;
|
||||
|
||||
buttonEl.on('click', function () {
|
||||
app.parseAndTranslate('partials/modals/rename_room', {
|
||||
@@ -378,7 +378,7 @@ define('forum/chats', [
|
||||
return;
|
||||
}
|
||||
|
||||
var data = {
|
||||
const data = {
|
||||
element: element,
|
||||
strategies: [],
|
||||
options: {
|
||||
@@ -398,7 +398,7 @@ define('forum/chats', [
|
||||
};
|
||||
|
||||
Chats.leave = function (el) {
|
||||
var roomId = el.attr('data-roomid');
|
||||
const roomId = el.attr('data-roomid');
|
||||
socket.emit('modules.chats.leave', roomId, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
@@ -409,7 +409,7 @@ define('forum/chats', [
|
||||
el.remove();
|
||||
}
|
||||
require(['chat'], function (chat) {
|
||||
var modal = chat.getModal(roomId);
|
||||
const modal = chat.getModal(roomId);
|
||||
if (modal.length) {
|
||||
chat.close(modal);
|
||||
}
|
||||
@@ -423,7 +423,7 @@ define('forum/chats', [
|
||||
roomid = '';
|
||||
}
|
||||
|
||||
var url = 'user/' + ajaxify.data.userslug + '/chats/' + roomid + window.location.search;
|
||||
const url = 'user/' + ajaxify.data.userslug + '/chats/' + roomid + window.location.search;
|
||||
if (self.fetch) {
|
||||
fetch(config.relative_path + '/api/' + url, { credentials: 'include' })
|
||||
.then(function (response) {
|
||||
@@ -475,12 +475,12 @@ define('forum/chats', [
|
||||
|
||||
messages.appendChatMessage($('.expanded-chat .chat-content'), data.message);
|
||||
} else if (ajaxify.data.template.chats) {
|
||||
var roomEl = $('[data-roomid=' + data.roomId + ']');
|
||||
const roomEl = $('[data-roomid=' + data.roomId + ']');
|
||||
|
||||
if (roomEl.length > 0) {
|
||||
roomEl.addClass('unread');
|
||||
} else {
|
||||
var recentEl = components.get('chat/recent');
|
||||
const recentEl = components.get('chat/recent');
|
||||
app.parseAndTranslate('partials/chats/recent_room', {
|
||||
rooms: {
|
||||
roomId: data.roomId,
|
||||
@@ -502,8 +502,8 @@ define('forum/chats', [
|
||||
messages.addSocketListeners();
|
||||
|
||||
socket.on('event:chats.roomRename', function (data) {
|
||||
var roomEl = components.get('chat/recent/room', data.roomId);
|
||||
var titleEl = roomEl.find('[component="chat/title"]');
|
||||
const roomEl = components.get('chat/recent/room', data.roomId);
|
||||
const titleEl = roomEl.find('[component="chat/title"]');
|
||||
ajaxify.data.roomName = data.newName;
|
||||
|
||||
titleEl.text(data.newName);
|
||||
@@ -511,10 +511,10 @@ define('forum/chats', [
|
||||
};
|
||||
|
||||
Chats.resizeMainWindow = function () {
|
||||
var viewportHeight = $(window).height();
|
||||
var mainWrapper = components.get('chat/main-wrapper');
|
||||
var navWrapper = components.get('chat/nav-wrapper');
|
||||
var fromTop = 0;
|
||||
const viewportHeight = $(window).height();
|
||||
const mainWrapper = components.get('chat/main-wrapper');
|
||||
const navWrapper = components.get('chat/nav-wrapper');
|
||||
let fromTop = 0;
|
||||
if (mainWrapper.length && navWrapper.length) {
|
||||
fromTop = mainWrapper.offset().top || navWrapper.offset().top;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
|
||||
define('forum/chats/messages', ['components', 'translator', 'benchpress', 'hooks', 'bootbox'], function (components, translator, Benchpress, hooks, bootbox) {
|
||||
var messages = {};
|
||||
const messages = {};
|
||||
|
||||
messages.sendMessage = function (roomId, inputEl) {
|
||||
var msg = inputEl.val();
|
||||
var mid = inputEl.attr('data-mid');
|
||||
const msg = inputEl.val();
|
||||
const mid = inputEl.attr('data-mid');
|
||||
|
||||
if (!msg.trim().length) {
|
||||
return;
|
||||
@@ -59,7 +59,7 @@ define('forum/chats/messages', ['components', 'translator', 'benchpress', 'hooks
|
||||
};
|
||||
|
||||
messages.updateRemainingLength = function (parent) {
|
||||
var element = parent.find('[component="chat/input"]');
|
||||
const element = parent.find('[component="chat/input"]');
|
||||
parent.find('[component="chat/message/length"]').text(element.val().length);
|
||||
parent.find('[component="chat/message/remaining"]').text(config.maximumChatMessageLength - element.val().length);
|
||||
hooks.fire('action:chat.updateRemainingLength', {
|
||||
@@ -68,8 +68,8 @@ define('forum/chats/messages', ['components', 'translator', 'benchpress', 'hooks
|
||||
};
|
||||
|
||||
messages.appendChatMessage = function (chatContentEl, data) {
|
||||
var lastSpeaker = parseInt(chatContentEl.find('.chat-message').last().attr('data-uid'), 10);
|
||||
var lasttimestamp = parseInt(chatContentEl.find('.chat-message').last().attr('data-timestamp'), 10);
|
||||
const lastSpeaker = parseInt(chatContentEl.find('.chat-message').last().attr('data-uid'), 10);
|
||||
const lasttimestamp = parseInt(chatContentEl.find('.chat-message').last().attr('data-timestamp'), 10);
|
||||
if (!Array.isArray(data)) {
|
||||
data.newSet = lastSpeaker !== parseInt(data.fromuid, 10) ||
|
||||
parseInt(data.timestamp, 10) > parseInt(lasttimestamp, 10) + (1000 * 60 * 3);
|
||||
@@ -81,8 +81,8 @@ define('forum/chats/messages', ['components', 'translator', 'benchpress', 'hooks
|
||||
};
|
||||
|
||||
function onMessagesParsed(chatContentEl, html) {
|
||||
var newMessage = $(html);
|
||||
var isAtBottom = messages.isAtBottom(chatContentEl);
|
||||
const newMessage = $(html);
|
||||
const isAtBottom = messages.isAtBottom(chatContentEl);
|
||||
newMessage.appendTo(chatContentEl);
|
||||
newMessage.find('.timeago').timeago();
|
||||
newMessage.find('img:not(.not-responsive)').addClass('img-responsive');
|
||||
@@ -114,7 +114,7 @@ define('forum/chats/messages', ['components', 'translator', 'benchpress', 'hooks
|
||||
|
||||
messages.isAtBottom = function (containerEl, threshold) {
|
||||
if (containerEl.length) {
|
||||
var distanceToBottom = containerEl[0].scrollHeight - (
|
||||
const distanceToBottom = containerEl[0].scrollHeight - (
|
||||
containerEl.outerHeight() + containerEl.scrollTop()
|
||||
);
|
||||
return distanceToBottom < (threshold || 100);
|
||||
@@ -131,7 +131,7 @@ define('forum/chats/messages', ['components', 'translator', 'benchpress', 'hooks
|
||||
};
|
||||
|
||||
messages.toggleScrollUpAlert = function (containerEl) {
|
||||
var isAtBottom = messages.isAtBottom(containerEl, 300);
|
||||
const isAtBottom = messages.isAtBottom(containerEl, 300);
|
||||
containerEl.parent()
|
||||
.find('[component="chat/messages/scroll-up-alert"]')
|
||||
.toggleClass('hidden', isAtBottom);
|
||||
@@ -171,10 +171,10 @@ define('forum/chats/messages', ['components', 'translator', 'benchpress', 'hooks
|
||||
|
||||
function onChatMessageEdited(data) {
|
||||
data.messages.forEach(function (message) {
|
||||
var self = parseInt(message.fromuid, 10) === parseInt(app.user.uid, 10);
|
||||
const self = parseInt(message.fromuid, 10) === parseInt(app.user.uid, 10);
|
||||
message.self = self ? 1 : 0;
|
||||
messages.parseMessage(message, function (html) {
|
||||
var body = components.get('chat/message', message.messageId);
|
||||
const body = components.get('chat/message', message.messageId);
|
||||
if (body.length) {
|
||||
body.replaceWith(html);
|
||||
components.get('chat/message', message.messageId).find('.timeago').timeago();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('forum/chats/recent', function () {
|
||||
var recent = {};
|
||||
const recent = {};
|
||||
|
||||
recent.init = function () {
|
||||
require(['forum/chats'], function (Chats) {
|
||||
@@ -11,8 +11,8 @@ define('forum/chats/recent', function () {
|
||||
});
|
||||
|
||||
$('[component="chat/recent"]').on('scroll', function () {
|
||||
var $this = $(this);
|
||||
var bottom = ($this[0].scrollHeight - $this.height()) * 0.9;
|
||||
const $this = $(this);
|
||||
const bottom = ($this[0].scrollHeight - $this.height()) * 0.9;
|
||||
if ($this.scrollTop() > bottom) {
|
||||
loadMoreRecentChats();
|
||||
}
|
||||
@@ -21,7 +21,7 @@ define('forum/chats/recent', function () {
|
||||
};
|
||||
|
||||
function loadMoreRecentChats() {
|
||||
var recentChats = $('[component="chat/recent"]');
|
||||
const recentChats = $('[component="chat/recent"]');
|
||||
if (recentChats.attr('loading')) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
|
||||
define('forum/chats/search', ['components', 'api'], function (components, api) {
|
||||
var search = {};
|
||||
const search = {};
|
||||
|
||||
search.init = function () {
|
||||
components.get('chat/search').on('keyup', utils.debounce(doSearch, 250));
|
||||
};
|
||||
|
||||
function doSearch() {
|
||||
var username = components.get('chat/search').val();
|
||||
const username = components.get('chat/search').val();
|
||||
if (!username) {
|
||||
return $('[component="chat/search/list"]').empty();
|
||||
}
|
||||
@@ -23,7 +23,7 @@ define('forum/chats/search', ['components', 'api'], function (components, api) {
|
||||
}
|
||||
|
||||
function displayResults(data) {
|
||||
var chatsListEl = $('[component="chat/search/list"]');
|
||||
const chatsListEl = $('[component="chat/search/list"]');
|
||||
chatsListEl.empty();
|
||||
|
||||
data.users = data.users.filter(function (user) {
|
||||
@@ -35,7 +35,7 @@ define('forum/chats/search', ['components', 'api'], function (components, api) {
|
||||
}
|
||||
|
||||
data.users.forEach(function (userObj) {
|
||||
var chatEl = displayUser(chatsListEl, userObj);
|
||||
const chatEl = displayUser(chatsListEl, userObj);
|
||||
onUserClick(chatEl, userObj);
|
||||
});
|
||||
|
||||
@@ -50,7 +50,7 @@ define('forum/chats/search', ['components', 'api'], function (components, api) {
|
||||
'<i class="fa fa-circle status ' + userObj.status + '"></i> ' + userObj.username;
|
||||
}
|
||||
|
||||
var chatEl = $('<li component="chat/search/user"></li>')
|
||||
const chatEl = $('<li component="chat/search/user"></li>')
|
||||
.attr('data-uid', userObj.uid)
|
||||
.appendTo(chatsListEl);
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
|
||||
define('forum/compose', ['hooks'], function (hooks) {
|
||||
var Compose = {};
|
||||
const Compose = {};
|
||||
|
||||
Compose.init = function () {
|
||||
var container = $('.composer');
|
||||
const container = $('.composer');
|
||||
|
||||
if (container.length) {
|
||||
hooks.fire('action:composer.enhance', {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
define('forum/flags/detail', ['forum/flags/list', 'components', 'translator', 'benchpress', 'forum/account/header', 'accounts/delete', 'api', 'bootbox'], function (FlagsList, components, translator, Benchpress, AccountHeader, AccountsDelete, api, bootbox) {
|
||||
var Detail = {};
|
||||
const Detail = {};
|
||||
|
||||
Detail.init = function () {
|
||||
// Update attributes
|
||||
@@ -9,9 +9,9 @@ define('forum/flags/detail', ['forum/flags/list', 'components', 'translator', 'b
|
||||
$('#assignee').val(ajaxify.data.assignee).removeAttr('disabled');
|
||||
|
||||
$('#content > div').on('click', '[data-action]', function () {
|
||||
var action = this.getAttribute('data-action');
|
||||
var uid = $(this).parents('[data-uid]').attr('data-uid');
|
||||
var noteEl = document.getElementById('note');
|
||||
const action = this.getAttribute('data-action');
|
||||
const uid = $(this).parents('[data-uid]').attr('data-uid');
|
||||
const noteEl = document.getElementById('note');
|
||||
|
||||
switch (action) {
|
||||
case 'assign':
|
||||
@@ -45,8 +45,8 @@ define('forum/flags/detail', ['forum/flags/list', 'components', 'translator', 'b
|
||||
}).catch(app.alertError);
|
||||
break;
|
||||
|
||||
case 'delete-note':
|
||||
var datetime = parseInt(this.closest('[data-datetime]').getAttribute('data-datetime'), 10);
|
||||
case 'delete-note': {
|
||||
const datetime = parseInt(this.closest('[data-datetime]').getAttribute('data-datetime'), 10);
|
||||
bootbox.confirm('[[flags:delete-note-confirm]]', function (ok) {
|
||||
if (ok) {
|
||||
api.delete(`/flags/${ajaxify.data.flagId}/notes/${datetime}`, {}).then((payload) => {
|
||||
@@ -57,7 +57,7 @@ define('forum/flags/detail', ['forum/flags/list', 'components', 'translator', 'b
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
}
|
||||
case 'chat':
|
||||
app.newChat(uid);
|
||||
break;
|
||||
@@ -90,15 +90,15 @@ define('forum/flags/detail', ['forum/flags/list', 'components', 'translator', 'b
|
||||
postAction('restore', ajaxify.data.target.pid, ajaxify.data.target.tid);
|
||||
break;
|
||||
|
||||
case 'prepare-edit':
|
||||
var selectedNoteEl = this.closest('[data-index]');
|
||||
var index = selectedNoteEl.getAttribute('data-index');
|
||||
var textareaEl = document.getElementById('note');
|
||||
case 'prepare-edit': {
|
||||
const selectedNoteEl = this.closest('[data-index]');
|
||||
const index = selectedNoteEl.getAttribute('data-index');
|
||||
const textareaEl = document.getElementById('note');
|
||||
textareaEl.value = ajaxify.data.notes[index].content;
|
||||
textareaEl.setAttribute('data-datetime', ajaxify.data.notes[index].datetime);
|
||||
|
||||
var siblings = selectedNoteEl.parentElement.children;
|
||||
for (var el in siblings) {
|
||||
const siblings = selectedNoteEl.parentElement.children;
|
||||
for (const el in siblings) {
|
||||
if (siblings.hasOwnProperty(el)) {
|
||||
siblings[el].classList.remove('editing');
|
||||
}
|
||||
@@ -106,6 +106,7 @@ define('forum/flags/detail', ['forum/flags/list', 'components', 'translator', 'b
|
||||
selectedNoteEl.classList.add('editing');
|
||||
textareaEl.focus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -136,7 +137,7 @@ define('forum/flags/detail', ['forum/flags/list', 'components', 'translator', 'b
|
||||
Benchpress.render('flags/detail', {
|
||||
notes: notes,
|
||||
}, 'notes').then(function (html) {
|
||||
var wrapperEl = components.get('flag/notes');
|
||||
const wrapperEl = components.get('flag/notes');
|
||||
wrapperEl.empty();
|
||||
wrapperEl.html(html);
|
||||
wrapperEl.find('span.timeago').timeago();
|
||||
@@ -148,7 +149,7 @@ define('forum/flags/detail', ['forum/flags/list', 'components', 'translator', 'b
|
||||
app.parseAndTranslate('flags/detail', 'history', {
|
||||
history: history,
|
||||
}, function (html) {
|
||||
var wrapperEl = components.get('flag/history');
|
||||
const wrapperEl = components.get('flag/history');
|
||||
wrapperEl.empty();
|
||||
wrapperEl.html(html);
|
||||
wrapperEl.find('span.timeago').timeago();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
define('forum/flags/list', ['components', 'Chart', 'categoryFilter', 'autocomplete', 'api'], function (components, Chart, categoryFilter, autocomplete, api) {
|
||||
var Flags = {};
|
||||
const Flags = {};
|
||||
|
||||
var selectedCids;
|
||||
let selectedCids;
|
||||
|
||||
Flags.init = function () {
|
||||
Flags.enableFilterForm();
|
||||
@@ -30,7 +30,7 @@ define('forum/flags/list', ['components', 'Chart', 'categoryFilter', 'autocomple
|
||||
return;
|
||||
}
|
||||
|
||||
var flagId = this.getAttribute('data-flag-id');
|
||||
const flagId = this.getAttribute('data-flag-id');
|
||||
ajaxify.go('flags/' + flagId);
|
||||
});
|
||||
|
||||
@@ -75,13 +75,13 @@ define('forum/flags/list', ['components', 'Chart', 'categoryFilter', 'autocomple
|
||||
};
|
||||
|
||||
Flags.enableCheckboxes = function () {
|
||||
var flagsList = document.querySelector('[component="flags/list"]');
|
||||
var checkboxes = flagsList.querySelectorAll('[data-flag-id] input[type="checkbox"]');
|
||||
var bulkEl = document.querySelector('[component="flags/bulk-actions"] button');
|
||||
var lastClicked;
|
||||
const flagsList = document.querySelector('[component="flags/list"]');
|
||||
const checkboxes = flagsList.querySelectorAll('[data-flag-id] input[type="checkbox"]');
|
||||
const bulkEl = document.querySelector('[component="flags/bulk-actions"] button');
|
||||
let lastClicked;
|
||||
|
||||
document.querySelector('[data-action="toggle-all"]').addEventListener('click', function () {
|
||||
var state = this.checked;
|
||||
const state = this.checked;
|
||||
|
||||
checkboxes.forEach(function (el) {
|
||||
el.checked = state;
|
||||
@@ -90,15 +90,15 @@ define('forum/flags/list', ['components', 'Chart', 'categoryFilter', 'autocomple
|
||||
});
|
||||
|
||||
flagsList.addEventListener('click', function (e) {
|
||||
var subselector = e.target.closest('input[type="checkbox"]');
|
||||
const subselector = e.target.closest('input[type="checkbox"]');
|
||||
if (subselector) {
|
||||
// Stop checkbox clicks from going into the flag details
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
if (lastClicked && e.shiftKey && lastClicked !== subselector) {
|
||||
// Select all the checkboxes in between
|
||||
var state = subselector.checked;
|
||||
var started = false;
|
||||
const state = subselector.checked;
|
||||
let started = false;
|
||||
|
||||
checkboxes.forEach(function (el) {
|
||||
if ([subselector, lastClicked].some(function (ref) {
|
||||
@@ -130,16 +130,16 @@ define('forum/flags/list', ['components', 'Chart', 'categoryFilter', 'autocomple
|
||||
|
||||
Flags.handleBulkActions = function () {
|
||||
document.querySelector('[component="flags/bulk-actions"]').addEventListener('click', function (e) {
|
||||
var subselector = e.target.closest('[data-action]');
|
||||
const subselector = e.target.closest('[data-action]');
|
||||
if (subselector) {
|
||||
var action = subselector.getAttribute('data-action');
|
||||
var flagIds = Flags.getSelected();
|
||||
var promises = [];
|
||||
const action = subselector.getAttribute('data-action');
|
||||
const flagIds = Flags.getSelected();
|
||||
const promises = [];
|
||||
|
||||
// TODO: this can be better done with flagIds.map to return promises
|
||||
flagIds.forEach(function (flagId) {
|
||||
promises.push(new Promise(function (resolve, reject) {
|
||||
var handler = function (err) {
|
||||
const handler = function (err) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
@@ -164,10 +164,10 @@ define('forum/flags/list', ['components', 'Chart', 'categoryFilter', 'autocomple
|
||||
});
|
||||
|
||||
Promise.allSettled(promises).then(function (results) {
|
||||
var fulfilled = results.filter(function (res) {
|
||||
const fulfilled = results.filter(function (res) {
|
||||
return res.status === 'fulfilled';
|
||||
}).length;
|
||||
var errors = results.filter(function (res) {
|
||||
const errors = results.filter(function (res) {
|
||||
return res.status === 'rejected';
|
||||
});
|
||||
if (fulfilled) {
|
||||
@@ -184,8 +184,8 @@ define('forum/flags/list', ['components', 'Chart', 'categoryFilter', 'autocomple
|
||||
};
|
||||
|
||||
Flags.getSelected = function () {
|
||||
var checkboxes = document.querySelectorAll('[component="flags/list"] [data-flag-id] input[type="checkbox"]');
|
||||
var payload = [];
|
||||
const checkboxes = document.querySelectorAll('[component="flags/list"] [data-flag-id] input[type="checkbox"]');
|
||||
const payload = [];
|
||||
checkboxes.forEach(function (el) {
|
||||
if (el.checked) {
|
||||
payload.push(el.closest('[data-flag-id]').getAttribute('data-flag-id'));
|
||||
@@ -196,15 +196,15 @@ define('forum/flags/list', ['components', 'Chart', 'categoryFilter', 'autocomple
|
||||
};
|
||||
|
||||
Flags.handleGraphs = function () {
|
||||
var dailyCanvas = document.getElementById('flags:daily');
|
||||
var dailyLabels = utils.getDaysArray().map(function (text, idx) {
|
||||
const dailyCanvas = document.getElementById('flags:daily');
|
||||
const dailyLabels = utils.getDaysArray().map(function (text, idx) {
|
||||
return idx % 3 ? '' : text;
|
||||
});
|
||||
|
||||
if (utils.isMobile()) {
|
||||
Chart.defaults.global.tooltips.enabled = false;
|
||||
}
|
||||
var data = {
|
||||
const data = {
|
||||
'flags:daily': {
|
||||
labels: dailyLabels,
|
||||
datasets: [
|
||||
|
||||
@@ -23,11 +23,11 @@ define('forum/groups/details', [
|
||||
categorySelector,
|
||||
bootbox
|
||||
) {
|
||||
var Details = {};
|
||||
var groupName;
|
||||
const Details = {};
|
||||
let groupName;
|
||||
|
||||
Details.init = function () {
|
||||
var detailsPage = components.get('groups/container');
|
||||
const detailsPage = components.get('groups/container');
|
||||
|
||||
groupName = ajaxify.data.group.name;
|
||||
|
||||
@@ -68,12 +68,12 @@ define('forum/groups/details', [
|
||||
components.get('groups/activity').find('.content img:not(.not-responsive)').addClass('img-responsive');
|
||||
|
||||
detailsPage.on('click', '[data-action]', function () {
|
||||
var btnEl = $(this);
|
||||
var userRow = btnEl.parents('[data-uid]');
|
||||
var ownerFlagEl = userRow.find('.member-name > i');
|
||||
var isOwner = !ownerFlagEl.hasClass('invisible');
|
||||
var uid = userRow.attr('data-uid');
|
||||
var action = btnEl.attr('data-action');
|
||||
const btnEl = $(this);
|
||||
const userRow = btnEl.parents('[data-uid]');
|
||||
const ownerFlagEl = userRow.find('.member-name > i');
|
||||
const isOwner = !ownerFlagEl.hasClass('invisible');
|
||||
const uid = userRow.attr('data-uid');
|
||||
const action = btnEl.attr('data-action');
|
||||
|
||||
switch (action) {
|
||||
case 'toggleOwnership':
|
||||
@@ -135,16 +135,16 @@ define('forum/groups/details', [
|
||||
};
|
||||
|
||||
Details.prepareSettings = function () {
|
||||
var settingsFormEl = components.get('groups/settings');
|
||||
var labelColorValueEl = settingsFormEl.find('[name="labelColor"]');
|
||||
var textColorValueEl = settingsFormEl.find('[name="textColor"]');
|
||||
var iconBtn = settingsFormEl.find('[data-action="icon-select"]');
|
||||
var previewEl = settingsFormEl.find('.label');
|
||||
var previewElText = settingsFormEl.find('.label-text');
|
||||
var previewIcon = previewEl.find('i');
|
||||
var userTitleEl = settingsFormEl.find('[name="userTitle"]');
|
||||
var userTitleEnabledEl = settingsFormEl.find('[name="userTitleEnabled"]');
|
||||
var iconValueEl = settingsFormEl.find('[name="icon"]');
|
||||
const settingsFormEl = components.get('groups/settings');
|
||||
const labelColorValueEl = settingsFormEl.find('[name="labelColor"]');
|
||||
const textColorValueEl = settingsFormEl.find('[name="textColor"]');
|
||||
const iconBtn = settingsFormEl.find('[data-action="icon-select"]');
|
||||
const previewEl = settingsFormEl.find('.label');
|
||||
const previewElText = settingsFormEl.find('.label-text');
|
||||
const previewIcon = previewEl.find('i');
|
||||
const userTitleEl = settingsFormEl.find('[name="userTitle"]');
|
||||
const userTitleEnabledEl = settingsFormEl.find('[name="userTitleEnabled"]');
|
||||
const iconValueEl = settingsFormEl.find('[name="icon"]');
|
||||
|
||||
labelColorValueEl.on('input', function () {
|
||||
previewEl.css('background-color', labelColorValueEl.val());
|
||||
@@ -168,7 +168,7 @@ define('forum/groups/details', [
|
||||
|
||||
// Disable user title customisation options if the the user title itself is disabled
|
||||
userTitleEnabledEl.on('change', function () {
|
||||
var customOpts = components.get('groups/userTitleOption');
|
||||
const customOpts = components.get('groups/userTitleOption');
|
||||
|
||||
if (this.checked) {
|
||||
customOpts.removeAttr('disabled');
|
||||
@@ -179,9 +179,9 @@ define('forum/groups/details', [
|
||||
}
|
||||
});
|
||||
|
||||
var cidSelector = categorySelector.init($('.member-post-cids-selector [component="category-selector"]'), {
|
||||
const cidSelector = categorySelector.init($('.member-post-cids-selector [component="category-selector"]'), {
|
||||
onSelect: function (selectedCategory) {
|
||||
var cids = ($('#memberPostCids').val() || '').split(',').map(cid => parseInt(cid, 10));
|
||||
let cids = ($('#memberPostCids').val() || '').split(',').map(cid => parseInt(cid, 10));
|
||||
cids.push(selectedCategory.cid);
|
||||
cids = cids.filter((cid, index, array) => array.indexOf(cid) === index);
|
||||
$('#memberPostCids').val(cids.join(','));
|
||||
@@ -191,11 +191,11 @@ define('forum/groups/details', [
|
||||
};
|
||||
|
||||
Details.update = function () {
|
||||
var settingsFormEl = components.get('groups/settings');
|
||||
var checkboxes = settingsFormEl.find('input[type="checkbox"][name]');
|
||||
const settingsFormEl = components.get('groups/settings');
|
||||
const checkboxes = settingsFormEl.find('input[type="checkbox"][name]');
|
||||
|
||||
if (settingsFormEl.length) {
|
||||
var settings = settingsFormEl.serializeObject();
|
||||
const settings = settingsFormEl.serializeObject();
|
||||
|
||||
// serializeObject doesnt return array for multi selects if only one item is selected
|
||||
if (!Array.isArray(settings.memberPostCids)) {
|
||||
@@ -212,7 +212,7 @@ define('forum/groups/details', [
|
||||
|
||||
api.put(`/groups/${ajaxify.data.group.slug}`, settings).then(() => {
|
||||
if (settings.name) {
|
||||
var pathname = window.location.pathname;
|
||||
let pathname = window.location.pathname;
|
||||
pathname = pathname.substr(1, pathname.lastIndexOf('/'));
|
||||
ajaxify.go(pathname + slugify(settings.name));
|
||||
} else {
|
||||
@@ -244,7 +244,7 @@ define('forum/groups/details', [
|
||||
return;
|
||||
}
|
||||
|
||||
var searchInput = $('[component="groups/members/invite"]');
|
||||
const searchInput = $('[component="groups/members/invite"]');
|
||||
require(['autocomplete'], function (autocomplete) {
|
||||
autocomplete.user(searchInput, function (event, selected) {
|
||||
socket.emit('groups.issueInvite', {
|
||||
@@ -260,7 +260,7 @@ define('forum/groups/details', [
|
||||
});
|
||||
|
||||
$('[component="groups/members/bulk-invite-button"]').on('click', function () {
|
||||
var usernames = $('[component="groups/members/bulk-invite"]').val();
|
||||
const usernames = $('[component="groups/members/bulk-invite"]').val();
|
||||
if (!usernames) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
define('forum/groups/list', [
|
||||
'forum/infinitescroll', 'benchpress', 'api', 'bootbox',
|
||||
], function (infinitescroll, Benchpress, api, bootbox) {
|
||||
var Groups = {};
|
||||
const Groups = {};
|
||||
|
||||
Groups.init = function () {
|
||||
infinitescroll.init(Groups.loadMoreGroups);
|
||||
@@ -20,7 +20,7 @@ define('forum/groups/list', [
|
||||
}
|
||||
});
|
||||
});
|
||||
var params = utils.params();
|
||||
const params = utils.params();
|
||||
$('#search-sort').val(params.sort || 'alpha');
|
||||
|
||||
// Group searching
|
||||
@@ -58,9 +58,9 @@ define('forum/groups/list', [
|
||||
};
|
||||
|
||||
Groups.search = function () {
|
||||
var groupsEl = $('#groups-list');
|
||||
var queryEl = $('#search-text');
|
||||
var sortEl = $('#search-sort');
|
||||
const groupsEl = $('#groups-list');
|
||||
const queryEl = $('#search-text');
|
||||
const sortEl = $('#search-sort');
|
||||
|
||||
socket.emit('groups.search', {
|
||||
query: queryEl.val(),
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
define('forum/groups/memberlist', ['api', 'bootbox'], function (api, bootbox) {
|
||||
var MemberList = {};
|
||||
var searchInterval;
|
||||
var groupName;
|
||||
var templateName;
|
||||
const MemberList = {};
|
||||
let searchInterval;
|
||||
let groupName;
|
||||
let templateName;
|
||||
|
||||
MemberList.init = function (_templateName) {
|
||||
templateName = _templateName || 'groups/details';
|
||||
@@ -18,14 +18,14 @@ define('forum/groups/memberlist', ['api', 'bootbox'], function (api, bootbox) {
|
||||
function handleMemberAdd() {
|
||||
$('[component="groups/members/add"]').on('click', function () {
|
||||
app.parseAndTranslate('admin/partials/groups/add-members', {}, function (html) {
|
||||
var foundUsers = [];
|
||||
var modal = bootbox.dialog({
|
||||
const foundUsers = [];
|
||||
const modal = bootbox.dialog({
|
||||
title: '[[groups:details.add-member]]',
|
||||
message: html,
|
||||
buttons: {
|
||||
ok: {
|
||||
callback: function () {
|
||||
var users = [];
|
||||
const users = [];
|
||||
modal.find('[data-uid][data-selected]').each(function (index, el) {
|
||||
users.push(foundUsers[$(el).attr('data-uid')]);
|
||||
});
|
||||
@@ -37,7 +37,7 @@ define('forum/groups/memberlist', ['api', 'bootbox'], function (api, bootbox) {
|
||||
},
|
||||
});
|
||||
modal.on('click', '[data-username]', function () {
|
||||
var isSelected = $(this).attr('data-selected') === '1';
|
||||
const isSelected = $(this).attr('data-selected') === '1';
|
||||
if (isSelected) {
|
||||
$(this).removeAttr('data-selected');
|
||||
} else {
|
||||
@@ -75,7 +75,7 @@ define('forum/groups/memberlist', ['api', 'bootbox'], function (api, bootbox) {
|
||||
});
|
||||
callback();
|
||||
}
|
||||
var uids = users.map(function (user) { return user.uid; });
|
||||
const uids = users.map(function (user) { return user.uid; });
|
||||
if (groupName === 'administrators') {
|
||||
socket.emit('admin.user.makeAdmins', uids, function (err) {
|
||||
if (err) {
|
||||
@@ -90,7 +90,7 @@ define('forum/groups/memberlist', ['api', 'bootbox'], function (api, bootbox) {
|
||||
|
||||
function handleMemberSearch() {
|
||||
$('[component="groups/members/search"]').on('keyup', function () {
|
||||
var query = $(this).val();
|
||||
const query = $(this).val();
|
||||
if (searchInterval) {
|
||||
clearInterval(searchInterval);
|
||||
searchInterval = 0;
|
||||
@@ -112,8 +112,8 @@ define('forum/groups/memberlist', ['api', 'bootbox'], function (api, bootbox) {
|
||||
|
||||
function handleMemberInfiniteScroll() {
|
||||
$('[component="groups/members"] tbody').on('scroll', function () {
|
||||
var $this = $(this);
|
||||
var bottom = ($this[0].scrollHeight - $this.innerHeight()) * 0.9;
|
||||
const $this = $(this);
|
||||
const bottom = ($this[0].scrollHeight - $this.innerHeight()) * 0.9;
|
||||
|
||||
if ($this.scrollTop() > bottom && !$('[component="groups/members/search"]').val()) {
|
||||
loadMoreMembers();
|
||||
@@ -122,7 +122,7 @@ define('forum/groups/memberlist', ['api', 'bootbox'], function (api, bootbox) {
|
||||
}
|
||||
|
||||
function loadMoreMembers() {
|
||||
var members = $('[component="groups/members"]');
|
||||
const members = $('[component="groups/members"]');
|
||||
if (members.attr('loading')) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
define('forum/header/chat', ['components'], function (components) {
|
||||
var chat = {};
|
||||
const chat = {};
|
||||
|
||||
chat.prepareDOM = function () {
|
||||
var chatsToggleEl = components.get('chat/dropdown');
|
||||
var chatsListEl = components.get('chat/list');
|
||||
const chatsToggleEl = components.get('chat/dropdown');
|
||||
const chatsListEl = components.get('chat/list');
|
||||
|
||||
chatsToggleEl.on('click', function () {
|
||||
if (chatsToggleEl.parent().hasClass('open')) {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
define('forum/header/notifications', ['components'], function (components) {
|
||||
var notifications = {};
|
||||
const notifications = {};
|
||||
|
||||
notifications.prepareDOM = function () {
|
||||
var notifContainer = components.get('notifications');
|
||||
var notifTrigger = notifContainer.children('a');
|
||||
var notifList = components.get('notifications/list');
|
||||
const notifContainer = components.get('notifications');
|
||||
const notifTrigger = notifContainer.children('a');
|
||||
const notifList = components.get('notifications/list');
|
||||
|
||||
notifTrigger.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
|
||||
define('forum/infinitescroll', ['hooks'], function (hooks) {
|
||||
var scroll = {};
|
||||
var callback;
|
||||
var previousScrollTop = 0;
|
||||
var loadingMore = false;
|
||||
var container;
|
||||
var scrollTimeout = 0;
|
||||
const scroll = {};
|
||||
let callback;
|
||||
let previousScrollTop = 0;
|
||||
let loadingMore = false;
|
||||
let container;
|
||||
let scrollTimeout = 0;
|
||||
|
||||
scroll.init = function (el, cb) {
|
||||
const $body = $('body');
|
||||
@@ -37,20 +37,20 @@ define('forum/infinitescroll', ['hooks'], function (hooks) {
|
||||
}
|
||||
|
||||
function onScroll() {
|
||||
var bsEnv = utils.findBootstrapEnvironment();
|
||||
var mobileComposerOpen = (bsEnv === 'xs' || bsEnv === 'sm') && $('html').hasClass('composing');
|
||||
const bsEnv = utils.findBootstrapEnvironment();
|
||||
const mobileComposerOpen = (bsEnv === 'xs' || bsEnv === 'sm') && $('html').hasClass('composing');
|
||||
if (loadingMore || mobileComposerOpen) {
|
||||
return;
|
||||
}
|
||||
var currentScrollTop = $(window).scrollTop();
|
||||
var wh = $(window).height();
|
||||
var viewportHeight = container.height() - wh;
|
||||
var offsetTop = container.offset() ? container.offset().top : 0;
|
||||
var scrollPercent = 100 * (currentScrollTop - offsetTop) / (viewportHeight <= 0 ? wh : viewportHeight);
|
||||
const currentScrollTop = $(window).scrollTop();
|
||||
const wh = $(window).height();
|
||||
const viewportHeight = container.height() - wh;
|
||||
const offsetTop = container.offset() ? container.offset().top : 0;
|
||||
const scrollPercent = 100 * (currentScrollTop - offsetTop) / (viewportHeight <= 0 ? wh : viewportHeight);
|
||||
|
||||
var top = 15;
|
||||
var bottom = 85;
|
||||
var direction = currentScrollTop > previousScrollTop ? 1 : -1;
|
||||
const top = 15;
|
||||
const bottom = 85;
|
||||
const direction = currentScrollTop > previousScrollTop ? 1 : -1;
|
||||
|
||||
if (scrollPercent < top && currentScrollTop < previousScrollTop) {
|
||||
callback(direction);
|
||||
@@ -69,7 +69,7 @@ define('forum/infinitescroll', ['hooks'], function (hooks) {
|
||||
}
|
||||
loadingMore = true;
|
||||
|
||||
var hookData = { method: method, data: data };
|
||||
const hookData = { method: method, data: data };
|
||||
hooks.fire('action:infinitescroll.loadmore', hookData);
|
||||
|
||||
socket.emit(hookData.method, hookData.data, function (err, data) {
|
||||
@@ -88,8 +88,8 @@ define('forum/infinitescroll', ['hooks'], function (hooks) {
|
||||
return;
|
||||
}
|
||||
loadingMore = true;
|
||||
var url = config.relative_path + '/api' + location.pathname.replace(new RegExp('^' + config.relative_path), '');
|
||||
var hookData = { url: url, data: data };
|
||||
const url = config.relative_path + '/api' + location.pathname.replace(new RegExp('^' + config.relative_path), '');
|
||||
const hookData = { url: url, data: data };
|
||||
hooks.fire('action:infinitescroll.loadmore.xhr', hookData);
|
||||
|
||||
$.get(url, data, function (data) {
|
||||
@@ -107,10 +107,10 @@ define('forum/infinitescroll', ['hooks'], function (hooks) {
|
||||
return;
|
||||
}
|
||||
|
||||
var removeCount = els.length - count;
|
||||
const removeCount = els.length - count;
|
||||
if (direction > 0) {
|
||||
var height = $(document).height();
|
||||
var scrollTop = $(window).scrollTop();
|
||||
const height = $(document).height();
|
||||
const scrollTop = $(window).scrollTop();
|
||||
|
||||
els.slice(0, removeCount).remove();
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
|
||||
define('forum/ip-blacklist', ['Chart', 'benchpress', 'bootbox'], function (Chart, Benchpress, bootbox) {
|
||||
var Blacklist = {};
|
||||
const Blacklist = {};
|
||||
|
||||
Blacklist.init = function () {
|
||||
var blacklist = $('#blacklist-rules');
|
||||
const blacklist = $('#blacklist-rules');
|
||||
|
||||
blacklist.on('keyup', function () {
|
||||
$('#blacklist-rules-holder').val(blacklist.val());
|
||||
@@ -42,12 +42,12 @@ define('forum/ip-blacklist', ['Chart', 'benchpress', 'bootbox'], function (Chart
|
||||
};
|
||||
|
||||
Blacklist.setupAnalytics = function () {
|
||||
var hourlyCanvas = document.getElementById('blacklist:hourly');
|
||||
var dailyCanvas = document.getElementById('blacklist:daily');
|
||||
var hourlyLabels = utils.getHoursArray().map(function (text, idx) {
|
||||
const hourlyCanvas = document.getElementById('blacklist:hourly');
|
||||
const dailyCanvas = document.getElementById('blacklist:daily');
|
||||
const hourlyLabels = utils.getHoursArray().map(function (text, idx) {
|
||||
return idx % 3 ? '' : text;
|
||||
});
|
||||
var dailyLabels = utils.getDaysArray().slice(-7).map(function (text, idx) {
|
||||
const dailyLabels = utils.getDaysArray().slice(-7).map(function (text, idx) {
|
||||
return idx % 3 ? '' : text;
|
||||
});
|
||||
|
||||
@@ -55,7 +55,7 @@ define('forum/ip-blacklist', ['Chart', 'benchpress', 'bootbox'], function (Chart
|
||||
Chart.defaults.global.tooltips.enabled = false;
|
||||
}
|
||||
|
||||
var data = {
|
||||
const data = {
|
||||
'blacklist:hourly': {
|
||||
labels: hourlyLabels,
|
||||
datasets: [
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
|
||||
define('forum/login', ['hooks', 'translator', 'jquery-form'], function (hooks, translator) {
|
||||
var Login = {
|
||||
const Login = {
|
||||
_capsState: false,
|
||||
};
|
||||
|
||||
Login.init = function () {
|
||||
var errorEl = $('#login-error-notify');
|
||||
var submitEl = $('#login');
|
||||
var formEl = $('#login-form');
|
||||
const errorEl = $('#login-error-notify');
|
||||
const submitEl = $('#login');
|
||||
const formEl = $('#login-form');
|
||||
|
||||
submitEl.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
@@ -36,17 +36,17 @@ define('forum/login', ['hooks', 'translator', 'jquery-form'], function (hooks, t
|
||||
},
|
||||
success: function (data) {
|
||||
hooks.fire('action:app.loggedIn', data);
|
||||
var pathname = utils.urlToLocation(data.next).pathname;
|
||||
var params = utils.params({ url: data.next });
|
||||
const pathname = utils.urlToLocation(data.next).pathname;
|
||||
const params = utils.params({ url: data.next });
|
||||
params.loggedin = true;
|
||||
delete params.register; // clear register message incase it exists
|
||||
var qs = decodeURIComponent($.param(params));
|
||||
const qs = decodeURIComponent($.param(params));
|
||||
|
||||
window.location.href = pathname + '?' + qs;
|
||||
},
|
||||
error: function (data) {
|
||||
var message = data.responseText;
|
||||
var errInfo = data.responseJSON;
|
||||
let message = data.responseText;
|
||||
const errInfo = data.responseJSON;
|
||||
if (data.status === 403 && data.responseText === 'Forbidden') {
|
||||
window.location.href = config.relative_path + '/login?error=csrf-invalid';
|
||||
} else if (errInfo && errInfo.hasOwnProperty('banned_until')) {
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
|
||||
define('forum/notifications', ['components'], function (components) {
|
||||
var Notifications = {};
|
||||
const Notifications = {};
|
||||
|
||||
Notifications.init = function () {
|
||||
var listEl = $('.notifications-list');
|
||||
const listEl = $('.notifications-list');
|
||||
listEl.on('click', '[component="notifications/item/link"]', function () {
|
||||
var nid = $(this).parents('[data-nid]').attr('data-nid');
|
||||
const nid = $(this).parents('[data-nid]').attr('data-nid');
|
||||
socket.emit('notifications.markRead', nid, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('forum/pagination', ['bootbox'], function (bootbox) {
|
||||
var pagination = {};
|
||||
const pagination = {};
|
||||
|
||||
pagination.init = function () {
|
||||
$('body').on('click', '[component="pagination/select-page"]', function () {
|
||||
@@ -20,10 +20,10 @@ define('forum/pagination', ['bootbox'], function (bootbox) {
|
||||
return;
|
||||
}
|
||||
|
||||
var query = utils.params();
|
||||
const query = utils.params();
|
||||
query.page = page;
|
||||
|
||||
var url = window.location.pathname + '?' + $.param(query);
|
||||
const url = window.location.pathname + '?' + $.param(query);
|
||||
ajaxify.go(url, callback);
|
||||
};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('forum/popular', ['topicList'], function (topicList) {
|
||||
var Popular = {};
|
||||
const Popular = {};
|
||||
|
||||
Popular.init = function () {
|
||||
app.enterRoom('popular_topics');
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
define('forum/post-queue', [
|
||||
'categoryFilter', 'categorySelector', 'api',
|
||||
], function (categoryFilter, categorySelector, api) {
|
||||
var PostQueue = {};
|
||||
const PostQueue = {};
|
||||
|
||||
PostQueue.init = function () {
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
@@ -14,10 +14,10 @@ define('forum/post-queue', [
|
||||
});
|
||||
|
||||
$('.posts-list').on('click', '[data-action]', function () {
|
||||
var parent = $(this).parents('[data-id]');
|
||||
var action = $(this).attr('data-action');
|
||||
var id = parent.attr('data-id');
|
||||
var listContainer = parent.get(0).parentNode;
|
||||
const parent = $(this).parents('[data-id]');
|
||||
const action = $(this).attr('data-action');
|
||||
const id = parent.attr('data-id');
|
||||
const listContainer = parent.get(0).parentNode;
|
||||
|
||||
if (!['accept', 'reject'].some(function (valid) {
|
||||
return action === valid;
|
||||
@@ -42,8 +42,8 @@ define('forum/post-queue', [
|
||||
handleContentEdit('.topic-title', '.topic-title-editable', 'input');
|
||||
|
||||
$('.posts-list').on('click', '.topic-category[data-editable]', function () {
|
||||
var $this = $(this);
|
||||
var id = $this.parents('[data-id]').attr('data-id');
|
||||
const $this = $(this);
|
||||
const id = $this.parents('[data-id]').attr('data-id');
|
||||
categorySelector.modal({
|
||||
onSubmit: function (selectedCategory) {
|
||||
Promise.all([
|
||||
@@ -53,7 +53,7 @@ define('forum/post-queue', [
|
||||
cid: selectedCategory.cid,
|
||||
}),
|
||||
]).then(function (result) {
|
||||
var category = result[0];
|
||||
const category = result[0];
|
||||
app.parseAndTranslate('post-queue', 'posts', {
|
||||
posts: [{
|
||||
category: category,
|
||||
@@ -79,8 +79,8 @@ define('forum/post-queue', [
|
||||
|
||||
function handleContentEdit(displayClass, editableClass, inputSelector) {
|
||||
$('.posts-list').on('click', displayClass, function () {
|
||||
var el = $(this);
|
||||
var inputEl = el.parent().find(editableClass);
|
||||
const el = $(this);
|
||||
const inputEl = el.parent().find(editableClass);
|
||||
if (inputEl.length) {
|
||||
el.addClass('hidden');
|
||||
inputEl.removeClass('hidden').find(inputSelector).focus();
|
||||
@@ -88,10 +88,10 @@ define('forum/post-queue', [
|
||||
});
|
||||
|
||||
$('.posts-list').on('blur', editableClass + ' ' + inputSelector, function () {
|
||||
var textarea = $(this);
|
||||
var preview = textarea.parent().parent().find(displayClass);
|
||||
var id = textarea.parents('[data-id]').attr('data-id');
|
||||
var titleEdit = displayClass === '.topic-title';
|
||||
const textarea = $(this);
|
||||
const preview = textarea.parent().parent().find(displayClass);
|
||||
const id = textarea.parents('[data-id]').attr('data-id');
|
||||
const titleEdit = displayClass === '.topic-title';
|
||||
|
||||
socket.emit('posts.editQueuedContent', {
|
||||
id: id,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
define('forum/recent', ['topicList'], function (topicList) {
|
||||
var Recent = {};
|
||||
const Recent = {};
|
||||
|
||||
Recent.init = function () {
|
||||
app.enterRoom('recent_topics');
|
||||
|
||||
@@ -4,21 +4,21 @@
|
||||
define('forum/register', [
|
||||
'translator', 'zxcvbn', 'slugify', 'api', 'bootbox', 'forum/login', 'jquery-form',
|
||||
], function (translator, zxcvbn, slugify, api, bootbox, Login) {
|
||||
var Register = {};
|
||||
var validationError = false;
|
||||
var successIcon = '';
|
||||
const Register = {};
|
||||
let validationError = false;
|
||||
const successIcon = '';
|
||||
|
||||
Register.init = function () {
|
||||
var username = $('#username');
|
||||
var password = $('#password');
|
||||
var password_confirm = $('#password-confirm');
|
||||
var register = $('#register');
|
||||
const username = $('#username');
|
||||
const password = $('#password');
|
||||
const password_confirm = $('#password-confirm');
|
||||
const register = $('#register');
|
||||
|
||||
handleLanguageOverride();
|
||||
|
||||
$('#content #noscript').val('false');
|
||||
|
||||
var query = utils.params();
|
||||
const query = utils.params();
|
||||
if (query.token) {
|
||||
$('#token').val(query.token);
|
||||
}
|
||||
@@ -57,8 +57,8 @@ define('forum/register', [
|
||||
Login.capsLockCheck(document.querySelector('#password'), document.querySelector('#caps-lock-warning'));
|
||||
|
||||
register.on('click', function (e) {
|
||||
var registerBtn = $(this);
|
||||
var errorEl = $('#register-error-notify');
|
||||
const registerBtn = $(this);
|
||||
const errorEl = $('#register-error-notify');
|
||||
errorEl.addClass('hidden');
|
||||
e.preventDefault();
|
||||
validateForm(function () {
|
||||
@@ -78,11 +78,11 @@ define('forum/register', [
|
||||
return;
|
||||
}
|
||||
if (data.next) {
|
||||
var pathname = utils.urlToLocation(data.next).pathname;
|
||||
const pathname = utils.urlToLocation(data.next).pathname;
|
||||
|
||||
var params = utils.params({ url: data.next });
|
||||
const params = utils.params({ url: data.next });
|
||||
params.registered = true;
|
||||
var qs = decodeURIComponent($.param(params));
|
||||
const qs = decodeURIComponent($.param(params));
|
||||
|
||||
window.location.href = pathname + '?' + qs;
|
||||
} else if (data.message) {
|
||||
@@ -114,8 +114,8 @@ define('forum/register', [
|
||||
function validateUsername(username, callback) {
|
||||
callback = callback || function () {};
|
||||
|
||||
var username_notify = $('#username-notify');
|
||||
var userslug = slugify(username);
|
||||
const username_notify = $('#username-notify');
|
||||
const userslug = slugify(username);
|
||||
if (username.length < ajaxify.data.minimumUsernameLength || userslug.length < ajaxify.data.minimumUsernameLength) {
|
||||
showError(username_notify, '[[error:username-too-short]]');
|
||||
} else if (username.length > ajaxify.data.maximumUsernameLength) {
|
||||
@@ -139,9 +139,9 @@ define('forum/register', [
|
||||
}
|
||||
|
||||
function validatePassword(password, password_confirm) {
|
||||
var password_notify = $('#password-notify');
|
||||
var password_confirm_notify = $('#password-confirm-notify');
|
||||
var passwordStrength = zxcvbn(password);
|
||||
const password_notify = $('#password-notify');
|
||||
const password_confirm_notify = $('#password-confirm-notify');
|
||||
const passwordStrength = zxcvbn(password);
|
||||
|
||||
if (password.length < ajaxify.data.minimumPasswordLength) {
|
||||
showError(password_notify, '[[reset_password:password_too_short]]');
|
||||
@@ -163,8 +163,8 @@ define('forum/register', [
|
||||
}
|
||||
|
||||
function validatePasswordConfirm(password, password_confirm) {
|
||||
var password_notify = $('#password-notify');
|
||||
var password_confirm_notify = $('#password-confirm-notify');
|
||||
const password_notify = $('#password-notify');
|
||||
const password_confirm_notify = $('#password-confirm-notify');
|
||||
|
||||
if (!password || password_notify.hasClass('alert-error')) {
|
||||
return;
|
||||
@@ -200,8 +200,8 @@ define('forum/register', [
|
||||
|
||||
function handleLanguageOverride() {
|
||||
if (!app.user.uid && config.defaultLang !== config.userLang) {
|
||||
var formEl = $('[component="register/local"]');
|
||||
var langEl = $('<input type="hidden" name="userLang" value="' + config.userLang + '" />');
|
||||
const formEl = $('[component="register/local"]');
|
||||
const langEl = $('<input type="hidden" name="userLang" value="' + config.userLang + '" />');
|
||||
|
||||
formEl.append(langEl);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
|
||||
define('forum/reset', function () {
|
||||
var ResetPassword = {};
|
||||
const ResetPassword = {};
|
||||
|
||||
ResetPassword.init = function () {
|
||||
var inputEl = $('#email');
|
||||
var errorEl = $('#error');
|
||||
var successEl = $('#success');
|
||||
const inputEl = $('#email');
|
||||
const errorEl = $('#error');
|
||||
const successEl = $('#success');
|
||||
|
||||
$('#reset').on('click', function () {
|
||||
if (inputEl.val() && inputEl.val().indexOf('@') !== -1) {
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
|
||||
define('forum/reset_code', ['zxcvbn'], function (zxcvbn) {
|
||||
var ResetCode = {};
|
||||
const ResetCode = {};
|
||||
|
||||
ResetCode.init = function () {
|
||||
var reset_code = ajaxify.data.code;
|
||||
const reset_code = ajaxify.data.code;
|
||||
|
||||
var resetEl = $('#reset');
|
||||
var password = $('#password');
|
||||
var repeat = $('#repeat');
|
||||
const resetEl = $('#reset');
|
||||
const password = $('#password');
|
||||
const repeat = $('#repeat');
|
||||
|
||||
resetEl.on('click', function () {
|
||||
var strength = zxcvbn(password.val());
|
||||
const strength = zxcvbn(password.val());
|
||||
if (password.val().length < ajaxify.data.minimumPasswordLength) {
|
||||
$('#notice').removeClass('hidden');
|
||||
$('#notice strong').translateText('[[reset_password:password_too_short]]');
|
||||
|
||||
@@ -7,12 +7,12 @@ define('forum/search', [
|
||||
'storage',
|
||||
'hooks',
|
||||
], function (searchModule, autocomplete, storage, hooks) {
|
||||
var Search = {};
|
||||
const Search = {};
|
||||
|
||||
Search.init = function () {
|
||||
var searchQuery = $('#results').attr('data-search-query');
|
||||
const searchQuery = $('#results').attr('data-search-query');
|
||||
|
||||
var searchIn = $('#search-in');
|
||||
const searchIn = $('#search-in');
|
||||
|
||||
searchIn.on('change', function () {
|
||||
updateFormItemVisiblity(searchIn.val());
|
||||
@@ -36,8 +36,8 @@ define('forum/search', [
|
||||
};
|
||||
|
||||
function getSearchDataFromDOM() {
|
||||
var form = $('#advanced-search');
|
||||
var searchData = {
|
||||
const form = $('#advanced-search');
|
||||
const searchData = {
|
||||
in: $('#search-in').val(),
|
||||
};
|
||||
searchData.term = $('#search-input').val();
|
||||
@@ -65,17 +65,17 @@ define('forum/search', [
|
||||
}
|
||||
|
||||
function updateFormItemVisiblity(searchIn) {
|
||||
var hide = searchIn.indexOf('posts') === -1 && searchIn.indexOf('titles') === -1;
|
||||
const hide = searchIn.indexOf('posts') === -1 && searchIn.indexOf('titles') === -1;
|
||||
$('.post-search-item').toggleClass('hide', hide);
|
||||
}
|
||||
|
||||
function fillOutForm() {
|
||||
var params = utils.params({
|
||||
const params = utils.params({
|
||||
disableToType: true,
|
||||
});
|
||||
|
||||
var searchData = searchModule.getSearchPreferences();
|
||||
var formData = utils.merge(searchData, params);
|
||||
const searchData = searchModule.getSearchPreferences();
|
||||
const formData = utils.merge(searchData, params);
|
||||
|
||||
if (formData) {
|
||||
if (ajaxify.data.term) {
|
||||
@@ -127,8 +127,8 @@ define('forum/search', [
|
||||
$('#post-sort-direction').val(formData.sortDirection || 'desc');
|
||||
|
||||
if (formData.showAs) {
|
||||
var isTopic = formData.showAs === 'topics';
|
||||
var isPost = formData.showAs === 'posts';
|
||||
const isTopic = formData.showAs === 'topics';
|
||||
const isPost = formData.showAs === 'posts';
|
||||
$('#show-as-topics').prop('checked', isTopic).parent().toggleClass('active', isTopic);
|
||||
$('#show-as-posts').prop('checked', isPost).parent().toggleClass('active', isPost);
|
||||
}
|
||||
@@ -148,7 +148,7 @@ define('forum/search', [
|
||||
|
||||
$('#clear-preferences').on('click', function () {
|
||||
storage.removeItem('search-preferences');
|
||||
var query = $('#search-input').val();
|
||||
const query = $('#search-input').val();
|
||||
$('#advanced-search')[0].reset();
|
||||
$('#search-input').val(query);
|
||||
app.alertSuccess('[[search:search-preferences-cleared]]');
|
||||
@@ -157,7 +157,7 @@ define('forum/search', [
|
||||
}
|
||||
|
||||
function enableAutoComplete() {
|
||||
var userEl = $('#posted-by-user');
|
||||
const userEl = $('#posted-by-user');
|
||||
userEl.tagsinput({
|
||||
confirmKeys: [13, 44],
|
||||
trimValue: true,
|
||||
@@ -166,7 +166,7 @@ define('forum/search', [
|
||||
autocomplete.user(userEl.siblings('.bootstrap-tagsinput').find('input'));
|
||||
}
|
||||
|
||||
var tagEl = $('#has-tags');
|
||||
const tagEl = $('#has-tags');
|
||||
tagEl.tagsinput({
|
||||
confirmKeys: [13, 44],
|
||||
trimValue: true,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
define('forum/tag', ['topicList', 'forum/infinitescroll'], function (topicList) {
|
||||
var Tag = {};
|
||||
const Tag = {};
|
||||
|
||||
Tag.init = function () {
|
||||
app.enterRoom('tags');
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
define('forum/tags', ['forum/infinitescroll'], function (infinitescroll) {
|
||||
var Tags = {};
|
||||
const Tags = {};
|
||||
|
||||
Tags.init = function () {
|
||||
app.enterRoom('tags');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
define('forum/top', ['topicList'], function (topicList) {
|
||||
var Top = {};
|
||||
const Top = {};
|
||||
|
||||
Top.init = function () {
|
||||
app.enterRoom('top_topics');
|
||||
|
||||
@@ -18,8 +18,8 @@ define('forum/topic', [
|
||||
events, posts, images, navigator, sort,
|
||||
components, storage, hooks
|
||||
) {
|
||||
var Topic = {};
|
||||
var currentUrl = '';
|
||||
const Topic = {};
|
||||
let currentUrl = '';
|
||||
|
||||
$(window).on('action:ajaxify.start', function (ev, data) {
|
||||
if (Topic.replaceURLTimeout) {
|
||||
@@ -42,7 +42,7 @@ define('forum/topic', [
|
||||
});
|
||||
|
||||
Topic.init = function () {
|
||||
var tid = ajaxify.data.tid;
|
||||
const tid = ajaxify.data.tid;
|
||||
currentUrl = ajaxify.currentPage;
|
||||
hooks.fire('action:topic.loading');
|
||||
|
||||
@@ -95,8 +95,8 @@ define('forum/topic', [
|
||||
if (config.topicSearchEnabled) {
|
||||
require(['mousetrap'], function (mousetrap) {
|
||||
mousetrap.bind(['command+f', 'ctrl+f'], function (e) {
|
||||
var match = ajaxify.currentPage.match(/^topic\/([\d]+)/);
|
||||
var tid;
|
||||
const match = ajaxify.currentPage.match(/^topic\/([\d]+)/);
|
||||
let tid;
|
||||
if (match) {
|
||||
e.preventDefault();
|
||||
tid = match[1];
|
||||
@@ -124,13 +124,13 @@ define('forum/topic', [
|
||||
|
||||
function handleBookmark(tid) {
|
||||
if (window.location.hash) {
|
||||
var el = $(utils.escapeHTML(window.location.hash));
|
||||
const el = $(utils.escapeHTML(window.location.hash));
|
||||
if (el.length) {
|
||||
return navigator.scrollToElement(el, true, 0);
|
||||
}
|
||||
}
|
||||
var bookmark = ajaxify.data.bookmark || storage.getItem('topic:' + tid + ':bookmark');
|
||||
var postIndex = ajaxify.data.postIndex;
|
||||
const bookmark = ajaxify.data.bookmark || storage.getItem('topic:' + tid + ':bookmark');
|
||||
const postIndex = ajaxify.data.postIndex;
|
||||
|
||||
if (postIndex > 1) {
|
||||
if (components.get('post/anchor', postIndex - 1).length) {
|
||||
@@ -160,19 +160,19 @@ define('forum/topic', [
|
||||
|
||||
function addBlockQuoteHandler() {
|
||||
components.get('topic').on('click', 'blockquote .toggle', function () {
|
||||
var blockQuote = $(this).parent('blockquote');
|
||||
var toggle = $(this);
|
||||
const blockQuote = $(this).parent('blockquote');
|
||||
const toggle = $(this);
|
||||
blockQuote.toggleClass('uncollapsed');
|
||||
var collapsed = !blockQuote.hasClass('uncollapsed');
|
||||
const collapsed = !blockQuote.hasClass('uncollapsed');
|
||||
toggle.toggleClass('fa-angle-down', collapsed).toggleClass('fa-angle-up', !collapsed);
|
||||
});
|
||||
}
|
||||
|
||||
function addParentHandler() {
|
||||
components.get('topic').on('click', '[component="post/parent"]', function (e) {
|
||||
var toPid = $(this).attr('data-topid');
|
||||
const toPid = $(this).attr('data-topid');
|
||||
|
||||
var toPost = $('[component="topic"]>[component="post"][data-pid="' + toPid + '"]');
|
||||
const toPost = $('[component="topic"]>[component="post"][data-pid="' + toPid + '"]');
|
||||
if (toPost.length) {
|
||||
e.preventDefault();
|
||||
navigator.scrollToIndex(toPost.attr('data-index'), true);
|
||||
@@ -183,18 +183,18 @@ define('forum/topic', [
|
||||
|
||||
function addDropupHandler() {
|
||||
// Locate all dropdowns
|
||||
var target = $('#content .dropdown-menu').parent();
|
||||
const target = $('#content .dropdown-menu').parent();
|
||||
|
||||
// Toggle dropup if past 50% of screen
|
||||
$(target).on('show.bs.dropdown', function () {
|
||||
var dropUp = this.getBoundingClientRect().top > ($(window).height() / 2);
|
||||
const dropUp = this.getBoundingClientRect().top > ($(window).height() / 2);
|
||||
$(this).toggleClass('dropup', dropUp);
|
||||
});
|
||||
}
|
||||
|
||||
function addRepliesHandler() {
|
||||
$('[component="topic"]').on('click', '[component="post/reply-count"]', function () {
|
||||
var btn = $(this);
|
||||
const btn = $(this);
|
||||
require(['forum/topic/replies'], function (replies) {
|
||||
replies.init(btn);
|
||||
});
|
||||
@@ -202,7 +202,7 @@ define('forum/topic', [
|
||||
}
|
||||
|
||||
function updateTopicTitle() {
|
||||
var span = components.get('navbar/title').find('span');
|
||||
const span = components.get('navbar/title').find('span');
|
||||
if ($(window).scrollTop() > 50 && span.hasClass('hidden')) {
|
||||
span.html(ajaxify.data.title).removeClass('hidden');
|
||||
} else if ($(window).scrollTop() <= 50 && !span.hasClass('hidden')) {
|
||||
@@ -214,7 +214,7 @@ define('forum/topic', [
|
||||
}
|
||||
|
||||
Topic.navigatorCallback = function (index, elementCount) {
|
||||
var path = ajaxify.removeRelativePath(window.location.pathname.slice(1));
|
||||
const path = ajaxify.removeRelativePath(window.location.pathname.slice(1));
|
||||
if (!path.startsWith('topic')) {
|
||||
return;
|
||||
}
|
||||
@@ -223,7 +223,7 @@ define('forum/topic', [
|
||||
return;
|
||||
}
|
||||
|
||||
var newUrl = 'topic/' + ajaxify.data.slug + (index > 1 ? ('/' + index) : '');
|
||||
const newUrl = 'topic/' + ajaxify.data.slug + (index > 1 ? ('/' + index) : '');
|
||||
if (newUrl !== currentUrl) {
|
||||
if (Topic.replaceURLTimeout) {
|
||||
clearTimeout(Topic.replaceURLTimeout);
|
||||
@@ -239,7 +239,7 @@ define('forum/topic', [
|
||||
|
||||
Topic.replaceURLTimeout = 0;
|
||||
if (ajaxify.data.updateUrlWithPostIndex && history.replaceState) {
|
||||
var search = window.location.search || '';
|
||||
let search = window.location.search || '';
|
||||
if (!config.usePagination) {
|
||||
search = (search && !/^\?page=\d+$/.test(search) ? search : '');
|
||||
}
|
||||
@@ -253,8 +253,8 @@ define('forum/topic', [
|
||||
};
|
||||
|
||||
function updateUserBookmark(index) {
|
||||
var bookmarkKey = 'topic:' + ajaxify.data.tid + ':bookmark';
|
||||
var currentBookmark = ajaxify.data.bookmark || storage.getItem(bookmarkKey);
|
||||
const bookmarkKey = 'topic:' + ajaxify.data.tid + ':bookmark';
|
||||
const currentBookmark = ajaxify.data.bookmark || storage.getItem(bookmarkKey);
|
||||
if (config.topicPostSort === 'newest_to_oldest') {
|
||||
index = Math.max(1, ajaxify.data.postcount - index + 2);
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ define('forum/topic/change-owner', [
|
||||
'postSelect',
|
||||
'autocomplete',
|
||||
], function (components, postSelect, autocomplete) {
|
||||
var ChangeOwner = {};
|
||||
const ChangeOwner = {};
|
||||
|
||||
var modal;
|
||||
var commit;
|
||||
var toUid = 0;
|
||||
let modal;
|
||||
let commit;
|
||||
let toUid = 0;
|
||||
ChangeOwner.init = function (postEl) {
|
||||
if (modal) {
|
||||
return;
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
|
||||
define('forum/topic/delete-posts', ['components', 'postSelect'], function (components, postSelect) {
|
||||
var DeletePosts = {};
|
||||
var modal;
|
||||
var deleteBtn;
|
||||
var purgeBtn;
|
||||
var tid;
|
||||
const DeletePosts = {};
|
||||
let modal;
|
||||
let deleteBtn;
|
||||
let purgeBtn;
|
||||
let tid;
|
||||
|
||||
DeletePosts.init = function () {
|
||||
tid = ajaxify.data.tid;
|
||||
|
||||
@@ -12,9 +12,9 @@ define('forum/topic/events', [
|
||||
'benchpress',
|
||||
'hooks',
|
||||
], function (postTools, threadTools, posts, images, components, translator, Benchpress, hooks) {
|
||||
var Events = {};
|
||||
const Events = {};
|
||||
|
||||
var events = {
|
||||
const events = {
|
||||
'event:user_status_change': onUserStatusChange,
|
||||
'event:voted': updatePostVotesAndUserReputation,
|
||||
'event:bookmarked': updateBookmarkCount,
|
||||
@@ -50,7 +50,7 @@ define('forum/topic/events', [
|
||||
|
||||
Events.init = function () {
|
||||
Events.removeListeners();
|
||||
for (var eventName in events) {
|
||||
for (const eventName in events) {
|
||||
if (events.hasOwnProperty(eventName)) {
|
||||
socket.on(eventName, events[eventName]);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ define('forum/topic/events', [
|
||||
};
|
||||
|
||||
Events.removeListeners = function () {
|
||||
for (var eventName in events) {
|
||||
for (const eventName in events) {
|
||||
if (events.hasOwnProperty(eventName)) {
|
||||
socket.removeListener(eventName, events[eventName]);
|
||||
}
|
||||
@@ -70,10 +70,10 @@ define('forum/topic/events', [
|
||||
}
|
||||
|
||||
function updatePostVotesAndUserReputation(data) {
|
||||
var votes = $('[data-pid="' + data.post.pid + '"] [component="post/vote-count"]').filter(function (index, el) {
|
||||
const votes = $('[data-pid="' + data.post.pid + '"] [component="post/vote-count"]').filter(function (index, el) {
|
||||
return parseInt($(el).closest('[data-pid]').attr('data-pid'), 10) === parseInt(data.post.pid, 10);
|
||||
});
|
||||
var reputationElements = $('.reputation[data-uid="' + data.post.uid + '"]');
|
||||
const reputationElements = $('.reputation[data-uid="' + data.post.uid + '"]');
|
||||
votes.html(data.post.votes).attr('data-votes', data.post.votes);
|
||||
reputationElements.html(data.user.reputation).attr('data-reputation', data.user.reputation);
|
||||
}
|
||||
@@ -104,16 +104,16 @@ define('forum/topic/events', [
|
||||
if (!data || !data.post || parseInt(data.post.tid, 10) !== parseInt(ajaxify.data.tid, 10)) {
|
||||
return;
|
||||
}
|
||||
var editedPostEl = components.get('post/content', data.post.pid).filter(function (index, el) {
|
||||
const editedPostEl = components.get('post/content', data.post.pid).filter(function (index, el) {
|
||||
return parseInt($(el).closest('[data-pid]').attr('data-pid'), 10) === parseInt(data.post.pid, 10);
|
||||
});
|
||||
|
||||
var editorEl = $('[data-pid="' + data.post.pid + '"] [component="post/editor"]').filter(function (index, el) {
|
||||
const editorEl = $('[data-pid="' + data.post.pid + '"] [component="post/editor"]').filter(function (index, el) {
|
||||
return parseInt($(el).closest('[data-pid]').attr('data-pid'), 10) === parseInt(data.post.pid, 10);
|
||||
});
|
||||
var topicTitle = components.get('topic/title');
|
||||
var navbarTitle = components.get('navbar/title').find('span');
|
||||
var breadCrumb = components.get('breadcrumb/current');
|
||||
const topicTitle = components.get('topic/title');
|
||||
const navbarTitle = components.get('navbar/title').find('span');
|
||||
const breadCrumb = components.get('breadcrumb/current');
|
||||
|
||||
if (data.topic.rescheduled) {
|
||||
return ajaxify.go('topic/' + data.topic.slug, null, true);
|
||||
@@ -121,7 +121,7 @@ define('forum/topic/events', [
|
||||
|
||||
if (topicTitle.length && data.topic.title && data.topic.renamed) {
|
||||
ajaxify.data.title = data.topic.title;
|
||||
var newUrl = 'topic/' + data.topic.slug + (window.location.search ? window.location.search : '');
|
||||
const newUrl = 'topic/' + data.topic.slug + (window.location.search ? window.location.search : '');
|
||||
history.replaceState({ url: newUrl }, null, window.location.protocol + '//' + window.location.host + config.relative_path + '/' + newUrl);
|
||||
|
||||
topicTitle.fadeOut(250, function () {
|
||||
@@ -143,7 +143,7 @@ define('forum/topic/events', [
|
||||
posts.addBlockquoteEllipses(editedPostEl.parent());
|
||||
editedPostEl.fadeIn(250);
|
||||
|
||||
var editData = {
|
||||
const editData = {
|
||||
editor: data.editor,
|
||||
editedISO: utils.toISOString(data.post.edited),
|
||||
};
|
||||
@@ -160,7 +160,7 @@ define('forum/topic/events', [
|
||||
|
||||
if (data.topic.tags && tagsUpdated(data.topic.tags)) {
|
||||
Benchpress.render('partials/topic/tags', { tags: data.topic.tags }).then(function (html) {
|
||||
var tags = $('.tags');
|
||||
const tags = $('.tags');
|
||||
|
||||
tags.fadeOut(250, function () {
|
||||
tags.html(html).fadeIn(250);
|
||||
@@ -176,7 +176,7 @@ define('forum/topic/events', [
|
||||
return true;
|
||||
}
|
||||
|
||||
for (var i = 0; i < tags.length; i += 1) {
|
||||
for (let i = 0; i < tags.length; i += 1) {
|
||||
if (!$('.tags .tag-item[data-tag="' + tags[i].value + '"]').length) {
|
||||
return true;
|
||||
}
|
||||
@@ -200,14 +200,14 @@ define('forum/topic/events', [
|
||||
}
|
||||
|
||||
function togglePostDeleteState(data) {
|
||||
var postEl = components.get('post', 'pid', data.pid);
|
||||
const postEl = components.get('post', 'pid', data.pid);
|
||||
|
||||
if (!postEl.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
postEl.toggleClass('deleted');
|
||||
var isDeleted = postEl.hasClass('deleted');
|
||||
const isDeleted = postEl.hasClass('deleted');
|
||||
postTools.toggle(data.pid, isDeleted);
|
||||
|
||||
if (!ajaxify.data.privileges.isAdminOrMod && parseInt(data.uid, 10) !== parseInt(app.user.uid, 10)) {
|
||||
@@ -221,7 +221,7 @@ define('forum/topic/events', [
|
||||
}
|
||||
|
||||
function togglePostBookmark(data) {
|
||||
var el = $('[data-pid="' + data.post.pid + '"] [component="post/bookmark"]').filter(function (index, el) {
|
||||
const el = $('[data-pid="' + data.post.pid + '"] [component="post/bookmark"]').filter(function (index, el) {
|
||||
return parseInt($(el).closest('[data-pid]').attr('data-pid'), 10) === parseInt(data.post.pid, 10);
|
||||
});
|
||||
if (!el.length) {
|
||||
@@ -235,7 +235,7 @@ define('forum/topic/events', [
|
||||
}
|
||||
|
||||
function togglePostVote(data) {
|
||||
var post = $('[data-pid="' + data.post.pid + '"]');
|
||||
const post = $('[data-pid="' + data.post.pid + '"]');
|
||||
post.find('[component="post/upvote"]').filter(function (index, el) {
|
||||
return parseInt($(el).closest('[data-pid]').attr('data-pid'), 10) === parseInt(data.post.pid, 10);
|
||||
}).toggleClass('upvoted', data.upvote);
|
||||
@@ -245,7 +245,7 @@ define('forum/topic/events', [
|
||||
}
|
||||
|
||||
function onNewNotification(data) {
|
||||
var tid = ajaxify.data.tid;
|
||||
const tid = ajaxify.data.tid;
|
||||
if (data && data.tid && parseInt(data.tid, 10) === parseInt(tid, 10)) {
|
||||
socket.emit('topics.markTopicNotificationsRead', [tid]);
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
|
||||
define('forum/topic/fork', ['components', 'postSelect'], function (components, postSelect) {
|
||||
var Fork = {};
|
||||
var forkModal;
|
||||
var forkCommit;
|
||||
var fromTid;
|
||||
const Fork = {};
|
||||
let forkModal;
|
||||
let forkCommit;
|
||||
let fromTid;
|
||||
|
||||
Fork.init = function () {
|
||||
fromTid = ajaxify.data.tid;
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
|
||||
define('forum/topic/images', [], function () {
|
||||
var Images = {};
|
||||
const Images = {};
|
||||
|
||||
Images.wrapImagesInLinks = function (posts) {
|
||||
posts.find('[component="post/content"] img:not(.emoji)').each(function () {
|
||||
var $this = $(this);
|
||||
var src = $this.attr('src') || '';
|
||||
var alt = $this.attr('alt') || '';
|
||||
var suffixRegex = /-resized(\.[\w]+)?$/;
|
||||
const $this = $(this);
|
||||
let src = $this.attr('src') || '';
|
||||
const alt = $this.attr('alt') || '';
|
||||
const suffixRegex = /-resized(\.[\w]+)?$/;
|
||||
|
||||
if (src === 'about:blank') {
|
||||
return;
|
||||
@@ -18,9 +18,9 @@ define('forum/topic/images', [], function () {
|
||||
if (utils.isRelativeUrl(src) && suffixRegex.test(src)) {
|
||||
src = src.replace(suffixRegex, '$1');
|
||||
}
|
||||
var srcExt = src.split('.').slice(1).pop();
|
||||
var altFilename = alt.split('/').pop();
|
||||
var altExt = altFilename.split('.').slice(1).pop();
|
||||
const srcExt = src.split('.').slice(1).pop();
|
||||
const altFilename = alt.split('/').pop();
|
||||
const altExt = altFilename.split('.').slice(1).pop();
|
||||
|
||||
if (!$this.parent().is('a')) {
|
||||
$this.wrap('<a href="' + src + '" ' +
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
|
||||
define('forum/topic/merge', function () {
|
||||
var Merge = {};
|
||||
var modal;
|
||||
var mergeBtn;
|
||||
const Merge = {};
|
||||
let modal;
|
||||
let mergeBtn;
|
||||
|
||||
var selectedTids = {};
|
||||
let selectedTids = {};
|
||||
|
||||
Merge.init = function (callback) {
|
||||
callback = callback || function () {};
|
||||
@@ -56,7 +56,7 @@ define('forum/topic/merge', function () {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
var title = topicData ? topicData.title : 'No title';
|
||||
const title = topicData ? topicData.title : 'No title';
|
||||
if (selectedTids[tid]) {
|
||||
delete selectedTids[tid];
|
||||
} else {
|
||||
@@ -72,7 +72,7 @@ define('forum/topic/merge', function () {
|
||||
if (!modal) {
|
||||
return;
|
||||
}
|
||||
var tid = $(this).parents('[component="category/topic"]').attr('data-tid');
|
||||
const tid = $(this).parents('[component="category/topic"]').attr('data-tid');
|
||||
Merge.addTopic(tid);
|
||||
|
||||
ev.preventDefault();
|
||||
@@ -82,8 +82,8 @@ define('forum/topic/merge', function () {
|
||||
|
||||
function mergeTopics(btn) {
|
||||
btn.attr('disabled', true);
|
||||
var tids = Object.keys(selectedTids);
|
||||
var options = {};
|
||||
const tids = Object.keys(selectedTids);
|
||||
const options = {};
|
||||
if (modal.find('.merge-main-topic-radio').is(':checked')) {
|
||||
options.mainTid = modal.find('.merge-main-topic-select').val();
|
||||
} else if (modal.find('.merge-new-title-radio').is(':checked')) {
|
||||
@@ -104,12 +104,12 @@ define('forum/topic/merge', function () {
|
||||
if (!modal) {
|
||||
return;
|
||||
}
|
||||
var tids = Object.keys(selectedTids);
|
||||
const tids = Object.keys(selectedTids);
|
||||
tids.sort(function (a, b) {
|
||||
return a - b;
|
||||
});
|
||||
|
||||
var topics = tids.map(function (tid) {
|
||||
const topics = tids.map(function (tid) {
|
||||
return { tid: tid, title: selectedTids[tid] };
|
||||
});
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
define('forum/topic/move-post', [
|
||||
'components', 'postSelect', 'translator', 'alerts', 'api',
|
||||
], function (components, postSelect, translator, alerts, api) {
|
||||
var MovePost = {};
|
||||
const MovePost = {};
|
||||
|
||||
var moveModal;
|
||||
var moveCommit;
|
||||
var fromTid;
|
||||
let moveModal;
|
||||
let moveCommit;
|
||||
let fromTid;
|
||||
|
||||
MovePost.init = function (postEl) {
|
||||
if (moveModal) {
|
||||
@@ -40,7 +40,7 @@ define('forum/topic/move-post', [
|
||||
return;
|
||||
}
|
||||
moveCommit.attr('disabled', true);
|
||||
var data = {
|
||||
const data = {
|
||||
pids: postSelect.pids.slice(),
|
||||
tid: targetTid,
|
||||
};
|
||||
@@ -71,8 +71,8 @@ define('forum/topic/move-post', [
|
||||
if (!moveModal) {
|
||||
return;
|
||||
}
|
||||
var tidInput = moveModal.find('#topicId');
|
||||
var targetTid = null;
|
||||
const tidInput = moveModal.find('#topicId');
|
||||
let targetTid = null;
|
||||
if (ajaxify.data.template.topic && ajaxify.data.tid &&
|
||||
parseInt(ajaxify.data.tid, 10) !== fromTid
|
||||
) {
|
||||
@@ -85,7 +85,7 @@ define('forum/topic/move-post', [
|
||||
}
|
||||
|
||||
function getTargetTid() {
|
||||
var tidInput = moveModal.find('#topicId');
|
||||
const tidInput = moveModal.find('#topicId');
|
||||
if (tidInput.length && tidInput.val()) {
|
||||
return tidInput.val();
|
||||
}
|
||||
@@ -96,7 +96,7 @@ define('forum/topic/move-post', [
|
||||
if (!moveModal) {
|
||||
return;
|
||||
}
|
||||
var targetTid = getTargetTid();
|
||||
const targetTid = getTargetTid();
|
||||
if (postSelect.pids.length) {
|
||||
if (targetTid && parseInt(targetTid, 10) !== parseInt(fromTid, 10)) {
|
||||
api.get('/topics/' + targetTid, {}).then(function (data) {
|
||||
@@ -106,7 +106,7 @@ define('forum/topic/move-post', [
|
||||
if (data.scheduled) {
|
||||
return app.alertError('[[error:cant-move-posts-to-scheduled]]');
|
||||
}
|
||||
var translateStr = translator.compile('topic:x-posts-will-be-moved-to-y', postSelect.pids.length, data.title);
|
||||
const translateStr = translator.compile('topic:x-posts-will-be-moved-to-y', postSelect.pids.length, data.title);
|
||||
moveModal.find('#pids').translateHtml(translateStr);
|
||||
});
|
||||
} else {
|
||||
@@ -121,7 +121,7 @@ define('forum/topic/move-post', [
|
||||
if (!moveModal) {
|
||||
return;
|
||||
}
|
||||
var targetTid = getTargetTid();
|
||||
const targetTid = getTargetTid();
|
||||
if (postSelect.pids.length && targetTid &&
|
||||
parseInt(targetTid, 10) !== parseInt(fromTid, 10)
|
||||
) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user