Adding a participant to a room can be done only by the owner and
moderators of that room, so the "Add participant" dropdown should be
shown only to those types of participants.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
When a participant is selected in the select2 dropdown the "change"
event is triggered for the "Add participants" input; this sets the value
of the input and also adds the participant to the room. However, the
event is triggered only if the selected item is different than the
current value of the "Add participant" input. Due to this, the value has
to be cleared when it is set to make possible to add the same
participant several times in a row (for example, in different rooms).
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
When explicitly leaving the current room through the room list view the
chat view was detached. However, as the internal state of the
Application object (which manages the placement of the chat view) was
not updated the chat view was always hidden from that point on until the
page was reloaded.
Moreover, as the chat view was detached only when explicitly leaving the
current room the chat view was not hidden for other users in the room if
it was deleted by a moderator.
As the "leaveCurrentRoom" event is triggered in the room channel when
the current room is left, either explicitly or implicitly, now the
Application object listens to that event and hides the chat view as
needed when it is received.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
The contacts menu can be shown only in user sessions; in the public view
it just fails and shows an error message instead of any useful option,
so now it is disabled for mentions in the public view.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
When an element is detached and then attached again its scroll position
is reset to the top. Now the chat view provides the "saveScrollPosition"
and "restoreScrollPosition" methods to save the scroll position before
detaching its element and then restoring it when attached again.
Note that the position can not be exactly restored, as the size of the
chat view may have changed due to switching it from the main view to the
sidebar, and thus the visible messages can not be the same in both
cases. Due to this, restoring the scroll position just ensures that the
last message that was partially visible when it was saved will be fully
visible when it is restored.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
The scroll area covers the top and bottom padding of an element, but not
its top and bottom margins, so the margins should not be taken into
account in the scroll calculations.
Currently this does not cause any difference in the behaviour, as the
message lists does not have any margin, but it is fixed just in case it
is added in the future.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
When an element has a negative top margin jQuery returns its top
position as the position in where the element would be if it had no
margin. In a similar way, when there is a negative margin the returned
height is not the actual height of the element, but its height without
that margin.
The message list is expected to scroll to the newest message if the last
one is partially visible, but due to the jQuery behaviour the message
list did not scroll when the last message was grouped and less than 20px
(the negative top margin) of the content of that message was visible.
Now the negative margin is taken into account and the message list
always scrolls to the newest message if the last one is partially
visible.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
When the oldest on top layout was added it was enabled by default,
although the original newest on top layout was also kept as an option.
However, the newest on top layout has not been used since then, and it
is not expected to be used ever again. To make the chat view more
maintainable and ease adding new features this commit removes the
original newest on top chat layout.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
When the chat view used the oldest on top layout the "oldestOnTopLayout"
CSS class was suppossed to be added to its main element. However, when
the "className" method was executed the "initialize" method had not been
executed yet, so there was no "_oldestOnTopLayout" attribute even if it
was included in the options, so the CSS class was never set and thus the
CSS rules were never used.
The support for the newest on top layout is going to be removed, and the
common CSS rules were already being used for the oldest on top layout
without problems; due to this, instead of fixing the setting of the CSS
class, the specific CSS rules for the oldest on top layout were simply
removed.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Note that "currentUser" is not set in the author row of guest users, but
this is not a problem; that CSS class is used only to show the default
cursor instead of the pointer cursor, but as all the author rows of
guest users show the default cursor it makes no difference if
"currentUser" is set for them or not.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Instead of adding the "currentUser" CSS class to ".avatar" and ".author"
elements now it is added to their wrapping ".authorRow" element.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
The server expects mentions to be in plain text, so the formatted
mentions have to be converted to "@" followed by the user name before
the message is sent to the server.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
CSS styles were directly copied from
"apps/comments/css/autocomplete.scss".
JavaScript code in the chat view
was slightly simplified from "apps/comments/js/commentstabview.js".
Currently mentions are not formatted when a message is being composed;
"@" followed by the user name is added to the message so it can be
directly sent without further processing. Formatted mentions will be
introduced in another commit.
Signed-off-by: Joas Schilling <coding@schilljs.com>
Clicking on a message author shows the contacts menu (provided the
author is not the current user); in those cases the cursor should be a
pointer so the user knows that an interaction with those elements is
possible.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
The contacts menu expects its parent element to be its positioning
context, so the mention must have a relative position. Besides that, the
default CSS rules from the server set the position of the contacts menu
assuming that the parent element is an avatar, so the rules have to be
overriden to position it on the text.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
The RichObjectStringParser was copied from the Notifications app and
adapted to be used in the chat (support for file references was removed,
"-" is taken into account too in parameter IDs, only local users are
taken into account, and if the display name of a mention is empty the
user ID is used instead).
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>