mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-05 03:51:26 +01:00
Merge branch 'fix-some-code-lint' of https://github.com/HeeL/NodeBB into HeeL-fix-some-code-lint
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
"eqeqeq": "off",
|
||||
"camelcase": "off",
|
||||
"no-negated-condition": "off",
|
||||
"wrap-iife": "off",
|
||||
"one-var-declaration-per-line": "off",
|
||||
"new-cap": "off",
|
||||
"no-lonely-if": "off",
|
||||
@@ -57,7 +56,6 @@
|
||||
"indent": "off",
|
||||
"func-names": "off",
|
||||
"prefer-arrow-callback": "off",
|
||||
"space-before-function-paren": "off",
|
||||
"object-curly-spacing": "off",
|
||||
"no-var": "off",
|
||||
"no-shadow": "off",
|
||||
@@ -77,7 +75,6 @@
|
||||
"no-multi-spaces": "off",
|
||||
"quotes": "off",
|
||||
"keyword-spacing": "off",
|
||||
"space-infix-ops": "off",
|
||||
"no-plusplus": "off",
|
||||
"no-mixed-operators": "off",
|
||||
"semi": "off",
|
||||
|
||||
@@ -6,7 +6,7 @@ var fork = require('child_process').fork,
|
||||
incomplete = [];
|
||||
|
||||
|
||||
module.exports = function(grunt) {
|
||||
module.exports = function (grunt) {
|
||||
var args = [];
|
||||
if (!grunt.option('verbose')) {
|
||||
args.push('--log-level=info');
|
||||
@@ -34,7 +34,7 @@ module.exports = function(grunt) {
|
||||
fromFile = ['clientLess', 'acpLess', 'js', 'tpl'];
|
||||
}
|
||||
|
||||
fromFile = fromFile.filter(function(ext) {
|
||||
fromFile = fromFile.filter(function (ext) {
|
||||
return incomplete.indexOf(ext) === -1;
|
||||
});
|
||||
|
||||
@@ -44,7 +44,7 @@ module.exports = function(grunt) {
|
||||
worker.kill();
|
||||
worker = fork('app.js', updateArgs, { env: env });
|
||||
|
||||
worker.on('message', function() {
|
||||
worker.on('message', function () {
|
||||
if (incomplete.length) {
|
||||
incomplete = [];
|
||||
|
||||
|
||||
26
app.js
26
app.js
@@ -36,7 +36,7 @@ global.env = process.env.NODE_ENV || 'production';
|
||||
winston.remove(winston.transports.Console);
|
||||
winston.add(winston.transports.Console, {
|
||||
colorize: true,
|
||||
timestamp: function() {
|
||||
timestamp: function () {
|
||||
var date = new Date();
|
||||
return date.getDate() + '/' + (date.getMonth() + 1) + ' ' + date.toTimeString().substr(0,5) + ' [' + global.process.pid + ']';
|
||||
},
|
||||
@@ -146,7 +146,7 @@ function start() {
|
||||
process.on('SIGTERM', shutdown);
|
||||
process.on('SIGINT', shutdown);
|
||||
process.on('SIGHUP', restart);
|
||||
process.on('message', function(message) {
|
||||
process.on('message', function (message) {
|
||||
if (typeof message !== 'object') {
|
||||
return;
|
||||
}
|
||||
@@ -173,7 +173,7 @@ function start() {
|
||||
}
|
||||
});
|
||||
|
||||
process.on('uncaughtException', function(err) {
|
||||
process.on('uncaughtException', function (err) {
|
||||
winston.error(err.stack);
|
||||
console.log(err.stack);
|
||||
|
||||
@@ -184,10 +184,10 @@ function start() {
|
||||
async.waterfall([
|
||||
async.apply(db.init),
|
||||
async.apply(db.checkCompatibility),
|
||||
function(next) {
|
||||
function (next) {
|
||||
require('./src/meta').configs.init(next);
|
||||
},
|
||||
function(next) {
|
||||
function (next) {
|
||||
if (nconf.get('dep-check') === undefined || nconf.get('dep-check') !== false) {
|
||||
require('./src/meta').dependencies.check(next);
|
||||
} else {
|
||||
@@ -195,10 +195,10 @@ function start() {
|
||||
setImmediate(next);
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
function (next) {
|
||||
require('./src/upgrade').check(next);
|
||||
},
|
||||
function(next) {
|
||||
function (next) {
|
||||
var webserver = require('./src/webserver');
|
||||
require('./src/socket.io').init(webserver.server);
|
||||
|
||||
@@ -209,7 +209,7 @@ function start() {
|
||||
|
||||
webserver.listen();
|
||||
}
|
||||
], function(err) {
|
||||
], function (err) {
|
||||
if (err) {
|
||||
switch(err.message) {
|
||||
case 'schema-out-of-date':
|
||||
@@ -251,7 +251,7 @@ function setup() {
|
||||
install.setup(function (err, data) {
|
||||
var separator = ' ';
|
||||
if (process.stdout.columns > 10) {
|
||||
for(var x=0,cols=process.stdout.columns-10;x<cols;x++) {
|
||||
for(var x = 0,cols = process.stdout.columns - 10;x < cols;x++) {
|
||||
separator += '=';
|
||||
}
|
||||
}
|
||||
@@ -280,7 +280,7 @@ function setup() {
|
||||
}
|
||||
|
||||
function upgrade() {
|
||||
require('./src/database').init(function(err) {
|
||||
require('./src/database').init(function (err) {
|
||||
if (err) {
|
||||
winston.error(err.stack);
|
||||
process.exit();
|
||||
@@ -292,7 +292,7 @@ function upgrade() {
|
||||
}
|
||||
|
||||
function activate() {
|
||||
require('./src/database').init(function(err) {
|
||||
require('./src/database').init(function (err) {
|
||||
if (err) {
|
||||
winston.error(err.stack);
|
||||
process.exit(1);
|
||||
@@ -308,7 +308,7 @@ function activate() {
|
||||
}
|
||||
|
||||
function listPlugins() {
|
||||
require('./src/database').init(function(err) {
|
||||
require('./src/database').init(function (err) {
|
||||
if (err) {
|
||||
winston.error(err.stack);
|
||||
process.exit(1);
|
||||
@@ -316,7 +316,7 @@ function listPlugins() {
|
||||
|
||||
var db = require('./src/database');
|
||||
|
||||
db.getSortedSetRange('plugins:active', 0, -1, function(err, plugins) {
|
||||
db.getSortedSetRange('plugins:active', 0, -1, function (err, plugins) {
|
||||
if (err) {
|
||||
winston.error(err.stack);
|
||||
process.exit(1);
|
||||
|
||||
@@ -5,7 +5,7 @@ var bcrypt = require('bcryptjs'),
|
||||
async = require('async');
|
||||
|
||||
|
||||
process.on('message', function(msg) {
|
||||
process.on('message', function (msg) {
|
||||
if (msg.type === 'hash') {
|
||||
hashPassword(msg.password, msg.rounds);
|
||||
} else if (msg.type === 'compare') {
|
||||
@@ -15,10 +15,10 @@ process.on('message', function(msg) {
|
||||
|
||||
function hashPassword(password, rounds) {
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
function (next) {
|
||||
bcrypt.genSalt(parseInt(rounds, 10), next);
|
||||
},
|
||||
function(salt, next) {
|
||||
function (salt, next) {
|
||||
bcrypt.hash(password, salt, next);
|
||||
}
|
||||
], done);
|
||||
|
||||
@@ -9,7 +9,7 @@ var questions = {
|
||||
mongo: require('../src/database/mongo').questions
|
||||
};
|
||||
|
||||
module.exports = function(config, callback) {
|
||||
module.exports = function (config, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
process.stdout.write('\n');
|
||||
@@ -74,7 +74,7 @@ function saveDatabaseConfig(config, databaseConfig, callback) {
|
||||
}
|
||||
|
||||
var allQuestions = questions.redis.concat(questions.mongo);
|
||||
for (var x=0; x<allQuestions.length; x++) {
|
||||
for (var x = 0; x < allQuestions.length; x++) {
|
||||
delete config[allQuestions[x].name];
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ var server;
|
||||
winston.add(winston.transports.File, {
|
||||
filename: 'logs/webinstall.log',
|
||||
colorize: true,
|
||||
timestamp: function() {
|
||||
timestamp: function () {
|
||||
var date = new Date();
|
||||
return date.getDate() + '/' + (date.getMonth() + 1) + ' ' + date.toTimeString().substr(0,5) + ' [' + global.process.pid + ']';
|
||||
},
|
||||
@@ -30,7 +30,7 @@ var scripts = [
|
||||
'public/src/installer/install.js'
|
||||
];
|
||||
|
||||
web.install = function(port) {
|
||||
web.install = function (port) {
|
||||
port = port || 4567;
|
||||
winston.info('Launching web installer on port', port);
|
||||
|
||||
@@ -42,7 +42,7 @@ web.install = function(port) {
|
||||
extended: true
|
||||
}));
|
||||
|
||||
async.parallel([compileLess, compileJS], function() {
|
||||
async.parallel([compileLess, compileJS], function () {
|
||||
setupRoutes();
|
||||
launchExpress(port);
|
||||
});
|
||||
@@ -50,7 +50,7 @@ web.install = function(port) {
|
||||
|
||||
|
||||
function launchExpress(port) {
|
||||
server = app.listen(port, function() {
|
||||
server = app.listen(port, function () {
|
||||
winston.info('Web installer listening on http://%s:%s', '0.0.0.0', port);
|
||||
});
|
||||
}
|
||||
@@ -63,7 +63,7 @@ function setupRoutes() {
|
||||
|
||||
function welcome(req, res) {
|
||||
var dbs = ['redis', 'mongo'];
|
||||
var databases = dbs.map(function(el) {
|
||||
var databases = dbs.map(function (el) {
|
||||
return {
|
||||
name: el,
|
||||
questions: require('../src/database/' + el).questions
|
||||
@@ -93,7 +93,7 @@ function install(req, res) {
|
||||
env: process.env
|
||||
});
|
||||
|
||||
child.on('close', function(data) {
|
||||
child.on('close', function (data) {
|
||||
if (data === 0) {
|
||||
res.locals.success = true;
|
||||
} else {
|
||||
@@ -129,12 +129,12 @@ function compileLess(callback) {
|
||||
return callback(false);
|
||||
}
|
||||
|
||||
fs.readFile(path.join(__dirname, '../public/less/install.less'), function(err, style) {
|
||||
fs.readFile(path.join(__dirname, '../public/less/install.less'), function (err, style) {
|
||||
if (err) {
|
||||
return winston.error('Unable to read LESS install file: ', err);
|
||||
}
|
||||
|
||||
less.render(style.toString(), function(err, css) {
|
||||
less.render(style.toString(), function (err, css) {
|
||||
if(err) {
|
||||
return winston.error('Unable to compile LESS: ', err);
|
||||
}
|
||||
@@ -151,7 +151,7 @@ function compileJS(callback) {
|
||||
}
|
||||
|
||||
var scriptPath = path.join(__dirname, '..');
|
||||
var result = uglify.minify(scripts.map(function(script) {
|
||||
var result = uglify.minify(scripts.map(function (script) {
|
||||
return path.join(scriptPath, script);
|
||||
}));
|
||||
|
||||
|
||||
42
loader.js
42
loader.js
@@ -33,9 +33,9 @@ var pidFilePath = __dirname + '/pidfile',
|
||||
templatesCompiled: false
|
||||
};
|
||||
|
||||
Loader.init = function(callback) {
|
||||
Loader.init = function (callback) {
|
||||
if (silent) {
|
||||
console.log = function() {
|
||||
console.log = function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
output.write(args.join(' ') + '\n');
|
||||
};
|
||||
@@ -47,7 +47,7 @@ Loader.init = function(callback) {
|
||||
callback();
|
||||
};
|
||||
|
||||
Loader.displayStartupMessages = function(callback) {
|
||||
Loader.displayStartupMessages = function (callback) {
|
||||
console.log('');
|
||||
console.log('NodeBB v' + pkg.version + ' Copyright (C) 2013-2014 NodeBB Inc.');
|
||||
console.log('This program comes with ABSOLUTELY NO WARRANTY.');
|
||||
@@ -57,25 +57,25 @@ Loader.displayStartupMessages = function(callback) {
|
||||
callback();
|
||||
};
|
||||
|
||||
Loader.addWorkerEvents = function(worker) {
|
||||
Loader.addWorkerEvents = function (worker) {
|
||||
|
||||
worker.on('exit', function(code, signal) {
|
||||
worker.on('exit', function (code, signal) {
|
||||
if (code !== 0) {
|
||||
if (Loader.timesStarted < numProcs*3) {
|
||||
if (Loader.timesStarted < numProcs * 3) {
|
||||
Loader.timesStarted++;
|
||||
if (Loader.crashTimer) {
|
||||
clearTimeout(Loader.crashTimer);
|
||||
}
|
||||
Loader.crashTimer = setTimeout(function() {
|
||||
Loader.crashTimer = setTimeout(function () {
|
||||
Loader.timesStarted = 0;
|
||||
}, 10000);
|
||||
} else {
|
||||
console.log(numProcs*3 + ' restarts in 10 seconds, most likely an error on startup. Halting.');
|
||||
console.log(numProcs * 3 + ' restarts in 10 seconds, most likely an error on startup. Halting.');
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
|
||||
console.log('[cluster] Child Process (' + worker.pid + ') has exited (code: ' + code + ', signal: ' + signal +')');
|
||||
console.log('[cluster] Child Process (' + worker.pid + ') has exited (code: ' + code + ', signal: ' + signal + ')');
|
||||
if (!(worker.suicide || code === 0)) {
|
||||
console.log('[cluster] Spinning up another process...');
|
||||
|
||||
@@ -83,7 +83,7 @@ Loader.addWorkerEvents = function(worker) {
|
||||
}
|
||||
});
|
||||
|
||||
worker.on('message', function(message) {
|
||||
worker.on('message', function (message) {
|
||||
if (message && typeof message === 'object' && message.action) {
|
||||
switch (message.action) {
|
||||
case 'ready':
|
||||
@@ -148,11 +148,11 @@ Loader.addWorkerEvents = function(worker) {
|
||||
});
|
||||
};
|
||||
|
||||
Loader.start = function(callback) {
|
||||
Loader.start = function (callback) {
|
||||
numProcs = getPorts().length;
|
||||
console.log('Clustering enabled: Spinning up ' + numProcs + ' process(es).\n');
|
||||
|
||||
for (var x=0; x<numProcs; ++x) {
|
||||
for (var x = 0; x < numProcs; ++x) {
|
||||
forkWorker(x, x === 0);
|
||||
}
|
||||
|
||||
@@ -205,22 +205,22 @@ function getPorts() {
|
||||
return port;
|
||||
}
|
||||
|
||||
Loader.restart = function() {
|
||||
Loader.restart = function () {
|
||||
killWorkers();
|
||||
nconf.remove('file');
|
||||
nconf.use('file', { file: path.join(__dirname, '/config.json') });
|
||||
Loader.start();
|
||||
};
|
||||
|
||||
Loader.reload = function() {
|
||||
workers.forEach(function(worker) {
|
||||
Loader.reload = function () {
|
||||
workers.forEach(function (worker) {
|
||||
worker.send({
|
||||
action: 'reload'
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Loader.stop = function() {
|
||||
Loader.stop = function () {
|
||||
killWorkers();
|
||||
|
||||
// Clean up the pidfile
|
||||
@@ -228,15 +228,15 @@ Loader.stop = function() {
|
||||
};
|
||||
|
||||
function killWorkers() {
|
||||
workers.forEach(function(worker) {
|
||||
workers.forEach(function (worker) {
|
||||
worker.suicide = true;
|
||||
worker.kill();
|
||||
});
|
||||
}
|
||||
|
||||
Loader.notifyWorkers = function(msg, worker_pid) {
|
||||
Loader.notifyWorkers = function (msg, worker_pid) {
|
||||
worker_pid = parseInt(worker_pid, 10);
|
||||
workers.forEach(function(worker) {
|
||||
workers.forEach(function (worker) {
|
||||
if (parseInt(worker.pid, 10) !== worker_pid) {
|
||||
try {
|
||||
worker.send(msg);
|
||||
@@ -247,7 +247,7 @@ Loader.notifyWorkers = function(msg, worker_pid) {
|
||||
});
|
||||
};
|
||||
|
||||
fs.open(path.join(__dirname, 'config.json'), 'r', function(err) {
|
||||
fs.open(path.join(__dirname, 'config.json'), 'r', function (err) {
|
||||
if (!err) {
|
||||
if (nconf.get('daemon') !== 'false' && nconf.get('daemon') !== false) {
|
||||
if (file.existsSync(pidFilePath)) {
|
||||
@@ -272,7 +272,7 @@ fs.open(path.join(__dirname, 'config.json'), 'r', function(err) {
|
||||
Loader.init,
|
||||
Loader.displayStartupMessages,
|
||||
Loader.start
|
||||
], function(err) {
|
||||
], function (err) {
|
||||
if (err) {
|
||||
console.log('[loader] Error during startup: ' + err.message);
|
||||
}
|
||||
|
||||
14
minifier.js
14
minifier.js
@@ -12,18 +12,18 @@ var Minifier = {
|
||||
/* Javascript */
|
||||
Minifier.js.minify = function (scripts, minify, callback) {
|
||||
|
||||
scripts = scripts.filter(function(file) {
|
||||
scripts = scripts.filter(function (file) {
|
||||
return file && file.endsWith('.js');
|
||||
});
|
||||
|
||||
async.filter(scripts, function(script, next) {
|
||||
file.exists(script, function(exists) {
|
||||
async.filter(scripts, function (script, next) {
|
||||
file.exists(script, function (exists) {
|
||||
if (!exists) {
|
||||
console.warn('[minifier] file not found, ' + script);
|
||||
}
|
||||
next(exists);
|
||||
});
|
||||
}, function(scripts) {
|
||||
}, function (scripts) {
|
||||
if (minify) {
|
||||
minifyScripts(scripts, callback);
|
||||
} else {
|
||||
@@ -32,10 +32,10 @@ Minifier.js.minify = function (scripts, minify, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
process.on('message', function(payload) {
|
||||
process.on('message', function (payload) {
|
||||
switch(payload.action) {
|
||||
case 'js':
|
||||
Minifier.js.minify(payload.scripts, payload.minify, function(minified/*, sourceMap*/) {
|
||||
Minifier.js.minify(payload.scripts, payload.minify, function (minified/*, sourceMap*/) {
|
||||
process.send({
|
||||
type: 'end',
|
||||
// sourceMap: sourceMap,
|
||||
@@ -65,7 +65,7 @@ function minifyScripts(scripts, callback) {
|
||||
}
|
||||
|
||||
function concatenateScripts(scripts, callback) {
|
||||
async.map(scripts, fs.readFile, function(err, scripts) {
|
||||
async.map(scripts, fs.readFile, function (err, scripts) {
|
||||
if (err) {
|
||||
process.send({
|
||||
type: 'error',
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
"use strict";
|
||||
/*global config, componentHandler, socket, app, bootbox, Slideout, NProgress*/
|
||||
|
||||
(function() {
|
||||
(function () {
|
||||
var logoutTimer = 0;
|
||||
function startLogoutTimer() {
|
||||
if (logoutTimer) {
|
||||
clearTimeout(logoutTimer);
|
||||
}
|
||||
|
||||
logoutTimer = setTimeout(function() {
|
||||
require(['translator'], function(translator) {
|
||||
translator.translate('[[login:logged-out-due-to-inactivity]]', function(translated) {
|
||||
logoutTimer = setTimeout(function () {
|
||||
require(['translator'], function (translator) {
|
||||
translator.translate('[[login:logged-out-due-to-inactivity]]', function (translated) {
|
||||
bootbox.alert({
|
||||
closeButton: false,
|
||||
message: translated,
|
||||
callback: function(){
|
||||
callback: function (){
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
@@ -23,7 +23,7 @@
|
||||
}, 3600000);
|
||||
}
|
||||
|
||||
$(window).on('action:ajaxify.end', function() {
|
||||
$(window).on('action:ajaxify.end', function () {
|
||||
showCorrectNavTab();
|
||||
startLogoutTimer();
|
||||
});
|
||||
@@ -35,11 +35,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
setupKeybindings();
|
||||
|
||||
if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
|
||||
require(['admin/modules/search'], function(search) {
|
||||
require(['admin/modules/search'], function (search) {
|
||||
search.init();
|
||||
});
|
||||
}
|
||||
@@ -51,7 +51,7 @@
|
||||
setupNProgress();
|
||||
});
|
||||
|
||||
$(window).on('action:ajaxify.contentLoaded', function(ev, data) {
|
||||
$(window).on('action:ajaxify.contentLoaded', function (ev, data) {
|
||||
selectMenuItem(data.url);
|
||||
setupRestartLinks();
|
||||
|
||||
@@ -59,28 +59,28 @@
|
||||
});
|
||||
|
||||
function setupNProgress() {
|
||||
$(window).on('action:ajaxify.start', function() {
|
||||
$(window).on('action:ajaxify.start', function () {
|
||||
NProgress.set(0.7);
|
||||
});
|
||||
|
||||
$(window).on('action:ajaxify.end', function() {
|
||||
$(window).on('action:ajaxify.end', function () {
|
||||
NProgress.done();
|
||||
});
|
||||
}
|
||||
|
||||
function setupKeybindings() {
|
||||
require(['mousetrap'], function(mousetrap) {
|
||||
mousetrap.bind('ctrl+shift+a r', function() {
|
||||
require(['admin/modules/instance'], function(instance) {
|
||||
require(['mousetrap'], function (mousetrap) {
|
||||
mousetrap.bind('ctrl+shift+a r', function () {
|
||||
require(['admin/modules/instance'], function (instance) {
|
||||
instance.reload();
|
||||
});
|
||||
});
|
||||
|
||||
mousetrap.bind('ctrl+shift+a R', function() {
|
||||
mousetrap.bind('ctrl+shift+a R', function () {
|
||||
socket.emit('admin.restart');
|
||||
});
|
||||
|
||||
mousetrap.bind('/', function() {
|
||||
mousetrap.bind('/', function () {
|
||||
$('#acp-search input').focus();
|
||||
|
||||
return false;
|
||||
@@ -100,7 +100,7 @@
|
||||
}
|
||||
|
||||
$('#main-menu li').removeClass('active');
|
||||
$('#main-menu a').removeClass('active').each(function() {
|
||||
$('#main-menu a').removeClass('active').each(function () {
|
||||
var menu = $(this),
|
||||
href = menu.attr('href'),
|
||||
isLink = menu.parent().attr('data-link') === '1';
|
||||
@@ -115,7 +115,7 @@
|
||||
});
|
||||
|
||||
var acpPath = url.replace('admin/', '').split('/');
|
||||
acpPath.forEach(function(path, i) {
|
||||
acpPath.forEach(function (path, i) {
|
||||
acpPath[i] = path.charAt(0).toUpperCase() + path.slice(1);
|
||||
});
|
||||
acpPath = acpPath.join(' > ');
|
||||
@@ -124,18 +124,18 @@
|
||||
}
|
||||
|
||||
function setupRestartLinks() {
|
||||
$('.restart').off('click').on('click', function() {
|
||||
bootbox.confirm('Are you sure you wish to restart NodeBB?', function(confirm) {
|
||||
$('.restart').off('click').on('click', function () {
|
||||
bootbox.confirm('Are you sure you wish to restart NodeBB?', function (confirm) {
|
||||
if (confirm) {
|
||||
require(['admin/modules/instance'], function(instance) {
|
||||
require(['admin/modules/instance'], function (instance) {
|
||||
instance.restart();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.reload').off('click').on('click', function() {
|
||||
require(['admin/modules/instance'], function(instance) {
|
||||
$('.reload').off('click').on('click', function () {
|
||||
require(['admin/modules/instance'], function (instance) {
|
||||
instance.reload();
|
||||
});
|
||||
});
|
||||
@@ -144,8 +144,8 @@
|
||||
function launchSnackbar(params) {
|
||||
var message = (params.title ? "<strong>" + params.title + "</strong>" : '') + (params.message ? params.message : '');
|
||||
|
||||
require(['translator'], function(translator) {
|
||||
translator.translate(message, function(html) {
|
||||
require(['translator'], function (translator) {
|
||||
translator.translate(message, function (html) {
|
||||
var bar = $.snackbar({
|
||||
content: html,
|
||||
timeout: 3000,
|
||||
@@ -167,15 +167,15 @@
|
||||
'tolerance': 70
|
||||
});
|
||||
|
||||
$('#mobile-menu').on('click', function() {
|
||||
$('#mobile-menu').on('click', function () {
|
||||
slideout.toggle();
|
||||
});
|
||||
|
||||
$('#menu a').on('click', function() {
|
||||
$('#menu a').on('click', function () {
|
||||
slideout.close();
|
||||
});
|
||||
|
||||
$(window).on('resize', function() {
|
||||
$(window).on('resize', function () {
|
||||
slideout.close();
|
||||
});
|
||||
|
||||
@@ -190,7 +190,7 @@
|
||||
slideout.on('open', onOpeningMenu);
|
||||
slideout.on('translate', onOpeningMenu);
|
||||
|
||||
slideout.on('close', function() {
|
||||
slideout.on('close', function () {
|
||||
$('#header').css({
|
||||
'top': '0px',
|
||||
'position': 'fixed'
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
"use strict";
|
||||
/*global config, define, app, socket, ajaxify, bootbox, templates, Chart, utils */
|
||||
|
||||
define('admin/advanced/errors', ['Chart'], function(Chart) {
|
||||
define('admin/advanced/errors', ['Chart'], function (Chart) {
|
||||
var Errors = {};
|
||||
|
||||
Errors.init = function() {
|
||||
Errors.init = function () {
|
||||
Errors.setupCharts();
|
||||
|
||||
$('[data-action="clear"]').on('click', Errors.clear404);
|
||||
};
|
||||
|
||||
Errors.clear404 = function() {
|
||||
bootbox.confirm('Are you sure you wish to clear the 404 error logs?', function(ok) {
|
||||
Errors.clear404 = function () {
|
||||
bootbox.confirm('Are you sure you wish to clear the 404 error logs?', function (ok) {
|
||||
if (ok) {
|
||||
socket.emit('admin.errors.clear', {}, function(err) {
|
||||
socket.emit('admin.errors.clear', {}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -25,7 +25,7 @@ define('admin/advanced/errors', ['Chart'], function(Chart) {
|
||||
});
|
||||
};
|
||||
|
||||
Errors.setupCharts = function() {
|
||||
Errors.setupCharts = function () {
|
||||
var notFoundCanvas = document.getElementById('not-found'),
|
||||
tooBusyCanvas = document.getElementById('toobusy'),
|
||||
dailyLabels = utils.getDaysArray();
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
/* global define, socket, app */
|
||||
|
||||
|
||||
define('admin/advanced/events', function() {
|
||||
define('admin/advanced/events', function () {
|
||||
var Events = {};
|
||||
|
||||
Events.init = function() {
|
||||
Events.init = function () {
|
||||
|
||||
$('[data-action="clear"]').on('click', function() {
|
||||
socket.emit('admin.deleteAllEvents', function(err) {
|
||||
$('[data-action="clear"]').on('click', function () {
|
||||
socket.emit('admin.deleteAllEvents', function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
"use strict";
|
||||
/* global define, socket, app */
|
||||
|
||||
define('admin/advanced/logs', function() {
|
||||
define('admin/advanced/logs', function () {
|
||||
var Logs = {};
|
||||
|
||||
Logs.init = function() {
|
||||
Logs.init = function () {
|
||||
var logsEl = $('.logs pre');
|
||||
logsEl.scrollTop(logsEl.prop('scrollHeight'));
|
||||
// Affix menu
|
||||
$('.affix').affix();
|
||||
|
||||
$('.logs').find('button[data-action]').on('click', function(event) {
|
||||
$('.logs').find('button[data-action]').on('click', function (event) {
|
||||
var btnEl = $(this),
|
||||
action = btnEl.attr('data-action');
|
||||
|
||||
switch(action) {
|
||||
case 'reload':
|
||||
socket.emit('admin.logs.get', function(err, logs) {
|
||||
socket.emit('admin.logs.get', function (err, logs) {
|
||||
if (!err) {
|
||||
logsEl.text(logs);
|
||||
logsEl.scrollTop(logsEl.prop('scrollHeight'));
|
||||
@@ -27,7 +27,7 @@ define('admin/advanced/logs', function() {
|
||||
break;
|
||||
|
||||
case 'clear':
|
||||
socket.emit('admin.logs.clear', function(err) {
|
||||
socket.emit('admin.logs.clear', function (err) {
|
||||
if (!err) {
|
||||
app.alertSuccess('Logs Cleared!');
|
||||
btnEl.prev().click();
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"use strict";
|
||||
/* global ace, define, app, socket */
|
||||
|
||||
define('admin/appearance/customise', ['admin/settings'], function(Settings) {
|
||||
define('admin/appearance/customise', ['admin/settings'], function (Settings) {
|
||||
var Customise = {};
|
||||
|
||||
Customise.init = function() {
|
||||
Settings.prepare(function() {
|
||||
Customise.init = function () {
|
||||
Settings.prepare(function () {
|
||||
$('#customCSS').text($('#customCSS-holder').val());
|
||||
$('#customHTML').text($('#customHTML-holder').val());
|
||||
|
||||
@@ -15,7 +15,7 @@ define('admin/appearance/customise', ['admin/settings'], function(Settings) {
|
||||
customCSS.setTheme("ace/theme/twilight");
|
||||
customCSS.getSession().setMode("ace/mode/css");
|
||||
|
||||
customCSS.on('change', function(event) {
|
||||
customCSS.on('change', function (event) {
|
||||
app.flags = app.flags || {};
|
||||
app.flags._unsaved = true;
|
||||
$('#customCSS-holder').val(customCSS.getValue());
|
||||
@@ -24,7 +24,7 @@ define('admin/appearance/customise', ['admin/settings'], function(Settings) {
|
||||
customHTML.setTheme("ace/theme/twilight");
|
||||
customHTML.getSession().setMode("ace/mode/html");
|
||||
|
||||
customHTML.on('change', function(event) {
|
||||
customHTML.on('change', function (event) {
|
||||
app.flags = app.flags || {};
|
||||
app.flags._unsaved = true;
|
||||
$('#customHTML-holder').val(customHTML.getValue());
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
"use strict";
|
||||
/* global define, app, socket, templates */
|
||||
|
||||
define('admin/appearance/skins', function() {
|
||||
define('admin/appearance/skins', function () {
|
||||
var Skins = {};
|
||||
|
||||
Skins.init = function() {
|
||||
Skins.init = function () {
|
||||
// Populate skins from Bootswatch API
|
||||
$.ajax({
|
||||
method: 'get',
|
||||
url: 'https://bootswatch.com/api/3.json'
|
||||
}).done(Skins.render);
|
||||
|
||||
$('#skins').on('click', function(e){
|
||||
$('#skins').on('click', function (e){
|
||||
var target = $(e.target);
|
||||
|
||||
if (!target.attr('data-action')) {
|
||||
@@ -31,7 +31,7 @@ define('admin/appearance/skins', function() {
|
||||
type: themeType,
|
||||
id: themeId,
|
||||
src: cssSrc
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -49,11 +49,11 @@ define('admin/appearance/skins', function() {
|
||||
});
|
||||
};
|
||||
|
||||
Skins.render = function(bootswatch) {
|
||||
Skins.render = function (bootswatch) {
|
||||
var themeContainer = $('#bootstrap_themes');
|
||||
|
||||
templates.parse('admin/partials/theme_list', {
|
||||
themes: bootswatch.themes.map(function(theme) {
|
||||
themes: bootswatch.themes.map(function (theme) {
|
||||
return {
|
||||
type: 'bootswatch',
|
||||
id: theme.name,
|
||||
@@ -66,13 +66,13 @@ define('admin/appearance/skins', function() {
|
||||
};
|
||||
}),
|
||||
showRevert: true
|
||||
}, function(html) {
|
||||
}, function (html) {
|
||||
themeContainer.html(html);
|
||||
|
||||
if (config['theme:src']) {
|
||||
var skin = config['theme:src']
|
||||
.match(/latest\/(\S+)\/bootstrap.min.css/)[1]
|
||||
.replace(/(^|\s)([a-z])/g , function(m,p1,p2){return p1+p2.toUpperCase();});
|
||||
.replace(/(^|\s)([a-z])/g , function (m,p1,p2){return p1 + p2.toUpperCase();});
|
||||
|
||||
highlightSelectedTheme(skin);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ define('admin/appearance/skins', function() {
|
||||
function highlightSelectedTheme(themeId) {
|
||||
$('[data-theme]')
|
||||
.removeClass('selected')
|
||||
.find('[data-action="use"]').each(function() {
|
||||
.find('[data-action="use"]').each(function () {
|
||||
if ($(this).parents('[data-theme]').attr('data-theme')) {
|
||||
$(this)
|
||||
.html('Select Skin')
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"use strict";
|
||||
/* global define, app, socket, bootbox, templates, config */
|
||||
|
||||
define('admin/appearance/themes', function() {
|
||||
define('admin/appearance/themes', function () {
|
||||
var Themes = {};
|
||||
|
||||
Themes.init = function() {
|
||||
$('#installed_themes').on('click', function(e){
|
||||
Themes.init = function () {
|
||||
$('#installed_themes').on('click', function (e){
|
||||
var target = $(e.target),
|
||||
action = target.attr('data-action');
|
||||
|
||||
@@ -19,7 +19,7 @@ define('admin/appearance/themes', function() {
|
||||
type: themeType,
|
||||
id: themeId,
|
||||
src: cssSrc
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -31,7 +31,7 @@ define('admin/appearance/themes', function() {
|
||||
title: 'Theme Changed',
|
||||
message: 'Please restart your NodeBB to fully activate this theme',
|
||||
timeout: 5000,
|
||||
clickfn: function() {
|
||||
clickfn: function () {
|
||||
socket.emit('admin.restart');
|
||||
}
|
||||
});
|
||||
@@ -39,13 +39,13 @@ define('admin/appearance/themes', function() {
|
||||
}
|
||||
});
|
||||
|
||||
$('#revert_theme').on('click', function() {
|
||||
bootbox.confirm('Are you sure you wish to restore the default NodeBB theme?', function(confirm) {
|
||||
$('#revert_theme').on('click', function () {
|
||||
bootbox.confirm('Are you sure you wish to restore the default NodeBB theme?', function (confirm) {
|
||||
if (confirm) {
|
||||
socket.emit('admin.themes.set', {
|
||||
type: 'local',
|
||||
id: 'nodebb-theme-persona'
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -62,7 +62,7 @@ define('admin/appearance/themes', function() {
|
||||
});
|
||||
});
|
||||
|
||||
socket.emit('admin.themes.getInstalled', function(err, themes) {
|
||||
socket.emit('admin.themes.getInstalled', function (err, themes) {
|
||||
if(err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -75,9 +75,9 @@ define('admin/appearance/themes', function() {
|
||||
} else {
|
||||
templates.parse('admin/partials/theme_list', {
|
||||
themes: themes
|
||||
}, function(html) {
|
||||
require(['translator'], function(translator) {
|
||||
translator.translate(html, function(html) {
|
||||
}, function (html) {
|
||||
require(['translator'], function (translator) {
|
||||
translator.translate(html, function (html) {
|
||||
instListEl.html(html);
|
||||
highlightSelectedTheme(config['theme:id']);
|
||||
});
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"use strict";
|
||||
/* global define, app, socket, bootbox */
|
||||
|
||||
define('admin/extend/plugins', function() {
|
||||
define('admin/extend/plugins', function () {
|
||||
var Plugins = {};
|
||||
Plugins.init = function() {
|
||||
Plugins.init = function () {
|
||||
var pluginsList = $('.plugins'),
|
||||
numPlugins = pluginsList[0].querySelectorAll('li').length,
|
||||
pluginID;
|
||||
@@ -15,11 +15,11 @@ define('admin/extend/plugins', function() {
|
||||
|
||||
$('#plugin-search').val('');
|
||||
|
||||
pluginsList.on('click', 'button[data-action="toggleActive"]', function() {
|
||||
pluginsList.on('click', 'button[data-action="toggleActive"]', function () {
|
||||
var pluginEl = $(this).parents('li');
|
||||
pluginID = pluginEl.attr('data-plugin-id');
|
||||
var btn = $('#' + pluginID + ' [data-action="toggleActive"]');
|
||||
socket.emit('admin.plugins.toggleActive', pluginID, function(err, status) {
|
||||
socket.emit('admin.plugins.toggleActive', pluginID, function (err, status) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
@@ -37,8 +37,8 @@ define('admin/extend/plugins', function() {
|
||||
message: status.active ? 'Please restart your NodeBB to fully activate this plugin' : 'Plugin successfully deactivated',
|
||||
type: status.active ? 'warning' : 'success',
|
||||
timeout: 5000,
|
||||
clickfn: function() {
|
||||
require(['admin/modules/instance'], function(instance) {
|
||||
clickfn: function () {
|
||||
require(['admin/modules/instance'], function (instance) {
|
||||
instance.restart();
|
||||
});
|
||||
}
|
||||
@@ -46,7 +46,7 @@ define('admin/extend/plugins', function() {
|
||||
});
|
||||
});
|
||||
|
||||
pluginsList.on('click', 'button[data-action="toggleInstall"]', function() {
|
||||
pluginsList.on('click', 'button[data-action="toggleInstall"]', function () {
|
||||
var btn = $(this);
|
||||
btn.attr('disabled', true);
|
||||
pluginID = $(this).parents('li').attr('data-plugin-id');
|
||||
@@ -55,9 +55,9 @@ define('admin/extend/plugins', function() {
|
||||
return Plugins.toggleInstall(pluginID, $(this).parents('li').attr('data-version'));
|
||||
}
|
||||
|
||||
Plugins.suggest(pluginID, function(err, payload) {
|
||||
Plugins.suggest(pluginID, function (err, payload) {
|
||||
if (err) {
|
||||
bootbox.confirm('<p>NodeBB could not reach the package manager, proceed with installation of latest version?</p><div class="alert alert-danger"><strong>Server returned (' + err.status + ')</strong>: ' + err.responseText + '</div>', function(confirm) {
|
||||
bootbox.confirm('<p>NodeBB could not reach the package manager, proceed with installation of latest version?</p><div class="alert alert-danger"><strong>Server returned (' + err.status + ')</strong>: ' + err.responseText + '</div>', function (confirm) {
|
||||
if (confirm) {
|
||||
Plugins.toggleInstall(pluginID, 'latest');
|
||||
} else {
|
||||
@@ -67,11 +67,11 @@ define('admin/extend/plugins', function() {
|
||||
return;
|
||||
}
|
||||
|
||||
require(['semver'], function(semver) {
|
||||
require(['semver'], function (semver) {
|
||||
if (payload.version !== 'latest') {
|
||||
Plugins.toggleInstall(pluginID, payload.version);
|
||||
} else if (payload.version === 'latest') {
|
||||
confirmInstall(pluginID, function(confirm) {
|
||||
confirmInstall(pluginID, function (confirm) {
|
||||
if (confirm) {
|
||||
Plugins.toggleInstall(pluginID, 'latest');
|
||||
} else {
|
||||
@@ -85,21 +85,21 @@ define('admin/extend/plugins', function() {
|
||||
});
|
||||
});
|
||||
|
||||
pluginsList.on('click', 'button[data-action="upgrade"]', function() {
|
||||
pluginsList.on('click', 'button[data-action="upgrade"]', function () {
|
||||
var btn = $(this);
|
||||
var parent = btn.parents('li');
|
||||
pluginID = parent.attr('data-plugin-id');
|
||||
|
||||
Plugins.suggest(pluginID, function(err, payload) {
|
||||
Plugins.suggest(pluginID, function (err, payload) {
|
||||
if (err) {
|
||||
return bootbox.alert('<p>NodeBB could not reach the package manager, an upgrade is not suggested at this time.</p>');
|
||||
}
|
||||
|
||||
require(['semver'], function(semver) {
|
||||
require(['semver'], function (semver) {
|
||||
if (payload.version !== 'latest' && semver.gt(payload.version, parent.find('.currentVersion').text())) {
|
||||
upgrade(pluginID, btn, payload.version);
|
||||
} else if (payload.version === 'latest') {
|
||||
confirmInstall(pluginID, function() {
|
||||
confirmInstall(pluginID, function () {
|
||||
upgrade(pluginID, btn, payload.version);
|
||||
});
|
||||
} else {
|
||||
@@ -109,22 +109,22 @@ define('admin/extend/plugins', function() {
|
||||
});
|
||||
});
|
||||
|
||||
$('#plugin-search').on('input propertychange', function() {
|
||||
$('#plugin-search').on('input propertychange', function () {
|
||||
var term = $(this).val();
|
||||
$('.plugins li').each(function() {
|
||||
$('.plugins li').each(function () {
|
||||
var pluginId = $(this).attr('data-plugin-id');
|
||||
$(this).toggleClass('hide', pluginId && pluginId.indexOf(term) === -1);
|
||||
});
|
||||
});
|
||||
|
||||
$('#plugin-order').on('click', function() {
|
||||
$('#plugin-order').on('click', function () {
|
||||
$('#order-active-plugins-modal').modal('show');
|
||||
socket.emit('admin.plugins.getActive', function(err, activePlugins) {
|
||||
socket.emit('admin.plugins.getActive', function (err, activePlugins) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
var html = '';
|
||||
activePlugins.forEach(function(plugin) {
|
||||
activePlugins.forEach(function (plugin) {
|
||||
html += '<li class="">' + plugin + '</li>';
|
||||
});
|
||||
if (!activePlugins.length) {
|
||||
@@ -134,14 +134,14 @@ define('admin/extend/plugins', function() {
|
||||
});
|
||||
});
|
||||
|
||||
$('#save-plugin-order').on('click', function() {
|
||||
$('#save-plugin-order').on('click', function () {
|
||||
var plugins = $('#order-active-plugins-modal .plugin-list').children();
|
||||
var data = [];
|
||||
plugins.each(function(index, el) {
|
||||
plugins.each(function (index, el) {
|
||||
data.push({name: $(el).text(), order: index});
|
||||
});
|
||||
|
||||
socket.emit('admin.plugins.orderActivePlugins', data, function(err) {
|
||||
socket.emit('admin.plugins.orderActivePlugins', data, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -158,7 +158,7 @@ define('admin/extend/plugins', function() {
|
||||
'<div class="alert alert-warning"><p><strong>No Compatibility Infomation Found</strong></p><p>This plugin did not specify a specific version for installation given your NodeBB version. Full compatibility cannot be guaranteed, and may cause your NodeBB to no longer start properly.</p></div>' +
|
||||
'<p>In the event that NodeBB cannot boot properly:</p>' +
|
||||
'<pre><code>$ ./nodebb reset plugin="' + pluginID + '"</code></pre>' +
|
||||
'<p>Continue installation of latest version of this plugin?</p>', function(confirm) {
|
||||
'<p>Continue installation of latest version of this plugin?</p>', function (confirm) {
|
||||
callback(confirm);
|
||||
});
|
||||
}
|
||||
@@ -168,7 +168,7 @@ define('admin/extend/plugins', function() {
|
||||
socket.emit('admin.plugins.upgrade', {
|
||||
id: pluginID,
|
||||
version: version
|
||||
}, function(err, isActive) {
|
||||
}, function (err, isActive) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -183,8 +183,8 @@ define('admin/extend/plugins', function() {
|
||||
message: 'Please reload your NodeBB to fully upgrade this plugin',
|
||||
type: 'warning',
|
||||
timeout: 5000,
|
||||
clickfn: function() {
|
||||
require(['admin/modules/instance'], function(instance) {
|
||||
clickfn: function () {
|
||||
require(['admin/modules/instance'], function (instance) {
|
||||
instance.reload();
|
||||
});
|
||||
}
|
||||
@@ -193,7 +193,7 @@ define('admin/extend/plugins', function() {
|
||||
});
|
||||
}
|
||||
|
||||
Plugins.toggleInstall = function(pluginID, version, callback) {
|
||||
Plugins.toggleInstall = function (pluginID, version, callback) {
|
||||
var btn = $('li[data-plugin-id="' + pluginID + '"] button[data-action="toggleInstall"]');
|
||||
var activateBtn = btn.siblings('[data-action="toggleActive"]');
|
||||
btn.find('i').attr('class', 'fa fa-refresh fa-spin');
|
||||
@@ -201,7 +201,7 @@ define('admin/extend/plugins', function() {
|
||||
socket.emit('admin.plugins.toggleInstall', {
|
||||
id: pluginID,
|
||||
version: version
|
||||
}, function(err, pluginData) {
|
||||
}, function (err, pluginData) {
|
||||
if (err) {
|
||||
btn.removeAttr('disabled');
|
||||
return app.alertError(err.message);
|
||||
@@ -223,7 +223,7 @@ define('admin/extend/plugins', function() {
|
||||
});
|
||||
};
|
||||
|
||||
Plugins.suggest = function(pluginId, callback) {
|
||||
Plugins.suggest = function (pluginId, callback) {
|
||||
var nbbVersion = app.config.version.match(/^\d\.\d\.\d/);
|
||||
$.ajax((app.config.registry || 'https://packages.nodebb.org') + '/api/v1/suggest', {
|
||||
type: 'GET',
|
||||
@@ -232,13 +232,13 @@ define('admin/extend/plugins', function() {
|
||||
version: nbbVersion[0]
|
||||
},
|
||||
dataType: 'json'
|
||||
}).done(function(payload) {
|
||||
}).done(function (payload) {
|
||||
callback(undefined, payload);
|
||||
}).fail(callback);
|
||||
};
|
||||
|
||||
function populateUpgradeablePlugins() {
|
||||
$('#installed ul li').each(function() {
|
||||
$('#installed ul li').each(function () {
|
||||
if ($(this).children('[data-action="upgrade"]').length) {
|
||||
$('#upgrade ul').append($(this).clone(true));
|
||||
}
|
||||
@@ -246,7 +246,7 @@ define('admin/extend/plugins', function() {
|
||||
}
|
||||
|
||||
function populateActivePlugins() {
|
||||
$('#installed ul li').each(function() {
|
||||
$('#installed ul li').each(function () {
|
||||
if ($(this).hasClass('active')) {
|
||||
$('#active ul').append($(this).clone(true));
|
||||
} else {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
/* global define, app, ajaxify, socket, templates, bootbox */
|
||||
|
||||
define('admin/extend/rewards', function() {
|
||||
define('admin/extend/rewards', function () {
|
||||
var rewards = {};
|
||||
|
||||
|
||||
@@ -10,25 +10,25 @@ define('admin/extend/rewards', function() {
|
||||
conditions,
|
||||
conditionals;
|
||||
|
||||
rewards.init = function() {
|
||||
rewards.init = function () {
|
||||
available = ajaxify.data.rewards;
|
||||
active = ajaxify.data.active;
|
||||
conditions = ajaxify.data.conditions;
|
||||
conditionals = ajaxify.data.conditionals;
|
||||
|
||||
$('[data-selected]').each(function() {
|
||||
$('[data-selected]').each(function () {
|
||||
select($(this));
|
||||
});
|
||||
|
||||
$('#active')
|
||||
.on('change', '[data-selected]', function() {
|
||||
.on('change', '[data-selected]', function () {
|
||||
update($(this));
|
||||
})
|
||||
.on('click', '.delete', function() {
|
||||
.on('click', '.delete', function () {
|
||||
var parent = $(this).parents('[data-id]'),
|
||||
id = parent.attr('data-id');
|
||||
|
||||
socket.emit('admin.rewards.delete', {id: id}, function(err) {
|
||||
socket.emit('admin.rewards.delete', {id: id}, function (err) {
|
||||
if (err) {
|
||||
app.alertError(err.message);
|
||||
} else {
|
||||
@@ -39,7 +39,7 @@ define('admin/extend/rewards', function() {
|
||||
parent.remove();
|
||||
return false;
|
||||
})
|
||||
.on('click', '.toggle', function() {
|
||||
.on('click', '.toggle', function () {
|
||||
var btn = $(this),
|
||||
disabled = btn.hasClass('btn-success'),
|
||||
id = $(this).parents('[data-id]').attr('data-id');
|
||||
@@ -93,17 +93,17 @@ define('admin/extend/rewards', function() {
|
||||
return app.alertError('Illegal reward - no inputs found! ' + el.attr('data-selected'));
|
||||
}
|
||||
|
||||
inputs.forEach(function(input) {
|
||||
inputs.forEach(function (input) {
|
||||
html += '<label for="' + input.name + '">' + input.label + '<br />';
|
||||
switch (input.type) {
|
||||
case 'select':
|
||||
html += '<select name="' + input.name + '">';
|
||||
input.values.forEach(function(value) {
|
||||
input.values.forEach(function (value) {
|
||||
html += '<option value="' + value.value + '">' + value.name + '</option>';
|
||||
});
|
||||
break;
|
||||
case 'text':
|
||||
html += '<input type="text" name="' + input.name +'" />';
|
||||
html += '<input type="text" name="' + input.name + '" />';
|
||||
break;
|
||||
}
|
||||
html += '</label><br />';
|
||||
@@ -113,7 +113,7 @@ define('admin/extend/rewards', function() {
|
||||
}
|
||||
|
||||
function populateInputs() {
|
||||
$('[data-rid]').each(function(i) {
|
||||
$('[data-rid]').each(function (i) {
|
||||
var div = $(this).find('.inputs'),
|
||||
rewards = active[i].rewards;
|
||||
|
||||
@@ -141,7 +141,7 @@ define('admin/extend/rewards', function() {
|
||||
rewards: available,
|
||||
};
|
||||
|
||||
templates.parse('admin/extend/rewards', 'active', data, function(li) {
|
||||
templates.parse('admin/extend/rewards', 'active', data, function (li) {
|
||||
li = $(li);
|
||||
ul.append(li);
|
||||
li.find('select').val('');
|
||||
@@ -151,16 +151,16 @@ define('admin/extend/rewards', function() {
|
||||
function saveRewards() {
|
||||
var activeRewards = [];
|
||||
|
||||
$('#active li').each(function() {
|
||||
$('#active li').each(function () {
|
||||
var data = {rewards: {}},
|
||||
main = $(this).find('form.main').serializeArray(),
|
||||
rewards = $(this).find('form.rewards').serializeArray();
|
||||
|
||||
main.forEach(function(obj) {
|
||||
main.forEach(function (obj) {
|
||||
data[obj.name] = obj.value;
|
||||
});
|
||||
|
||||
rewards.forEach(function(obj) {
|
||||
rewards.forEach(function (obj) {
|
||||
data.rewards[obj.name] = obj.value;
|
||||
});
|
||||
|
||||
@@ -170,7 +170,7 @@ define('admin/extend/rewards', function() {
|
||||
activeRewards.push(data);
|
||||
});
|
||||
|
||||
socket.emit('admin.rewards.save', activeRewards, function(err) {
|
||||
socket.emit('admin.rewards.save', activeRewards, function (err) {
|
||||
if (err) {
|
||||
app.alertError(err.message);
|
||||
} else {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"use strict";
|
||||
/* global define, app, socket */
|
||||
|
||||
define('admin/extend/widgets', ['jqueryui'], function(jqueryui) {
|
||||
define('admin/extend/widgets', ['jqueryui'], function (jqueryui) {
|
||||
var Widgets = {};
|
||||
|
||||
Widgets.init = function() {
|
||||
$('#widgets .nav-pills a').on('click', function(ev) {
|
||||
Widgets.init = function () {
|
||||
$('#widgets .nav-pills a').on('click', function (ev) {
|
||||
var $this = $(this);
|
||||
$('#widgets .nav-pills li').removeClass('active');
|
||||
$this.parent().addClass('active');
|
||||
@@ -17,7 +17,7 @@ define('admin/extend/widgets', ['jqueryui'], function(jqueryui) {
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#widget-selector').on('change', function() {
|
||||
$('#widget-selector').on('change', function () {
|
||||
$('.available-widgets [data-widget]').addClass('hide');
|
||||
$('.available-widgets [data-widget="' + $(this).val() + '"]').removeClass('hide');
|
||||
});
|
||||
@@ -31,7 +31,7 @@ define('admin/extend/widgets', ['jqueryui'], function(jqueryui) {
|
||||
$('[data-location="drafts"]').insertAfter($('[data-location="drafts"]').closest('.tab-content'));
|
||||
|
||||
$('#widgets .available-widgets .widget-panel').draggable({
|
||||
helper: function(e) {
|
||||
helper: function (e) {
|
||||
return $(e.target).parents('.widget-panel').clone();
|
||||
},
|
||||
distance: 10,
|
||||
@@ -40,7 +40,7 @@ define('admin/extend/widgets', ['jqueryui'], function(jqueryui) {
|
||||
|
||||
$('#widgets .available-containers .containers > [data-container-html]')
|
||||
.draggable({
|
||||
helper: function(e) {
|
||||
helper: function (e) {
|
||||
var target = $(e.target);
|
||||
target = target.attr('data-container-html') ? target : target.parents('[data-container-html]');
|
||||
|
||||
@@ -48,7 +48,7 @@ define('admin/extend/widgets', ['jqueryui'], function(jqueryui) {
|
||||
},
|
||||
distance: 10
|
||||
})
|
||||
.each(function() {
|
||||
.each(function () {
|
||||
$(this).attr('data-container-html', $(this).attr('data-container-html').replace(/\\\{([\s\S]*?)\\\}/g, '{$1}'));
|
||||
});
|
||||
|
||||
@@ -57,15 +57,15 @@ define('admin/extend/widgets', ['jqueryui'], function(jqueryui) {
|
||||
appendToggle(ui.item);
|
||||
},
|
||||
connectWith: "div"
|
||||
}).on('click', '.delete-widget', function() {
|
||||
}).on('click', '.delete-widget', function () {
|
||||
var panel = $(this).parents('.widget-panel');
|
||||
|
||||
bootbox.confirm('Are you sure you wish to delete this widget?', function(confirm) {
|
||||
bootbox.confirm('Are you sure you wish to delete this widget?', function (confirm) {
|
||||
if (confirm) {
|
||||
panel.remove();
|
||||
}
|
||||
});
|
||||
}).on('mouseup', '> .panel > .panel-heading', function(evt) {
|
||||
}).on('mouseup', '> .panel > .panel-heading', function (evt) {
|
||||
if ( !( $(this).parent().is('.ui-sortable-helper') || $(evt.target).closest('.delete-widget').length ) ) {
|
||||
$(this).parent().children('.panel-body').toggleClass('hidden');
|
||||
}
|
||||
@@ -76,7 +76,7 @@ define('admin/extend/widgets', ['jqueryui'], function(jqueryui) {
|
||||
function saveWidgets() {
|
||||
var total = $('#widgets [data-template][data-location]').length;
|
||||
|
||||
$('#widgets [data-template][data-location]').each(function(i, el) {
|
||||
$('#widgets [data-template][data-location]').each(function (i, el) {
|
||||
el = $(el);
|
||||
|
||||
var template = el.attr('data-template'),
|
||||
@@ -84,7 +84,7 @@ define('admin/extend/widgets', ['jqueryui'], function(jqueryui) {
|
||||
area = el.children('.widget-area'),
|
||||
widgets = [];
|
||||
|
||||
area.find('.widget-panel[data-widget]').each(function() {
|
||||
area.find('.widget-panel[data-widget]').each(function () {
|
||||
var widgetData = {},
|
||||
data = $(this).find('form').serializeArray();
|
||||
|
||||
@@ -113,7 +113,7 @@ define('admin/extend/widgets', ['jqueryui'], function(jqueryui) {
|
||||
template: template,
|
||||
location: location,
|
||||
widgets: widgets
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
total--;
|
||||
|
||||
if (err) {
|
||||
@@ -134,13 +134,13 @@ define('admin/extend/widgets', ['jqueryui'], function(jqueryui) {
|
||||
});
|
||||
}
|
||||
|
||||
$('.color-selector').on('click', '.btn', function() {
|
||||
$('.color-selector').on('click', '.btn', function () {
|
||||
var btn = $(this),
|
||||
selector = btn.parents('.color-selector'),
|
||||
container = selector.parents('[data-container-html]'),
|
||||
classList = [];
|
||||
|
||||
selector.children().each(function() {
|
||||
selector.children().each(function () {
|
||||
classList.push($(this).attr('data-class'));
|
||||
});
|
||||
|
||||
@@ -159,7 +159,7 @@ define('admin/extend/widgets', ['jqueryui'], function(jqueryui) {
|
||||
el.addClass('block').css('width', '').css('height', '')
|
||||
.droppable({
|
||||
accept: '[data-container-html]',
|
||||
drop: function(event, ui) {
|
||||
drop: function (event, ui) {
|
||||
var el = $(this);
|
||||
|
||||
el.find('.panel-body .container-html').val(ui.draggable.attr('data-container-html'));
|
||||
@@ -180,7 +180,7 @@ define('admin/extend/widgets', ['jqueryui'], function(jqueryui) {
|
||||
title.text(title.text() + ' - ' + data.title);
|
||||
}
|
||||
|
||||
widget.find('input, textarea, select').each(function() {
|
||||
widget.find('input, textarea, select').each(function () {
|
||||
var input = $(this),
|
||||
value = data[input.attr('name')];
|
||||
|
||||
@@ -194,16 +194,16 @@ define('admin/extend/widgets', ['jqueryui'], function(jqueryui) {
|
||||
return widget;
|
||||
}
|
||||
|
||||
$.get(RELATIVE_PATH + '/api/admin/extend/widgets', function(data) {
|
||||
$.get(RELATIVE_PATH + '/api/admin/extend/widgets', function (data) {
|
||||
var areas = data.areas;
|
||||
|
||||
for(var i=0; i<areas.length; ++i) {
|
||||
for(var i = 0; i < areas.length; ++i) {
|
||||
var area = areas[i],
|
||||
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) {
|
||||
for (var k = 0; k < area.data.length; ++k) {
|
||||
var widgetData = area.data[k],
|
||||
widgetEl = $('.available-widgets [data-widget="' + widgetData.widget + '"]').clone(true).removeClass('hide');
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
/*global define, ajaxify, app, socket, utils, bootbox, RELATIVE_PATH*/
|
||||
|
||||
define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) {
|
||||
define('admin/general/dashboard', ['semver', 'Chart'], function (semver, Chart) {
|
||||
var Admin = {};
|
||||
var intervals = {
|
||||
rooms: false,
|
||||
@@ -24,7 +24,7 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) {
|
||||
realtimeInterval: 1500
|
||||
};
|
||||
|
||||
$(window).on('action:ajaxify.start', function(ev, data) {
|
||||
$(window).on('action:ajaxify.start', function (ev, data) {
|
||||
clearInterval(intervals.rooms);
|
||||
clearInterval(intervals.graphs);
|
||||
|
||||
@@ -35,19 +35,19 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) {
|
||||
usedTopicColors.length = 0;
|
||||
});
|
||||
|
||||
Admin.init = function() {
|
||||
Admin.init = function () {
|
||||
app.enterRoom('admin');
|
||||
socket.emit('admin.rooms.getAll', Admin.updateRoomUsage);
|
||||
|
||||
isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
||||
|
||||
$.get('https://api.github.com/repos/NodeBB/NodeBB/tags', function(releases) {
|
||||
$.get('https://api.github.com/repos/NodeBB/NodeBB/tags', function (releases) {
|
||||
// Re-sort the releases, as they do not follow Semver (wrt pre-releases)
|
||||
releases = releases.sort(function(a, b) {
|
||||
releases = releases.sort(function (a, b) {
|
||||
a = a.name.replace(/^v/, '');
|
||||
b = b.name.replace(/^v/, '');
|
||||
return semver.lt(a, b) ? 1 : -1;
|
||||
}).filter(function(version) {
|
||||
}).filter(function (version) {
|
||||
return !isPrerelease.test(version.name); // filter out automated prerelease versions
|
||||
});
|
||||
|
||||
@@ -79,7 +79,7 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) {
|
||||
initiateDashboard();
|
||||
};
|
||||
|
||||
Admin.updateRoomUsage = function(err, data) {
|
||||
Admin.updateRoomUsage = function (err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -91,19 +91,19 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) {
|
||||
graphData.rooms = data;
|
||||
|
||||
var html = '<div class="text-center pull-left">' +
|
||||
'<div>'+ data.onlineRegisteredCount +'</div>' +
|
||||
'<div>' + data.onlineRegisteredCount + '</div>' +
|
||||
'<div>Users</div>' +
|
||||
'</div>' +
|
||||
'<div class="text-center pull-left">' +
|
||||
'<div>'+ data.onlineGuestCount +'</div>' +
|
||||
'<div>' + data.onlineGuestCount + '</div>' +
|
||||
'<div>Guests</div>' +
|
||||
'</div>' +
|
||||
'<div class="text-center pull-left">' +
|
||||
'<div>'+ (data.onlineRegisteredCount + data.onlineGuestCount) +'</div>' +
|
||||
'<div>' + (data.onlineRegisteredCount + data.onlineGuestCount) + '</div>' +
|
||||
'<div>Total</div>' +
|
||||
'</div>' +
|
||||
'<div class="text-center pull-left">' +
|
||||
'<div>'+ data.socketCount +'</div>' +
|
||||
'<div>' + data.socketCount + '</div>' +
|
||||
'<div>Connections</div>' +
|
||||
'</div>';
|
||||
|
||||
@@ -150,7 +150,7 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) {
|
||||
if (g > 255) g = 255;
|
||||
else if (g < 0) g = 0;
|
||||
|
||||
return (usePound?"#":"") + (g | (b << 8) | (r << 16)).toString(16);
|
||||
return (usePound ? "#" : "") + (g | (b << 8) | (r << 16)).toString(16);
|
||||
}
|
||||
|
||||
function setupGraphs() {
|
||||
@@ -272,12 +272,12 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) {
|
||||
$(window).on('resize', adjustPieCharts);
|
||||
adjustPieCharts();
|
||||
|
||||
$('[data-action="updateGraph"]').on('click', function() {
|
||||
$('[data-action="updateGraph"]').on('click', function () {
|
||||
var until = undefined;
|
||||
switch($(this).attr('data-until')) {
|
||||
case 'last-month':
|
||||
var lastMonth = new Date();
|
||||
lastMonth.setDate(lastMonth.getDate()-30);
|
||||
lastMonth.setDate(lastMonth.getDate() - 30);
|
||||
until = lastMonth.getTime();
|
||||
}
|
||||
updateTrafficGraph($(this).attr('data-units'), until);
|
||||
@@ -285,7 +285,7 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) {
|
||||
}
|
||||
|
||||
function adjustPieCharts() {
|
||||
$('.pie-chart.legend-up').each(function() {
|
||||
$('.pie-chart.legend-up').each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
if ($this.width() < 320) {
|
||||
@@ -396,7 +396,7 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) {
|
||||
}
|
||||
|
||||
function setupRealtimeButton() {
|
||||
$('#toggle-realtime .fa').on('click', function() {
|
||||
$('#toggle-realtime .fa').on('click', function () {
|
||||
var $this = $(this);
|
||||
if ($this.hasClass('fa-toggle-on')) {
|
||||
$this.removeClass('fa-toggle-on').addClass('fa-toggle-off');
|
||||
@@ -414,13 +414,13 @@ define('admin/general/dashboard', ['semver', 'Chart'], function(semver, Chart) {
|
||||
clearInterval(intervals.rooms);
|
||||
clearInterval(intervals.graphs);
|
||||
|
||||
intervals.rooms = setInterval(function() {
|
||||
intervals.rooms = setInterval(function () {
|
||||
if (app.isFocused && app.isConnected) {
|
||||
socket.emit('admin.rooms.getAll', Admin.updateRoomUsage);
|
||||
}
|
||||
}, realtime ? DEFAULTS.realtimeInterval : DEFAULTS.roomInterval);
|
||||
|
||||
intervals.graphs = setInterval(function() {
|
||||
intervals.graphs = setInterval(function () {
|
||||
updateTrafficGraph(currentGraph.units, currentGraph.until);
|
||||
}, realtime ? DEFAULTS.realtimeInterval : DEFAULTS.graphInterval);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
/*global define*/
|
||||
|
||||
define('admin/general/homepage', ['admin/settings'], function(Settings) {
|
||||
define('admin/general/homepage', ['admin/settings'], function (Settings) {
|
||||
|
||||
function toggleCustomRoute() {
|
||||
if ($('[data-field="homePageRoute"]').val()) {
|
||||
@@ -13,7 +13,7 @@ define('admin/general/homepage', ['admin/settings'], function(Settings) {
|
||||
|
||||
var Homepage = {};
|
||||
|
||||
Homepage.init = function() {
|
||||
Homepage.init = function () {
|
||||
$('[data-field="homePageRoute"]').on('change', toggleCustomRoute);
|
||||
|
||||
toggleCustomRoute();
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"use strict";
|
||||
/*global define*/
|
||||
|
||||
define('admin/general/languages', ['admin/settings'], function(Settings) {
|
||||
define('admin/general/languages', ['admin/settings'], function (Settings) {
|
||||
var Languages = {}
|
||||
|
||||
Languages.init = function() {
|
||||
Languages.init = function () {
|
||||
Settings.prepare();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
"use strict";
|
||||
/* global define, app, ajaxify, socket, templates */
|
||||
|
||||
define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], function(translator, iconSelect, jqueryui) {
|
||||
define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], function (translator, iconSelect, jqueryui) {
|
||||
var navigation = {},
|
||||
available;
|
||||
|
||||
navigation.init = function() {
|
||||
navigation.init = function () {
|
||||
available = ajaxify.data.available;
|
||||
|
||||
$('#enabled .unescape').each(function() {
|
||||
$('#enabled .unescape').each(function () {
|
||||
$(this).val(translator.unescape($(this).val()));
|
||||
});
|
||||
|
||||
translator.translate(translator.unescape($('#available').html()), function(html) {
|
||||
translator.translate(translator.unescape($('#available').html()), function (html) {
|
||||
$('#available').html(html)
|
||||
.find('li .drag-item').draggable({
|
||||
connectToSortable: '#active-navigation',
|
||||
@@ -26,9 +26,9 @@ define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], fun
|
||||
accept: $('#available li .drag-item')
|
||||
});
|
||||
|
||||
$('#enabled').on('click', '.iconPicker', function() {
|
||||
$('#enabled').on('click', '.iconPicker', function () {
|
||||
var iconEl = $(this).find('i');
|
||||
iconSelect.init(iconEl, function(el) {
|
||||
iconSelect.init(iconEl, function (el) {
|
||||
var newIconClass = el.attr('value');
|
||||
var index = iconEl.parents('[data-index]').attr('data-index');
|
||||
$('#active-navigation [data-index="' + index + '"] i').attr('class', 'fa fa-fw ' + newIconClass);
|
||||
@@ -68,13 +68,13 @@ define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], fun
|
||||
data.enabled = false;
|
||||
data.index = (parseInt($('#enabled').children().last().attr('data-index'), 10) || 0) + 1;
|
||||
|
||||
templates.parse('admin/general/navigation', 'navigation', {navigation: [data]}, function(li) {
|
||||
templates.parse('admin/general/navigation', 'navigation', {navigation: [data]}, function (li) {
|
||||
li = $(translator.unescape(li));
|
||||
el.after(li);
|
||||
el.remove();
|
||||
});
|
||||
|
||||
templates.parse('admin/general/navigation', 'enabled', {enabled: [data]}, function(li) {
|
||||
templates.parse('admin/general/navigation', 'enabled', {enabled: [data]}, function (li) {
|
||||
li = $(translator.unescape(li));
|
||||
$('#enabled').append(li);
|
||||
componentHandler.upgradeDom()
|
||||
@@ -85,17 +85,17 @@ define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], fun
|
||||
var nav = [];
|
||||
|
||||
var indices = [];
|
||||
$('#active-navigation li').each(function() {
|
||||
$('#active-navigation li').each(function () {
|
||||
indices.push($(this).attr('data-index'));
|
||||
});
|
||||
|
||||
indices.forEach(function(index) {
|
||||
indices.forEach(function (index) {
|
||||
var el = $('#enabled').children('[data-index="' + index + '"]');
|
||||
var form = el.find('form').serializeArray(),
|
||||
data = {},
|
||||
properties = {};
|
||||
|
||||
form.forEach(function(input) {
|
||||
form.forEach(function (input) {
|
||||
if (input.name.slice(0, 9) === 'property:' && input.value === 'on') {
|
||||
properties[input.name.slice(9)] = true;
|
||||
} else {
|
||||
@@ -114,7 +114,7 @@ define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], fun
|
||||
nav.push(data);
|
||||
});
|
||||
|
||||
socket.emit('admin.navigation.save', nav, function(err) {
|
||||
socket.emit('admin.navigation.save', nav, function (err) {
|
||||
if (err) {
|
||||
app.alertError(err.message);
|
||||
} else {
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
"use strict";
|
||||
/*global define, socket*/
|
||||
|
||||
define('admin/general/social', [], function() {
|
||||
define('admin/general/social', [], function () {
|
||||
var social = {};
|
||||
|
||||
social.init = function() {
|
||||
$('#save').on('click', function() {
|
||||
social.init = function () {
|
||||
$('#save').on('click', function () {
|
||||
var networks = [];
|
||||
$('#postSharingNetworks input[type="checkbox"]').each(function() {
|
||||
$('#postSharingNetworks input[type="checkbox"]').each(function () {
|
||||
if ($(this).prop('checked')) {
|
||||
networks.push($(this).attr('id'));
|
||||
}
|
||||
});
|
||||
|
||||
socket.emit('admin.social.savePostSharingNetworks', networks, function(err) {
|
||||
socket.emit('admin.social.savePostSharingNetworks', networks, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"use strict";
|
||||
/* global app, define, socket */
|
||||
|
||||
define('admin/general/sounds', ['sounds', 'settings'], function(Sounds, Settings) {
|
||||
define('admin/general/sounds', ['sounds', 'settings'], function (Sounds, Settings) {
|
||||
var SoundsAdmin = {};
|
||||
|
||||
SoundsAdmin.init = function() {
|
||||
SoundsAdmin.init = function () {
|
||||
// Sounds tab
|
||||
$('.sounds').find('button[data-action="play"]').on('click', function(e) {
|
||||
$('.sounds').find('button[data-action="play"]').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var fileName = $(this).parent().parent().find('select').val();
|
||||
@@ -18,8 +18,8 @@ define('admin/general/sounds', ['sounds', 'settings'], function(Sounds, Settings
|
||||
|
||||
// Saving of Form Values
|
||||
var saveEl = $('#save');
|
||||
saveEl.on('click', function() {
|
||||
Settings.save('sounds', $('.sounds form'), function() {
|
||||
saveEl.on('click', function () {
|
||||
Settings.save('sounds', $('.sounds form'), function () {
|
||||
socket.emit('admin.fireEvent', {
|
||||
name: 'event:sounds.reloadMapping'
|
||||
});
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"use strict";
|
||||
/*global define, socket, app, bootbox, templates, ajaxify, Sortable */
|
||||
|
||||
define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-serializeobject.min', 'translator'], function(serialize, translator) {
|
||||
define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-serializeobject.min', 'translator'], function (serialize, translator) {
|
||||
var Categories = {}, newCategoryId = -1, sortables;
|
||||
|
||||
Categories.init = function() {
|
||||
socket.emit('admin.categories.getAll', function(error, payload){
|
||||
Categories.init = function () {
|
||||
socket.emit('admin.categories.getAll', function (error, payload){
|
||||
if(error){
|
||||
return app.alertError(error.message);
|
||||
}
|
||||
@@ -16,13 +16,13 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
|
||||
$('button[data-action="create"]').on('click', Categories.throwCreateModal);
|
||||
|
||||
// Enable/Disable toggle events
|
||||
$('.categories').on('click', 'button[data-action="toggle"]', function() {
|
||||
$('.categories').on('click', 'button[data-action="toggle"]', function () {
|
||||
var $this = $(this),
|
||||
cid = $this.attr('data-cid'),
|
||||
parentEl = $this.parents('li[data-cid="' + cid + '"]'),
|
||||
disabled = parentEl.hasClass('disabled');
|
||||
|
||||
var children = parentEl.find('li[data-cid]').map(function() {
|
||||
var children = parentEl.find('li[data-cid]').map(function () {
|
||||
return $(this).attr('data-cid');
|
||||
}).get();
|
||||
|
||||
@@ -31,15 +31,15 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
|
||||
});
|
||||
};
|
||||
|
||||
Categories.throwCreateModal = function() {
|
||||
socket.emit('admin.categories.getNames', {}, function(err, categories) {
|
||||
Categories.throwCreateModal = function () {
|
||||
socket.emit('admin.categories.getNames', {}, function (err, categories) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
templates.parse('admin/partials/categories/create', {
|
||||
categories: categories
|
||||
}, function(html) {
|
||||
}, function (html) {
|
||||
function submit() {
|
||||
var formData = modal.find('form').serializeObject();
|
||||
formData.description = '';
|
||||
@@ -67,8 +67,8 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
|
||||
});
|
||||
};
|
||||
|
||||
Categories.create = function(payload) {
|
||||
socket.emit('admin.categories.create', payload, function(err, data) {
|
||||
Categories.create = function (payload) {
|
||||
socket.emit('admin.categories.create', payload, function (err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -85,7 +85,7 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
|
||||
});
|
||||
};
|
||||
|
||||
Categories.render = function(categories){
|
||||
Categories.render = function (categories){
|
||||
var container = $('.categories');
|
||||
|
||||
if (!categories || !categories.length) {
|
||||
@@ -99,16 +99,16 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
|
||||
}
|
||||
};
|
||||
|
||||
Categories.toggle = function(cids, disabled) {
|
||||
Categories.toggle = function (cids, disabled) {
|
||||
var payload = {};
|
||||
|
||||
cids.forEach(function(cid) {
|
||||
cids.forEach(function (cid) {
|
||||
payload[cid] = {
|
||||
disabled: disabled ? 1 : 0
|
||||
};
|
||||
});
|
||||
|
||||
socket.emit('admin.categories.update', payload, function(err) {
|
||||
socket.emit('admin.categories.update', payload, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -154,8 +154,8 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
|
||||
function renderList(categories, container, parentId){
|
||||
// Translate category names if needed
|
||||
var count = 0;
|
||||
categories.forEach(function(category, idx, parent) {
|
||||
translator.translate(category.name, function(translated) {
|
||||
categories.forEach(function (category, idx, parent) {
|
||||
translator.translate(category.name, function (translated) {
|
||||
if (category.name !== translated) {
|
||||
category.name = translated;
|
||||
}
|
||||
@@ -175,11 +175,11 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
|
||||
templates.parse('admin/partials/categories/category-rows', {
|
||||
cid: parentId,
|
||||
categories: categories
|
||||
}, function(html) {
|
||||
}, function (html) {
|
||||
container.append(html);
|
||||
|
||||
// Handle and children categories in this level have
|
||||
for(var x=0,numCategories=categories.length;x<numCategories;x++) {
|
||||
for(var x = 0,numCategories = categories.length;x < numCategories;x++) {
|
||||
renderList(categories[x].children, $('li[data-cid="' + categories[x].cid + '"]'), categories[x].cid);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
"use strict";
|
||||
/*global define, ajaxify, utils */
|
||||
|
||||
define('admin/manage/category-analytics', ['Chart'], function(Chart) {
|
||||
define('admin/manage/category-analytics', ['Chart'], function (Chart) {
|
||||
var CategoryAnalytics = {};
|
||||
|
||||
CategoryAnalytics.init = function() {
|
||||
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) {
|
||||
var hourlyLabels = utils.getHoursArray().map(function (text, idx) {
|
||||
return idx % 3 ? '' : text;
|
||||
});
|
||||
var dailyLabels = utils.getDaysArray().map(function(text, idx) {
|
||||
var dailyLabels = utils.getDaysArray().map(function (text, idx) {
|
||||
return idx % 3 ? '' : text;
|
||||
});
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ define('admin/manage/category', [
|
||||
'iconSelect',
|
||||
'admin/modules/colorpicker',
|
||||
'autocomplete'
|
||||
], function(uploader, iconSelect, colorpicker, autocomplete) {
|
||||
], function (uploader, iconSelect, colorpicker, autocomplete) {
|
||||
var Category = {};
|
||||
|
||||
Category.init = function() {
|
||||
Category.init = function () {
|
||||
var modified_categories = {};
|
||||
|
||||
function modified(el) {
|
||||
@@ -28,7 +28,7 @@ define('admin/manage/category', [
|
||||
e.preventDefault();
|
||||
|
||||
if(Object.keys(modified_categories).length) {
|
||||
socket.emit('admin.categories.update', modified_categories, function(err, result) {
|
||||
socket.emit('admin.categories.update', modified_categories, function (err, result) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ define('admin/manage/category', [
|
||||
}
|
||||
}
|
||||
|
||||
$('.blockclass, form.category select').each(function() {
|
||||
$('.blockclass, form.category select').each(function () {
|
||||
var $this = $(this);
|
||||
$this.val($this.attr('data-value'));
|
||||
});
|
||||
@@ -56,7 +56,7 @@ define('admin/manage/category', [
|
||||
var $inputEl = $(inputEl),
|
||||
previewEl = $inputEl.parents('[data-cid]').find('.category-preview');
|
||||
|
||||
colorpicker.enable($inputEl, function(hsb, hex) {
|
||||
colorpicker.enable($inputEl, function (hsb, hex) {
|
||||
if ($inputEl.attr('data-name') === 'bgColor') {
|
||||
previewEl.css('background-color', '#' + hex);
|
||||
} else if ($inputEl.attr('data-name') === 'color') {
|
||||
@@ -69,31 +69,31 @@ define('admin/manage/category', [
|
||||
|
||||
|
||||
$('form.category input, form.category select')
|
||||
.on('change', function(ev) {
|
||||
.on('change', function (ev) {
|
||||
modified(ev.target);
|
||||
})
|
||||
.on('keydown', function(ev) {
|
||||
.on('keydown', function (ev) {
|
||||
if (ev.which === 13) {
|
||||
ev.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('[data-name="imageClass"]').on('change', function() {
|
||||
$('[data-name="imageClass"]').on('change', function () {
|
||||
$('.category-preview').css('background-size', $(this).val());
|
||||
});
|
||||
|
||||
$('[data-name="bgColor"], [data-name="color"]').each(enableColorPicker);
|
||||
|
||||
$('#save').on('click', save);
|
||||
$('.purge').on('click', function(e) {
|
||||
$('.purge').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
bootbox.confirm('<p class="lead">Do you really want to purge this category "' + $('form.category').find('input[data-name="name"]').val() + '"?</p><h5><strong class="text-danger">Warning!</strong> All topics and posts in this category will be purged!</h5> <p class="help-block">Purging a category will remove all topics and posts, and delete the category from the database. If you want to remove a category <em>temporarily</em>, you\'ll want to "disable" the category instead.</p>', function(confirm) {
|
||||
bootbox.confirm('<p class="lead">Do you really want to purge this category "' + $('form.category').find('input[data-name="name"]').val() + '"?</p><h5><strong class="text-danger">Warning!</strong> All topics and posts in this category will be purged!</h5> <p class="help-block">Purging a category will remove all topics and posts, and delete the category from the database. If you want to remove a category <em>temporarily</em>, you\'ll want to "disable" the category instead.</p>', function (confirm) {
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
socket.emit('admin.categories.purge', ajaxify.data.category.cid, function(err) {
|
||||
socket.emit('admin.categories.purge', ajaxify.data.category.cid, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -103,9 +103,9 @@ define('admin/manage/category', [
|
||||
});
|
||||
});
|
||||
|
||||
$('.copy-settings').on('click', function() {
|
||||
selectCategoryModal(function(cid) {
|
||||
socket.emit('admin.categories.copySettingsFrom', {fromCid: cid, toCid: ajaxify.data.category.cid}, function(err) {
|
||||
$('.copy-settings').on('click', function () {
|
||||
selectCategoryModal(function (cid) {
|
||||
socket.emit('admin.categories.copySettingsFrom', {fromCid: cid, toCid: ajaxify.data.category.cid}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ define('admin/manage/category', [
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.upload-button').on('click', function() {
|
||||
$('.upload-button').on('click', function () {
|
||||
var inputEl = $(this);
|
||||
var cid = inputEl.attr('data-cid');
|
||||
|
||||
@@ -124,7 +124,7 @@ define('admin/manage/category', [
|
||||
title: 'Upload category image',
|
||||
route: config.relative_path + '/api/admin/category/uploadpicture',
|
||||
params: {cid: cid}
|
||||
}, function(imageUrlOnServer) {
|
||||
}, function (imageUrlOnServer) {
|
||||
$('#category-image').val(imageUrlOnServer);
|
||||
var previewBox = inputEl.parent().parent().siblings('.category-preview');
|
||||
previewBox.css('background', 'url(' + imageUrlOnServer + '?' + new Date().getTime() + ')');
|
||||
@@ -133,11 +133,11 @@ define('admin/manage/category', [
|
||||
});
|
||||
});
|
||||
|
||||
$('#category-image').on('change', function() {
|
||||
$('#category-image').on('change', function () {
|
||||
$('.category-preview').css('background-image', $(this).val() ? ('url("' + $(this).val() + '")') : '');
|
||||
});
|
||||
|
||||
$('.delete-image').on('click', function(e) {
|
||||
$('.delete-image').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var inputEl = $('#category-image');
|
||||
@@ -149,18 +149,18 @@ define('admin/manage/category', [
|
||||
$(this).parent().addClass('hide').hide();
|
||||
});
|
||||
|
||||
$('.category-preview').on('click', function() {
|
||||
$('.category-preview').on('click', function () {
|
||||
iconSelect.init($(this).find('i'), modified);
|
||||
});
|
||||
|
||||
$('button[data-action="setParent"], button[data-action="changeParent"]').on('click', Category.launchParentSelector);
|
||||
$('button[data-action="removeParent"]').on('click', function() {
|
||||
var payload= {};
|
||||
$('button[data-action="removeParent"]').on('click', function () {
|
||||
var payload = {};
|
||||
payload[ajaxify.data.category.cid] = {
|
||||
parentCid: 0
|
||||
};
|
||||
|
||||
socket.emit('admin.categories.update', payload, function(err) {
|
||||
socket.emit('admin.categories.update', payload, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -173,8 +173,8 @@ define('admin/manage/category', [
|
||||
Category.setupPrivilegeTable();
|
||||
};
|
||||
|
||||
Category.setupPrivilegeTable = function() {
|
||||
$('.privilege-table-container').on('change', 'input[type="checkbox"]', function() {
|
||||
Category.setupPrivilegeTable = function () {
|
||||
$('.privilege-table-container').on('change', 'input[type="checkbox"]', function () {
|
||||
var checkboxEl = $(this),
|
||||
privilege = checkboxEl.parent().attr('data-privilege'),
|
||||
state = checkboxEl.prop('checked'),
|
||||
@@ -185,7 +185,7 @@ define('admin/manage/category', [
|
||||
|
||||
if (member) {
|
||||
if (isGroup && privilege === 'groups:moderate' && !isPrivate && state) {
|
||||
bootbox.confirm('<strong>Are you sure you wish to grant the moderation privilege to this user group?</strong> This group is public, and any users can join at will.', function(confirm) {
|
||||
bootbox.confirm('<strong>Are you sure you wish to grant the moderation privilege to this user group?</strong> This group is public, and any users can join at will.', function (confirm) {
|
||||
if (confirm) {
|
||||
Category.setPrivilege(member, privilege, state, checkboxEl);
|
||||
} else {
|
||||
@@ -208,36 +208,36 @@ define('admin/manage/category', [
|
||||
Category.exposeAssumedPrivileges();
|
||||
};
|
||||
|
||||
Category.refreshPrivilegeTable = function() {
|
||||
socket.emit('admin.categories.getPrivilegeSettings', ajaxify.data.category.cid, function(err, privileges) {
|
||||
Category.refreshPrivilegeTable = function () {
|
||||
socket.emit('admin.categories.getPrivilegeSettings', ajaxify.data.category.cid, function (err, privileges) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
templates.parse('admin/partials/categories/privileges', {
|
||||
privileges: privileges
|
||||
}, function(html) {
|
||||
}, function (html) {
|
||||
$('.privilege-table-container').html(html);
|
||||
Category.exposeAssumedPrivileges();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Category.exposeAssumedPrivileges = function() {
|
||||
Category.exposeAssumedPrivileges = function () {
|
||||
/*
|
||||
If registered-users has a privilege enabled, then all users and groups of that privilege
|
||||
should be assumed to have that privilege as well, even if not set in the db, so reflect
|
||||
this arrangement in the table
|
||||
*/
|
||||
var privs = [];
|
||||
$('.privilege-table tr[data-group-name="registered-users"] td input[type="checkbox"]').parent().each(function(idx, el) {
|
||||
$('.privilege-table tr[data-group-name="registered-users"] td input[type="checkbox"]').parent().each(function (idx, el) {
|
||||
if ($(el).find('input').prop('checked')) {
|
||||
privs.push(el.getAttribute('data-privilege'));
|
||||
}
|
||||
});
|
||||
for(var x=0,numPrivs=privs.length;x<numPrivs;x++) {
|
||||
for(var x = 0,numPrivs = privs.length;x < numPrivs;x++) {
|
||||
var inputs = $('.privilege-table tr[data-group-name]:not([data-group-name="registered-users"],[data-group-name="guests"]) td[data-privilege="' + privs[x] + '"] input');
|
||||
inputs.each(function(idx, el) {
|
||||
inputs.each(function (idx, el) {
|
||||
if (!el.checked) {
|
||||
el.indeterminate = true;
|
||||
}
|
||||
@@ -245,13 +245,13 @@ define('admin/manage/category', [
|
||||
}
|
||||
};
|
||||
|
||||
Category.setPrivilege = function(member, privilege, state, checkboxEl) {
|
||||
Category.setPrivilege = function (member, privilege, state, checkboxEl) {
|
||||
socket.emit('admin.categories.setPrivilege', {
|
||||
cid: ajaxify.data.category.cid,
|
||||
privilege: privilege,
|
||||
set: state,
|
||||
member: member
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -261,25 +261,25 @@ define('admin/manage/category', [
|
||||
});
|
||||
};
|
||||
|
||||
Category.launchParentSelector = function() {
|
||||
socket.emit('categories.get', function(err, categories) {
|
||||
Category.launchParentSelector = function () {
|
||||
socket.emit('categories.get', function (err, categories) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
categories = categories.filter(function(category) {
|
||||
categories = categories.filter(function (category) {
|
||||
return category && !category.disabled && parseInt(category.cid, 10) !== parseInt(ajaxify.data.category.cid, 10);
|
||||
});
|
||||
|
||||
templates.parse('partials/category_list', {
|
||||
categories: categories
|
||||
}, function(html) {
|
||||
}, function (html) {
|
||||
var modal = bootbox.dialog({
|
||||
message: html,
|
||||
title: 'Set Parent Category'
|
||||
});
|
||||
|
||||
modal.find('li[data-cid]').on('click', function() {
|
||||
modal.find('li[data-cid]').on('click', function () {
|
||||
var parentCid = $(this).attr('data-cid'),
|
||||
payload = {};
|
||||
|
||||
@@ -287,11 +287,11 @@ define('admin/manage/category', [
|
||||
parentCid: parentCid
|
||||
};
|
||||
|
||||
socket.emit('admin.categories.update', payload, function(err) {
|
||||
socket.emit('admin.categories.update', payload, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
var parent = categories.filter(function(category) {
|
||||
var parent = categories.filter(function (category) {
|
||||
return category && parseInt(category.cid, 10) === parseInt(parentCid, 10);
|
||||
});
|
||||
parent = parent[0];
|
||||
@@ -307,23 +307,23 @@ define('admin/manage/category', [
|
||||
});
|
||||
};
|
||||
|
||||
Category.addUserToPrivilegeTable = function() {
|
||||
Category.addUserToPrivilegeTable = function () {
|
||||
var modal = bootbox.dialog({
|
||||
title: 'Find a User',
|
||||
message: '<input class="form-control input-lg" placeholder="Search for a user here..." />',
|
||||
show: true
|
||||
});
|
||||
|
||||
modal.on('shown.bs.modal', function() {
|
||||
modal.on('shown.bs.modal', function () {
|
||||
var inputEl = modal.find('input');
|
||||
|
||||
autocomplete.user(inputEl, function(ev, ui) {
|
||||
autocomplete.user(inputEl, function (ev, ui) {
|
||||
socket.emit('admin.categories.setPrivilege', {
|
||||
cid: ajaxify.data.category.cid,
|
||||
privilege: ['find', 'read', 'topics:read'],
|
||||
set: true,
|
||||
member: ui.item.user.uid
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -335,23 +335,23 @@ define('admin/manage/category', [
|
||||
});
|
||||
};
|
||||
|
||||
Category.addGroupToPrivilegeTable = function() {
|
||||
Category.addGroupToPrivilegeTable = function () {
|
||||
var modal = bootbox.dialog({
|
||||
title: 'Find a Group',
|
||||
message: '<input class="form-control input-lg" placeholder="Search for a group here..." />',
|
||||
show: true
|
||||
});
|
||||
|
||||
modal.on('shown.bs.modal', function() {
|
||||
modal.on('shown.bs.modal', function () {
|
||||
var inputEl = modal.find('input');
|
||||
|
||||
autocomplete.group(inputEl, function(ev, ui) {
|
||||
autocomplete.group(inputEl, function (ev, ui) {
|
||||
socket.emit('admin.categories.setPrivilege', {
|
||||
cid: ajaxify.data.category.cid,
|
||||
privilege: ['groups:find', 'groups:read', 'groups:topics:read'],
|
||||
set: true,
|
||||
member: ui.item.group.name
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -363,8 +363,8 @@ define('admin/manage/category', [
|
||||
});
|
||||
};
|
||||
|
||||
Category.copyPrivilegesToChildren = function() {
|
||||
socket.emit('admin.categories.copyPrivilegesToChildren', ajaxify.data.category.cid, function(err) {
|
||||
Category.copyPrivilegesToChildren = function () {
|
||||
socket.emit('admin.categories.copyPrivilegesToChildren', ajaxify.data.category.cid, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -372,9 +372,9 @@ define('admin/manage/category', [
|
||||
});
|
||||
};
|
||||
|
||||
Category.copyPrivilegesFromCategory = function() {
|
||||
selectCategoryModal(function(cid) {
|
||||
socket.emit('admin.categories.copyPrivilegesFrom', {toCid: ajaxify.data.category.cid, fromCid: cid}, function(err) {
|
||||
Category.copyPrivilegesFromCategory = function () {
|
||||
selectCategoryModal(function (cid) {
|
||||
socket.emit('admin.categories.copyPrivilegesFrom', {toCid: ajaxify.data.category.cid, fromCid: cid}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -384,14 +384,14 @@ define('admin/manage/category', [
|
||||
};
|
||||
|
||||
function selectCategoryModal(callback) {
|
||||
socket.emit('admin.categories.getNames', function(err, categories) {
|
||||
socket.emit('admin.categories.getNames', function (err, categories) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
templates.parse('admin/partials/categories/select-category', {
|
||||
categories: categories
|
||||
}, function(html) {
|
||||
}, function (html) {
|
||||
function submit() {
|
||||
var formData = modal.find('form').serializeObject();
|
||||
callback(formData['select-cid']);
|
||||
|
||||
@@ -5,11 +5,11 @@ define('admin/manage/flags', [
|
||||
'autocomplete',
|
||||
'Chart',
|
||||
'components'
|
||||
], function(autocomplete, Chart, components) {
|
||||
], function (autocomplete, Chart, components) {
|
||||
|
||||
var Flags = {};
|
||||
|
||||
Flags.init = function() {
|
||||
Flags.init = function () {
|
||||
$('.post-container .content img:not(.not-responsive)').addClass('img-responsive');
|
||||
|
||||
autocomplete.user($('#byUsername'));
|
||||
@@ -30,19 +30,19 @@ define('admin/manage/flags', [
|
||||
};
|
||||
|
||||
function handleDismiss() {
|
||||
$('.flags').on('click', '.dismiss', function() {
|
||||
$('.flags').on('click', '.dismiss', function () {
|
||||
var btn = $(this);
|
||||
var pid = btn.parents('[data-pid]').attr('data-pid');
|
||||
|
||||
socket.emit('posts.dismissFlag', pid, function(err) {
|
||||
socket.emit('posts.dismissFlag', pid, function (err) {
|
||||
done(err, btn);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function handleDismissAll() {
|
||||
$('#dismissAll').on('click', function() {
|
||||
socket.emit('posts.dismissAllFlags', function(err) {
|
||||
$('#dismissAll').on('click', function () {
|
||||
socket.emit('posts.dismissAllFlags', function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -54,15 +54,15 @@ define('admin/manage/flags', [
|
||||
}
|
||||
|
||||
function handleDelete() {
|
||||
$('.flags').on('click', '.delete', function() {
|
||||
$('.flags').on('click', '.delete', function () {
|
||||
var btn = $(this);
|
||||
bootbox.confirm('Do you really want to delete this post?', function(confirm) {
|
||||
bootbox.confirm('Do you really want to delete this post?', function (confirm) {
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
var pid = btn.parents('[data-pid]').attr('data-pid');
|
||||
var tid = btn.parents('[data-pid]').attr('data-tid');
|
||||
socket.emit('posts.delete', {pid: pid, tid: tid}, function(err) {
|
||||
socket.emit('posts.delete', {pid: pid, tid: tid}, function (err) {
|
||||
done(err, btn);
|
||||
});
|
||||
});
|
||||
@@ -73,7 +73,7 @@ define('admin/manage/flags', [
|
||||
if (err) {
|
||||
return app.alertError(err.messaage);
|
||||
}
|
||||
btn.parents('[data-pid]').fadeOut(function() {
|
||||
btn.parents('[data-pid]').fadeOut(function () {
|
||||
$(this).remove();
|
||||
if (!$('.flags [data-pid]').length) {
|
||||
$('.post-container').text('No flagged posts!');
|
||||
@@ -83,7 +83,7 @@ define('admin/manage/flags', [
|
||||
|
||||
function handleGraphs() {
|
||||
var dailyCanvas = document.getElementById('flags:daily');
|
||||
var dailyLabels = utils.getDaysArray().map(function(text, idx) {
|
||||
var dailyLabels = utils.getDaysArray().map(function (text, idx) {
|
||||
return idx % 3 ? '' : text;
|
||||
});
|
||||
|
||||
@@ -133,12 +133,12 @@ define('admin/manage/flags', [
|
||||
// As the flag details are returned in the API, update the form controls to show the correct data
|
||||
|
||||
// Create reference hash for use in this method
|
||||
source = source.reduce(function(memo, cur) {
|
||||
source = source.reduce(function (memo, cur) {
|
||||
memo[cur.pid] = cur.flagData;
|
||||
return memo;
|
||||
}, {});
|
||||
|
||||
components.get('posts/flag').each(function(idx, el) {
|
||||
components.get('posts/flag').each(function (idx, el) {
|
||||
var pid = el.getAttribute('data-pid');
|
||||
var el = $(el);
|
||||
|
||||
@@ -159,7 +159,7 @@ define('admin/manage/flags', [
|
||||
socket.emit('posts.updateFlag', {
|
||||
pid: pid,
|
||||
data: formData
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
} else {
|
||||
|
||||
@@ -6,10 +6,10 @@ define('admin/manage/group', [
|
||||
'iconSelect',
|
||||
'admin/modules/colorpicker',
|
||||
'translator'
|
||||
], function(memberList, iconSelect, colorpicker, translator) {
|
||||
], function (memberList, iconSelect, colorpicker, translator) {
|
||||
var Groups = {};
|
||||
|
||||
Groups.init = function() {
|
||||
Groups.init = function () {
|
||||
var groupDetailsSearch = $('#group-details-search'),
|
||||
groupDetailsSearchResults = $('#group-details-search-results'),
|
||||
groupIcon = $('#group-icon'),
|
||||
@@ -23,25 +23,25 @@ define('admin/manage/group', [
|
||||
|
||||
memberList.init();
|
||||
|
||||
changeGroupUserTitle.keyup(function() {
|
||||
changeGroupUserTitle.keyup(function () {
|
||||
groupLabelPreview.text(changeGroupUserTitle.val());
|
||||
});
|
||||
|
||||
changeGroupLabelColor.keyup(function() {
|
||||
changeGroupLabelColor.keyup(function () {
|
||||
groupLabelPreview.css('background', changeGroupLabelColor.val() || '#000000');
|
||||
});
|
||||
|
||||
groupDetailsSearch.on('keyup', function() {
|
||||
groupDetailsSearch.on('keyup', function () {
|
||||
|
||||
if (searchDelay) {
|
||||
clearTimeout(searchDelay);
|
||||
}
|
||||
|
||||
searchDelay = setTimeout(function() {
|
||||
searchDelay = setTimeout(function () {
|
||||
var searchText = groupDetailsSearch.val(),
|
||||
foundUser;
|
||||
|
||||
socket.emit('admin.user.search', {query: searchText}, function(err, results) {
|
||||
socket.emit('admin.user.search', {query: searchText}, function (err, results) {
|
||||
if (!err && results && results.users.length > 0) {
|
||||
var numResults = results.users.length, x;
|
||||
if (numResults > 20) {
|
||||
@@ -75,14 +75,14 @@ define('admin/manage/group', [
|
||||
}, 200);
|
||||
});
|
||||
|
||||
groupDetailsSearchResults.on('click', 'li[data-uid]', function() {
|
||||
groupDetailsSearchResults.on('click', 'li[data-uid]', function () {
|
||||
var userLabel = $(this),
|
||||
uid = parseInt(userLabel.attr('data-uid'), 10);
|
||||
|
||||
socket.emit('admin.groups.join', {
|
||||
groupName: groupName,
|
||||
uid: uid
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -96,15 +96,15 @@ define('admin/manage/group', [
|
||||
"icon:text": userLabel.attr('data-usericon-text')
|
||||
};
|
||||
|
||||
templates.parse('partials/groups/memberlist', 'members', {group: {isOwner: ajaxify.data.group.isOwner, members: [member]}}, function(html) {
|
||||
translator.translate(html, function(html) {
|
||||
templates.parse('partials/groups/memberlist', 'members', {group: {isOwner: ajaxify.data.group.isOwner, members: [member]}}, function (html) {
|
||||
translator.translate(html, function (html) {
|
||||
$('[component="groups/members"] tbody').prepend(html);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('[component="groups/members"]').on('click', '[data-action]', function() {
|
||||
$('[component="groups/members"]').on('click', '[data-action]', function () {
|
||||
var btnEl = $(this),
|
||||
userRow = btnEl.parents('[data-uid]'),
|
||||
ownerFlagEl = userRow.find('.member-name i'),
|
||||
@@ -117,7 +117,7 @@ define('admin/manage/group', [
|
||||
socket.emit('groups.' + (isOwner ? 'rescind' : 'grant'), {
|
||||
toUid: uid,
|
||||
groupName: groupName
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -126,14 +126,14 @@ define('admin/manage/group', [
|
||||
break;
|
||||
|
||||
case 'kick':
|
||||
bootbox.confirm('Are you sure you want to remove this user?', function(confirm) {
|
||||
bootbox.confirm('Are you sure you want to remove this user?', function (confirm) {
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
socket.emit('admin.groups.leave', {
|
||||
uid: uid,
|
||||
groupName: groupName
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -147,15 +147,15 @@ define('admin/manage/group', [
|
||||
}
|
||||
});
|
||||
|
||||
$('#group-icon').on('click', function() {
|
||||
$('#group-icon').on('click', function () {
|
||||
iconSelect.init(groupIcon);
|
||||
});
|
||||
|
||||
colorpicker.enable(changeGroupLabelColor, function(hsb, hex) {
|
||||
colorpicker.enable(changeGroupLabelColor, function (hsb, hex) {
|
||||
groupLabelPreview.css('background-color', '#' + hex);
|
||||
});
|
||||
|
||||
$('.save').on('click', function() {
|
||||
$('.save').on('click', function () {
|
||||
socket.emit('admin.groups.update', {
|
||||
groupName: groupName,
|
||||
values: {
|
||||
@@ -169,7 +169,7 @@ define('admin/manage/group', [
|
||||
hidden: $('#group-hidden').is(':checked'),
|
||||
disableJoinRequests: $('#group-disableJoinRequests').is(':checked')
|
||||
}
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
define('admin/manage/groups', [
|
||||
'translator',
|
||||
'components'
|
||||
], function(translator, components) {
|
||||
], function (translator, components) {
|
||||
var Groups = {};
|
||||
|
||||
var intervalId = 0;
|
||||
|
||||
Groups.init = function() {
|
||||
Groups.init = function () {
|
||||
var createModal = $('#create-modal'),
|
||||
createGroupName = $('#create-group-name'),
|
||||
createModalGo = $('#create-modal-go'),
|
||||
@@ -17,30 +17,30 @@ define('admin/manage/groups', [
|
||||
|
||||
handleSearch();
|
||||
|
||||
createModal.on('keypress', function(e) {
|
||||
createModal.on('keypress', function (e) {
|
||||
if (e.keyCode === 13) {
|
||||
createModalGo.click();
|
||||
}
|
||||
});
|
||||
|
||||
$('#create').on('click', function() {
|
||||
$('#create').on('click', function () {
|
||||
createModal.modal('show');
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
createGroupName.focus();
|
||||
}, 250);
|
||||
});
|
||||
|
||||
createModalGo.on('click', function() {
|
||||
createModalGo.on('click', function () {
|
||||
var submitObj = {
|
||||
name: createGroupName.val(),
|
||||
description: $('#create-group-desc').val()
|
||||
},
|
||||
errorText;
|
||||
|
||||
socket.emit('admin.groups.create', submitObj, function(err) {
|
||||
socket.emit('admin.groups.create', submitObj, function (err) {
|
||||
if (err) {
|
||||
if (err.hasOwnProperty('message') && utils.hasLanguageKey(err.message)) {
|
||||
translator.translate(err.message, config.defaultLang, function(translated) {
|
||||
translator.translate(err.message, config.defaultLang, function (translated) {
|
||||
createModalError.html(translated).removeClass('hide');
|
||||
});
|
||||
} else {
|
||||
@@ -49,7 +49,7 @@ define('admin/manage/groups', [
|
||||
} else {
|
||||
createModalError.addClass('hide');
|
||||
createGroupName.val('');
|
||||
createModal.on('hidden.bs.modal', function() {
|
||||
createModal.on('hidden.bs.modal', function () {
|
||||
ajaxify.refresh();
|
||||
});
|
||||
createModal.modal('hide');
|
||||
@@ -57,18 +57,18 @@ define('admin/manage/groups', [
|
||||
});
|
||||
});
|
||||
|
||||
$('.groups-list').on('click', 'button[data-action]', function() {
|
||||
$('.groups-list').on('click', 'button[data-action]', function () {
|
||||
var el = $(this),
|
||||
action = el.attr('data-action'),
|
||||
groupName = el.parents('tr[data-groupname]').attr('data-groupname');
|
||||
|
||||
switch (action) {
|
||||
case 'delete':
|
||||
bootbox.confirm('Are you sure you wish to delete this group?', function(confirm) {
|
||||
bootbox.confirm('Are you sure you wish to delete this group?', function (confirm) {
|
||||
if (confirm) {
|
||||
socket.emit('groups.delete', {
|
||||
groupName: groupName
|
||||
}, function(err, data) {
|
||||
}, function (err, data) {
|
||||
if(err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -94,14 +94,14 @@ define('admin/manage/groups', [
|
||||
options: {
|
||||
sort: 'date'
|
||||
}
|
||||
}, function(err, groups) {
|
||||
}, function (err, groups) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
templates.parse('admin/manage/groups', 'groups', {
|
||||
groups: groups
|
||||
}, function(html) {
|
||||
}, function (html) {
|
||||
groupsEl.find('[data-groupname]').remove();
|
||||
groupsEl.find('tr').after(html);
|
||||
});
|
||||
@@ -110,7 +110,7 @@ define('admin/manage/groups', [
|
||||
|
||||
var queryEl = $('#group-search');
|
||||
|
||||
queryEl.on('keyup', function() {
|
||||
queryEl.on('keyup', function () {
|
||||
if (intervalId) {
|
||||
clearTimeout(intervalId);
|
||||
intervalId = 0;
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
'use strict';
|
||||
/* globals $, app, socket, templates, define, bootbox */
|
||||
|
||||
define('admin/manage/ip-blacklist', [], function() {
|
||||
define('admin/manage/ip-blacklist', [], function () {
|
||||
|
||||
var Blacklist = {};
|
||||
|
||||
Blacklist.init = function() {
|
||||
Blacklist.init = function () {
|
||||
var blacklist = $('#blacklist-rules');
|
||||
|
||||
blacklist.on('keyup', function() {
|
||||
blacklist.on('keyup', function () {
|
||||
$('#blacklist-rules-holder').val(blacklist.val());
|
||||
});
|
||||
|
||||
$('[data-action="apply"]').on('click', function() {
|
||||
socket.emit('blacklist.save', blacklist.val(), function(err) {
|
||||
$('[data-action="apply"]').on('click', function () {
|
||||
socket.emit('blacklist.save', blacklist.val(), function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -25,15 +25,15 @@ define('admin/manage/ip-blacklist', [], function() {
|
||||
});
|
||||
});
|
||||
|
||||
$('[data-action="test"]').on('click', function() {
|
||||
$('[data-action="test"]').on('click', function () {
|
||||
socket.emit('blacklist.validate', {
|
||||
rules: blacklist.val()
|
||||
}, function(err, data) {
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
templates.parse('admin/partials/blacklist-validate', data, function(html) {
|
||||
templates.parse('admin/partials/blacklist-validate', data, function (html) {
|
||||
bootbox.alert(html);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
|
||||
/* global config, socket, define, templates, bootbox, app, ajaxify, */
|
||||
|
||||
define('admin/manage/registration', function() {
|
||||
define('admin/manage/registration', function () {
|
||||
var Registration = {};
|
||||
|
||||
Registration.init = function() {
|
||||
Registration.init = function () {
|
||||
|
||||
$('.users-list').on('click', '[data-action]', function(ev) {
|
||||
$('.users-list').on('click', '[data-action]', function (ev) {
|
||||
var parent = $(this).parents('[data-username]');
|
||||
var action = $(this).attr('data-action');
|
||||
var username = parent.attr('data-username');
|
||||
var method = action === 'accept' ? 'admin.user.acceptRegistration' : 'admin.user.rejectRegistration';
|
||||
|
||||
socket.emit(method, {username: username}, function(err) {
|
||||
socket.emit(method, {username: username}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -22,7 +22,7 @@ define('admin/manage/registration', function() {
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.invites-list').on('click', '[data-action]', function(ev) {
|
||||
$('.invites-list').on('click', '[data-action]', function (ev) {
|
||||
var parent = $(this).parents('[data-invitation-mail][data-invited-by]');
|
||||
var email = parent.attr('data-invitation-mail');
|
||||
var invitedBy = parent.attr('data-invited-by');
|
||||
@@ -39,9 +39,9 @@ define('admin/manage/registration', function() {
|
||||
parent.remove();
|
||||
};
|
||||
if (action === 'delete') {
|
||||
bootbox.confirm('Are you sure you wish to delete this invitation?', function(confirm) {
|
||||
bootbox.confirm('Are you sure you wish to delete this invitation?', function (confirm) {
|
||||
if (confirm) {
|
||||
socket.emit(method, {email: email, invitedBy: invitedBy}, function(err) {
|
||||
socket.emit(method, {email: email, invitedBy: invitedBy}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ define('admin/manage/tags', [
|
||||
'forum/infinitescroll',
|
||||
'admin/modules/selectable',
|
||||
'admin/modules/colorpicker'
|
||||
], function(infinitescroll, selectable, colorpicker) {
|
||||
], function (infinitescroll, selectable, colorpicker) {
|
||||
var Tags = {},
|
||||
timeoutId = 0;
|
||||
|
||||
Tags.init = function() {
|
||||
Tags.init = function () {
|
||||
selectable.enable('.tag-management', '.tag-row');
|
||||
|
||||
handleCreate();
|
||||
@@ -23,29 +23,29 @@ define('admin/manage/tags', [
|
||||
var createTagName = $('#create-tag-name');
|
||||
var createModalGo = $('#create-modal-go');
|
||||
|
||||
createModal.on('keypress', function(e) {
|
||||
createModal.on('keypress', function (e) {
|
||||
if (e.keyCode === 13) {
|
||||
createModalGo.click();
|
||||
}
|
||||
});
|
||||
|
||||
$('#create').on('click', function() {
|
||||
$('#create').on('click', function () {
|
||||
createModal.modal('show');
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
createTagName.focus();
|
||||
}, 250);
|
||||
});
|
||||
|
||||
createModalGo.on('click', function() {
|
||||
createModalGo.on('click', function () {
|
||||
socket.emit('admin.tags.create', {
|
||||
tag: createTagName.val()
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
createTagName.val('');
|
||||
createModal.on('hidden.bs.modal', function() {
|
||||
createModal.on('hidden.bs.modal', function () {
|
||||
ajaxify.refresh();
|
||||
});
|
||||
createModal.modal('hide');
|
||||
@@ -54,19 +54,19 @@ define('admin/manage/tags', [
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
$('#tag-search').on('input propertychange', function() {
|
||||
$('#tag-search').on('input propertychange', function () {
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = 0;
|
||||
}
|
||||
|
||||
timeoutId = setTimeout(function() {
|
||||
socket.emit('topics.searchAndLoadTags', {query: $('#tag-search').val()}, function(err, result) {
|
||||
timeoutId = setTimeout(function () {
|
||||
socket.emit('topics.searchAndLoadTags', {query: $('#tag-search').val()}, function (err, result) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
app.parseAndTranslate('admin/manage/tags', 'tags', {tags: result.tags}, function(html) {
|
||||
app.parseAndTranslate('admin/manage/tags', 'tags', {tags: result.tags}, function (html) {
|
||||
$('.tag-list').html(html);
|
||||
utils.makeNumbersHumanReadable(html.find('.human-readable-number'));
|
||||
timeoutId = 0;
|
||||
@@ -79,7 +79,7 @@ define('admin/manage/tags', [
|
||||
}
|
||||
|
||||
function handleModify() {
|
||||
$('#modify').on('click', function() {
|
||||
$('#modify').on('click', function () {
|
||||
var tagsToModify = $('.tag-row.ui-selected');
|
||||
if (!tagsToModify.length) {
|
||||
return;
|
||||
@@ -95,12 +95,12 @@ define('admin/manage/tags', [
|
||||
success: {
|
||||
label: "Save",
|
||||
className: "btn-primary save",
|
||||
callback: function() {
|
||||
callback: function () {
|
||||
var modal = $('.bootbox'),
|
||||
bgColor = modal.find('[data-name="bgColor"]').val(),
|
||||
color = modal.find('[data-name="color"]').val();
|
||||
|
||||
tagsToModify.each(function(idx, tag) {
|
||||
tagsToModify.each(function (idx, tag) {
|
||||
tag = $(tag);
|
||||
|
||||
tag.find('[data-name="bgColor"]').val(bgColor);
|
||||
@@ -119,21 +119,21 @@ define('admin/manage/tags', [
|
||||
}
|
||||
|
||||
function handleDeleteSelected() {
|
||||
$('#deleteSelected').on('click', function() {
|
||||
$('#deleteSelected').on('click', function () {
|
||||
var tagsToDelete = $('.tag-row.ui-selected');
|
||||
if (!tagsToDelete.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
bootbox.confirm('Do you want to delete the selected tags?', function(confirm) {
|
||||
bootbox.confirm('Do you want to delete the selected tags?', function (confirm) {
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
var tags = [];
|
||||
tagsToDelete.each(function(index, el) {
|
||||
tagsToDelete.each(function (index, el) {
|
||||
tags.push($(el).attr('data-tag'));
|
||||
});
|
||||
socket.emit('admin.tags.deleteTags', {tags: tags}, function(err) {
|
||||
socket.emit('admin.tags.deleteTags', {tags: tags}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -159,7 +159,7 @@ define('admin/manage/tags', [
|
||||
color : tag.find('[data-name="color"]').val()
|
||||
};
|
||||
|
||||
socket.emit('admin.tags.update', data, function(err) {
|
||||
socket.emit('admin.tags.update', data, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
/* global config, socket, define, templates, bootbox, app, ajaxify */
|
||||
|
||||
define('admin/manage/users', ['translator'], function(translator) {
|
||||
define('admin/manage/users', ['translator'], function (translator) {
|
||||
var Users = {};
|
||||
|
||||
Users.init = function() {
|
||||
Users.init = function () {
|
||||
var navPills = $('.nav-pills li');
|
||||
var pathname = window.location.pathname;
|
||||
if (!navPills.find('a[href="' + pathname + '"]').length) {
|
||||
@@ -16,7 +16,7 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
function getSelectedUids() {
|
||||
var uids = [];
|
||||
|
||||
$('.users-table [component="user/select/single"]').each(function() {
|
||||
$('.users-table [component="user/select/single"]').each(function () {
|
||||
if ($(this).is(':checked')) {
|
||||
uids.push($(this).attr('data-uid'));
|
||||
}
|
||||
@@ -26,7 +26,7 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
}
|
||||
|
||||
function update(className, state) {
|
||||
$('.users-table [component="user/select/single"]:checked').parents('.user-row').find(className).each(function() {
|
||||
$('.users-table [component="user/select/single"]:checked').parents('.user-row').find(className).each(function () {
|
||||
$(this).toggleClass('hidden', !state);
|
||||
});
|
||||
}
|
||||
@@ -41,7 +41,7 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
}
|
||||
|
||||
function done(successMessage, className, flag) {
|
||||
return function(err) {
|
||||
return function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
};
|
||||
}
|
||||
|
||||
$('[component="user/select/all"]').on('click', function() {
|
||||
$('[component="user/select/all"]').on('click', function () {
|
||||
if ($(this).is(':checked')) {
|
||||
$('.users-table [component="user/select/single"]').prop('checked', true);
|
||||
} else {
|
||||
@@ -61,28 +61,28 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
}
|
||||
});
|
||||
|
||||
$('.ban-user').on('click', function() {
|
||||
$('.ban-user').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
app.alertError('[[error:no-users-selected]]');
|
||||
return false; // specifically to keep the menu open
|
||||
}
|
||||
|
||||
bootbox.confirm('Do you really want to ban ' + (uids.length > 1 ? 'these users' : 'this user') + ' <strong>permanently</strong>?', function(confirm) {
|
||||
bootbox.confirm('Do you really want to ban ' + (uids.length > 1 ? 'these users' : 'this user') + ' <strong>permanently</strong>?', function (confirm) {
|
||||
if (confirm) {
|
||||
socket.emit('user.banUsers', { uids: uids, reason: '' }, done('User(s) banned!', '.ban', true));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.ban-user-temporary').on('click', function() {
|
||||
$('.ban-user-temporary').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
app.alertError('[[error:no-users-selected]]');
|
||||
return false; // specifically to keep the menu open
|
||||
}
|
||||
|
||||
templates.parse('admin/partials/temporary-ban', {}, function(html) {
|
||||
templates.parse('admin/partials/temporary-ban', {}, function (html) {
|
||||
bootbox.dialog({
|
||||
className: 'ban-modal',
|
||||
title: '[[user:ban_account]]',
|
||||
@@ -95,12 +95,12 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
},
|
||||
submit: {
|
||||
label: 'Ban ' + uids.length + (uids.length > 1 ? ' users' : ' user'),
|
||||
callback: function() {
|
||||
var formData = $('.ban-modal form').serializeArray().reduce(function(data, cur) {
|
||||
callback: function () {
|
||||
var formData = $('.ban-modal form').serializeArray().reduce(function (data, cur) {
|
||||
data[cur.name] = cur.value;
|
||||
return data;
|
||||
}, {});
|
||||
var until = formData.length ? (Date.now() + formData.length * 1000*60*60 * (parseInt(formData.unit, 10) ? 24 : 1)) : 0;
|
||||
var until = formData.length ? (Date.now() + formData.length * 1000 * 60 * 60 * (parseInt(formData.unit, 10) ? 24 : 1)) : 0;
|
||||
socket.emit('user.banUsers', { uids: uids, until: until, reason: formData.reason }, done('User(s) banned!', '.ban', true));
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
});
|
||||
});
|
||||
|
||||
$('.unban-user').on('click', function() {
|
||||
$('.unban-user').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
app.alertError('[[error:no-users-selected]]');
|
||||
@@ -119,7 +119,7 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
socket.emit('user.unbanUsers', uids, done('User(s) unbanned!', '.ban', false));
|
||||
});
|
||||
|
||||
$('.reset-lockout').on('click', function() {
|
||||
$('.reset-lockout').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
return;
|
||||
@@ -128,7 +128,7 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
socket.emit('admin.user.resetLockouts', uids, done('Lockout(s) reset!'));
|
||||
});
|
||||
|
||||
$('.reset-flags').on('click', function() {
|
||||
$('.reset-flags').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
return;
|
||||
@@ -137,7 +137,7 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
socket.emit('admin.user.resetFlags', uids, done('Flags(s) reset!'));
|
||||
});
|
||||
|
||||
$('.admin-user').on('click', function() {
|
||||
$('.admin-user').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
return;
|
||||
@@ -150,7 +150,7 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
}
|
||||
});
|
||||
|
||||
$('.remove-admin-user').on('click', function() {
|
||||
$('.remove-admin-user').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
return;
|
||||
@@ -159,7 +159,7 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
if (uids.indexOf(app.user.uid.toString()) !== -1) {
|
||||
app.alertError('You can\'t remove yourself as Administrator!');
|
||||
} else {
|
||||
bootbox.confirm('Do you really want to remove admins?', function(confirm) {
|
||||
bootbox.confirm('Do you really want to remove admins?', function (confirm) {
|
||||
if (confirm) {
|
||||
socket.emit('admin.user.removeAdmins', uids, done('User(s) are no longer administrators.', '.administrator', false));
|
||||
}
|
||||
@@ -167,17 +167,17 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
}
|
||||
});
|
||||
|
||||
$('.validate-email').on('click', function() {
|
||||
$('.validate-email').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
bootbox.confirm('Do you want to validate email(s) of these user(s)?', function(confirm) {
|
||||
bootbox.confirm('Do you want to validate email(s) of these user(s)?', function (confirm) {
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
socket.emit('admin.user.validateEmail', uids, function(err) {
|
||||
socket.emit('admin.user.validateEmail', uids, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -189,12 +189,12 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
});
|
||||
});
|
||||
|
||||
$('.send-validation-email').on('click', function() {
|
||||
$('.send-validation-email').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
return;
|
||||
}
|
||||
socket.emit('admin.user.sendValidationEmail', uids, function(err) {
|
||||
socket.emit('admin.user.sendValidationEmail', uids, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -202,28 +202,28 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
});
|
||||
});
|
||||
|
||||
$('.password-reset-email').on('click', function() {
|
||||
$('.password-reset-email').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
bootbox.confirm('Do you want to send password reset email(s) to these user(s)?', function(confirm) {
|
||||
bootbox.confirm('Do you want to send password reset email(s) to these user(s)?', function (confirm) {
|
||||
if (confirm) {
|
||||
socket.emit('admin.user.sendPasswordResetEmail', uids, done('Emails sent'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.delete-user').on('click', function() {
|
||||
$('.delete-user').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
bootbox.confirm('<b>Warning!</b><br/>Do you really want to delete user(s)?<br/> This action is not reversable, only the user account will be deleted, their posts and topics will not be deleled!', function(confirm) {
|
||||
bootbox.confirm('<b>Warning!</b><br/>Do you really want to delete user(s)?<br/> This action is not reversable, only the user account will be deleted, their posts and topics will not be deleled!', function (confirm) {
|
||||
if (confirm) {
|
||||
socket.emit('admin.user.deleteUsers', uids, function(err) {
|
||||
socket.emit('admin.user.deleteUsers', uids, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -236,14 +236,14 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
});
|
||||
});
|
||||
|
||||
$('.delete-user-and-content').on('click', function() {
|
||||
$('.delete-user-and-content').on('click', function () {
|
||||
var uids = getSelectedUids();
|
||||
if (!uids.length) {
|
||||
return;
|
||||
}
|
||||
bootbox.confirm('<b>Warning!</b><br/>Do you really want to delete user(s) and their content?<br/> This action is not reversable, all user data and content will be erased!', function(confirm) {
|
||||
bootbox.confirm('<b>Warning!</b><br/>Do you really want to delete user(s) and their content?<br/> This action is not reversable, all user data and content will be erased!', function (confirm) {
|
||||
if (confirm) {
|
||||
socket.emit('admin.user.deleteUsersAndContent', uids, function(err) {
|
||||
socket.emit('admin.user.deleteUsersAndContent', uids, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -257,9 +257,9 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
});
|
||||
|
||||
function handleUserCreate() {
|
||||
$('#createUser').on('click', function() {
|
||||
templates.parse('admin/partials/create_user_modal', {}, function(html) {
|
||||
translator.translate(html, function(html) {
|
||||
$('#createUser').on('click', function () {
|
||||
templates.parse('admin/partials/create_user_modal', {}, function (html) {
|
||||
translator.translate(html, function (html) {
|
||||
bootbox.dialog({
|
||||
message: html,
|
||||
title: 'Create User',
|
||||
@@ -272,7 +272,7 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
create: {
|
||||
label: 'Create',
|
||||
className: 'btn-primary',
|
||||
callback: function() {
|
||||
callback: function () {
|
||||
createUser.call(this);
|
||||
return false;
|
||||
}
|
||||
@@ -303,13 +303,13 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
password: password
|
||||
};
|
||||
|
||||
socket.emit('admin.user.createUser', user, function(err) {
|
||||
socket.emit('admin.user.createUser', user, function (err) {
|
||||
if(err) {
|
||||
return errorEl.translateHtml('<strong>Error</strong><p>' + err.message + '</p>').removeClass('hide');
|
||||
}
|
||||
|
||||
modal.modal('hide');
|
||||
modal.on('hidden.bs.modal', function() {
|
||||
modal.on('hidden.bs.modal', function () {
|
||||
ajaxify.refresh();
|
||||
});
|
||||
app.alertSuccess('User created!');
|
||||
@@ -318,7 +318,7 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
|
||||
var timeoutId = 0;
|
||||
|
||||
$('#search-user-name, #search-user-email, #search-user-ip').on('keyup', function() {
|
||||
$('#search-user-name, #search-user-email, #search-user-ip').on('keyup', function () {
|
||||
if (timeoutId !== 0) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = 0;
|
||||
@@ -327,15 +327,15 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
var $this = $(this);
|
||||
var type = $this.attr('data-search-type');
|
||||
|
||||
timeoutId = setTimeout(function() {
|
||||
timeoutId = setTimeout(function () {
|
||||
$('.fa-spinner').removeClass('hidden');
|
||||
|
||||
socket.emit('admin.user.search', {searchBy: type, query: $this.val()}, function(err, data) {
|
||||
socket.emit('admin.user.search', {searchBy: type, query: $this.val()}, function (err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
templates.parse('admin/manage/users', 'users', data, function(html) {
|
||||
templates.parse('admin/manage/users', 'users', data, function (html) {
|
||||
html = $(html);
|
||||
$('.users-table tr').not(':first').remove();
|
||||
$('.users-table tr').first().after(html);
|
||||
@@ -367,13 +367,13 @@ define('admin/manage/users', ['translator'], function(translator) {
|
||||
};
|
||||
|
||||
function handleInvite() {
|
||||
$('[component="user/invite"]').on('click', function() {
|
||||
bootbox.prompt('Email: ', function(email) {
|
||||
$('[component="user/invite"]').on('click', function () {
|
||||
bootbox.prompt('Email: ', function (email) {
|
||||
if (!email) {
|
||||
return;
|
||||
}
|
||||
|
||||
socket.emit('user.invite', email, function(err) {
|
||||
socket.emit('user.invite', email, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
|
||||
/*globals define*/
|
||||
|
||||
define('admin/modules/colorpicker', function() {
|
||||
define('admin/modules/colorpicker', function () {
|
||||
var colorpicker = {};
|
||||
|
||||
colorpicker.enable = function(inputEl, callback) {
|
||||
(inputEl instanceof jQuery ? inputEl : $(inputEl)).each(function() {
|
||||
colorpicker.enable = function (inputEl, callback) {
|
||||
(inputEl instanceof jQuery ? inputEl : $(inputEl)).each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
$this.ColorPicker({
|
||||
color: $this.val() || '#000',
|
||||
onChange: function(hsb, hex) {
|
||||
onChange: function (hsb, hex) {
|
||||
$this.val('#' + hex);
|
||||
if (typeof callback === 'function') {
|
||||
callback(hsb, hex);
|
||||
}
|
||||
},
|
||||
onShow: function(colpkr) {
|
||||
onShow: function (colpkr) {
|
||||
$(colpkr).css('z-index', 1051);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
/*globals define, app, socket*/
|
||||
|
||||
define('admin/modules/instance', function() {
|
||||
define('admin/modules/instance', function () {
|
||||
var instance = {};
|
||||
|
||||
instance.reload = function(callback) {
|
||||
instance.reload = function (callback) {
|
||||
app.alert({
|
||||
alert_id: 'instance_reload',
|
||||
type: 'info',
|
||||
@@ -14,7 +14,7 @@ define('admin/modules/instance', function() {
|
||||
timeout: 5000
|
||||
});
|
||||
|
||||
socket.emit('admin.reload', function(err) {
|
||||
socket.emit('admin.reload', function (err) {
|
||||
if (!err) {
|
||||
app.alert({
|
||||
alert_id: 'instance_reload',
|
||||
@@ -38,7 +38,7 @@ define('admin/modules/instance', function() {
|
||||
});
|
||||
};
|
||||
|
||||
instance.restart = function(callback) {
|
||||
instance.restart = function (callback) {
|
||||
app.alert({
|
||||
alert_id: 'instance_restart',
|
||||
type: 'info',
|
||||
@@ -47,7 +47,7 @@ define('admin/modules/instance', function() {
|
||||
timeout: 5000
|
||||
});
|
||||
|
||||
$(window).one('action:reconnected', function() {
|
||||
$(window).one('action:reconnected', function () {
|
||||
app.alert({
|
||||
alert_id: 'instance_restart',
|
||||
type: 'success',
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"use strict";
|
||||
/*globals define, admin, ajaxify, RELATIVE_PATH*/
|
||||
|
||||
define(function() {
|
||||
define(function () {
|
||||
var search = {},
|
||||
searchIndex;
|
||||
|
||||
search.init = function() {
|
||||
search.init = function () {
|
||||
$.getJSON(RELATIVE_PATH + '/templates/indexed.json', function (data) {
|
||||
searchIndex = data;
|
||||
for (var file in searchIndex) {
|
||||
@@ -31,17 +31,17 @@ define(function() {
|
||||
input = $('#acp-search input'),
|
||||
firstResult = null;
|
||||
|
||||
input.on('keyup', function() {
|
||||
input.on('keyup', function () {
|
||||
$('#acp-search .dropdown').addClass('open');
|
||||
});
|
||||
|
||||
$('#acp-search').parents('form').on('submit', function(ev) {
|
||||
$('#acp-search').parents('form').on('submit', function (ev) {
|
||||
var input = $(this).find('input'),
|
||||
href = firstResult ? firstResult : RELATIVE_PATH + '/search/' + input.val();
|
||||
|
||||
ajaxify.go(href.replace(/^\//, ''));
|
||||
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
$('#acp-search .dropdown').removeClass('open');
|
||||
$(input).blur();
|
||||
}, 150);
|
||||
@@ -50,11 +50,11 @@ define(function() {
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#main-menu a').each(function(idx, link) {
|
||||
$('#main-menu a').each(function (idx, link) {
|
||||
routes.push($(link).attr('href'));
|
||||
});
|
||||
|
||||
input.on('keyup focus', function() {
|
||||
input.on('keyup focus', function () {
|
||||
var $input = $(this),
|
||||
value = $input.val().toLowerCase(),
|
||||
menuItems = $('#acp-search .dropdown-menu').html('');
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
/*globals define*/
|
||||
|
||||
define('admin/modules/selectable', ['jqueryui'], function(jqueryui) {
|
||||
define('admin/modules/selectable', ['jqueryui'], function (jqueryui) {
|
||||
var selectable = {};
|
||||
|
||||
selectable.enable = function(containerEl, targets) {
|
||||
selectable.enable = function (containerEl, targets) {
|
||||
$(containerEl).selectable({
|
||||
filter: targets
|
||||
});
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
'use strict';
|
||||
/*global define, app, socket, ajaxify */
|
||||
|
||||
define('admin/settings', ['uploader'], function(uploader) {
|
||||
define('admin/settings', ['uploader'], function (uploader) {
|
||||
var Settings = {};
|
||||
|
||||
Settings.init = function() {
|
||||
Settings.init = function () {
|
||||
console.warn('[deprecation] require(\'admin/settings\').init() has been deprecated, please call require(\'admin/settings\').prepare() directly instead.');
|
||||
Settings.prepare();
|
||||
};
|
||||
|
||||
Settings.populateTOC = function() {
|
||||
$('.settings-header').each(function() {
|
||||
Settings.populateTOC = function () {
|
||||
$('.settings-header').each(function () {
|
||||
var header = $(this).text(),
|
||||
anchor = header.toLowerCase().replace(/ /g, '-').trim();
|
||||
|
||||
@@ -19,7 +19,7 @@ define('admin/settings', ['uploader'], function(uploader) {
|
||||
});
|
||||
};
|
||||
|
||||
Settings.prepare = function(callback) {
|
||||
Settings.prepare = function (callback) {
|
||||
// Populate the fields on the page from the config
|
||||
var fields = $('#content [data-field]'),
|
||||
numFields = fields.length,
|
||||
@@ -28,7 +28,7 @@ define('admin/settings', ['uploader'], function(uploader) {
|
||||
x, key, inputType, field;
|
||||
|
||||
// Handle unsaved changes
|
||||
$(fields).on('change', function() {
|
||||
$(fields).on('change', function () {
|
||||
app.flags = app.flags || {};
|
||||
app.flags._unsaved = true;
|
||||
});
|
||||
@@ -66,11 +66,11 @@ define('admin/settings', ['uploader'], function(uploader) {
|
||||
}
|
||||
}
|
||||
|
||||
revertBtn.off('click').on('click', function() {
|
||||
revertBtn.off('click').on('click', function () {
|
||||
ajaxify.refresh();
|
||||
});
|
||||
|
||||
saveBtn.off('click').on('click', function(e) {
|
||||
saveBtn.off('click').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
saveFields(fields, function onFieldsSaved(err) {
|
||||
@@ -100,8 +100,8 @@ define('admin/settings', ['uploader'], function(uploader) {
|
||||
|
||||
handleUploads();
|
||||
|
||||
$('#clear-sitemap-cache').off('click').on('click', function() {
|
||||
socket.emit('admin.settings.clearSitemapCache', function() {
|
||||
$('#clear-sitemap-cache').off('click').on('click', function () {
|
||||
socket.emit('admin.settings.clearSitemapCache', function () {
|
||||
app.alertSuccess('Sitemap Cache Cleared!');
|
||||
});
|
||||
return false;
|
||||
@@ -111,15 +111,15 @@ define('admin/settings', ['uploader'], function(uploader) {
|
||||
callback();
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
$(window).trigger('action:admin.settingsLoaded');
|
||||
}, 0);
|
||||
};
|
||||
|
||||
function handleUploads() {
|
||||
$('#content input[data-action="upload"]').each(function() {
|
||||
$('#content input[data-action="upload"]').each(function () {
|
||||
var uploadBtn = $(this);
|
||||
uploadBtn.on('click', function() {
|
||||
uploadBtn.on('click', function () {
|
||||
uploader.show({
|
||||
title: uploadBtn.attr('data-title'),
|
||||
description: uploadBtn.attr('data-description'),
|
||||
@@ -127,7 +127,7 @@ define('admin/settings', ['uploader'], function(uploader) {
|
||||
params: {},
|
||||
showHelp: uploadBtn.attr('data-help') ? uploadBtn.attr('data-help') === 1 : undefined,
|
||||
accept: uploadBtn.attr('data-accept')
|
||||
}, function(image) {
|
||||
}, function (image) {
|
||||
// need to move these into template, ex data-callback
|
||||
if (ajaxify.currentPage === 'admin/general/sounds') {
|
||||
ajaxify.refresh();
|
||||
@@ -139,14 +139,14 @@ define('admin/settings', ['uploader'], function(uploader) {
|
||||
});
|
||||
}
|
||||
|
||||
Settings.remove = function(key) {
|
||||
Settings.remove = function (key) {
|
||||
socket.emit('admin.config.remove', key);
|
||||
};
|
||||
|
||||
function saveFields(fields, callback) {
|
||||
var data = {};
|
||||
|
||||
fields.each(function() {
|
||||
fields.each(function () {
|
||||
var field = $(this);
|
||||
var key = field.attr('data-field'),
|
||||
value, inputType;
|
||||
@@ -173,7 +173,7 @@ define('admin/settings', ['uploader'], function(uploader) {
|
||||
data[key] = value;
|
||||
});
|
||||
|
||||
socket.emit('admin.config.setMultiple', data, function(err) {
|
||||
socket.emit('admin.config.setMultiple', data, function (err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
"use strict";
|
||||
/* global define, socket, app, ajaxify, ace */
|
||||
|
||||
define('admin/settings/email', ['admin/settings'], function(settings) {
|
||||
define('admin/settings/email', ['admin/settings'], function (settings) {
|
||||
var module = {},
|
||||
emailEditor;
|
||||
|
||||
module.init = function() {
|
||||
module.init = function () {
|
||||
configureEmailTester();
|
||||
configureEmailEditor();
|
||||
|
||||
$(window).on('action:admin.settingsLoaded action:admin.settingsSaved', handleDigestHourChange);
|
||||
$(window).on('action:admin.settingsSaved', function() {
|
||||
$(window).on('action:admin.settingsSaved', function () {
|
||||
socket.emit('admin.user.restartJobs');
|
||||
});
|
||||
};
|
||||
|
||||
function configureEmailTester() {
|
||||
$('button[data-action="email.test"]').off('click').on('click', function() {
|
||||
socket.emit('admin.email.test', {template: $('#test-email').val()}, function(err) {
|
||||
$('button[data-action="email.test"]').off('click').on('click', function () {
|
||||
socket.emit('admin.email.test', {template: $('#test-email').val()}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -34,10 +34,10 @@ define('admin/settings/email', ['admin/settings'], function(settings) {
|
||||
emailEditor.setTheme("ace/theme/twilight");
|
||||
emailEditor.getSession().setMode("ace/mode/html");
|
||||
|
||||
emailEditor.on('change', function() {
|
||||
emailEditor.on('change', function () {
|
||||
var emailPath = $('#email-editor-selector').val();
|
||||
var original;
|
||||
ajaxify.data.emails.forEach(function(email) {
|
||||
ajaxify.data.emails.forEach(function (email) {
|
||||
if (email.path === emailPath) {
|
||||
original = email.original;
|
||||
}
|
||||
@@ -46,8 +46,8 @@ define('admin/settings/email', ['admin/settings'], function(settings) {
|
||||
$('#email-editor-holder').val(newEmail !== original ? newEmail : '');
|
||||
});
|
||||
|
||||
$('button[data-action="email.revert"]').off('click').on('click', function() {
|
||||
ajaxify.data.emails.forEach(function(email) {
|
||||
$('button[data-action="email.revert"]').off('click').on('click', function () {
|
||||
ajaxify.data.emails.forEach(function (email) {
|
||||
if (email.path === $('#email-editor-selector').val()) {
|
||||
emailEditor.getSession().setValue(email.original);
|
||||
$('#email-editor-holder').val('');
|
||||
@@ -59,7 +59,7 @@ define('admin/settings/email', ['admin/settings'], function(settings) {
|
||||
}
|
||||
|
||||
function updateEmailEditor() {
|
||||
ajaxify.data.emails.forEach(function(email) {
|
||||
ajaxify.data.emails.forEach(function (email) {
|
||||
if (email.path === $('#email-editor-selector').val()) {
|
||||
emailEditor.getSession().setValue(email.text);
|
||||
$('#email-editor-holder')
|
||||
@@ -78,7 +78,7 @@ define('admin/settings/email', ['admin/settings'], function(settings) {
|
||||
hour = 0;
|
||||
}
|
||||
|
||||
socket.emit('meta.getServerTime', {}, function(err, now) {
|
||||
socket.emit('meta.getServerTime', {}, function (err, now) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
"use strict";
|
||||
/* global define, socket */
|
||||
|
||||
define('admin/settings/general', ['admin/settings'], function(Settings) {
|
||||
define('admin/settings/general', ['admin/settings'], function (Settings) {
|
||||
var Module = {}
|
||||
|
||||
Module.init = function() {
|
||||
$('button[data-action="removeLogo"]').on('click', function() {
|
||||
Module.init = function () {
|
||||
$('button[data-action="removeLogo"]').on('click', function () {
|
||||
$('input[data-field="brand:logo"]').val('');
|
||||
});
|
||||
$('button[data-action="removeFavicon"]').on('click', function() {
|
||||
$('button[data-action="removeFavicon"]').on('click', function () {
|
||||
$('input[data-field="brand:favicon"]').val('');
|
||||
});
|
||||
$('button[data-action="removeTouchIcon"]').on('click', function() {
|
||||
$('button[data-action="removeTouchIcon"]').on('click', function () {
|
||||
$('input[data-field="brand:touchIcon"]').val('');
|
||||
});
|
||||
$('button[data-action="removeOgImage"]').on('click', function() {
|
||||
$('button[data-action="removeOgImage"]').on('click', function () {
|
||||
$('input[data-field="removeOgImage"]').val('');
|
||||
});
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
var ajaxify = ajaxify || {};
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
var location = document.location || window.location;
|
||||
var rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
|
||||
var apiXHR = null;
|
||||
@@ -14,7 +14,7 @@ $(document).ready(function() {
|
||||
|
||||
// Dumb hack to fool ajaxify into thinking translator is still a global
|
||||
// When ajaxify is migrated to a require.js module, then this can be merged into the "define" call
|
||||
require(['translator'], function(_translator) {
|
||||
require(['translator'], function (_translator) {
|
||||
translator = _translator;
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ $(document).ready(function() {
|
||||
url: ev.state.returnPath
|
||||
}, ev.state.returnPath, config.relative_path + '/' + ev.state.returnPath);
|
||||
} else if (ev.state.url !== undefined) {
|
||||
ajaxify.go(ev.state.url, function() {
|
||||
ajaxify.go(ev.state.url, function () {
|
||||
$(window).trigger('action:popstate', {url: ev.state.url});
|
||||
}, true);
|
||||
}
|
||||
@@ -41,7 +41,7 @@ $(document).ready(function() {
|
||||
if (ajaxify.reconnectAction) {
|
||||
$(window).off('action:reconnected', ajaxify.reconnectAction);
|
||||
}
|
||||
ajaxify.reconnectAction = function(e) {
|
||||
ajaxify.reconnectAction = function (e) {
|
||||
ajaxify.go(url, callback, quiet);
|
||||
$(window).off(e);
|
||||
};
|
||||
@@ -75,7 +75,7 @@ $(document).ready(function() {
|
||||
previousBodyClass = ajaxify.data.bodyClass;
|
||||
$('#footer, #content').removeClass('hide').addClass('ajaxifying');
|
||||
|
||||
ajaxify.loadData(url, function(err, data) {
|
||||
ajaxify.loadData(url, function (err, data) {
|
||||
|
||||
if (!err || (err && err.data && (parseInt(err.data.status, 10) !== 302 && parseInt(err.data.status, 10) !== 308))) {
|
||||
ajaxify.updateHistory(url, quiet);
|
||||
@@ -88,7 +88,7 @@ $(document).ready(function() {
|
||||
retry = true;
|
||||
app.template = data.template.name;
|
||||
|
||||
require(['translator'], function(translator) {
|
||||
require(['translator'], function (translator) {
|
||||
translator.load(config.defaultLang, data.template.name);
|
||||
renderTemplate(url, data.template.name, data, callback);
|
||||
});
|
||||
@@ -97,7 +97,7 @@ $(document).ready(function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
ajaxify.handleRedirects = function(url) {
|
||||
ajaxify.handleRedirects = function (url) {
|
||||
url = ajaxify.removeRelativePath(url.replace(/\/$/, '')).toLowerCase();
|
||||
var isClientToAdmin = url.startsWith('admin') && window.location.pathname.indexOf(RELATIVE_PATH + '/admin') !== 0;
|
||||
var isAdminToClient = !url.startsWith('admin') && window.location.pathname.indexOf(RELATIVE_PATH + '/admin') === 0;
|
||||
@@ -110,7 +110,7 @@ $(document).ready(function() {
|
||||
};
|
||||
|
||||
|
||||
ajaxify.start = function(url) {
|
||||
ajaxify.start = function (url) {
|
||||
url = ajaxify.removeRelativePath(url.replace(/^\/|\/$/g, ''));
|
||||
|
||||
var payload = {
|
||||
@@ -122,7 +122,7 @@ $(document).ready(function() {
|
||||
return payload.url;
|
||||
};
|
||||
|
||||
ajaxify.updateHistory = function(url, quiet) {
|
||||
ajaxify.updateHistory = function (url, quiet) {
|
||||
ajaxify.currentPage = url.split(/[?#]/)[0];
|
||||
if (window.history && window.history.pushState) {
|
||||
window.history[!quiet ? 'pushState' : 'replaceState']({
|
||||
@@ -171,8 +171,8 @@ $(document).ready(function() {
|
||||
function renderTemplate(url, tpl_url, data, callback) {
|
||||
$(window).trigger('action:ajaxify.loadingTemplates', {});
|
||||
|
||||
templates.parse(tpl_url, data, function(template) {
|
||||
translator.translate(template, function(translatedTemplate) {
|
||||
templates.parse(tpl_url, data, function (template) {
|
||||
translator.translate(template, function (translatedTemplate) {
|
||||
translatedTemplate = translator.unescape(translatedTemplate);
|
||||
$('body').removeClass(previousBodyClass).addClass(data.bodyClass);
|
||||
$('#content').html(translatedTemplate);
|
||||
@@ -190,7 +190,7 @@ $(document).ready(function() {
|
||||
});
|
||||
}
|
||||
|
||||
ajaxify.end = function(url, tpl_url) {
|
||||
ajaxify.end = function (url, tpl_url) {
|
||||
function done() {
|
||||
if (--count === 0) {
|
||||
$(window).trigger('action:ajaxify.end', {url: url, tpl_url: tpl_url, title: ajaxify.data.title});
|
||||
@@ -207,7 +207,7 @@ $(document).ready(function() {
|
||||
app.processPage();
|
||||
};
|
||||
|
||||
ajaxify.parseData = function() {
|
||||
ajaxify.parseData = function () {
|
||||
var dataEl = $('#ajaxify-data');
|
||||
if (dataEl.length) {
|
||||
ajaxify.data = JSON.parse(dataEl.text());
|
||||
@@ -215,18 +215,18 @@ $(document).ready(function() {
|
||||
}
|
||||
};
|
||||
|
||||
ajaxify.removeRelativePath = function(url) {
|
||||
ajaxify.removeRelativePath = function (url) {
|
||||
if (url.startsWith(RELATIVE_PATH.slice(1))) {
|
||||
url = url.slice(RELATIVE_PATH.length);
|
||||
}
|
||||
return url;
|
||||
};
|
||||
|
||||
ajaxify.refresh = function(callback) {
|
||||
ajaxify.refresh = function (callback) {
|
||||
ajaxify.go(ajaxify.currentPage + window.location.search + window.location.hash, callback, true);
|
||||
};
|
||||
|
||||
ajaxify.loadScript = function(tpl_url, callback) {
|
||||
ajaxify.loadScript = function (tpl_url, callback) {
|
||||
var location = !app.inAdmin ? 'forum/' : '';
|
||||
|
||||
if (tpl_url.startsWith('admin')) {
|
||||
@@ -239,7 +239,7 @@ $(document).ready(function() {
|
||||
|
||||
$(window).trigger('action:script.load', data);
|
||||
|
||||
require(data.scripts, function(script) {
|
||||
require(data.scripts, function (script) {
|
||||
if (script && script.init) {
|
||||
script.init();
|
||||
}
|
||||
@@ -250,7 +250,7 @@ $(document).ready(function() {
|
||||
});
|
||||
};
|
||||
|
||||
ajaxify.loadData = function(url, callback) {
|
||||
ajaxify.loadData = function (url, callback) {
|
||||
url = ajaxify.removeRelativePath(url);
|
||||
|
||||
$(window).trigger('action:ajaxify.loadingData', {url: url});
|
||||
@@ -258,7 +258,7 @@ $(document).ready(function() {
|
||||
apiXHR = $.ajax({
|
||||
url: RELATIVE_PATH + '/api/' + url,
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
@@ -270,7 +270,7 @@ $(document).ready(function() {
|
||||
|
||||
callback(null, data);
|
||||
},
|
||||
error: function(data, textStatus) {
|
||||
error: function (data, textStatus) {
|
||||
if (data.status === 0 && textStatus === 'error') {
|
||||
data.status = 500;
|
||||
}
|
||||
@@ -282,17 +282,17 @@ $(document).ready(function() {
|
||||
});
|
||||
};
|
||||
|
||||
ajaxify.loadTemplate = function(template, callback) {
|
||||
ajaxify.loadTemplate = function (template, callback) {
|
||||
if (templates.cache[template]) {
|
||||
callback(templates.cache[template]);
|
||||
} else {
|
||||
$.ajax({
|
||||
url: RELATIVE_PATH + '/templates/' + template + '.tpl' + (config['cache-buster'] ? '?v=' + config['cache-buster'] : ''),
|
||||
type: 'GET',
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
callback(data.toString());
|
||||
},
|
||||
error: function(error) {
|
||||
error: function (error) {
|
||||
throw new Error("Unable to load template: " + template + " (" + error.statusText + ")");
|
||||
}
|
||||
});
|
||||
@@ -309,7 +309,7 @@ $(document).ready(function() {
|
||||
// Enhancing all anchors to ajaxify...
|
||||
$(document.body).on('click', 'a', function (e) {
|
||||
var _self = this;
|
||||
var process = function() {
|
||||
var process = function () {
|
||||
if (!e.ctrlKey && !e.shiftKey && !e.metaKey && e.which === 1) {
|
||||
if (internalLink) {
|
||||
var pathname = this.href.replace(rootUrl + RELATIVE_PATH + '/', '');
|
||||
@@ -358,8 +358,8 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
if (app.flags && app.flags.hasOwnProperty('_unsaved') && app.flags._unsaved === true) {
|
||||
translator.translate('[[global:unsaved-changes]]', function(text) {
|
||||
bootbox.confirm(text, function(navigate) {
|
||||
translator.translate('[[global:unsaved-changes]]', function (text) {
|
||||
bootbox.confirm(text, function (navigate) {
|
||||
if (navigate) {
|
||||
app.flags._unsaved = false;
|
||||
process.call(_self);
|
||||
@@ -382,7 +382,7 @@ $(document).ready(function() {
|
||||
|
||||
app.load();
|
||||
|
||||
$('[type="text/tpl"][data-template]').each(function() {
|
||||
$('[type="text/tpl"][data-template]').each(function () {
|
||||
templates.cache[$(this).attr('data-template')] = $('<div/>').html($(this).html()).text();
|
||||
$(this).parent().remove();
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ app.cacheBuster = null;
|
||||
locale: config.userLang
|
||||
});
|
||||
|
||||
app.load = function() {
|
||||
app.load = function () {
|
||||
app.loadProgressiveStylesheet();
|
||||
|
||||
var url = ajaxify.start(window.location.pathname.slice(1) + window.location.search + window.location.hash);
|
||||
@@ -33,15 +33,15 @@ app.cacheBuster = null;
|
||||
app.handleSearch();
|
||||
}
|
||||
|
||||
$('body').on('click', '#new_topic', function(){
|
||||
$('body').on('click', '#new_topic', function (){
|
||||
app.newTopic();
|
||||
});
|
||||
|
||||
require(['components'], function(components) {
|
||||
require(['components'], function (components) {
|
||||
components.get('user/logout').on('click', app.logout);
|
||||
});
|
||||
|
||||
Visibility.change(function(event, state){
|
||||
Visibility.change(function (event, state){
|
||||
if (state === 'visible') {
|
||||
app.isFocused = true;
|
||||
app.alternatingTitle('');
|
||||
@@ -56,7 +56,7 @@ app.cacheBuster = null;
|
||||
app.showEmailConfirmWarning();
|
||||
|
||||
socket.removeAllListeners('event:nodebb.ready');
|
||||
socket.on('event:nodebb.ready', function(data) {
|
||||
socket.on('event:nodebb.ready', function (data) {
|
||||
if (!app.cacheBuster || app.cacheBuster !== data['cache-buster']) {
|
||||
app.cacheBuster = data['cache-buster'];
|
||||
|
||||
@@ -64,7 +64,7 @@ app.cacheBuster = null;
|
||||
alert_id: 'forum_updated',
|
||||
title: '[[global:updated.title]]',
|
||||
message: '[[global:updated.message]]',
|
||||
clickfn: function() {
|
||||
clickfn: function () {
|
||||
window.location.reload();
|
||||
},
|
||||
type: 'warning'
|
||||
@@ -72,7 +72,7 @@ app.cacheBuster = null;
|
||||
}
|
||||
});
|
||||
|
||||
require(['taskbar', 'helpers', 'forum/pagination'], function(taskbar, helpers, pagination) {
|
||||
require(['taskbar', 'helpers', 'forum/pagination'], function (taskbar, helpers, pagination) {
|
||||
taskbar.init();
|
||||
|
||||
// templates.js helpers
|
||||
@@ -84,14 +84,14 @@ app.cacheBuster = null;
|
||||
});
|
||||
};
|
||||
|
||||
app.logout = function() {
|
||||
app.logout = function () {
|
||||
$(window).trigger('action:app.logout');
|
||||
$.ajax(config.relative_path + '/logout', {
|
||||
type: 'POST',
|
||||
headers: {
|
||||
'x-csrf-token': config.csrf_token
|
||||
},
|
||||
success: function() {
|
||||
success: function () {
|
||||
var payload = {
|
||||
next: config.relative_path + '/'
|
||||
};
|
||||
@@ -103,13 +103,13 @@ app.cacheBuster = null;
|
||||
};
|
||||
|
||||
app.alert = function (params) {
|
||||
require(['alerts'], function(alerts) {
|
||||
require(['alerts'], function (alerts) {
|
||||
alerts.alert(params);
|
||||
});
|
||||
};
|
||||
|
||||
app.removeAlert = function(id) {
|
||||
require(['alerts'], function(alerts) {
|
||||
app.removeAlert = function (id) {
|
||||
require(['alerts'], function (alerts) {
|
||||
alerts.remove(id);
|
||||
});
|
||||
};
|
||||
@@ -136,7 +136,7 @@ app.cacheBuster = null;
|
||||
});
|
||||
};
|
||||
|
||||
app.handleInvalidSession = function() {
|
||||
app.handleInvalidSession = function () {
|
||||
if (app.flags && app.flags._sessionRefresh) {
|
||||
return;
|
||||
}
|
||||
@@ -144,13 +144,13 @@ app.cacheBuster = null;
|
||||
app.flags = app.flags || {};
|
||||
app.flags._sessionRefresh = true;
|
||||
|
||||
require(['translator'], function(translator) {
|
||||
translator.translate('[[error:invalid-session-text]]', function(translated) {
|
||||
require(['translator'], function (translator) {
|
||||
translator.translate('[[error:invalid-session-text]]', function (translated) {
|
||||
bootbox.alert({
|
||||
title: '[[error:invalid-session]]',
|
||||
message: translated,
|
||||
closeButton: false,
|
||||
callback: function() {
|
||||
callback: function () {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
@@ -159,13 +159,13 @@ app.cacheBuster = null;
|
||||
};
|
||||
|
||||
app.enterRoom = function (room, callback) {
|
||||
callback = callback || function() {};
|
||||
callback = callback || function () {};
|
||||
if (socket && app.user.uid && app.currentRoom !== room) {
|
||||
var previousRoom = app.currentRoom;
|
||||
app.currentRoom = room;
|
||||
socket.emit('meta.rooms.enter', {
|
||||
enter: room
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
app.currentRoom = previousRoom;
|
||||
return app.alertError(err.message);
|
||||
@@ -176,11 +176,11 @@ app.cacheBuster = null;
|
||||
}
|
||||
};
|
||||
|
||||
app.leaveCurrentRoom = function() {
|
||||
app.leaveCurrentRoom = function () {
|
||||
if (!socket) {
|
||||
return;
|
||||
}
|
||||
socket.emit('meta.rooms.leaveCurrent', function(err) {
|
||||
socket.emit('meta.rooms.leaveCurrent', function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -196,9 +196,9 @@ app.cacheBuster = null;
|
||||
}
|
||||
}
|
||||
|
||||
app.createUserTooltips = function(els, placement) {
|
||||
app.createUserTooltips = function (els, placement) {
|
||||
els = els || $('body');
|
||||
els.find('.avatar,img[title].teaser-pic,img[title].user-img,div.user-icon,span.user-icon').each(function() {
|
||||
els.find('.avatar,img[title].teaser-pic,img[title].user-img,div.user-icon,span.user-icon').each(function () {
|
||||
if (!utils.isTouchDevice()) {
|
||||
$(this).tooltip({
|
||||
placement: placement || $(this).attr('title-placement') || 'top',
|
||||
@@ -208,7 +208,7 @@ app.cacheBuster = null;
|
||||
});
|
||||
};
|
||||
|
||||
app.createStatusTooltips = function() {
|
||||
app.createStatusTooltips = function () {
|
||||
if (!utils.isTouchDevice()) {
|
||||
$('body').tooltip({
|
||||
selector:'.fa-circle.status',
|
||||
@@ -217,9 +217,9 @@ app.cacheBuster = null;
|
||||
}
|
||||
};
|
||||
|
||||
app.replaceSelfLinks = function(selector) {
|
||||
app.replaceSelfLinks = function (selector) {
|
||||
selector = selector || $('a');
|
||||
selector.each(function() {
|
||||
selector.each(function () {
|
||||
var href = $(this).attr('href');
|
||||
if (href && app.user.userslug && href.indexOf('user/_self_') !== -1) {
|
||||
$(this).attr('href', href.replace(/user\/_self_/g, 'user/' + app.user.userslug));
|
||||
@@ -281,11 +281,11 @@ app.cacheBuster = null;
|
||||
if (chat.modalExists(roomId)) {
|
||||
loadAndCenter(chat.getModal(roomId));
|
||||
} else {
|
||||
socket.emit('modules.chats.loadRoom', {roomId: roomId, uid: uid || app.user.uid}, function(err, roomData) {
|
||||
socket.emit('modules.chats.loadRoom', {roomId: roomId, uid: uid || app.user.uid}, function (err, roomData) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
roomData.users = roomData.users.filter(function(user) {
|
||||
roomData.users = roomData.users.filter(function (user) {
|
||||
return user && parseInt(user.uid, 10) !== parseInt(app.user.uid, 10);
|
||||
});
|
||||
roomData.uid = uid || app.user.uid;
|
||||
@@ -296,12 +296,12 @@ app.cacheBuster = null;
|
||||
};
|
||||
|
||||
app.newChat = function (touid, callback) {
|
||||
callback = callback || function() {};
|
||||
callback = callback || function () {};
|
||||
if (!app.user.uid) {
|
||||
return app.alertError('[[error:not-logged-in]]');
|
||||
}
|
||||
|
||||
socket.emit('modules.chats.newRoom', {touid: touid}, function(err, roomId) {
|
||||
socket.emit('modules.chats.newRoom', {touid: touid}, function (err, roomId) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -332,14 +332,14 @@ app.cacheBuster = null;
|
||||
titleObj.titles[0] = window.document.title;
|
||||
}
|
||||
|
||||
require(['translator'], function(translator) {
|
||||
translator.translate(title, function(translated) {
|
||||
require(['translator'], function (translator) {
|
||||
translator.translate(title, function (translated) {
|
||||
titleObj.titles[1] = translated;
|
||||
if (titleObj.interval) {
|
||||
clearInterval(titleObj.interval);
|
||||
}
|
||||
|
||||
titleObj.interval = setInterval(function() {
|
||||
titleObj.interval = setInterval(function () {
|
||||
var title = titleObj.titles[titleObj.titles.indexOf(window.document.title) ^ 1];
|
||||
if (title) {
|
||||
window.document.title = $('<div/>').html(title).text();
|
||||
@@ -357,23 +357,23 @@ app.cacheBuster = null;
|
||||
}
|
||||
};
|
||||
|
||||
app.refreshTitle = function(title) {
|
||||
app.refreshTitle = function (title) {
|
||||
if (!title) {
|
||||
return;
|
||||
}
|
||||
require(['translator'], function(translator) {
|
||||
require(['translator'], function (translator) {
|
||||
title = config.titleLayout.replace(/{/g, '{').replace(/}/g, '}')
|
||||
.replace('{pageTitle}', function() { return title; })
|
||||
.replace('{browserTitle}', function() { return config.browserTitle; });
|
||||
.replace('{pageTitle}', function () { return title; })
|
||||
.replace('{browserTitle}', function () { return config.browserTitle; });
|
||||
|
||||
translator.translate(title, function(translated) {
|
||||
translator.translate(title, function (translated) {
|
||||
titleObj.titles[0] = translated;
|
||||
app.alternatingTitle('');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
app.toggleNavbar = function(state) {
|
||||
app.toggleNavbar = function (state) {
|
||||
var navbarEl = $('.navbar');
|
||||
if (navbarEl) {
|
||||
navbarEl.toggleClass('hidden', !!!state);
|
||||
@@ -385,7 +385,7 @@ app.cacheBuster = null;
|
||||
if (env === 'xs' || env === 'sm') {
|
||||
return;
|
||||
}
|
||||
$('#header-menu li a[title]').each(function() {
|
||||
$('#header-menu li a[title]').each(function () {
|
||||
if (!utils.isTouchDevice()) {
|
||||
$(this).tooltip({
|
||||
placement: 'bottom',
|
||||
@@ -417,7 +417,7 @@ app.cacheBuster = null;
|
||||
searchFields = $("#search-fields"),
|
||||
searchInput = $('#search-fields input');
|
||||
|
||||
$('#search-form .advanced-search-link').on('mousedown', function() {
|
||||
$('#search-form .advanced-search-link').on('mousedown', function () {
|
||||
ajaxify.go('/search');
|
||||
});
|
||||
|
||||
@@ -429,7 +429,7 @@ app.cacheBuster = null;
|
||||
searchButton.removeClass('hidden');
|
||||
}
|
||||
|
||||
searchButton.on('click', function(e) {
|
||||
searchButton.on('click', function (e) {
|
||||
if (!config.loggedIn && !config.allowGuestSearching) {
|
||||
app.alert({
|
||||
message:'[[error:search-requires-login]]',
|
||||
@@ -446,10 +446,10 @@ app.cacheBuster = null;
|
||||
|
||||
$('#search-form').on('submit', function () {
|
||||
var input = $(this).find('input');
|
||||
require(['search'], function(search) {
|
||||
require(['search'], function (search) {
|
||||
var data = search.getSearchPreferences();
|
||||
data.term = input.val();
|
||||
search.query(data, function() {
|
||||
search.query(data, function () {
|
||||
input.val('');
|
||||
});
|
||||
});
|
||||
@@ -457,16 +457,16 @@ app.cacheBuster = null;
|
||||
});
|
||||
};
|
||||
|
||||
app.prepareSearch = function() {
|
||||
app.prepareSearch = function () {
|
||||
$("#search-fields").removeClass('hidden');
|
||||
$("#search-button").addClass('hidden');
|
||||
$('#search-fields input').focus();
|
||||
};
|
||||
|
||||
function handleStatusChange() {
|
||||
$('[component="header/usercontrol"] [data-status]').off('click').on('click', function(e) {
|
||||
$('[component="header/usercontrol"] [data-status]').off('click').on('click', function (e) {
|
||||
var status = $(this).attr('data-status');
|
||||
socket.emit('user.setStatus', status, function(err) {
|
||||
socket.emit('user.setStatus', status, function (err) {
|
||||
if(err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -480,13 +480,13 @@ app.cacheBuster = null;
|
||||
});
|
||||
}
|
||||
|
||||
app.updateUserStatus = function(el, status) {
|
||||
app.updateUserStatus = function (el, status) {
|
||||
if (!el.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
require(['translator'], function(translator) {
|
||||
translator.translate('[[global:' + status + ']]', function(translated) {
|
||||
require(['translator'], function (translator) {
|
||||
translator.translate('[[global:' + status + ']]', function (translated) {
|
||||
el.removeClass('online offline dnd away')
|
||||
.addClass(status)
|
||||
.attr('title', translated)
|
||||
@@ -502,7 +502,7 @@ app.cacheBuster = null;
|
||||
});
|
||||
};
|
||||
|
||||
app.loadJQueryUI = function(callback) {
|
||||
app.loadJQueryUI = function (callback) {
|
||||
if (typeof $().autocomplete === 'function') {
|
||||
return callback();
|
||||
}
|
||||
@@ -514,7 +514,7 @@ app.cacheBuster = null;
|
||||
document.head.appendChild(scriptEl);
|
||||
};
|
||||
|
||||
app.showEmailConfirmWarning = function(err) {
|
||||
app.showEmailConfirmWarning = function (err) {
|
||||
if (!config.requireEmailConfirmation || !app.user.uid) {
|
||||
return;
|
||||
}
|
||||
@@ -526,16 +526,16 @@ app.cacheBuster = null;
|
||||
|
||||
if (!app.user.email) {
|
||||
msg.message = '[[error:no-email-to-confirm]]';
|
||||
msg.clickfn = function() {
|
||||
msg.clickfn = function () {
|
||||
app.removeAlert('email_confirm');
|
||||
ajaxify.go('user/' + app.user.userslug + '/edit');
|
||||
};
|
||||
app.alert(msg);
|
||||
} else if (!app.user['email:confirmed'] && !app.user.isEmailConfirmSent) {
|
||||
msg.message = err ? err.message : '[[error:email-not-confirmed]]';
|
||||
msg.clickfn = function() {
|
||||
msg.clickfn = function () {
|
||||
app.removeAlert('email_confirm');
|
||||
socket.emit('user.emailConfirm', {}, function(err) {
|
||||
socket.emit('user.emailConfirm', {}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -550,30 +550,30 @@ app.cacheBuster = null;
|
||||
}
|
||||
};
|
||||
|
||||
app.parseAndTranslate = function(template, blockName, data, callback) {
|
||||
require(['translator'], function(translator) {
|
||||
app.parseAndTranslate = function (template, blockName, data, callback) {
|
||||
require(['translator'], function (translator) {
|
||||
function translate(html, callback) {
|
||||
translator.translate(html, function(translatedHTML) {
|
||||
translator.translate(html, function (translatedHTML) {
|
||||
translatedHTML = translator.unescape(translatedHTML);
|
||||
callback($(translatedHTML));
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof blockName === 'string') {
|
||||
templates.parse(template, blockName, data, function(html) {
|
||||
templates.parse(template, blockName, data, function (html) {
|
||||
translate(html, callback);
|
||||
});
|
||||
} else {
|
||||
callback = data;
|
||||
data = blockName;
|
||||
templates.parse(template, data, function(html) {
|
||||
templates.parse(template, data, function (html) {
|
||||
translate(html, callback);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
app.loadProgressiveStylesheet = function() {
|
||||
app.loadProgressiveStylesheet = function () {
|
||||
var linkEl = document.createElement('link');
|
||||
linkEl.rel = 'stylesheet';
|
||||
linkEl.href = config.relative_path + '/js-enabled.css';
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
/* globals define */
|
||||
|
||||
define('forum/account/best', ['forum/account/header', 'forum/account/posts'], function(header, posts) {
|
||||
define('forum/account/best', ['forum/account/header', 'forum/account/posts'], function (header, posts) {
|
||||
var Best = {};
|
||||
|
||||
Best.init = function() {
|
||||
Best.init = function () {
|
||||
header.init();
|
||||
|
||||
$('[component="post/content"] img:not(.not-responsive)').addClass('img-responsive');
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
/* globals define */
|
||||
|
||||
define('forum/account/bookmarks', ['forum/account/header', 'forum/account/posts'], function(header, posts) {
|
||||
define('forum/account/bookmarks', ['forum/account/header', 'forum/account/posts'], function (header, posts) {
|
||||
var Bookmarks = {};
|
||||
|
||||
Bookmarks.init = function() {
|
||||
Bookmarks.init = function () {
|
||||
header.init();
|
||||
|
||||
$('[component="post/content"] img:not(.not-responsive)').addClass('img-responsive');
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
/* globals define */
|
||||
|
||||
define('forum/account/downvoted', ['forum/account/header', 'forum/account/posts'], function(header, posts) {
|
||||
define('forum/account/downvoted', ['forum/account/header', 'forum/account/posts'], function (header, posts) {
|
||||
var Downvoted = {};
|
||||
|
||||
Downvoted.init = function() {
|
||||
Downvoted.init = function () {
|
||||
header.init();
|
||||
|
||||
$('[component="post/content"] img:not(.not-responsive)').addClass('img-responsive');
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
|
||||
/* globals define, ajaxify, socket, app, config, templates, bootbox */
|
||||
|
||||
define('forum/account/edit', ['forum/account/header', 'uploader', 'translator', 'components'], function(header, uploader, translator, components) {
|
||||
define('forum/account/edit', ['forum/account/header', 'uploader', 'translator', 'components'], function (header, uploader, translator, components) {
|
||||
var AccountEdit = {};
|
||||
|
||||
AccountEdit.init = function() {
|
||||
AccountEdit.init = function () {
|
||||
|
||||
header.init();
|
||||
|
||||
$('#submitBtn').on('click', updateProfile);
|
||||
|
||||
app.loadJQueryUI(function() {
|
||||
app.loadJQueryUI(function () {
|
||||
$('#inputBirthday').datepicker({
|
||||
changeMonth: true,
|
||||
changeYear: true,
|
||||
@@ -39,7 +39,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator',
|
||||
aboutme: $('#inputAboutMe').val()
|
||||
};
|
||||
|
||||
socket.emit('user.updateProfile', userData, function(err, data) {
|
||||
socket.emit('user.updateProfile', userData, function (err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -70,14 +70,14 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator',
|
||||
|
||||
function handleImageChange() {
|
||||
|
||||
$('#changePictureBtn').on('click', function() {
|
||||
socket.emit('user.getProfilePictures', {uid: ajaxify.data.uid}, function(err, pictures) {
|
||||
$('#changePictureBtn').on('click', function () {
|
||||
socket.emit('user.getProfilePictures', {uid: ajaxify.data.uid}, function (err, pictures) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
// boolean to signify whether an uploaded picture is present in the pictures list
|
||||
var uploaded = pictures.reduce(function(memo, cur) {
|
||||
var uploaded = pictures.reduce(function (memo, cur) {
|
||||
return memo || cur.type === 'uploaded';
|
||||
}, false);
|
||||
|
||||
@@ -85,8 +85,8 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator',
|
||||
pictures: pictures,
|
||||
uploaded: uploaded,
|
||||
allowProfileImageUploads: ajaxify.data.allowProfileImageUploads
|
||||
}, function(html) {
|
||||
translator.translate(html, function(html) {
|
||||
}, function (html) {
|
||||
translator.translate(html, function (html) {
|
||||
var modal = bootbox.dialog({
|
||||
className: 'picture-switcher',
|
||||
title: '[[user:change_picture]]',
|
||||
@@ -124,7 +124,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator',
|
||||
if (!ajaxify.data.picture) {
|
||||
modal.find('.list-group-item .user-icon').parents('.list-group-item').addClass('active');
|
||||
} else {
|
||||
modal.find('.list-group-item img').each(function() {
|
||||
modal.find('.list-group-item img').each(function () {
|
||||
if (this.getAttribute('src') === ajaxify.data.picture) {
|
||||
$(this).parents('.list-group-item').addClass('active');
|
||||
}
|
||||
@@ -135,7 +135,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator',
|
||||
function saveSelection() {
|
||||
var type = modal.find('.list-group-item.active').attr('data-type');
|
||||
|
||||
changeUserPicture(type, function(err) {
|
||||
changeUserPicture(type, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -157,9 +157,9 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator',
|
||||
}
|
||||
|
||||
function handleAccountDelete() {
|
||||
$('#deleteAccountBtn').on('click', function() {
|
||||
translator.translate('[[user:delete_account_confirm]]', function(translated) {
|
||||
var modal = bootbox.confirm(translated + '<p><input type="text" class="form-control" id="confirm-username" /></p>', function(confirm) {
|
||||
$('#deleteAccountBtn').on('click', function () {
|
||||
translator.translate('[[user:delete_account_confirm]]', function (translated) {
|
||||
var modal = bootbox.confirm(translated + '<p><input type="text" class="form-control" id="confirm-username" /></p>', function (confirm) {
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
@@ -168,7 +168,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator',
|
||||
app.alertError('[[error:invalid-username]]');
|
||||
return false;
|
||||
} else {
|
||||
socket.emit('user.deleteAccount', {}, function(err) {
|
||||
socket.emit('user.deleteAccount', {}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -178,7 +178,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator',
|
||||
}
|
||||
});
|
||||
|
||||
modal.on('shown.bs.modal', function() {
|
||||
modal.on('shown.bs.modal', function () {
|
||||
modal.find('input').focus();
|
||||
});
|
||||
});
|
||||
@@ -196,7 +196,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator',
|
||||
$('#user-current-picture, img.avatar').attr('src', urlOnServer);
|
||||
ajaxify.data.uploadedpicture = urlOnServer;
|
||||
} else {
|
||||
ajaxify.refresh(function() {
|
||||
ajaxify.refresh(function () {
|
||||
$('#user-current-picture, img.avatar').attr('src', urlOnServer);
|
||||
});
|
||||
}
|
||||
@@ -209,7 +209,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator',
|
||||
}
|
||||
}
|
||||
|
||||
modal.find('[data-action="upload"]').on('click', function() {
|
||||
modal.find('[data-action="upload"]').on('click', function () {
|
||||
modal.modal('hide');
|
||||
|
||||
uploader.show({
|
||||
@@ -219,26 +219,26 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator',
|
||||
title: '[[user:upload_picture]]',
|
||||
description: '[[user:upload_a_picture]]',
|
||||
accept: '.png,.jpg,.bmp'
|
||||
}, function(imageUrlOnServer) {
|
||||
}, function (imageUrlOnServer) {
|
||||
onUploadComplete(imageUrlOnServer);
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
modal.find('[data-action="upload-url"]').on('click', function() {
|
||||
modal.find('[data-action="upload-url"]').on('click', function () {
|
||||
modal.modal('hide');
|
||||
templates.parse('partials/modals/upload_picture_from_url_modal', {}, function(html) {
|
||||
translator.translate(html, function(html) {
|
||||
templates.parse('partials/modals/upload_picture_from_url_modal', {}, function (html) {
|
||||
translator.translate(html, function (html) {
|
||||
var uploadModal = $(html);
|
||||
uploadModal.modal('show');
|
||||
|
||||
uploadModal.find('.upload-btn').on('click', function() {
|
||||
uploadModal.find('.upload-btn').on('click', function () {
|
||||
var url = uploadModal.find('#uploadFromUrl').val();
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
socket.emit('user.uploadProfileImageFromUrl', {url: url, uid: ajaxify.data.theirid}, function(err, imageUrlOnServer) {
|
||||
socket.emit('user.uploadProfileImageFromUrl', {url: url, uid: ajaxify.data.theirid}, function (err, imageUrlOnServer) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -255,8 +255,8 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator',
|
||||
return false;
|
||||
});
|
||||
|
||||
modal.find('[data-action="remove-uploaded"]').on('click', function() {
|
||||
socket.emit('user.removeUploadedPicture', {uid: ajaxify.data.theirid}, function(err) {
|
||||
modal.find('[data-action="remove-uploaded"]').on('click', function () {
|
||||
socket.emit('user.removeUploadedPicture', {uid: ajaxify.data.theirid}, function (err) {
|
||||
modal.modal('hide');
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
@@ -267,9 +267,9 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator',
|
||||
}
|
||||
|
||||
function handleEmailConfirm() {
|
||||
$('#confirm-email').on('click', function() {
|
||||
$('#confirm-email').on('click', function () {
|
||||
var btn = $(this).attr('disabled', true);
|
||||
socket.emit('user.emailConfirm', {}, function(err) {
|
||||
socket.emit('user.emailConfirm', {}, function (err) {
|
||||
btn.removeAttr('disabled');
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
@@ -294,7 +294,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator',
|
||||
var el = $('#inputSignature');
|
||||
$('#signatureCharCountLeft').html(getCharsLeft(el, ajaxify.data.maximumSignatureLength));
|
||||
|
||||
el.on('keyup change', function() {
|
||||
el.on('keyup change', function () {
|
||||
$('#signatureCharCountLeft').html(getCharsLeft(el, ajaxify.data.maximumSignatureLength));
|
||||
});
|
||||
}
|
||||
@@ -303,7 +303,7 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator',
|
||||
var el = $('#inputAboutMe');
|
||||
$('#aboutMeCharCountLeft').html(getCharsLeft(el, ajaxify.data.maximumAboutMeLength));
|
||||
|
||||
el.on('keyup change', function() {
|
||||
el.on('keyup change', function () {
|
||||
$('#aboutMeCharCountLeft').html(getCharsLeft(el, ajaxify.data.maximumAboutMeLength));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
/* globals define, ajaxify, socket, app */
|
||||
|
||||
define('forum/account/edit/email', ['forum/account/header'], function(header) {
|
||||
define('forum/account/edit/email', ['forum/account/header'], function (header) {
|
||||
var AccountEditEmail = {};
|
||||
|
||||
AccountEditEmail.init = function() {
|
||||
AccountEditEmail.init = function () {
|
||||
header.init();
|
||||
|
||||
$('#submitBtn').on('click', function () {
|
||||
@@ -26,7 +26,7 @@ define('forum/account/edit/email', ['forum/account/header'], function(header) {
|
||||
var btn = $(this);
|
||||
btn.addClass('disabled').find('i').removeClass('hide');
|
||||
|
||||
socket.emit('user.changeUsernameEmail', userData, function(err) {
|
||||
socket.emit('user.changeUsernameEmail', userData, function (err) {
|
||||
btn.removeClass('disabled').find('i').addClass('hide');
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
/* globals define, ajaxify, socket, app, utils */
|
||||
|
||||
define('forum/account/edit/password', ['forum/account/header', 'translator'], function(header, translator) {
|
||||
define('forum/account/edit/password', ['forum/account/header', 'translator'], function (header, translator) {
|
||||
var AccountEditPassword = {};
|
||||
|
||||
AccountEditPassword.init = function() {
|
||||
AccountEditPassword.init = function () {
|
||||
header.init();
|
||||
|
||||
handlePasswordChange();
|
||||
@@ -56,7 +56,7 @@ define('forum/account/edit/password', ['forum/account/header', 'translator'], fu
|
||||
password.on('blur', onPasswordChanged);
|
||||
password_confirm.on('blur', onPasswordConfirmChanged);
|
||||
|
||||
$('#changePasswordBtn').on('click', function() {
|
||||
$('#changePasswordBtn').on('click', function () {
|
||||
onPasswordChanged();
|
||||
onPasswordConfirmChanged();
|
||||
|
||||
@@ -67,7 +67,7 @@ define('forum/account/edit/password', ['forum/account/header', 'translator'], fu
|
||||
'currentPassword': currentPassword.val(),
|
||||
'newPassword': password.val(),
|
||||
'uid': ajaxify.data.theirid
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
btn.removeClass('disabled').find('i').addClass('hide');
|
||||
currentPassword.val('');
|
||||
password.val('');
|
||||
@@ -97,7 +97,7 @@ define('forum/account/edit/password', ['forum/account/header', 'translator'], fu
|
||||
}
|
||||
|
||||
function showError(element, msg) {
|
||||
translator.translate(msg, function(msg) {
|
||||
translator.translate(msg, function (msg) {
|
||||
element.html(msg);
|
||||
|
||||
element.parent()
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
/* globals define, ajaxify, socket, app, utils, config */
|
||||
|
||||
define('forum/account/edit/username', ['forum/account/header'], function(header) {
|
||||
define('forum/account/edit/username', ['forum/account/header'], function (header) {
|
||||
var AccountEditUsername = {};
|
||||
|
||||
AccountEditUsername.init = function() {
|
||||
AccountEditUsername.init = function () {
|
||||
header.init();
|
||||
|
||||
$('#submitBtn').on('click', function updateUsername() {
|
||||
@@ -25,7 +25,7 @@ define('forum/account/edit/username', ['forum/account/header'], function(header)
|
||||
|
||||
var btn = $(this);
|
||||
btn.addClass('disabled').find('i').removeClass('hide');
|
||||
socket.emit('user.changeUsernameEmail', userData, function(err, data) {
|
||||
socket.emit('user.changeUsernameEmail', userData, function (err, data) {
|
||||
btn.removeClass('disabled').find('i').addClass('hide');
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
/* globals define */
|
||||
|
||||
define('forum/account/followers', ['forum/account/header'], function(header) {
|
||||
define('forum/account/followers', ['forum/account/header'], function (header) {
|
||||
var Followers = {};
|
||||
|
||||
Followers.init = function() {
|
||||
Followers.init = function () {
|
||||
header.init();
|
||||
};
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
/* globals define */
|
||||
|
||||
define('forum/account/following', ['forum/account/header'], function(header) {
|
||||
define('forum/account/following', ['forum/account/header'], function (header) {
|
||||
var Following = {};
|
||||
|
||||
Following.init = function() {
|
||||
Following.init = function () {
|
||||
header.init();
|
||||
};
|
||||
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
/* globals ajaxify, define, app, socket, utils */
|
||||
|
||||
define('forum/account/groups', ['forum/account/header'], function(header) {
|
||||
define('forum/account/groups', ['forum/account/header'], function (header) {
|
||||
var AccountTopics = {};
|
||||
|
||||
AccountTopics.init = function() {
|
||||
AccountTopics.init = function () {
|
||||
header.init();
|
||||
|
||||
var groupsEl = $('#groups-list');
|
||||
|
||||
groupsEl.on('click', '.list-cover', function() {
|
||||
groupsEl.on('click', '.list-cover', function () {
|
||||
var groupSlug = $(this).parents('[data-slug]').attr('data-slug');
|
||||
|
||||
ajaxify.go('groups/' + groupSlug);
|
||||
|
||||
@@ -6,11 +6,11 @@ define('forum/account/header', [
|
||||
'uploader',
|
||||
'components',
|
||||
'translator'
|
||||
], function(coverPhoto, uploader, components, translator) {
|
||||
], function (coverPhoto, uploader, components, translator) {
|
||||
var AccountHeader = {};
|
||||
var isAdminOrSelfOrGlobalMod;
|
||||
|
||||
AccountHeader.init = function() {
|
||||
AccountHeader.init = function () {
|
||||
isAdminOrSelfOrGlobalMod = ajaxify.data.isAdmin || ajaxify.data.isSelf || ajaxify.data.isGlobalModerator;
|
||||
|
||||
hidePrivateLinks();
|
||||
@@ -20,16 +20,16 @@ define('forum/account/header', [
|
||||
setupCoverPhoto();
|
||||
}
|
||||
|
||||
components.get('account/follow').on('click', function() {
|
||||
components.get('account/follow').on('click', function () {
|
||||
toggleFollow('follow');
|
||||
});
|
||||
|
||||
components.get('account/unfollow').on('click', function() {
|
||||
components.get('account/unfollow').on('click', function () {
|
||||
toggleFollow('unfollow');
|
||||
});
|
||||
|
||||
components.get('account/chat').on('click', function() {
|
||||
socket.emit('modules.chats.hasPrivateChat', ajaxify.data.uid, function(err, roomId) {
|
||||
components.get('account/chat').on('click', function () {
|
||||
socket.emit('modules.chats.hasPrivateChat', ajaxify.data.uid, function (err, roomId) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ define('forum/account/header', [
|
||||
}
|
||||
|
||||
function selectActivePill() {
|
||||
$('.account-sub-links li').removeClass('active').each(function() {
|
||||
$('.account-sub-links li').removeClass('active').each(function () {
|
||||
var href = $(this).find('a').attr('href');
|
||||
|
||||
if (decodeURIComponent(href) === decodeURIComponent(window.location.pathname)) {
|
||||
@@ -65,20 +65,20 @@ define('forum/account/header', [
|
||||
|
||||
function setupCoverPhoto() {
|
||||
coverPhoto.init(components.get('account/cover'),
|
||||
function(imageData, position, callback) {
|
||||
function (imageData, position, callback) {
|
||||
socket.emit('user.updateCover', {
|
||||
uid: ajaxify.data.uid,
|
||||
imageData: imageData,
|
||||
position: position
|
||||
}, callback);
|
||||
},
|
||||
function() {
|
||||
function () {
|
||||
uploader.show({
|
||||
title: '[[user:upload_cover_picture]]',
|
||||
route: config.relative_path + '/api/user/' + ajaxify.data.userslug + '/uploadcover',
|
||||
params: {uid: ajaxify.data.uid },
|
||||
accept: '.png,.jpg,.bmp'
|
||||
}, function(imageUrlOnServer) {
|
||||
}, function (imageUrlOnServer) {
|
||||
components.get('account/cover').css('background-image', 'url(' + imageUrlOnServer + '?v=' + Date.now() + ')');
|
||||
});
|
||||
},
|
||||
@@ -89,7 +89,7 @@ define('forum/account/header', [
|
||||
function toggleFollow(type) {
|
||||
socket.emit('user.' + type, {
|
||||
uid: ajaxify.data.uid
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -102,7 +102,7 @@ define('forum/account/header', [
|
||||
}
|
||||
|
||||
function banAccount() {
|
||||
templates.parse('admin/partials/temporary-ban', {}, function(html) {
|
||||
templates.parse('admin/partials/temporary-ban', {}, function (html) {
|
||||
bootbox.dialog({
|
||||
className: 'ban-modal',
|
||||
title: '[[user:ban_account]]',
|
||||
@@ -115,14 +115,14 @@ define('forum/account/header', [
|
||||
},
|
||||
submit: {
|
||||
label: '[[user:ban_account]]',
|
||||
callback: function() {
|
||||
var formData = $('.ban-modal form').serializeArray().reduce(function(data, cur) {
|
||||
callback: function () {
|
||||
var formData = $('.ban-modal form').serializeArray().reduce(function (data, cur) {
|
||||
data[cur.name] = cur.value;
|
||||
return data;
|
||||
}, {});
|
||||
var until = formData.length ? (Date.now() + formData.length * 1000*60*60 * (parseInt(formData.unit, 10) ? 24 : 1)) : 0;
|
||||
var until = formData.length ? (Date.now() + formData.length * 1000 * 60 * 60 * (parseInt(formData.unit, 10) ? 24 : 1)) : 0;
|
||||
|
||||
socket.emit('user.banUsers', { uids: [ajaxify.data.theirid], until: until, reason: formData.reason || '' }, function(err) {
|
||||
socket.emit('user.banUsers', { uids: [ajaxify.data.theirid], until: until, reason: formData.reason || '' }, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -136,7 +136,7 @@ define('forum/account/header', [
|
||||
}
|
||||
|
||||
function unbanAccount() {
|
||||
socket.emit('user.unbanUsers', [ajaxify.data.theirid], function(err) {
|
||||
socket.emit('user.unbanUsers', [ajaxify.data.theirid], function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -145,13 +145,13 @@ define('forum/account/header', [
|
||||
}
|
||||
|
||||
function deleteAccount() {
|
||||
translator.translate('[[user:delete_this_account_confirm]]', function(translated) {
|
||||
bootbox.confirm(translated, function(confirm) {
|
||||
translator.translate('[[user:delete_this_account_confirm]]', function (translated) {
|
||||
bootbox.confirm(translated, function (confirm) {
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
|
||||
socket.emit('admin.user.deleteUsersAndContent', [ajaxify.data.theirid], function(err) {
|
||||
socket.emit('admin.user.deleteUsersAndContent', [ajaxify.data.theirid], function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -165,7 +165,7 @@ define('forum/account/header', [
|
||||
function removeCover() {
|
||||
socket.emit('user.removeCover', {
|
||||
uid: ajaxify.data.uid
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (!err) {
|
||||
ajaxify.refresh();
|
||||
} else {
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
|
||||
/* globals define, socket, ajaxify, app */
|
||||
|
||||
define('forum/account/info', ['forum/account/header'], function(header) {
|
||||
define('forum/account/info', ['forum/account/header'], function (header) {
|
||||
var Info = {};
|
||||
|
||||
Info.init = function() {
|
||||
Info.init = function () {
|
||||
header.init();
|
||||
handleModerationNote();
|
||||
};
|
||||
|
||||
function handleModerationNote() {
|
||||
$('[component="account/save-moderation-note"]').on('click', function() {
|
||||
$('[component="account/save-moderation-note"]').on('click', function () {
|
||||
var note = $('[component="account/moderation-note"]').val();
|
||||
socket.emit('user.setModerationNote', {uid: ajaxify.data.uid, note: note}, function(err) {
|
||||
socket.emit('user.setModerationNote', {uid: ajaxify.data.uid, note: note}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
/* globals define, app, socket, utils, config, ajaxify */
|
||||
|
||||
define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll'], function(header, infinitescroll) {
|
||||
define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll'], function (header, infinitescroll) {
|
||||
var AccountPosts = {};
|
||||
var method, template;
|
||||
|
||||
AccountPosts.init = function() {
|
||||
AccountPosts.init = function () {
|
||||
header.init();
|
||||
|
||||
$('[component="post/content"] img:not(.not-responsive)').addClass('img-responsive');
|
||||
@@ -14,7 +14,7 @@ define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll'],
|
||||
AccountPosts.handleInfiniteScroll('posts.loadMoreUserPosts', 'account/posts');
|
||||
};
|
||||
|
||||
AccountPosts.handleInfiniteScroll = function(_method, _template) {
|
||||
AccountPosts.handleInfiniteScroll = function (_method, _template) {
|
||||
method = _method;
|
||||
template = _template;
|
||||
if (!config.usePagination) {
|
||||
@@ -30,7 +30,7 @@ define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll'],
|
||||
infinitescroll.loadMore(method, {
|
||||
uid: ajaxify.data.theirid,
|
||||
after: $('[component="posts"]').attr('data-nextstart')
|
||||
}, function(data, done) {
|
||||
}, function (data, done) {
|
||||
if (data.posts && data.posts.length) {
|
||||
onPostsLoaded(data.posts, done);
|
||||
} else {
|
||||
@@ -41,7 +41,7 @@ define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll'],
|
||||
}
|
||||
|
||||
function onPostsLoaded(posts, callback) {
|
||||
app.parseAndTranslate(template, 'posts', {posts: posts}, function(html) {
|
||||
app.parseAndTranslate(template, 'posts', {posts: posts}, function (html) {
|
||||
$('[component="posts"]').append(html);
|
||||
html.find('img:not(.not-responsive)').addClass('img-responsive');
|
||||
html.find('.timeago').timeago();
|
||||
|
||||
@@ -7,11 +7,11 @@ define('forum/account/profile', [
|
||||
'forum/infinitescroll',
|
||||
'translator',
|
||||
'components'
|
||||
], function(header, infinitescroll, translator) {
|
||||
], function (header, infinitescroll, translator) {
|
||||
var Account = {},
|
||||
theirid;
|
||||
|
||||
Account.init = function() {
|
||||
Account.init = function () {
|
||||
header.init();
|
||||
|
||||
theirid = ajaxify.data.theirid;
|
||||
@@ -48,7 +48,7 @@ define('forum/account/profile', [
|
||||
infinitescroll.loadMore('posts.loadMoreUserPosts', {
|
||||
after: $('[component="posts"]').attr('data-nextstart'),
|
||||
uid: theirid
|
||||
}, function(data, done) {
|
||||
}, function (data, done) {
|
||||
if (data.posts && data.posts.length) {
|
||||
onPostsLoaded(data.posts, done);
|
||||
} else {
|
||||
@@ -60,7 +60,7 @@ define('forum/account/profile', [
|
||||
}
|
||||
|
||||
function onPostsLoaded(posts, callback) {
|
||||
posts = posts.filter(function(post) {
|
||||
posts = posts.filter(function (post) {
|
||||
return !$('[component="posts"] [data-pid=' + post.pid + ']').length;
|
||||
});
|
||||
|
||||
@@ -68,7 +68,7 @@ define('forum/account/profile', [
|
||||
return callback();
|
||||
}
|
||||
|
||||
app.parseAndTranslate('account/profile', 'posts', {posts: posts}, function(html) {
|
||||
app.parseAndTranslate('account/profile', 'posts', {posts: posts}, function (html) {
|
||||
|
||||
$('[component="posts"]').append(html);
|
||||
html.find('.timeago').timeago();
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
/*global define, socket, app, ajaxify, config*/
|
||||
|
||||
define('forum/account/settings', ['forum/account/header', 'components', 'sounds'], function(header, components, sounds) {
|
||||
define('forum/account/settings', ['forum/account/header', 'components', 'sounds'], function (header, components, sounds) {
|
||||
var AccountSettings = {};
|
||||
|
||||
AccountSettings.init = function() {
|
||||
AccountSettings.init = function () {
|
||||
header.init();
|
||||
|
||||
$('#submitBtn').on('click', function() {
|
||||
$('#submitBtn').on('click', function () {
|
||||
var settings = loadSettings();
|
||||
|
||||
if (settings.homePageRoute === 'custom' && settings.homePageCustom) {
|
||||
$.get(config.relative_path + '/' + settings.homePageCustom, function() {
|
||||
$.get(config.relative_path + '/' + settings.homePageCustom, function () {
|
||||
saveSettings(settings);
|
||||
}).fail(function() {
|
||||
}).fail(function () {
|
||||
app.alertError('[[error:invalid-home-page-route]]');
|
||||
});
|
||||
} else {
|
||||
@@ -24,7 +24,7 @@ define('forum/account/settings', ['forum/account/header', 'components', 'sounds'
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#bootswatchSkin').on('change', function() {
|
||||
$('#bootswatchSkin').on('change', function () {
|
||||
var css = $('#bootswatchCSS');
|
||||
var val = $(this).val() === 'default' ? config['theme:src'] : '//maxcdn.bootstrapcdn.com/bootswatch/latest/' + $(this).val() + '/bootstrap.min.css';
|
||||
|
||||
@@ -33,7 +33,7 @@ define('forum/account/settings', ['forum/account/header', 'components', 'sounds'
|
||||
|
||||
$('[data-property="homePageRoute"]').on('change', toggleCustomRoute);
|
||||
|
||||
$('.account').find('button[data-action="play"]').on('click', function(e) {
|
||||
$('.account').find('button[data-action="play"]').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var fileName = $(this).parent().parent().find('select').val();
|
||||
@@ -49,7 +49,7 @@ define('forum/account/settings', ['forum/account/header', 'components', 'sounds'
|
||||
function loadSettings() {
|
||||
var settings = {};
|
||||
|
||||
$('.account').find('input, textarea, select').each(function(id, input) {
|
||||
$('.account').find('input, textarea, select').each(function (id, input) {
|
||||
input = $(input);
|
||||
var setting = input.attr('data-property');
|
||||
if (input.is('select')) {
|
||||
@@ -72,7 +72,7 @@ define('forum/account/settings', ['forum/account/header', 'components', 'sounds'
|
||||
}
|
||||
|
||||
function saveSettings(settings) {
|
||||
socket.emit('user.saveSettings', {uid: ajaxify.data.theirid, settings: settings}, function(err, newSettings) {
|
||||
socket.emit('user.saveSettings', {uid: ajaxify.data.theirid, settings: settings}, function (err, newSettings) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ define('forum/account/settings', ['forum/account/header', 'components', 'sounds'
|
||||
message: '[[user:settings-require-reload]]',
|
||||
type: 'warning',
|
||||
timeout: 5000,
|
||||
clickfn: function() {
|
||||
clickfn: function () {
|
||||
ajaxify.refresh();
|
||||
}
|
||||
});
|
||||
@@ -116,7 +116,7 @@ define('forum/account/settings', ['forum/account/header', 'components', 'sounds'
|
||||
}
|
||||
|
||||
function prepareSessionRevoking() {
|
||||
components.get('user/sessions').on('click', '[data-action]', function() {
|
||||
components.get('user/sessions').on('click', '[data-action]', function () {
|
||||
var parentEl = $(this).parents('[data-uuid]');
|
||||
var uuid = parentEl.attr('data-uuid');
|
||||
|
||||
@@ -129,9 +129,9 @@ define('forum/account/settings', ['forum/account/header', 'components', 'sounds'
|
||||
headers: {
|
||||
'x-csrf-token': config.csrf_token
|
||||
}
|
||||
}).done(function() {
|
||||
}).done(function () {
|
||||
parentEl.remove();
|
||||
}).fail(function(err) {
|
||||
}).fail(function (err) {
|
||||
try {
|
||||
var errorObj = JSON.parse(err.responseText);
|
||||
if (errorObj.loggedIn === false) {
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
/* globals define, app, socket, utils, config, ajaxify */
|
||||
|
||||
define('forum/account/topics', ['forum/account/header', 'forum/infinitescroll'], function(header, infinitescroll) {
|
||||
define('forum/account/topics', ['forum/account/header', 'forum/infinitescroll'], function (header, infinitescroll) {
|
||||
var AccountTopics = {};
|
||||
var template, set;
|
||||
|
||||
AccountTopics.init = function() {
|
||||
AccountTopics.init = function () {
|
||||
header.init();
|
||||
|
||||
AccountTopics.handleInfiniteScroll('account/topics', 'uid:' + ajaxify.data.theirid + ':topics');
|
||||
};
|
||||
|
||||
AccountTopics.handleInfiniteScroll = function(_template, _set) {
|
||||
AccountTopics.handleInfiniteScroll = function (_template, _set) {
|
||||
template = _template;
|
||||
set = _set;
|
||||
|
||||
@@ -29,7 +29,7 @@ define('forum/account/topics', ['forum/account/header', 'forum/infinitescroll'],
|
||||
infinitescroll.loadMore('topics.loadMoreFromSet', {
|
||||
set: set,
|
||||
after: $('[component="category"]').attr('data-nextstart')
|
||||
}, function(data, done) {
|
||||
}, function (data, done) {
|
||||
if (data.topics && data.topics.length) {
|
||||
onTopicsLoaded(data.topics, done);
|
||||
} else {
|
||||
@@ -41,7 +41,7 @@ define('forum/account/topics', ['forum/account/header', 'forum/infinitescroll'],
|
||||
}
|
||||
|
||||
function onTopicsLoaded(topics, callback) {
|
||||
app.parseAndTranslate('account/topics', 'topics', {topics: topics}, function(html) {
|
||||
app.parseAndTranslate('account/topics', 'topics', {topics: topics}, function (html) {
|
||||
$('[component="category"]').append(html);
|
||||
html.find('.timeago').timeago();
|
||||
app.createUserTooltips();
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
/* globals define */
|
||||
|
||||
define('forum/account/upvoted', ['forum/account/header', 'forum/account/posts'], function(header, posts) {
|
||||
define('forum/account/upvoted', ['forum/account/header', 'forum/account/posts'], function (header, posts) {
|
||||
var Upvoted = {};
|
||||
|
||||
Upvoted.init = function() {
|
||||
Upvoted.init = function () {
|
||||
header.init();
|
||||
|
||||
$('[component="post/content"] img:not(.not-responsive)').addClass('img-responsive');
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
/* globals define, app, socket, utils */
|
||||
define('forum/account/watched', ['forum/account/header', 'forum/account/topics'], function(header, topics) {
|
||||
define('forum/account/watched', ['forum/account/header', 'forum/account/topics'], function (header, topics) {
|
||||
var AccountWatched = {};
|
||||
|
||||
AccountWatched.init = function() {
|
||||
AccountWatched.init = function () {
|
||||
header.init();
|
||||
|
||||
topics.handleInfiniteScroll('account/watched', 'uid:' + ajaxify.data.theirid + ':followed_tids');
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
|
||||
/* globals define, socket, app, templates, ajaxify*/
|
||||
|
||||
define('forum/categories', ['components', 'translator'], function(components, translator) {
|
||||
define('forum/categories', ['components', 'translator'], function (components, translator) {
|
||||
var categories = {};
|
||||
|
||||
$(window).on('action:ajaxify.start', function(ev, data) {
|
||||
$(window).on('action:ajaxify.start', function (ev, data) {
|
||||
if (ajaxify.currentPage !== data.url) {
|
||||
socket.removeListener('event:new_post', categories.onNewPost);
|
||||
}
|
||||
});
|
||||
|
||||
categories.init = function() {
|
||||
categories.init = function () {
|
||||
app.enterRoom('categories');
|
||||
|
||||
socket.removeListener('event:new_post', categories.onNewPost);
|
||||
@@ -22,7 +22,7 @@ define('forum/categories', ['components', 'translator'], function(components, tr
|
||||
});
|
||||
};
|
||||
|
||||
categories.onNewPost = function(data) {
|
||||
categories.onNewPost = function (data) {
|
||||
if (data && data.posts && data.posts.length && data.posts[0].topic) {
|
||||
renderNewPost(data.posts[0].topic.cid, data.posts[0]);
|
||||
}
|
||||
@@ -38,7 +38,7 @@ define('forum/categories', ['components', 'translator'], function(components, tr
|
||||
var recentPosts = category.find('[component="category/posts"]');
|
||||
var insertBefore = recentPosts.first();
|
||||
|
||||
parseAndTranslate([post], function(html) {
|
||||
parseAndTranslate([post], function (html) {
|
||||
html.hide();
|
||||
if(recentPosts.length === 0) {
|
||||
html.appendTo(category);
|
||||
@@ -60,8 +60,8 @@ define('forum/categories', ['components', 'translator'], function(components, tr
|
||||
}
|
||||
|
||||
function parseAndTranslate(posts, callback) {
|
||||
templates.parse('categories', '(categories.)?posts', {categories: {posts: posts}}, function(html) {
|
||||
translator.translate(html, function(translatedHTML) {
|
||||
templates.parse('categories', '(categories.)?posts', {categories: {posts: posts}}, function (html) {
|
||||
translator.translate(html, function (translatedHTML) {
|
||||
translatedHTML = $(translatedHTML);
|
||||
translatedHTML.find('img:not(.not-responsive)').addClass('img-responsive');
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ define('forum/category', [
|
||||
'translator',
|
||||
'topicSelect',
|
||||
'forum/pagination'
|
||||
], function(infinitescroll, share, navigator, categoryTools, sort, components, translator, topicSelect, pagination) {
|
||||
], function (infinitescroll, share, navigator, categoryTools, sort, components, translator, topicSelect, pagination) {
|
||||
var Category = {};
|
||||
|
||||
$(window).on('action:ajaxify.start', function(ev, data) {
|
||||
$(window).on('action:ajaxify.start', function (ev, data) {
|
||||
if (ajaxify.currentPage !== data.url) {
|
||||
navigator.disable();
|
||||
|
||||
@@ -27,7 +27,7 @@ define('forum/category', [
|
||||
categoryTools.removeListeners();
|
||||
}
|
||||
|
||||
Category.init = function() {
|
||||
Category.init = function () {
|
||||
var cid = ajaxify.data.cid;
|
||||
|
||||
app.enterRoom('category_' + cid);
|
||||
@@ -47,9 +47,9 @@ define('forum/category', [
|
||||
|
||||
enableInfiniteLoadingOrPagination();
|
||||
|
||||
$('[component="category"]').on('click', '[component="topic/header"]', function() {
|
||||
$('[component="category"]').on('click', '[component="topic/header"]', function () {
|
||||
var clickedIndex = $(this).parents('[data-index]').attr('data-index');
|
||||
$('[component="category/topic"]').each(function(index, el) {
|
||||
$('[component="category/topic"]').each(function (index, el) {
|
||||
if ($(el).offset().top - $(window).scrollTop() > 0) {
|
||||
localStorage.setItem('category:' + cid + ':bookmark', $(el).attr('data-index'));
|
||||
localStorage.setItem('category:' + cid + ':bookmark:clicked', clickedIndex);
|
||||
@@ -65,11 +65,11 @@ define('forum/category', [
|
||||
};
|
||||
|
||||
function handleIgnoreWatch(cid) {
|
||||
$('[component="category/watching"], [component="category/ignoring"]').on('click', function() {
|
||||
$('[component="category/watching"], [component="category/ignoring"]').on('click', function () {
|
||||
var $this = $(this);
|
||||
var command = $this.attr('component') === 'category/watching' ? 'watch' : 'ignore';
|
||||
|
||||
socket.emit('categories.' + command, cid, function(err) {
|
||||
socket.emit('categories.' + command, cid, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -85,12 +85,12 @@ define('forum/category', [
|
||||
});
|
||||
}
|
||||
|
||||
Category.toTop = function() {
|
||||
Category.toTop = function () {
|
||||
navigator.scrollTop(0);
|
||||
};
|
||||
|
||||
Category.toBottom = function() {
|
||||
socket.emit('categories.getTopicCount', ajaxify.data.cid, function(err, count) {
|
||||
Category.toBottom = function () {
|
||||
socket.emit('categories.getTopicCount', ajaxify.data.cid, function (err, count) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -99,11 +99,11 @@ define('forum/category', [
|
||||
});
|
||||
};
|
||||
|
||||
Category.navigatorCallback = function(topIndex, bottomIndex, elementCount) {
|
||||
Category.navigatorCallback = function (topIndex, bottomIndex, elementCount) {
|
||||
return bottomIndex;
|
||||
};
|
||||
|
||||
$(window).on('action:popstate', function(ev, data) {
|
||||
$(window).on('action:popstate', function (ev, data) {
|
||||
if (data.url.startsWith('category/')) {
|
||||
var cid = data.url.match(/^category\/(\d+)/);
|
||||
if (cid && cid[1]) {
|
||||
@@ -125,7 +125,7 @@ define('forum/category', [
|
||||
if (config.usePagination) {
|
||||
var page = Math.ceil((parseInt(bookmarkIndex, 10) + 1) / config.topicsPerPage);
|
||||
if (parseInt(page, 10) !== ajaxify.data.pagination.currentPage) {
|
||||
pagination.loadPage(page, function() {
|
||||
pagination.loadPage(page, function () {
|
||||
Category.scrollToTopic(bookmarkIndex, clickedIndex, 400);
|
||||
});
|
||||
} else {
|
||||
@@ -139,25 +139,25 @@ define('forum/category', [
|
||||
|
||||
$('[component="category"]').empty();
|
||||
|
||||
loadTopicsAfter(Math.max(0, bookmarkIndex - 1), 1, function() {
|
||||
loadTopicsAfter(Math.max(0, bookmarkIndex - 1), 1, function () {
|
||||
Category.scrollToTopic(bookmarkIndex, clickedIndex, 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Category.highlightTopic = function(topicIndex) {
|
||||
Category.highlightTopic = function (topicIndex) {
|
||||
var highlight = components.get('category/topic', 'index', topicIndex);
|
||||
|
||||
if (highlight.length && !highlight.hasClass('highlight')) {
|
||||
highlight.addClass('highlight');
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
highlight.removeClass('highlight');
|
||||
}, 5000);
|
||||
}
|
||||
};
|
||||
|
||||
Category.scrollToTopic = function(bookmarkIndex, clickedIndex, duration, offset) {
|
||||
Category.scrollToTopic = function (bookmarkIndex, clickedIndex, duration, offset) {
|
||||
if (!bookmarkIndex) {
|
||||
return;
|
||||
}
|
||||
@@ -172,7 +172,7 @@ define('forum/category', [
|
||||
if (scrollTo.length && cid) {
|
||||
$('html, body').animate({
|
||||
scrollTop: (scrollTo.offset().top - offset) + 'px'
|
||||
}, duration !== undefined ? duration : 400, function() {
|
||||
}, duration !== undefined ? duration : 400, function () {
|
||||
Category.highlightTopic(clickedIndex);
|
||||
navigator.update();
|
||||
});
|
||||
@@ -187,7 +187,7 @@ define('forum/category', [
|
||||
}
|
||||
}
|
||||
|
||||
Category.onNewTopic = function(topic) {
|
||||
Category.onNewTopic = function (topic) {
|
||||
var cid = ajaxify.data.cid;
|
||||
if (!topic || parseInt(topic.cid, 10) !== parseInt(cid, 10)) {
|
||||
return;
|
||||
@@ -202,8 +202,8 @@ define('forum/category', [
|
||||
showSelect: editable,
|
||||
topics: [topic],
|
||||
template: {category: true}
|
||||
}, function(html) {
|
||||
translator.translate(html, function(translatedHTML) {
|
||||
}, function (html) {
|
||||
translator.translate(html, function (translatedHTML) {
|
||||
var topic = $(translatedHTML),
|
||||
container = $('[component="category"]'),
|
||||
topics = $('[component="category/topic"]'),
|
||||
@@ -246,7 +246,7 @@ define('forum/category', [
|
||||
};
|
||||
|
||||
function updateTopicCount() {
|
||||
socket.emit('categories.getTopicCount', ajaxify.data.cid, function(err, topicCount) {
|
||||
socket.emit('categories.getTopicCount', ajaxify.data.cid, function (err, topicCount) {
|
||||
if(err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -254,7 +254,7 @@ define('forum/category', [
|
||||
});
|
||||
}
|
||||
|
||||
Category.loadMoreTopics = function(direction) {
|
||||
Category.loadMoreTopics = function (direction) {
|
||||
if (!$('[component="category"]').length || !$('[component="category"]').children().length) {
|
||||
return;
|
||||
}
|
||||
@@ -267,7 +267,7 @@ define('forum/category', [
|
||||
};
|
||||
|
||||
function loadTopicsAfter(after, direction, callback) {
|
||||
callback = callback || function() {};
|
||||
callback = callback || function () {};
|
||||
if (!utils.isNumber(after) || (after === 0 && components.get('category/topic', 'index', 0).length)) {
|
||||
return callback();
|
||||
}
|
||||
@@ -294,13 +294,13 @@ define('forum/category', [
|
||||
}
|
||||
|
||||
|
||||
Category.onTopicsLoaded = function(data, direction, callback) {
|
||||
Category.onTopicsLoaded = function (data, direction, callback) {
|
||||
if (!data || !data.topics.length) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
function removeAlreadyAddedTopics(topics) {
|
||||
return topics.filter(function(topic) {
|
||||
return topics.filter(function (topic) {
|
||||
return components.get('category/topic', 'tid', topic.tid).length === 0;
|
||||
});
|
||||
}
|
||||
@@ -321,7 +321,7 @@ define('forum/category', [
|
||||
before = topics.first();
|
||||
}
|
||||
|
||||
app.parseAndTranslate('category', 'topics', data, function(html) {
|
||||
app.parseAndTranslate('category', 'topics', data, function (html) {
|
||||
$('[component="category"]').removeClass('hidden');
|
||||
$('.category-sidebar').removeClass('hidden');
|
||||
|
||||
|
||||
@@ -4,31 +4,31 @@
|
||||
/* globals define, app, socket, bootbox, ajaxify */
|
||||
|
||||
|
||||
define('forum/categoryTools', ['forum/topic/move', 'topicSelect', 'components', 'translator'], function(move, topicSelect, components, translator) {
|
||||
define('forum/categoryTools', ['forum/topic/move', 'topicSelect', 'components', 'translator'], function (move, topicSelect, components, translator) {
|
||||
|
||||
var CategoryTools = {};
|
||||
|
||||
CategoryTools.init = function(cid) {
|
||||
CategoryTools.init = function (cid) {
|
||||
CategoryTools.cid = cid;
|
||||
|
||||
topicSelect.init(updateDropdownOptions);
|
||||
|
||||
components.get('topic/delete').on('click', function() {
|
||||
components.get('topic/delete').on('click', function () {
|
||||
categoryCommand('delete', topicSelect.getSelectedTids());
|
||||
return false;
|
||||
});
|
||||
|
||||
components.get('topic/restore').on('click', function() {
|
||||
components.get('topic/restore').on('click', function () {
|
||||
categoryCommand('restore', topicSelect.getSelectedTids());
|
||||
return false;
|
||||
});
|
||||
|
||||
components.get('topic/purge').on('click', function() {
|
||||
components.get('topic/purge').on('click', function () {
|
||||
categoryCommand('purge', topicSelect.getSelectedTids());
|
||||
return false;
|
||||
});
|
||||
|
||||
components.get('topic/lock').on('click', function() {
|
||||
components.get('topic/lock').on('click', function () {
|
||||
var tids = topicSelect.getSelectedTids();
|
||||
if (tids.length) {
|
||||
socket.emit('topics.lock', {tids: tids, cid: CategoryTools.cid}, onCommandComplete);
|
||||
@@ -36,7 +36,7 @@ define('forum/categoryTools', ['forum/topic/move', 'topicSelect', 'components',
|
||||
return false;
|
||||
});
|
||||
|
||||
components.get('topic/unlock').on('click', function() {
|
||||
components.get('topic/unlock').on('click', function () {
|
||||
var tids = topicSelect.getSelectedTids();
|
||||
if (tids.length) {
|
||||
socket.emit('topics.unlock', {tids: tids, cid: CategoryTools.cid}, onCommandComplete);
|
||||
@@ -44,7 +44,7 @@ define('forum/categoryTools', ['forum/topic/move', 'topicSelect', 'components',
|
||||
return false;
|
||||
});
|
||||
|
||||
components.get('topic/pin').on('click', function() {
|
||||
components.get('topic/pin').on('click', function () {
|
||||
var tids = topicSelect.getSelectedTids();
|
||||
if (tids.length) {
|
||||
socket.emit('topics.pin', {tids: tids, cid: CategoryTools.cid}, onCommandComplete);
|
||||
@@ -52,7 +52,7 @@ define('forum/categoryTools', ['forum/topic/move', 'topicSelect', 'components',
|
||||
return false;
|
||||
});
|
||||
|
||||
components.get('topic/unpin').on('click', function() {
|
||||
components.get('topic/unpin').on('click', function () {
|
||||
var tids = topicSelect.getSelectedTids();
|
||||
if (tids.length) {
|
||||
socket.emit('topics.unpin', {tids: tids, cid: CategoryTools.cid}, onCommandComplete);
|
||||
@@ -60,15 +60,15 @@ define('forum/categoryTools', ['forum/topic/move', 'topicSelect', 'components',
|
||||
return false;
|
||||
});
|
||||
|
||||
components.get('topic/mark-unread-for-all').on('click', function() {
|
||||
components.get('topic/mark-unread-for-all').on('click', function () {
|
||||
var tids = topicSelect.getSelectedTids();
|
||||
if (tids.length) {
|
||||
socket.emit('topics.markAsUnreadForAll', tids, function(err) {
|
||||
socket.emit('topics.markAsUnreadForAll', tids, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
app.alertSuccess('[[topic:markAsUnreadForAll.success]]');
|
||||
tids.forEach(function(tid) {
|
||||
tids.forEach(function (tid) {
|
||||
$('[component="category/topic"][data-tid="' + tid + '"]').addClass('unread');
|
||||
});
|
||||
onCommandComplete();
|
||||
@@ -78,7 +78,7 @@ define('forum/categoryTools', ['forum/topic/move', 'topicSelect', 'components',
|
||||
return false;
|
||||
});
|
||||
|
||||
components.get('topic/move').on('click', function() {
|
||||
components.get('topic/move').on('click', function () {
|
||||
var tids = topicSelect.getSelectedTids();
|
||||
|
||||
if (tids.length) {
|
||||
@@ -87,8 +87,8 @@ define('forum/categoryTools', ['forum/topic/move', 'topicSelect', 'components',
|
||||
return false;
|
||||
});
|
||||
|
||||
components.get('topic/move-all').on('click', function() {
|
||||
move.init(null, cid, function(err) {
|
||||
components.get('topic/move-all').on('click', function () {
|
||||
move.init(null, cid, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -113,8 +113,8 @@ define('forum/categoryTools', ['forum/topic/move', 'topicSelect', 'components',
|
||||
return;
|
||||
}
|
||||
|
||||
translator.translate('[[topic:thread_tools.' + command + '_confirm]]', function(msg) {
|
||||
bootbox.confirm(msg, function(confirm) {
|
||||
translator.translate('[[topic:thread_tools.' + command + '_confirm]]', function (msg) {
|
||||
bootbox.confirm(msg, function (confirm) {
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ define('forum/categoryTools', ['forum/topic/move', 'topicSelect', 'components',
|
||||
});
|
||||
}
|
||||
|
||||
CategoryTools.removeListeners = function() {
|
||||
CategoryTools.removeListeners = function () {
|
||||
socket.removeListener('event:topic_deleted', setDeleteState);
|
||||
socket.removeListener('event:topic_restored', setDeleteState);
|
||||
socket.removeListener('event:topic_purged', onTopicPurged);
|
||||
@@ -175,7 +175,7 @@ define('forum/categoryTools', ['forum/topic/move', 'topicSelect', 'components',
|
||||
}
|
||||
|
||||
function isAny(method, tids) {
|
||||
for(var i=0; i<tids.length; ++i) {
|
||||
for(var i = 0; i < tids.length; ++i) {
|
||||
if(method(tids[i])) {
|
||||
return true;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ define('forum/categoryTools', ['forum/topic/move', 'topicSelect', 'components',
|
||||
}
|
||||
|
||||
function areAll(method, tids) {
|
||||
for(var i=0; i<tids.length; ++i) {
|
||||
for(var i = 0; i < tids.length; ++i) {
|
||||
if(!method(tids[i])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ define('forum/chats', [
|
||||
'forum/chats/recent',
|
||||
'forum/chats/search',
|
||||
'forum/chats/messages'
|
||||
], function(components, translator, mousetrap, recentChats, search, messages) {
|
||||
], function (components, translator, mousetrap, recentChats, search, messages) {
|
||||
var Chats = {
|
||||
initialised: false
|
||||
};
|
||||
|
||||
var newMessage = false;
|
||||
|
||||
Chats.init = function() {
|
||||
Chats.init = function () {
|
||||
var env = utils.findBootstrapEnvironment();
|
||||
|
||||
if (!Chats.initialised) {
|
||||
@@ -44,25 +44,25 @@ define('forum/chats', [
|
||||
}
|
||||
};
|
||||
|
||||
Chats.addEventListeners = function() {
|
||||
$('[component="chat/recent"]').on('click', '[component="chat/leave"]', function() {
|
||||
Chats.addEventListeners = function () {
|
||||
$('[component="chat/recent"]').on('click', '[component="chat/leave"]', function () {
|
||||
Chats.leave($(this).parents('[data-roomid]'));
|
||||
return false;
|
||||
});
|
||||
|
||||
$('[component="chat/recent"]').on('click', '[component="chat/recent/room"]', function() {
|
||||
$('[component="chat/recent"]').on('click', '[component="chat/recent/room"]', function () {
|
||||
Chats.switchChat($(this).attr('data-roomid'));
|
||||
});
|
||||
|
||||
Chats.addSendHandlers(ajaxify.data.roomId, $('.chat-input'), $('.expanded-chat button[data-action="send"]'));
|
||||
|
||||
$('[data-action="pop-out"]').on('click', function() {
|
||||
$('[data-action="pop-out"]').on('click', function () {
|
||||
|
||||
var text = components.get('chat/input').val();
|
||||
var roomId = ajaxify.data.roomId;
|
||||
|
||||
if (app.previousUrl && app.previousUrl.match(/chats/)) {
|
||||
ajaxify.go('user/' + ajaxify.data.userslug + '/chats', function() {
|
||||
ajaxify.go('user/' + ajaxify.data.userslug + '/chats', function () {
|
||||
app.openChat(roomId, ajaxify.data.uid);
|
||||
}, true);
|
||||
} else {
|
||||
@@ -70,7 +70,7 @@ define('forum/chats', [
|
||||
app.openChat(roomId, ajaxify.data.uid);
|
||||
}
|
||||
|
||||
$(window).one('action:chat.loaded', function() {
|
||||
$(window).one('action:chat.loaded', function () {
|
||||
components.get('chat/input').val(text);
|
||||
});
|
||||
});
|
||||
@@ -83,9 +83,9 @@ define('forum/chats', [
|
||||
Chats.addScrollHandler(ajaxify.data.roomId, ajaxify.data.uid, $('.chat-content'));
|
||||
};
|
||||
|
||||
Chats.addScrollHandler = function(roomId, uid, el) {
|
||||
Chats.addScrollHandler = function (roomId, uid, el) {
|
||||
var loading = false;
|
||||
el.off('scroll').on('scroll', function() {
|
||||
el.off('scroll').on('scroll', function () {
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
@@ -96,14 +96,14 @@ define('forum/chats', [
|
||||
}
|
||||
loading = true;
|
||||
var start = parseInt($('.chat-content').children('[data-index]').first().attr('data-index'), 10) + 1;
|
||||
socket.emit('modules.chats.getMessages', {roomId: roomId, uid: uid, start: start}, function(err, data) {
|
||||
socket.emit('modules.chats.getMessages', {roomId: roomId, uid: uid, start: start}, function (err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
messages.parseMessage(data, function(html) {
|
||||
messages.parseMessage(data, function (html) {
|
||||
var currentScrollTop = el.scrollTop();
|
||||
var previousHeight = el[0].scrollHeight;
|
||||
html = $(html);
|
||||
@@ -117,19 +117,19 @@ define('forum/chats', [
|
||||
});
|
||||
};
|
||||
|
||||
Chats.addEditDeleteHandler = function(element, roomId) {
|
||||
element.on('click', '[data-action="edit"]', function() {
|
||||
Chats.addEditDeleteHandler = function (element, roomId) {
|
||||
element.on('click', '[data-action="edit"]', function () {
|
||||
var messageId = $(this).parents('[data-mid]').attr('data-mid');
|
||||
var inputEl = components.get('chat/input');
|
||||
messages.prepEdit(inputEl, messageId, roomId);
|
||||
}).on('click', '[data-action="delete"]', function() {
|
||||
}).on('click', '[data-action="delete"]', function () {
|
||||
var messageId = $(this).parents('[data-mid]').attr('data-mid');
|
||||
messages.delete(messageId, roomId);
|
||||
});
|
||||
};
|
||||
|
||||
Chats.addHotkeys = function() {
|
||||
mousetrap.bind('ctrl+up', function() {
|
||||
Chats.addHotkeys = function () {
|
||||
mousetrap.bind('ctrl+up', function () {
|
||||
var activeContact = $('.chats-list .bg-primary'),
|
||||
prev = activeContact.prev();
|
||||
|
||||
@@ -137,7 +137,7 @@ define('forum/chats', [
|
||||
Chats.switchChat(prev.attr('data-roomid'));
|
||||
}
|
||||
});
|
||||
mousetrap.bind('ctrl+down', function() {
|
||||
mousetrap.bind('ctrl+down', function () {
|
||||
var activeContact = $('.chats-list .bg-primary'),
|
||||
next = activeContact.next();
|
||||
|
||||
@@ -145,7 +145,7 @@ define('forum/chats', [
|
||||
Chats.switchChat(next.attr('data-roomid'));
|
||||
}
|
||||
});
|
||||
mousetrap.bind('up', function(e) {
|
||||
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();
|
||||
@@ -157,9 +157,9 @@ define('forum/chats', [
|
||||
});
|
||||
};
|
||||
|
||||
Chats.addRenameHandler = function(roomId, inputEl) {
|
||||
Chats.addRenameHandler = function (roomId, inputEl) {
|
||||
var oldName = inputEl.val();
|
||||
inputEl.on('blur keypress', function(ev) {
|
||||
inputEl.on('blur keypress', function (ev) {
|
||||
if (ev.type === 'keypress' && ev.keyCode !== 13) {
|
||||
return;
|
||||
}
|
||||
@@ -168,7 +168,7 @@ define('forum/chats', [
|
||||
if (oldName === newName) {
|
||||
return;
|
||||
}
|
||||
socket.emit('modules.chats.renameRoom', {roomId: roomId, newName: newName}, function(err) {
|
||||
socket.emit('modules.chats.renameRoom', {roomId: roomId, newName: newName}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -178,28 +178,28 @@ define('forum/chats', [
|
||||
});
|
||||
};
|
||||
|
||||
Chats.addSendHandlers = function(roomId, inputEl, sendEl) {
|
||||
inputEl.off('keypress').on('keypress', function(e) {
|
||||
Chats.addSendHandlers = function (roomId, inputEl, sendEl) {
|
||||
inputEl.off('keypress').on('keypress', function (e) {
|
||||
if (e.which === 13 && !e.shiftKey) {
|
||||
messages.sendMessage(roomId, inputEl);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
sendEl.off('click').on('click', function() {
|
||||
sendEl.off('click').on('click', function () {
|
||||
messages.sendMessage(roomId, inputEl);
|
||||
inputEl.focus();
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
Chats.createAutoComplete = function(element) {
|
||||
Chats.createAutoComplete = function (element) {
|
||||
var data = {
|
||||
element: element,
|
||||
strategies: [],
|
||||
options: {
|
||||
zIndex: 20000,
|
||||
listPosition: function(position) {
|
||||
listPosition: function (position) {
|
||||
this.$el.css(this._applyPlacement(position));
|
||||
this.$el.css('position', 'absolute');
|
||||
return this;
|
||||
@@ -213,27 +213,27 @@ define('forum/chats', [
|
||||
}
|
||||
};
|
||||
|
||||
Chats.createTagsInput = function(tagEl, data) {
|
||||
Chats.createTagsInput = function (tagEl, data) {
|
||||
tagEl.tagsinput({
|
||||
confirmKeys: [13, 44],
|
||||
trimValue: true
|
||||
});
|
||||
|
||||
if (data.users && data.users.length) {
|
||||
data.users.forEach(function(user) {
|
||||
data.users.forEach(function (user) {
|
||||
tagEl.tagsinput('add', $('<div/>').html(user.username).text());
|
||||
});
|
||||
}
|
||||
|
||||
tagEl.on('beforeItemAdd', function(event) {
|
||||
tagEl.on('beforeItemAdd', function (event) {
|
||||
event.cancel = event.item === app.user.username;
|
||||
});
|
||||
|
||||
tagEl.on('itemAdded', function(event) {
|
||||
tagEl.on('itemAdded', function (event) {
|
||||
if (event.item === app.user.username) {
|
||||
return;
|
||||
}
|
||||
socket.emit('modules.chats.addUserToRoom', {roomId: data.roomId, username: event.item}, function(err) {
|
||||
socket.emit('modules.chats.addUserToRoom', {roomId: data.roomId, username: event.item}, function (err) {
|
||||
if (err) {
|
||||
app.alertError(err.message);
|
||||
tagEl.tagsinput('remove', event.item, {nouser: true});
|
||||
@@ -241,7 +241,7 @@ define('forum/chats', [
|
||||
});
|
||||
});
|
||||
|
||||
tagEl.on('beforeItemRemove', function(event) {
|
||||
tagEl.on('beforeItemRemove', function (event) {
|
||||
if (event.options && event.options.nouser) {
|
||||
return;
|
||||
}
|
||||
@@ -256,11 +256,11 @@ define('forum/chats', [
|
||||
}
|
||||
});
|
||||
|
||||
tagEl.on('itemRemoved', function(event) {
|
||||
tagEl.on('itemRemoved', function (event) {
|
||||
if (event.options && event.options.nouser) {
|
||||
return;
|
||||
}
|
||||
socket.emit('modules.chats.removeUserFromRoom', {roomId: data.roomId, username: event.item}, function(err) {
|
||||
socket.emit('modules.chats.removeUserFromRoom', {roomId: data.roomId, username: event.item}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -269,14 +269,14 @@ define('forum/chats', [
|
||||
|
||||
var input = $('.users-tag-container').find('.bootstrap-tagsinput input');
|
||||
|
||||
require(['autocomplete'], function(autocomplete) {
|
||||
require(['autocomplete'], function (autocomplete) {
|
||||
autocomplete.user(input);
|
||||
});
|
||||
};
|
||||
|
||||
Chats.leave = function(el) {
|
||||
Chats.leave = function (el) {
|
||||
var roomId = el.attr('data-roomid');
|
||||
socket.emit('modules.chats.leave', roomId, function(err) {
|
||||
socket.emit('modules.chats.leave', roomId, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -288,13 +288,13 @@ define('forum/chats', [
|
||||
});
|
||||
};
|
||||
|
||||
Chats.switchChat = function(roomid) {
|
||||
Chats.switchChat = function (roomid) {
|
||||
ajaxify.go('user/' + ajaxify.data.userslug + '/chats/' + roomid);
|
||||
};
|
||||
|
||||
Chats.addGlobalEventListeners = function() {
|
||||
Chats.addGlobalEventListeners = function () {
|
||||
$(window).on('resize', Chats.resizeMainWindow);
|
||||
$(window).on('mousemove keypress click', function() {
|
||||
$(window).on('mousemove keypress click', function () {
|
||||
if (newMessage && ajaxify.data.roomId) {
|
||||
socket.emit('modules.chats.markRead', ajaxify.data.roomId);
|
||||
newMessage = false;
|
||||
@@ -302,8 +302,8 @@ define('forum/chats', [
|
||||
});
|
||||
};
|
||||
|
||||
Chats.addSocketListeners = function() {
|
||||
socket.on('event:chats.receive', function(data) {
|
||||
Chats.addSocketListeners = function () {
|
||||
socket.on('event:chats.receive', function (data) {
|
||||
if (parseInt(data.roomId, 10) === parseInt(ajaxify.data.roomId, 10)) {
|
||||
newMessage = data.self === 0;
|
||||
data.message.self = data.self;
|
||||
@@ -319,8 +319,8 @@ define('forum/chats', [
|
||||
var recentEl = components.get('chat/recent');
|
||||
templates.parse('partials/chat_recent_room', {
|
||||
rooms: { "roomId": data.roomId, "lastUser": data.message.fromUser, "usernames": data.message.fromUser.username, "unread": true }
|
||||
}, function(html) {
|
||||
translator.translate(html, function(translated) {
|
||||
}, function (html) {
|
||||
translator.translate(html, function (translated) {
|
||||
recentEl.prepend(translated);
|
||||
});
|
||||
});
|
||||
@@ -329,18 +329,18 @@ define('forum/chats', [
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('event:user_status_change', function(data) {
|
||||
socket.on('event:user_status_change', function (data) {
|
||||
app.updateUserStatus($('.chats-list [data-uid="' + data.uid + '"] [component="user/status"]'), data.status);
|
||||
});
|
||||
|
||||
messages.onChatMessageEdit();
|
||||
|
||||
socket.on('event:chats.roomRename', function(data) {
|
||||
socket.on('event:chats.roomRename', function (data) {
|
||||
$('[component="chat/room/name"]').val($('<div/>').html(data.newName).text());
|
||||
});
|
||||
};
|
||||
|
||||
Chats.resizeMainWindow = function() {
|
||||
Chats.resizeMainWindow = function () {
|
||||
var messagesList = $('.expanded-chat .chat-content');
|
||||
|
||||
if (messagesList.length) {
|
||||
@@ -352,13 +352,13 @@ define('forum/chats', [
|
||||
|
||||
messagesList.height($(window).height() - (fromTop + inputHeight + (margin * 4)));
|
||||
components.get('chat/recent').height($('.expanded-chat').height() - (searchHeight + searchListHeight));
|
||||
$('[component="chat/search/list"]').css('max-height', components.get('chat/recent').height()/2 + 'px');
|
||||
$('[component="chat/search/list"]').css('max-height', components.get('chat/recent').height() / 2 + 'px');
|
||||
}
|
||||
|
||||
Chats.setActive();
|
||||
};
|
||||
|
||||
Chats.setActive = function() {
|
||||
Chats.setActive = function () {
|
||||
if (ajaxify.data.roomId) {
|
||||
socket.emit('modules.chats.markRead', ajaxify.data.roomId);
|
||||
$('.expanded-chat input').focus();
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
/* globals define, socket, app, ajaxify, templates, bootbox */
|
||||
|
||||
define('forum/chats/messages', ['components', 'sounds', 'translator'], function(components, sounds, translator) {
|
||||
define('forum/chats/messages', ['components', 'sounds', 'translator'], function (components, sounds, translator) {
|
||||
|
||||
var messages = {};
|
||||
|
||||
messages.sendMessage = function(roomId, inputEl) {
|
||||
messages.sendMessage = function (roomId, inputEl) {
|
||||
var msg = inputEl.val();
|
||||
var mid = inputEl.attr('data-mid');
|
||||
|
||||
@@ -25,7 +25,7 @@ define('forum/chats/messages', ['components', 'sounds', 'translator'], function(
|
||||
socket.emit('modules.chats.send', {
|
||||
roomId: roomId,
|
||||
message: msg
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
if (err.message === '[[error:email-not-confirmed-chat]]') {
|
||||
return app.showEmailConfirmWarning(err);
|
||||
@@ -40,7 +40,7 @@ define('forum/chats/messages', ['components', 'sounds', 'translator'], function(
|
||||
roomId: roomId,
|
||||
mid: mid,
|
||||
message: msg
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -48,14 +48,14 @@ define('forum/chats/messages', ['components', 'sounds', 'translator'], function(
|
||||
}
|
||||
};
|
||||
|
||||
messages.appendChatMessage = function(chatContentEl, data) {
|
||||
messages.appendChatMessage = function (chatContentEl, data) {
|
||||
|
||||
var lastSpeaker = parseInt(chatContentEl.find('.chat-message').last().attr('data-uid'), 10);
|
||||
if (!Array.isArray(data)) {
|
||||
data.newSet = lastSpeaker !== data.fromuid;
|
||||
}
|
||||
|
||||
messages.parseMessage(data, function(html) {
|
||||
messages.parseMessage(data, function (html) {
|
||||
onMessagesParsed(chatContentEl, html);
|
||||
});
|
||||
};
|
||||
@@ -70,16 +70,16 @@ define('forum/chats/messages', ['components', 'sounds', 'translator'], function(
|
||||
}
|
||||
|
||||
|
||||
messages.parseMessage = function(data, callback) {
|
||||
messages.parseMessage = function (data, callback) {
|
||||
templates.parse('partials/chat_message' + (Array.isArray(data) ? 's' : ''), {
|
||||
messages: data
|
||||
}, function(html) {
|
||||
}, function (html) {
|
||||
translator.translate(html, callback);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
messages.scrollToBottom = function(containerEl) {
|
||||
messages.scrollToBottom = function (containerEl) {
|
||||
if (containerEl.length) {
|
||||
containerEl.scrollTop(
|
||||
containerEl[0].scrollHeight - containerEl.height()
|
||||
@@ -87,8 +87,8 @@ define('forum/chats/messages', ['components', 'sounds', 'translator'], function(
|
||||
}
|
||||
};
|
||||
|
||||
messages.prepEdit = function(inputEl, messageId, roomId) {
|
||||
socket.emit('modules.chats.getRaw', { mid: messageId, roomId: roomId }, function(err, raw) {
|
||||
messages.prepEdit = function (inputEl, messageId, roomId) {
|
||||
socket.emit('modules.chats.getRaw', { mid: messageId, roomId: roomId }, function (err, raw) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -102,12 +102,12 @@ define('forum/chats/messages', ['components', 'sounds', 'translator'], function(
|
||||
});
|
||||
};
|
||||
|
||||
messages.onChatMessageEdit = function() {
|
||||
socket.on('event:chats.edit', function(data) {
|
||||
data.messages.forEach(function(message) {
|
||||
messages.onChatMessageEdit = function () {
|
||||
socket.on('event:chats.edit', function (data) {
|
||||
data.messages.forEach(function (message) {
|
||||
var self = parseInt(message.fromuid, 10) === parseInt(app.user.uid);
|
||||
message.self = self ? 1 : 0;
|
||||
messages.parseMessage(message, function(html) {
|
||||
messages.parseMessage(message, function (html) {
|
||||
var body = components.get('chat/message', message.messageId);
|
||||
if (body.length) {
|
||||
body.replaceWith(html);
|
||||
@@ -118,9 +118,9 @@ define('forum/chats/messages', ['components', 'sounds', 'translator'], function(
|
||||
});
|
||||
};
|
||||
|
||||
messages.delete = function(messageId, roomId) {
|
||||
translator.translate('[[modules:chat.delete_message_confirm]]', function(translated) {
|
||||
bootbox.confirm(translated, function(ok) {
|
||||
messages.delete = function (messageId, roomId) {
|
||||
translator.translate('[[modules:chat.delete_message_confirm]]', function (translated) {
|
||||
bootbox.confirm(translated, function (ok) {
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
@@ -128,12 +128,12 @@ define('forum/chats/messages', ['components', 'sounds', 'translator'], function(
|
||||
socket.emit('modules.chats.delete', {
|
||||
messageId: messageId,
|
||||
roomId: roomId
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
components.get('chat/message', messageId).slideUp('slow', function() {
|
||||
components.get('chat/message', messageId).slideUp('slow', function () {
|
||||
$(this).remove();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
/* globals define, socket, app */
|
||||
|
||||
define('forum/chats/recent', function() {
|
||||
define('forum/chats/recent', function () {
|
||||
|
||||
var recent = {};
|
||||
|
||||
recent.init = function() {
|
||||
$('[component="chat/recent"]').on('scroll', function() {
|
||||
recent.init = function () {
|
||||
$('[component="chat/recent"]').on('scroll', function () {
|
||||
var $this = $(this);
|
||||
var bottom = ($this[0].scrollHeight - $this.height()) * 0.9;
|
||||
if ($this.scrollTop() > bottom) {
|
||||
@@ -25,13 +25,13 @@ define('forum/chats/recent', function() {
|
||||
socket.emit('modules.chats.getRecentChats', {
|
||||
uid: ajaxify.data.uid,
|
||||
after: recentChats.attr('data-nextstart')
|
||||
}, function(err, data) {
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
if (data && data.rooms.length) {
|
||||
onRecentChatsLoaded(data, function() {
|
||||
onRecentChatsLoaded(data, function () {
|
||||
recentChats.removeAttr('loading');
|
||||
recentChats.attr('data-nextstart', data.nextStart);
|
||||
});
|
||||
@@ -46,7 +46,7 @@ define('forum/chats/recent', function() {
|
||||
return callback();
|
||||
}
|
||||
|
||||
app.parseAndTranslate('chats', 'rooms', data, function(html) {
|
||||
app.parseAndTranslate('chats', 'rooms', data, function (html) {
|
||||
$('[component="chat/recent"]').append(html);
|
||||
html.find('.timeago').timeago();
|
||||
callback();
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
/* globals define, socket, app */
|
||||
|
||||
define('forum/chats/search', ['components'], function(components) {
|
||||
define('forum/chats/search', ['components'], function (components) {
|
||||
|
||||
var search = {};
|
||||
|
||||
search.init = function() {
|
||||
search.init = function () {
|
||||
var timeoutId = 0;
|
||||
|
||||
components.get('chat/search').on('keyup', function() {
|
||||
components.get('chat/search').on('keyup', function () {
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = 0;
|
||||
@@ -30,7 +30,7 @@ define('forum/chats/search', ['components'], function(components) {
|
||||
socket.emit('user.search', {
|
||||
query: username,
|
||||
searchBy: 'username'
|
||||
}, function(err, data) {
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -46,7 +46,7 @@ define('forum/chats/search', ['components'], function(components) {
|
||||
return chatsListEl.translateHtml('<li><div><span>[[users:no-users-found]]</span></div></li>');
|
||||
}
|
||||
|
||||
data.users.forEach(function(userObj) {
|
||||
data.users.forEach(function (userObj) {
|
||||
var chatEl = displayUser(chatsListEl, userObj);
|
||||
onUserClick(chatEl, userObj);
|
||||
});
|
||||
@@ -55,7 +55,7 @@ define('forum/chats/search', ['components'], function(components) {
|
||||
function displayUser(chatsListEl, userObj) {
|
||||
function createUserImage() {
|
||||
return (userObj.picture ?
|
||||
'<img src="' + userObj.picture + '" title="' + userObj.username +'" />' :
|
||||
'<img src="' + userObj.picture + '" title="' + userObj.username + '" />' :
|
||||
'<div class="user-icon" style="background-color: ' + userObj['icon:bgColor'] + '">' + userObj['icon:text'] + '</div>') +
|
||||
'<i class="fa fa-circle status ' + userObj.status + '"></i> ' + userObj.username;
|
||||
}
|
||||
@@ -69,13 +69,13 @@ define('forum/chats/search', ['components'], function(components) {
|
||||
}
|
||||
|
||||
function onUserClick(chatEl, userObj) {
|
||||
chatEl.on('click', function() {
|
||||
socket.emit('modules.chats.hasPrivateChat', userObj.uid, function(err, roomId) {
|
||||
chatEl.on('click', function () {
|
||||
socket.emit('modules.chats.hasPrivateChat', userObj.uid, function (err, roomId) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
if (roomId) {
|
||||
require(['forum/chats'], function(chats) {
|
||||
require(['forum/chats'], function (chats) {
|
||||
chats.switchChat(roomId);
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
/* globals define */
|
||||
|
||||
define('forum/compose', [], function() {
|
||||
define('forum/compose', [], function () {
|
||||
var Compose = {};
|
||||
|
||||
Compose.init = function() {
|
||||
Compose.init = function () {
|
||||
var container = $('.composer');
|
||||
|
||||
if (container.length) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
/*globals define, app, socket*/
|
||||
|
||||
define('forum/footer', ['notifications', 'chat', 'components', 'translator'], function(Notifications, Chat, components, translator) {
|
||||
define('forum/footer', ['notifications', 'chat', 'components', 'translator'], function (Notifications, Chat, components, translator) {
|
||||
|
||||
Notifications.prepareDOM();
|
||||
Chat.prepareDOM();
|
||||
@@ -49,7 +49,7 @@ define('forum/footer', ['notifications', 'chat', 'components', 'translator'], fu
|
||||
$('[data-tid="' + tid + '"]').addClass('unread');
|
||||
}
|
||||
|
||||
$(window).on('action:ajaxify.end', function(ev, data) {
|
||||
$(window).on('action:ajaxify.end', function (ev, data) {
|
||||
if (data.url) {
|
||||
var tid = data.url.match(/^topic\/(\d+)/);
|
||||
|
||||
@@ -63,7 +63,7 @@ define('forum/footer', ['notifications', 'chat', 'components', 'translator'], fu
|
||||
}
|
||||
|
||||
if (app.user.uid) {
|
||||
socket.emit('user.getUnreadCounts', function(err, data) {
|
||||
socket.emit('user.getUnreadCounts', function (err, data) {
|
||||
if (err) {
|
||||
return app.alert(err.message);
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ define('forum/groups/details', [
|
||||
'coverPhoto',
|
||||
'uploader',
|
||||
'vendor/colorpicker/colorpicker'
|
||||
], function(memberList, iconSelect, components, coverPhoto, uploader) {
|
||||
], function (memberList, iconSelect, components, coverPhoto, uploader) {
|
||||
|
||||
var Details = {};
|
||||
var groupName;
|
||||
|
||||
Details.init = function() {
|
||||
Details.init = function () {
|
||||
var detailsPage = components.get('groups/container');
|
||||
|
||||
groupName = ajaxify.data.group.name;
|
||||
@@ -22,19 +22,19 @@ define('forum/groups/details', [
|
||||
Details.prepareSettings();
|
||||
|
||||
coverPhoto.init(components.get('groups/cover'),
|
||||
function(imageData, position, callback) {
|
||||
function (imageData, position, callback) {
|
||||
socket.emit('groups.cover.update', {
|
||||
groupName: groupName,
|
||||
imageData: imageData,
|
||||
position: position
|
||||
}, callback);
|
||||
},
|
||||
function() {
|
||||
function () {
|
||||
uploader.show({
|
||||
title: '[[groups:upload-group-cover]]',
|
||||
route: config.relative_path + '/api/groups/uploadpicture',
|
||||
params: {groupName: groupName}
|
||||
}, function(imageUrlOnServer) {
|
||||
}, function (imageUrlOnServer) {
|
||||
components.get('groups/cover').css('background-image', 'url(' + imageUrlOnServer + ')');
|
||||
});
|
||||
},
|
||||
@@ -48,7 +48,7 @@ define('forum/groups/details', [
|
||||
|
||||
components.get('groups/activity').find('.content img:not(.not-responsive)').addClass('img-responsive');
|
||||
|
||||
detailsPage.on('click', '[data-action]', function() {
|
||||
detailsPage.on('click', '[data-action]', function () {
|
||||
var btnEl = $(this),
|
||||
userRow = btnEl.parents('[data-uid]'),
|
||||
ownerFlagEl = userRow.find('.member-name > i'),
|
||||
@@ -61,7 +61,7 @@ define('forum/groups/details', [
|
||||
socket.emit('groups.' + (isOwner ? 'rescind' : 'grant'), {
|
||||
toUid: uid,
|
||||
groupName: groupName
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (!err) {
|
||||
ownerFlagEl.toggleClass('invisible');
|
||||
} else {
|
||||
@@ -74,7 +74,7 @@ define('forum/groups/details', [
|
||||
socket.emit('groups.kick', {
|
||||
uid: uid,
|
||||
groupName: groupName
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (!err) {
|
||||
userRow.slideUp().remove();
|
||||
} else {
|
||||
@@ -104,7 +104,7 @@ define('forum/groups/details', [
|
||||
socket.emit('groups.' + action, {
|
||||
toUid: uid,
|
||||
groupName: groupName
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (!err) {
|
||||
ajaxify.refresh();
|
||||
} else {
|
||||
@@ -116,7 +116,7 @@ define('forum/groups/details', [
|
||||
});
|
||||
};
|
||||
|
||||
Details.prepareSettings = function() {
|
||||
Details.prepareSettings = function () {
|
||||
var settingsFormEl = components.get('groups/settings'),
|
||||
colorBtn = settingsFormEl.find('[data-action="color-select"]'),
|
||||
colorValueEl = settingsFormEl.find('[name="labelColor"]'),
|
||||
@@ -130,31 +130,31 @@ define('forum/groups/details', [
|
||||
// Add color picker to settings form
|
||||
colorBtn.ColorPicker({
|
||||
color: colorValueEl.val() || '#000',
|
||||
onChange: function(hsb, hex) {
|
||||
onChange: function (hsb, hex) {
|
||||
colorValueEl.val('#' + hex);
|
||||
previewEl.css('background-color', '#' + hex);
|
||||
},
|
||||
onShow: function(colpkr) {
|
||||
onShow: function (colpkr) {
|
||||
$(colpkr).css('z-index', 1051);
|
||||
}
|
||||
});
|
||||
|
||||
// Add icon selection interface
|
||||
iconBtn.on('click', function() {
|
||||
iconSelect.init(previewIcon, function() {
|
||||
iconBtn.on('click', function () {
|
||||
iconSelect.init(previewIcon, function () {
|
||||
iconValueEl.val(previewIcon.val());
|
||||
});
|
||||
});
|
||||
|
||||
// If the user title changes, update that too
|
||||
userTitleEl.on('keyup', function() {
|
||||
userTitleEl.on('keyup', function () {
|
||||
var icon = previewIcon.detach();
|
||||
previewEl.text(' ' + (this.value || settingsFormEl.find('#name').val()));
|
||||
previewEl.prepend(icon);
|
||||
});
|
||||
|
||||
// Disable user title customisation options if the the user title itself is disabled
|
||||
userTitleEnabledEl.on('change', function() {
|
||||
userTitleEnabledEl.on('change', function () {
|
||||
var customOpts = components.get('groups/userTitleOption');
|
||||
|
||||
if (this.checked) {
|
||||
@@ -167,16 +167,16 @@ define('forum/groups/details', [
|
||||
});
|
||||
};
|
||||
|
||||
Details.update = function() {
|
||||
Details.update = function () {
|
||||
var settingsFormEl = components.get('groups/settings'),
|
||||
checkboxes = settingsFormEl.find('input[type="checkbox"][name]');
|
||||
|
||||
if (settingsFormEl.length) {
|
||||
require(['vendor/jquery/serializeObject/jquery.ba-serializeobject.min'], function() {
|
||||
require(['vendor/jquery/serializeObject/jquery.ba-serializeobject.min'], function () {
|
||||
var settings = settingsFormEl.serializeObject();
|
||||
|
||||
// Fix checkbox values
|
||||
checkboxes.each(function(idx, inputEl) {
|
||||
checkboxes.each(function (idx, inputEl) {
|
||||
inputEl = $(inputEl);
|
||||
if (inputEl.length) {
|
||||
settings[inputEl.attr('name')] = inputEl.prop('checked');
|
||||
@@ -186,7 +186,7 @@ define('forum/groups/details', [
|
||||
socket.emit('groups.update', {
|
||||
groupName: groupName,
|
||||
values: settings
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -205,14 +205,14 @@ define('forum/groups/details', [
|
||||
}
|
||||
};
|
||||
|
||||
Details.deleteGroup = function() {
|
||||
bootbox.confirm('Are you sure you want to delete the group: ' + utils.escapeHTML(groupName), function(confirm) {
|
||||
Details.deleteGroup = function () {
|
||||
bootbox.confirm('Are you sure you want to delete the group: ' + utils.escapeHTML(groupName), function (confirm) {
|
||||
if (confirm) {
|
||||
bootbox.prompt('Please enter the name of this group in order to delete it:', function(response) {
|
||||
bootbox.prompt('Please enter the name of this group in order to delete it:', function (response) {
|
||||
if (response === groupName) {
|
||||
socket.emit('groups.delete', {
|
||||
groupName: groupName
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (!err) {
|
||||
app.alertSuccess('[[groups:event.deleted, ' + utils.escapeHTML(groupName) + ']]');
|
||||
ajaxify.go('groups');
|
||||
@@ -232,12 +232,12 @@ define('forum/groups/details', [
|
||||
}
|
||||
|
||||
var searchInput = $('[component="groups/members/invite"]');
|
||||
require(['autocomplete'], function(autocomplete) {
|
||||
autocomplete.user(searchInput, function(event, selected) {
|
||||
require(['autocomplete'], function (autocomplete) {
|
||||
autocomplete.user(searchInput, function (event, selected) {
|
||||
socket.emit('groups.issueInvite', {
|
||||
toUid: selected.item.user.uid,
|
||||
groupName: ajaxify.data.group.name
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -246,7 +246,7 @@ define('forum/groups/details', [
|
||||
});
|
||||
});
|
||||
|
||||
$('[component="groups/members/bulk-invite-button"]').on('click', function() {
|
||||
$('[component="groups/members/bulk-invite-button"]').on('click', function () {
|
||||
var usernames = $('[component="groups/members/bulk-invite"]').val();
|
||||
if (!usernames) {
|
||||
return false;
|
||||
@@ -254,7 +254,7 @@ define('forum/groups/details', [
|
||||
socket.emit('groups.issueMassInvite', {
|
||||
usernames: usernames,
|
||||
groupName: ajaxify.data.group.name
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -267,7 +267,7 @@ define('forum/groups/details', [
|
||||
function removeCover() {
|
||||
socket.emit('groups.cover.remove', {
|
||||
groupName: ajaxify.data.group.name
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (!err) {
|
||||
ajaxify.refresh();
|
||||
} else {
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
"use strict";
|
||||
/* globals app, define, ajaxify, socket, bootbox, utils, templates */
|
||||
|
||||
define('forum/groups/list', ['forum/infinitescroll'], function(infinitescroll) {
|
||||
define('forum/groups/list', ['forum/infinitescroll'], function (infinitescroll) {
|
||||
var Groups = {};
|
||||
|
||||
Groups.init = function() {
|
||||
Groups.init = function () {
|
||||
var groupsEl = $('#groups-list');
|
||||
|
||||
infinitescroll.init(Groups.loadMoreGroups);
|
||||
|
||||
// Group creation
|
||||
$('button[data-action="new"]').on('click', function() {
|
||||
bootbox.prompt('[[groups:new-group.group_name]]', function(name) {
|
||||
$('button[data-action="new"]').on('click', function () {
|
||||
bootbox.prompt('[[groups:new-group.group_name]]', function (name) {
|
||||
if (name && name.length) {
|
||||
socket.emit('groups.create', {
|
||||
name: name
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (!err) {
|
||||
ajaxify.go('groups/' + utils.slugify(name));
|
||||
} else {
|
||||
@@ -31,12 +31,12 @@ define('forum/groups/list', ['forum/infinitescroll'], function(infinitescroll) {
|
||||
// Group searching
|
||||
$('#search-text').on('keyup', Groups.search);
|
||||
$('#search-button').on('click', Groups.search);
|
||||
$('#search-sort').on('change', function() {
|
||||
$('#search-sort').on('change', function () {
|
||||
ajaxify.go('groups?sort=' + $('#search-sort').val());
|
||||
});
|
||||
};
|
||||
|
||||
Groups.loadMoreGroups = function(direction) {
|
||||
Groups.loadMoreGroups = function (direction) {
|
||||
if (direction < 0) {
|
||||
return;
|
||||
}
|
||||
@@ -44,11 +44,11 @@ define('forum/groups/list', ['forum/infinitescroll'], function(infinitescroll) {
|
||||
infinitescroll.loadMore('groups.loadMore', {
|
||||
sort: $('#search-sort').val(),
|
||||
after: $('[component="groups/container"]').attr('data-nextstart')
|
||||
}, function(data, done) {
|
||||
}, function (data, done) {
|
||||
if (data && data.groups.length) {
|
||||
templates.parse('partials/groups/list', {
|
||||
groups: data.groups
|
||||
}, function(html) {
|
||||
}, function (html) {
|
||||
$('#groups-list').append(html);
|
||||
done();
|
||||
});
|
||||
@@ -62,7 +62,7 @@ define('forum/groups/list', ['forum/infinitescroll'], function(infinitescroll) {
|
||||
});
|
||||
}
|
||||
|
||||
Groups.search = function() {
|
||||
Groups.search = function () {
|
||||
var groupsEl = $('#groups-list'),
|
||||
queryEl = $('#search-text'),
|
||||
sortEl = $('#search-sort');
|
||||
@@ -73,16 +73,16 @@ define('forum/groups/list', ['forum/infinitescroll'], function(infinitescroll) {
|
||||
sort: sortEl.val(),
|
||||
filterHidden: true
|
||||
}
|
||||
}, function(err, groups) {
|
||||
}, function (err, groups) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
groups = groups.filter(function(group) {
|
||||
groups = groups.filter(function (group) {
|
||||
return group.name !== 'registered-users' && group.name !== 'guests';
|
||||
});
|
||||
templates.parse('partials/groups/list', {
|
||||
groups: groups
|
||||
}, function(html) {
|
||||
}, function (html) {
|
||||
groupsEl.empty().append(html);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
"use strict";
|
||||
/* globals define, socket, ajaxify, app */
|
||||
|
||||
define('forum/groups/memberlist', ['components', 'forum/infinitescroll'], function(components, infinitescroll) {
|
||||
define('forum/groups/memberlist', ['components', 'forum/infinitescroll'], function (components, infinitescroll) {
|
||||
|
||||
var MemberList = {};
|
||||
var searchInterval;
|
||||
var groupName;
|
||||
|
||||
MemberList.init = function() {
|
||||
MemberList.init = function () {
|
||||
groupName = ajaxify.data.group.name;
|
||||
|
||||
handleMemberSearch();
|
||||
@@ -15,19 +15,19 @@ define('forum/groups/memberlist', ['components', 'forum/infinitescroll'], functi
|
||||
};
|
||||
|
||||
function handleMemberSearch() {
|
||||
$('[component="groups/members/search"]').on('keyup', function() {
|
||||
$('[component="groups/members/search"]').on('keyup', function () {
|
||||
var query = $(this).val();
|
||||
if (searchInterval) {
|
||||
clearInterval(searchInterval);
|
||||
searchInterval = 0;
|
||||
}
|
||||
|
||||
searchInterval = setTimeout(function() {
|
||||
socket.emit('groups.searchMembers', {groupName: groupName, query: query}, function(err, results) {
|
||||
searchInterval = setTimeout(function () {
|
||||
socket.emit('groups.searchMembers', {groupName: groupName, query: query}, function (err, results) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
parseAndTranslate(results.users, function(html) {
|
||||
parseAndTranslate(results.users, function (html) {
|
||||
$('[component="groups/members"] tbody').html(html);
|
||||
$('[component="groups/members"]').attr('data-nextstart', 20);
|
||||
});
|
||||
@@ -37,7 +37,7 @@ define('forum/groups/memberlist', ['components', 'forum/infinitescroll'], functi
|
||||
}
|
||||
|
||||
function handleMemberInfiniteScroll() {
|
||||
$('[component="groups/members"] tbody').on('scroll', function() {
|
||||
$('[component="groups/members"] tbody').on('scroll', function () {
|
||||
var $this = $(this);
|
||||
var bottom = ($this[0].scrollHeight - $this.innerHeight()) * 0.9;
|
||||
|
||||
@@ -57,13 +57,13 @@ define('forum/groups/memberlist', ['components', 'forum/infinitescroll'], functi
|
||||
socket.emit('groups.loadMoreMembers', {
|
||||
groupName: groupName,
|
||||
after: members.attr('data-nextstart')
|
||||
}, function(err, data) {
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
if (data && data.users.length) {
|
||||
onMembersLoaded(data.users, function() {
|
||||
onMembersLoaded(data.users, function () {
|
||||
members.removeAttr('loading');
|
||||
members.attr('data-nextstart', data.nextStart);
|
||||
});
|
||||
@@ -74,11 +74,11 @@ define('forum/groups/memberlist', ['components', 'forum/infinitescroll'], functi
|
||||
}
|
||||
|
||||
function onMembersLoaded(users, callback) {
|
||||
users = users.filter(function(user) {
|
||||
users = users.filter(function (user) {
|
||||
return !$('[component="groups/members"] [data-uid="' + user.uid + '"]').length;
|
||||
});
|
||||
|
||||
parseAndTranslate(users, function(html) {
|
||||
parseAndTranslate(users, function (html) {
|
||||
$('[component="groups/members"] tbody').append(html);
|
||||
callback();
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/* globals define, socket, app */
|
||||
|
||||
define('forum/infinitescroll', function() {
|
||||
define('forum/infinitescroll', function () {
|
||||
|
||||
var scroll = {};
|
||||
var callback;
|
||||
@@ -10,7 +10,7 @@ define('forum/infinitescroll', function() {
|
||||
var loadingMore = false;
|
||||
var container;
|
||||
|
||||
scroll.init = function(el, cb) {
|
||||
scroll.init = function (el, cb) {
|
||||
if (typeof el === 'function') {
|
||||
callback = el;
|
||||
container = $('body');
|
||||
@@ -47,7 +47,7 @@ define('forum/infinitescroll', function() {
|
||||
previousScrollTop = currentScrollTop;
|
||||
}
|
||||
|
||||
scroll.loadMore = function(method, data, callback) {
|
||||
scroll.loadMore = function (method, data, callback) {
|
||||
if (loadingMore) {
|
||||
return;
|
||||
}
|
||||
@@ -56,18 +56,18 @@ define('forum/infinitescroll', function() {
|
||||
var hookData = {method: method, data: data};
|
||||
$(window).trigger('action:infinitescroll.loadmore', hookData);
|
||||
|
||||
socket.emit(hookData.method, hookData.data, function(err, data) {
|
||||
socket.emit(hookData.method, hookData.data, function (err, data) {
|
||||
if (err) {
|
||||
loadingMore = false;
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
callback(data, function() {
|
||||
callback(data, function () {
|
||||
loadingMore = false;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
scroll.removeExtra = function(els, direction, count) {
|
||||
scroll.removeExtra = function (els, direction, count) {
|
||||
if (els.length <= count) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
"use strict";
|
||||
/* global define, app, config, RELATIVE_PATH */
|
||||
|
||||
define('forum/login', ['translator'], function(translator) {
|
||||
define('forum/login', ['translator'], function (translator) {
|
||||
var Login = {};
|
||||
|
||||
Login.init = function() {
|
||||
Login.init = function () {
|
||||
var errorEl = $('#login-error-notify'),
|
||||
submitEl = $('#login'),
|
||||
formEl = $('#login-form');
|
||||
|
||||
submitEl.on('click', function(e) {
|
||||
submitEl.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (!$('#username').val() || !$('#password').val()) {
|
||||
@@ -27,10 +27,10 @@ define('forum/login', ['translator'], function(translator) {
|
||||
headers: {
|
||||
'x-csrf-token': config.csrf_token
|
||||
},
|
||||
success: function(data, status) {
|
||||
success: function (data, status) {
|
||||
window.location.href = data + '?loggedin';
|
||||
},
|
||||
error: function(data, status) {
|
||||
error: function (data, status) {
|
||||
if (data.status === 403 && data.responseText === 'Forbidden') {
|
||||
window.location.href = config.relative_path + '/login?error=csrf-invalid';
|
||||
} else {
|
||||
@@ -48,7 +48,7 @@ define('forum/login', ['translator'], function(translator) {
|
||||
}
|
||||
});
|
||||
|
||||
$('#login-error-notify button').on('click', function(e) {
|
||||
$('#login-error-notify button').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
errorEl.hide();
|
||||
return false;
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
/* globals define, socket, app */
|
||||
|
||||
define('forum/notifications', ['components', 'notifications', 'forum/infinitescroll'], function(components, notifs, infinitescroll) {
|
||||
define('forum/notifications', ['components', 'notifications', 'forum/infinitescroll'], function (components, notifs, infinitescroll) {
|
||||
var Notifications = {};
|
||||
|
||||
Notifications.init = function() {
|
||||
Notifications.init = function () {
|
||||
var listEl = $('.notifications-list');
|
||||
listEl.on('click', '[component="notifications/item/link"]', function() {
|
||||
listEl.on('click', '[component="notifications/item/link"]', function () {
|
||||
var nid = $(this).parents('[data-nid]').attr('data-nid');
|
||||
socket.emit('notifications.markRead', nid, function(err) {
|
||||
socket.emit('notifications.markRead', nid, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
@@ -18,8 +18,8 @@ define('forum/notifications', ['components', 'notifications', 'forum/infinitescr
|
||||
|
||||
$('.timeago').timeago();
|
||||
|
||||
components.get('notifications/mark_all').on('click', function() {
|
||||
socket.emit('notifications.markAllRead', function(err) {
|
||||
components.get('notifications/mark_all').on('click', function () {
|
||||
socket.emit('notifications.markAllRead', function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -39,7 +39,7 @@ define('forum/notifications', ['components', 'notifications', 'forum/infinitescr
|
||||
var notifList = $('.notifications-list');
|
||||
infinitescroll.loadMore('notifications.loadMore', {
|
||||
after: notifList.attr('data-nextstart')
|
||||
}, function(data, done) {
|
||||
}, function (data, done) {
|
||||
if (!data) {
|
||||
return done();
|
||||
}
|
||||
@@ -47,7 +47,7 @@ define('forum/notifications', ['components', 'notifications', 'forum/infinitescr
|
||||
if (!data.notifications || !data.notifications.length) {
|
||||
return done();
|
||||
}
|
||||
app.parseAndTranslate('notifications', 'notifications', {notifications: data.notifications}, function(html) {
|
||||
app.parseAndTranslate('notifications', 'notifications', {notifications: data.notifications}, function (html) {
|
||||
notifList.append(html);
|
||||
html.find('.timeago').timeago();
|
||||
done();
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
'use strict';
|
||||
/*global define, utils, ajaxify, bootbox*/
|
||||
|
||||
define('forum/pagination', function() {
|
||||
define('forum/pagination', function () {
|
||||
var pagination = {};
|
||||
|
||||
pagination.init = function() {
|
||||
$('body').on('click', '[component="pagination/select-page"]', function() {
|
||||
bootbox.prompt('[[global:enter_page_number]]', function(pageNum) {
|
||||
pagination.init = function () {
|
||||
$('body').on('click', '[component="pagination/select-page"]', function () {
|
||||
bootbox.prompt('[[global:enter_page_number]]', function (pageNum) {
|
||||
pagination.loadPage(pageNum);
|
||||
});
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
pagination.loadPage = function(page, callback) {
|
||||
callback = callback || function() {};
|
||||
pagination.loadPage = function (page, callback) {
|
||||
callback = callback || function () {};
|
||||
page = parseInt(page, 10);
|
||||
if (!utils.isNumber(page) || page < 1 || page > ajaxify.data.pagination.pageCount) {
|
||||
return;
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
/* globals define, app, socket*/
|
||||
|
||||
define('forum/popular', ['components'], function(components) {
|
||||
define('forum/popular', ['components'], function (components) {
|
||||
var Popular = {};
|
||||
|
||||
Popular.init = function() {
|
||||
Popular.init = function () {
|
||||
app.enterRoom('popular_topics');
|
||||
|
||||
components.get('popular/tab')
|
||||
|
||||
@@ -2,24 +2,24 @@
|
||||
|
||||
/* globals define, app, socket, utils, ajaxify, config */
|
||||
|
||||
define('forum/recent', ['forum/infinitescroll', 'components'], function(infinitescroll, components) {
|
||||
define('forum/recent', ['forum/infinitescroll', 'components'], function (infinitescroll, components) {
|
||||
var Recent = {};
|
||||
|
||||
var newTopicCount = 0;
|
||||
var newPostCount = 0;
|
||||
|
||||
$(window).on('action:ajaxify.start', function(ev, data) {
|
||||
$(window).on('action:ajaxify.start', function (ev, data) {
|
||||
if (ajaxify.currentPage !== data.url) {
|
||||
Recent.removeListeners();
|
||||
}
|
||||
});
|
||||
|
||||
Recent.init = function() {
|
||||
Recent.init = function () {
|
||||
app.enterRoom('recent_topics');
|
||||
|
||||
Recent.watchForNewPosts();
|
||||
|
||||
$('#new-topics-alert').on('click', function() {
|
||||
$('#new-topics-alert').on('click', function () {
|
||||
$(this).addClass('hide');
|
||||
});
|
||||
|
||||
@@ -74,7 +74,7 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite
|
||||
}
|
||||
|
||||
if (ajaxify.data.selectedFilter && ajaxify.data.selectedFilter.url === 'unread/watched') {
|
||||
socket.emit('topics.isFollowed', post.tid, function(err, isFollowed) {
|
||||
socket.emit('topics.isFollowed', post.tid, function (err, isFollowed) {
|
||||
if (err) {
|
||||
app.alertError(err.message);
|
||||
}
|
||||
@@ -88,12 +88,12 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite
|
||||
showAlert();
|
||||
}
|
||||
|
||||
Recent.removeListeners = function() {
|
||||
Recent.removeListeners = function () {
|
||||
socket.removeListener('event:new_topic', onNewTopic);
|
||||
socket.removeListener('event:new_post', onNewPost);
|
||||
};
|
||||
|
||||
Recent.updateAlertText = function() {
|
||||
Recent.updateAlertText = function () {
|
||||
var text = '';
|
||||
|
||||
if (newTopicCount === 0) {
|
||||
@@ -108,7 +108,7 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite
|
||||
} else if (newPostCount === 1) {
|
||||
text = '[[recent:there-is-a-new-topic-and-a-new-post]]';
|
||||
} else if (newPostCount > 1) {
|
||||
text = '[[recent:there-is-a-new-topic-and-new-posts, ' + newPostCount +']]';
|
||||
text = '[[recent:there-is-a-new-topic-and-new-posts, ' + newPostCount + ']]';
|
||||
}
|
||||
} else if (newTopicCount > 1) {
|
||||
if (newPostCount === 0) {
|
||||
@@ -116,7 +116,7 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite
|
||||
} else if (newPostCount === 1) {
|
||||
text = '[[recent:there-are-new-topics-and-a-new-post, ' + newTopicCount + ']]';
|
||||
} else if (newPostCount > 1) {
|
||||
text = '[[recent:there-are-new-topics-and-new-posts, ' + newTopicCount + ', ' + newPostCount +']]';
|
||||
text = '[[recent:there-are-new-topics-and-new-posts, ' + newTopicCount + ', ' + newPostCount + ']]';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite
|
||||
$('#category-no-topics').addClass('hide');
|
||||
};
|
||||
|
||||
Recent.loadMoreTopics = function(direction) {
|
||||
Recent.loadMoreTopics = function (direction) {
|
||||
if(direction < 0 || !$('[component="category"]').length) {
|
||||
return;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite
|
||||
infinitescroll.loadMore('topics.loadMoreFromSet', {
|
||||
after: $('[component="category"]').attr('data-nextstart'),
|
||||
set: $('[component="category"]').attr('data-set') ? $('[component="category"]').attr('data-set') : 'topics:recent'
|
||||
}, function(data, done) {
|
||||
}, function (data, done) {
|
||||
if (data.topics && data.topics.length) {
|
||||
Recent.onTopicsLoaded('recent', data.topics, false, done);
|
||||
} else {
|
||||
@@ -144,9 +144,9 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite
|
||||
});
|
||||
};
|
||||
|
||||
Recent.onTopicsLoaded = function(templateName, topics, showSelect, callback) {
|
||||
Recent.onTopicsLoaded = function (templateName, topics, showSelect, callback) {
|
||||
|
||||
topics = topics.filter(function(topic) {
|
||||
topics = topics.filter(function (topic) {
|
||||
return !components.get('category/topic', 'tid', topic.tid).length;
|
||||
});
|
||||
|
||||
@@ -154,7 +154,7 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite
|
||||
return callback();
|
||||
}
|
||||
|
||||
app.parseAndTranslate(templateName, 'topics', {topics: topics, showSelect: showSelect}, function(html) {
|
||||
app.parseAndTranslate(templateName, 'topics', {topics: topics, showSelect: showSelect}, function (html) {
|
||||
$('#category-no-topics').remove();
|
||||
|
||||
$('[component="category"]').append(html);
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
/* globals define, app, utils, socket, config, ajaxify, bootbox */
|
||||
|
||||
|
||||
define('forum/register', ['translator'], function(translator) {
|
||||
define('forum/register', ['translator'], function (translator) {
|
||||
var Register = {},
|
||||
validationError = false,
|
||||
successIcon = '';
|
||||
|
||||
Register.init = function() {
|
||||
Register.init = function () {
|
||||
var email = $('#email'),
|
||||
username = $('#username'),
|
||||
password = $('#password'),
|
||||
@@ -19,7 +19,7 @@ define('forum/register', ['translator'], function(translator) {
|
||||
|
||||
$('#referrer').val(app.previousUrl);
|
||||
|
||||
email.on('blur', function() {
|
||||
email.on('blur', function () {
|
||||
if (email.val().length) {
|
||||
validateEmail(email.val());
|
||||
}
|
||||
@@ -32,23 +32,23 @@ define('forum/register', ['translator'], function(translator) {
|
||||
}
|
||||
|
||||
// Update the "others can mention you via" text
|
||||
username.on('keyup', function() {
|
||||
username.on('keyup', function () {
|
||||
$('#yourUsername').text(this.value.length > 0 ? utils.slugify(this.value) : 'username');
|
||||
});
|
||||
|
||||
username.on('blur', function() {
|
||||
username.on('blur', function () {
|
||||
if (username.val().length) {
|
||||
validateUsername(username.val());
|
||||
}
|
||||
});
|
||||
|
||||
password.on('blur', function() {
|
||||
password.on('blur', function () {
|
||||
if (password.val().length) {
|
||||
validatePassword(password.val(), password_confirm.val());
|
||||
}
|
||||
});
|
||||
|
||||
password_confirm.on('blur', function() {
|
||||
password_confirm.on('blur', function () {
|
||||
if (password_confirm.val().length) {
|
||||
validatePasswordConfirm(password.val(), password_confirm.val());
|
||||
}
|
||||
@@ -59,17 +59,17 @@ define('forum/register', ['translator'], function(translator) {
|
||||
validatePassword(password.val(), password_confirm.val());
|
||||
validatePasswordConfirm(password.val(), password_confirm.val());
|
||||
|
||||
validateEmail(email.val(), function() {
|
||||
validateEmail(email.val(), function () {
|
||||
validateUsername(username.val(), callback);
|
||||
});
|
||||
}
|
||||
|
||||
register.on('click', function(e) {
|
||||
register.on('click', function (e) {
|
||||
var registerBtn = $(this);
|
||||
var errorEl = $('#register-error-notify');
|
||||
errorEl.addClass('hidden');
|
||||
e.preventDefault();
|
||||
validateForm(function() {
|
||||
validateForm(function () {
|
||||
if (validationError) {
|
||||
return;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ define('forum/register', ['translator'], function(translator) {
|
||||
headers: {
|
||||
'x-csrf-token': config.csrf_token
|
||||
},
|
||||
success: function(data) {
|
||||
success: function (data) {
|
||||
registerBtn.removeClass('disabled');
|
||||
if (!data) {
|
||||
return;
|
||||
@@ -88,16 +88,16 @@ define('forum/register', ['translator'], function(translator) {
|
||||
if (data.referrer) {
|
||||
window.location.href = data.referrer;
|
||||
} else if (data.message) {
|
||||
require(['translator'], function(translator) {
|
||||
translator.translate(data.message, function(msg) {
|
||||
require(['translator'], function (translator) {
|
||||
translator.translate(data.message, function (msg) {
|
||||
bootbox.alert(msg);
|
||||
ajaxify.go('/');
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
translator.translate(data.responseText, config.defaultLang, function(translated) {
|
||||
error: function (data) {
|
||||
translator.translate(data.responseText, config.defaultLang, function (translated) {
|
||||
if (data.status === 403 && data.responseText === 'Forbidden') {
|
||||
window.location.href = config.relative_path + '/register?error=csrf-invalid';
|
||||
} else {
|
||||
@@ -113,7 +113,7 @@ define('forum/register', ['translator'], function(translator) {
|
||||
};
|
||||
|
||||
function validateEmail(email, callback) {
|
||||
callback = callback || function() {};
|
||||
callback = callback || function () {};
|
||||
var email_notify = $('#email-notify');
|
||||
|
||||
if (!utils.isEmailValid(email)) {
|
||||
@@ -123,7 +123,7 @@ define('forum/register', ['translator'], function(translator) {
|
||||
|
||||
socket.emit('user.emailExists', {
|
||||
email: email
|
||||
}, function(err, exists) {
|
||||
}, function (err, exists) {
|
||||
if (err) {
|
||||
app.alertError(err.message);
|
||||
return callback();
|
||||
@@ -140,7 +140,7 @@ define('forum/register', ['translator'], function(translator) {
|
||||
}
|
||||
|
||||
function validateUsername(username, callback) {
|
||||
callback = callback || function() {};
|
||||
callback = callback || function () {};
|
||||
|
||||
var username_notify = $('#username-notify');
|
||||
|
||||
@@ -153,7 +153,7 @@ define('forum/register', ['translator'], function(translator) {
|
||||
} else {
|
||||
socket.emit('user.exists', {
|
||||
username: username
|
||||
}, function(err, exists) {
|
||||
}, function (err, exists) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -208,7 +208,7 @@ define('forum/register', ['translator'], function(translator) {
|
||||
}
|
||||
|
||||
function showError(element, msg) {
|
||||
translator.translate(msg, function(msg) {
|
||||
translator.translate(msg, function (msg) {
|
||||
element.html(msg);
|
||||
element.parent()
|
||||
.removeClass('register-success')
|
||||
@@ -219,7 +219,7 @@ define('forum/register', ['translator'], function(translator) {
|
||||
}
|
||||
|
||||
function showSuccess(element, msg) {
|
||||
translator.translate(msg, function(msg) {
|
||||
translator.translate(msg, function (msg) {
|
||||
element.html(msg);
|
||||
element.parent()
|
||||
.removeClass('register-danger')
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
"use strict";
|
||||
/*globals define, app, socket*/
|
||||
|
||||
define('forum/reset', function() {
|
||||
define('forum/reset', function () {
|
||||
var ResetPassword = {};
|
||||
|
||||
ResetPassword.init = function() {
|
||||
ResetPassword.init = function () {
|
||||
var inputEl = $('#email'),
|
||||
errorEl = $('#error'),
|
||||
successEl = $('#success');
|
||||
|
||||
$('#reset').on('click', function() {
|
||||
$('#reset').on('click', function () {
|
||||
if (inputEl.val() && inputEl.val().indexOf('@') !== -1) {
|
||||
socket.emit('user.reset.send', inputEl.val(), function(err) {
|
||||
socket.emit('user.reset.send', inputEl.val(), function (err) {
|
||||
if(err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
"use strict";
|
||||
/*globals define, app, ajaxify, socket, config*/
|
||||
|
||||
define('forum/reset_code', function() {
|
||||
define('forum/reset_code', function () {
|
||||
var ResetCode = {};
|
||||
|
||||
ResetCode.init = function() {
|
||||
ResetCode.init = function () {
|
||||
var reset_code = ajaxify.data.code;
|
||||
|
||||
var resetEl = $('#reset');
|
||||
var password = $('#password');
|
||||
var repeat = $('#repeat');
|
||||
|
||||
resetEl.on('click', function() {
|
||||
resetEl.on('click', function () {
|
||||
if (password.val().length < ajaxify.data.minimumPasswordLength) {
|
||||
app.alertError('[[reset_password:password_too_short]]');
|
||||
} else if (password.val() !== repeat.val()) {
|
||||
@@ -21,7 +21,7 @@ define('forum/reset_code', function() {
|
||||
socket.emit('user.reset.commit', {
|
||||
code: reset_code,
|
||||
password: password.val()
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
ajaxify.refresh();
|
||||
return app.alertError(err.message);
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
/* globals app, define, utils*/
|
||||
|
||||
define('forum/search', ['search', 'autocomplete'], function(searchModule, autocomplete) {
|
||||
define('forum/search', ['search', 'autocomplete'], function (searchModule, autocomplete) {
|
||||
var Search = {};
|
||||
|
||||
Search.init = function() {
|
||||
Search.init = function () {
|
||||
var searchQuery = $('#results').attr('data-search-query');
|
||||
|
||||
$('#search-input').val(searchQuery);
|
||||
@@ -14,15 +14,15 @@ define('forum/search', ['search', 'autocomplete'], function(searchModule, autoco
|
||||
|
||||
fillOutForm();
|
||||
|
||||
searchIn.on('change', function() {
|
||||
searchIn.on('change', function () {
|
||||
updateFormItemVisiblity(searchIn.val());
|
||||
});
|
||||
|
||||
highlightMatches(searchQuery);
|
||||
|
||||
$('#advanced-search').off('submit').on('submit', function(e) {
|
||||
$('#advanced-search').off('submit').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
searchModule.query(getSearchData(), function() {
|
||||
searchModule.query(getSearchData(), function () {
|
||||
$('#search-input').val('');
|
||||
});
|
||||
return false;
|
||||
@@ -120,10 +120,10 @@ define('forum/search', ['search', 'autocomplete'], function(searchModule, autoco
|
||||
var regexStr = searchQuery.replace(/^"/, '').replace(/"$/, '').trim().split(' ').join('|');
|
||||
var regex = new RegExp('(' + regexStr + ')', 'gi');
|
||||
|
||||
$('.search-result-text p, .search-result-text h4').each(function() {
|
||||
$('.search-result-text p, .search-result-text h4').each(function () {
|
||||
var result = $(this), nested = [];
|
||||
|
||||
result.find('*').each(function() {
|
||||
result.find('*').each(function () {
|
||||
$(this).after('<!-- ' + nested.length + ' -->');
|
||||
nested.push($('<div />').append($(this)));
|
||||
});
|
||||
@@ -139,13 +139,13 @@ define('forum/search', ['search', 'autocomplete'], function(searchModule, autoco
|
||||
}
|
||||
|
||||
function handleSavePreferences() {
|
||||
$('#save-preferences').on('click', function() {
|
||||
$('#save-preferences').on('click', function () {
|
||||
localStorage.setItem('search-preferences', JSON.stringify(getSearchData()));
|
||||
app.alertSuccess('[[search:search-preferences-saved]]');
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#clear-preferences').on('click', function() {
|
||||
$('#clear-preferences').on('click', function () {
|
||||
localStorage.removeItem('search-preferences');
|
||||
var query = $('#search-input').val();
|
||||
$('#advanced-search')[0].reset();
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
/* globals define, app, ajaxify, socket */
|
||||
|
||||
define('forum/tag', ['forum/recent', 'forum/infinitescroll'], function(recent, infinitescroll) {
|
||||
define('forum/tag', ['forum/recent', 'forum/infinitescroll'], function (recent, infinitescroll) {
|
||||
var Tag = {};
|
||||
|
||||
Tag.init = function() {
|
||||
Tag.init = function () {
|
||||
app.enterRoom('tags');
|
||||
|
||||
if ($('body').height() <= $(window).height() && $('[component="category"]').children().length >= 20) {
|
||||
$('#load-more-btn').show();
|
||||
}
|
||||
|
||||
$('#load-more-btn').on('click', function() {
|
||||
$('#load-more-btn').on('click', function () {
|
||||
loadMoreTopics();
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ define('forum/tag', ['forum/recent', 'forum/infinitescroll'], function(recent, i
|
||||
infinitescroll.loadMore('topics.loadMoreFromSet', {
|
||||
set: 'tag:' + ajaxify.data.tag + ':topics',
|
||||
after: $('[component="category"]').attr('data-nextstart')
|
||||
}, function(data, done) {
|
||||
}, function (data, done) {
|
||||
if (data.topics && data.topics.length) {
|
||||
recent.onTopicsLoaded('tag', data.topics, false, done);
|
||||
} else {
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
/* globals define, app, utils, socket */
|
||||
|
||||
define('forum/tags', ['forum/infinitescroll'], function(infinitescroll) {
|
||||
define('forum/tags', ['forum/infinitescroll'], function (infinitescroll) {
|
||||
var Tags = {};
|
||||
var timeoutId = 0;
|
||||
|
||||
Tags.init = function() {
|
||||
Tags.init = function () {
|
||||
app.enterRoom('tags');
|
||||
|
||||
$('#tag-search').on('input propertychange', function() {
|
||||
$('#tag-search').on('input propertychange', function () {
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = 0;
|
||||
@@ -19,12 +19,12 @@ define('forum/tags', ['forum/infinitescroll'], function(infinitescroll) {
|
||||
return resetSearch();
|
||||
}
|
||||
|
||||
timeoutId = setTimeout(function() {
|
||||
socket.emit('topics.searchAndLoadTags', {query: $('#tag-search').val()}, function(err, results) {
|
||||
timeoutId = setTimeout(function () {
|
||||
socket.emit('topics.searchAndLoadTags', {query: $('#tag-search').val()}, function (err, results) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
onTagsLoaded(results.tags, true, function() {
|
||||
onTagsLoaded(results.tags, true, function () {
|
||||
timeoutId = 0;
|
||||
});
|
||||
});
|
||||
@@ -34,14 +34,14 @@ define('forum/tags', ['forum/infinitescroll'], function(infinitescroll) {
|
||||
infinitescroll.init(Tags.loadMoreTags);
|
||||
};
|
||||
|
||||
Tags.loadMoreTags = function(direction) {
|
||||
Tags.loadMoreTags = function (direction) {
|
||||
if(direction < 0 || !$('.tag-list').length) {
|
||||
return;
|
||||
}
|
||||
|
||||
infinitescroll.loadMore('topics.loadMoreTags', {
|
||||
after: $('.tag-list').attr('data-nextstart')
|
||||
}, function(data, done) {
|
||||
}, function (data, done) {
|
||||
if (data && data.tags && data.tags.length) {
|
||||
onTagsLoaded(data.tags, false, done);
|
||||
$('.tag-list').attr('data-nextstart', data.nextStart);
|
||||
@@ -54,7 +54,7 @@ define('forum/tags', ['forum/infinitescroll'], function(infinitescroll) {
|
||||
function resetSearch() {
|
||||
socket.emit('topics.loadMoreTags', {
|
||||
after: 0
|
||||
}, function(err, data) {
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -63,8 +63,8 @@ define('forum/tags', ['forum/infinitescroll'], function(infinitescroll) {
|
||||
}
|
||||
|
||||
function onTagsLoaded(tags, replace, callback) {
|
||||
callback = callback || function() {};
|
||||
app.parseAndTranslate('tags', 'tags', {tags: tags}, function(html) {
|
||||
callback = callback || function () {};
|
||||
app.parseAndTranslate('tags', 'tags', {tags: tags}, function (html) {
|
||||
$('.tag-list')[replace ? 'html' : 'append'](html);
|
||||
utils.makeNumbersHumanReadable(html.find('.human-readable-number'));
|
||||
callback();
|
||||
|
||||
@@ -12,11 +12,11 @@ define('forum/topic', [
|
||||
'navigator',
|
||||
'sort',
|
||||
'components'
|
||||
], function(infinitescroll, threadTools, postTools, events, posts, navigator, sort, components) {
|
||||
], function (infinitescroll, threadTools, postTools, events, posts, navigator, sort, components) {
|
||||
var Topic = {},
|
||||
currentUrl = '';
|
||||
|
||||
$(window).on('action:ajaxify.start', function(ev, data) {
|
||||
$(window).on('action:ajaxify.start', function (ev, data) {
|
||||
if (Topic.replaceURLTimeout) {
|
||||
clearTimeout(Topic.replaceURLTimeout);
|
||||
Topic.replaceURLTimeout = 0;
|
||||
@@ -32,7 +32,7 @@ define('forum/topic', [
|
||||
}
|
||||
|
||||
if (data.url && !data.url.startsWith('topic/')) {
|
||||
require(['search'], function(search) {
|
||||
require(['search'], function (search) {
|
||||
if (search.topicDOM.active) {
|
||||
search.topicDOM.end();
|
||||
}
|
||||
@@ -40,7 +40,7 @@ define('forum/topic', [
|
||||
}
|
||||
});
|
||||
|
||||
Topic.init = function() {
|
||||
Topic.init = function () {
|
||||
var tid = ajaxify.data.tid;
|
||||
|
||||
$(window).trigger('action:topic.loading');
|
||||
@@ -98,16 +98,16 @@ define('forum/topic', [
|
||||
}
|
||||
|
||||
function handleTopicSearch() {
|
||||
require(['search', 'mousetrap'], function(search, mousetrap) {
|
||||
require(['search', 'mousetrap'], function (search, mousetrap) {
|
||||
$('.topic-search')
|
||||
.on('click', '.prev', function() {
|
||||
.on('click', '.prev', function () {
|
||||
search.topicDOM.prev();
|
||||
})
|
||||
.on('click', '.next', function() {
|
||||
.on('click', '.next', function () {
|
||||
search.topicDOM.next();
|
||||
});
|
||||
|
||||
mousetrap.bind('ctrl+f', function(e) {
|
||||
mousetrap.bind('ctrl+f', function (e) {
|
||||
if (config.topicSearchEnabled) {
|
||||
// If in topic, open search window and populate, otherwise regular behaviour
|
||||
var match = ajaxify.currentPage.match(/^topic\/([\d]+)/),
|
||||
@@ -123,12 +123,12 @@ define('forum/topic', [
|
||||
});
|
||||
}
|
||||
|
||||
Topic.toTop = function() {
|
||||
Topic.toTop = function () {
|
||||
navigator.scrollTop(0);
|
||||
};
|
||||
|
||||
Topic.toBottom = function() {
|
||||
socket.emit('topics.postcount', ajaxify.data.tid, function(err, postCount) {
|
||||
Topic.toBottom = function () {
|
||||
socket.emit('topics.postcount', ajaxify.data.tid, function (err, postCount) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -155,14 +155,14 @@ define('forum/topic', [
|
||||
message: '[[topic:bookmark_instructions]]',
|
||||
timeout: 0,
|
||||
type: 'info',
|
||||
clickfn : function() {
|
||||
clickfn : function () {
|
||||
navigator.scrollToPost(parseInt(bookmark - 1, 10), true);
|
||||
},
|
||||
closefn : function() {
|
||||
closefn : function () {
|
||||
localStorage.removeItem('topic:' + tid + ':bookmark');
|
||||
}
|
||||
});
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
app.removeAlert('bookmark');
|
||||
}, 10000);
|
||||
} else {
|
||||
@@ -187,7 +187,7 @@ define('forum/topic', [
|
||||
}
|
||||
|
||||
function addBlockQuoteHandler() {
|
||||
components.get('topic').on('click', 'blockquote .toggle', function() {
|
||||
components.get('topic').on('click', 'blockquote .toggle', function () {
|
||||
var blockQuote = $(this).parent('blockquote');
|
||||
var toggle = $(this);
|
||||
blockQuote.toggleClass('uncollapsed');
|
||||
@@ -197,7 +197,7 @@ define('forum/topic', [
|
||||
}
|
||||
|
||||
function addParentHandler() {
|
||||
components.get('topic').on('click', '[component="post/parent"]', function(e) {
|
||||
components.get('topic').on('click', '[component="post/parent"]', function (e) {
|
||||
var toPid = $(this).attr('data-topid');
|
||||
|
||||
var toPost = $('[component="post"][data-pid="' + toPid + '"]');
|
||||
@@ -221,14 +221,14 @@ define('forum/topic', [
|
||||
}
|
||||
}
|
||||
|
||||
Topic.calculateIndex = function(index, elementCount) {
|
||||
Topic.calculateIndex = function (index, elementCount) {
|
||||
if (index !== 1 && config.topicPostSort !== 'oldest_to_newest') {
|
||||
return elementCount - index + 2;
|
||||
}
|
||||
return index;
|
||||
};
|
||||
|
||||
Topic.navigatorCallback = function(index, elementCount, threshold) {
|
||||
Topic.navigatorCallback = function (index, elementCount, threshold) {
|
||||
var path = ajaxify.removeRelativePath(window.location.pathname.slice(1));
|
||||
if (!path.startsWith('topic')) {
|
||||
return;
|
||||
@@ -248,7 +248,7 @@ define('forum/topic', [
|
||||
clearTimeout(Topic.replaceURLTimeout);
|
||||
}
|
||||
|
||||
Topic.replaceURLTimeout = setTimeout(function() {
|
||||
Topic.replaceURLTimeout = setTimeout(function () {
|
||||
|
||||
if (index >= elementCount && app.user.uid) {
|
||||
socket.emit('topics.markAsRead', [ajaxify.data.tid]);
|
||||
@@ -281,7 +281,7 @@ define('forum/topic', [
|
||||
socket.emit('topics.bookmark', {
|
||||
'tid': ajaxify.data.tid,
|
||||
'index': index
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
/* globals define, app, ajaxify, socket */
|
||||
|
||||
define('forum/topic/delete-posts', ['components', 'postSelect'], function(components, postSelect) {
|
||||
define('forum/topic/delete-posts', ['components', 'postSelect'], function (components, postSelect) {
|
||||
|
||||
var DeletePosts = {};
|
||||
var modal;
|
||||
var deleteBtn;
|
||||
var purgeBtn;
|
||||
|
||||
DeletePosts.init = function() {
|
||||
DeletePosts.init = function () {
|
||||
$('.topic').on('click', '[component="topic/delete/posts"]', onDeletePostsClicked);
|
||||
$(window).on('action:ajaxify.start', onAjaxifyStart);
|
||||
};
|
||||
@@ -20,7 +20,7 @@ define('forum/topic/delete-posts', ['components', 'postSelect'], function(compon
|
||||
}
|
||||
|
||||
function onDeletePostsClicked() {
|
||||
app.parseAndTranslate('partials/delete_posts_modal', {}, function(html) {
|
||||
app.parseAndTranslate('partials/delete_posts_modal', {}, function (html) {
|
||||
modal = html;
|
||||
|
||||
$('body').append(modal);
|
||||
@@ -30,16 +30,16 @@ define('forum/topic/delete-posts', ['components', 'postSelect'], function(compon
|
||||
|
||||
modal.find('.close,#delete_posts_cancel').on('click', closeModal);
|
||||
|
||||
postSelect.init(function() {
|
||||
postSelect.init(function () {
|
||||
checkButtonEnable();
|
||||
showPostsSelected();
|
||||
});
|
||||
showPostsSelected();
|
||||
|
||||
deleteBtn.on('click', function() {
|
||||
deleteBtn.on('click', function () {
|
||||
deletePosts(deleteBtn, 'posts.deletePosts');
|
||||
});
|
||||
purgeBtn.on('click', function() {
|
||||
purgeBtn.on('click', function () {
|
||||
deletePosts(purgeBtn, 'posts.purgePosts');
|
||||
});
|
||||
});
|
||||
@@ -50,7 +50,7 @@ define('forum/topic/delete-posts', ['components', 'postSelect'], function(compon
|
||||
socket.emit(command, {
|
||||
tid: ajaxify.data.tid,
|
||||
pids: postSelect.pids
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
btn.removeAttr('disabled');
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
@@ -79,7 +79,7 @@ define('forum/topic/delete-posts', ['components', 'postSelect'], function(compon
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
postSelect.pids.forEach(function(pid) {
|
||||
postSelect.pids.forEach(function (pid) {
|
||||
components.get('post', 'pid', pid).toggleClass('bg-success', false);
|
||||
});
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ define('forum/topic/events', [
|
||||
'forum/topic/posts',
|
||||
'components',
|
||||
'translator'
|
||||
], function(postTools, threadTools, posts, components, translator) {
|
||||
], function (postTools, threadTools, posts, components, translator) {
|
||||
|
||||
var Events = {};
|
||||
|
||||
@@ -47,7 +47,7 @@ define('forum/topic/events', [
|
||||
'event:new_post': posts.onNewPost
|
||||
};
|
||||
|
||||
Events.init = function() {
|
||||
Events.init = function () {
|
||||
Events.removeListeners();
|
||||
for(var eventName in events) {
|
||||
if (events.hasOwnProperty(eventName)) {
|
||||
@@ -56,7 +56,7 @@ define('forum/topic/events', [
|
||||
}
|
||||
};
|
||||
|
||||
Events.removeListeners = function() {
|
||||
Events.removeListeners = function () {
|
||||
for(var eventName in events) {
|
||||
if (events.hasOwnProperty(eventName)) {
|
||||
socket.removeListener(eventName, events[eventName]);
|
||||
@@ -107,18 +107,18 @@ define('forum/topic/events', [
|
||||
var 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() {
|
||||
topicTitle.fadeOut(250, function () {
|
||||
topicTitle.html(data.topic.title).fadeIn(250);
|
||||
});
|
||||
breadCrumb.fadeOut(250, function() {
|
||||
breadCrumb.fadeOut(250, function () {
|
||||
breadCrumb.html(data.topic.title).fadeIn(250);
|
||||
});
|
||||
navbarTitle.fadeOut(250, function() {
|
||||
navbarTitle.fadeOut(250, function () {
|
||||
navbarTitle.html(data.topic.title).fadeIn(250);
|
||||
});
|
||||
}
|
||||
|
||||
editedPostEl.fadeOut(250, function() {
|
||||
editedPostEl.fadeOut(250, function () {
|
||||
editedPostEl.html(translator.unescape(data.post.content));
|
||||
editedPostEl.find('img:not(.not-responsive)').addClass('img-responsive');
|
||||
app.replaceSelfLinks(editedPostEl.find('a'));
|
||||
@@ -132,8 +132,8 @@ define('forum/topic/events', [
|
||||
editedISO: utils.toISOString(data.post.edited)
|
||||
};
|
||||
|
||||
templates.parse('partials/topic/post-editor', editData, function(html) {
|
||||
translator.translate(html, function(translated) {
|
||||
templates.parse('partials/topic/post-editor', editData, function (html) {
|
||||
translator.translate(html, function (translated) {
|
||||
html = $(translated);
|
||||
editorEl.replaceWith(html);
|
||||
html.find('.timeago').timeago();
|
||||
@@ -143,10 +143,10 @@ define('forum/topic/events', [
|
||||
});
|
||||
|
||||
if (data.topic.tags && tagsUpdated(data.topic.tags)) {
|
||||
templates.parse('partials/post_bar', 'tags', {tags: data.topic.tags}, function(html) {
|
||||
templates.parse('partials/post_bar', 'tags', {tags: data.topic.tags}, function (html) {
|
||||
var tags = $('.tags');
|
||||
|
||||
tags.fadeOut(250, function() {
|
||||
tags.fadeOut(250, function () {
|
||||
tags.html(html).fadeIn(250);
|
||||
});
|
||||
});
|
||||
@@ -158,7 +158,7 @@ define('forum/topic/events', [
|
||||
return true;
|
||||
}
|
||||
|
||||
for (var i=0; i<tags.length; ++i) {
|
||||
for (var i = 0; i < tags.length; ++i) {
|
||||
if (!$('.tags .tag-item[data-tag="' + tags[i].value + '"]').length) {
|
||||
return true;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ define('forum/topic/events', [
|
||||
}
|
||||
|
||||
function onPostPurged(pid) {
|
||||
components.get('post', 'pid', pid).fadeOut(500, function() {
|
||||
components.get('post', 'pid', pid).fadeOut(500, function () {
|
||||
$(this).remove();
|
||||
ajaxify.data.postcount --;
|
||||
postTools.updatePostCount(ajaxify.data.postcount);
|
||||
|
||||
@@ -2,27 +2,27 @@
|
||||
|
||||
/* globals define, app, socket, templates */
|
||||
|
||||
define('forum/topic/flag', [], function() {
|
||||
define('forum/topic/flag', [], function () {
|
||||
|
||||
var Flag = {},
|
||||
flagModal,
|
||||
flagCommit;
|
||||
|
||||
Flag.showFlagModal = function(pid) {
|
||||
parseModal(function(html) {
|
||||
Flag.showFlagModal = function (pid) {
|
||||
parseModal(function (html) {
|
||||
flagModal = $(html);
|
||||
|
||||
flagModal.on('hidden.bs.modal', function() {
|
||||
flagModal.on('hidden.bs.modal', function () {
|
||||
flagModal.remove();
|
||||
});
|
||||
|
||||
flagCommit = flagModal.find('#flag-post-commit');
|
||||
|
||||
flagModal.on('click', '.flag-reason', function() {
|
||||
flagModal.on('click', '.flag-reason', function () {
|
||||
flagPost(pid, $(this).text());
|
||||
});
|
||||
|
||||
flagCommit.on('click', function() {
|
||||
flagCommit.on('click', function () {
|
||||
flagPost(pid, flagModal.find('#flag-reason-custom').val());
|
||||
});
|
||||
|
||||
@@ -33,8 +33,8 @@ define('forum/topic/flag', [], function() {
|
||||
};
|
||||
|
||||
function parseModal(callback) {
|
||||
templates.parse('partials/modals/flag_post_modal', {}, function(html) {
|
||||
require(['translator'], function(translator) {
|
||||
templates.parse('partials/modals/flag_post_modal', {}, function (html) {
|
||||
require(['translator'], function (translator) {
|
||||
translator.translate(html, callback);
|
||||
});
|
||||
});
|
||||
@@ -44,7 +44,7 @@ define('forum/topic/flag', [], function() {
|
||||
if (!pid || !reason) {
|
||||
return;
|
||||
}
|
||||
socket.emit('posts.flag', {pid: pid, reason: reason}, function(err) {
|
||||
socket.emit('posts.flag', {pid: pid, reason: reason}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
/* globals define, app, ajaxify, socket */
|
||||
|
||||
define('forum/topic/fork', ['components', 'postSelect'], function(components, postSelect) {
|
||||
define('forum/topic/fork', ['components', 'postSelect'], function (components, postSelect) {
|
||||
|
||||
var Fork = {};
|
||||
var forkModal;
|
||||
var forkCommit;
|
||||
|
||||
Fork.init = function() {
|
||||
Fork.init = function () {
|
||||
$('.topic').on('click', '[component="topic/fork"]', onForkThreadClicked);
|
||||
$(window).on('action:ajaxify.start', onAjaxifyStart);
|
||||
};
|
||||
@@ -19,7 +19,7 @@ define('forum/topic/fork', ['components', 'postSelect'], function(components, po
|
||||
}
|
||||
|
||||
function onForkThreadClicked() {
|
||||
app.parseAndTranslate('partials/fork_thread_modal', {}, function(html) {
|
||||
app.parseAndTranslate('partials/fork_thread_modal', {}, function (html) {
|
||||
forkModal = html;
|
||||
|
||||
forkCommit = forkModal.find('#fork_thread_commit');
|
||||
@@ -29,7 +29,7 @@ define('forum/topic/fork', ['components', 'postSelect'], function(components, po
|
||||
forkModal.find('.close,#fork_thread_cancel').on('click', closeForkModal);
|
||||
forkModal.find('#fork-title').on('keyup', checkForkButtonEnable);
|
||||
|
||||
postSelect.init(function() {
|
||||
postSelect.init(function () {
|
||||
checkForkButtonEnable();
|
||||
showPostsSelected();
|
||||
});
|
||||
@@ -45,9 +45,9 @@ define('forum/topic/fork', ['components', 'postSelect'], function(components, po
|
||||
title: forkModal.find('#fork-title').val(),
|
||||
pids: postSelect.pids,
|
||||
fromTid: ajaxify.data.tid
|
||||
}, function(err, newTopic) {
|
||||
}, function (err, newTopic) {
|
||||
function fadeOutAndRemove(pid) {
|
||||
components.get('post', 'pid', pid).fadeOut(500, function() {
|
||||
components.get('post', 'pid', pid).fadeOut(500, function () {
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
@@ -61,12 +61,12 @@ define('forum/topic/fork', ['components', 'postSelect'], function(components, po
|
||||
title: '[[global:alert.success]]',
|
||||
message: '[[topic:fork_success]]',
|
||||
type: 'success',
|
||||
clickfn: function() {
|
||||
clickfn: function () {
|
||||
ajaxify.go('topic/' + newTopic.slug);
|
||||
}
|
||||
});
|
||||
|
||||
postSelect.pids.forEach(function(pid) {
|
||||
postSelect.pids.forEach(function (pid) {
|
||||
fadeOutAndRemove(pid);
|
||||
});
|
||||
|
||||
@@ -91,7 +91,7 @@ define('forum/topic/fork', ['components', 'postSelect'], function(components, po
|
||||
}
|
||||
|
||||
function closeForkModal() {
|
||||
postSelect.pids.forEach(function(pid) {
|
||||
postSelect.pids.forEach(function (pid) {
|
||||
components.get('post', 'pid', pid).toggleClass('bg-success', false);
|
||||
});
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
/* globals define, app, socket, templates */
|
||||
|
||||
define('forum/topic/move', function() {
|
||||
define('forum/topic/move', function () {
|
||||
|
||||
var Move = {},
|
||||
modal,
|
||||
selectedEl;
|
||||
|
||||
Move.init = function(tids, currentCid, onComplete) {
|
||||
Move.init = function (tids, currentCid, onComplete) {
|
||||
Move.tids = tids;
|
||||
Move.currentCid = currentCid;
|
||||
Move.onComplete = onComplete;
|
||||
@@ -22,9 +22,9 @@ define('forum/topic/move', function() {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
parseModal(categories, function() {
|
||||
parseModal(categories, function () {
|
||||
|
||||
modal.on('hidden.bs.modal', function() {
|
||||
modal.on('hidden.bs.modal', function () {
|
||||
modal.remove();
|
||||
});
|
||||
|
||||
@@ -34,7 +34,7 @@ define('forum/topic/move', function() {
|
||||
modal.find('.modal-header h3').translateText('[[topic:move_topics]]');
|
||||
}
|
||||
|
||||
modal.on('click', '.category-list li[data-cid]', function() {
|
||||
modal.on('click', '.category-list li[data-cid]', function () {
|
||||
selectCategory($(this));
|
||||
});
|
||||
|
||||
@@ -45,11 +45,11 @@ define('forum/topic/move', function() {
|
||||
}
|
||||
|
||||
function parseModal(categories, callback) {
|
||||
templates.parse('partials/move_thread_modal', {categories: []}, function(html) {
|
||||
require(['translator'], function(translator) {
|
||||
translator.translate(html, function(html) {
|
||||
templates.parse('partials/move_thread_modal', {categories: []}, function (html) {
|
||||
require(['translator'], function (translator) {
|
||||
translator.translate(html, function (html) {
|
||||
modal = $(html);
|
||||
categories.forEach(function(category) {
|
||||
categories.forEach(function (category) {
|
||||
if (!category.link) {
|
||||
buildRecursive(modal.find('.category-list'), category, '');
|
||||
}
|
||||
@@ -80,7 +80,7 @@ define('forum/topic/move', function() {
|
||||
parentEl.append('<br/>');
|
||||
|
||||
var indent = ' ';
|
||||
category.children.forEach(function(childCategory) {
|
||||
category.children.forEach(function (childCategory) {
|
||||
if (!childCategory.link) {
|
||||
buildRecursive(parentEl, childCategory, indent + level);
|
||||
}
|
||||
@@ -110,7 +110,7 @@ define('forum/topic/move', function() {
|
||||
tids: Move.tids,
|
||||
cid: selectedEl.attr('data-cid'),
|
||||
currentCid: Move.currentCid
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
modal.modal('hide');
|
||||
|
||||
if (err) {
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
/* globals define, app, ajaxify, bootbox, socket, templates, utils, config */
|
||||
|
||||
define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator'], function(share, navigator, components, translator) {
|
||||
define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator'], function (share, navigator, components, translator) {
|
||||
|
||||
var PostTools = {};
|
||||
|
||||
var staleReplyAnyway = false;
|
||||
|
||||
PostTools.init = function(tid) {
|
||||
PostTools.init = function (tid) {
|
||||
staleReplyAnyway = false;
|
||||
|
||||
renderMenu();
|
||||
@@ -23,7 +23,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
};
|
||||
|
||||
function renderMenu() {
|
||||
$('[component="topic"]').on('show.bs.dropdown', '.moderator-tools', function() {
|
||||
$('[component="topic"]').on('show.bs.dropdown', '.moderator-tools', function () {
|
||||
var $this = $(this);
|
||||
var dropdownMenu = $this.find('.dropdown-menu');
|
||||
if (dropdownMenu.html()) {
|
||||
@@ -33,14 +33,14 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
var pid = postEl.attr('data-pid');
|
||||
var index = parseInt(postEl.attr('data-index'), 10);
|
||||
|
||||
socket.emit('posts.loadPostTools', {pid: pid, cid: ajaxify.data.cid}, function(err, data) {
|
||||
socket.emit('posts.loadPostTools', {pid: pid, cid: ajaxify.data.cid}, function (err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
data.posts.display_move_tools = data.posts.display_move_tools && index !== 0;
|
||||
|
||||
templates.parse('partials/topic/post-menu-list', data, function(html) {
|
||||
translator.translate(html, function(html) {
|
||||
templates.parse('partials/topic/post-menu-list', data, function (html) {
|
||||
translator.translate(html, function (html) {
|
||||
dropdownMenu.html(html);
|
||||
$(window).trigger('action:post.tools.load');
|
||||
});
|
||||
@@ -49,7 +49,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
});
|
||||
}
|
||||
|
||||
PostTools.toggle = function(pid, isDeleted) {
|
||||
PostTools.toggle = function (pid, isDeleted) {
|
||||
var postEl = components.get('post', 'pid', pid);
|
||||
|
||||
postEl.find('[component="post/quote"], [component="post/bookmark"], [component="post/reply"], [component="post/flag"], [component="user/chat"]')
|
||||
@@ -62,7 +62,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
postEl.find('[component="post/tools"] .dropdown-menu').html('');
|
||||
};
|
||||
|
||||
PostTools.updatePostCount = function(postCount) {
|
||||
PostTools.updatePostCount = function (postCount) {
|
||||
var postCountEl = components.get('topic/post-count');
|
||||
postCountEl.html(postCount).attr('title', postCount);
|
||||
utils.makeNumbersHumanReadable(postCountEl);
|
||||
@@ -71,9 +71,9 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
|
||||
function addVoteHandler() {
|
||||
components.get('topic').on('mouseenter', '[data-pid] [component="post/vote-count"]', loadDataAndCreateTooltip);
|
||||
components.get('topic').on('mouseout', '[data-pid] [component="post/vote-count"]', function() {
|
||||
components.get('topic').on('mouseout', '[data-pid] [component="post/vote-count"]', function () {
|
||||
var el = $(this).parent();
|
||||
el.on('shown.bs.tooltip', function() {
|
||||
el.on('shown.bs.tooltip', function () {
|
||||
$('.tooltip').tooltip('destroy');
|
||||
el.off('shown.bs.tooltip');
|
||||
});
|
||||
@@ -92,7 +92,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
$('.tooltip').tooltip('destroy');
|
||||
$this.off('mouseenter', loadDataAndCreateTooltip);
|
||||
|
||||
socket.emit('posts.getUpvoters', [pid], function(err, data) {
|
||||
socket.emit('posts.getUpvoters', [pid], function (err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -115,7 +115,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
}
|
||||
if (usernames.length + data.otherCount > 6) {
|
||||
usernames = usernames.join(', ').replace(/,/g, '|');
|
||||
translator.translate('[[topic:users_and_others, ' + usernames + ', ' + data.otherCount + ']]', function(translated) {
|
||||
translator.translate('[[topic:users_and_others, ' + usernames + ', ' + data.otherCount + ']]', function (translated) {
|
||||
translated = translated.replace(/\|/g, ',');
|
||||
doCreateTooltip(translated);
|
||||
});
|
||||
@@ -128,20 +128,20 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
function addPostHandlers(tid) {
|
||||
var postContainer = components.get('topic');
|
||||
|
||||
postContainer.on('click', '[component="post/quote"]', function() {
|
||||
postContainer.on('click', '[component="post/quote"]', function () {
|
||||
onQuoteClicked($(this), tid);
|
||||
});
|
||||
|
||||
postContainer.on('click', '[component="post/reply"]', function() {
|
||||
postContainer.on('click', '[component="post/reply"]', function () {
|
||||
onReplyClicked($(this), tid);
|
||||
});
|
||||
|
||||
$('.topic').on('click', '[component="topic/reply"]', function() {
|
||||
$('.topic').on('click', '[component="topic/reply"]', function () {
|
||||
onReplyClicked($(this), tid);
|
||||
});
|
||||
|
||||
$('.topic').on('click', '[component="topic/reply-as-topic"]', function() {
|
||||
translator.translate('[[topic:link_back, ' + ajaxify.data.titleRaw + ', ' + config.relative_path + '/topic/' + ajaxify.data.slug + ']]', function(body) {
|
||||
$('.topic').on('click', '[component="topic/reply-as-topic"]', function () {
|
||||
translator.translate('[[topic:link_back, ' + ajaxify.data.titleRaw + ', ' + config.relative_path + '/topic/' + ajaxify.data.slug + ']]', function (body) {
|
||||
$(window).trigger('action:composer.topic.new', {
|
||||
cid: ajaxify.data.cid,
|
||||
body: body
|
||||
@@ -149,30 +149,30 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
});
|
||||
});
|
||||
|
||||
postContainer.on('click', '[component="post/bookmark"]', function() {
|
||||
postContainer.on('click', '[component="post/bookmark"]', function () {
|
||||
bookmarkPost($(this), getData($(this), 'data-pid'));
|
||||
});
|
||||
|
||||
postContainer.on('click', '[component="post/upvote"]', function() {
|
||||
postContainer.on('click', '[component="post/upvote"]', function () {
|
||||
return toggleVote($(this), '.upvoted', 'posts.upvote');
|
||||
});
|
||||
|
||||
postContainer.on('click', '[component="post/downvote"]', function() {
|
||||
postContainer.on('click', '[component="post/downvote"]', function () {
|
||||
return toggleVote($(this), '.downvoted', 'posts.downvote');
|
||||
});
|
||||
|
||||
postContainer.on('click', '[component="post/vote-count"]', function() {
|
||||
postContainer.on('click', '[component="post/vote-count"]', function () {
|
||||
showVotes(getData($(this), 'data-pid'));
|
||||
});
|
||||
|
||||
postContainer.on('click', '[component="post/flag"]', function() {
|
||||
postContainer.on('click', '[component="post/flag"]', function () {
|
||||
var pid = getData($(this), 'data-pid');
|
||||
require(['forum/topic/flag'], function(flag) {
|
||||
require(['forum/topic/flag'], function (flag) {
|
||||
flag.showFlagModal(pid);
|
||||
});
|
||||
});
|
||||
|
||||
postContainer.on('click', '[component="post/edit"]', function() {
|
||||
postContainer.on('click', '[component="post/edit"]', function () {
|
||||
var btn = $(this);
|
||||
|
||||
var timestamp = parseInt(getData(btn, 'data-timestamp'), 10);
|
||||
@@ -185,7 +185,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
}
|
||||
});
|
||||
|
||||
postContainer.on('click', '[component="post/delete"]', function() {
|
||||
postContainer.on('click', '[component="post/delete"]', function () {
|
||||
var btn = $(this);
|
||||
var timestamp = parseInt(getData(btn, 'data-timestamp'), 10);
|
||||
var postDeleteDuration = parseInt(ajaxify.data.postDeleteDuration, 10);
|
||||
@@ -226,19 +226,19 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
return true;
|
||||
}
|
||||
|
||||
postContainer.on('click', '[component="post/restore"]', function() {
|
||||
postContainer.on('click', '[component="post/restore"]', function () {
|
||||
togglePostDelete($(this), tid);
|
||||
});
|
||||
|
||||
postContainer.on('click', '[component="post/purge"]', function() {
|
||||
postContainer.on('click', '[component="post/purge"]', function () {
|
||||
purgePost($(this), tid);
|
||||
});
|
||||
|
||||
postContainer.on('click', '[component="post/move"]', function() {
|
||||
postContainer.on('click', '[component="post/move"]', function () {
|
||||
openMovePostModal($(this));
|
||||
});
|
||||
|
||||
postContainer.on('click', '[component="post/chat"]', function() {
|
||||
postContainer.on('click', '[component="post/chat"]', function () {
|
||||
openChat($(this));
|
||||
});
|
||||
}
|
||||
@@ -246,7 +246,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
function onReplyClicked(button, tid) {
|
||||
var selectedText = getSelectedText(button);
|
||||
|
||||
showStaleWarning(function() {
|
||||
showStaleWarning(function () {
|
||||
var username = getUserName(button);
|
||||
if (getData(button, 'data-uid') === '0' || !getData(button, 'data-userslug')) {
|
||||
username = '';
|
||||
@@ -278,7 +278,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
function onQuoteClicked(button, tid) {
|
||||
var selectedText = getSelectedText(button);
|
||||
|
||||
showStaleWarning(function() {
|
||||
showStaleWarning(function () {
|
||||
|
||||
function quote(text) {
|
||||
$(window).trigger('action:composer.addQuote', {
|
||||
@@ -298,7 +298,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
if (selectedText) {
|
||||
return quote(selectedText);
|
||||
}
|
||||
socket.emit('posts.getRawPost', pid, function(err, post) {
|
||||
socket.emit('posts.getRawPost', pid, function (err, post) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -336,7 +336,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
socket.emit(method, {
|
||||
pid: pid,
|
||||
room_id: app.currentRoom
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
app.alertError(err.message);
|
||||
}
|
||||
@@ -352,7 +352,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
socket.emit(currentState ? 'posts.unvote' : method , {
|
||||
pid: post.attr('data-pid'),
|
||||
room_id: app.currentRoom
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
if (err.message === 'self-vote') {
|
||||
showVotes(post.attr('data-pid'));
|
||||
@@ -366,7 +366,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
}
|
||||
|
||||
function showVotes(pid) {
|
||||
socket.emit('posts.getVoters', {pid: pid, cid: ajaxify.data.cid}, function(err, data) {
|
||||
socket.emit('posts.getVoters', {pid: pid, cid: ajaxify.data.cid}, function (err, data) {
|
||||
if (err) {
|
||||
if (err.message === '[[error:no-privileges]]') {
|
||||
return;
|
||||
@@ -376,8 +376,8 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
templates.parse('partials/modals/votes_modal', data, function(html) {
|
||||
translator.translate(html, function(translated) {
|
||||
templates.parse('partials/modals/votes_modal', data, function (html) {
|
||||
translator.translate(html, function (translated) {
|
||||
var dialog = bootbox.dialog({
|
||||
title: 'Voters',
|
||||
message: translated,
|
||||
@@ -385,7 +385,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
show: true
|
||||
});
|
||||
|
||||
dialog.on('click', function() {
|
||||
dialog.on('click', function () {
|
||||
dialog.modal('hide');
|
||||
});
|
||||
|
||||
@@ -429,8 +429,8 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
}
|
||||
|
||||
function postAction(action, pid, tid) {
|
||||
translator.translate('[[topic:post_' + action + '_confirm]]', function(msg) {
|
||||
bootbox.confirm(msg, function(confirm) {
|
||||
translator.translate('[[topic:post_' + action + '_confirm]]', function (msg) {
|
||||
bootbox.confirm(msg, function (confirm) {
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
@@ -438,7 +438,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
socket.emit('posts.' + action, {
|
||||
pid: pid,
|
||||
tid: tid
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
app.alertError(err.message);
|
||||
}
|
||||
@@ -448,28 +448,28 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
}
|
||||
|
||||
function openMovePostModal(button) {
|
||||
parseMoveModal(function(html) {
|
||||
parseMoveModal(function (html) {
|
||||
var moveModal = $(html);
|
||||
|
||||
var moveBtn = moveModal.find('#move_post_commit'),
|
||||
topicId = moveModal.find('#topicId');
|
||||
|
||||
moveModal.on('hidden.bs.modal', function() {
|
||||
moveModal.on('hidden.bs.modal', function () {
|
||||
moveModal.remove();
|
||||
});
|
||||
|
||||
showMoveModal(moveModal);
|
||||
|
||||
moveModal.find('.close, #move_post_cancel').on('click', function() {
|
||||
moveModal.find('.close, #move_post_cancel').on('click', function () {
|
||||
moveModal.addClass('hide');
|
||||
});
|
||||
|
||||
topicId.on('keyup change', function() {
|
||||
topicId.on('keyup change', function () {
|
||||
moveBtn.attr('disabled', !topicId.val());
|
||||
});
|
||||
|
||||
moveBtn.on('click', function() {
|
||||
movePost(button.parents('[data-pid]'), getData(button, 'data-pid'), topicId.val(), function() {
|
||||
moveBtn.on('click', function () {
|
||||
movePost(button.parents('[data-pid]'), getData(button, 'data-pid'), topicId.val(), function () {
|
||||
moveModal.modal('hide');
|
||||
topicId.val('');
|
||||
});
|
||||
@@ -479,7 +479,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
}
|
||||
|
||||
function parseMoveModal(callback) {
|
||||
templates.parse('partials/move_post_modal', {}, function(html) {
|
||||
templates.parse('partials/move_post_modal', {}, function (html) {
|
||||
translator.translate(html, callback);
|
||||
});
|
||||
}
|
||||
@@ -493,13 +493,13 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
}
|
||||
|
||||
function movePost(post, pid, tid, callback) {
|
||||
socket.emit('posts.movePost', {pid: pid, tid: tid}, function(err) {
|
||||
socket.emit('posts.movePost', {pid: pid, tid: tid}, function (err) {
|
||||
if (err) {
|
||||
app.alertError(err.message);
|
||||
return callback();
|
||||
}
|
||||
|
||||
post.fadeOut(500, function() {
|
||||
post.fadeOut(500, function () {
|
||||
post.remove();
|
||||
});
|
||||
|
||||
@@ -521,7 +521,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
return callback();
|
||||
}
|
||||
|
||||
translator.translate('[[topic:stale.warning]]', function(translated) {
|
||||
translator.translate('[[topic:stale.warning]]', function (translated) {
|
||||
var warning = bootbox.dialog({
|
||||
title: '[[topic:stale.title]]',
|
||||
message: translated,
|
||||
@@ -529,7 +529,7 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
reply: {
|
||||
label: '[[topic:stale.reply_anyway]]',
|
||||
className: 'btn-link',
|
||||
callback: function() {
|
||||
callback: function () {
|
||||
staleReplyAnyway = true;
|
||||
callback();
|
||||
}
|
||||
@@ -537,8 +537,8 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
||||
create: {
|
||||
label: '[[topic:stale.create]]',
|
||||
className: 'btn-primary',
|
||||
callback: function() {
|
||||
translator.translate('[[topic:link_back, ' + ajaxify.data.title + ', ' + config.relative_path + '/topic/' + ajaxify.data.slug + ']]', function(body) {
|
||||
callback: function () {
|
||||
translator.translate('[[topic:link_back, ' + ajaxify.data.title + ', ' + config.relative_path + '/topic/' + ajaxify.data.slug + ']]', function (body) {
|
||||
$(window).trigger('action:composer.topic.new', {
|
||||
cid: ajaxify.data.cid,
|
||||
body: body
|
||||
|
||||
@@ -8,13 +8,13 @@ define('forum/topic/posts', [
|
||||
'forum/topic/postTools',
|
||||
'navigator',
|
||||
'components'
|
||||
], function(pagination, infinitescroll, postTools, navigator, components) {
|
||||
], function (pagination, infinitescroll, postTools, navigator, components) {
|
||||
|
||||
var Posts = {
|
||||
_imageLoaderTimeout: undefined
|
||||
};
|
||||
|
||||
Posts.onNewPost = function(data) {
|
||||
Posts.onNewPost = function (data) {
|
||||
if (!data || !data.posts || !data.posts.length) {
|
||||
return;
|
||||
}
|
||||
@@ -25,7 +25,7 @@ define('forum/topic/posts', [
|
||||
|
||||
data.loggedIn = app.user.uid ? true : false;
|
||||
data.privileges = ajaxify.data.privileges;
|
||||
data.posts.forEach(function(post) {
|
||||
data.posts.forEach(function (post) {
|
||||
post.selfPost = !!app.user.uid && parseInt(post.uid, 10) === parseInt(app.user.uid, 10);
|
||||
post.display_edit_tools = (ajaxify.data.privileges['posts:edit'] && post.selfPost) || ajaxify.data.privileges.isAdminOrMod;
|
||||
post.display_delete_tools = (ajaxify.data.privileges['posts:delete'] && post.selfPost) || ajaxify.data.privileges.isAdminOrMod;
|
||||
@@ -47,7 +47,7 @@ define('forum/topic/posts', [
|
||||
};
|
||||
|
||||
function updatePostCounts(posts) {
|
||||
for (var i=0; i<posts.length; ++i) {
|
||||
for (var i = 0; i < posts.length; ++i) {
|
||||
var cmp = components.get('user/postcount', posts[i].uid);
|
||||
cmp.html(parseInt(cmp.attr('data-postcount'), 10) + 1);
|
||||
utils.addCommasToNumbers(cmp);
|
||||
@@ -72,7 +72,7 @@ define('forum/topic/posts', [
|
||||
createNewPosts(data, components.get('post').not('[data-index=0]'), direction, scrollToPost);
|
||||
} else if (ajaxify.data.scrollToMyPost && parseInt(posts[0].uid, 10) === parseInt(app.user.uid, 10)) {
|
||||
// https://github.com/NodeBB/NodeBB/issues/5004#issuecomment-247157441
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
pagination.loadPage(ajaxify.data.pagination.pageCount, scrollToPost);
|
||||
}, 250);
|
||||
} else {
|
||||
@@ -81,8 +81,8 @@ define('forum/topic/posts', [
|
||||
}
|
||||
|
||||
function updatePagination() {
|
||||
$.get(config.relative_path + '/api/topic/pagination/' + ajaxify.data.tid, {page: ajaxify.data.pagination.currentPage}, function(paginationData) {
|
||||
app.parseAndTranslate('partials/paginator', {pagination: paginationData}, function(html) {
|
||||
$.get(config.relative_path + '/api/topic/pagination/' + ajaxify.data.tid, {page: ajaxify.data.pagination.currentPage}, function (paginationData) {
|
||||
app.parseAndTranslate('partials/paginator', {pagination: paginationData}, function (html) {
|
||||
$('[component="pagination"]').after(html).remove();
|
||||
});
|
||||
});
|
||||
@@ -91,7 +91,7 @@ define('forum/topic/posts', [
|
||||
function onNewPostInfiniteScroll(data) {
|
||||
var direction = config.topicPostSort === 'oldest_to_newest' || config.topicPostSort === 'most_votes' ? 1 : -1;
|
||||
|
||||
createNewPosts(data, components.get('post').not('[data-index=0]'), direction, function(html) {
|
||||
createNewPosts(data, components.get('post').not('[data-index=0]'), direction, function (html) {
|
||||
if (html) {
|
||||
html.addClass('new');
|
||||
}
|
||||
@@ -111,7 +111,7 @@ define('forum/topic/posts', [
|
||||
}
|
||||
|
||||
function createNewPosts(data, repliesSelector, direction, callback) {
|
||||
callback = callback || function() {};
|
||||
callback = callback || function () {};
|
||||
if (!data || (data.posts && !data.posts.length)) {
|
||||
return callback();
|
||||
}
|
||||
@@ -121,14 +121,14 @@ define('forum/topic/posts', [
|
||||
|
||||
if (newPosts.length === data.posts.length) {
|
||||
var allSamePids = true;
|
||||
newPosts.each(function(index, el) {
|
||||
newPosts.each(function (index, el) {
|
||||
if (parseInt($(el).attr('data-pid'), 10) !== parseInt(data.posts[index].pid, 10)) {
|
||||
allSamePids = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (allSamePids) {
|
||||
newPosts.each(function() {
|
||||
newPosts.each(function () {
|
||||
$(this).removeClass('new');
|
||||
});
|
||||
data.posts.length = 0;
|
||||
@@ -137,7 +137,7 @@ define('forum/topic/posts', [
|
||||
}
|
||||
|
||||
if (newPosts.length && data.posts.length > 1) {
|
||||
data.posts.forEach(function(post) {
|
||||
data.posts.forEach(function (post) {
|
||||
var p = components.get('post', 'pid', post.pid);
|
||||
if (p.hasClass('new')) {
|
||||
p.remove();
|
||||
@@ -145,7 +145,7 @@ define('forum/topic/posts', [
|
||||
});
|
||||
}
|
||||
|
||||
data.posts = data.posts.filter(function(post) {
|
||||
data.posts = data.posts.filter(function (post) {
|
||||
return $('[component="post"][data-pid="' + post.pid + '"]').length === 0;
|
||||
});
|
||||
}
|
||||
@@ -168,9 +168,9 @@ define('forum/topic/posts', [
|
||||
|
||||
$(window).trigger('action:posts.loading', {posts: data.posts, after: after, before: before});
|
||||
|
||||
app.parseAndTranslate('topic', 'posts', data, function(html) {
|
||||
app.parseAndTranslate('topic', 'posts', data, function (html) {
|
||||
|
||||
html = html.filter(function() {
|
||||
html = html.filter(function () {
|
||||
var pid = $(this).attr('data-pid');
|
||||
return pid && $('[component="post"][data-pid="' + pid + '"]').length === 0;
|
||||
});
|
||||
@@ -200,12 +200,12 @@ define('forum/topic/posts', [
|
||||
});
|
||||
}
|
||||
|
||||
Posts.loadMorePosts = function(direction) {
|
||||
Posts.loadMorePosts = function (direction) {
|
||||
if (!components.get('topic').length || navigator.scrollActive || Posts._infiniteScrollTimeout) {
|
||||
return;
|
||||
}
|
||||
|
||||
Posts._infiniteScrollTimeout = setTimeout(function() {
|
||||
Posts._infiniteScrollTimeout = setTimeout(function () {
|
||||
delete Posts._infiniteScrollTimeout;
|
||||
}, 1000);
|
||||
var replies = components.get('post').not('[data-index=0]').not('.new');
|
||||
@@ -239,7 +239,7 @@ define('forum/topic/posts', [
|
||||
});
|
||||
};
|
||||
|
||||
Posts.processPage = function(posts) {
|
||||
Posts.processPage = function (posts) {
|
||||
Posts.unloadImages(posts);
|
||||
Posts.showBottomPostBar();
|
||||
posts.find('[component="post/content"] img:not(.not-responsive)').addClass('img-responsive');
|
||||
@@ -253,11 +253,11 @@ define('forum/topic/posts', [
|
||||
hidePostToolsForDeletedPosts(posts);
|
||||
};
|
||||
|
||||
Posts.unloadImages = function(posts) {
|
||||
Posts.unloadImages = function (posts) {
|
||||
var images = posts.find('[component="post/content"] img:not(.not-responsive)');
|
||||
|
||||
if (config.delayImageLoading) {
|
||||
images.each(function() {
|
||||
images.each(function () {
|
||||
$(this).attr('data-src', $(this).attr('src'));
|
||||
}).attr('data-state', 'unloaded').attr('src', 'about:blank');
|
||||
} else {
|
||||
@@ -266,12 +266,12 @@ define('forum/topic/posts', [
|
||||
}
|
||||
};
|
||||
|
||||
Posts.loadImages = function(threshold) {
|
||||
Posts.loadImages = function (threshold) {
|
||||
if (Posts._imageLoaderTimeout) {
|
||||
clearTimeout(Posts._imageLoaderTimeout);
|
||||
}
|
||||
|
||||
Posts._imageLoaderTimeout = setTimeout(function() {
|
||||
Posts._imageLoaderTimeout = setTimeout(function () {
|
||||
/*
|
||||
If threshold is defined, images loaded above this threshold will modify
|
||||
the user's scroll position so they are not scrolled away from content
|
||||
@@ -282,16 +282,16 @@ define('forum/topic/posts', [
|
||||
*/
|
||||
|
||||
var images = components.get('post/content').find('img[data-state="unloaded"]'),
|
||||
visible = images.filter(function() {
|
||||
visible = images.filter(function () {
|
||||
return utils.isElementInViewport(this);
|
||||
}),
|
||||
posts = $.unique(visible.map(function() {
|
||||
posts = $.unique(visible.map(function () {
|
||||
return $(this).parents('[component="post"]').get(0);
|
||||
})),
|
||||
scrollTop = $(window).scrollTop(),
|
||||
adjusting = false,
|
||||
adjustQueue = [],
|
||||
adjustPosition = function() {
|
||||
adjustPosition = function () {
|
||||
adjusting = true;
|
||||
oldHeight = document.body.clientHeight;
|
||||
|
||||
@@ -318,10 +318,10 @@ define('forum/topic/posts', [
|
||||
|
||||
// For each image, reset the source and adjust scrollTop when loaded
|
||||
visible.attr('data-state', 'loading');
|
||||
visible.each(function(index, image) {
|
||||
visible.each(function (index, image) {
|
||||
image = $(image);
|
||||
|
||||
image.on('load', function() {
|
||||
image.on('load', function () {
|
||||
if (!adjusting) {
|
||||
adjustPosition.call(this);
|
||||
} else {
|
||||
@@ -335,8 +335,8 @@ define('forum/topic/posts', [
|
||||
}, 250);
|
||||
};
|
||||
|
||||
Posts.wrapImagesInLinks = function(posts) {
|
||||
posts.find('[component="post/content"] img:not(.emoji)').each(function() {
|
||||
Posts.wrapImagesInLinks = function (posts) {
|
||||
posts.find('[component="post/content"] img:not(.emoji)').each(function () {
|
||||
var $this = $(this),
|
||||
src = $this.attr('src'),
|
||||
suffixRegex = /-resized(\.[\w]+)?$/;
|
||||
@@ -355,7 +355,7 @@ define('forum/topic/posts', [
|
||||
});
|
||||
};
|
||||
|
||||
Posts.showBottomPostBar = function() {
|
||||
Posts.showBottomPostBar = function () {
|
||||
var mainPost = components.get('post', 'index', 0);
|
||||
var placeHolder = $('.post-bar-placeholder');
|
||||
var posts = $('[component="post"]');
|
||||
@@ -368,7 +368,7 @@ define('forum/topic/posts', [
|
||||
};
|
||||
|
||||
function hidePostToolsForDeletedPosts(posts) {
|
||||
posts.each(function() {
|
||||
posts.each(function () {
|
||||
if ($(this).hasClass('deleted')) {
|
||||
postTools.toggle($(this).attr('data-pid'), true);
|
||||
}
|
||||
@@ -376,7 +376,7 @@ define('forum/topic/posts', [
|
||||
}
|
||||
|
||||
function addBlockquoteEllipses(blockquotes) {
|
||||
blockquotes.each(function() {
|
||||
blockquotes.each(function () {
|
||||
var $this = $(this);
|
||||
if ($this.find(':hidden:not(br)').length && !$this.find('.toggle').length) {
|
||||
$this.append('<i class="fa fa-angle-down pointer toggle"></i>');
|
||||
|
||||
@@ -8,53 +8,53 @@ define('forum/topic/threadTools', [
|
||||
'forum/topic/delete-posts',
|
||||
'components',
|
||||
'translator'
|
||||
], function(fork, move, deletePosts, components, translator) {
|
||||
], function (fork, move, deletePosts, components, translator) {
|
||||
|
||||
var ThreadTools = {};
|
||||
|
||||
ThreadTools.init = function(tid) {
|
||||
ThreadTools.init = function (tid) {
|
||||
|
||||
renderMenu();
|
||||
|
||||
var topicContainer = $('.topic');
|
||||
|
||||
topicContainer.on('click', '[component="topic/delete"]', function() {
|
||||
topicContainer.on('click', '[component="topic/delete"]', function () {
|
||||
topicCommand('delete', tid);
|
||||
return false;
|
||||
});
|
||||
|
||||
topicContainer.on('click', '[component="topic/restore"]', function() {
|
||||
topicContainer.on('click', '[component="topic/restore"]', function () {
|
||||
topicCommand('restore', tid);
|
||||
return false;
|
||||
});
|
||||
|
||||
topicContainer.on('click', '[component="topic/purge"]', function() {
|
||||
topicContainer.on('click', '[component="topic/purge"]', function () {
|
||||
topicCommand('purge', tid);
|
||||
return false;
|
||||
});
|
||||
|
||||
topicContainer.on('click', '[component="topic/lock"]', function() {
|
||||
topicContainer.on('click', '[component="topic/lock"]', function () {
|
||||
socket.emit('topics.lock', {tids: [tid], cid: ajaxify.data.cid});
|
||||
return false;
|
||||
});
|
||||
|
||||
topicContainer.on('click', '[component="topic/unlock"]', function() {
|
||||
topicContainer.on('click', '[component="topic/unlock"]', function () {
|
||||
socket.emit('topics.unlock', {tids: [tid], cid: ajaxify.data.cid});
|
||||
return false;
|
||||
});
|
||||
|
||||
topicContainer.on('click', '[component="topic/pin"]', function() {
|
||||
topicContainer.on('click', '[component="topic/pin"]', function () {
|
||||
socket.emit('topics.pin', {tids: [tid], cid: ajaxify.data.cid});
|
||||
return false;
|
||||
});
|
||||
|
||||
topicContainer.on('click', '[component="topic/unpin"]', function() {
|
||||
topicContainer.on('click', '[component="topic/unpin"]', function () {
|
||||
socket.emit('topics.unpin', {tids: [tid], cid: ajaxify.data.cid});
|
||||
return false;
|
||||
});
|
||||
|
||||
topicContainer.on('click', '[component="topic/mark-unread"]', function() {
|
||||
socket.emit('topics.markUnread', tid, function(err) {
|
||||
topicContainer.on('click', '[component="topic/mark-unread"]', function () {
|
||||
socket.emit('topics.markUnread', tid, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
@@ -63,9 +63,9 @@ define('forum/topic/threadTools', [
|
||||
return false;
|
||||
});
|
||||
|
||||
topicContainer.on('click', '[component="topic/mark-unread-for-all"]', function() {
|
||||
topicContainer.on('click', '[component="topic/mark-unread-for-all"]', function () {
|
||||
var btn = $(this);
|
||||
socket.emit('topics.markAsUnreadForAll', [tid], function(err) {
|
||||
socket.emit('topics.markAsUnreadForAll', [tid], function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -75,7 +75,7 @@ define('forum/topic/threadTools', [
|
||||
return false;
|
||||
});
|
||||
|
||||
topicContainer.on('click', '[component="topic/move"]', function() {
|
||||
topicContainer.on('click', '[component="topic/move"]', function () {
|
||||
move.init([tid], ajaxify.data.cid);
|
||||
return false;
|
||||
});
|
||||
@@ -83,18 +83,18 @@ define('forum/topic/threadTools', [
|
||||
deletePosts.init();
|
||||
fork.init();
|
||||
|
||||
$('.topic').on('click', '[component="topic/following"]', function() {
|
||||
$('.topic').on('click', '[component="topic/following"]', function () {
|
||||
changeWatching('follow');
|
||||
});
|
||||
$('.topic').on('click', '[component="topic/not-following"]', function() {
|
||||
$('.topic').on('click', '[component="topic/not-following"]', function () {
|
||||
changeWatching('unfollow');
|
||||
});
|
||||
$('.topic').on('click', '[component="topic/ignoring"]', function() {
|
||||
$('.topic').on('click', '[component="topic/ignoring"]', function () {
|
||||
changeWatching('ignore');
|
||||
});
|
||||
|
||||
function changeWatching(type) {
|
||||
socket.emit('topics.changeWatching', {tid: tid, type: type}, function(err) {
|
||||
socket.emit('topics.changeWatching', {tid: tid, type: type}, function (err) {
|
||||
if (err) {
|
||||
return app.alert({
|
||||
type: 'danger',
|
||||
@@ -136,13 +136,13 @@ define('forum/topic/threadTools', [
|
||||
return;
|
||||
}
|
||||
|
||||
socket.emit('topics.loadTopicTools', {tid: ajaxify.data.tid, cid: ajaxify.data.cid}, function(err, data) {
|
||||
socket.emit('topics.loadTopicTools', {tid: ajaxify.data.tid, cid: ajaxify.data.cid}, function (err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
|
||||
templates.parse('partials/topic/topic-menu-list', data, function(html) {
|
||||
translator.translate(html, function(html) {
|
||||
templates.parse('partials/topic/topic-menu-list', data, function (html) {
|
||||
translator.translate(html, function (html) {
|
||||
dropdownMenu.html(html);
|
||||
$(window).trigger('action:topic.tools.load');
|
||||
});
|
||||
@@ -152,13 +152,13 @@ define('forum/topic/threadTools', [
|
||||
}
|
||||
|
||||
function topicCommand(command, tid) {
|
||||
translator.translate('[[topic:thread_tools.' + command + '_confirm]]', function(msg) {
|
||||
bootbox.confirm(msg, function(confirm) {
|
||||
translator.translate('[[topic:thread_tools.' + command + '_confirm]]', function (msg) {
|
||||
bootbox.confirm(msg, function (confirm) {
|
||||
if (!confirm) {
|
||||
return;
|
||||
}
|
||||
|
||||
socket.emit('topics.' + command, {tids: [tid], cid: ajaxify.data.cid}, function(err) {
|
||||
socket.emit('topics.' + command, {tids: [tid], cid: ajaxify.data.cid}, function (err) {
|
||||
if (err) {
|
||||
app.alertError(err.message);
|
||||
}
|
||||
@@ -167,7 +167,7 @@ define('forum/topic/threadTools', [
|
||||
});
|
||||
}
|
||||
|
||||
ThreadTools.setLockedState = function(data) {
|
||||
ThreadTools.setLockedState = function (data) {
|
||||
var threadEl = components.get('topic');
|
||||
if (parseInt(data.tid, 10) !== parseInt(threadEl.attr('data-tid'), 10)) {
|
||||
return;
|
||||
@@ -186,14 +186,14 @@ define('forum/topic/threadTools', [
|
||||
threadEl.find('[component="post"]:not(.deleted) [component="post/reply"], [component="post"]:not(.deleted) [component="post/quote"]').toggleClass('hidden', hideReply);
|
||||
threadEl.find('[component="post/edit"], [component="post/delete"]').toggleClass('hidden', isLocked);
|
||||
|
||||
threadEl.find('[component="post"][data-uid="'+app.user.uid+'"].deleted [component="post/tools"]').toggleClass('hidden', isLocked);
|
||||
threadEl.find('[component="post"][data-uid="' + app.user.uid + '"].deleted [component="post/tools"]').toggleClass('hidden', isLocked);
|
||||
|
||||
$('[component="post/header"] i.fa-lock').toggleClass('hidden', !data.isLocked);
|
||||
$('[component="post/tools"] .dropdown-menu').html('');
|
||||
ajaxify.data.locked = data.isLocked;
|
||||
};
|
||||
|
||||
ThreadTools.setDeleteState = function(data) {
|
||||
ThreadTools.setDeleteState = function (data) {
|
||||
var threadEl = components.get('topic');
|
||||
if (parseInt(data.tid, 10) !== parseInt(threadEl.attr('data-tid'), 10)) {
|
||||
return;
|
||||
@@ -215,7 +215,7 @@ define('forum/topic/threadTools', [
|
||||
};
|
||||
|
||||
|
||||
ThreadTools.setPinnedState = function(data) {
|
||||
ThreadTools.setPinnedState = function (data) {
|
||||
var threadEl = components.get('topic');
|
||||
if (parseInt(data.tid, 10) !== parseInt(threadEl.attr('data-tid'), 10)) {
|
||||
return;
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
/* globals define, app, socket */
|
||||
|
||||
define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', 'components'], function(recent, topicSelect, infinitescroll, components) {
|
||||
define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', 'components'], function (recent, topicSelect, infinitescroll, components) {
|
||||
var Unread = {};
|
||||
|
||||
$(window).on('action:ajaxify.start', function(ev, data) {
|
||||
$(window).on('action:ajaxify.start', function (ev, data) {
|
||||
if (ajaxify.currentPage !== data.url) {
|
||||
recent.removeListeners();
|
||||
}
|
||||
});
|
||||
|
||||
Unread.init = function() {
|
||||
Unread.init = function () {
|
||||
app.enterRoom('unread_topics');
|
||||
|
||||
$('#new-topics-alert').on('click', function() {
|
||||
$('#new-topics-alert').on('click', function () {
|
||||
$(this).addClass('hide');
|
||||
});
|
||||
|
||||
@@ -22,12 +22,12 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', '
|
||||
|
||||
$(window).trigger('action:topics.loaded', {topics: ajaxify.data.topics});
|
||||
|
||||
$('#markSelectedRead').on('click', function() {
|
||||
$('#markSelectedRead').on('click', function () {
|
||||
var tids = topicSelect.getSelectedTids();
|
||||
if(!tids.length) {
|
||||
return;
|
||||
}
|
||||
socket.emit('topics.markAsRead', tids, function(err) {
|
||||
socket.emit('topics.markAsRead', tids, function (err) {
|
||||
if(err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -36,8 +36,8 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', '
|
||||
});
|
||||
});
|
||||
|
||||
$('#markAllRead').on('click', function() {
|
||||
socket.emit('topics.markAllRead', function(err) {
|
||||
$('#markAllRead').on('click', function () {
|
||||
socket.emit('topics.markAllRead', function (err) {
|
||||
if(err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -51,10 +51,10 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', '
|
||||
});
|
||||
});
|
||||
|
||||
$('.markread').on('click', '.category', function() {
|
||||
$('.markread').on('click', '.category', function () {
|
||||
function getCategoryTids(cid) {
|
||||
var tids = [];
|
||||
components.get('category/topic', 'cid', cid).each(function() {
|
||||
components.get('category/topic', 'cid', cid).each(function () {
|
||||
tids.push($(this).attr('data-tid'));
|
||||
});
|
||||
return tids;
|
||||
@@ -62,7 +62,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', '
|
||||
var cid = $(this).attr('data-cid');
|
||||
var tids = getCategoryTids(cid);
|
||||
|
||||
socket.emit('topics.markCategoryTopicsRead', cid, function(err) {
|
||||
socket.emit('topics.markCategoryTopicsRead', cid, function (err) {
|
||||
if(err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -77,7 +77,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', '
|
||||
$('#load-more-btn').show();
|
||||
}
|
||||
|
||||
$('#load-more-btn').on('click', function() {
|
||||
$('#load-more-btn').on('click', function () {
|
||||
loadMoreTopics();
|
||||
});
|
||||
|
||||
@@ -95,7 +95,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', '
|
||||
after: $('[component="category"]').attr('data-nextstart'),
|
||||
cid: cid,
|
||||
filter: ajaxify.data.selectedFilter.filter
|
||||
}, function(data, done) {
|
||||
}, function (data, done) {
|
||||
if (data.topics && data.topics.length) {
|
||||
recent.onTopicsLoaded('unread', data.topics, true, done);
|
||||
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
||||
@@ -119,7 +119,7 @@ define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', '
|
||||
}
|
||||
|
||||
function removeTids(tids) {
|
||||
for(var i=0; i<tids.length; ++i) {
|
||||
for(var i = 0; i < tids.length; ++i) {
|
||||
components.get('category/topic', 'tid', tids[i]).remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
|
||||
/* globals define, socket, app, templates, bootbox, utils */
|
||||
|
||||
define('forum/users', ['translator'], function(translator) {
|
||||
define('forum/users', ['translator'], function (translator) {
|
||||
var Users = {};
|
||||
|
||||
var searchTimeoutID = 0;
|
||||
|
||||
$(window).on('action:ajaxify.start', function() {
|
||||
$(window).on('action:ajaxify.start', function () {
|
||||
if (searchTimeoutID) {
|
||||
clearTimeout(searchTimeoutID);
|
||||
searchTimeoutID = 0;
|
||||
}
|
||||
});
|
||||
|
||||
Users.init = function() {
|
||||
Users.init = function () {
|
||||
app.enterRoom('user_list');
|
||||
|
||||
var section = utils.params().section ? ('?section=' + utils.params().section) : '';
|
||||
@@ -31,7 +31,7 @@ define('forum/users', ['translator'], function(translator) {
|
||||
function handleSearch() {
|
||||
searchTimeoutID = 0;
|
||||
|
||||
$('#search-user').on('keyup', function() {
|
||||
$('#search-user').on('keyup', function () {
|
||||
if (searchTimeoutID) {
|
||||
clearTimeout(searchTimeoutID);
|
||||
searchTimeoutID = 0;
|
||||
@@ -40,7 +40,7 @@ define('forum/users', ['translator'], function(translator) {
|
||||
searchTimeoutID = setTimeout(doSearch, 150);
|
||||
});
|
||||
|
||||
$('.search select, .search input[type="checkbox"]').on('change', function() {
|
||||
$('.search select, .search input[type="checkbox"]').on('change', function () {
|
||||
doSearch();
|
||||
});
|
||||
}
|
||||
@@ -91,7 +91,7 @@ define('forum/users', ['translator'], function(translator) {
|
||||
|
||||
function loadPage(query) {
|
||||
var qs = decodeURIComponent($.param(query));
|
||||
$.get(config.relative_path + '/api/users?' + qs, renderSearchResults).fail(function(xhrErr) {
|
||||
$.get(config.relative_path + '/api/users?' + qs, renderSearchResults).fail(function (xhrErr) {
|
||||
if (xhrErr && xhrErr.responseJSON && xhrErr.responseJSON.error) {
|
||||
app.alertError(xhrErr.responseJSON.error);
|
||||
}
|
||||
@@ -99,12 +99,12 @@ define('forum/users', ['translator'], function(translator) {
|
||||
}
|
||||
|
||||
function renderSearchResults(data) {
|
||||
templates.parse('partials/paginator', {pagination: data.pagination}, function(html) {
|
||||
templates.parse('partials/paginator', {pagination: data.pagination}, function (html) {
|
||||
$('.pagination-container').replaceWith(html);
|
||||
});
|
||||
|
||||
templates.parse('users', 'users', data, function(html) {
|
||||
translator.translate(html, function(translated) {
|
||||
templates.parse('users', 'users', data, function (html) {
|
||||
translator.translate(html, function (translated) {
|
||||
translated = $(translated);
|
||||
$('#users-container').html(translated);
|
||||
translated.find('span.timeago').timeago();
|
||||
@@ -122,7 +122,7 @@ define('forum/users', ['translator'], function(translator) {
|
||||
}
|
||||
|
||||
function updateUser(data) {
|
||||
app.updateUserStatus($('#users-container [data-uid="' + data.uid +'"] [component="user/status"]'), data.status);
|
||||
app.updateUserStatus($('#users-container [data-uid="' + data.uid + '"] [component="user/status"]'), data.status);
|
||||
}
|
||||
|
||||
function getActiveSection() {
|
||||
@@ -130,13 +130,13 @@ define('forum/users', ['translator'], function(translator) {
|
||||
}
|
||||
|
||||
function handleInvite() {
|
||||
$('[component="user/invite"]').on('click', function() {
|
||||
bootbox.prompt('Email: ', function(email) {
|
||||
$('[component="user/invite"]').on('click', function () {
|
||||
bootbox.prompt('Email: ', function (email) {
|
||||
if (!email) {
|
||||
return;
|
||||
}
|
||||
|
||||
socket.emit('user.invite', email, function(err) {
|
||||
socket.emit('user.invite', email, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
/*global utils*/
|
||||
|
||||
$('document').ready(function() {
|
||||
$('document').ready(function () {
|
||||
setupInputs();
|
||||
$('[name="username"]').focus();
|
||||
|
||||
@@ -19,7 +19,7 @@ $('document').ready(function() {
|
||||
|
||||
|
||||
function setupInputs() {
|
||||
$('form').on('focus', '.form-control', function() {
|
||||
$('form').on('focus', '.form-control', function () {
|
||||
var parent = $(this).parents('.input-row');
|
||||
|
||||
$('.input-row.active').removeClass('active');
|
||||
@@ -29,7 +29,7 @@ $('document').ready(function() {
|
||||
help.html(help.attr('data-help'));
|
||||
});
|
||||
|
||||
$('form').on('blur change', '[name]', function() {
|
||||
$('form').on('blur change', '[name]', function () {
|
||||
activate($(this).attr('name'), $(this));
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@ $('document').ready(function() {
|
||||
}
|
||||
|
||||
function validateAll(ev) {
|
||||
$('form .admin [name]').each(function() {
|
||||
$('form .admin [name]').each(function () {
|
||||
activate($(this).attr('name'), $(this));
|
||||
});
|
||||
|
||||
@@ -116,9 +116,9 @@ $('document').ready(function() {
|
||||
function launchForum() {
|
||||
$('#launch .fa-spin').removeClass('hide');
|
||||
|
||||
$.post('/launch', function() {
|
||||
setInterval(function() {
|
||||
$.get('/admin').done(function(data) {
|
||||
$.post('/launch', function () {
|
||||
setInterval(function () {
|
||||
$.get('/admin').done(function (data) {
|
||||
window.location = 'admin';
|
||||
});
|
||||
}, 750);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
/* globals define, templates */
|
||||
|
||||
define('alerts', ['translator', 'components'], function(translator, components) {
|
||||
define('alerts', ['translator', 'components'], function (translator, components) {
|
||||
var module = {};
|
||||
|
||||
module.alert = function (params) {
|
||||
@@ -19,8 +19,8 @@ define('alerts', ['translator', 'components'], function(translator, components)
|
||||
};
|
||||
|
||||
function createNew(params) {
|
||||
templates.parse('alert', params, function(alertTpl) {
|
||||
translator.translate(alertTpl, function(translatedHTML) {
|
||||
templates.parse('alert', params, function (alertTpl) {
|
||||
translator.translate(alertTpl, function (translatedHTML) {
|
||||
var alert = $('#' + params.alert_id);
|
||||
if (alert.length) {
|
||||
return updateAlert(alert, params);
|
||||
@@ -31,7 +31,7 @@ define('alerts', ['translator', 'components'], function(translator, components)
|
||||
components.get('toaster/tray').prepend(alert);
|
||||
|
||||
if(typeof params.closefn === 'function') {
|
||||
alert.find('button').on('click', function() {
|
||||
alert.find('button').on('click', function () {
|
||||
params.closefn();
|
||||
fadeOut(alert);
|
||||
return false;
|
||||
@@ -56,7 +56,7 @@ define('alerts', ['translator', 'components'], function(translator, components)
|
||||
});
|
||||
}
|
||||
|
||||
module.remove = function(id) {
|
||||
module.remove = function (id) {
|
||||
$('#alert_button_' + id).remove();
|
||||
};
|
||||
|
||||
@@ -71,7 +71,7 @@ define('alerts', ['translator', 'components'], function(translator, components)
|
||||
}
|
||||
|
||||
alert.children().fadeOut(100);
|
||||
translator.translate(alert.html(), function(translatedHTML) {
|
||||
translator.translate(alert.html(), function (translatedHTML) {
|
||||
alert.children().fadeIn(100);
|
||||
alert.html(translatedHTML);
|
||||
});
|
||||
|
||||
@@ -3,25 +3,25 @@
|
||||
|
||||
/* globals define, socket, app */
|
||||
|
||||
define('autocomplete', function() {
|
||||
define('autocomplete', function () {
|
||||
var module = {};
|
||||
|
||||
module.user = function (input, onselect) {
|
||||
app.loadJQueryUI(function() {
|
||||
app.loadJQueryUI(function () {
|
||||
input.autocomplete({
|
||||
delay: 200,
|
||||
open: function() {
|
||||
open: function () {
|
||||
$(this).autocomplete('widget').css('z-index', 20000);
|
||||
},
|
||||
select: onselect,
|
||||
source: function(request, response) {
|
||||
socket.emit('user.search', {query: request.term}, function(err, result) {
|
||||
source: function (request, response) {
|
||||
socket.emit('user.search', {query: request.term}, function (err, result) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
if (result && result.users) {
|
||||
var names = result.users.map(function(user) {
|
||||
var names = result.users.map(function (user) {
|
||||
var username = $('<div/>').html(user.username).text()
|
||||
return user && {
|
||||
label: username,
|
||||
@@ -42,21 +42,21 @@ define('autocomplete', function() {
|
||||
});
|
||||
};
|
||||
|
||||
module.group = function(input, onselect) {
|
||||
app.loadJQueryUI(function() {
|
||||
module.group = function (input, onselect) {
|
||||
app.loadJQueryUI(function () {
|
||||
input.autocomplete({
|
||||
delay: 200,
|
||||
select: onselect,
|
||||
source: function(request, response) {
|
||||
source: function (request, response) {
|
||||
socket.emit('groups.search', {
|
||||
query: request.term
|
||||
}, function(err, results) {
|
||||
}, function (err, results) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
if (results && results.length) {
|
||||
var names = results.map(function(group) {
|
||||
var names = results.map(function (group) {
|
||||
return group && {
|
||||
label: group.name,
|
||||
value: group.name,
|
||||
|
||||
@@ -9,16 +9,16 @@ define('chat', [
|
||||
'forum/chats',
|
||||
'forum/chats/messages',
|
||||
'translator'
|
||||
], function(components, taskbar, S, sounds, Chats, ChatsMessages, translator) {
|
||||
], function (components, taskbar, S, sounds, Chats, ChatsMessages, translator) {
|
||||
|
||||
var module = {};
|
||||
var newMessage = false;
|
||||
|
||||
module.prepareDOM = function() {
|
||||
module.prepareDOM = function () {
|
||||
var chatsToggleEl = components.get('chat/dropdown');
|
||||
var chatsListEl = components.get('chat/list');
|
||||
|
||||
chatsToggleEl.on('click', function() {
|
||||
chatsToggleEl.on('click', function () {
|
||||
if (chatsToggleEl.parent().hasClass('open')) {
|
||||
return;
|
||||
}
|
||||
@@ -26,7 +26,7 @@ define('chat', [
|
||||
module.loadChatsDropdown(chatsListEl);
|
||||
});
|
||||
|
||||
chatsListEl.on('click', '[data-roomid]', function(ev) {
|
||||
chatsListEl.on('click', '[data-roomid]', function (ev) {
|
||||
if ($(ev.target).parents('.user-link').length) {
|
||||
return;
|
||||
}
|
||||
@@ -38,15 +38,15 @@ define('chat', [
|
||||
}
|
||||
});
|
||||
|
||||
$('[component="chats/mark-all-read"]').on('click', function() {
|
||||
socket.emit('modules.chats.markAllRead', function(err) {
|
||||
$('[component="chats/mark-all-read"]').on('click', function () {
|
||||
socket.emit('modules.chats.markAllRead', function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('event:chats.receive', function(data) {
|
||||
socket.on('event:chats.receive', function (data) {
|
||||
var username = data.message.fromUser.username;
|
||||
var isSelf = data.self === 1;
|
||||
data.message.self = data.self;
|
||||
@@ -75,16 +75,16 @@ define('chat', [
|
||||
});
|
||||
}
|
||||
} else {
|
||||
socket.emit('modules.chats.loadRoom', {roomId: data.roomId}, function(err, roomData) {
|
||||
socket.emit('modules.chats.loadRoom', {roomId: data.roomId}, function (err, roomData) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
roomData.users = roomData.users.filter(function(user) {
|
||||
roomData.users = roomData.users.filter(function (user) {
|
||||
return user && parseInt(user.uid, 10) !== parseInt(app.user.uid, 10);
|
||||
});
|
||||
roomData.silent = true;
|
||||
roomData.uid = app.user.uid;
|
||||
module.createModal(roomData, function(modal) {
|
||||
module.createModal(roomData, function (modal) {
|
||||
module.toggleNew(modal.attr('UUID'), !isSelf, true);
|
||||
if (!isSelf) {
|
||||
app.alternatingTitle('[[modules:chat.user_has_messaged_you, ' + username + ']]');
|
||||
@@ -95,32 +95,32 @@ define('chat', [
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('event:user_status_change', function(data) {
|
||||
socket.on('event:user_status_change', function (data) {
|
||||
var modal = module.getModal(data.uid);
|
||||
app.updateUserStatus(modal.find('[component="user/status"]'), data.status);
|
||||
});
|
||||
|
||||
socket.on('event:chats.roomRename', function(data) {
|
||||
socket.on('event:chats.roomRename', function (data) {
|
||||
module.getModal(data.roomId).find('[component="chat/room/name"]').val($('<div/>').html(data.newName).text());
|
||||
});
|
||||
|
||||
ChatsMessages.onChatMessageEdit();
|
||||
};
|
||||
|
||||
module.loadChatsDropdown = function(chatsListEl) {
|
||||
socket.emit('modules.chats.getRecentChats', {uid: app.user.uid, after: 0}, function(err, data) {
|
||||
module.loadChatsDropdown = function (chatsListEl) {
|
||||
socket.emit('modules.chats.getRecentChats', {uid: app.user.uid, after: 0}, function (err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
var rooms = data.rooms.filter(function(room) {
|
||||
var rooms = data.rooms.filter(function (room) {
|
||||
return room.teaser;
|
||||
});
|
||||
|
||||
templates.parse('partials/chat_dropdown', {
|
||||
rooms: rooms
|
||||
}, function(html) {
|
||||
translator.translate(html, function(translated) {
|
||||
}, function (html) {
|
||||
translator.translate(html, function (translated) {
|
||||
chatsListEl.empty().html(translated);
|
||||
app.createUserTooltips(chatsListEl, 'right');
|
||||
});
|
||||
@@ -128,7 +128,7 @@ define('chat', [
|
||||
});
|
||||
};
|
||||
|
||||
module.bringModalToTop = function(chatModal) {
|
||||
module.bringModalToTop = function (chatModal) {
|
||||
var topZ = 0;
|
||||
|
||||
taskbar.updateActive(chatModal.attr('UUID'));
|
||||
@@ -136,7 +136,7 @@ define('chat', [
|
||||
if ($('.chat-modal').length === 1) {
|
||||
return;
|
||||
}
|
||||
$('.chat-modal').each(function() {
|
||||
$('.chat-modal').each(function () {
|
||||
var thisZ = parseInt($(this).css('zIndex'), 10);
|
||||
if (thisZ > topZ) {
|
||||
topZ = thisZ;
|
||||
@@ -146,16 +146,16 @@ define('chat', [
|
||||
chatModal.css('zIndex', topZ + 1);
|
||||
};
|
||||
|
||||
module.getModal = function(roomId) {
|
||||
module.getModal = function (roomId) {
|
||||
return $('#chat-modal-' + roomId);
|
||||
};
|
||||
|
||||
module.modalExists = function(roomId) {
|
||||
module.modalExists = function (roomId) {
|
||||
return $('#chat-modal-' + roomId).length !== 0;
|
||||
};
|
||||
|
||||
module.createModal = function(data, callback) {
|
||||
app.parseAndTranslate('chat', data, function(chatModal) {
|
||||
module.createModal = function (data, callback) {
|
||||
app.parseAndTranslate('chat', data, function (chatModal) {
|
||||
|
||||
var uuid = utils.generateUUID();
|
||||
var dragged = false;
|
||||
@@ -170,14 +170,14 @@ define('chat', [
|
||||
chatModal.find('.timeago').timeago();
|
||||
module.center(chatModal);
|
||||
|
||||
app.loadJQueryUI(function() {
|
||||
app.loadJQueryUI(function () {
|
||||
chatModal.find('.modal-content').resizable({
|
||||
handles: 'n, e, s, w, se',
|
||||
minHeight: 250,
|
||||
minWidth: 400
|
||||
});
|
||||
|
||||
chatModal.find('.modal-content').on('resize', function(event, ui) {
|
||||
chatModal.find('.modal-content').on('resize', function (event, ui) {
|
||||
if (ui.originalSize.height === ui.size.height) {
|
||||
return;
|
||||
}
|
||||
@@ -186,10 +186,10 @@ define('chat', [
|
||||
});
|
||||
|
||||
chatModal.draggable({
|
||||
start:function() {
|
||||
start:function () {
|
||||
module.bringModalToTop(chatModal);
|
||||
},
|
||||
stop:function() {
|
||||
stop:function () {
|
||||
chatModal.find('#chat-message-input').focus();
|
||||
},
|
||||
distance: 10,
|
||||
@@ -197,13 +197,13 @@ define('chat', [
|
||||
});
|
||||
});
|
||||
|
||||
chatModal.find('#chat-close-btn').on('click', function() {
|
||||
chatModal.find('#chat-close-btn').on('click', function () {
|
||||
module.close(chatModal);
|
||||
});
|
||||
|
||||
function gotoChats() {
|
||||
var text = components.get('chat/input').val();
|
||||
$(window).one('action:ajaxify.end', function() {
|
||||
$(window).one('action:ajaxify.end', function () {
|
||||
components.get('chat/input').val(text);
|
||||
});
|
||||
|
||||
@@ -214,7 +214,7 @@ define('chat', [
|
||||
chatModal.find('.modal-header').on('dblclick', gotoChats);
|
||||
chatModal.find('button[data-action="maximize"]').on('click', gotoChats);
|
||||
|
||||
chatModal.on('click', function() {
|
||||
chatModal.on('click', function () {
|
||||
module.bringModalToTop(chatModal);
|
||||
|
||||
if (dragged) {
|
||||
@@ -222,13 +222,13 @@ define('chat', [
|
||||
}
|
||||
});
|
||||
|
||||
chatModal.on('mousemove', function(e) {
|
||||
chatModal.on('mousemove', function (e) {
|
||||
if (e.which === 1) {
|
||||
dragged = true;
|
||||
}
|
||||
});
|
||||
|
||||
chatModal.on('mousemove keypress click', function() {
|
||||
chatModal.on('mousemove keypress click', function () {
|
||||
if (newMessage) {
|
||||
socket.emit('modules.chats.markRead', data.roomId);
|
||||
newMessage = false;
|
||||
@@ -237,7 +237,7 @@ define('chat', [
|
||||
|
||||
Chats.addEditDeleteHandler(chatModal.find('[component="chat/messages"]'), data.roomId);
|
||||
|
||||
chatModal.find('[component="chat/controlsToggle"]').on('click', function() {
|
||||
chatModal.find('[component="chat/controlsToggle"]').on('click', function () {
|
||||
var messagesEl = chatModal.find('[component="chat/messages"]');
|
||||
|
||||
chatModal.find('[component="chat/controls"]').toggle();
|
||||
@@ -268,11 +268,11 @@ define('chat', [
|
||||
});
|
||||
};
|
||||
|
||||
module.focusInput = function(chatModal) {
|
||||
module.focusInput = function (chatModal) {
|
||||
chatModal.find('#chat-message-input').focus();
|
||||
};
|
||||
|
||||
module.close = function(chatModal) {
|
||||
module.close = function (chatModal) {
|
||||
clearInterval(chatModal.attr('intervalId'));
|
||||
chatModal.attr('intervalId', 0);
|
||||
chatModal.remove();
|
||||
@@ -284,7 +284,7 @@ define('chat', [
|
||||
}
|
||||
};
|
||||
|
||||
module.center = function(chatModal) {
|
||||
module.center = function (chatModal) {
|
||||
var hideAfter = false;
|
||||
if (chatModal.hasClass('hide')) {
|
||||
chatModal.removeClass('hide');
|
||||
@@ -299,7 +299,7 @@ define('chat', [
|
||||
return chatModal;
|
||||
};
|
||||
|
||||
module.load = function(uuid) {
|
||||
module.load = function (uuid) {
|
||||
var chatModal = $('div[UUID="' + uuid + '"]');
|
||||
chatModal.removeClass('hide');
|
||||
taskbar.updateActive(uuid);
|
||||
@@ -314,22 +314,22 @@ define('chat', [
|
||||
}
|
||||
};
|
||||
|
||||
module.enableMobileBehaviour = function(modalEl) {
|
||||
module.enableMobileBehaviour = function (modalEl) {
|
||||
app.toggleNavbar(false);
|
||||
modalEl.attr('data-mobile', '1');
|
||||
var messagesEl = modalEl.find('.chat-content');
|
||||
messagesEl.css('height', module.calculateChatListHeight(modalEl));
|
||||
|
||||
$(window).on('resize', function() {
|
||||
$(window).on('resize', function () {
|
||||
messagesEl.css('height', module.calculateChatListHeight(modalEl));
|
||||
});
|
||||
};
|
||||
|
||||
module.disableMobileBehaviour = function() {
|
||||
module.disableMobileBehaviour = function () {
|
||||
app.toggleNavbar(true);
|
||||
};
|
||||
|
||||
module.calculateChatListHeight = function(modalEl) {
|
||||
module.calculateChatListHeight = function (modalEl) {
|
||||
var totalHeight = modalEl.find('.modal-content').outerHeight() - modalEl.find('.modal-header').outerHeight();
|
||||
var padding = parseInt(modalEl.find('.modal-body').css('padding-top'), 10) + parseInt(modalEl.find('.modal-body').css('padding-bottom'), 10);
|
||||
var contentMargin = parseInt(modalEl.find('.chat-content').css('margin-top'), 10) + parseInt(modalEl.find('.chat-content').css('margin-bottom'), 10);
|
||||
@@ -338,7 +338,7 @@ define('chat', [
|
||||
return totalHeight - padding - contentMargin - inputGroupHeight;
|
||||
};
|
||||
|
||||
module.minimize = function(uuid) {
|
||||
module.minimize = function (uuid) {
|
||||
var chatModal = $('div[UUID="' + uuid + '"]');
|
||||
chatModal.addClass('hide');
|
||||
taskbar.minimize('chat', uuid);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user