mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-22 16:30:34 +01:00
ESlint one-var, fix comma-dangle
This commit is contained in:
@@ -3,10 +3,17 @@
|
|||||||
|
|
||||||
"rules": {
|
"rules": {
|
||||||
"handle-callback-err": [ "error","^(e$|(e|(.*(_e|E)))rr)" ],
|
"handle-callback-err": [ "error","^(e$|(e|(.*(_e|E)))rr)" ],
|
||||||
|
"comma-dangle": ["error", {
|
||||||
|
"arrays": "always-multiline",
|
||||||
|
"objects": "always-multiline",
|
||||||
|
"imports": "always-multiline",
|
||||||
|
"exports": "always-multiline",
|
||||||
|
"functions": "never"
|
||||||
|
}],
|
||||||
// "linebreak-style": "off",
|
// "linebreak-style": "off",
|
||||||
"import/no-unresolved": "off",
|
"import/no-unresolved": "off",
|
||||||
"import/no-extraneous-dependencies": "off",
|
"import/no-extraneous-dependencies": "off",
|
||||||
"one-var": "off",
|
// "one-var": "off",
|
||||||
"no-undef": "off",
|
"no-undef": "off",
|
||||||
"max-len": "off",
|
"max-len": "off",
|
||||||
"no-new": "off",
|
"no-new": "off",
|
||||||
|
|||||||
19
Gruntfile.js
19
Gruntfile.js
@@ -1,10 +1,11 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var fork = require('child_process').fork,
|
var fork = require('child_process').fork;
|
||||||
env = process.env,
|
var env = process.env;
|
||||||
worker, updateWorker,
|
var worker;
|
||||||
incomplete = [],
|
var updateWorker;
|
||||||
running = 0;
|
var incomplete = [];
|
||||||
|
var running = 0;
|
||||||
|
|
||||||
|
|
||||||
module.exports = function (grunt) {
|
module.exports = function (grunt) {
|
||||||
@@ -14,10 +15,10 @@ module.exports = function (grunt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function update(action, filepath, target) {
|
function update(action, filepath, target) {
|
||||||
var updateArgs = args.slice(),
|
var updateArgs = args.slice();
|
||||||
fromFile = '',
|
var fromFile = '';
|
||||||
compiling = '',
|
var compiling = '';
|
||||||
time = Date.now();
|
var time = Date.now();
|
||||||
|
|
||||||
if (target === 'lessUpdated_Client') {
|
if (target === 'lessUpdated_Client') {
|
||||||
compiling = 'clientCSS';
|
compiling = 'clientCSS';
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var bcrypt = require('bcryptjs'),
|
var bcrypt = require('bcryptjs');
|
||||||
async = require('async');
|
var async = require('async');
|
||||||
|
|
||||||
|
|
||||||
process.on('message', function (msg) {
|
process.on('message', function (msg) {
|
||||||
|
|||||||
36
loader.js
36
loader.js
@@ -1,29 +1,27 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var nconf = require('nconf'),
|
var nconf = require('nconf');
|
||||||
fs = require('fs'),
|
var fs = require('fs');
|
||||||
url = require('url'),
|
var url = require('url');
|
||||||
path = require('path'),
|
var path = require('path');
|
||||||
fork = require('child_process').fork,
|
var fork = require('child_process').fork;
|
||||||
|
var async = require('async');
|
||||||
async = require('async'),
|
var logrotate = require('logrotate-stream');
|
||||||
logrotate = require('logrotate-stream'),
|
var file = require('./src/file');
|
||||||
file = require('./src/file'),
|
var pkg = require('./package.json');
|
||||||
pkg = require('./package.json');
|
|
||||||
|
|
||||||
nconf.argv().env().file({
|
nconf.argv().env().file({
|
||||||
file: path.join(__dirname, '/config.json'),
|
file: path.join(__dirname, '/config.json'),
|
||||||
});
|
});
|
||||||
|
|
||||||
var pidFilePath = __dirname + '/pidfile',
|
var pidFilePath = __dirname + '/pidfile';
|
||||||
output = logrotate({ file: __dirname + '/logs/output.log', size: '1m', keep: 3, compress: true }),
|
var output = logrotate({ file: __dirname + '/logs/output.log', size: '1m', keep: 3, compress: true });
|
||||||
silent = nconf.get('silent') === 'false' ? false : nconf.get('silent') !== false,
|
var silent = nconf.get('silent') === 'false' ? false : nconf.get('silent') !== false;
|
||||||
numProcs,
|
var numProcs;
|
||||||
workers = [],
|
var workers = [];
|
||||||
|
var Loader = {
|
||||||
Loader = {
|
timesStarted: 0,
|
||||||
timesStarted: 0,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
Loader.init = function (callback) {
|
Loader.init = function (callback) {
|
||||||
if (silent) {
|
if (silent) {
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ define('admin/advanced/errors', ['Chart', 'translator'], function (Chart, transl
|
|||||||
};
|
};
|
||||||
|
|
||||||
Errors.setupCharts = function () {
|
Errors.setupCharts = function () {
|
||||||
var notFoundCanvas = document.getElementById('not-found'),
|
var notFoundCanvas = document.getElementById('not-found');
|
||||||
tooBusyCanvas = document.getElementById('toobusy'),
|
var tooBusyCanvas = document.getElementById('toobusy');
|
||||||
dailyLabels = utils.getDaysArray();
|
var dailyLabels = utils.getDaysArray();
|
||||||
|
|
||||||
dailyLabels = dailyLabels.slice(-7);
|
dailyLabels = dailyLabels.slice(-7);
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ define('admin/advanced/logs', function () {
|
|||||||
$('.affix').affix();
|
$('.affix').affix();
|
||||||
|
|
||||||
$('.logs').find('button[data-action]').on('click', function (event) {
|
$('.logs').find('button[data-action]').on('click', function (event) {
|
||||||
var btnEl = $(this),
|
var btnEl = $(this);
|
||||||
action = btnEl.attr('data-action');
|
var action = btnEl.attr('data-action');
|
||||||
|
|
||||||
switch(action) {
|
switch(action) {
|
||||||
case 'reload':
|
case 'reload':
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ define('admin/appearance/customise', ['admin/settings'], function (Settings) {
|
|||||||
$('#customCSS').text($('#customCSS-holder').val());
|
$('#customCSS').text($('#customCSS-holder').val());
|
||||||
$('#customHTML').text($('#customHTML-holder').val());
|
$('#customHTML').text($('#customHTML-holder').val());
|
||||||
|
|
||||||
var customCSS = ace.edit("customCSS"),
|
var customCSS = ace.edit("customCSS");
|
||||||
customHTML = ace.edit("customHTML");
|
var customHTML = ace.edit("customHTML");
|
||||||
|
|
||||||
customCSS.setTheme("ace/theme/twilight");
|
customCSS.setTheme("ace/theme/twilight");
|
||||||
customCSS.getSession().setMode("ace/mode/css");
|
customCSS.getSession().setMode("ace/mode/css");
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ define('admin/appearance/skins', ['translator'], function (translator) {
|
|||||||
var action = target.attr('data-action');
|
var action = target.attr('data-action');
|
||||||
|
|
||||||
if (action && action === 'use') {
|
if (action && action === 'use') {
|
||||||
var parentEl = target.parents('[data-theme]'),
|
var parentEl = target.parents('[data-theme]');
|
||||||
themeType = parentEl.attr('data-type'),
|
var themeType = parentEl.attr('data-type');
|
||||||
cssSrc = parentEl.attr('data-css'),
|
var cssSrc = parentEl.attr('data-css');
|
||||||
themeId = parentEl.attr('data-theme');
|
var themeId = parentEl.attr('data-theme');
|
||||||
|
|
||||||
|
|
||||||
socket.emit('admin.themes.set', {
|
socket.emit('admin.themes.set', {
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ define('admin/appearance/themes', ['translator'], function (translator) {
|
|||||||
|
|
||||||
Themes.init = function () {
|
Themes.init = function () {
|
||||||
$('#installed_themes').on('click', function (e) {
|
$('#installed_themes').on('click', function (e) {
|
||||||
var target = $(e.target),
|
var target = $(e.target);
|
||||||
action = target.attr('data-action');
|
var action = target.attr('data-action');
|
||||||
|
|
||||||
if (action && action === 'use') {
|
if (action && action === 'use') {
|
||||||
var parentEl = target.parents('[data-theme]'),
|
var parentEl = target.parents('[data-theme]');
|
||||||
themeType = parentEl.attr('data-type'),
|
var themeType = parentEl.attr('data-type');
|
||||||
cssSrc = parentEl.attr('data-css'),
|
var cssSrc = parentEl.attr('data-css');
|
||||||
themeId = parentEl.attr('data-theme');
|
var themeId = parentEl.attr('data-theme');
|
||||||
|
|
||||||
socket.emit('admin.themes.set', {
|
socket.emit('admin.themes.set', {
|
||||||
type: themeType,
|
type: themeType,
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
define('admin/extend/plugins', ['jqueryui', 'translator'], function (jqueryui, translator) {
|
define('admin/extend/plugins', ['jqueryui', 'translator'], function (jqueryui, translator) {
|
||||||
var Plugins = {};
|
var Plugins = {};
|
||||||
Plugins.init = function () {
|
Plugins.init = function () {
|
||||||
var pluginsList = $('.plugins'),
|
var pluginsList = $('.plugins');
|
||||||
numPlugins = pluginsList[0].querySelectorAll('li').length,
|
var numPlugins = pluginsList[0].querySelectorAll('li').length;
|
||||||
pluginID;
|
var pluginID;
|
||||||
|
|
||||||
if (!numPlugins) {
|
if (!numPlugins) {
|
||||||
translator.translate('<li><p><i>[[admin/extend/plugins:none-found]]</i></p></li>', function (html) {
|
translator.translate('<li><p><i>[[admin/extend/plugins:none-found]]</i></p></li>', function (html) {
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ define('admin/extend/rewards', ['translator'], function (translator) {
|
|||||||
var rewards = {};
|
var rewards = {};
|
||||||
|
|
||||||
|
|
||||||
var available,
|
var available;
|
||||||
active,
|
var active;
|
||||||
conditions,
|
var conditions;
|
||||||
conditionals;
|
var conditionals;
|
||||||
|
|
||||||
rewards.init = function () {
|
rewards.init = function () {
|
||||||
available = ajaxify.data.rewards;
|
available = ajaxify.data.rewards;
|
||||||
@@ -25,8 +25,8 @@ define('admin/extend/rewards', ['translator'], function (translator) {
|
|||||||
update($(this));
|
update($(this));
|
||||||
})
|
})
|
||||||
.on('click', '.delete', function () {
|
.on('click', '.delete', function () {
|
||||||
var parent = $(this).parents('[data-id]'),
|
var parent = $(this).parents('[data-id]');
|
||||||
id = parent.attr('data-id');
|
var 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) {
|
if (err) {
|
||||||
@@ -40,9 +40,9 @@ define('admin/extend/rewards', ['translator'], function (translator) {
|
|||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
.on('click', '.toggle', function () {
|
.on('click', '.toggle', function () {
|
||||||
var btn = $(this),
|
var btn = $(this);
|
||||||
disabled = btn.hasClass('btn-success'),
|
var disabled = btn.hasClass('btn-success');
|
||||||
id = $(this).parents('[data-id]').attr('data-id');
|
var id = $(this).parents('[data-id]').attr('data-id');
|
||||||
btn.toggleClass('btn-warning').toggleClass('btn-success').translateHtml('[[admin/extend/rewards:' + disabled ? 'disable' : 'enable' + ']]');
|
btn.toggleClass('btn-warning').toggleClass('btn-success').translateHtml('[[admin/extend/rewards:' + disabled ? 'disable' : 'enable' + ']]');
|
||||||
// send disable api call
|
// send disable api call
|
||||||
return false;
|
return false;
|
||||||
@@ -73,10 +73,10 @@ define('admin/extend/rewards', ['translator'], function (translator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function selectReward(el) {
|
function selectReward(el) {
|
||||||
var parent = el.parents('[data-rid]'),
|
var parent = el.parents('[data-rid]');
|
||||||
div = parent.find('.inputs'),
|
var div = parent.find('.inputs');
|
||||||
inputs,
|
var inputs;
|
||||||
html = '';
|
var html = '';
|
||||||
|
|
||||||
for (var reward in available) {
|
for (var reward in available) {
|
||||||
if (available.hasOwnProperty(reward)) {
|
if (available.hasOwnProperty(reward)) {
|
||||||
@@ -113,8 +113,8 @@ define('admin/extend/rewards', ['translator'], function (translator) {
|
|||||||
|
|
||||||
function populateInputs() {
|
function populateInputs() {
|
||||||
$('[data-rid]').each(function (i) {
|
$('[data-rid]').each(function (i) {
|
||||||
var div = $(this).find('.inputs'),
|
var div = $(this).find('.inputs');
|
||||||
rewards = active[i].rewards;
|
var rewards = active[i].rewards;
|
||||||
|
|
||||||
for (var reward in rewards) {
|
for (var reward in rewards) {
|
||||||
if (rewards.hasOwnProperty(reward)) {
|
if (rewards.hasOwnProperty(reward)) {
|
||||||
@@ -153,9 +153,9 @@ define('admin/extend/rewards', ['translator'], function (translator) {
|
|||||||
var activeRewards = [];
|
var activeRewards = [];
|
||||||
|
|
||||||
$('#active li').each(function () {
|
$('#active li').each(function () {
|
||||||
var data = {rewards: {}},
|
var data = {rewards: {}};
|
||||||
main = $(this).find('form.main').serializeArray(),
|
var main = $(this).find('form.main').serializeArray();
|
||||||
rewards = $(this).find('form.rewards').serializeArray();
|
var rewards = $(this).find('form.rewards').serializeArray();
|
||||||
|
|
||||||
main.forEach(function (obj) {
|
main.forEach(function (obj) {
|
||||||
data[obj.name] = obj.value;
|
data[obj.name] = obj.value;
|
||||||
|
|||||||
@@ -80,14 +80,14 @@ define('admin/extend/widgets', ['jqueryui'], function (jqueryui) {
|
|||||||
$('#widgets [data-template][data-location]').each(function (i, el) {
|
$('#widgets [data-template][data-location]').each(function (i, el) {
|
||||||
el = $(el);
|
el = $(el);
|
||||||
|
|
||||||
var template = el.attr('data-template'),
|
var template = el.attr('data-template');
|
||||||
location = el.attr('data-location'),
|
var location = el.attr('data-location');
|
||||||
area = el.children('.widget-area'),
|
var area = el.children('.widget-area');
|
||||||
widgets = [];
|
var widgets = [];
|
||||||
|
|
||||||
area.find('.widget-panel[data-widget]').each(function () {
|
area.find('.widget-panel[data-widget]').each(function () {
|
||||||
var widgetData = {},
|
var widgetData = {};
|
||||||
data = $(this).find('form').serializeArray();
|
var data = $(this).find('form').serializeArray();
|
||||||
|
|
||||||
for (var d in data) {
|
for (var d in data) {
|
||||||
if (data.hasOwnProperty(d)) {
|
if (data.hasOwnProperty(d)) {
|
||||||
@@ -136,10 +136,10 @@ define('admin/extend/widgets', ['jqueryui'], function (jqueryui) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$('.color-selector').on('click', '.btn', function () {
|
$('.color-selector').on('click', '.btn', function () {
|
||||||
var btn = $(this),
|
var btn = $(this);
|
||||||
selector = btn.parents('.color-selector'),
|
var selector = btn.parents('.color-selector');
|
||||||
container = selector.parents('[data-container-html]'),
|
var container = selector.parents('[data-container-html]');
|
||||||
classList = [];
|
var classList = [];
|
||||||
|
|
||||||
selector.children().each(function () {
|
selector.children().each(function () {
|
||||||
classList.push($(this).attr('data-class'));
|
classList.push($(this).attr('data-class'));
|
||||||
@@ -150,7 +150,7 @@ define('admin/extend/widgets', ['jqueryui'], function (jqueryui) {
|
|||||||
.addClass(btn.attr('data-class'));
|
.addClass(btn.attr('data-class'));
|
||||||
|
|
||||||
container.attr('data-container-html', container.attr('data-container-html')
|
container.attr('data-container-html', container.attr('data-container-html')
|
||||||
.replace(/class="[a-zA-Z0-9-\s]+"/, 'class="' + container[0].className.replace(' pointer ui-draggable', '') + '"'),
|
.replace(/class="[a-zA-Z0-9-\s]+"/, 'class="' + container[0].className.replace(' pointer ui-draggable', '') + '"')
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -191,8 +191,8 @@ define('admin/extend/widgets', ['jqueryui'], function (jqueryui) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
widget.find('input, textarea, select').each(function () {
|
widget.find('input, textarea, select').each(function () {
|
||||||
var input = $(this),
|
var input = $(this);
|
||||||
value = data[input.attr('name')];
|
var value = data[input.attr('name')];
|
||||||
|
|
||||||
if (input.attr('type') === 'checkbox') {
|
if (input.attr('type') === 'checkbox') {
|
||||||
input.prop('checked', !!value).trigger('change');
|
input.prop('checked', !!value).trigger('change');
|
||||||
@@ -208,14 +208,14 @@ define('admin/extend/widgets', ['jqueryui'], function (jqueryui) {
|
|||||||
var areas = data.areas;
|
var areas = data.areas;
|
||||||
|
|
||||||
for(var i = 0; i < areas.length; ++i) {
|
for(var i = 0; i < areas.length; ++i) {
|
||||||
var area = areas[i],
|
var area = areas[i];
|
||||||
widgetArea = $('#widgets .area[data-template="' + area.template + '"][data-location="' + area.location + '"]').find('.widget-area');
|
var widgetArea = $('#widgets .area[data-template="' + area.template + '"][data-location="' + area.location + '"]').find('.widget-area');
|
||||||
|
|
||||||
widgetArea.html('');
|
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],
|
var widgetData = area.data[k];
|
||||||
widgetEl = $('.available-widgets [data-widget="' + widgetData.widget + '"]').clone(true).removeClass('hide');
|
var widgetEl = $('.available-widgets [data-widget="' + widgetData.widget + '"]').clone(true).removeClass('hide');
|
||||||
|
|
||||||
widgetArea.append(populateWidget(widgetEl, widgetData.data));
|
widgetArea.append(populateWidget(widgetEl, widgetData.data));
|
||||||
appendToggle(widgetEl);
|
appendToggle(widgetEl);
|
||||||
|
|||||||
@@ -51,10 +51,10 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s
|
|||||||
return !isPrerelease.test(version.name); // filter out automated prerelease versions
|
return !isPrerelease.test(version.name); // filter out automated prerelease versions
|
||||||
});
|
});
|
||||||
|
|
||||||
var version = $('#version').html(),
|
var version = $('#version').html();
|
||||||
latestVersion = releases[0].name.slice(1),
|
var latestVersion = releases[0].name.slice(1);
|
||||||
checkEl = $('.version-check'),
|
var checkEl = $('.version-check');
|
||||||
text;
|
var text;
|
||||||
|
|
||||||
// Alter box colour accordingly
|
// Alter box colour accordingly
|
||||||
if (semver.eq(latestVersion, version)) {
|
if (semver.eq(latestVersion, version)) {
|
||||||
@@ -159,15 +159,15 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator'], function (s
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setupGraphs() {
|
function setupGraphs() {
|
||||||
var trafficCanvas = document.getElementById('analytics-traffic'),
|
var trafficCanvas = document.getElementById('analytics-traffic');
|
||||||
registeredCanvas = document.getElementById('analytics-registered'),
|
var registeredCanvas = document.getElementById('analytics-registered');
|
||||||
presenceCanvas = document.getElementById('analytics-presence'),
|
var presenceCanvas = document.getElementById('analytics-presence');
|
||||||
topicsCanvas = document.getElementById('analytics-topics'),
|
var topicsCanvas = document.getElementById('analytics-topics');
|
||||||
trafficCtx = trafficCanvas.getContext('2d'),
|
var trafficCtx = trafficCanvas.getContext('2d');
|
||||||
registeredCtx = registeredCanvas.getContext('2d'),
|
var registeredCtx = registeredCanvas.getContext('2d');
|
||||||
presenceCtx = presenceCanvas.getContext('2d'),
|
var presenceCtx = presenceCanvas.getContext('2d');
|
||||||
topicsCtx = topicsCanvas.getContext('2d'),
|
var topicsCtx = topicsCanvas.getContext('2d');
|
||||||
trafficLabels = utils.getHoursArray();
|
var trafficLabels = utils.getHoursArray();
|
||||||
|
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
Chart.defaults.global.tooltips.enabled = false;
|
Chart.defaults.global.tooltips.enabled = false;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
/* global define, app, ajaxify, socket, templates */
|
/* 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 = {},
|
var navigation = {};
|
||||||
available;
|
var available;
|
||||||
|
|
||||||
navigation.init = function () {
|
navigation.init = function () {
|
||||||
available = ajaxify.data.available;
|
available = ajaxify.data.available;
|
||||||
@@ -61,9 +61,9 @@ define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], fun
|
|||||||
}
|
}
|
||||||
|
|
||||||
function drop(ev, ui) {
|
function drop(ev, ui) {
|
||||||
var id = ui.helper.attr('data-id'),
|
var id = ui.helper.attr('data-id');
|
||||||
el = $('#active-navigation [data-id="' + id + '"]'),
|
var el = $('#active-navigation [data-id="' + id + '"]');
|
||||||
data = id === 'custom' ? {iconClass: 'fa-navicon'} : available[id];
|
var data = id === 'custom' ? {iconClass: 'fa-navicon'} : available[id];
|
||||||
|
|
||||||
data.enabled = false;
|
data.enabled = false;
|
||||||
data.index = (parseInt($('#enabled').children().last().attr('data-index'), 10) || 0) + 1;
|
data.index = (parseInt($('#enabled').children().last().attr('data-index'), 10) || 0) + 1;
|
||||||
@@ -95,9 +95,9 @@ define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], fun
|
|||||||
|
|
||||||
indices.forEach(function (index) {
|
indices.forEach(function (index) {
|
||||||
var el = $('#enabled').children('[data-index="' + index + '"]');
|
var el = $('#enabled').children('[data-index="' + index + '"]');
|
||||||
var form = el.find('form').serializeArray(),
|
var form = el.find('form').serializeArray();
|
||||||
data = {},
|
var data = {};
|
||||||
properties = {};
|
var properties = {};
|
||||||
|
|
||||||
form.forEach(function (input) {
|
form.forEach(function (input) {
|
||||||
if (input.name.slice(0, 9) === 'property:' && input.value === 'on') {
|
if (input.name.slice(0, 9) === 'property:' && input.value === 'on') {
|
||||||
@@ -135,8 +135,8 @@ define('admin/general/navigation', ['translator', 'iconSelect', 'jqueryui'], fun
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toggle() {
|
function toggle() {
|
||||||
var btn = $(this),
|
var btn = $(this);
|
||||||
disabled = btn.hasClass('btn-success');
|
var disabled = btn.hasClass('btn-success');
|
||||||
translator.translate(disabled ? '[[admin/general/navigation:btn.disable]]' : '[[admin/general/navigation:btn.enable]]', function (html) {
|
translator.translate(disabled ? '[[admin/general/navigation:btn.disable]]' : '[[admin/general/navigation:btn.enable]]', function (html) {
|
||||||
btn.toggleClass('btn-warning').toggleClass('btn-success').html(html);
|
btn.toggleClass('btn-warning').toggleClass('btn-success').html(html);
|
||||||
btn.parents('li').find('[name="enabled"]').val(disabled ? 'on' : '');
|
btn.parents('li').find('[name="enabled"]').val(disabled ? 'on' : '');
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
/*global define, socket, app, bootbox, templates, ajaxify, Sortable */
|
/*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;
|
var Categories = {};
|
||||||
|
var newCategoryId = -1;
|
||||||
|
var sortables;
|
||||||
|
|
||||||
Categories.init = function () {
|
Categories.init = function () {
|
||||||
socket.emit('admin.categories.getAll', function (error, payload) {
|
socket.emit('admin.categories.getAll', function (error, payload) {
|
||||||
@@ -17,10 +19,10 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
|
|||||||
|
|
||||||
// Enable/Disable toggle events
|
// Enable/Disable toggle events
|
||||||
$('.categories').on('click', 'button[data-action="toggle"]', function () {
|
$('.categories').on('click', 'button[data-action="toggle"]', function () {
|
||||||
var $this = $(this),
|
var $this = $(this);
|
||||||
cid = $this.attr('data-cid'),
|
var cid = $this.attr('data-cid');
|
||||||
parentEl = $this.parents('li[data-cid="' + cid + '"]'),
|
var parentEl = $this.parents('li[data-cid="' + cid + '"]');
|
||||||
disabled = parentEl.hasClass('disabled');
|
var 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');
|
return $(this).attr('data-cid');
|
||||||
@@ -127,8 +129,11 @@ define('admin/manage/categories', ['vendor/jquery/serializeObject/jquery.ba-seri
|
|||||||
|
|
||||||
//Update needed?
|
//Update needed?
|
||||||
if((e.newIndex != undefined && e.oldIndex != e.newIndex) || isCategoryUpdate) {
|
if((e.newIndex != undefined && e.oldIndex != e.newIndex) || isCategoryUpdate) {
|
||||||
var parentCategory = isCategoryUpdate ? sortables[newCategoryId] : sortables[e.from.dataset.cid],
|
var parentCategory = isCategoryUpdate ? sortables[newCategoryId] : sortables[e.from.dataset.cid];
|
||||||
modified = {}, i = 0, list = parentCategory.toArray(), len = list.length;
|
var modified = {};
|
||||||
|
var i = 0;
|
||||||
|
var list = parentCategory.toArray();
|
||||||
|
var len = list.length;
|
||||||
|
|
||||||
for(i; i < len; ++i) {
|
for(i; i < len; ++i) {
|
||||||
modified[list[i]] = {
|
modified[list[i]] = {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ define('admin/manage/category', [
|
|||||||
title: '[[admin/manage/categories:alert.updated]]',
|
title: '[[admin/manage/categories:alert.updated]]',
|
||||||
message: translator.compile(
|
message: translator.compile(
|
||||||
'admin/manage/categories:alert.updated-success',
|
'admin/manage/categories:alert.updated-success',
|
||||||
results.join(', '),
|
results.join(', ')
|
||||||
),
|
),
|
||||||
type: 'success',
|
type: 'success',
|
||||||
timeout: 2000,
|
timeout: 2000,
|
||||||
@@ -58,8 +58,8 @@ define('admin/manage/category', [
|
|||||||
});
|
});
|
||||||
|
|
||||||
function enableColorPicker(idx, inputEl) {
|
function enableColorPicker(idx, inputEl) {
|
||||||
var $inputEl = $(inputEl),
|
var $inputEl = $(inputEl);
|
||||||
previewEl = $inputEl.parents('[data-cid]').find('.category-preview');
|
var 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') {
|
if ($inputEl.attr('data-name') === 'bgColor') {
|
||||||
@@ -117,7 +117,7 @@ define('admin/manage/category', [
|
|||||||
|
|
||||||
bootbox.confirm(translator.compile(
|
bootbox.confirm(translator.compile(
|
||||||
'admin/manage/categories:alert.confirm-purge',
|
'admin/manage/categories:alert.confirm-purge',
|
||||||
$('form.category').find('input[data-name="name"]').val(),
|
$('form.category').find('input[data-name="name"]').val()
|
||||||
), function (confirm) {
|
), function (confirm) {
|
||||||
if (!confirm) {
|
if (!confirm) {
|
||||||
return;
|
return;
|
||||||
@@ -233,13 +233,13 @@ define('admin/manage/category', [
|
|||||||
|
|
||||||
Category.setupPrivilegeTable = function () {
|
Category.setupPrivilegeTable = function () {
|
||||||
$('.privilege-table-container').on('change', 'input[type="checkbox"]', function () {
|
$('.privilege-table-container').on('change', 'input[type="checkbox"]', function () {
|
||||||
var checkboxEl = $(this),
|
var checkboxEl = $(this);
|
||||||
privilege = checkboxEl.parent().attr('data-privilege'),
|
var privilege = checkboxEl.parent().attr('data-privilege');
|
||||||
state = checkboxEl.prop('checked'),
|
var state = checkboxEl.prop('checked');
|
||||||
rowEl = checkboxEl.parents('tr'),
|
var rowEl = checkboxEl.parents('tr');
|
||||||
member = rowEl.attr('data-group-name') || rowEl.attr('data-uid'),
|
var member = rowEl.attr('data-group-name') || rowEl.attr('data-uid');
|
||||||
isPrivate = parseInt(rowEl.attr('data-private') || 0, 10),
|
var isPrivate = parseInt(rowEl.attr('data-private') || 0, 10);
|
||||||
isGroup = rowEl.attr('data-group-name') !== undefined;
|
var isGroup = rowEl.attr('data-group-name') !== undefined;
|
||||||
|
|
||||||
if (member) {
|
if (member) {
|
||||||
if (isGroup && privilege === 'groups:moderate' && !isPrivate && state) {
|
if (isGroup && privilege === 'groups:moderate' && !isPrivate && state) {
|
||||||
@@ -340,8 +340,8 @@ define('admin/manage/category', [
|
|||||||
});
|
});
|
||||||
|
|
||||||
modal.find('li[data-cid]').on('click', function () {
|
modal.find('li[data-cid]').on('click', function () {
|
||||||
var parentCid = $(this).attr('data-cid'),
|
var parentCid = $(this).attr('data-cid');
|
||||||
payload = {};
|
var payload = {};
|
||||||
|
|
||||||
payload[ajaxify.data.category.cid] = {
|
payload[ajaxify.data.category.cid] = {
|
||||||
parentCid: parentCid,
|
parentCid: parentCid,
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ define('admin/manage/group', [
|
|||||||
var Groups = {};
|
var Groups = {};
|
||||||
|
|
||||||
Groups.init = function () {
|
Groups.init = function () {
|
||||||
var groupDetailsSearch = $('#group-details-search'),
|
var groupDetailsSearch = $('#group-details-search');
|
||||||
groupDetailsSearchResults = $('#group-details-search-results'),
|
var groupDetailsSearchResults = $('#group-details-search-results');
|
||||||
groupIcon = $('#group-icon'),
|
var groupIcon = $('#group-icon');
|
||||||
changeGroupUserTitle = $('#change-group-user-title'),
|
var changeGroupUserTitle = $('#change-group-user-title');
|
||||||
changeGroupLabelColor = $('#change-group-label-color'),
|
var changeGroupLabelColor = $('#change-group-label-color');
|
||||||
groupLabelPreview = $('#group-label-preview'),
|
var groupLabelPreview = $('#group-label-preview');
|
||||||
searchDelay;
|
var searchDelay;
|
||||||
|
|
||||||
|
|
||||||
var groupName = ajaxify.data.group.name;
|
var groupName = ajaxify.data.group.name;
|
||||||
@@ -38,12 +38,13 @@ define('admin/manage/group', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
searchDelay = setTimeout(function () {
|
searchDelay = setTimeout(function () {
|
||||||
var searchText = groupDetailsSearch.val(),
|
var searchText = groupDetailsSearch.val();
|
||||||
foundUser;
|
var 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) {
|
if (!err && results && results.users.length > 0) {
|
||||||
var numResults = results.users.length, x;
|
var numResults = results.users.length;
|
||||||
|
var x;
|
||||||
if (numResults > 20) {
|
if (numResults > 20) {
|
||||||
numResults = 20;
|
numResults = 20;
|
||||||
}
|
}
|
||||||
@@ -76,8 +77,8 @@ define('admin/manage/group', [
|
|||||||
});
|
});
|
||||||
|
|
||||||
groupDetailsSearchResults.on('click', 'li[data-uid]', function () {
|
groupDetailsSearchResults.on('click', 'li[data-uid]', function () {
|
||||||
var userLabel = $(this),
|
var userLabel = $(this);
|
||||||
uid = parseInt(userLabel.attr('data-uid'), 10);
|
var uid = parseInt(userLabel.attr('data-uid'), 10);
|
||||||
|
|
||||||
socket.emit('admin.groups.join', {
|
socket.emit('admin.groups.join', {
|
||||||
groupName: groupName,
|
groupName: groupName,
|
||||||
@@ -105,12 +106,12 @@ define('admin/manage/group', [
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('[component="groups/members"]').on('click', '[data-action]', function () {
|
$('[component="groups/members"]').on('click', '[data-action]', function () {
|
||||||
var btnEl = $(this),
|
var btnEl = $(this);
|
||||||
userRow = btnEl.parents('[data-uid]'),
|
var userRow = btnEl.parents('[data-uid]');
|
||||||
ownerFlagEl = userRow.find('.member-name i'),
|
var ownerFlagEl = userRow.find('.member-name i');
|
||||||
isOwner = !ownerFlagEl.hasClass('invisible') ? true : false,
|
var isOwner = !ownerFlagEl.hasClass('invisible') ? true : false;
|
||||||
uid = userRow.attr('data-uid'),
|
var uid = userRow.attr('data-uid');
|
||||||
action = btnEl.attr('data-action');
|
var action = btnEl.attr('data-action');
|
||||||
|
|
||||||
switch(action) {
|
switch(action) {
|
||||||
case 'toggleOwnership':
|
case 'toggleOwnership':
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ define('admin/manage/groups', ['translator'], function (translator) {
|
|||||||
var intervalId = 0;
|
var intervalId = 0;
|
||||||
|
|
||||||
Groups.init = function () {
|
Groups.init = function () {
|
||||||
var createModal = $('#create-modal'),
|
var createModal = $('#create-modal');
|
||||||
createGroupName = $('#create-group-name'),
|
var createGroupName = $('#create-group-name');
|
||||||
createModalGo = $('#create-modal-go'),
|
var createModalGo = $('#create-modal-go');
|
||||||
createModalError = $('#create-modal-error');
|
var createModalError = $('#create-modal-error');
|
||||||
|
|
||||||
handleSearch();
|
handleSearch();
|
||||||
|
|
||||||
@@ -29,10 +29,10 @@ define('admin/manage/groups', ['translator'], function (translator) {
|
|||||||
|
|
||||||
createModalGo.on('click', function () {
|
createModalGo.on('click', function () {
|
||||||
var submitObj = {
|
var submitObj = {
|
||||||
name: createGroupName.val(),
|
name: createGroupName.val(),
|
||||||
description: $('#create-group-desc').val(),
|
description: $('#create-group-desc').val(),
|
||||||
},
|
};
|
||||||
errorText;
|
var errorText;
|
||||||
|
|
||||||
socket.emit('admin.groups.create', submitObj, function (err) {
|
socket.emit('admin.groups.create', submitObj, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -52,9 +52,9 @@ define('admin/manage/groups', ['translator'], function (translator) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('.groups-list').on('click', 'button[data-action]', function () {
|
$('.groups-list').on('click', 'button[data-action]', function () {
|
||||||
var el = $(this),
|
var el = $(this);
|
||||||
action = el.attr('data-action'),
|
var action = el.attr('data-action');
|
||||||
groupName = el.parents('tr[data-groupname]').attr('data-groupname');
|
var groupName = el.parents('tr[data-groupname]').attr('data-groupname');
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'delete':
|
case 'delete':
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ define('admin/manage/registration', function () {
|
|||||||
var method = 'admin.user.deleteInvitation';
|
var method = 'admin.user.deleteInvitation';
|
||||||
|
|
||||||
var removeRow = function () {
|
var removeRow = function () {
|
||||||
var nextRow = parent.next(),
|
var nextRow = parent.next();
|
||||||
thisRowinvitedBy = parent.find('.invited-by'),
|
var thisRowinvitedBy = parent.find('.invited-by');
|
||||||
nextRowInvitedBy = nextRow.find('.invited-by');
|
var nextRowInvitedBy = nextRow.find('.invited-by');
|
||||||
if (nextRowInvitedBy.html() !== undefined && nextRowInvitedBy.html().length < 2) {
|
if (nextRowInvitedBy.html() !== undefined && nextRowInvitedBy.html().length < 2) {
|
||||||
nextRowInvitedBy.html(thisRowinvitedBy.html());
|
nextRowInvitedBy.html(thisRowinvitedBy.html());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ define('admin/manage/tags', [
|
|||||||
'admin/modules/selectable',
|
'admin/modules/selectable',
|
||||||
'admin/modules/colorpicker',
|
'admin/modules/colorpicker',
|
||||||
], function (infinitescroll, selectable, colorpicker) {
|
], function (infinitescroll, selectable, colorpicker) {
|
||||||
var Tags = {},
|
var Tags = {};
|
||||||
timeoutId = 0;
|
var timeoutId = 0;
|
||||||
|
|
||||||
Tags.init = function () {
|
Tags.init = function () {
|
||||||
selectable.enable('.tag-management', '.tag-row');
|
selectable.enable('.tag-management', '.tag-row');
|
||||||
@@ -85,8 +85,8 @@ define('admin/manage/tags', [
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var firstTag = $(tagsToModify[0]),
|
var firstTag = $(tagsToModify[0]);
|
||||||
title = tagsToModify.length > 1 ? '[[admin/manage/tags:alerts.editing-multiple]]' : '[[admin/manage/tags:alerts.editing-x, ' + firstTag.find('.tag-item').text() + ']]';
|
var title = tagsToModify.length > 1 ? '[[admin/manage/tags:alerts.editing-multiple]]' : '[[admin/manage/tags:alerts.editing-x, ' + firstTag.find('.tag-item').text() + ']]';
|
||||||
|
|
||||||
var modal = bootbox.dialog({
|
var modal = bootbox.dialog({
|
||||||
title: title,
|
title: title,
|
||||||
@@ -96,9 +96,9 @@ define('admin/manage/tags', [
|
|||||||
label: "Save",
|
label: "Save",
|
||||||
className: "btn-primary save",
|
className: "btn-primary save",
|
||||||
callback: function () {
|
callback: function () {
|
||||||
var modal = $('.bootbox'),
|
var modal = $('.bootbox');
|
||||||
bgColor = modal.find('[data-name="bgColor"]').val(),
|
var bgColor = modal.find('[data-name="bgColor"]').val();
|
||||||
color = modal.find('[data-name="color"]').val();
|
var color = modal.find('[data-name="color"]').val();
|
||||||
|
|
||||||
tagsToModify.each(function (idx, tag) {
|
tagsToModify.each(function (idx, tag) {
|
||||||
tag = $(tag);
|
tag = $(tag);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ define('admin/modules/search', ['mousetrap'], function (mousetrap) {
|
|||||||
// and wrap the match in a `.search-match` element
|
// and wrap the match in a `.search-match` element
|
||||||
.replace(
|
.replace(
|
||||||
new RegExp('^[\\s\\S]*?(.{0,25})(' + term + ')(.{0,25})[\\s\\S]*?$', 'gmi'),
|
new RegExp('^[\\s\\S]*?(.{0,25})(' + term + ')(.{0,25})[\\s\\S]*?$', 'gmi'),
|
||||||
'...$1<span class="search-match">$2</span>$3...<br>',
|
'...$1<span class="search-match">$2</span>$3...<br>'
|
||||||
)
|
)
|
||||||
// collapse whitespace
|
// collapse whitespace
|
||||||
.replace(/(?:\n ?)+/g, '\n')
|
.replace(/(?:\n ?)+/g, '\n')
|
||||||
@@ -29,7 +29,7 @@ define('admin/modules/search', ['mousetrap'], function (mousetrap) {
|
|||||||
|
|
||||||
title = title.replace(
|
title = title.replace(
|
||||||
new RegExp('(^.*?)(' + term + ')(.*?$)', 'gi'),
|
new RegExp('(^.*?)(' + term + ')(.*?$)', 'gi'),
|
||||||
'$1<span class="search-match">$2</span>$3',
|
'$1<span class="search-match">$2</span>$3'
|
||||||
);
|
);
|
||||||
|
|
||||||
return '<li role="presentation" class="result">' +
|
return '<li role="presentation" class="result">' +
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ define('admin/settings', ['uploader'], function (uploader) {
|
|||||||
|
|
||||||
Settings.populateTOC = function () {
|
Settings.populateTOC = function () {
|
||||||
$('.settings-header').each(function () {
|
$('.settings-header').each(function () {
|
||||||
var header = $(this).text(),
|
var header = $(this).text();
|
||||||
anchor = header.toLowerCase().replace(/ /g, '-').trim();
|
var anchor = header.toLowerCase().replace(/ /g, '-').trim();
|
||||||
|
|
||||||
$(this).prepend('<a name="' + anchor + '"></a>');
|
$(this).prepend('<a name="' + anchor + '"></a>');
|
||||||
$('.section-content ul').append('<li><a href="#' + anchor + '">' + header + '</a></li>');
|
$('.section-content ul').append('<li><a href="#' + anchor + '">' + header + '</a></li>');
|
||||||
@@ -21,11 +21,14 @@ define('admin/settings', ['uploader'], function (uploader) {
|
|||||||
|
|
||||||
Settings.prepare = function (callback) {
|
Settings.prepare = function (callback) {
|
||||||
// Populate the fields on the page from the config
|
// Populate the fields on the page from the config
|
||||||
var fields = $('#content [data-field]'),
|
var fields = $('#content [data-field]');
|
||||||
numFields = fields.length,
|
var numFields = fields.length;
|
||||||
saveBtn = $('#save'),
|
var saveBtn = $('#save');
|
||||||
revertBtn = $('#revert'),
|
var revertBtn = $('#revert');
|
||||||
x, key, inputType, field;
|
var x;
|
||||||
|
var key;
|
||||||
|
var inputType;
|
||||||
|
var field;
|
||||||
|
|
||||||
// Handle unsaved changes
|
// Handle unsaved changes
|
||||||
$(fields).on('change', function () {
|
$(fields).on('change', function () {
|
||||||
@@ -148,8 +151,9 @@ define('admin/settings', ['uploader'], function (uploader) {
|
|||||||
|
|
||||||
fields.each(function () {
|
fields.each(function () {
|
||||||
var field = $(this);
|
var field = $(this);
|
||||||
var key = field.attr('data-field'),
|
var key = field.attr('data-field');
|
||||||
value, inputType;
|
var value;
|
||||||
|
var inputType;
|
||||||
|
|
||||||
if (field.is('input')) {
|
if (field.is('input')) {
|
||||||
inputType = field.attr('type');
|
inputType = field.attr('type');
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
/* global define, socket, app, ajaxify, ace */
|
/* global define, socket, app, ajaxify, ace */
|
||||||
|
|
||||||
define('admin/settings/email', ['admin/settings'], function (settings) {
|
define('admin/settings/email', ['admin/settings'], function (settings) {
|
||||||
var module = {},
|
var module = {};
|
||||||
emailEditor;
|
var emailEditor;
|
||||||
|
|
||||||
module.init = function () {
|
module.init = function () {
|
||||||
configureEmailTester();
|
configureEmailTester();
|
||||||
|
|||||||
@@ -462,9 +462,9 @@ app.cacheBuster = null;
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.handleSearch = function () {
|
app.handleSearch = function () {
|
||||||
var searchButton = $("#search-button"),
|
var searchButton = $("#search-button");
|
||||||
searchFields = $("#search-fields"),
|
var searchFields = $("#search-fields");
|
||||||
searchInput = $('#search-fields input');
|
var searchInput = $('#search-fields input');
|
||||||
|
|
||||||
$('#search-form .advanced-search-link').on('mousedown', function () {
|
$('#search-form .advanced-search-link').on('mousedown', function () {
|
||||||
ajaxify.go('/search');
|
ajaxify.go('/search');
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ define('forum/account/header', [
|
|||||||
components.get('account/cover').css('background-image', 'url(' + imageUrlOnServer + '?' + config['cache-buster'] + ')');
|
components.get('account/cover').css('background-image', 'url(' + imageUrlOnServer + '?' + config['cache-buster'] + ')');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
removeCover,
|
removeCover
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
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 AccountPosts = {};
|
||||||
var method, template;
|
var method;
|
||||||
|
var template;
|
||||||
|
|
||||||
AccountPosts.init = function () {
|
AccountPosts.init = function () {
|
||||||
header.init();
|
header.init();
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
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 AccountTopics = {};
|
||||||
var template, set;
|
var template;
|
||||||
|
var set;
|
||||||
|
|
||||||
AccountTopics.init = function () {
|
AccountTopics.init = function () {
|
||||||
header.init();
|
header.init();
|
||||||
|
|||||||
@@ -211,10 +211,10 @@ define('forum/category', [
|
|||||||
template: {category: true},
|
template: {category: true},
|
||||||
}, function (html) {
|
}, function (html) {
|
||||||
translator.translate(html, function (translatedHTML) {
|
translator.translate(html, function (translatedHTML) {
|
||||||
var topic = $(translatedHTML),
|
var topic = $(translatedHTML);
|
||||||
container = $('[component="category"]'),
|
var container = $('[component="category"]');
|
||||||
topics = $('[component="category/topic"]'),
|
var topics = $('[component="category/topic"]');
|
||||||
numTopics = topics.length;
|
var numTopics = topics.length;
|
||||||
|
|
||||||
$('[component="category"]').removeClass('hidden');
|
$('[component="category"]').removeClass('hidden');
|
||||||
$('.category-sidebar').removeClass('hidden');
|
$('.category-sidebar').removeClass('hidden');
|
||||||
@@ -319,7 +319,8 @@ define('forum/category', [
|
|||||||
|
|
||||||
data.showSelect = data.privileges.editable;
|
data.showSelect = data.privileges.editable;
|
||||||
|
|
||||||
var after, before;
|
var after;
|
||||||
|
var before;
|
||||||
var topics = $('[component="category/topic"]');
|
var topics = $('[component="category/topic"]');
|
||||||
|
|
||||||
if (direction > 0 && topics.length) {
|
if (direction > 0 && topics.length) {
|
||||||
@@ -337,8 +338,8 @@ define('forum/category', [
|
|||||||
if (after) {
|
if (after) {
|
||||||
html.insertAfter(after);
|
html.insertAfter(after);
|
||||||
} else if (before) {
|
} else if (before) {
|
||||||
var height = $(document).height(),
|
var height = $(document).height();
|
||||||
scrollTop = $(window).scrollTop();
|
var scrollTop = $(window).scrollTop();
|
||||||
|
|
||||||
html.insertBefore(before);
|
html.insertBefore(before);
|
||||||
|
|
||||||
|
|||||||
@@ -134,16 +134,16 @@ define('forum/chats', [
|
|||||||
|
|
||||||
Chats.addHotkeys = function () {
|
Chats.addHotkeys = function () {
|
||||||
mousetrap.bind('ctrl+up', function () {
|
mousetrap.bind('ctrl+up', function () {
|
||||||
var activeContact = $('.chats-list .bg-primary'),
|
var activeContact = $('.chats-list .bg-primary');
|
||||||
prev = activeContact.prev();
|
var prev = activeContact.prev();
|
||||||
|
|
||||||
if (prev.length) {
|
if (prev.length) {
|
||||||
Chats.switchChat(prev.attr('data-roomid'));
|
Chats.switchChat(prev.attr('data-roomid'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mousetrap.bind('ctrl+down', function () {
|
mousetrap.bind('ctrl+down', function () {
|
||||||
var activeContact = $('.chats-list .bg-primary'),
|
var activeContact = $('.chats-list .bg-primary');
|
||||||
next = activeContact.next();
|
var next = activeContact.next();
|
||||||
|
|
||||||
if (next.length) {
|
if (next.length) {
|
||||||
Chats.switchChat(next.attr('data-roomid'));
|
Chats.switchChat(next.attr('data-roomid'));
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ define('forum/chats/messages', ['components', 'sounds', 'translator'], function
|
|||||||
messages.scrollToBottom = function (containerEl) {
|
messages.scrollToBottom = function (containerEl) {
|
||||||
if (containerEl.length) {
|
if (containerEl.length) {
|
||||||
containerEl.scrollTop(
|
containerEl.scrollTop(
|
||||||
containerEl[0].scrollHeight - containerEl.height(),
|
containerEl[0].scrollHeight - containerEl.height()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ define('forum/groups/details', [
|
|||||||
components.get('groups/cover').css('background-image', 'url(' + imageUrlOnServer + ')');
|
components.get('groups/cover').css('background-image', 'url(' + imageUrlOnServer + ')');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
removeCover,
|
removeCover
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,12 +52,12 @@ define('forum/groups/details', [
|
|||||||
components.get('groups/activity').find('.content img:not(.not-responsive)').addClass('img-responsive');
|
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),
|
var btnEl = $(this);
|
||||||
userRow = btnEl.parents('[data-uid]'),
|
var userRow = btnEl.parents('[data-uid]');
|
||||||
ownerFlagEl = userRow.find('.member-name > i'),
|
var ownerFlagEl = userRow.find('.member-name > i');
|
||||||
isOwner = !ownerFlagEl.hasClass('invisible') ? true : false,
|
var isOwner = !ownerFlagEl.hasClass('invisible') ? true : false;
|
||||||
uid = userRow.attr('data-uid'),
|
var uid = userRow.attr('data-uid');
|
||||||
action = btnEl.attr('data-action');
|
var action = btnEl.attr('data-action');
|
||||||
|
|
||||||
switch(action) {
|
switch(action) {
|
||||||
case 'toggleOwnership':
|
case 'toggleOwnership':
|
||||||
@@ -120,15 +120,15 @@ define('forum/groups/details', [
|
|||||||
};
|
};
|
||||||
|
|
||||||
Details.prepareSettings = function () {
|
Details.prepareSettings = function () {
|
||||||
var settingsFormEl = components.get('groups/settings'),
|
var settingsFormEl = components.get('groups/settings');
|
||||||
colorBtn = settingsFormEl.find('[data-action="color-select"]'),
|
var colorBtn = settingsFormEl.find('[data-action="color-select"]');
|
||||||
colorValueEl = settingsFormEl.find('[name="labelColor"]'),
|
var colorValueEl = settingsFormEl.find('[name="labelColor"]');
|
||||||
iconBtn = settingsFormEl.find('[data-action="icon-select"]'),
|
var iconBtn = settingsFormEl.find('[data-action="icon-select"]');
|
||||||
previewEl = settingsFormEl.find('.label'),
|
var previewEl = settingsFormEl.find('.label');
|
||||||
previewIcon = previewEl.find('i'),
|
var previewIcon = previewEl.find('i');
|
||||||
userTitleEl = settingsFormEl.find('[name="userTitle"]'),
|
var userTitleEl = settingsFormEl.find('[name="userTitle"]');
|
||||||
userTitleEnabledEl = settingsFormEl.find('[name="userTitleEnabled"]'),
|
var userTitleEnabledEl = settingsFormEl.find('[name="userTitleEnabled"]');
|
||||||
iconValueEl = settingsFormEl.find('[name="icon"]');
|
var iconValueEl = settingsFormEl.find('[name="icon"]');
|
||||||
|
|
||||||
// Add color picker to settings form
|
// Add color picker to settings form
|
||||||
colorBtn.ColorPicker({
|
colorBtn.ColorPicker({
|
||||||
@@ -171,8 +171,8 @@ define('forum/groups/details', [
|
|||||||
};
|
};
|
||||||
|
|
||||||
Details.update = function () {
|
Details.update = function () {
|
||||||
var settingsFormEl = components.get('groups/settings'),
|
var settingsFormEl = components.get('groups/settings');
|
||||||
checkboxes = settingsFormEl.find('input[type="checkbox"][name]');
|
var checkboxes = settingsFormEl.find('input[type="checkbox"][name]');
|
||||||
|
|
||||||
if (settingsFormEl.length) {
|
if (settingsFormEl.length) {
|
||||||
require(['vendor/jquery/serializeObject/jquery.ba-serializeobject.min'], function () {
|
require(['vendor/jquery/serializeObject/jquery.ba-serializeobject.min'], function () {
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ define('forum/groups/list', ['forum/infinitescroll'], function (infinitescroll)
|
|||||||
};
|
};
|
||||||
|
|
||||||
Groups.search = function () {
|
Groups.search = function () {
|
||||||
var groupsEl = $('#groups-list'),
|
var groupsEl = $('#groups-list');
|
||||||
queryEl = $('#search-text'),
|
var queryEl = $('#search-text');
|
||||||
sortEl = $('#search-sort');
|
var sortEl = $('#search-sort');
|
||||||
|
|
||||||
socket.emit('groups.search', {
|
socket.emit('groups.search', {
|
||||||
query: queryEl.val(),
|
query: queryEl.val(),
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ define('forum/infinitescroll', function () {
|
|||||||
var offsetTop = container.offset() ? container.offset().top : 0;
|
var offsetTop = container.offset() ? container.offset().top : 0;
|
||||||
var scrollPercent = 100 * (currentScrollTop - offsetTop) / (viewportHeight <= 0 ? wh : viewportHeight);
|
var scrollPercent = 100 * (currentScrollTop - offsetTop) / (viewportHeight <= 0 ? wh : viewportHeight);
|
||||||
|
|
||||||
var top = 20, bottom = 80;
|
var top = 20;
|
||||||
|
var bottom = 80;
|
||||||
|
|
||||||
var direction = currentScrollTop > previousScrollTop ? 1 : -1;
|
var direction = currentScrollTop > previousScrollTop ? 1 : -1;
|
||||||
|
|
||||||
@@ -76,8 +77,8 @@ define('forum/infinitescroll', function () {
|
|||||||
|
|
||||||
var removeCount = els.length - count;
|
var removeCount = els.length - count;
|
||||||
if (direction > 0) {
|
if (direction > 0) {
|
||||||
var height = $(document).height(),
|
var height = $(document).height();
|
||||||
scrollTop = $(window).scrollTop();
|
var scrollTop = $(window).scrollTop();
|
||||||
|
|
||||||
els.slice(0, removeCount).remove();
|
els.slice(0, removeCount).remove();
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ define('forum/login', ['translator'], function (translator) {
|
|||||||
var Login = {};
|
var Login = {};
|
||||||
|
|
||||||
Login.init = function () {
|
Login.init = function () {
|
||||||
var errorEl = $('#login-error-notify'),
|
var errorEl = $('#login-error-notify');
|
||||||
submitEl = $('#login'),
|
var submitEl = $('#login');
|
||||||
formEl = $('#login-form');
|
var formEl = $('#login-form');
|
||||||
|
|
||||||
submitEl.on('click', function (e) {
|
submitEl.on('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
@@ -4,16 +4,16 @@
|
|||||||
|
|
||||||
|
|
||||||
define('forum/register', ['translator'], function (translator) {
|
define('forum/register', ['translator'], function (translator) {
|
||||||
var Register = {},
|
var Register = {};
|
||||||
validationError = false,
|
var validationError = false;
|
||||||
successIcon = '';
|
var successIcon = '';
|
||||||
|
|
||||||
Register.init = function () {
|
Register.init = function () {
|
||||||
var email = $('#email'),
|
var email = $('#email');
|
||||||
username = $('#username'),
|
var username = $('#username');
|
||||||
password = $('#password'),
|
var password = $('#password');
|
||||||
password_confirm = $('#password-confirm'),
|
var password_confirm = $('#password-confirm');
|
||||||
register = $('#register');
|
var register = $('#register');
|
||||||
|
|
||||||
handleLanguageOverride();
|
handleLanguageOverride();
|
||||||
|
|
||||||
@@ -170,8 +170,8 @@ define('forum/register', ['translator'], function (translator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function validatePassword(password, password_confirm) {
|
function validatePassword(password, password_confirm) {
|
||||||
var password_notify = $('#password-notify'),
|
var password_notify = $('#password-notify');
|
||||||
password_confirm_notify = $('#password-confirm-notify');
|
var password_confirm_notify = $('#password-confirm-notify');
|
||||||
|
|
||||||
if (password.length < ajaxify.data.minimumPasswordLength) {
|
if (password.length < ajaxify.data.minimumPasswordLength) {
|
||||||
showError(password_notify, '[[user:change_password_error_length]]');
|
showError(password_notify, '[[user:change_password_error_length]]');
|
||||||
@@ -193,8 +193,8 @@ define('forum/register', ['translator'], function (translator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function validatePasswordConfirm(password, password_confirm) {
|
function validatePasswordConfirm(password, password_confirm) {
|
||||||
var password_notify = $('#password-notify'),
|
var password_notify = $('#password-notify');
|
||||||
password_confirm_notify = $('#password-confirm-notify');
|
var password_confirm_notify = $('#password-confirm-notify');
|
||||||
|
|
||||||
if (!password || password_notify.hasClass('alert-error')) {
|
if (!password || password_notify.hasClass('alert-error')) {
|
||||||
return;
|
return;
|
||||||
@@ -230,8 +230,8 @@ define('forum/register', ['translator'], function (translator) {
|
|||||||
|
|
||||||
function handleLanguageOverride() {
|
function handleLanguageOverride() {
|
||||||
if (!app.user.uid && config.defaultLang !== config.userLang) {
|
if (!app.user.uid && config.defaultLang !== config.userLang) {
|
||||||
var formEl = $('[component="register/local"]'),
|
var formEl = $('[component="register/local"]');
|
||||||
langEl = $('<input type="hidden" name="userLang" value="' + config.userLang + '" />');
|
var langEl = $('<input type="hidden" name="userLang" value="' + config.userLang + '" />');
|
||||||
|
|
||||||
formEl.append(langEl);
|
formEl.append(langEl);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ define('forum/reset', function () {
|
|||||||
var ResetPassword = {};
|
var ResetPassword = {};
|
||||||
|
|
||||||
ResetPassword.init = function () {
|
ResetPassword.init = function () {
|
||||||
var inputEl = $('#email'),
|
var inputEl = $('#email');
|
||||||
errorEl = $('#error'),
|
var errorEl = $('#error');
|
||||||
successEl = $('#success');
|
var successEl = $('#success');
|
||||||
|
|
||||||
$('#reset').on('click', function () {
|
$('#reset').on('click', function () {
|
||||||
if (inputEl.val() && inputEl.val().indexOf('@') !== -1) {
|
if (inputEl.val() && inputEl.val().indexOf('@') !== -1) {
|
||||||
|
|||||||
@@ -128,7 +128,8 @@ define('forum/search', ['search', 'autocomplete'], function (searchModule, autoc
|
|||||||
var regex = new RegExp('(' + regexStr + ')', 'gi');
|
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 = [];
|
var result = $(this);
|
||||||
|
var nested = [];
|
||||||
|
|
||||||
result.find('*').each(function () {
|
result.find('*').each(function () {
|
||||||
$(this).after('<!-- ' + nested.length + ' -->');
|
$(this).after('<!-- ' + nested.length + ' -->');
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ define('forum/topic', [
|
|||||||
'sort',
|
'sort',
|
||||||
'components',
|
'components',
|
||||||
], function (infinitescroll, threadTools, postTools, events, posts, replies, navigator, sort, components) {
|
], function (infinitescroll, threadTools, postTools, events, posts, replies, navigator, sort, components) {
|
||||||
var Topic = {},
|
var Topic = {};
|
||||||
currentUrl = '';
|
var currentUrl = '';
|
||||||
|
|
||||||
$(window).on('action:ajaxify.start', function (ev, data) {
|
$(window).on('action:ajaxify.start', function (ev, data) {
|
||||||
if (Topic.replaceURLTimeout) {
|
if (Topic.replaceURLTimeout) {
|
||||||
@@ -112,8 +112,8 @@ define('forum/topic', [
|
|||||||
mousetrap.bind('ctrl+f', function (e) {
|
mousetrap.bind('ctrl+f', function (e) {
|
||||||
if (config.topicSearchEnabled) {
|
if (config.topicSearchEnabled) {
|
||||||
// If in topic, open search window and populate, otherwise regular behaviour
|
// If in topic, open search window and populate, otherwise regular behaviour
|
||||||
var match = ajaxify.currentPage.match(/^topic\/([\d]+)/),
|
var match = ajaxify.currentPage.match(/^topic\/([\d]+)/);
|
||||||
tid;
|
var tid;
|
||||||
if (match) {
|
if (match) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
tid = match[1];
|
tid = match[1];
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
define('forum/topic/flag', [], function () {
|
define('forum/topic/flag', [], function () {
|
||||||
|
|
||||||
var Flag = {},
|
var Flag = {};
|
||||||
flagModal,
|
var flagModal;
|
||||||
flagCommit;
|
var flagCommit;
|
||||||
|
|
||||||
Flag.showFlagModal = function (pid, username, userslug) {
|
Flag.showFlagModal = function (pid, username, userslug) {
|
||||||
parseModal({
|
parseModal({
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ define('forum/topic/move-post', [], function () {
|
|||||||
app.parseAndTranslate('partials/move_post_modal', {}, function (html) {
|
app.parseAndTranslate('partials/move_post_modal', {}, function (html) {
|
||||||
var moveModal = $(html);
|
var moveModal = $(html);
|
||||||
|
|
||||||
var moveBtn = moveModal.find('#move_post_commit'),
|
var moveBtn = moveModal.find('#move_post_commit');
|
||||||
topicId = moveModal.find('#topicId');
|
var topicId = moveModal.find('#topicId');
|
||||||
|
|
||||||
moveModal.on('hidden.bs.modal', function () {
|
moveModal.on('hidden.bs.modal', function () {
|
||||||
moveModal.remove();
|
moveModal.remove();
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
define('forum/topic/move', function () {
|
define('forum/topic/move', function () {
|
||||||
|
|
||||||
var Move = {},
|
var Move = {};
|
||||||
modal,
|
var modal;
|
||||||
selectedEl;
|
var selectedEl;
|
||||||
|
|
||||||
Move.init = function (tids, currentCid, onComplete) {
|
Move.init = function (tids, currentCid, onComplete) {
|
||||||
Move.tids = tids;
|
Move.tids = tids;
|
||||||
|
|||||||
@@ -165,7 +165,8 @@ define('forum/topic/posts', [
|
|||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
var after, before;
|
var after;
|
||||||
|
var before;
|
||||||
|
|
||||||
if (direction > 0 && repliesSelector.length) {
|
if (direction > 0 && repliesSelector.length) {
|
||||||
after = repliesSelector.last();
|
after = repliesSelector.last();
|
||||||
@@ -188,8 +189,8 @@ define('forum/topic/posts', [
|
|||||||
html.insertAfter(after);
|
html.insertAfter(after);
|
||||||
} else if (before) {
|
} else if (before) {
|
||||||
// Save document height and position for future reference (about 5 lines down)
|
// Save document height and position for future reference (about 5 lines down)
|
||||||
var height = $(document).height(),
|
var height = $(document).height();
|
||||||
scrollTop = $(window).scrollTop();
|
var scrollTop = $(window).scrollTop();
|
||||||
|
|
||||||
html.insertBefore(before);
|
html.insertBefore(before);
|
||||||
|
|
||||||
@@ -290,40 +291,42 @@ define('forum/topic/posts', [
|
|||||||
default
|
default
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var images = components.get('post/content').find('img[data-state="unloaded"]'),
|
var images = components.get('post/content').find('img[data-state="unloaded"]');
|
||||||
visible = images.filter(function () {
|
var visible = images.filter(function () {
|
||||||
return utils.isElementInViewport(this);
|
return utils.isElementInViewport(this);
|
||||||
}),
|
});
|
||||||
posts = $.unique(visible.map(function () {
|
var posts = $.unique(visible.map(function () {
|
||||||
return $(this).parents('[component="post"]').get(0);
|
return $(this).parents('[component="post"]').get(0);
|
||||||
})),
|
}));
|
||||||
scrollTop = $(window).scrollTop(),
|
var scrollTop = $(window).scrollTop();
|
||||||
adjusting = false,
|
var adjusting = false;
|
||||||
adjustQueue = [],
|
var adjustQueue = [];
|
||||||
adjustPosition = function () {
|
var oldHeight;
|
||||||
adjusting = true;
|
var newHeight;
|
||||||
oldHeight = document.body.clientHeight;
|
|
||||||
|
|
||||||
// Display the image
|
function adjustPosition() {
|
||||||
$(this).attr('data-state', 'loaded');
|
adjusting = true;
|
||||||
newHeight = document.body.clientHeight;
|
oldHeight = document.body.clientHeight;
|
||||||
|
|
||||||
var imageRect = this.getBoundingClientRect();
|
// Display the image
|
||||||
if (imageRect.top < threshold) {
|
$(this).attr('data-state', 'loaded');
|
||||||
scrollTop = scrollTop + (newHeight - oldHeight);
|
newHeight = document.body.clientHeight;
|
||||||
$(window).scrollTop(scrollTop);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (adjustQueue.length) {
|
var imageRect = this.getBoundingClientRect();
|
||||||
adjustQueue.pop()();
|
if (imageRect.top < threshold) {
|
||||||
} else {
|
scrollTop = scrollTop + (newHeight - oldHeight);
|
||||||
adjusting = false;
|
$(window).scrollTop(scrollTop);
|
||||||
|
}
|
||||||
|
|
||||||
Posts.wrapImagesInLinks(posts);
|
if (adjustQueue.length) {
|
||||||
posts.length = 0;
|
adjustQueue.pop()();
|
||||||
}
|
} else {
|
||||||
},
|
adjusting = false;
|
||||||
oldHeight, newHeight;
|
|
||||||
|
Posts.wrapImagesInLinks(posts);
|
||||||
|
posts.length = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// For each image, reset the source and adjust scrollTop when loaded
|
// For each image, reset the source and adjust scrollTop when loaded
|
||||||
visible.attr('data-state', 'loading');
|
visible.attr('data-state', 'loading');
|
||||||
@@ -346,9 +349,9 @@ define('forum/topic/posts', [
|
|||||||
|
|
||||||
Posts.wrapImagesInLinks = function (posts) {
|
Posts.wrapImagesInLinks = function (posts) {
|
||||||
posts.find('[component="post/content"] img:not(.emoji)').each(function () {
|
posts.find('[component="post/content"] img:not(.emoji)').each(function () {
|
||||||
var $this = $(this),
|
var $this = $(this);
|
||||||
src = $this.attr('src'),
|
var src = $this.attr('src');
|
||||||
suffixRegex = /-resized(\.[\w]+)?$/;
|
var suffixRegex = /-resized(\.[\w]+)?$/;
|
||||||
|
|
||||||
if (src === 'about:blank') {
|
if (src === 'about:blank') {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ define('forum/topic/votes', ['components', 'translator'], function (components,
|
|||||||
|
|
||||||
|
|
||||||
Votes.toggleVote = function (button, className, method) {
|
Votes.toggleVote = function (button, className, method) {
|
||||||
var post = button.parents('[data-pid]'),
|
var post = button.parents('[data-pid]');
|
||||||
currentState = post.find(className).length;
|
var currentState = post.find(className).length;
|
||||||
|
|
||||||
socket.emit(currentState ? 'posts.unvote' : method , {
|
socket.emit(currentState ? 'posts.unvote' : method , {
|
||||||
pid: post.attr('data-pid'),
|
pid: post.attr('data-pid'),
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ $('document').ready(function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function activate(type, el) {
|
function activate(type, el) {
|
||||||
var field = el.val(),
|
var field = el.val();
|
||||||
parent = el.parents('.input-row'),
|
var parent = el.parents('.input-row');
|
||||||
help = parent.children('.help-text');
|
var help = parent.children('.help-text');
|
||||||
|
|
||||||
function validateUsername(field) {
|
function validateUsername(field) {
|
||||||
if (!utils.isUserNameValid(field) || !utils.slugify(field)) {
|
if (!utils.isUserNameValid(field) || !utils.slugify(field)) {
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ define('coverPhoto', [
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var files = e.originalEvent.dataTransfer.files,
|
var files = e.originalEvent.dataTransfer.files;
|
||||||
reader = new FileReader();
|
var reader = new FileReader();
|
||||||
|
|
||||||
if (files.length && files[0].type.match('image.*')) {
|
if (files.length && files[0].type.match('image.*')) {
|
||||||
reader.onload = function (e) {
|
reader.onload = function (e) {
|
||||||
|
|||||||
@@ -37,19 +37,19 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
helpers.buildMetaTag = function (tag) {
|
helpers.buildMetaTag = function (tag) {
|
||||||
var name = tag.name ? 'name="' + tag.name + '" ' : '',
|
var name = tag.name ? 'name="' + tag.name + '" ' : '';
|
||||||
property = tag.property ? 'property="' + tag.property + '" ' : '',
|
var property = tag.property ? 'property="' + tag.property + '" ' : '';
|
||||||
content = tag.content ? 'content="' + tag.content.replace(/\n/g, ' ') + '" ' : '';
|
var content = tag.content ? 'content="' + tag.content.replace(/\n/g, ' ') + '" ' : '';
|
||||||
|
|
||||||
return '<meta ' + name + property + content + '/>\n\t';
|
return '<meta ' + name + property + content + '/>\n\t';
|
||||||
};
|
};
|
||||||
|
|
||||||
helpers.buildLinkTag = function (tag) {
|
helpers.buildLinkTag = function (tag) {
|
||||||
var link = tag.link ? 'link="' + tag.link + '" ' : '',
|
var link = tag.link ? 'link="' + tag.link + '" ' : '';
|
||||||
rel = tag.rel ? 'rel="' + tag.rel + '" ' : '',
|
var rel = tag.rel ? 'rel="' + tag.rel + '" ' : '';
|
||||||
type = tag.type ? 'type="' + tag.type + '" ' : '',
|
var type = tag.type ? 'type="' + tag.type + '" ' : '';
|
||||||
href = tag.href ? 'href="' + tag.href + '" ' : '',
|
var href = tag.href ? 'href="' + tag.href + '" ' : '';
|
||||||
sizes = tag.sizes ? 'sizes="' + tag.sizes + '" ' : '';
|
var sizes = tag.sizes ? 'sizes="' + tag.sizes + '" ' : '';
|
||||||
|
|
||||||
return '<link ' + link + rel + type + sizes + href + '/>\n\t';
|
return '<link ' + link + rel + type + sizes + href + '/>\n\t';
|
||||||
};
|
};
|
||||||
@@ -285,5 +285,5 @@
|
|||||||
}(
|
}(
|
||||||
typeof exports === 'object' ? exports :
|
typeof exports === 'object' ? exports :
|
||||||
typeof define === 'function' && define.amd ? {} :
|
typeof define === 'function' && define.amd ? {} :
|
||||||
helpers = {},
|
helpers = {}
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ define('iconSelect', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
picker.on('show.bs.modal', function () {
|
picker.on('show.bs.modal', function () {
|
||||||
var modalEl = $(this),
|
var modalEl = $(this);
|
||||||
searchEl = modalEl.find('input');
|
var searchEl = modalEl.find('input');
|
||||||
|
|
||||||
if (selected) {
|
if (selected) {
|
||||||
modalEl.find('.' + selected).addClass('selected');
|
modalEl.find('.' + selected).addClass('selected');
|
||||||
@@ -72,10 +72,10 @@ define('iconSelect', function () {
|
|||||||
}).modal('show');
|
}).modal('show');
|
||||||
|
|
||||||
picker.on('shown.bs.modal', function () {
|
picker.on('shown.bs.modal', function () {
|
||||||
var modalEl = $(this),
|
var modalEl = $(this);
|
||||||
searchEl = modalEl.find('input'),
|
var searchEl = modalEl.find('input');
|
||||||
icons = modalEl.find('.fa-icons i'),
|
var icons = modalEl.find('.fa-icons i');
|
||||||
submitEl = modalEl.find('button.btn-primary');
|
var submitEl = modalEl.find('button.btn-primary');
|
||||||
|
|
||||||
function changeSelection(newSelection) {
|
function changeSelection(newSelection) {
|
||||||
modalEl.find('i.selected').removeClass('selected');
|
modalEl.find('i.selected').removeClass('selected');
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ define('notifications', ['sounds', 'translator', 'components'], function (sound,
|
|||||||
var unreadNotifs = {};
|
var unreadNotifs = {};
|
||||||
|
|
||||||
Notifications.prepareDOM = function () {
|
Notifications.prepareDOM = function () {
|
||||||
var notifContainer = components.get('notifications'),
|
var notifContainer = components.get('notifications');
|
||||||
notifTrigger = notifContainer.children('a'),
|
var notifTrigger = notifContainer.children('a');
|
||||||
notifList = components.get('notifications/list'),
|
var notifList = components.get('notifications/list');
|
||||||
notifIcon = components.get('notifications/icon');
|
var notifIcon = components.get('notifications/icon');
|
||||||
|
|
||||||
notifTrigger
|
notifTrigger
|
||||||
.on('click', function (e) {
|
.on('click', function (e) {
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ define('settings', function () {
|
|||||||
'settings/object',
|
'settings/object',
|
||||||
];
|
];
|
||||||
|
|
||||||
var Settings,
|
var Settings;
|
||||||
onReady = [],
|
var onReady = [];
|
||||||
waitingJobs = 0,
|
var waitingJobs = 0;
|
||||||
helper;
|
var helper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the hook of given name that matches the given type or element.
|
Returns the hook of given name that matches the given type or element.
|
||||||
@@ -24,7 +24,8 @@ define('settings', function () {
|
|||||||
@param name The name of the hook.
|
@param name The name of the hook.
|
||||||
*/
|
*/
|
||||||
function getHook(type, name) {
|
function getHook(type, name) {
|
||||||
var hook, plugin;
|
var hook;
|
||||||
|
var plugin;
|
||||||
if (typeof type !== 'string') {
|
if (typeof type !== 'string') {
|
||||||
type = $(type);
|
type = $(type);
|
||||||
type = type.data('type') || type.attr('type') || type.prop('tagName');
|
type = type.data('type') || type.attr('type') || type.prop('tagName');
|
||||||
@@ -99,7 +100,8 @@ define('settings', function () {
|
|||||||
@returns JQuery The created element.
|
@returns JQuery The created element.
|
||||||
*/
|
*/
|
||||||
createElementOfType: function (type, tagName, data) {
|
createElementOfType: function (type, tagName, data) {
|
||||||
var element, hook = getHook(type, 'create');
|
var element;
|
||||||
|
var hook = getHook(type, 'create');
|
||||||
if (hook != null) {
|
if (hook != null) {
|
||||||
element = $(hook.call(Settings, type, tagName, data));
|
element = $(hook.call(Settings, type, tagName, data));
|
||||||
} else {
|
} else {
|
||||||
@@ -151,11 +153,11 @@ define('settings', function () {
|
|||||||
@returns Object The value of the element.
|
@returns Object The value of the element.
|
||||||
*/
|
*/
|
||||||
readValue: function (element) {
|
readValue: function (element) {
|
||||||
var empty = !helper.isFalse(element.data('empty')),
|
var empty = !helper.isFalse(element.data('empty'));
|
||||||
trim = !helper.isFalse(element.data('trim')),
|
var trim = !helper.isFalse(element.data('trim'));
|
||||||
split = element.data('split'),
|
var split = element.data('split');
|
||||||
hook = getHook(element, 'get'),
|
var hook = getHook(element, 'get');
|
||||||
value;
|
var value;
|
||||||
if (hook != null) {
|
if (hook != null) {
|
||||||
return hook.call(Settings, element, trim, empty);
|
return hook.call(Settings, element, trim, empty);
|
||||||
}
|
}
|
||||||
@@ -183,8 +185,8 @@ define('settings', function () {
|
|||||||
@param value The value to set.
|
@param value The value to set.
|
||||||
*/
|
*/
|
||||||
fillField: function (element, value) {
|
fillField: function (element, value) {
|
||||||
var hook = getHook(element, 'set'),
|
var hook = getHook(element, 'set');
|
||||||
trim = element.data('trim');
|
var trim = element.data('trim');
|
||||||
trim = trim !== 'false' && +trim !== 0;
|
trim = trim !== 'false' && +trim !== 0;
|
||||||
if (hook != null) {
|
if (hook != null) {
|
||||||
return hook.call(Settings, element, value, trim);
|
return hook.call(Settings, element, value, trim);
|
||||||
@@ -218,9 +220,9 @@ define('settings', function () {
|
|||||||
initFields: function (wrapper) {
|
initFields: function (wrapper) {
|
||||||
$('[data-key]', wrapper).each(function (ignored, field) {
|
$('[data-key]', wrapper).each(function (ignored, field) {
|
||||||
field = $(field);
|
field = $(field);
|
||||||
var hook = getHook(field, 'init'),
|
var hook = getHook(field, 'init');
|
||||||
keyParts = field.data('key').split('.'),
|
var keyParts = field.data('key').split('.');
|
||||||
value = Settings.get();
|
var value = Settings.get();
|
||||||
if (hook != null) {
|
if (hook != null) {
|
||||||
hook.call(Settings, field);
|
hook.call(Settings, field);
|
||||||
}
|
}
|
||||||
@@ -408,17 +410,17 @@ define('settings', function () {
|
|||||||
@param notify Whether to send notification when settings got saved.
|
@param notify Whether to send notification when settings got saved.
|
||||||
*/
|
*/
|
||||||
persist: function (hash, wrapper, callback, notify) {
|
persist: function (hash, wrapper, callback, notify) {
|
||||||
var notSaved = [],
|
var notSaved = [];
|
||||||
fields = $('[data-key]', wrapper || 'form').toArray();
|
var fields = $('[data-key]', wrapper || 'form').toArray();
|
||||||
if (notify == null) {
|
if (notify == null) {
|
||||||
notify = true;
|
notify = true;
|
||||||
}
|
}
|
||||||
for (var i = 0; i < fields.length; i++) {
|
for (var i = 0; i < fields.length; i++) {
|
||||||
var field = $(fields[i]),
|
var field = $(fields[i]);
|
||||||
value = helper.readValue(field),
|
var value = helper.readValue(field);
|
||||||
parentCfg = Settings.get(),
|
var parentCfg = Settings.get();
|
||||||
keyParts = field.data('key').split('.'),
|
var keyParts = field.data('key').split('.');
|
||||||
lastKey = keyParts[keyParts.length - 1];
|
var lastKey = keyParts[keyParts.length - 1];
|
||||||
if (keyParts.length > 1) {
|
if (keyParts.length > 1) {
|
||||||
for (var j = 0; j < keyParts.length - 1; j++) {
|
for (var j = 0; j < keyParts.length - 1; j++) {
|
||||||
var part = keyParts[j];
|
var part = keyParts[j];
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
define('settings/array', function () {
|
define('settings/array', function () {
|
||||||
|
|
||||||
var Settings = null,
|
var Settings = null;
|
||||||
SettingsArray,
|
var SettingsArray;
|
||||||
helper = null;
|
var helper = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates a new button that removes itself and the given elements on click.
|
Creates a new button that removes itself and the given elements on click.
|
||||||
@@ -41,8 +41,8 @@ define('settings/array', function () {
|
|||||||
*/
|
*/
|
||||||
function addArrayChildElement(field, key, attributes, value, separator, insertCb) {
|
function addArrayChildElement(field, key, attributes, value, separator, insertCb) {
|
||||||
attributes = helper.deepClone(attributes);
|
attributes = helper.deepClone(attributes);
|
||||||
var type = attributes['data-type'] || attributes.type || 'text',
|
var type = attributes['data-type'] || attributes.type || 'text';
|
||||||
element = $(helper.createElementOfType(type, attributes.tagName, attributes));
|
var element = $(helper.createElementOfType(type, attributes.tagName, attributes));
|
||||||
element.attr('data-parent', '_' + key);
|
element.attr('data-parent', '_' + key);
|
||||||
delete attributes['data-type'];
|
delete attributes['data-type'];
|
||||||
delete attributes['tagName'];
|
delete attributes['tagName'];
|
||||||
@@ -72,12 +72,12 @@ define('settings/array', function () {
|
|||||||
@param separator The separator to forward to {@link addArrayChildElement}.
|
@param separator The separator to forward to {@link addArrayChildElement}.
|
||||||
*/
|
*/
|
||||||
function addAddButton(element, key, attributes, separator) {
|
function addAddButton(element, key, attributes, separator) {
|
||||||
var addSpace = $(document.createTextNode(' ')),
|
var addSpace = $(document.createTextNode(' '));
|
||||||
newValue = element.data('new') || '',
|
var newValue = element.data('new') || '';
|
||||||
add = $(helper.createElement('button', {
|
var add = $(helper.createElement('button', {
|
||||||
"class": 'btn btn-sm btn-primary add',
|
"class": 'btn btn-sm btn-primary add',
|
||||||
title: 'Expand Array',
|
title: 'Expand Array',
|
||||||
}, '+'));
|
}, '+'));
|
||||||
add.click(function (event) {
|
add.click(function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
addArrayChildElement(element, key, attributes, newValue, separator.clone(), function (el) {
|
addArrayChildElement(element, key, attributes, newValue, separator.clone(), function (el) {
|
||||||
@@ -98,9 +98,9 @@ define('settings/array', function () {
|
|||||||
return helper.createElement(tagName || 'div');
|
return helper.createElement(tagName || 'div');
|
||||||
},
|
},
|
||||||
set: function (element, value) {
|
set: function (element, value) {
|
||||||
var attributes = element.data('attributes'),
|
var attributes = element.data('attributes');
|
||||||
key = element.data('key') || element.data('parent'),
|
var key = element.data('key') || element.data('parent');
|
||||||
separator = element.data('split') || ', ';
|
var separator = element.data('split') || ', ';
|
||||||
separator = (function () {
|
separator = (function () {
|
||||||
try {
|
try {
|
||||||
return $(separator);
|
return $(separator);
|
||||||
@@ -123,13 +123,13 @@ define('settings/array', function () {
|
|||||||
addAddButton(element, key, attributes, separator);
|
addAddButton(element, key, attributes, separator);
|
||||||
},
|
},
|
||||||
get: function (element, trim, empty) {
|
get: function (element, trim, empty) {
|
||||||
var key = element.data('key') || element.data('parent'),
|
var key = element.data('key') || element.data('parent');
|
||||||
children = $("[data-parent=\"_" + key + "\"]", element),
|
var children = $("[data-parent=\"_" + key + "\"]", element);
|
||||||
values = [];
|
var values = [];
|
||||||
children.each(function (i, child) {
|
children.each(function (i, child) {
|
||||||
child = $(child);
|
child = $(child);
|
||||||
var val = helper.readValue(child),
|
var val = helper.readValue(child);
|
||||||
empty = helper.isTrue(child.data('empty'));
|
var empty = helper.isTrue(child.data('empty'));
|
||||||
if (empty || val !== void 0 && (val == null || val.length !== 0)) {
|
if (empty || val !== void 0 && (val == null || val.length !== 0)) {
|
||||||
return values.push(val);
|
return values.push(val);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
define('settings/checkbox', function () {
|
define('settings/checkbox', function () {
|
||||||
|
|
||||||
var Settings = null,
|
var Settings = null;
|
||||||
SettingsCheckbox;
|
var SettingsCheckbox;
|
||||||
|
|
||||||
SettingsCheckbox = {
|
SettingsCheckbox = {
|
||||||
types: ['checkbox'],
|
types: ['checkbox'],
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
define('settings/key', function () {
|
define('settings/key', function () {
|
||||||
|
|
||||||
var Settings = null,
|
var Settings = null;
|
||||||
SettingsKey,
|
var SettingsKey;
|
||||||
helper = null,
|
var helper = null;
|
||||||
lastKey = null,
|
var lastKey = null;
|
||||||
oldKey = null,
|
var oldKey = null;
|
||||||
keyMap = Object.freeze({
|
var keyMap = Object.freeze({
|
||||||
0: '',
|
0: '',
|
||||||
8: 'Backspace',
|
8: 'Backspace',
|
||||||
9: 'Tab',
|
9: 'Tab',
|
||||||
13: 'Enter',
|
13: 'Enter',
|
||||||
27: 'Escape',
|
27: 'Escape',
|
||||||
32: 'Space',
|
32: 'Space',
|
||||||
37: 'Left',
|
37: 'Left',
|
||||||
38: 'Up',
|
38: 'Up',
|
||||||
39: 'Right',
|
39: 'Right',
|
||||||
40: 'Down',
|
40: 'Down',
|
||||||
45: 'Insert',
|
45: 'Insert',
|
||||||
46: 'Delete',
|
46: 'Delete',
|
||||||
187: '=',
|
187: '=',
|
||||||
189: '-',
|
189: '-',
|
||||||
190: '.',
|
190: '.',
|
||||||
191: '/',
|
191: '/',
|
||||||
219: '[',
|
219: '[',
|
||||||
220: '\\',
|
220: '\\',
|
||||||
221: ']',
|
221: ']',
|
||||||
});
|
});
|
||||||
|
|
||||||
function Key() {
|
function Key() {
|
||||||
this.c = false;
|
this.c = false;
|
||||||
@@ -42,9 +42,9 @@ define('settings/key', function () {
|
|||||||
@returns Key | null The Key-Object the focused element should be set to.
|
@returns Key | null The Key-Object the focused element should be set to.
|
||||||
*/
|
*/
|
||||||
function getKey(event) {
|
function getKey(event) {
|
||||||
var anyModChange = event.ctrlKey !== lastKey.c || event.altKey !== lastKey.a || event.shiftKey !== lastKey.s || event.metaKey !== lastKey.m,
|
var anyModChange = event.ctrlKey !== lastKey.c || event.altKey !== lastKey.a || event.shiftKey !== lastKey.s || event.metaKey !== lastKey.m;
|
||||||
modChange = event.ctrlKey + event.altKey + event.shiftKey + event.metaKey - lastKey.c - lastKey.a - lastKey.s - lastKey.m,
|
var modChange = event.ctrlKey + event.altKey + event.shiftKey + event.metaKey - lastKey.c - lastKey.a - lastKey.s - lastKey.m;
|
||||||
key = new Key();
|
var key = new Key();
|
||||||
key.c = event.ctrlKey;
|
key.c = event.ctrlKey;
|
||||||
key.a = event.altKey;
|
key.a = event.altKey;
|
||||||
key.s = event.shiftKey;
|
key.s = event.shiftKey;
|
||||||
@@ -128,9 +128,9 @@ define('settings/key', function () {
|
|||||||
if (str instanceof Key) {
|
if (str instanceof Key) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
var key = new Key(),
|
var key = new Key();
|
||||||
sep = /([^CtrlAShifMea#\d]+)(?:#|\d)/.exec(str),
|
var sep = /([^CtrlAShifMea#\d]+)(?:#|\d)/.exec(str);
|
||||||
parts = sep != null ? str.split(sep[1]) : [str];
|
var parts = sep != null ? str.split(sep[1]) : [str];
|
||||||
for (var i = 0; i < parts.length; i++) {
|
for (var i = 0; i < parts.length; i++) {
|
||||||
var part = parts[i];
|
var part = parts[i];
|
||||||
switch (part) {
|
switch (part) {
|
||||||
@@ -199,9 +199,9 @@ define('settings/key', function () {
|
|||||||
element.val(getKeyString(key, true, false, ' + '));
|
element.val(getKeyString(key, true, false, ' + '));
|
||||||
},
|
},
|
||||||
get: function (element, trim, empty) {
|
get: function (element, trim, empty) {
|
||||||
var key = element.data('keyData'),
|
var key = element.data('keyData');
|
||||||
separator = element.data('split') || element.data('separator') || '+',
|
var separator = element.data('split') || element.data('separator') || '+';
|
||||||
short = !helper.isFalse(element.data('short'));
|
var short = !helper.isFalse(element.data('short'));
|
||||||
if (trim) {
|
if (trim) {
|
||||||
if (empty || (key != null && key.char)) {
|
if (empty || (key != null && key.char)) {
|
||||||
return getKeyString(key, false, short, separator);
|
return getKeyString(key, false, short, separator);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
define('settings/object', function () {
|
define('settings/object', function () {
|
||||||
|
|
||||||
var Settings = null,
|
var Settings = null;
|
||||||
SettingsObject,
|
var SettingsObject;
|
||||||
helper = null;
|
var helper = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates a new child-element of given property with given data and calls given callback with elements to add.
|
Creates a new child-element of given property with given data and calls given callback with elements to add.
|
||||||
@@ -15,9 +15,10 @@ define('settings/object', function () {
|
|||||||
@param insertCb The callback to insert the elements.
|
@param insertCb The callback to insert the elements.
|
||||||
*/
|
*/
|
||||||
function addObjectPropertyElement(field, key, attributes, prop, value, separator, insertCb) {
|
function addObjectPropertyElement(field, key, attributes, prop, value, separator, insertCb) {
|
||||||
var prepend = attributes['data-prepend'],
|
var prepend = attributes['data-prepend'];
|
||||||
append = attributes['data-append'],
|
var append = attributes['data-append'];
|
||||||
type, element;
|
var type;
|
||||||
|
var element;
|
||||||
delete attributes['data-prepend'];
|
delete attributes['data-prepend'];
|
||||||
delete attributes['data-append'];
|
delete attributes['data-append'];
|
||||||
attributes = helper.deepClone(attributes);
|
attributes = helper.deepClone(attributes);
|
||||||
@@ -59,10 +60,12 @@ define('settings/object', function () {
|
|||||||
return helper.createElement(tagName || 'div');
|
return helper.createElement(tagName || 'div');
|
||||||
},
|
},
|
||||||
set: function (element, value) {
|
set: function (element, value) {
|
||||||
var properties = element.data('attributes') || element.data('properties'),
|
var properties = element.data('attributes') || element.data('properties');
|
||||||
key = element.data('key') || element.data('parent'),
|
var key = element.data('key') || element.data('parent');
|
||||||
separator = element.data('split') || ', ',
|
var separator = element.data('split') || ', ';
|
||||||
propertyIndex, propertyName, attributes;
|
var propertyIndex;
|
||||||
|
var propertyName;
|
||||||
|
var attributes;
|
||||||
separator = (function () {
|
separator = (function () {
|
||||||
try {
|
try {
|
||||||
return $(separator);
|
return $(separator);
|
||||||
@@ -91,14 +94,14 @@ define('settings/object', function () {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
get: function (element, trim, empty) {
|
get: function (element, trim, empty) {
|
||||||
var key = element.data('key') || element.data('parent'),
|
var key = element.data('key') || element.data('parent');
|
||||||
properties = $('[data-parent="_' + key + '"]', element),
|
var properties = $('[data-parent="_' + key + '"]', element);
|
||||||
value = {};
|
var value = {};
|
||||||
properties.each(function (i, property) {
|
properties.each(function (i, property) {
|
||||||
property = $(property);
|
property = $(property);
|
||||||
var val = helper.readValue(property),
|
var val = helper.readValue(property);
|
||||||
prop = property.data('prop'),
|
var prop = property.data('prop');
|
||||||
empty = helper.isTrue(property.data('empty'));
|
var empty = helper.isTrue(property.data('empty'));
|
||||||
if (empty || val !== void 0 && (val == null || val.length !== 0)) {
|
if (empty || val !== void 0 && (val == null || val.length !== 0)) {
|
||||||
return value[prop] = val;
|
return value[prop] = val;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
define('settings/select', function () {
|
define('settings/select', function () {
|
||||||
|
|
||||||
var Settings = null,
|
var Settings = null;
|
||||||
SettingsSelect;
|
var SettingsSelect;
|
||||||
|
|
||||||
function addOptions(element, options) {
|
function addOptions(element, options) {
|
||||||
for (var i = 0; i < options.length; i++) {
|
for (var i = 0; i < options.length; i++) {
|
||||||
var optionData = options[i],
|
var optionData = options[i];
|
||||||
value = optionData.text || optionData.value;
|
var value = optionData.text || optionData.value;
|
||||||
delete optionData.text;
|
delete optionData.text;
|
||||||
element.append($(Settings.helper.createElement('option', optionData)).text(value));
|
element.append($(Settings.helper.createElement('option', optionData)).text(value));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
define('settings/textarea', function () {
|
define('settings/textarea', function () {
|
||||||
|
|
||||||
var Settings = null,
|
var Settings = null;
|
||||||
SettingsArea;
|
var SettingsArea;
|
||||||
|
|
||||||
SettingsArea = {
|
SettingsArea = {
|
||||||
types: ['textarea'],
|
types: ['textarea'],
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ define('taskbar', function () {
|
|||||||
$(document.body).append(self.taskbar);
|
$(document.body).append(self.taskbar);
|
||||||
|
|
||||||
self.taskbar.on('click', 'li', function () {
|
self.taskbar.on('click', 'li', function () {
|
||||||
var $btn = $(this),
|
var $btn = $(this);
|
||||||
module = $btn.attr('data-module'),
|
var module = $btn.attr('data-module');
|
||||||
uuid = $btn.attr('data-uuid');
|
var uuid = $btn.attr('data-uuid');
|
||||||
|
|
||||||
require([module], function (module) {
|
require([module], function (module) {
|
||||||
if (!$btn.hasClass('active')) {
|
if (!$btn.hasClass('active')) {
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
(function (module) {
|
(function (module) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var utils, fs, XRegExp;
|
var utils;
|
||||||
|
var fs;
|
||||||
|
var XRegExp;
|
||||||
|
|
||||||
if ('undefined' === typeof window) {
|
if ('undefined' === typeof window) {
|
||||||
fs = require('fs');
|
fs = require('fs');
|
||||||
@@ -24,8 +26,8 @@
|
|||||||
module.exports = utils = {
|
module.exports = utils = {
|
||||||
generateUUID: function () {
|
generateUUID: function () {
|
||||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||||
var r = Math.random() * 16 | 0,
|
var r = Math.random() * 16 | 0;
|
||||||
v = c === 'x' ? r : (r & 0x3 | 0x8);
|
var v = c === 'x' ? r : (r & 0x3 | 0x8);
|
||||||
return v.toString(16);
|
return v.toString(16);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -143,7 +145,9 @@
|
|||||||
|
|
||||||
// shallow objects merge
|
// shallow objects merge
|
||||||
merge: function () {
|
merge: function () {
|
||||||
var result = {}, obj, keys;
|
var result = {};
|
||||||
|
var obj;
|
||||||
|
var keys;
|
||||||
for (var i = 0; i < arguments.length; i++) {
|
for (var i = 0; i < arguments.length; i++) {
|
||||||
obj = arguments[i] || {};
|
obj = arguments[i] || {};
|
||||||
keys = Object.keys(obj);
|
keys = Object.keys(obj);
|
||||||
@@ -268,8 +272,8 @@
|
|||||||
|
|
||||||
findBootstrapEnvironment: function () {
|
findBootstrapEnvironment: function () {
|
||||||
//http://stackoverflow.com/questions/14441456/how-to-detect-which-device-view-youre-on-using-twitter-bootstrap-api
|
//http://stackoverflow.com/questions/14441456/how-to-detect-which-device-view-youre-on-using-twitter-bootstrap-api
|
||||||
var envs = ['xs', 'sm', 'md', 'lg'],
|
var envs = ['xs', 'sm', 'md', 'lg'];
|
||||||
$el = $('<div>');
|
var $el = $('<div>');
|
||||||
|
|
||||||
$el.appendTo($('body'));
|
$el.appendTo($('body'));
|
||||||
|
|
||||||
@@ -292,8 +296,8 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
getHoursArray: function () {
|
getHoursArray: function () {
|
||||||
var currentHour = new Date().getHours(),
|
var currentHour = new Date().getHours();
|
||||||
labels = [];
|
var labels = [];
|
||||||
|
|
||||||
for (var i = currentHour, ii = currentHour - 24; i > ii; i--) {
|
for (var i = currentHour, ii = currentHour - 24; i > ii; i--) {
|
||||||
var hour = i < 0 ? 24 + i : i;
|
var hour = i < 0 ? 24 + i : i;
|
||||||
@@ -304,10 +308,10 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
getDaysArray: function (from) {
|
getDaysArray: function (from) {
|
||||||
var currentDay = new Date(from || Date.now()).getTime(),
|
var currentDay = new Date(from || Date.now()).getTime();
|
||||||
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
||||||
labels = [],
|
var labels = [];
|
||||||
tmpDate;
|
var tmpDate;
|
||||||
|
|
||||||
for(var x = 29; x >= 0; x--) {
|
for(var x = 29; x >= 0; x--) {
|
||||||
tmpDate = new Date(currentDay - (1000 * 60 * 60 * 24 * x));
|
tmpDate = new Date(currentDay - (1000 * 60 * 60 * 24 * x));
|
||||||
@@ -336,7 +340,9 @@
|
|||||||
|
|
||||||
// get all the url params in a single key/value hash
|
// get all the url params in a single key/value hash
|
||||||
params: function (options) {
|
params: function (options) {
|
||||||
var a, hash = {}, params;
|
var a;
|
||||||
|
var hash = {};
|
||||||
|
var params;
|
||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
options.skipToType = options.skipToType || {};
|
options.skipToType = options.skipToType || {};
|
||||||
@@ -347,9 +353,9 @@
|
|||||||
params = (a ? a.search : window.location.search).substring(1).split("&");
|
params = (a ? a.search : window.location.search).substring(1).split("&");
|
||||||
|
|
||||||
params.forEach(function (param) {
|
params.forEach(function (param) {
|
||||||
var val = param.split('='),
|
var val = param.split('=');
|
||||||
key = decodeURI(val[0]),
|
var key = decodeURI(val[0]);
|
||||||
value = options.skipToType[key] ? decodeURI(val[1]) : utils.toType(decodeURI(val[1]));
|
var value = options.skipToType[key] ? decodeURI(val[1]) : utils.toType(decodeURI(val[1]));
|
||||||
|
|
||||||
if (key) {
|
if (key) {
|
||||||
if (key.substr(-2, 2) === '[]') {
|
if (key.substr(-2, 2) === '[]') {
|
||||||
@@ -423,8 +429,8 @@
|
|||||||
}
|
}
|
||||||
return obj[props];
|
return obj[props];
|
||||||
}
|
}
|
||||||
var prop = props.slice(0, i),
|
var prop = props.slice(0, i);
|
||||||
newProps = props.slice(i + 1);
|
var newProps = props.slice(i + 1);
|
||||||
|
|
||||||
if(props !== undefined && !(obj[prop] instanceof Object) ) {
|
if(props !== undefined && !(obj[prop] instanceof Object) ) {
|
||||||
obj[prop] = {};
|
obj[prop] = {};
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ Analytics.pageView = function (payload) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (payload.path) {
|
if (payload.path) {
|
||||||
var categoryMatch = payload.path.match(isCategory),
|
var categoryMatch = payload.path.match(isCategory);
|
||||||
cid = categoryMatch ? parseInt(categoryMatch[1], 10) : null;
|
var cid = categoryMatch ? parseInt(categoryMatch[1], 10) : null;
|
||||||
|
|
||||||
if (cid) {
|
if (cid) {
|
||||||
Analytics.increment(['pageviews:byCid:' + cid]);
|
Analytics.increment(['pageviews:byCid:' + cid]);
|
||||||
@@ -103,8 +103,8 @@ Analytics.writeData = function (callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Analytics.getHourlyStatsForSet = function (set, hour, numHours, callback) {
|
Analytics.getHourlyStatsForSet = function (set, hour, numHours, callback) {
|
||||||
var terms = {},
|
var terms = {};
|
||||||
hoursArr = [];
|
var hoursArr = [];
|
||||||
|
|
||||||
hour = new Date(hour);
|
hour = new Date(hour);
|
||||||
hour.setHours(hour.getHours(), 0, 0, 0);
|
hour.setHours(hour.getHours(), 0, 0, 0);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ exports.processSortedSet = function (setKey, process, options, callback) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
callback,
|
callback
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -105,6 +105,6 @@ exports.processArray = function (array, process, options, callback) {
|
|||||||
},
|
},
|
||||||
function (err) {
|
function (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -293,7 +293,10 @@ var privileges = require('./privileges');
|
|||||||
* @param parentCid {number} start from 0 to build full tree
|
* @param parentCid {number} start from 0 to build full tree
|
||||||
*/
|
*/
|
||||||
Categories.getTree = function (categories, parentCid) {
|
Categories.getTree = function (categories, parentCid) {
|
||||||
var tree = [], i = 0, len = categories.length, category;
|
var tree = [];
|
||||||
|
var i = 0;
|
||||||
|
var len = categories.length;
|
||||||
|
var category;
|
||||||
|
|
||||||
for (i; i < len; ++i) {
|
for (i; i < len; ++i) {
|
||||||
category = categories[i];
|
category = categories[i];
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ profileController.get = function (req, res, callback) {
|
|||||||
property: "og:image:url",
|
property: "og:image:url",
|
||||||
content: userData.picture,
|
content: userData.picture,
|
||||||
noEscape: true,
|
noEscape: true,
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
userData.selectedGroup = userData.groups.find(function (group) {
|
userData.selectedGroup = userData.groups.find(function (group) {
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ themesController.get = function (req, res, next) {
|
|||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
var themeConfig = require(path.join(themeDir, 'theme.json')),
|
var themeConfig = require(path.join(themeDir, 'theme.json'));
|
||||||
screenshotPath = path.join(themeDir, themeConfig.screenshot);
|
var screenshotPath = path.join(themeDir, themeConfig.screenshot);
|
||||||
if (themeConfig.screenshot && file.existsSync(screenshotPath)) {
|
if (themeConfig.screenshot && file.existsSync(screenshotPath)) {
|
||||||
res.sendFile(screenshotPath);
|
res.sendFile(screenshotPath);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -55,9 +55,9 @@ uploadsController.uploadFavicon = function (req, res, next) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
uploadsController.uploadTouchIcon = function (req, res, next) {
|
uploadsController.uploadTouchIcon = function (req, res, next) {
|
||||||
var uploadedFile = req.files.files[0],
|
var uploadedFile = req.files.files[0];
|
||||||
allowedTypes = ['image/png'],
|
var allowedTypes = ['image/png'];
|
||||||
sizes = [36, 48, 72, 96, 144, 192];
|
var sizes = [36, 48, 72, 96, 144, 192];
|
||||||
|
|
||||||
if (validateUpload(req, res, next, uploadedFile, allowedTypes)) {
|
if (validateUpload(req, res, next, uploadedFile, allowedTypes)) {
|
||||||
file.saveFileToLocal('touchicon-orig.png', 'system', uploadedFile.path, function (err, imageObj) {
|
file.saveFileToLocal('touchicon-orig.png', 'system', uploadedFile.path, function (err, imageObj) {
|
||||||
@@ -105,8 +105,8 @@ uploadsController.uploadSound = function (req, res, next) {
|
|||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var soundsPath = path.join(__dirname, '../../../build/public/sounds'),
|
var soundsPath = path.join(__dirname, '../../../build/public/sounds');
|
||||||
filePath = path.join(nconf.get('upload_path'), 'sounds', uploadedFile.name);
|
var filePath = path.join(nconf.get('upload_path'), 'sounds', uploadedFile.name);
|
||||||
|
|
||||||
file.link(filePath, path.join(soundsPath, path.basename(filePath)));
|
file.link(filePath, path.join(soundsPath, path.basename(filePath)));
|
||||||
|
|
||||||
|
|||||||
@@ -343,7 +343,8 @@ authenticationController.localLogin = function (req, username, password, next) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var userslug = utils.slugify(username);
|
var userslug = utils.slugify(username);
|
||||||
var uid, userData = {};
|
var uid;
|
||||||
|
var userData = {};
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
|
|||||||
@@ -259,9 +259,9 @@ module.exports = function (db, module) {
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var map = helpers.toMap(result),
|
var map = helpers.toMap(result);
|
||||||
returnData = [],
|
var returnData = [];
|
||||||
item;
|
var item;
|
||||||
|
|
||||||
for(var i = 0; i < keys.length; ++i) {
|
for(var i = 0; i < keys.length; ++i) {
|
||||||
item = map[keys[i]];
|
item = map[keys[i]];
|
||||||
@@ -500,7 +500,7 @@ module.exports = function (db, module) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
callback,
|
callback
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -198,7 +198,8 @@ module.exports = function (redisClient, module) {
|
|||||||
function sortedSetLex(method, reverse, key, min, max, start, count, callback) {
|
function sortedSetLex(method, reverse, key, min, max, start, count, callback) {
|
||||||
callback = callback || start;
|
callback = callback || start;
|
||||||
|
|
||||||
var minmin, maxmax;
|
var minmin;
|
||||||
|
var maxmax;
|
||||||
if (reverse) {
|
if (reverse) {
|
||||||
minmin = '+';
|
minmin = '+';
|
||||||
maxmax = '-';
|
maxmax = '-';
|
||||||
|
|||||||
@@ -20,30 +20,30 @@ var utils = require('../public/src/utils');
|
|||||||
require('./groups/search')(Groups);
|
require('./groups/search')(Groups);
|
||||||
require('./groups/cover')(Groups);
|
require('./groups/cover')(Groups);
|
||||||
|
|
||||||
var ephemeralGroups = ['guests'],
|
var ephemeralGroups = ['guests'];
|
||||||
|
|
||||||
internals = {
|
var internals = {
|
||||||
getEphemeralGroup: function (groupName) {
|
getEphemeralGroup: function (groupName) {
|
||||||
return {
|
return {
|
||||||
name: groupName,
|
name: groupName,
|
||||||
slug: utils.slugify(groupName),
|
slug: utils.slugify(groupName),
|
||||||
description: '',
|
description: '',
|
||||||
deleted: '0',
|
deleted: '0',
|
||||||
hidden: '0',
|
hidden: '0',
|
||||||
system: '1',
|
system: '1',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
removeEphemeralGroups: function (groups) {
|
removeEphemeralGroups: function (groups) {
|
||||||
var x = groups.length;
|
var x = groups.length;
|
||||||
while(x--) {
|
while(x--) {
|
||||||
if (ephemeralGroups.indexOf(groups[x]) !== -1) {
|
if (ephemeralGroups.indexOf(groups[x]) !== -1) {
|
||||||
groups.splice(x, 1);
|
groups.splice(x, 1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return groups;
|
return groups;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
Groups.internals = internals;
|
Groups.internals = internals;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async'),
|
var async = require('async');
|
||||||
db = require('../database'),
|
var db = require('../database');
|
||||||
plugins = require('../plugins');
|
var plugins = require('../plugins');
|
||||||
|
|
||||||
module.exports = function (Groups) {
|
module.exports = function (Groups) {
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var HotSwap = {},
|
var HotSwap = {};
|
||||||
winston = require('winston'),
|
var winston = require('winston');
|
||||||
stack;
|
var stack;
|
||||||
|
|
||||||
HotSwap.prepare = function (app) {
|
HotSwap.prepare = function (app) {
|
||||||
stack = app._router.stack;
|
stack = app._router.stack;
|
||||||
|
|||||||
14
src/image.js
14
src/image.js
@@ -24,13 +24,13 @@ image.resizeImage = function (data, callback) {
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var w = image.bitmap.width,
|
var w = image.bitmap.width;
|
||||||
h = image.bitmap.height,
|
var h = image.bitmap.height;
|
||||||
origRatio = w / h,
|
var origRatio = w / h;
|
||||||
desiredRatio = data.width && data.height ? data.width / data.height : origRatio,
|
var desiredRatio = data.width && data.height ? data.width / data.height : origRatio;
|
||||||
x = 0,
|
var x = 0;
|
||||||
y = 0,
|
var y = 0;
|
||||||
crop;
|
var crop;
|
||||||
|
|
||||||
if (origRatio !== desiredRatio) {
|
if (origRatio !== desiredRatio) {
|
||||||
if (desiredRatio > origRatio) {
|
if (desiredRatio > origRatio) {
|
||||||
|
|||||||
172
src/install.js
172
src/install.js
@@ -228,84 +228,84 @@ function createAdmin(callback) {
|
|||||||
winston.warn('No administrators have been detected, running initial user setup\n');
|
winston.warn('No administrators have been detected, running initial user setup\n');
|
||||||
|
|
||||||
var questions = [{
|
var questions = [{
|
||||||
name: 'username',
|
name: 'username',
|
||||||
description: 'Administrator username',
|
description: 'Administrator username',
|
||||||
required: true,
|
required: true,
|
||||||
type: 'string',
|
type: 'string',
|
||||||
}, {
|
}, {
|
||||||
name: 'email',
|
name: 'email',
|
||||||
description: 'Administrator email address',
|
description: 'Administrator email address',
|
||||||
pattern: /.+@.+/,
|
pattern: /.+@.+/,
|
||||||
required: true,
|
required: true,
|
||||||
}],
|
}];
|
||||||
passwordQuestions = [{
|
var passwordQuestions = [{
|
||||||
name: 'password',
|
name: 'password',
|
||||||
description: 'Password',
|
description: 'Password',
|
||||||
required: true,
|
required: true,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
type: 'string',
|
type: 'string',
|
||||||
}, {
|
}, {
|
||||||
name: 'password:confirm',
|
name: 'password:confirm',
|
||||||
description: 'Confirm Password',
|
description: 'Confirm Password',
|
||||||
required: true,
|
required: true,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
type: 'string',
|
type: 'string',
|
||||||
}],
|
}];
|
||||||
success = function (err, results) {
|
function success(err, results) {
|
||||||
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
if (!results) {
|
||||||
|
return callback(new Error('aborted'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (results['password:confirm'] !== results.password) {
|
||||||
|
winston.warn("Passwords did not match, please try again");
|
||||||
|
return retryPassword(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (results.password.length < meta.config.minimumPasswordLength) {
|
||||||
|
winston.warn("Password too short, please try again");
|
||||||
|
return retryPassword(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
var adminUid;
|
||||||
|
async.waterfall([
|
||||||
|
function (next) {
|
||||||
|
User.create({username: results.username, password: results.password, email: results.email}, next);
|
||||||
|
},
|
||||||
|
function (uid, next) {
|
||||||
|
adminUid = uid;
|
||||||
|
Groups.join('administrators', uid, next);
|
||||||
|
},
|
||||||
|
function (next) {
|
||||||
|
Groups.show('administrators', next);
|
||||||
|
},
|
||||||
|
function (next) {
|
||||||
|
Groups.ownership.grant(adminUid, 'administrators', next);
|
||||||
|
},
|
||||||
|
], function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
callback(null, password ? results : undefined);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function retryPassword(originalResults) {
|
||||||
|
// Ask only the password questions
|
||||||
|
prompt.get(passwordQuestions, function (err, results) {
|
||||||
if (!results) {
|
if (!results) {
|
||||||
return callback(new Error('aborted'));
|
return callback(new Error('aborted'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (results['password:confirm'] !== results.password) {
|
// Update the original data with newly collected password
|
||||||
winston.warn("Passwords did not match, please try again");
|
originalResults.password = results.password;
|
||||||
return retryPassword(results);
|
originalResults['password:confirm'] = results['password:confirm'];
|
||||||
}
|
|
||||||
|
|
||||||
if (results.password.length < meta.config.minimumPasswordLength) {
|
// Send back to success to handle
|
||||||
winston.warn("Password too short, please try again");
|
success(err, originalResults);
|
||||||
return retryPassword(results);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var adminUid;
|
|
||||||
async.waterfall([
|
|
||||||
function (next) {
|
|
||||||
User.create({username: results.username, password: results.password, email: results.email}, next);
|
|
||||||
},
|
|
||||||
function (uid, next) {
|
|
||||||
adminUid = uid;
|
|
||||||
Groups.join('administrators', uid, next);
|
|
||||||
},
|
|
||||||
function (next) {
|
|
||||||
Groups.show('administrators', next);
|
|
||||||
},
|
|
||||||
function (next) {
|
|
||||||
Groups.ownership.grant(adminUid, 'administrators', next);
|
|
||||||
},
|
|
||||||
], function (err) {
|
|
||||||
if (err) {
|
|
||||||
return callback(err);
|
|
||||||
}
|
|
||||||
callback(null, password ? results : undefined);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
retryPassword = function (originalResults) {
|
|
||||||
// Ask only the password questions
|
|
||||||
prompt.get(passwordQuestions, function (err, results) {
|
|
||||||
if (!results) {
|
|
||||||
return callback(new Error('aborted'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the original data with newly collected password
|
|
||||||
originalResults.password = results.password;
|
|
||||||
originalResults['password:confirm'] = results['password:confirm'];
|
|
||||||
|
|
||||||
// Send back to success to handle
|
|
||||||
success(err, originalResults);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Add the password questions
|
// Add the password questions
|
||||||
questions = questions.concat(passwordQuestions);
|
questions = questions.concat(passwordQuestions);
|
||||||
@@ -389,16 +389,16 @@ function createMenuItems(next) {
|
|||||||
if (err || exists) {
|
if (err || exists) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
var navigation = require('./navigation/admin'),
|
var navigation = require('./navigation/admin');
|
||||||
data = require('../install/data/navigation.json');
|
var data = require('../install/data/navigation.json');
|
||||||
|
|
||||||
navigation.save(data, next);
|
navigation.save(data, next);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createWelcomePost(next) {
|
function createWelcomePost(next) {
|
||||||
var db = require('./database'),
|
var db = require('./database');
|
||||||
Topics = require('./topics');
|
var Topics = require('./topics');
|
||||||
|
|
||||||
async.parallel([
|
async.parallel([
|
||||||
function (next) {
|
function (next) {
|
||||||
@@ -412,8 +412,8 @@ function createWelcomePost(next) {
|
|||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var content = results[0],
|
var content = results[0];
|
||||||
numTopics = results[1];
|
var numTopics = results[1];
|
||||||
|
|
||||||
if (!parseInt(numTopics, 10)) {
|
if (!parseInt(numTopics, 10)) {
|
||||||
process.stdout.write('Creating welcome post!\n');
|
process.stdout.write('Creating welcome post!\n');
|
||||||
@@ -434,16 +434,16 @@ function enableDefaultPlugins(next) {
|
|||||||
process.stdout.write('Enabling default plugins\n');
|
process.stdout.write('Enabling default plugins\n');
|
||||||
|
|
||||||
var defaultEnabled = [
|
var defaultEnabled = [
|
||||||
'nodebb-plugin-composer-default',
|
'nodebb-plugin-composer-default',
|
||||||
'nodebb-plugin-markdown',
|
'nodebb-plugin-markdown',
|
||||||
'nodebb-plugin-mentions',
|
'nodebb-plugin-mentions',
|
||||||
'nodebb-widget-essentials',
|
'nodebb-widget-essentials',
|
||||||
'nodebb-rewards-essentials',
|
'nodebb-rewards-essentials',
|
||||||
'nodebb-plugin-soundpack-default',
|
'nodebb-plugin-soundpack-default',
|
||||||
'nodebb-plugin-emoji-extended',
|
'nodebb-plugin-emoji-extended',
|
||||||
'nodebb-plugin-emoji-one',
|
'nodebb-plugin-emoji-one',
|
||||||
],
|
];
|
||||||
customDefaults = nconf.get('defaultPlugins');
|
var customDefaults = nconf.get('defaultPlugins');
|
||||||
|
|
||||||
winston.info('[install/defaultPlugins] customDefaults', customDefaults);
|
winston.info('[install/defaultPlugins] customDefaults', customDefaults);
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,14 @@
|
|||||||
* Logger module: ability to dynamically turn on/off logging for http requests & socket.io events
|
* Logger module: ability to dynamically turn on/off logging for http requests & socket.io events
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var fs = require('fs'),
|
var fs = require('fs');
|
||||||
path = require('path'),
|
var path = require('path');
|
||||||
winston = require('winston'),
|
var winston = require('winston');
|
||||||
util = require('util'),
|
var util = require('util');
|
||||||
|
|
||||||
file = require('./file'),
|
var file = require('./file');
|
||||||
meta = require('./meta'),
|
var meta = require('./meta');
|
||||||
morgan = require('morgan');
|
var morgan = require('morgan');
|
||||||
|
|
||||||
var opts = {
|
var opts = {
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -78,9 +78,9 @@ Blacklist.validate = function (rules, callback) {
|
|||||||
var cidr = [];
|
var cidr = [];
|
||||||
var invalid = [];
|
var invalid = [];
|
||||||
|
|
||||||
var isCidrSubnet = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$/,
|
var isCidrSubnet = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$/;
|
||||||
inlineCommentMatch = /#.*$/,
|
var inlineCommentMatch = /#.*$/;
|
||||||
whitelist = ['127.0.0.1', '::1', '::ffff:0:127.0.0.1'];
|
var whitelist = ['127.0.0.1', '::1', '::ffff:0:127.0.0.1'];
|
||||||
|
|
||||||
// Filter out blank lines and lines starting with the hash character (comments)
|
// Filter out blank lines and lines starting with the hash character (comments)
|
||||||
// Also trim inputs and remove inline comments
|
// Also trim inputs and remove inline comments
|
||||||
|
|||||||
@@ -90,8 +90,8 @@ module.exports = function (Meta) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function getStyleSource(files, prefix, extension, callback) {
|
function getStyleSource(files, prefix, extension, callback) {
|
||||||
var pluginDirectories = [],
|
var pluginDirectories = [];
|
||||||
source = '';
|
var source = '';
|
||||||
|
|
||||||
files.forEach(function (styleFile) {
|
files.forEach(function (styleFile) {
|
||||||
if (styleFile.endsWith(extension)) {
|
if (styleFile.endsWith(extension)) {
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ function getTranslationTree(callback) {
|
|||||||
|
|
||||||
// generate list of languages and namespaces
|
// generate list of languages and namespaces
|
||||||
function (plugins, next) {
|
function (plugins, next) {
|
||||||
var languages = [], namespaces = [];
|
var languages = [];
|
||||||
|
namespaces = [];
|
||||||
|
|
||||||
// pull languages and namespaces from paths
|
// pull languages and namespaces from paths
|
||||||
function extrude(languageDir, paths) {
|
function extrude(languageDir, paths) {
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ Templates.compile = function (callback) {
|
|||||||
|
|
||||||
|
|
||||||
function getBaseTemplates(theme) {
|
function getBaseTemplates(theme) {
|
||||||
var baseTemplatesPaths = [],
|
var baseTemplatesPaths = [];
|
||||||
baseThemePath, baseThemeConfig;
|
var baseThemePath;
|
||||||
|
var baseThemeConfig;
|
||||||
|
|
||||||
while (theme) {
|
while (theme) {
|
||||||
baseThemePath = path.join(nconf.get('themes_path'), theme);
|
baseThemePath = path.join(nconf.get('themes_path'), theme);
|
||||||
@@ -78,9 +79,9 @@ function preparePaths(baseTemplatesPaths, callback) {
|
|||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
}, function (err, data) {
|
}, function (err, data) {
|
||||||
var baseThemes = data.baseThemes,
|
var baseThemes = data.baseThemes;
|
||||||
coreTpls = data.coreTpls,
|
var coreTpls = data.coreTpls;
|
||||||
paths = {};
|
var paths = {};
|
||||||
|
|
||||||
coreTpls.forEach(function (el, i) {
|
coreTpls.forEach(function (el, i) {
|
||||||
paths[coreTpls[i].replace(coreTemplatesPath, '')] = coreTpls[i];
|
paths[coreTpls[i].replace(coreTemplatesPath, '')] = coreTpls[i];
|
||||||
@@ -104,9 +105,9 @@ function preparePaths(baseTemplatesPaths, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function compile(callback) {
|
function compile(callback) {
|
||||||
var themeConfig = require(nconf.get('theme_config')),
|
var themeConfig = require(nconf.get('theme_config'));
|
||||||
baseTemplatesPaths = themeConfig.baseTheme ? getBaseTemplates(themeConfig.baseTheme) : [nconf.get('base_templates_path')],
|
var baseTemplatesPaths = themeConfig.baseTheme ? getBaseTemplates(themeConfig.baseTheme) : [nconf.get('base_templates_path')];
|
||||||
viewsPath = nconf.get('views_dir');
|
var viewsPath = nconf.get('views_dir');
|
||||||
|
|
||||||
|
|
||||||
preparePaths(baseTemplatesPaths, function (err, paths) {
|
preparePaths(baseTemplatesPaths, function (err, paths) {
|
||||||
@@ -115,9 +116,9 @@ function compile(callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async.each(Object.keys(paths), function (relativePath, next) {
|
async.each(Object.keys(paths), function (relativePath, next) {
|
||||||
var file = fs.readFileSync(paths[relativePath]).toString(),
|
var file = fs.readFileSync(paths[relativePath]).toString();
|
||||||
matches = null,
|
var matches = null;
|
||||||
regex = /[ \t]*<!-- IMPORT ([\s\S]*?)? -->[ \t]*/;
|
var regex = /[ \t]*<!-- IMPORT ([\s\S]*?)? -->[ \t]*/;
|
||||||
|
|
||||||
while((matches = file.match(regex)) !== null) {
|
while((matches = file.match(regex)) !== null) {
|
||||||
var partial = "/" + matches[1];
|
var partial = "/" + matches[1];
|
||||||
|
|||||||
@@ -153,8 +153,8 @@ module.exports = function (Meta) {
|
|||||||
|
|
||||||
Meta.themes.setPath = function (themeObj) {
|
Meta.themes.setPath = function (themeObj) {
|
||||||
// Theme's templates path
|
// Theme's templates path
|
||||||
var themePath = nconf.get('base_templates_path'),
|
var themePath = nconf.get('base_templates_path');
|
||||||
fallback = path.join(nconf.get('themes_path'), themeObj.id, 'templates');
|
var fallback = path.join(nconf.get('themes_path'), themeObj.id, 'templates');
|
||||||
|
|
||||||
if (themeObj.templates) {
|
if (themeObj.templates) {
|
||||||
themePath = path.join(nconf.get('themes_path'), themeObj.id, themeObj.templates);
|
themePath = path.join(nconf.get('themes_path'), themeObj.id, themeObj.templates);
|
||||||
|
|||||||
@@ -184,9 +184,9 @@ middleware.applyBlacklist = function (req, res, next) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
middleware.processTimeagoLocales = function (req, res, next) {
|
middleware.processTimeagoLocales = function (req, res, next) {
|
||||||
var fallback = req.path.indexOf('-short') === -1 ? 'jquery.timeago.en.js' : 'jquery.timeago.en-short.js',
|
var fallback = req.path.indexOf('-short') === -1 ? 'jquery.timeago.en.js' : 'jquery.timeago.en-short.js';
|
||||||
localPath = path.join(__dirname, '../../public/vendor/jquery/timeago/locales', req.path),
|
var localPath = path.join(__dirname, '../../public/vendor/jquery/timeago/locales', req.path);
|
||||||
exists;
|
var exists;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
exists = fs.accessSync(localPath, fs.F_OK | fs.R_OK);
|
exists = fs.accessSync(localPath, fs.F_OK | fs.R_OK);
|
||||||
|
|||||||
@@ -373,8 +373,8 @@ var utils = require('../public/src/utils');
|
|||||||
};
|
};
|
||||||
|
|
||||||
Notifications.prune = function () {
|
Notifications.prune = function () {
|
||||||
var week = 604800000,
|
var week = 604800000;
|
||||||
numPruned = 0;
|
var numPruned = 0;
|
||||||
|
|
||||||
var cutoffTime = Date.now() - week;
|
var cutoffTime = Date.now() - week;
|
||||||
|
|
||||||
@@ -411,13 +411,17 @@ var utils = require('../public/src/utils');
|
|||||||
Notifications.merge = function (notifications, callback) {
|
Notifications.merge = function (notifications, callback) {
|
||||||
// When passed a set of notification objects, merge any that can be merged
|
// When passed a set of notification objects, merge any that can be merged
|
||||||
var mergeIds = [
|
var mergeIds = [
|
||||||
'notifications:upvoted_your_post_in',
|
'notifications:upvoted_your_post_in',
|
||||||
'notifications:user_started_following_you',
|
'notifications:user_started_following_you',
|
||||||
'notifications:user_posted_to',
|
'notifications:user_posted_to',
|
||||||
'notifications:user_flagged_post_in',
|
'notifications:user_flagged_post_in',
|
||||||
'new_register',
|
'new_register',
|
||||||
],
|
];
|
||||||
isolated, differentiators, differentiator, modifyIndex, set;
|
var isolated;
|
||||||
|
var differentiators;
|
||||||
|
var differentiator;
|
||||||
|
var modifyIndex;
|
||||||
|
var set;
|
||||||
|
|
||||||
notifications = mergeIds.reduce(function (notifications, mergeId) {
|
notifications = mergeIds.reduce(function (notifications, mergeId) {
|
||||||
isolated = notifications.filter(function (notifObj) {
|
isolated = notifications.filter(function (notifObj) {
|
||||||
|
|||||||
@@ -147,8 +147,8 @@ var middleware;
|
|||||||
};
|
};
|
||||||
|
|
||||||
Plugins.getTemplates = function (callback) {
|
Plugins.getTemplates = function (callback) {
|
||||||
var templates = {},
|
var templates = {};
|
||||||
tplName;
|
var tplName;
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
async.apply(db.getSortedSetRange, 'plugins:active', 0, -1),
|
async.apply(db.getSortedSetRange, 'plugins:active', 0, -1),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var winston = require('winston'),
|
var winston = require('winston');
|
||||||
async = require('async');
|
var async = require('async');
|
||||||
|
|
||||||
module.exports = function (Plugins) {
|
module.exports = function (Plugins) {
|
||||||
Plugins.deprecatedHooks = {
|
Plugins.deprecatedHooks = {
|
||||||
@@ -36,7 +36,7 @@ module.exports = function (Plugins) {
|
|||||||
(Plugins.deprecatedHooks[data.hook] ?
|
(Plugins.deprecatedHooks[data.hook] ?
|
||||||
'please use `' + Plugins.deprecatedHooks[data.hook] + '` instead.' :
|
'please use `' + Plugins.deprecatedHooks[data.hook] + '` instead.' :
|
||||||
'there is no alternative.'
|
'there is no alternative.'
|
||||||
),
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// handle hook's startsWith, i.e. action:homepage.get
|
// handle hook's startsWith, i.e. action:homepage.get
|
||||||
|
|||||||
@@ -49,7 +49,9 @@ module.exports = function (Posts) {
|
|||||||
|
|
||||||
Posts.relativeToAbsolute = function (content) {
|
Posts.relativeToAbsolute = function (content) {
|
||||||
// Turns relative links in post body to absolute urls
|
// Turns relative links in post body to absolute urls
|
||||||
var parsed, current, absolute;
|
var parsed;
|
||||||
|
var current;
|
||||||
|
var absolute;
|
||||||
|
|
||||||
while ((current = urlRegex.exec(content)) !== null) {
|
while ((current = urlRegex.exec(content)) !== null) {
|
||||||
if (current[1]) {
|
if (current[1]) {
|
||||||
@@ -76,8 +78,8 @@ module.exports = function (Posts) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function sanitizeSignature(signature) {
|
function sanitizeSignature(signature) {
|
||||||
var string = S(signature),
|
var string = S(signature);
|
||||||
tagsToStrip = [];
|
var tagsToStrip = [];
|
||||||
|
|
||||||
if (parseInt(meta.config['signatures:disableLinks'], 10) === 1) {
|
if (parseInt(meta.config['signatures:disableLinks'], 10) === 1) {
|
||||||
tagsToStrip.push('a');
|
tagsToStrip.push('a');
|
||||||
|
|||||||
@@ -158,9 +158,9 @@ module.exports = function (Posts) {
|
|||||||
return callback(new Error('[[error:not-enough-reputation-to-downvote]]'));
|
return callback(new Error('[[error:not-enough-reputation-to-downvote]]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
var voteStatus = results.voteStatus,
|
var voteStatus = results.voteStatus;
|
||||||
hook,
|
var hook;
|
||||||
current = voteStatus.upvoted ? 'upvote' : 'downvote';
|
var current = voteStatus.upvoted ? 'upvote' : 'downvote';
|
||||||
|
|
||||||
if (voteStatus.upvoted && command === 'downvote' || voteStatus.downvoted && command === 'upvote') { // e.g. User *has* upvoted, and clicks downvote
|
if (voteStatus.upvoted && command === 'downvote' || voteStatus.downvoted && command === 'upvote') { // e.g. User *has* upvoted, and clicks downvote
|
||||||
hook = command;
|
hook = command;
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ function isUserAllowedToCids(privilege, uid, cids, callback) {
|
|||||||
return isGuestAllowedToCids(privilege, cids, callback);
|
return isGuestAllowedToCids(privilege, cids, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
var userKeys = [], groupKeys = [];
|
var userKeys = [];
|
||||||
|
var groupKeys = [];
|
||||||
for (var i = 0; i < cids.length; ++i) {
|
for (var i = 0; i < cids.length; ++i) {
|
||||||
userKeys.push('cid:' + cids[i] + ':privileges:' + privilege);
|
userKeys.push('cid:' + cids[i] + ':privileges:' + privilege);
|
||||||
groupKeys.push('cid:' + cids[i] + ':privileges:groups:' + privilege);
|
groupKeys.push('cid:' + cids[i] + ':privileges:groups:' + privilege);
|
||||||
@@ -63,7 +64,8 @@ function isUserAllowedToPrivileges(privileges, uid, cid, callback) {
|
|||||||
return isGuestAllowedToPrivileges(privileges, cid, callback);
|
return isGuestAllowedToPrivileges(privileges, cid, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
var userKeys = [], groupKeys = [];
|
var userKeys = [];
|
||||||
|
var groupKeys = [];
|
||||||
for (var i = 0; i < privileges.length; ++i) {
|
for (var i = 0; i < privileges.length; ++i) {
|
||||||
userKeys.push('cid:' + cid + ':privileges:' + privileges[i]);
|
userKeys.push('cid:' + cid + ':privileges:' + privileges[i]);
|
||||||
groupKeys.push('cid:' + cid + ':privileges:groups:' + privileges[i]);
|
groupKeys.push('cid:' + cid + ':privileges:groups:' + privileges[i]);
|
||||||
|
|||||||
@@ -73,9 +73,9 @@ module.exports = function (privileges) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var isMembers = checks.user.map(function (isMember, idx) {
|
var isMembers = checks.user.map(function (isMember, idx) {
|
||||||
return isMember || checks.group[idx];
|
return isMember || checks.group[idx];
|
||||||
}),
|
});
|
||||||
map = {};
|
var map = {};
|
||||||
|
|
||||||
uniqueCids.forEach(function (cid, index) {
|
uniqueCids.forEach(function (cid, index) {
|
||||||
map[cid] = isMembers[index];
|
map[cid] = isMembers[index];
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var nconf = require('nconf'),
|
var nconf = require('nconf');
|
||||||
util = require('util'),
|
var util = require('util');
|
||||||
winston = require('winston'),
|
var winston = require('winston');
|
||||||
EventEmitter = require('events').EventEmitter;
|
var EventEmitter = require('events').EventEmitter;
|
||||||
|
|
||||||
var channelName;
|
var channelName;
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
(function (Auth) {
|
(function (Auth) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var passport = require('passport'),
|
var passport = require('passport');
|
||||||
passportLocal = require('passport-local').Strategy,
|
var passportLocal = require('passport-local').Strategy;
|
||||||
nconf = require('nconf'),
|
var nconf = require('nconf');
|
||||||
winston = require('winston'),
|
var winston = require('winston');
|
||||||
express = require('express'),
|
var express = require('express');
|
||||||
|
|
||||||
controllers = require('../controllers'),
|
var controllers = require('../controllers');
|
||||||
plugins = require('../plugins'),
|
var plugins = require('../plugins');
|
||||||
hotswap = require('../hotswap'),
|
var hotswap = require('../hotswap');
|
||||||
|
|
||||||
loginStrategies = [];
|
var loginStrategies = [];
|
||||||
|
|
||||||
Auth.initialize = function (app, middleware) {
|
Auth.initialize = function (app, middleware) {
|
||||||
app.use(passport.initialize());
|
app.use(passport.initialize());
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
var meta = require('./meta');
|
var meta = require('./meta');
|
||||||
|
|
||||||
function expandObjBy(obj1, obj2) {
|
function expandObjBy(obj1, obj2) {
|
||||||
var key, val1, val2, xorValIsArray, changed = false;
|
var key;
|
||||||
|
var val1;
|
||||||
|
var val2;
|
||||||
|
var xorValIsArray;
|
||||||
|
var changed = false;
|
||||||
for (key in obj2) {
|
for (key in obj2) {
|
||||||
if (obj2.hasOwnProperty(key)) {
|
if (obj2.hasOwnProperty(key)) {
|
||||||
val2 = obj2[key];
|
val2 = obj2[key];
|
||||||
@@ -23,7 +27,8 @@ function expandObjBy(obj1, obj2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function trim(obj1, obj2) {
|
function trim(obj1, obj2) {
|
||||||
var key, val1;
|
var key;
|
||||||
|
var val1;
|
||||||
for (key in obj1) {
|
for (key in obj1) {
|
||||||
if (obj1.hasOwnProperty(key)) {
|
if (obj1.hasOwnProperty(key)) {
|
||||||
val1 = obj1[key];
|
val1 = obj1[key];
|
||||||
@@ -106,8 +111,8 @@ Settings.prototype.sync = function (callback) {
|
|||||||
@param callback Gets called when done.
|
@param callback Gets called when done.
|
||||||
*/
|
*/
|
||||||
Settings.prototype.persist = function (callback) {
|
Settings.prototype.persist = function (callback) {
|
||||||
var conf = this.cfg._,
|
var conf = this.cfg._;
|
||||||
_this = this;
|
var _this = this;
|
||||||
if (typeof conf === 'object') {
|
if (typeof conf === 'object') {
|
||||||
conf = JSON.stringify(conf);
|
conf = JSON.stringify(conf);
|
||||||
}
|
}
|
||||||
@@ -126,9 +131,9 @@ Settings.prototype.persist = function (callback) {
|
|||||||
@returns Object The setting to be used.
|
@returns Object The setting to be used.
|
||||||
*/
|
*/
|
||||||
Settings.prototype.get = function (key, def) {
|
Settings.prototype.get = function (key, def) {
|
||||||
var obj = this.cfg._,
|
var obj = this.cfg._;
|
||||||
parts = (key || '').split('.'),
|
var parts = (key || '').split('.');
|
||||||
part;
|
var part;
|
||||||
for (var i = 0; i < parts.length; i++) {
|
for (var i = 0; i < parts.length; i++) {
|
||||||
part = parts[i];
|
part = parts[i];
|
||||||
if (part && obj != null) {
|
if (part && obj != null) {
|
||||||
@@ -183,7 +188,9 @@ Settings.prototype.createDefaultWrapper = function () {
|
|||||||
@param val The value to set.
|
@param val The value to set.
|
||||||
*/
|
*/
|
||||||
Settings.prototype.set = function (key, val) {
|
Settings.prototype.set = function (key, val) {
|
||||||
var part, obj, parts;
|
var part;
|
||||||
|
var obj;
|
||||||
|
var parts;
|
||||||
this.cfg.v = this.version;
|
this.cfg.v = this.version;
|
||||||
if (val == null || !key) {
|
if (val == null || !key) {
|
||||||
this.cfg._ = val || key;
|
this.cfg._ = val || key;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var navigationAdmin = require('../../navigation/admin'),
|
var navigationAdmin = require('../../navigation/admin');
|
||||||
SocketNavigation = {};
|
var SocketNavigation = {};
|
||||||
|
|
||||||
SocketNavigation.save = function (socket, data, callback) {
|
SocketNavigation.save = function (socket, data, callback) {
|
||||||
navigationAdmin.save(data, callback);
|
navigationAdmin.save(data, callback);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var social = require('../../social'),
|
var social = require('../../social');
|
||||||
SocketSocial = {};
|
var SocketSocial = {};
|
||||||
|
|
||||||
SocketSocial.savePostSharingNetworks = function (socket, data, callback) {
|
SocketSocial.savePostSharingNetworks = function (socket, data, callback) {
|
||||||
social.setActivePostSharingNetworks(data, callback);
|
social.setActivePostSharingNetworks(data, callback);
|
||||||
|
|||||||
@@ -89,7 +89,9 @@ var social = require('./social');
|
|||||||
return callback(null, []);
|
return callback(null, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
var uids, cids, topics;
|
var uids;
|
||||||
|
var cids;
|
||||||
|
var topics;
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ module.exports = function (Topics) {
|
|||||||
postData = postData.filter(function (post) {
|
postData = postData.filter(function (post) {
|
||||||
return post && parseInt(post.deleted, 10) !== 1;
|
return post && parseInt(post.deleted, 10) !== 1;
|
||||||
});
|
});
|
||||||
var pidsToAdd = [], scores = [];
|
var pidsToAdd = [];
|
||||||
|
var scores = [];
|
||||||
postData.forEach(function (post) {
|
postData.forEach(function (post) {
|
||||||
pidsToAdd.push(post.pid);
|
pidsToAdd.push(post.pid);
|
||||||
scores.push(post.timestamp);
|
scores.push(post.timestamp);
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ module.exports = function (Topics) {
|
|||||||
},
|
},
|
||||||
function (err) {
|
function (err) {
|
||||||
callback(err, latestPid);
|
callback(err, latestPid);
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ module.exports = function (User) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Revoke any sessions that have expired, return filtered list
|
// Revoke any sessions that have expired, return filtered list
|
||||||
var expiredSids = [],
|
var expiredSids = [];
|
||||||
expired;
|
var expired;
|
||||||
|
|
||||||
sessions = sessions.filter(function (sessionObj, idx) {
|
sessions = sessions.filter(function (sessionObj, idx) {
|
||||||
expired = !sessionObj || !sessionObj.hasOwnProperty('passport') ||
|
expired = !sessionObj || !sessionObj.hasOwnProperty('passport') ||
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ var topics = require('../topics');
|
|||||||
module.exports = function (User) {
|
module.exports = function (User) {
|
||||||
User.getLatestBanInfo = function (uid, callback) {
|
User.getLatestBanInfo = function (uid, callback) {
|
||||||
// Simply retrieves the last record of the user's ban, even if they've been unbanned since then.
|
// Simply retrieves the last record of the user's ban, even if they've been unbanned since then.
|
||||||
var timestamp, expiry, reason;
|
var timestamp;
|
||||||
|
var expiry;
|
||||||
|
var reason;
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
async.apply(db.getSortedSetRevRangeWithScores, 'uid:' + uid + ':bans', 0, 0),
|
async.apply(db.getSortedSetRevRangeWithScores, 'uid:' + uid + ':bans', 0, 0),
|
||||||
|
|||||||
@@ -126,7 +126,8 @@ module.exports = function (User) {
|
|||||||
|
|
||||||
User.updateCoverPicture = function (data, callback) {
|
User.updateCoverPicture = function (data, callback) {
|
||||||
var keepAllVersions = parseInt(meta.config['profile:keepAllUserImages'], 10) === 1;
|
var keepAllVersions = parseInt(meta.config['profile:keepAllUserImages'], 10) === 1;
|
||||||
var url, md5sum;
|
var url;
|
||||||
|
var md5sum;
|
||||||
|
|
||||||
if (!data.imageData && data.position) {
|
if (!data.imageData && data.position) {
|
||||||
return User.updateCoverPosition(data.uid, data.position, callback);
|
return User.updateCoverPosition(data.uid, data.position, callback);
|
||||||
@@ -224,7 +225,8 @@ module.exports = function (User) {
|
|||||||
|
|
||||||
User.uploadCroppedPicture = function (data, callback) {
|
User.uploadCroppedPicture = function (data, callback) {
|
||||||
var keepAllVersions = parseInt(meta.config['profile:keepAllUserImages'], 10) === 1;
|
var keepAllVersions = parseInt(meta.config['profile:keepAllUserImages'], 10) === 1;
|
||||||
var url, md5sum;
|
var url;
|
||||||
|
var md5sum;
|
||||||
|
|
||||||
if (!data.imageData) {
|
if (!data.imageData) {
|
||||||
return callback(new Error('[[error:invalid-data]]'));
|
return callback(new Error('[[error:invalid-data]]'));
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async'),
|
var async = require('async');
|
||||||
nconf = require('nconf'),
|
var nconf = require('nconf');
|
||||||
winston = require('winston'),
|
var winston = require('winston');
|
||||||
|
|
||||||
user = require('../user'),
|
var user = require('../user');
|
||||||
utils = require('../../public/src/utils'),
|
var utils = require('../../public/src/utils');
|
||||||
translator = require('../../public/src/modules/translator'),
|
var translator = require('../../public/src/modules/translator');
|
||||||
|
|
||||||
db = require('../database'),
|
var db = require('../database');
|
||||||
meta = require('../meta'),
|
var meta = require('../meta');
|
||||||
emailer = require('../emailer');
|
var emailer = require('../emailer');
|
||||||
|
|
||||||
(function (UserReset) {
|
(function (UserReset) {
|
||||||
var twoHours = 7200000;
|
var twoHours = 7200000;
|
||||||
|
|||||||
@@ -48,8 +48,9 @@ admin.get = function (callback) {
|
|||||||
w.content += widgetData.adminTemplate;
|
w.content += widgetData.adminTemplate;
|
||||||
});
|
});
|
||||||
|
|
||||||
var templates = [],
|
var templates = [];
|
||||||
list = {}, index = 0;
|
var list = {};
|
||||||
|
var index = 0;
|
||||||
|
|
||||||
widgetData.areas.forEach(function (area) {
|
widgetData.areas.forEach(function (area) {
|
||||||
if (typeof list[area.template] === 'undefined') {
|
if (typeof list[area.template] === 'undefined') {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
/*global require, after, before*/
|
/*global require, after, before*/
|
||||||
|
|
||||||
var async = require('async'),
|
var async = require('async');
|
||||||
assert = require('assert'),
|
var assert = require('assert');
|
||||||
db = require('../mocks/databasemock');
|
var db = require('../mocks/databasemock');
|
||||||
|
|
||||||
describe('Hash methods', function () {
|
describe('Hash methods', function () {
|
||||||
var testData = {
|
var testData = {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
/*global require, after*/
|
/*global require, after*/
|
||||||
|
|
||||||
var async = require('async'),
|
var async = require('async');
|
||||||
assert = require('assert'),
|
var assert = require('assert');
|
||||||
db = require('../mocks/databasemock');
|
var db = require('../mocks/databasemock');
|
||||||
|
|
||||||
describe('Key methods', function () {
|
describe('Key methods', function () {
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user