diff --git a/app/assets/javascripts/app/views/comment_mention_view.js b/app/assets/javascripts/app/views/comment_mention_view.js new file mode 100644 index 000000000..52b125774 --- /dev/null +++ b/app/assets/javascripts/app/views/comment_mention_view.js @@ -0,0 +1,10 @@ +// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later +//= require ./publisher/mention_view + +app.views.CommentMention = app.views.PublisherMention.extend({ + initialize: function(opts) { + opts.url = Routes.mentionablePost(opts.postId); + app.views.PublisherMention.prototype.initialize.call(this, opts); + } +}); +// @license-end diff --git a/app/assets/javascripts/app/views/comment_stream_view.js b/app/assets/javascripts/app/views/comment_stream_view.js index 05ba192db..c6374a301 100644 --- a/app/assets/javascripts/app/views/comment_stream_view.js +++ b/app/assets/javascripts/app/views/comment_stream_view.js @@ -27,6 +27,7 @@ app.views.CommentStream = app.views.Base.extend({ this.model.comments.each(this.appendComment, this); this.commentBox = this.$(".comment_box"); this.commentSubmitButton = this.$("input[name='commit']"); + new app.views.CommentMention({el: this.$el, postId: this.model.get("id")}); }, presenter: function(){ diff --git a/app/assets/javascripts/app/views/publisher/mention_view.js b/app/assets/javascripts/app/views/publisher/mention_view.js index f30779c70..bf15dc85e 100644 --- a/app/assets/javascripts/app/views/publisher/mention_view.js +++ b/app/assets/javascripts/app/views/publisher/mention_view.js @@ -6,15 +6,16 @@ app.views.PublisherMention = app.views.SearchBase.extend({ mentionSyntaxTemplate: function(person) { return "@{" + person.handle + "}"; }, events: { - "keydown #status_message_text": "onInputBoxKeyDown", - "input #status_message_text": "updateTypeaheadInput", - "click #status_message_text": "onInputBoxClick", - "blur #status_message_text": "onInputBoxBlur" + "keydown .mention-textarea": "onInputBoxKeyDown", + "input .mention-textarea": "updateTypeaheadInput", + "click .mention-textarea": "onInputBoxClick", + "blur .mention-textarea": "onInputBoxBlur" }, - initialize: function() { + initialize: function(opts) { this.mentionedPeople = []; - this.inputBox = this.$("#status_message_text"); + var url = (opts && opts.url) || "/contacts"; + this.inputBox = this.$(".mention-textarea"); this.typeaheadInput = this.$(".typeahead-mention-box"); this.bindTypeaheadEvents(); @@ -22,7 +23,7 @@ app.views.PublisherMention = app.views.SearchBase.extend({ typeaheadInput: this.typeaheadInput, customSearch: true, autoselect: true, - remoteRoute: {url: "/contacts"} + remoteRoute: {url: url} }); }, diff --git a/app/assets/stylesheets/comments.scss b/app/assets/stylesheets/comments.scss index 533c9cffb..54d5f1973 100644 --- a/app/assets/stylesheets/comments.scss +++ b/app/assets/stylesheets/comments.scss @@ -46,7 +46,7 @@ .comment.new-comment-form-wrapper { padding-bottom: 0; } - .submit_button { + .submit-button { margin-top: 10px; input { float: right; @@ -60,7 +60,7 @@ } textarea.comment_box:focus, textarea.comment_box:valid, textarea.comment_box:active { border-color: $border-dark-grey; - & + .submit_button { display: block; } + ~ .submit-button { display: block; } min-height: 35px; box-shadow: none; } diff --git a/app/assets/stylesheets/mentions.scss b/app/assets/stylesheets/mentions.scss index c9af7be45..97cd758ed 100644 --- a/app/assets/stylesheets/mentions.scss +++ b/app/assets/stylesheets/mentions.scss @@ -65,3 +65,21 @@ } } } + +.typeahead-mention-box-wrap .twitter-typeahead { + left: -1px; + width: calc(100% + 2px); + + .tt-menu { + // Override inline rule of Typeahead + // If this is not overridden (`position: absolute` by default in Typeahead) then + // the box is cut when opened because of the `overflow: hidden` from parent classes of comment form styles. By + // having `position: relative` here we make it visible by inserting it in the flow. + // This has a side effect of "Comment" button move down when box is open, but it feels like the least evil. + // scss-lint:disable ImportantRule + position: relative !important; + // scss-lint:enable ImportantRule + + width: 100%; + } +} diff --git a/app/assets/stylesheets/publisher.scss b/app/assets/stylesheets/publisher.scss index 94510aed7..f95480c94 100644 --- a/app/assets/stylesheets/publisher.scss +++ b/app/assets/stylesheets/publisher.scss @@ -19,12 +19,6 @@ .container-fluid{ padding: 0; } - .twitter-typeahead { - width: calc(100% + 2px); - - .tt-menu { width: 100%; } - } - form { margin: 0; #fileInfo { display: none !important; } @@ -245,7 +239,6 @@ } .twitter-typeahead { - left: -1px; // Override inline rule of Typeahead // scss-lint:disable ImportantRule position: absolute !important; diff --git a/app/assets/templates/comment-stream_tpl.jst.hbs b/app/assets/templates/comment-stream_tpl.jst.hbs index e7343507d..cf3bb4652 100644 --- a/app/assets/templates/comment-stream_tpl.jst.hbs +++ b/app/assets/templates/comment-stream_tpl.jst.hbs @@ -26,8 +26,14 @@