mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 02:36:16 +01:00
Fix space-before-function-paren linter rule
This commit is contained in:
@@ -9,14 +9,14 @@ define('forum/chats', [
|
||||
'forum/chats/recent',
|
||||
'forum/chats/search',
|
||||
'forum/chats/messages'
|
||||
], function(components, translator, mousetrap, recentChats, search, messages) {
|
||||
], function (components, translator, mousetrap, recentChats, search, messages) {
|
||||
var Chats = {
|
||||
initialised: false
|
||||
};
|
||||
|
||||
var newMessage = false;
|
||||
|
||||
Chats.init = function() {
|
||||
Chats.init = function () {
|
||||
var env = utils.findBootstrapEnvironment();
|
||||
|
||||
if (!Chats.initialised) {
|
||||
@@ -44,25 +44,25 @@ define('forum/chats', [
|
||||
}
|
||||
};
|
||||
|
||||
Chats.addEventListeners = function() {
|
||||
$('[component="chat/recent"]').on('click', '[component="chat/leave"]', function() {
|
||||
Chats.addEventListeners = function () {
|
||||
$('[component="chat/recent"]').on('click', '[component="chat/leave"]', function () {
|
||||
Chats.leave($(this).parents('[data-roomid]'));
|
||||
return false;
|
||||
});
|
||||
|
||||
$('[component="chat/recent"]').on('click', '[component="chat/recent/room"]', function() {
|
||||
$('[component="chat/recent"]').on('click', '[component="chat/recent/room"]', function () {
|
||||
Chats.switchChat($(this).attr('data-roomid'));
|
||||
});
|
||||
|
||||
Chats.addSendHandlers(ajaxify.data.roomId, $('.chat-input'), $('.expanded-chat button[data-action="send"]'));
|
||||
|
||||
$('[data-action="pop-out"]').on('click', function() {
|
||||
$('[data-action="pop-out"]').on('click', function () {
|
||||
|
||||
var text = components.get('chat/input').val();
|
||||
var roomId = ajaxify.data.roomId;
|
||||
|
||||
if (app.previousUrl && app.previousUrl.match(/chats/)) {
|
||||
ajaxify.go('user/' + ajaxify.data.userslug + '/chats', function() {
|
||||
ajaxify.go('user/' + ajaxify.data.userslug + '/chats', function () {
|
||||
app.openChat(roomId, ajaxify.data.uid);
|
||||
}, true);
|
||||
} else {
|
||||
@@ -70,7 +70,7 @@ define('forum/chats', [
|
||||
app.openChat(roomId, ajaxify.data.uid);
|
||||
}
|
||||
|
||||
$(window).one('action:chat.loaded', function() {
|
||||
$(window).one('action:chat.loaded', function () {
|
||||
components.get('chat/input').val(text);
|
||||
});
|
||||
});
|
||||
@@ -83,9 +83,9 @@ define('forum/chats', [
|
||||
Chats.addScrollHandler(ajaxify.data.roomId, ajaxify.data.uid, $('.chat-content'));
|
||||
};
|
||||
|
||||
Chats.addScrollHandler = function(roomId, uid, el) {
|
||||
Chats.addScrollHandler = function (roomId, uid, el) {
|
||||
var loading = false;
|
||||
el.off('scroll').on('scroll', function() {
|
||||
el.off('scroll').on('scroll', function () {
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
@@ -96,14 +96,14 @@ define('forum/chats', [
|
||||
}
|
||||
loading = true;
|
||||
var start = parseInt($('.chat-content').children('[data-index]').first().attr('data-index'), 10) + 1;
|
||||
socket.emit('modules.chats.getMessages', {roomId: roomId, uid: uid, start: start}, function(err, data) {
|
||||
socket.emit('modules.chats.getMessages', {roomId: roomId, uid: uid, start: start}, function (err, data) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
messages.parseMessage(data, function(html) {
|
||||
messages.parseMessage(data, function (html) {
|
||||
var currentScrollTop = el.scrollTop();
|
||||
var previousHeight = el[0].scrollHeight;
|
||||
html = $(html);
|
||||
@@ -117,19 +117,19 @@ define('forum/chats', [
|
||||
});
|
||||
};
|
||||
|
||||
Chats.addEditDeleteHandler = function(element, roomId) {
|
||||
element.on('click', '[data-action="edit"]', function() {
|
||||
Chats.addEditDeleteHandler = function (element, roomId) {
|
||||
element.on('click', '[data-action="edit"]', function () {
|
||||
var messageId = $(this).parents('[data-mid]').attr('data-mid');
|
||||
var inputEl = components.get('chat/input');
|
||||
messages.prepEdit(inputEl, messageId, roomId);
|
||||
}).on('click', '[data-action="delete"]', function() {
|
||||
}).on('click', '[data-action="delete"]', function () {
|
||||
var messageId = $(this).parents('[data-mid]').attr('data-mid');
|
||||
messages.delete(messageId, roomId);
|
||||
});
|
||||
};
|
||||
|
||||
Chats.addHotkeys = function() {
|
||||
mousetrap.bind('ctrl+up', function() {
|
||||
Chats.addHotkeys = function () {
|
||||
mousetrap.bind('ctrl+up', function () {
|
||||
var activeContact = $('.chats-list .bg-primary'),
|
||||
prev = activeContact.prev();
|
||||
|
||||
@@ -137,7 +137,7 @@ define('forum/chats', [
|
||||
Chats.switchChat(prev.attr('data-roomid'));
|
||||
}
|
||||
});
|
||||
mousetrap.bind('ctrl+down', function() {
|
||||
mousetrap.bind('ctrl+down', function () {
|
||||
var activeContact = $('.chats-list .bg-primary'),
|
||||
next = activeContact.next();
|
||||
|
||||
@@ -145,7 +145,7 @@ define('forum/chats', [
|
||||
Chats.switchChat(next.attr('data-roomid'));
|
||||
}
|
||||
});
|
||||
mousetrap.bind('up', function(e) {
|
||||
mousetrap.bind('up', function (e) {
|
||||
if (e.target === components.get('chat/input').get(0)) {
|
||||
// Retrieve message id from messages list
|
||||
var message = components.get('chat/messages').find('.chat-message[data-self="1"]').last();
|
||||
@@ -157,9 +157,9 @@ define('forum/chats', [
|
||||
});
|
||||
};
|
||||
|
||||
Chats.addRenameHandler = function(roomId, inputEl) {
|
||||
Chats.addRenameHandler = function (roomId, inputEl) {
|
||||
var oldName = inputEl.val();
|
||||
inputEl.on('blur keypress', function(ev) {
|
||||
inputEl.on('blur keypress', function (ev) {
|
||||
if (ev.type === 'keypress' && ev.keyCode !== 13) {
|
||||
return;
|
||||
}
|
||||
@@ -168,7 +168,7 @@ define('forum/chats', [
|
||||
if (oldName === newName) {
|
||||
return;
|
||||
}
|
||||
socket.emit('modules.chats.renameRoom', {roomId: roomId, newName: newName}, function(err) {
|
||||
socket.emit('modules.chats.renameRoom', {roomId: roomId, newName: newName}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -178,28 +178,28 @@ define('forum/chats', [
|
||||
});
|
||||
};
|
||||
|
||||
Chats.addSendHandlers = function(roomId, inputEl, sendEl) {
|
||||
inputEl.off('keypress').on('keypress', function(e) {
|
||||
Chats.addSendHandlers = function (roomId, inputEl, sendEl) {
|
||||
inputEl.off('keypress').on('keypress', function (e) {
|
||||
if (e.which === 13 && !e.shiftKey) {
|
||||
messages.sendMessage(roomId, inputEl);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
sendEl.off('click').on('click', function() {
|
||||
sendEl.off('click').on('click', function () {
|
||||
messages.sendMessage(roomId, inputEl);
|
||||
inputEl.focus();
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
Chats.createAutoComplete = function(element) {
|
||||
Chats.createAutoComplete = function (element) {
|
||||
var data = {
|
||||
element: element,
|
||||
strategies: [],
|
||||
options: {
|
||||
zIndex: 20000,
|
||||
listPosition: function(position) {
|
||||
listPosition: function (position) {
|
||||
this.$el.css(this._applyPlacement(position));
|
||||
this.$el.css('position', 'absolute');
|
||||
return this;
|
||||
@@ -213,27 +213,27 @@ define('forum/chats', [
|
||||
}
|
||||
};
|
||||
|
||||
Chats.createTagsInput = function(tagEl, data) {
|
||||
Chats.createTagsInput = function (tagEl, data) {
|
||||
tagEl.tagsinput({
|
||||
confirmKeys: [13, 44],
|
||||
trimValue: true
|
||||
});
|
||||
|
||||
if (data.users && data.users.length) {
|
||||
data.users.forEach(function(user) {
|
||||
data.users.forEach(function (user) {
|
||||
tagEl.tagsinput('add', $('<div/>').html(user.username).text());
|
||||
});
|
||||
}
|
||||
|
||||
tagEl.on('beforeItemAdd', function(event) {
|
||||
tagEl.on('beforeItemAdd', function (event) {
|
||||
event.cancel = event.item === app.user.username;
|
||||
});
|
||||
|
||||
tagEl.on('itemAdded', function(event) {
|
||||
tagEl.on('itemAdded', function (event) {
|
||||
if (event.item === app.user.username) {
|
||||
return;
|
||||
}
|
||||
socket.emit('modules.chats.addUserToRoom', {roomId: data.roomId, username: event.item}, function(err) {
|
||||
socket.emit('modules.chats.addUserToRoom', {roomId: data.roomId, username: event.item}, function (err) {
|
||||
if (err) {
|
||||
app.alertError(err.message);
|
||||
tagEl.tagsinput('remove', event.item, {nouser: true});
|
||||
@@ -241,7 +241,7 @@ define('forum/chats', [
|
||||
});
|
||||
});
|
||||
|
||||
tagEl.on('beforeItemRemove', function(event) {
|
||||
tagEl.on('beforeItemRemove', function (event) {
|
||||
if (event.options && event.options.nouser) {
|
||||
return;
|
||||
}
|
||||
@@ -256,11 +256,11 @@ define('forum/chats', [
|
||||
}
|
||||
});
|
||||
|
||||
tagEl.on('itemRemoved', function(event) {
|
||||
tagEl.on('itemRemoved', function (event) {
|
||||
if (event.options && event.options.nouser) {
|
||||
return;
|
||||
}
|
||||
socket.emit('modules.chats.removeUserFromRoom', {roomId: data.roomId, username: event.item}, function(err) {
|
||||
socket.emit('modules.chats.removeUserFromRoom', {roomId: data.roomId, username: event.item}, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -269,14 +269,14 @@ define('forum/chats', [
|
||||
|
||||
var input = $('.users-tag-container').find('.bootstrap-tagsinput input');
|
||||
|
||||
require(['autocomplete'], function(autocomplete) {
|
||||
require(['autocomplete'], function (autocomplete) {
|
||||
autocomplete.user(input);
|
||||
});
|
||||
};
|
||||
|
||||
Chats.leave = function(el) {
|
||||
Chats.leave = function (el) {
|
||||
var roomId = el.attr('data-roomid');
|
||||
socket.emit('modules.chats.leave', roomId, function(err) {
|
||||
socket.emit('modules.chats.leave', roomId, function (err) {
|
||||
if (err) {
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
@@ -288,13 +288,13 @@ define('forum/chats', [
|
||||
});
|
||||
};
|
||||
|
||||
Chats.switchChat = function(roomid) {
|
||||
Chats.switchChat = function (roomid) {
|
||||
ajaxify.go('user/' + ajaxify.data.userslug + '/chats/' + roomid);
|
||||
};
|
||||
|
||||
Chats.addGlobalEventListeners = function() {
|
||||
Chats.addGlobalEventListeners = function () {
|
||||
$(window).on('resize', Chats.resizeMainWindow);
|
||||
$(window).on('mousemove keypress click', function() {
|
||||
$(window).on('mousemove keypress click', function () {
|
||||
if (newMessage && ajaxify.data.roomId) {
|
||||
socket.emit('modules.chats.markRead', ajaxify.data.roomId);
|
||||
newMessage = false;
|
||||
@@ -302,8 +302,8 @@ define('forum/chats', [
|
||||
});
|
||||
};
|
||||
|
||||
Chats.addSocketListeners = function() {
|
||||
socket.on('event:chats.receive', function(data) {
|
||||
Chats.addSocketListeners = function () {
|
||||
socket.on('event:chats.receive', function (data) {
|
||||
if (parseInt(data.roomId, 10) === parseInt(ajaxify.data.roomId, 10)) {
|
||||
newMessage = data.self === 0;
|
||||
data.message.self = data.self;
|
||||
@@ -319,8 +319,8 @@ define('forum/chats', [
|
||||
var recentEl = components.get('chat/recent');
|
||||
templates.parse('partials/chat_recent_room', {
|
||||
rooms: { "roomId": data.roomId, "lastUser": data.message.fromUser, "usernames": data.message.fromUser.username, "unread": true }
|
||||
}, function(html) {
|
||||
translator.translate(html, function(translated) {
|
||||
}, function (html) {
|
||||
translator.translate(html, function (translated) {
|
||||
recentEl.prepend(translated);
|
||||
});
|
||||
});
|
||||
@@ -329,18 +329,18 @@ define('forum/chats', [
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('event:user_status_change', function(data) {
|
||||
socket.on('event:user_status_change', function (data) {
|
||||
app.updateUserStatus($('.chats-list [data-uid="' + data.uid + '"] [component="user/status"]'), data.status);
|
||||
});
|
||||
|
||||
messages.onChatMessageEdit();
|
||||
|
||||
socket.on('event:chats.roomRename', function(data) {
|
||||
socket.on('event:chats.roomRename', function (data) {
|
||||
$('[component="chat/room/name"]').val($('<div/>').html(data.newName).text());
|
||||
});
|
||||
};
|
||||
|
||||
Chats.resizeMainWindow = function() {
|
||||
Chats.resizeMainWindow = function () {
|
||||
var messagesList = $('.expanded-chat .chat-content');
|
||||
|
||||
if (messagesList.length) {
|
||||
@@ -358,7 +358,7 @@ define('forum/chats', [
|
||||
Chats.setActive();
|
||||
};
|
||||
|
||||
Chats.setActive = function() {
|
||||
Chats.setActive = function () {
|
||||
if (ajaxify.data.roomId) {
|
||||
socket.emit('modules.chats.markRead', ajaxify.data.roomId);
|
||||
$('.expanded-chat input').focus();
|
||||
|
||||
Reference in New Issue
Block a user