feat: #8734, jquery-ui, jquery-form, timeago (#8748)

* feat: #8734, jquery-ui, jquery-form, timeago

get rid of forum/footer.js move that code to app.js & wait for app to load before calling ajaxify.end
make sockets.js a requirejs module
move jquery-ui to node_modules and load via requirejs
move jquery-form to node_modules and load via requirejs
move timeago to node_modules and load via requirejs
only include the css for needed jquery-ui widgets

* feat: keep socket/io global for backwards compat

* refactor: move socket listener to chat
This commit is contained in:
Barış Soner Uşaklı
2020-10-10 21:47:27 -04:00
committed by GitHub
parent 666064bf46
commit fda2aedfd8
100 changed files with 98 additions and 2702 deletions

View File

@@ -2,11 +2,13 @@
const fs = require('fs');
const path = require('path');
const utils = require('./utils');
const paths = require('./constants').paths;
const Languages = module.exports;
const languagesPath = path.join(__dirname, '../build/public/language');
const files = fs.readdirSync(path.join(__dirname, '../public/vendor/jquery/timeago/locales'));
const files = fs.readdirSync(path.join(paths.nodeModules, '/timeago/locales'));
Languages.timeagoCodes = files.filter(f => f.startsWith('jquery.timeago')).map(f => f.split('.')[2]);
Languages.get = async function (language, namespace) {
@@ -62,4 +64,13 @@ Languages.list = async function () {
return languages;
};
Languages.userTimeagoCode = async function (userLang) {
const languageCodes = await Languages.listCodes();
const timeagoCode = utils.userLangToTimeagoCode(userLang);
if (languageCodes.includes(userLang) && Languages.timeagoCodes.includes(timeagoCode)) {
return timeagoCode;
}
return '';
};
require('./promisify')(Languages);