From 107952ff0095e93691a3e0b546ead347dfc5d39c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 23 Nov 2017 04:53:50 +0100 Subject: [PATCH 1/4] Fix cursor for author row and avatars in comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When it was on an author row the cursor was shown as a pointer, even if clicking on the author row itself does nothing. On the other hand, avatars used the default cursor, even if clicking on them either shows the contacts menu (in the case of the author row, only when the avatar is for a different user than the current one) or inserts a mention (for avatars shown in the list of suggested mentions), depending on the case. Now, the author row uses the default cursor, and avatars (and their associated user name) use a pointer cursor if clicking on them will trigger an action (either showing the contacts menu or inserting a mention). Signed-off-by: Daniel Calviño Sánchez --- apps/comments/css/comments.css | 11 +++++++++++ apps/comments/js/commentstabview.js | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/apps/comments/css/comments.css b/apps/comments/css/comments.css index 1ed418df2fc66..14fa4316b5a6e 100644 --- a/apps/comments/css/comments.css +++ b/apps/comments/css/comments.css @@ -125,6 +125,17 @@ .atwho-view-ul * .avatar-name-wrapper, #commentsTabView .comment .authorRow { position: relative; +} + +#commentsTabView .comment .message .avatar-name-wrapper, +#commentsTabView .comment .message .avatar-name-wrapper .avatar, +#commentsTabView .comment .authorRow .avatar:not(.currentUser), +#commentsTabView .comment .authorRow .author:not(.currentUser) { + cursor: pointer; +} + +.atwho-view-ul .avatar-name-wrapper, +.atwho-view-ul .avatar-name-wrapper .avatar { cursor: pointer; } diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index 7398a709421d5..c9fcc72e284e6 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -23,8 +23,8 @@ var EDIT_COMMENT_TEMPLATE = '
' + '
' + - '
' + - '
{{actorDisplayName}}
' + + '
' + + '
{{actorDisplayName}}
' + '{{#if isEditMode}}' + ' ' + '{{/if}}' + @@ -42,8 +42,8 @@ var COMMENT_TEMPLATE = '
  • ' + '
    ' + - '
    ' + - '
    {{actorDisplayName}}
    ' + + '
    ' + + '
    {{actorDisplayName}}
    ' + '{{#if isUserAuthor}}' + ' ' + '{{/if}}' + From 8eb19a278c1667b4c8679076b21c1e5e08a77e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Sun, 26 Nov 2017 23:45:35 +0100 Subject: [PATCH 2/4] Disable contacts menu for mentioned users in comments being composed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The contacts menu does not provide too much value for users mentioned in a message being composed, so it is now disabled in this case. Signed-off-by: Daniel Calviño Sánchez --- apps/comments/css/comments.css | 4 ++-- apps/comments/js/commentstabview.js | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/apps/comments/css/comments.css b/apps/comments/css/comments.css index 14fa4316b5a6e..1685574926882 100644 --- a/apps/comments/css/comments.css +++ b/apps/comments/css/comments.css @@ -127,8 +127,8 @@ position: relative; } -#commentsTabView .comment .message .avatar-name-wrapper, -#commentsTabView .comment .message .avatar-name-wrapper .avatar, +#commentsTabView .comment:not(.newCommentRow) .message .avatar-name-wrapper, +#commentsTabView .comment:not(.newCommentRow) .message .avatar-name-wrapper .avatar, #commentsTabView .comment .authorRow .avatar:not(.currentUser), #commentsTabView .comment .authorRow .author:not(.currentUser) { cursor: pointer; diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index c9fcc72e284e6..867072c466555 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -214,13 +214,15 @@ searchKey: "label" }); $target.on('inserted.atwho', function (je, $el) { + var editionMode = true; s._postRenderItem( // we need to pass the parent of the inserted element // passing the whole comments form would re-apply and request // avatars from the server $(je.target).find( 'div[data-username="' + $el.find('[data-username]').data('username') + '"]' - ).parent() + ).parent(), + editionMode ); }); }, @@ -377,7 +379,7 @@ }); }, - _postRenderItem: function($el) { + _postRenderItem: function($el, editionMode) { $el.find('.has-tooltip').tooltip(); $el.find('.avatar').each(function() { var $this = $(this); @@ -395,10 +397,14 @@ // it is the case when writing a comment and mentioning a person $message = $el; } - this._postRenderMessage($message); + this._postRenderMessage($message, editionMode); }, - _postRenderMessage: function($el) { + _postRenderMessage: function($el, editionMode) { + if (editionMode) { + return; + } + $el.find('.avatar').each(function() { var avatar = $(this); var strong = $(this).next(); @@ -486,7 +492,8 @@ .html(this._formatMessage(commentToEdit.get('message'), commentToEdit.get('mentions'))) .find('.avatar') .each(function () { $(this).avatar(); }); - this._postRenderItem($message); + var editionMode = true; + this._postRenderItem($message, editionMode); // Enable autosize autosize($formRow.find('.message')); From ea4414f9bc878385b9b17e702d0875c666ba06b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Mon, 27 Nov 2017 00:10:53 +0100 Subject: [PATCH 3/4] Disable contacts menu for mentions to current user in comment messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The contacts menu is not shown for avatars and user names in the author row if they represent the current user. For consistency, and because the contacts menu provides no value when shown for the current user, this commit also disables the contacts menu for mentions to the current user. Signed-off-by: Daniel Calviño Sánchez --- apps/comments/css/comments.css | 4 ++-- apps/comments/js/commentstabview.js | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/comments/css/comments.css b/apps/comments/css/comments.css index 1685574926882..4ca415c3b020f 100644 --- a/apps/comments/css/comments.css +++ b/apps/comments/css/comments.css @@ -127,8 +127,8 @@ position: relative; } -#commentsTabView .comment:not(.newCommentRow) .message .avatar-name-wrapper, -#commentsTabView .comment:not(.newCommentRow) .message .avatar-name-wrapper .avatar, +#commentsTabView .comment:not(.newCommentRow) .message .avatar-name-wrapper:not(.currentUser), +#commentsTabView .comment:not(.newCommentRow) .message .avatar-name-wrapper:not(.currentUser) .avatar, #commentsTabView .comment .authorRow .avatar:not(.currentUser), #commentsTabView .comment .authorRow .author:not(.currentUser) { cursor: pointer; diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index 867072c466555..67e2a37a40b9b 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -410,7 +410,10 @@ var strong = $(this).next(); var appendTo = $(this).parent(); - $.merge(avatar, strong).contactsMenu(avatar.data('user'), 0, appendTo); + var username = $(this).data('username'); + if (username !== oc_current_user) { + $.merge(avatar, strong).contactsMenu(avatar.data('user'), 0, appendTo); + } }); }, @@ -451,9 +454,11 @@ + ' data-user-display-name="' + _.escape(displayName) + '">
    '; + var isCurrentUser = (uid === oc_current_user); + return '' + '' - + '' + + '' + avatar + ' '+ _.escape(displayName)+'' + '' + ''; From d15ca9ffafcb2f3bdec5e53922fb5b5531a9fea3 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Mon, 27 Nov 2017 11:53:24 +0100 Subject: [PATCH 4/4] Replace with non-deprecated JS call Signed-off-by: Lukas Reschke --- apps/comments/js/commentstabview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index 67e2a37a40b9b..c48a971dfe6d9 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -454,7 +454,7 @@ + ' data-user-display-name="' + _.escape(displayName) + '">
  • '; - var isCurrentUser = (uid === oc_current_user); + var isCurrentUser = (uid === OC.getCurrentUser().uid); return '' + ''