mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-28 17:46:16 +01:00
feat: load jquery-form before using
This commit is contained in:
@@ -88,7 +88,19 @@ app.cacheBuster = null;
|
||||
app.showCookieWarning();
|
||||
registerServiceWorker();
|
||||
|
||||
require(['taskbar', 'helpers', 'forum/pagination'], function (taskbar, helpers, pagination) {
|
||||
require([
|
||||
'taskbar',
|
||||
'helpers',
|
||||
'forum/pagination',
|
||||
'translator',
|
||||
'forum/unread',
|
||||
'forum/header/notifications',
|
||||
'forum/header/chat',
|
||||
'timeago/jquery.timeago',
|
||||
], function (taskbar, helpers, pagination, translator, unread, notifications, chat) {
|
||||
notifications.prepareDOM();
|
||||
chat.prepareDOM();
|
||||
translator.prepareDOM();
|
||||
taskbar.init();
|
||||
|
||||
helpers.register();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
define('forum/login', [], function () {
|
||||
define('forum/login', ['jquery-form'], function () {
|
||||
var Login = {};
|
||||
|
||||
Login.init = function () {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
define('forum/register', ['translator', 'zxcvbn'], function (translator, zxcvbn) {
|
||||
define('forum/register', ['translator', 'zxcvbn', 'jquery-form'], function (translator, zxcvbn) {
|
||||
var Register = {};
|
||||
var validationError = false;
|
||||
var successIcon = '';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
define('uploader', ['translator', 'benchpress'], function (translator, Benchpress) {
|
||||
define('uploader', ['translator', 'benchpress', 'jquery-form'], function (translator, Benchpress) {
|
||||
var module = {};
|
||||
|
||||
module.show = function (data, callback) {
|
||||
|
||||
@@ -102,10 +102,11 @@ JS.scripts = {
|
||||
'zxcvbn.js': 'node_modules/zxcvbn/dist/zxcvbn.js',
|
||||
ace: 'node_modules/ace-builds/src-min',
|
||||
'clipboard.js': 'node_modules/clipboard/dist/clipboard.min.js',
|
||||
'nprogress.js': 'node_modules/nprogress/nprogress.js',
|
||||
'tinycon.js': 'node_modules/tinycon/tinycon.js',
|
||||
'slideout.js': 'node_modules/slideout/dist/slideout.min.js',
|
||||
'compare-versions.js': 'node_modules/compare-versions/index.js',
|
||||
'timeago/locales': 'node_modules/timeago/locales',
|
||||
'jquery-form.js': 'node_modules/jquery-form/dist/jquery.form.min.js',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -272,6 +273,44 @@ JS.buildModules = function (fork, callback) {
|
||||
], callback);
|
||||
};
|
||||
|
||||
function requirejsOptimize(target, callback) {
|
||||
const requirejs = require('requirejs');
|
||||
let scriptText = '';
|
||||
const sharedCfg = {
|
||||
paths: {
|
||||
jquery: 'empty:',
|
||||
},
|
||||
optimize: 'none',
|
||||
out: function (text) {
|
||||
scriptText += text;
|
||||
},
|
||||
};
|
||||
const bundledModules = [
|
||||
{
|
||||
baseUrl: './node_modules',
|
||||
name: 'timeago/jquery.timeago',
|
||||
},
|
||||
{
|
||||
baseUrl: './node_modules/nprogress',
|
||||
name: 'nprogress',
|
||||
},
|
||||
];
|
||||
|
||||
async.eachSeries(bundledModules, function (moduleCfg, next) {
|
||||
requirejs.optimize({ ...sharedCfg, ...moduleCfg }, function () {
|
||||
next();
|
||||
}, function (err) {
|
||||
next(err);
|
||||
});
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
const filePath = path.join(__dirname, '../../build/public/rjs-bundle-' + target + '.js');
|
||||
fs.writeFile(filePath, scriptText, callback);
|
||||
});
|
||||
}
|
||||
|
||||
JS.linkStatics = function (callback) {
|
||||
rimraf(path.join(__dirname, '../../build/public/plugins'), function (err) {
|
||||
if (err) {
|
||||
@@ -348,6 +387,9 @@ JS.buildBundle = function (target, fork, callback) {
|
||||
};
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
requirejsOptimize(target, next);
|
||||
},
|
||||
function (next) {
|
||||
getBundleScriptList(target, next);
|
||||
},
|
||||
@@ -357,6 +399,10 @@ JS.buildBundle = function (target, fork, callback) {
|
||||
});
|
||||
},
|
||||
function (files, next) {
|
||||
files.push({
|
||||
srcPath: path.join(__dirname, '../../build/public/rjs-bundle-' + target + '.js'),
|
||||
});
|
||||
|
||||
var minify = process.env.NODE_ENV !== 'development';
|
||||
var filePath = path.join(__dirname, '../../build/public', fileNames[target]);
|
||||
|
||||
|
||||
@@ -1839,7 +1839,7 @@ describe('Controllers', function () {
|
||||
|
||||
describe('timeago locales', function () {
|
||||
it('should load timeago locale', function (done) {
|
||||
request(nconf.get('url') + '/assets/vendor/jquery/timeago/locales/jquery.timeago.af.js', function (err, res, body) {
|
||||
request(nconf.get('url') + '/assets/src/modules/timeago/locales/jquery.timeago.af.js', function (err, res, body) {
|
||||
assert.ifError(err);
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert(body.includes('Afrikaans'));
|
||||
@@ -1848,7 +1848,7 @@ describe('Controllers', function () {
|
||||
});
|
||||
|
||||
it('should return not found if NodeBB language exists but timeago locale does not exist', function (done) {
|
||||
request(nconf.get('url') + '/assets/vendor/jquery/timeago/locales/jquery.timeago.ms.js', function (err, res, body) {
|
||||
request(nconf.get('url') + '/assets/src/modules/timeago/locales/jquery.timeago.ms.js', function (err, res, body) {
|
||||
assert.ifError(err);
|
||||
assert.equal(res.statusCode, 404);
|
||||
done();
|
||||
@@ -1856,7 +1856,7 @@ describe('Controllers', function () {
|
||||
});
|
||||
|
||||
it('should return not found if NodeBB language does not exist', function (done) {
|
||||
request(nconf.get('url') + '/assets/vendor/jquery/timeago/locales/jquery.timeago.muggle.js', function (err, res, body) {
|
||||
request(nconf.get('url') + '/assets/src/modules/timeago/locales/jquery.timeago.muggle.js', function (err, res, body) {
|
||||
assert.ifError(err);
|
||||
assert.equal(res.statusCode, 404);
|
||||
done();
|
||||
|
||||
Reference in New Issue
Block a user