From facd1cae2f34d1833563cffe9e6f1361896a80d7 Mon Sep 17 00:00:00 2001 From: Abijeet Date: Fri, 19 Jan 2018 00:44:58 +0530 Subject: Fixes issue where saving a non-modified comment kept the edit window open. Now irrespective of the whether the comment has been modified we are going to go back to the view mode. Signed-off-by: Abijeet --- apps/comments/js/commentstabview.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index 20f1f590a28..dec2b6545d5 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -668,6 +668,12 @@ }, { success: function(model) { self._onSubmitSuccess(model, $form); + if(model.get('message').trim() === model.previous('message').trim()) { + // model change event doesn't trigger, manually remove the row. + var $row = $form.closest('.comment'); + $row.data('commentEl').removeClass('hidden'); + $row.remove(); + } }, error: function() { self._onSubmitError($form, commentId); -- cgit v1.2.3 From b3e1026cabc4f64670f404a3ae45d01507dac17d Mon Sep 17 00:00:00 2001 From: Abijeet Date: Fri, 19 Jan 2018 00:49:59 +0530 Subject: Fixes div being added placed directly under ul during editing of comments. Signed-off-by: Abijeet --- apps/comments/js/commentstabview.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index dec2b6545d5..73f19b7cd0b 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -21,7 +21,7 @@ ''; var EDIT_COMMENT_TEMPLATE = - '
' + + '<{{tag}} class="newCommentRow comment" data-id="{{id}}">' + '
' + '
' + '
{{actorDisplayName}}
' + @@ -38,7 +38,7 @@ '{{/if}}' + ' '+ ' ' + - '
'; + ''; var COMMENT_TEMPLATE = '
  • ' + @@ -116,7 +116,8 @@ newMessagePlaceholder: t('comments', 'New comment …'), deleteTooltip: t('comments', 'Delete comment'), submitText: t('comments', 'Post'), - cancelText: t('comments', 'Cancel') + cancelText: t('comments', 'Cancel'), + tag: 'li' }, params)); }, @@ -166,7 +167,7 @@ emptyResultLabel: t('comments', 'No comments yet, start the conversation!'), moreLabel: t('comments', 'More comments …') })); - this.$el.find('.comments').before(this.editCommentTemplate({})); + this.$el.find('.comments').before(this.editCommentTemplate({ tag: 'div'})); this.$el.find('.has-tooltip').tooltip(); this.$container = this.$el.find('ul.comments'); this.$el.find('.avatar').avatar(OC.getCurrentUser().uid, 32); -- cgit v1.2.3 From 61b38a16fa69880603d3aa2ad21fd2b541c67772 Mon Sep 17 00:00:00 2001 From: Abijeet Date: Fri, 19 Jan 2018 02:10:26 +0530 Subject: Fixes the following UI issues, 1. Increased the size of the delete, edit, close and submit buttons to take up 44x44px. 2. Now showing the delete button at all times when editing to avoid usability issues with touch screens. 3. Edit icon is also shown at all times, rather than only on hover. 4. Reduced the gap between comments a wee bit. 5. Fixed issues with focus event now working properly for edit and delete. 6. Removed absolute positioning of elements for alignment. 7. Fixed issue with tooltips becoming too high due to padding around actions. Occurred due to my changes. 8. Changed the position of the submit and close icons. 9. Fixed issue with jumping of the delete icon in Firefox. Occurred due to my changes. 10. Fixed issue with wrapping of content due to long author names. Occurred due to my changes. 11. Fixed issue with longer comments not appearing properly. This might have occurred due to my changes. Signed-off-by: Abijeet --- apps/comments/css/comments.css | 99 ++++++++++++++++++------------------- apps/comments/js/commentstabview.js | 10 ++-- 2 files changed, 52 insertions(+), 57 deletions(-) diff --git a/apps/comments/css/comments.css b/apps/comments/css/comments.css index 311eeebe4db..7f276f9f14f 100644 --- a/apps/comments/css/comments.css +++ b/apps/comments/css/comments.css @@ -13,49 +13,40 @@ } #commentsTabView .newCommentForm { - position: relative; - margin-bottom: 20px; + margin-left: 36px; } #commentsTabView .newCommentForm .message { - width: calc(100% - 81px); /* 36 (left margin) + 30 (right padding) + 15 (right padding of surrounding box) */ - margin-left: 36px; - padding-right: 30px; - display: block; + /* width = 100% - (width of submit button (44px) + margin (3px) + inline-block gap) */ + width: calc(100% - 52px); + display: inline-block; } #commentsTabView .newCommentForm .submit { - position: absolute; - bottom: 0px; - right: 8px; - width: 30px; + width: 44px; margin: 0; - padding: 7px 9px; + padding: 13px; background-color: transparent; border: none; opacity: .3; -} -#commentsTabView .newCommentForm .submit:not(:disabled):hover, -#commentsTabView .newCommentForm .submit:not(:disabled):focus { - opacity: 1; + vertical-align: bottom; } -#commentsTabView .newCommentForm .submitLoading { - background-position: left; +#commentsTabView .deleteLoading { + float: right; + padding: 14px; + vertical-align: middle; +} - /* Match rules for '#commentsTabView .newCommentForm .submit' to place the - loading icon at the same position as the confirm icon */ - position: absolute; - bottom: 0px; - right: 8px; - width: 30px; - margin: 0; - padding: 7px 9px; +#commentsTabView .submitLoading { + vertical-align: bottom; + display: inline-block; + padding: 14px; +} - /* Match rules for 'input[type="submit"]' to place the loading icon at the - same position as the confirm icon */ - min-height: 34px; - box-sizing: border-box; +#commentsTabView .newCommentForm .submit:not(:disabled):hover, +#commentsTabView .newCommentForm .submit:not(:disabled):focus { + opacity: 1; } #commentsTabView .newCommentForm .cancel { @@ -73,7 +64,8 @@ #commentsTabView .comment { position: relative; - margin-bottom: 30px; + /** padding bottom is little more so that the top and bottom gap look uniform **/ + padding: 10px 0px 15px; word-wrap: break-word; overflow-wrap: break-word; } @@ -123,19 +115,22 @@ background: -o-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1)); background: -ms-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1)); background: linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1)); - filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#00FFFFFF', endColorstr='#FFFFFFFF'); background-repeat: no-repeat; } -#commentsTabView .authorRow>div:not(.contactsmenu-popover) { - display: inline-block; - vertical-align: middle; -} - -#commentsTabView .authorRow>div.hidden { +#commentsTabView .hidden { display: none !important; } +/** set min-height as 44px to ensure that it fits the button sizes. **/ +#commentsTabView .comment .authorRow { + min-height: 44px; +} +#commentsTabView .comment .authorRow .tooltip { + /** because of the padding on the element, the tooltip appear too far up, + adding this brings them closer to the element**/ + margin-top: 5px; +} #commentsTabView .comments li .message .avatar-name-wrapper, .atwho-view-ul * .avatar-name-wrapper, #commentsTabView .comment .authorRow { @@ -171,32 +166,32 @@ } #commentsTabView .comment .date { margin-left: auto; + /** this is to fix the tooltip being too close due to the margin-top applied + to bring the tooltip closer for the action icons **/ + padding: 10px 0px; } -#commentsTabView .comments li .message { +#commentsTabView .comments > li:not(.newCommentRow) .message { padding-left: 40px; - display: inline-flex; - flex-wrap: wrap; - align-items: center; } #commentsTabView .comment .action { - opacity: 0; - padding: 5px; -} - -#commentsTabView .comment:hover .action { opacity: 0.3; + padding: 14px; + display: inline-block; + vertical-align: middle; } -#commentsTabView .comment .action:hover { +#commentsTabView .comment .action:hover, +#commentsTabView .comment .action:focus { opacity: 1; } -#commentsTabView .comment .action.delete, -#commentsTabView .comment .deleteLoading { - position: absolute; - right: 0; +#commentsTabView .newCommentRow .action-container { + margin-left: auto; + /** setting minimum width so as to avoid these two buttons from appearing on top of + each other when author name is long. width = icon-width * 2 + (inline-block gap) **/ + min-width: 92px; } #commentsTabView .comment.disabled { @@ -204,7 +199,7 @@ } #commentsTabView .comment.disabled .action { - visibility: hidden; + display: none; } #commentsTabView .message.error { diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index 73f19b7cd0b..36495e0690a 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -26,16 +26,16 @@ '
    ' + '
    {{actorDisplayName}}
    ' + '{{#if isEditMode}}' + - ' ' + - ' '+ + '
    ' + + ' ' + + ' ' + + ' '+ + '
    ' + '{{/if}}' + '
  • ' + '
    ' + '
    {{message}}
    ' + ' ' + - '{{#if isEditMode}}' + - ' ' + - '{{/if}}' + ' '+ '
    ' + ''; -- cgit v1.2.3 From 001cd986ed5ed8897043d9ce6d41d8a7b60af2f8 Mon Sep 17 00:00:00 2001 From: Abijeet Date: Fri, 19 Jan 2018 02:32:57 +0530 Subject: Converts the css file to scss file, and adds border-top to comments. Signed-off-by: Abijeet --- apps/comments/css/comments.css | 213 --------------------------------------- apps/comments/css/comments.scss | 217 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 217 insertions(+), 213 deletions(-) delete mode 100644 apps/comments/css/comments.css create mode 100644 apps/comments/css/comments.scss diff --git a/apps/comments/css/comments.css b/apps/comments/css/comments.css deleted file mode 100644 index 7f276f9f14f..00000000000 --- a/apps/comments/css/comments.css +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright (c) 2016 - * - * This file is licensed under the Affero General Public License version 3 - * or later. - * - * See the COPYING-README file. - * - */ - -#commentsTabView .emptycontent { - margin-top: 0; -} - -#commentsTabView .newCommentForm { - margin-left: 36px; -} - -#commentsTabView .newCommentForm .message { - /* width = 100% - (width of submit button (44px) + margin (3px) + inline-block gap) */ - width: calc(100% - 52px); - display: inline-block; -} - -#commentsTabView .newCommentForm .submit { - width: 44px; - margin: 0; - padding: 13px; - background-color: transparent; - border: none; - opacity: .3; - vertical-align: bottom; -} - -#commentsTabView .deleteLoading { - float: right; - padding: 14px; - vertical-align: middle; -} - -#commentsTabView .submitLoading { - vertical-align: bottom; - display: inline-block; - padding: 14px; -} - -#commentsTabView .newCommentForm .submit:not(:disabled):hover, -#commentsTabView .newCommentForm .submit:not(:disabled):focus { - opacity: 1; -} - -#commentsTabView .newCommentForm .cancel { - margin-right: 6px; -} - -#commentsTabView .newCommentForm div.message { - resize: none; -} - -#commentsTabView .newCommentForm div.message:empty:before { - content: attr(data-placeholder); - color: grey; -} - -#commentsTabView .comment { - position: relative; - /** padding bottom is little more so that the top and bottom gap look uniform **/ - padding: 10px 0px 15px; - word-wrap: break-word; - overflow-wrap: break-word; -} - -#commentsTabView .comment .avatar, -.atwho-view-ul * .avatar{ - width: 32px; - height: 32px; - line-height: 32px; - margin-right: 5px; -} - -#commentsTabView .comment .message .avatar, -.atwho-view-ul * .avatar -{ - display: inline-block; -} - -#activityTabView li.comment.collapsed .activitymessage, -#commentsTabView .comment.collapsed .message { - white-space: pre-wrap; -} - -#activityTabView li.comment.collapsed .activitymessage, -#commentsTabView .comment.collapsed .message { - max-height: 70px; - overflow: hidden; -} - -#activityTabView li.comment .message-overlay, -#commentsTabView .comment .message-overlay { - display: none; -} - -#activityTabView li.comment.collapsed .message-overlay, -#commentsTabView .comment.collapsed .message-overlay { - display: block; - position: absolute; - z-index: 2; - height: 50px; - pointer-events: none; - left: 0; - right: 0; - bottom: 0; - background: -moz-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1)); - background: -webkit-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1)); - background: -o-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1)); - background: -ms-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1)); - background: linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1)); - background-repeat: no-repeat; -} - -#commentsTabView .hidden { - display: none !important; -} - -/** set min-height as 44px to ensure that it fits the button sizes. **/ -#commentsTabView .comment .authorRow { - min-height: 44px; -} -#commentsTabView .comment .authorRow .tooltip { - /** because of the padding on the element, the tooltip appear too far up, - adding this brings them closer to the element**/ - margin-top: 5px; -} -#commentsTabView .comments li .message .avatar-name-wrapper, -.atwho-view-ul * .avatar-name-wrapper, -#commentsTabView .comment .authorRow { - position: relative; - display: inline-flex; - align-items: center; - width: 100%; -} - -#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; -} - -.atwho-view-ul .avatar-name-wrapper, -.atwho-view-ul .avatar-name-wrapper .avatar { - cursor: pointer; -} - -#commentsTabView .comments li .message .atwho-inserted { - margin-left: 5px; -} - -.atwho-view-ul * .avatar-name-wrapper { - white-space: nowrap; -} - -#commentsTabView .comment .author, -#commentsTabView .comment .date { - opacity: .5; -} -#commentsTabView .comment .date { - margin-left: auto; - /** this is to fix the tooltip being too close due to the margin-top applied - to bring the tooltip closer for the action icons **/ - padding: 10px 0px; -} - -#commentsTabView .comments > li:not(.newCommentRow) .message { - padding-left: 40px; -} - -#commentsTabView .comment .action { - opacity: 0.3; - padding: 14px; - display: inline-block; - vertical-align: middle; -} - -#commentsTabView .comment .action:hover, -#commentsTabView .comment .action:focus { - opacity: 1; -} - -#commentsTabView .newCommentRow .action-container { - margin-left: auto; - /** setting minimum width so as to avoid these two buttons from appearing on top of - each other when author name is long. width = icon-width * 2 + (inline-block gap) **/ - min-width: 92px; -} - -#commentsTabView .comment.disabled { - opacity: 0.3; -} - -#commentsTabView .comment.disabled .action { - display: none; -} - -#commentsTabView .message.error { - color: #e9322d; - border-color: #e9322d; - box-shadow: 0 0 6px #f8b9b7; -} - -.app-files .action-comment { - padding: 16px 14px; -} diff --git a/apps/comments/css/comments.scss b/apps/comments/css/comments.scss new file mode 100644 index 00000000000..88b890323aa --- /dev/null +++ b/apps/comments/css/comments.scss @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2016 + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + * + */ + +#commentsTabView .emptycontent { + margin-top: 0; +} + +#commentsTabView .newCommentForm { + margin-left: 36px; +} + +#commentsTabView .newCommentForm .message { + /* width = 100% - (width of submit button (44px) + margin (3px) + inline-block gap) */ + width: calc(100% - 52px); + display: inline-block; +} + +#commentsTabView .newCommentForm .submit { + width: 44px; + margin: 0; + padding: 13px; + background-color: transparent; + border: none; + opacity: .3; + vertical-align: bottom; +} + +#commentsTabView .deleteLoading { + float: right; + padding: 14px; + vertical-align: middle; +} + +#commentsTabView .submitLoading { + vertical-align: bottom; + display: inline-block; + padding: 14px; +} + +#commentsTabView .newCommentForm .submit:not(:disabled):hover, +#commentsTabView .newCommentForm .submit:not(:disabled):focus { + opacity: 1; +} + +#commentsTabView .newCommentForm .cancel { + margin-right: 6px; +} + +#commentsTabView .newCommentForm div.message { + resize: none; +} + +#commentsTabView .newCommentForm div.message:empty:before { + content: attr(data-placeholder); + color: grey; +} + +#commentsTabView .comment { + position: relative; + /** padding bottom is little more so that the top and bottom gap look uniform **/ + padding: 10px 0px 15px; + word-wrap: break-word; + overflow-wrap: break-word; +} + +#commentsTabView .comments .comment { + border-top: 1px solid $color-border; +} + +#commentsTabView .comment .avatar, +.atwho-view-ul * .avatar{ + width: 32px; + height: 32px; + line-height: 32px; + margin-right: 5px; +} + +#commentsTabView .comment .message .avatar, +.atwho-view-ul * .avatar +{ + display: inline-block; +} + +#activityTabView li.comment.collapsed .activitymessage, +#commentsTabView .comment.collapsed .message { + white-space: pre-wrap; +} + +#activityTabView li.comment.collapsed .activitymessage, +#commentsTabView .comment.collapsed .message { + max-height: 70px; + overflow: hidden; +} + +#activityTabView li.comment .message-overlay, +#commentsTabView .comment .message-overlay { + display: none; +} + +#activityTabView li.comment.collapsed .message-overlay, +#commentsTabView .comment.collapsed .message-overlay { + display: block; + position: absolute; + z-index: 2; + height: 50px; + pointer-events: none; + left: 0; + right: 0; + bottom: 0; + background: -moz-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1)); + background: -webkit-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1)); + background: -o-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1)); + background: -ms-linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1)); + background: linear-gradient(rgba(255,255,255,0), rgba(255,255,255,1)); + background-repeat: no-repeat; +} + +#commentsTabView .hidden { + display: none !important; +} + +/** set min-height as 44px to ensure that it fits the button sizes. **/ +#commentsTabView .comment .authorRow { + min-height: 44px; +} +#commentsTabView .comment .authorRow .tooltip { + /** because of the padding on the element, the tooltip appear too far up, + adding this brings them closer to the element**/ + margin-top: 5px; +} +#commentsTabView .comments li .message .avatar-name-wrapper, +.atwho-view-ul * .avatar-name-wrapper, +#commentsTabView .comment .authorRow { + position: relative; + display: inline-flex; + align-items: center; + width: 100%; +} + +#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; +} + +.atwho-view-ul .avatar-name-wrapper, +.atwho-view-ul .avatar-name-wrapper .avatar { + cursor: pointer; +} + +#commentsTabView .comments li .message .atwho-inserted { + margin-left: 5px; +} + +.atwho-view-ul * .avatar-name-wrapper { + white-space: nowrap; +} + +#commentsTabView .comment .author, +#commentsTabView .comment .date { + opacity: .5; +} +#commentsTabView .comment .date { + margin-left: auto; + /** this is to fix the tooltip being too close due to the margin-top applied + to bring the tooltip closer for the action icons **/ + padding: 10px 0px; +} + +#commentsTabView .comments > li:not(.newCommentRow) .message { + padding-left: 40px; +} + +#commentsTabView .comment .action { + opacity: 0.3; + padding: 14px; + display: inline-block; + vertical-align: middle; +} + +#commentsTabView .comment .action:hover, +#commentsTabView .comment .action:focus { + opacity: 1; +} + +#commentsTabView .newCommentRow .action-container { + margin-left: auto; + /** setting minimum width so as to avoid these two buttons from appearing on top of + each other when author name is long. width = icon-width * 2 + (inline-block gap) **/ + min-width: 92px; +} + +#commentsTabView .comment.disabled { + opacity: 0.3; +} + +#commentsTabView .comment.disabled .action { + display: none; +} + +#commentsTabView .message.error { + color: #e9322d; + border-color: #e9322d; + box-shadow: 0 0 6px #f8b9b7; +} + +.app-files .action-comment { + padding: 16px 14px; +} -- cgit v1.2.3 From 872853af58398c514eca40a014580a76d36a2da6 Mon Sep 17 00:00:00 2001 From: Abijeet Date: Sun, 4 Feb 2018 01:15:53 +0530 Subject: Moves the edit and delete options into a dropdown menu. Fixes #7281 - Added a new View to render the dropdown. - Modified the existing code. Signed-off-by: Abijeet --- apps/comments/css/comments.scss | 12 +--- apps/comments/js/commentsmodifymenu.js | 122 +++++++++++++++++++++++++++++++++ apps/comments/js/commentstabview.js | 41 +++++++---- apps/comments/js/merged.json | 1 + 4 files changed, 151 insertions(+), 25 deletions(-) create mode 100644 apps/comments/js/commentsmodifymenu.js diff --git a/apps/comments/css/comments.scss b/apps/comments/css/comments.scss index 88b890323aa..5e0bbce28a1 100644 --- a/apps/comments/css/comments.scss +++ b/apps/comments/css/comments.scss @@ -49,10 +49,6 @@ opacity: 1; } -#commentsTabView .newCommentForm .cancel { - margin-right: 6px; -} - #commentsTabView .newCommentForm div.message { resize: none; } @@ -182,8 +178,7 @@ #commentsTabView .comment .action { opacity: 0.3; padding: 14px; - display: inline-block; - vertical-align: middle; + display: block; } #commentsTabView .comment .action:hover, @@ -193,9 +188,6 @@ #commentsTabView .newCommentRow .action-container { margin-left: auto; - /** setting minimum width so as to avoid these two buttons from appearing on top of - each other when author name is long. width = icon-width * 2 + (inline-block gap) **/ - min-width: 92px; } #commentsTabView .comment.disabled { @@ -214,4 +206,4 @@ .app-files .action-comment { padding: 16px 14px; -} +} \ No newline at end of file diff --git a/apps/comments/js/commentsmodifymenu.js b/apps/comments/js/commentsmodifymenu.js new file mode 100644 index 00000000000..bd777ba5fa6 --- /dev/null +++ b/apps/comments/js/commentsmodifymenu.js @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2018 + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + * + */ +(function() { + var TEMPLATE_MENU = + ''; + + /** + * Construct a new CommentsModifyMenuinstance + * @constructs CommentsModifyMenu + * @memberof OC.Comments + */ + var CommentsModifyMenu = OC.Backbone.View.extend({ + tagName: 'div', + className: 'commentsModifyMenu popovermenu bubble menu', + _scopes: [ + { + name: 'edit', + displayName: t('comments', 'Edit comment'), + iconClass: 'icon-rename' + }, + { + name: 'delete', + displayName: t('comments', 'Delete comment'), + iconClass: 'icon-delete' + } + ], + initialize: function() { + + }, + events: { + 'click a.action': '_onClickAction' + }, + + template: Handlebars.compile(TEMPLATE_MENU), + + /** + * Event handler whenever an action has been clicked within the menu + * + * @param {Object} event event object + */ + _onClickAction: function(event) { + var $target = $(event.currentTarget); + if (!$target.hasClass('menuitem')) { + $target = $target.closest('.menuitem'); + } + + this.trigger('select:menu-item-clicked', event, $target.data('action')); + + OC.hideMenus(); + }, + + /** + * Renders the menu with the currently set items + */ + render: function() { + this.$el.html(this.template({ + items: this._scopes + })); + }, + + /** + * Displays the menu + */ + show: function(context) { + this._context = context; + + for(var i in this._scopes) { + this._scopes[i].active = false; + } + + + var $el = $(context.target); + var offsetIcon = $el.offset(); + var offsetContainer = $el.closest('.authorRow').offset(); + + // adding some extra top offset to push the menu below the button. + var position = { + top: offsetIcon.top - offsetContainer.top + 48, + left: '', + right: '' + }; + + position.left = offsetIcon.left - offsetContainer.left; + + if (position.left > 200) { + // we need to position the menu to the right. + position.left = ''; + position.right = this.$el.closest('.comment').find('.date').width(); + this.$el.removeClass('menu-left').addClass('menu-right'); + } else { + this.$el.removeClass('menu-right').addClass('menu-left'); + } + this.$el.css(position); + this.render(); + this.$el.removeClass('hidden'); + + OC.showMenu(null, this.$el); + } + }); + + OCA.Comments = OCA.Comments || {}; + OCA.Comments.CommentsModifyMenu = CommentsModifyMenu; +})(OC, OCA);; \ No newline at end of file diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index 36495e0690a..ad5f67842db 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -27,9 +27,7 @@ '
    {{actorDisplayName}}
    ' + '{{#if isEditMode}}' + '
    ' + - ' ' + ' ' + - ' '+ '
    ' + '{{/if}}' + ' ' + @@ -46,7 +44,8 @@ '
    ' + '
    {{actorDisplayName}}
    ' + '{{#if isUserAuthor}}' + - ' ' + + ' ' + + ' ' + '{{/if}}' + '
    {{date}}
    ' + ' ' + @@ -64,12 +63,11 @@ id: 'commentsTabView', className: 'tab commentsTabView', _autoCompleteData: undefined, + _commentsModifyMenu: undefined, events: { 'submit .newCommentForm': '_onSubmitComment', 'click .showMore': '_onClickShowMore', - 'click .action.edit': '_onClickEditComment', - 'click .action.delete': '_onClickDeleteComment', 'click .cancel': '_onClickCloseComment', 'click .comment': '_onClickComment', 'keyup div.message': '_onTextChange', @@ -114,7 +112,6 @@ actorId: currentUser.uid, actorDisplayName: currentUser.displayName, newMessagePlaceholder: t('comments', 'New comment …'), - deleteTooltip: t('comments', 'Delete comment'), submitText: t('comments', 'Post'), cancelText: t('comments', 'Cancel'), tag: 'li' @@ -402,6 +399,24 @@ // it is the case when writing a comment and mentioning a person $message = $el; } + + + if (!editionMode) { + var self = this; + // add the dropdown menu to display the edit and delete option + var modifyCommentMenu = new OCA.Comments.CommentsModifyMenu(); + $el.find('.authorRow').append(modifyCommentMenu.$el); + $el.find('.more').on('click', _.bind(modifyCommentMenu.show, modifyCommentMenu)); + + self.listenTo(modifyCommentMenu, 'select:menu-item-clicked', function(ev, action) { + if (action === 'edit') { + self._onClickEditComment(ev); + } else if (action === 'delete') { + self._onClickDeleteComment(ev); + } + }); + } + this._postRenderMessage($message, editionMode); }, @@ -568,15 +583,13 @@ var $comment = $(ev.target).closest('.comment'); var commentId = $comment.data('id'); var $loading = $comment.find('.deleteLoading'); - var $commentField = $comment.find('.message'); - var $submit = $comment.find('.submit'); - var $cancel = $comment.find('.cancel'); + var $moreIcon = $comment.find('.more'); - $commentField.prop('contenteditable', false); - $submit.prop('disabled', true); - $cancel.prop('disabled', true); $comment.addClass('disabled'); $loading.removeClass('hidden'); + $moreIcon.addClass('hidden'); + + $comment.data('commentEl', $comment); this.collection.get(commentId).destroy({ success: function() { @@ -585,10 +598,8 @@ }, error: function() { $loading.addClass('hidden'); + $moreIcon.removeClass('hidden'); $comment.removeClass('disabled'); - $commentField.prop('contenteditable', true); - $submit.prop('disabled', false); - $cancel.prop('disabled', false); OC.Notification.showTemporary(t('comments', 'Error occurred while retrieving comment with ID {id}', {id: commentId})); } diff --git a/apps/comments/js/merged.json b/apps/comments/js/merged.json index 0202c7ff55a..6e77d9cf80a 100644 --- a/apps/comments/js/merged.json +++ b/apps/comments/js/merged.json @@ -4,6 +4,7 @@ "commentcollection.js", "commentsummarymodel.js", "commentstabview.js", + "commentsmodifymenu.js", "filesplugin.js", "activitytabviewplugin.js", "vendor/Caret.js/dist/jquery.caret.min.js", -- cgit v1.2.3 From 6d2716dceb7791ef23f56510f9ceb29144b62dc1 Mon Sep 17 00:00:00 2001 From: Abijeet Date: Sun, 25 Feb 2018 20:10:56 +0530 Subject: Added ellipsis for longer usernames. Towards #7281 Signed-off-by: Abijeet --- apps/comments/css/comments.scss | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/comments/css/comments.scss b/apps/comments/css/comments.scss index 5e0bbce28a1..ec400a68090 100644 --- a/apps/comments/css/comments.scss +++ b/apps/comments/css/comments.scss @@ -159,11 +159,16 @@ .atwho-view-ul * .avatar-name-wrapper { white-space: nowrap; } - #commentsTabView .comment .author, #commentsTabView .comment .date { opacity: .5; } +#commentsTabView .comment .author { + max-width: 210px; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; +} #commentsTabView .comment .date { margin-left: auto; /** this is to fix the tooltip being too close due to the margin-top applied -- cgit v1.2.3 From 01c5a31a4ab04802ce4001e4e618d9812f83d69b Mon Sep 17 00:00:00 2001 From: Abijeet Date: Sun, 4 Mar 2018 11:36:33 +0530 Subject: Adds a tooltip for the submit / save button in comments. Towards #7281 Also hiding the menu before triggering click action. Signed-off-by: Abijeet --- apps/comments/js/commentsmodifymenu.js | 4 ++-- apps/comments/js/commentstabview.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/comments/js/commentsmodifymenu.js b/apps/comments/js/commentsmodifymenu.js index bd777ba5fa6..1c5f572d8cc 100644 --- a/apps/comments/js/commentsmodifymenu.js +++ b/apps/comments/js/commentsmodifymenu.js @@ -63,9 +63,9 @@ $target = $target.closest('.menuitem'); } - this.trigger('select:menu-item-clicked', event, $target.data('action')); - OC.hideMenus(); + + this.trigger('select:menu-item-clicked', event, $target.data('action')); }, /** diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js index ad5f67842db..9477cb0c301 100644 --- a/apps/comments/js/commentstabview.js +++ b/apps/comments/js/commentstabview.js @@ -33,7 +33,7 @@ ' ' + '
    ' + '
    {{message}}
    ' + - ' ' + + ' ' + ' '+ '
    ' + ''; -- cgit v1.2.3 From 18096f55d07a47c47e02239d82da5bebae617cec Mon Sep 17 00:00:00 2001 From: Abijeet Date: Sun, 11 Mar 2018 16:49:54 +0530 Subject: Disabled comment changes opacity only for message text. Signed-off-by: Abijeet --- apps/comments/css/comments.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/comments/css/comments.scss b/apps/comments/css/comments.scss index ec400a68090..c2bc136ba66 100644 --- a/apps/comments/css/comments.scss +++ b/apps/comments/css/comments.scss @@ -195,7 +195,7 @@ margin-left: auto; } -#commentsTabView .comment.disabled { +#commentsTabView .comment.disabled .message { opacity: 0.3; } -- cgit v1.2.3 From 16bf9326cb1ccb54351c04193755ade0f49588b4 Mon Sep 17 00:00:00 2001 From: Abijeet Date: Tue, 27 Mar 2018 01:34:00 +0530 Subject: Fixing failing test cases due to change in functionality. Also fixes scrutinizer warnings. Signed-off-by: Abijeet --- apps/comments/js/commentsmodifymenu.js | 8 +++-- apps/comments/tests/js/commentstabviewSpec.js | 42 +++++++++++++-------------- tests/karma.config.js | 3 +- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/apps/comments/js/commentsmodifymenu.js b/apps/comments/js/commentsmodifymenu.js index 1c5f572d8cc..4b17cbbfbf0 100644 --- a/apps/comments/js/commentsmodifymenu.js +++ b/apps/comments/js/commentsmodifymenu.js @@ -7,12 +7,14 @@ * See the COPYING-README file. * */ + +/* global Handlebars */ (function() { var TEMPLATE_MENU = '