mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-03 11:01:20 +01:00
refactor: dont use module, explodes on latest webpack
This commit is contained in:
@@ -8,9 +8,9 @@ define('admin/settings/activitypub', [
|
|||||||
'alerts',
|
'alerts',
|
||||||
'translator',
|
'translator',
|
||||||
], function (Benchpress, bootbox, categorySelector, api, alerts, translator) {
|
], function (Benchpress, bootbox, categorySelector, api, alerts, translator) {
|
||||||
const Module = {};
|
const ActivityPub = {};
|
||||||
|
|
||||||
Module.init = function () {
|
ActivityPub.init = function () {
|
||||||
const rulesEl = document.getElementById('rules');
|
const rulesEl = document.getElementById('rules');
|
||||||
if (rulesEl) {
|
if (rulesEl) {
|
||||||
rulesEl.addEventListener('click', (e) => {
|
rulesEl.addEventListener('click', (e) => {
|
||||||
@@ -19,7 +19,7 @@ define('admin/settings/activitypub', [
|
|||||||
const action = subselector.getAttribute('data-action');
|
const action = subselector.getAttribute('data-action');
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'rules.add': {
|
case 'rules.add': {
|
||||||
Module.throwRulesModal();
|
ActivityPub.throwRulesModal();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ define('admin/settings/activitypub', [
|
|||||||
const action = subselector.getAttribute('data-action');
|
const action = subselector.getAttribute('data-action');
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'relays.add': {
|
case 'relays.add': {
|
||||||
Module.throwRelaysModal();
|
ActivityPub.throwRelaysModal();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ define('admin/settings/activitypub', [
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Module.throwRulesModal = function () {
|
ActivityPub.throwRulesModal = function () {
|
||||||
Benchpress.render('admin/partials/activitypub/rules', {}).then(function (html) {
|
Benchpress.render('admin/partials/activitypub/rules', {}).then(function (html) {
|
||||||
const submit = function () {
|
const submit = function () {
|
||||||
const formEl = modal.find('form').get(0);
|
const formEl = modal.find('form').get(0);
|
||||||
@@ -123,7 +123,7 @@ define('admin/settings/activitypub', [
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Module.throwRelaysModal = function () {
|
ActivityPub.throwRelaysModal = function () {
|
||||||
Benchpress.render('admin/partials/activitypub/relays', {}).then(function (html) {
|
Benchpress.render('admin/partials/activitypub/relays', {}).then(function (html) {
|
||||||
const submit = function () {
|
const submit = function () {
|
||||||
const formEl = modal.find('form').get(0);
|
const formEl = modal.find('form').get(0);
|
||||||
@@ -155,5 +155,5 @@ define('admin/settings/activitypub', [
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return Module;
|
return ActivityPub;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('admin/settings/cookies', ['alerts'], function (alerts) {
|
define('admin/settings/cookies', ['alerts'], function (alerts) {
|
||||||
const Module = {};
|
const Cookies = {};
|
||||||
|
|
||||||
Module.init = function () {
|
Cookies.init = function () {
|
||||||
$('#delete-all-sessions').on('click', function () {
|
$('#delete-all-sessions').on('click', function () {
|
||||||
socket.emit('admin.deleteAllSessions', function (err) {
|
socket.emit('admin.deleteAllSessions', function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -15,5 +15,5 @@ define('admin/settings/cookies', ['alerts'], function (alerts) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return Module;
|
return Cookies;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
|
|
||||||
define('admin/settings/email', ['ace/ace', 'alerts', 'admin/settings'], function (ace, alerts) {
|
define('admin/settings/email', ['ace/ace', 'alerts', 'admin/settings'], function (ace, alerts) {
|
||||||
const module = {};
|
const Email = {};
|
||||||
let emailEditor;
|
let emailEditor;
|
||||||
|
|
||||||
module.init = function () {
|
Email.init = function () {
|
||||||
configureSmtpTester();
|
configureSmtpTester();
|
||||||
configureEmailTester();
|
configureEmailTester();
|
||||||
configureEmailEditor();
|
configureEmailEditor();
|
||||||
@@ -159,5 +159,5 @@ define('admin/settings/email', ['ace/ace', 'alerts', 'admin/settings'], function
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return module;
|
return Email;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
|
|
||||||
define('admin/settings/general', ['admin/settings'], function () {
|
define('admin/settings/general', ['admin/settings'], function () {
|
||||||
const Module = {};
|
const General = {};
|
||||||
|
|
||||||
Module.init = function () {
|
General.init = function () {
|
||||||
$('button[data-action="removeLogo"]').on('click', function () {
|
$('button[data-action="removeLogo"]').on('click', function () {
|
||||||
$('input[data-field="brand:logo"]').val('');
|
$('input[data-field="brand:logo"]').val('');
|
||||||
});
|
});
|
||||||
@@ -34,5 +34,5 @@ define('admin/settings/general', ['admin/settings'], function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Module;
|
return General;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ define('forum/header', [
|
|||||||
'forum/header/chat',
|
'forum/header/chat',
|
||||||
'alerts',
|
'alerts',
|
||||||
], function (unread, notifications, chat, alerts) {
|
], function (unread, notifications, chat, alerts) {
|
||||||
const module = {};
|
const header = {};
|
||||||
|
|
||||||
module.prepareDOM = function () {
|
header.prepareDOM = function () {
|
||||||
if (app.user.uid > 0) {
|
if (app.user.uid > 0) {
|
||||||
unread.initUnreadTopics();
|
unread.initUnreadTopics();
|
||||||
}
|
}
|
||||||
@@ -74,5 +74,5 @@ define('forum/header', [
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return module;
|
return header;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,17 +3,17 @@
|
|||||||
define('chat', [
|
define('chat', [
|
||||||
'components', 'taskbar', 'translator', 'hooks', 'bootbox', 'alerts', 'api', 'scrollStop',
|
'components', 'taskbar', 'translator', 'hooks', 'bootbox', 'alerts', 'api', 'scrollStop',
|
||||||
], function (components, taskbar, translator, hooks, bootbox, alerts, api, scrollStop) {
|
], function (components, taskbar, translator, hooks, bootbox, alerts, api, scrollStop) {
|
||||||
const module = {};
|
const Chat = {};
|
||||||
|
|
||||||
module.openChat = function (roomId, uid) {
|
Chat.openChat = function (roomId, uid) {
|
||||||
if (!app.user.uid) {
|
if (!app.user.uid) {
|
||||||
return alerts.error('[[error:not-logged-in]]');
|
return alerts.error('[[error:not-logged-in]]');
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadAndCenter(chatModal) {
|
function loadAndCenter(chatModal) {
|
||||||
module.load(chatModal.attr('data-uuid'));
|
Chat.load(chatModal.attr('data-uuid'));
|
||||||
module.center(chatModal);
|
Chat.center(chatModal);
|
||||||
module.focusInput(chatModal);
|
Chat.focusInput(chatModal);
|
||||||
}
|
}
|
||||||
hooks.fire('filter:chat.openChat', {
|
hooks.fire('filter:chat.openChat', {
|
||||||
modal: true,
|
modal: true,
|
||||||
@@ -23,8 +23,8 @@ define('chat', [
|
|||||||
if (!hookData.modal) {
|
if (!hookData.modal) {
|
||||||
return ajaxify.go(`/chats/${roomId}`);
|
return ajaxify.go(`/chats/${roomId}`);
|
||||||
}
|
}
|
||||||
if (module.modalExists(roomId)) {
|
if (Chat.modalExists(roomId)) {
|
||||||
loadAndCenter(module.getModal(roomId));
|
loadAndCenter(Chat.getModal(roomId));
|
||||||
} else {
|
} else {
|
||||||
api.get(`/chats/${roomId}`, {
|
api.get(`/chats/${roomId}`, {
|
||||||
uid: uid || app.user.uid,
|
uid: uid || app.user.uid,
|
||||||
@@ -34,19 +34,19 @@ define('chat', [
|
|||||||
});
|
});
|
||||||
roomData.uid = uid || app.user.uid;
|
roomData.uid = uid || app.user.uid;
|
||||||
roomData.isSelf = true;
|
roomData.isSelf = true;
|
||||||
module.createModal(roomData, loadAndCenter);
|
Chat.createModal(roomData, loadAndCenter);
|
||||||
}).catch(alerts.error);
|
}).catch(alerts.error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.newChat = function (touid, callback) {
|
Chat.newChat = function (touid, callback) {
|
||||||
function createChat() {
|
function createChat() {
|
||||||
api.post(`/chats`, {
|
api.post(`/chats`, {
|
||||||
uids: [touid],
|
uids: [touid],
|
||||||
}).then(({ roomId }) => {
|
}).then(({ roomId }) => {
|
||||||
if (!ajaxify.data.template.chats) {
|
if (!ajaxify.data.template.chats) {
|
||||||
module.openChat(roomId);
|
Chat.openChat(roomId);
|
||||||
} else {
|
} else {
|
||||||
ajaxify.go('chats/' + roomId);
|
ajaxify.go('chats/' + roomId);
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ define('chat', [
|
|||||||
}).catch(alerts.error);
|
}).catch(alerts.error);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.loadChatsDropdown = function (chatsListEl) {
|
Chat.loadChatsDropdown = function (chatsListEl) {
|
||||||
api.get('/chats', {
|
api.get('/chats', {
|
||||||
uid: app.user.uid,
|
uid: app.user.uid,
|
||||||
after: 0,
|
after: 0,
|
||||||
@@ -114,7 +114,7 @@ define('chat', [
|
|||||||
}
|
}
|
||||||
const roomId = $(this).attr('data-roomid');
|
const roomId = $(this).attr('data-roomid');
|
||||||
if (!ajaxify.currentPage.match(/^chats\//)) {
|
if (!ajaxify.currentPage.match(/^chats\//)) {
|
||||||
module.openChat(roomId);
|
Chat.openChat(roomId);
|
||||||
} else {
|
} else {
|
||||||
ajaxify.go('user/' + app.user.userslug + '/chats/' + roomId);
|
ajaxify.go('user/' + app.user.userslug + '/chats/' + roomId);
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@ define('chat', [
|
|||||||
const roomId = el.getAttribute('data-roomid');
|
const roomId = el.getAttribute('data-roomid');
|
||||||
await api.del(`/chats/${roomId}/state`);
|
await api.del(`/chats/${roomId}/state`);
|
||||||
if (ajaxify.data.template.chats) {
|
if (ajaxify.data.template.chats) {
|
||||||
module.markChatElUnread($(el), false);
|
Chat.markChatElUnread($(el), false);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
@@ -145,32 +145,32 @@ define('chat', [
|
|||||||
|
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const chatEl = e.target.closest('[data-roomid]');
|
const chatEl = e.target.closest('[data-roomid]');
|
||||||
module.toggleReadState(chatEl);
|
Chat.toggleReadState(chatEl);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.toggleReadState = function (chatEl) {
|
Chat.toggleReadState = function (chatEl) {
|
||||||
const state = !chatEl.classList.contains('unread'); // this is the new state
|
const state = !chatEl.classList.contains('unread'); // this is the new state
|
||||||
const roomId = chatEl.getAttribute('data-roomid');
|
const roomId = chatEl.getAttribute('data-roomid');
|
||||||
api[state ? 'put' : 'del'](`/chats/${roomId}/state`, {}).catch((err) => {
|
api[state ? 'put' : 'del'](`/chats/${roomId}/state`, {}).catch((err) => {
|
||||||
alerts.error(err);
|
alerts.error(err);
|
||||||
|
|
||||||
// Revert on failure
|
// Revert on failure
|
||||||
module.markChatElUnread($(chatEl), !state);
|
Chat.markChatElUnread($(chatEl), !state);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Immediate feedback
|
// Immediate feedback
|
||||||
module.markChatElUnread($(chatEl), state);
|
Chat.markChatElUnread($(chatEl), state);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.isFromBlockedUser = function (fromUid) {
|
Chat.isFromBlockedUser = function (fromUid) {
|
||||||
return app.user.blocks.includes(parseInt(fromUid, 10));
|
return app.user.blocks.includes(parseInt(fromUid, 10));
|
||||||
};
|
};
|
||||||
|
|
||||||
module.isLookingAtRoom = function (roomId) {
|
Chat.isLookingAtRoom = function (roomId) {
|
||||||
return ajaxify.data.template.chats && parseInt(ajaxify.data.roomId, 10) === parseInt(roomId, 10);
|
return ajaxify.data.template.chats && parseInt(ajaxify.data.roomId, 10) === parseInt(roomId, 10);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.markChatElUnread = function (roomEl, unread) {
|
Chat.markChatElUnread = function (roomEl, unread) {
|
||||||
if (roomEl.length > 0) {
|
if (roomEl.length > 0) {
|
||||||
roomEl.toggleClass('unread', unread);
|
roomEl.toggleClass('unread', unread);
|
||||||
const markEl = roomEl.find('.mark-read');
|
const markEl = roomEl.find('.mark-read');
|
||||||
@@ -181,12 +181,12 @@ define('chat', [
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.onChatMessageReceived = function (data) {
|
Chat.onChatMessageReceived = function (data) {
|
||||||
if (app.user.blocks.includes(parseInt(data.fromUid, 10))) {
|
if (app.user.blocks.includes(parseInt(data.fromUid, 10))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (module.modalExists(data.roomId)) {
|
if (Chat.modalExists(data.roomId)) {
|
||||||
const modal = module.getModal(data.roomId);
|
const modal = Chat.getModal(data.roomId);
|
||||||
const newMessage = parseInt(modal.attr('new-message'), 10) === 1;
|
const newMessage = parseInt(modal.attr('new-message'), 10) === 1;
|
||||||
data.self = parseInt(app.user.uid, 10) === parseInt(data.fromUid, 10) ? 1 : 0;
|
data.self = parseInt(app.user.uid, 10) === parseInt(data.fromUid, 10) ? 1 : 0;
|
||||||
if (!newMessage) {
|
if (!newMessage) {
|
||||||
@@ -200,7 +200,7 @@ define('chat', [
|
|||||||
};
|
};
|
||||||
|
|
||||||
function addMessageToModal(data) {
|
function addMessageToModal(data) {
|
||||||
const modal = module.getModal(data.roomId);
|
const modal = Chat.getModal(data.roomId);
|
||||||
const username = data.message.fromUser.username;
|
const username = data.message.fromUser.username;
|
||||||
const isSelf = data.self === 1;
|
const isSelf = data.self === 1;
|
||||||
require(['forum/chats/messages'], function (ChatsMessages) {
|
require(['forum/chats/messages'], function (ChatsMessages) {
|
||||||
@@ -215,7 +215,7 @@ define('chat', [
|
|||||||
ChatsMessages.scrollToBottomAfterImageLoad(modal.find('[component="chat/message/content"]'));
|
ChatsMessages.scrollToBottomAfterImageLoad(modal.find('[component="chat/message/content"]'));
|
||||||
}
|
}
|
||||||
} else if (!ajaxify.data.template.chats) {
|
} else if (!ajaxify.data.template.chats) {
|
||||||
module.toggleNew(modal.attr('data-uuid'), true, true);
|
Chat.toggleNew(modal.attr('data-uuid'), true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isSelf && (!modal.is(':visible') || !app.isFocused)) {
|
if (!isSelf && (!modal.is(':visible') || !app.isFocused)) {
|
||||||
@@ -229,8 +229,8 @@ define('chat', [
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.onRoomRename = function (data) {
|
Chat.onRoomRename = function (data) {
|
||||||
const modal = module.getModal(data.roomId);
|
const modal = Chat.getModal(data.roomId);
|
||||||
const titleEl = modal.find('[component="chat/room/name"]');
|
const titleEl = modal.find('[component="chat/room/name"]');
|
||||||
const icon = titleEl.attr('data-icon');
|
const icon = titleEl.attr('data-icon');
|
||||||
if (titleEl.length) {
|
if (titleEl.length) {
|
||||||
@@ -250,17 +250,17 @@ define('chat', [
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
module.onUserTyping = function (data) {
|
Chat.onUserTyping = function (data) {
|
||||||
if (data.uid === app.user.uid || module.isFromBlockedUser(data.uid)) {
|
if (data.uid === app.user.uid || Chat.isFromBlockedUser(data.uid)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const modal = module.getModal(data.roomId);
|
const modal = Chat.getModal(data.roomId);
|
||||||
if (modal.length) {
|
if (modal.length) {
|
||||||
module.updateTypingUserList(modal, data);
|
Chat.updateTypingUserList(modal, data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.updateTypingUserList = async function (container, { uid, username, typing }) {
|
Chat.updateTypingUserList = async function (container, { uid, username, typing }) {
|
||||||
const typingEl = container.find(`[component="chat/composer/typing"]`);
|
const typingEl = container.find(`[component="chat/composer/typing"]`);
|
||||||
const typingUsersList = typingEl.find('[component="chat/composer/typing/users"]');
|
const typingUsersList = typingEl.find('[component="chat/composer/typing/users"]');
|
||||||
const userEl = typingUsersList.find(`[data-uid="${uid}"]`);
|
const userEl = typingUsersList.find(`[data-uid="${uid}"]`);
|
||||||
@@ -288,15 +288,15 @@ define('chat', [
|
|||||||
typingTextEl.toggleClass('hidden', !usernames.length);
|
typingTextEl.toggleClass('hidden', !usernames.length);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.getModal = function (roomId) {
|
Chat.getModal = function (roomId) {
|
||||||
return $('#chat-modal-' + roomId);
|
return $('#chat-modal-' + roomId);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.modalExists = function (roomId) {
|
Chat.modalExists = function (roomId) {
|
||||||
return $('#chat-modal-' + roomId).length !== 0;
|
return $('#chat-modal-' + roomId).length !== 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.initWidget = function (roomId, chatModal) {
|
Chat.initWidget = function (roomId, chatModal) {
|
||||||
require(['forum/chats', 'forum/chats/messages'], function (Chats, ChatsMessages) {
|
require(['forum/chats', 'forum/chats/messages'], function (Chats, ChatsMessages) {
|
||||||
socket.emit('modules.chats.enter', roomId);
|
socket.emit('modules.chats.enter', roomId);
|
||||||
api.del(`/chats/${roomId}/state`, {});
|
api.del(`/chats/${roomId}/state`, {});
|
||||||
@@ -345,15 +345,15 @@ define('chat', [
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.createModal = function (data, callback) {
|
Chat.createModal = function (data, callback) {
|
||||||
callback = callback || function () {};
|
callback = callback || function () {};
|
||||||
require([
|
require([
|
||||||
'forum/chats', 'forum/chats/messages', 'forum/chats/message-search',
|
'forum/chats', 'forum/chats/messages', 'forum/chats/message-search',
|
||||||
], function (Chats, ChatsMessages, messageSearch) {
|
], function (Chats, ChatsMessages, messageSearch) {
|
||||||
app.parseAndTranslate('chat', data, function (chatModal) {
|
app.parseAndTranslate('chat', data, function (chatModal) {
|
||||||
const roomId = data.roomId;
|
const roomId = data.roomId;
|
||||||
if (module.modalExists(roomId)) {
|
if (Chat.modalExists(roomId)) {
|
||||||
return callback(module.getModal(data.roomId));
|
return callback(Chat.getModal(data.roomId));
|
||||||
}
|
}
|
||||||
const uuid = utils.generateUUID();
|
const uuid = utils.generateUUID();
|
||||||
let dragged = false;
|
let dragged = false;
|
||||||
@@ -369,12 +369,12 @@ define('chat', [
|
|||||||
|
|
||||||
scrollStop.apply(chatModal.find('[component="chat/messages"] .chat-content'));
|
scrollStop.apply(chatModal.find('[component="chat/messages"] .chat-content'));
|
||||||
|
|
||||||
module.center(chatModal);
|
Chat.center(chatModal);
|
||||||
|
|
||||||
makeModalResizeableDraggable(chatModal, uuid);
|
makeModalResizeableDraggable(chatModal, uuid);
|
||||||
|
|
||||||
chatModal.find('#chat-close-btn').on('click', function () {
|
chatModal.find('#chat-close-btn').on('click', function () {
|
||||||
module.close(uuid);
|
Chat.close(uuid);
|
||||||
});
|
});
|
||||||
|
|
||||||
function gotoChats() {
|
function gotoChats() {
|
||||||
@@ -384,14 +384,14 @@ define('chat', [
|
|||||||
});
|
});
|
||||||
|
|
||||||
ajaxify.go(`user/${app.user.userslug}/chats/${roomId}`);
|
ajaxify.go(`user/${app.user.userslug}/chats/${roomId}`);
|
||||||
module.close(uuid);
|
Chat.close(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
chatModal.find('.modal-header').on('dblclick', gotoChats);
|
chatModal.find('.modal-header').on('dblclick', gotoChats);
|
||||||
chatModal.find('button[data-action="maximize"]').on('click', gotoChats);
|
chatModal.find('button[data-action="maximize"]').on('click', gotoChats);
|
||||||
chatModal.find('button[data-action="minimize"]').on('click', function () {
|
chatModal.find('button[data-action="minimize"]').on('click', function () {
|
||||||
const uuid = chatModal.attr('data-uuid');
|
const uuid = chatModal.attr('data-uuid');
|
||||||
module.minimize(uuid);
|
Chat.minimize(uuid);
|
||||||
});
|
});
|
||||||
|
|
||||||
chatModal.on('mouseup', function () {
|
chatModal.on('mouseup', function () {
|
||||||
@@ -475,7 +475,7 @@ define('chat', [
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
chatModal.find('.modal-body').css('height', module.calculateChatListHeight(chatModal));
|
chatModal.find('.modal-body').css('height', Chat.calculateChatListHeight(chatModal));
|
||||||
});
|
});
|
||||||
|
|
||||||
chatModal.draggable({
|
chatModal.draggable({
|
||||||
@@ -484,7 +484,7 @@ define('chat', [
|
|||||||
chatModal.css({ bottom: 'auto', right: 'auto' });
|
chatModal.css({ bottom: 'auto', right: 'auto' });
|
||||||
},
|
},
|
||||||
stop: function () {
|
stop: function () {
|
||||||
module.focusInput(chatModal);
|
Chat.focusInput(chatModal);
|
||||||
},
|
},
|
||||||
distance: 10,
|
distance: 10,
|
||||||
handle: '.modal-header',
|
handle: '.modal-header',
|
||||||
@@ -492,20 +492,20 @@ define('chat', [
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.focusInput = function (chatModal) {
|
Chat.focusInput = function (chatModal) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
chatModal.find('[component="chat/input"]').focus();
|
chatModal.find('[component="chat/input"]').focus();
|
||||||
}, 20);
|
}, 20);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.close = function (uuid) {
|
Chat.close = function (uuid) {
|
||||||
const chatModal = $('.chat-modal[data-uuid="' + uuid + '"]');
|
const chatModal = $('.chat-modal[data-uuid="' + uuid + '"]');
|
||||||
chatModal.remove();
|
chatModal.remove();
|
||||||
chatModal.data('modal', null);
|
chatModal.data('modal', null);
|
||||||
taskbar.discard('chat', uuid);
|
taskbar.discard('chat', uuid);
|
||||||
|
|
||||||
if (chatModal.attr('data-mobile')) {
|
if (chatModal.attr('data-mobile')) {
|
||||||
module.disableMobileBehaviour(chatModal);
|
Chat.disableMobileBehaviour(chatModal);
|
||||||
}
|
}
|
||||||
const roomId = chatModal.attr('data-roomid');
|
const roomId = chatModal.attr('data-roomid');
|
||||||
require(['forum/chats'], function (chats) {
|
require(['forum/chats'], function (chats) {
|
||||||
@@ -518,7 +518,7 @@ define('chat', [
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.center = function (chatModal) {
|
Chat.center = function (chatModal) {
|
||||||
const center = chatModal.attr('data-center');
|
const center = chatModal.attr('data-center');
|
||||||
if (!center || center === 'false') {
|
if (!center || center === 'false') {
|
||||||
return;
|
return;
|
||||||
@@ -537,30 +537,30 @@ define('chat', [
|
|||||||
return chatModal;
|
return chatModal;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.load = function (uuid) {
|
Chat.load = function (uuid) {
|
||||||
require(['forum/chats/messages'], function (ChatsMessages) {
|
require(['forum/chats/messages'], function (ChatsMessages) {
|
||||||
const chatModal = $('.chat-modal[data-uuid="' + uuid + '"]');
|
const chatModal = $('.chat-modal[data-uuid="' + uuid + '"]');
|
||||||
chatModal.removeClass('hide');
|
chatModal.removeClass('hide');
|
||||||
taskbar.updateActive(uuid);
|
taskbar.updateActive(uuid);
|
||||||
ChatsMessages.scrollToBottomAfterImageLoad(chatModal.find('.chat-content'));
|
ChatsMessages.scrollToBottomAfterImageLoad(chatModal.find('.chat-content'));
|
||||||
module.focusInput(chatModal);
|
Chat.focusInput(chatModal);
|
||||||
const roomId = chatModal.attr('data-roomid');
|
const roomId = chatModal.attr('data-roomid');
|
||||||
api.del(`/chats/${roomId}/state`, {});
|
api.del(`/chats/${roomId}/state`, {});
|
||||||
socket.emit('modules.chats.enter', roomId);
|
socket.emit('modules.chats.enter', roomId);
|
||||||
const env = utils.findBootstrapEnvironment();
|
const env = utils.findBootstrapEnvironment();
|
||||||
if (env === 'xs' || env === 'sm') {
|
if (env === 'xs' || env === 'sm') {
|
||||||
module.enableMobileBehaviour(chatModal);
|
Chat.enableMobileBehaviour(chatModal);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.enableMobileBehaviour = function (modalEl) {
|
Chat.enableMobileBehaviour = function (modalEl) {
|
||||||
app.toggleNavbar(false);
|
app.toggleNavbar(false);
|
||||||
modalEl.attr('data-mobile', '1');
|
modalEl.attr('data-mobile', '1');
|
||||||
const messagesEl = modalEl.find('.modal-body');
|
const messagesEl = modalEl.find('.modal-body');
|
||||||
messagesEl.css('height', module.calculateChatListHeight(modalEl));
|
messagesEl.css('height', Chat.calculateChatListHeight(modalEl));
|
||||||
function resize() {
|
function resize() {
|
||||||
messagesEl.css('height', module.calculateChatListHeight(modalEl));
|
messagesEl.css('height', Chat.calculateChatListHeight(modalEl));
|
||||||
require(['forum/chats/messages'], function (ChatsMessages) {
|
require(['forum/chats/messages'], function (ChatsMessages) {
|
||||||
ChatsMessages.scrollToBottom(modalEl.find('.chat-content'));
|
ChatsMessages.scrollToBottom(modalEl.find('.chat-content'));
|
||||||
});
|
});
|
||||||
@@ -568,21 +568,21 @@ define('chat', [
|
|||||||
|
|
||||||
$(window).on('resize', resize);
|
$(window).on('resize', resize);
|
||||||
$(window).one('action:ajaxify.start', function () {
|
$(window).one('action:ajaxify.start', function () {
|
||||||
module.close(modalEl.attr('data-uuid'));
|
Chat.close(modalEl.attr('data-uuid'));
|
||||||
$(window).off('resize', resize);
|
$(window).off('resize', resize);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.disableMobileBehaviour = function () {
|
Chat.disableMobileBehaviour = function () {
|
||||||
app.toggleNavbar(true);
|
app.toggleNavbar(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.calculateChatListHeight = function (modalEl) {
|
Chat.calculateChatListHeight = function (modalEl) {
|
||||||
// Formula: modal height minus header height. Simple(tm).
|
// Formula: modal height minus header height. Simple(tm).
|
||||||
return modalEl.find('.modal-content').outerHeight() - modalEl.find('.modal-header').outerHeight();
|
return modalEl.find('.modal-content').outerHeight() - modalEl.find('.modal-header').outerHeight();
|
||||||
};
|
};
|
||||||
|
|
||||||
module.minimize = function (uuid) {
|
Chat.minimize = function (uuid) {
|
||||||
const chatModal = $('.chat-modal[data-uuid="' + uuid + '"]');
|
const chatModal = $('.chat-modal[data-uuid="' + uuid + '"]');
|
||||||
chatModal.addClass('hide');
|
chatModal.addClass('hide');
|
||||||
taskbar.minimize('chat', uuid);
|
taskbar.minimize('chat', uuid);
|
||||||
@@ -592,7 +592,7 @@ define('chat', [
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.toggleNew = taskbar.toggleNew;
|
Chat.toggleNew = taskbar.toggleNew;
|
||||||
|
|
||||||
return module;
|
return Chat;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('pictureCropper', ['alerts'], function (alerts) {
|
define('pictureCropper', ['alerts'], function (alerts) {
|
||||||
const module = {};
|
const PictureCropper = {};
|
||||||
|
|
||||||
module.show = function (data, callback) {
|
PictureCropper.show = function (data, callback) {
|
||||||
const fileSize = data.hasOwnProperty('fileSize') && data.fileSize !== undefined ? parseInt(data.fileSize, 10) : false;
|
const fileSize = data.hasOwnProperty('fileSize') && data.fileSize !== undefined ? parseInt(data.fileSize, 10) : false;
|
||||||
app.parseAndTranslate('modals/upload-file', {
|
app.parseAndTranslate('modals/upload-file', {
|
||||||
showHelp: data.hasOwnProperty('showHelp') && data.showHelp !== undefined ? data.showHelp : true,
|
showHelp: data.hasOwnProperty('showHelp') && data.showHelp !== undefined ? data.showHelp : true,
|
||||||
@@ -32,7 +32,7 @@ define('pictureCropper', ['alerts'], function (alerts) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.handleImageCrop = function (data, callback) {
|
PictureCropper.handleImageCrop = function (data, callback) {
|
||||||
$('#crop-picture-modal').remove();
|
$('#crop-picture-modal').remove();
|
||||||
app.parseAndTranslate('modals/crop_picture', {
|
app.parseAndTranslate('modals/crop_picture', {
|
||||||
url: utils.escapeHTML(data.url),
|
url: utils.escapeHTML(data.url),
|
||||||
@@ -227,7 +227,7 @@ define('pictureCropper', ['alerts'], function (alerts) {
|
|||||||
|
|
||||||
data.uploadModal.modal('hide');
|
data.uploadModal.modal('hide');
|
||||||
|
|
||||||
module.handleImageCrop({
|
PictureCropper.handleImageCrop({
|
||||||
url: imageUrl,
|
url: imageUrl,
|
||||||
imageType: file.type,
|
imageType: file.type,
|
||||||
socketMethod: data.socketMethod,
|
socketMethod: data.socketMethod,
|
||||||
@@ -245,5 +245,5 @@ define('pictureCropper', ['alerts'], function (alerts) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return module;
|
return PictureCropper;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,9 +10,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
define('scrollStop', function () {
|
define('scrollStop', function () {
|
||||||
const Module = {};
|
const ScrollStop = {};
|
||||||
|
|
||||||
Module.apply = function (element) {
|
ScrollStop.apply = function (element) {
|
||||||
$(element).on('mousewheel', function (e) {
|
$(element).on('mousewheel', function (e) {
|
||||||
const scrollTop = this.scrollTop;
|
const scrollTop = this.scrollTop;
|
||||||
const scrollHeight = this.scrollHeight;
|
const scrollHeight = this.scrollHeight;
|
||||||
@@ -27,5 +27,5 @@ define('scrollStop', function () {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return Module;
|
return ScrollStop;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
|
|
||||||
define('share', ['hooks'], function (hooks) {
|
define('share', ['hooks'], function (hooks) {
|
||||||
const module = {};
|
const share = {};
|
||||||
const baseUrl = window.location.protocol + '//' + window.location.host;
|
const baseUrl = window.location.protocol + '//' + window.location.host;
|
||||||
|
|
||||||
module.addShareHandlers = function (name) {
|
share.addShareHandlers = function (name) {
|
||||||
function openShare(url, urlToPost, width, height) {
|
function openShare(url, urlToPost, width, height) {
|
||||||
window.open(url, '_blank', 'width=' + width + ',height=' + height + ',scrollbars=no,status=no');
|
window.open(url, '_blank', 'width=' + width + ',height=' + height + ',scrollbars=no,status=no');
|
||||||
hooks.fire('action:share.open', {
|
hooks.fire('action:share.open', {
|
||||||
@@ -76,5 +76,5 @@ define('share', ['hooks'], function (hooks) {
|
|||||||
return baseUrl + config.relative_path + path;
|
return baseUrl + config.relative_path + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
return module;
|
return share;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
|
|
||||||
define('sort', ['components'], function (components) {
|
define('sort', ['components'], function (components) {
|
||||||
const module = {};
|
const Sort = {};
|
||||||
|
|
||||||
module.handleSort = function (field, gotoOnSave) {
|
Sort.handleSort = function (field, gotoOnSave) {
|
||||||
const threadSort = components.get('thread/sort');
|
const threadSort = components.get('thread/sort');
|
||||||
threadSort.find('i').removeClass('fa-check');
|
threadSort.find('i').removeClass('fa-check');
|
||||||
const currentSort = utils.params().sort || config[field];
|
const currentSort = utils.params().sort || config[field];
|
||||||
@@ -22,5 +22,5 @@ define('sort', ['components'], function (components) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return module;
|
return Sort;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
|
|
||||||
define('uploader', ['jquery-form'], function () {
|
define('uploader', ['jquery-form'], function () {
|
||||||
const module = {};
|
const Uploader = {};
|
||||||
|
|
||||||
module.show = function (data, callback) {
|
Uploader.show = function (data, callback) {
|
||||||
const fileSize = data.hasOwnProperty('fileSize') && data.fileSize !== undefined ? parseInt(data.fileSize, 10) : false;
|
const fileSize = data.hasOwnProperty('fileSize') && data.fileSize !== undefined ? parseInt(data.fileSize, 10) : false;
|
||||||
app.parseAndTranslate('modals/upload-file', {
|
app.parseAndTranslate('modals/upload-file', {
|
||||||
showHelp: data.hasOwnProperty('showHelp') && data.showHelp !== undefined ? data.showHelp : true,
|
showHelp: data.hasOwnProperty('showHelp') && data.showHelp !== undefined ? data.showHelp : true,
|
||||||
@@ -35,7 +35,7 @@ define('uploader', ['jquery-form'], function () {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.hideAlerts = function (modal) {
|
Uploader.hideAlerts = function (modal) {
|
||||||
$(modal).find('#alert-status, #alert-success, #alert-error, #upload-progress-box').addClass('hide');
|
$(modal).find('#alert-status, #alert-success, #alert-error, #upload-progress-box').addClass('hide');
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -53,11 +53,11 @@ define('uploader', ['jquery-form'], function () {
|
|||||||
return showAlert(uploadModal, 'error', '[[error:file-too-big, ' + fileSize + ']]');
|
return showAlert(uploadModal, 'error', '[[error:file-too-big, ' + fileSize + ']]');
|
||||||
}
|
}
|
||||||
|
|
||||||
module.ajaxSubmit(uploadModal, callback);
|
Uploader.ajaxSubmit(uploadModal, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showAlert(uploadModal, type, message) {
|
function showAlert(uploadModal, type, message) {
|
||||||
module.hideAlerts(uploadModal);
|
Uploader.hideAlerts(uploadModal);
|
||||||
if (type === 'error') {
|
if (type === 'error') {
|
||||||
uploadModal.find('#fileUploadSubmitBtn').removeClass('disabled');
|
uploadModal.find('#fileUploadSubmitBtn').removeClass('disabled');
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ define('uploader', ['jquery-form'], function () {
|
|||||||
uploadModal.find('#alert-' + type).translateText(message).removeClass('hide');
|
uploadModal.find('#alert-' + type).translateText(message).removeClass('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
module.ajaxSubmit = function (uploadModal, callback) {
|
Uploader.ajaxSubmit = function (uploadModal, callback) {
|
||||||
const uploadForm = uploadModal.find('#uploadForm');
|
const uploadForm = uploadModal.find('#uploadForm');
|
||||||
uploadForm.ajaxSubmit({
|
uploadForm.ajaxSubmit({
|
||||||
headers: {
|
headers: {
|
||||||
@@ -96,7 +96,7 @@ define('uploader', ['jquery-form'], function () {
|
|||||||
|
|
||||||
showAlert(uploadModal, 'success', '[[uploads:upload-success]]');
|
showAlert(uploadModal, 'success', '[[uploads:upload-success]]');
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
module.hideAlerts(uploadModal);
|
Uploader.hideAlerts(uploadModal);
|
||||||
uploadModal.modal('hide');
|
uploadModal.modal('hide');
|
||||||
}, 750);
|
}, 750);
|
||||||
},
|
},
|
||||||
@@ -122,5 +122,5 @@ define('uploader', ['jquery-form'], function () {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return module;
|
return Uploader;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user