Replace comment_box with comment-box
This commit is contained in:
parent
7457f254c1
commit
473cc2518b
9 changed files with 16 additions and 16 deletions
|
|
@ -7,7 +7,7 @@ app.views.CommentStream = app.views.Base.extend({
|
||||||
className : "comment_stream",
|
className : "comment_stream",
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
"keydown .comment_box": "keyDownOnCommentBox",
|
"keydown .comment-box": "keyDownOnCommentBox",
|
||||||
"submit form": "createComment",
|
"submit form": "createComment",
|
||||||
"click .toggle_post_comments": "expandComments",
|
"click .toggle_post_comments": "expandComments",
|
||||||
"click form": "openForm"
|
"click form": "openForm"
|
||||||
|
|
@ -26,11 +26,11 @@ app.views.CommentStream = app.views.Base.extend({
|
||||||
|
|
||||||
postRenderTemplate : function() {
|
postRenderTemplate : function() {
|
||||||
this.model.comments.each(this.appendComment, this);
|
this.model.comments.each(this.appendComment, this);
|
||||||
this.commentBox = this.$(".comment_box");
|
this.commentBox = this.$(".comment-box");
|
||||||
this.commentSubmitButton = this.$("input[name='commit']");
|
this.commentSubmitButton = this.$("input[name='commit']");
|
||||||
this.mentions = new app.views.CommentMention({el: this.$el, postId: this.model.get("id")});
|
this.mentions = new app.views.CommentMention({el: this.$el, postId: this.model.get("id")});
|
||||||
|
|
||||||
this.mdEditor = new Diaspora.MarkdownEditor(this.$(".comment_box"), {
|
this.mdEditor = new Diaspora.MarkdownEditor(this.$(".comment-box"), {
|
||||||
onPreview: function($mdInstance) {
|
onPreview: function($mdInstance) {
|
||||||
var renderedText = app.helpers.textFormatter($mdInstance.getContent(), this.mentions.getMentionedPeople());
|
var renderedText = app.helpers.textFormatter($mdInstance.getContent(), this.mentions.getMentionedPeople());
|
||||||
return "<div class='preview-content'>" + renderedText + "</div>";
|
return "<div class='preview-content'>" + renderedText + "</div>";
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ app.views.SinglePostActions = app.views.Feedback.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
focusComment: function() {
|
focusComment: function() {
|
||||||
$('.comment_stream .comment_box').focus();
|
$('.comment_stream .comment-box').focus();
|
||||||
$('html,body').animate({scrollTop: $('.comment_stream .comment_box').offset().top - ($('.comment_stream .comment_box').height() + 20)});
|
$('html,body').animate({scrollTop: $('.comment_stream .comment-box').offset().top - ($('.comment_stream .comment-box').height() + 20)});
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ app.views.StreamPost = app.views.Post.extend({
|
||||||
focusCommentTextarea: function(evt){
|
focusCommentTextarea: function(evt){
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
this.$(".new-comment-form-wrapper").removeClass("hidden");
|
this.$(".new-comment-form-wrapper").removeClass("hidden");
|
||||||
this.$(".comment_box").focus();
|
this.$(".comment-box").focus();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
new Diaspora.MarkdownEditor(".comment_box");
|
new Diaspora.MarkdownEditor(".comment-box");
|
||||||
|
|
||||||
this.stream().on("tap click", "a.show-comments", function(evt){
|
this.stream().on("tap click", "a.show-comments", function(evt){
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
submitComment: function(evt){
|
submitComment: function(evt){
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
var form = $(this);
|
var form = $(this);
|
||||||
var commentBox = form.find(".comment_box");
|
var commentBox = form.find(".comment-box");
|
||||||
var commentText = $.trim(commentBox.val());
|
var commentText = $.trim(commentBox.val());
|
||||||
if(!commentText){
|
if(!commentText){
|
||||||
commentBox.focus();
|
commentBox.focus();
|
||||||
|
|
@ -169,7 +169,7 @@
|
||||||
|
|
||||||
showCommentBox: function(link){
|
showCommentBox: function(link){
|
||||||
var bottomBar = link.closest(".bottom-bar").first();
|
var bottomBar = link.closest(".bottom-bar").first();
|
||||||
var textArea = bottomBar.find("textarea.comment_box").first()[0];
|
var textArea = bottomBar.find("textarea.comment-box").first()[0];
|
||||||
bottomBar.find(".add-comment-switcher").removeClass("hidden");
|
bottomBar.find(".add-comment-switcher").removeClass("hidden");
|
||||||
autosize(textArea);
|
autosize(textArea);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,11 @@
|
||||||
}
|
}
|
||||||
padding-left: 12px;
|
padding-left: 12px;
|
||||||
}
|
}
|
||||||
.comment_box {
|
.comment-box {
|
||||||
height: 35px;
|
height: 35px;
|
||||||
resize: none;
|
resize: none;
|
||||||
}
|
}
|
||||||
textarea.comment_box:focus, textarea.comment_box:valid, textarea.comment_box:active {
|
textarea.comment-box:focus, textarea.comment-box:valid, textarea.comment-box:active {
|
||||||
border-color: $border-dark-grey;
|
border-color: $border-dark-grey;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
<form accept-charset="UTF-8" action="/posts/{{id}}/comments"
|
<form accept-charset="UTF-8" action="/posts/{{id}}/comments"
|
||||||
class="new-comment" id="new-comment-on-{{id}}" method="post">
|
class="new-comment" id="new-comment-on-{{id}}" method="post">
|
||||||
|
|
||||||
<textarea class="comment_box form-control mention-textarea"
|
<textarea class="comment-box form-control mention-textarea"
|
||||||
id="comment_text_on_{{id}}" name="text" rows="1" required placeholder="{{t "stream.comment"}}" />
|
id="comment_text_on_{{id}}" name="text" rows="1" required placeholder="{{t "stream.comment"}}" />
|
||||||
<div class="typeahead-mention-box-wrap">
|
<div class="typeahead-mention-box-wrap">
|
||||||
<input class="typeahead-mention-box hidden" type="text">
|
<input class="typeahead-mention-box hidden" type="text">
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
%fieldset
|
%fieldset
|
||||||
= hidden_field_tag :post_id, post_id, id: "post-id-on-#{post_id}"
|
= hidden_field_tag :post_id, post_id, id: "post-id-on-#{post_id}"
|
||||||
.form-group.clearfix
|
.form-group.clearfix
|
||||||
= text_area_tag :text, nil, class: "col-md-12 comment_box form-control",
|
= text_area_tag :text, nil, class: "col-md-12 comment-box form-control",
|
||||||
id: "comment-text-on-#{post_id}", placeholder: t(".comment")
|
id: "comment-text-on-#{post_id}", placeholder: t(".comment")
|
||||||
= submit_tag t(".comment"), :id => "comment-submit-#{post_id}", "data-disable-with" => t(".commenting"),
|
= submit_tag t(".comment"), :id => "comment-submit-#{post_id}", "data-disable-with" => t(".commenting"),
|
||||||
"data-reset-with" => t(".comment"), :class => "btn btn-primary btn-block comment-button"
|
"data-reset-with" => t(".comment"), :class => "btn btn-primary btn-block comment-button"
|
||||||
|
|
|
||||||
|
|
@ -40,5 +40,5 @@ Given /^"([^"]*)" has commented a lot on "([^"]*)"$/ do |email, post_text|
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^I enter "([^"]*)" in the comment field$/ do |comment_text|
|
When /^I enter "([^"]*)" in the comment field$/ do |comment_text|
|
||||||
find("textarea.comment_box.mention-textarea").native.send_keys(comment_text)
|
find("textarea.comment-box.mention-textarea").native.send_keys(comment_text)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ describe("app.views.CommentStream", function(){
|
||||||
this.view.commentBox = undefined;
|
this.view.commentBox = undefined;
|
||||||
this.view.postRenderTemplate();
|
this.view.postRenderTemplate();
|
||||||
expect(this.view.commentBox).toBeDefined();
|
expect(this.view.commentBox).toBeDefined();
|
||||||
expect(this.view.commentBox).toEqual(this.view.$(".comment_box"));
|
expect(this.view.commentBox).toEqual(this.view.$(".comment-box"));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sets commentSubmitButton", function() {
|
it("sets commentSubmitButton", function() {
|
||||||
|
|
@ -124,7 +124,7 @@ describe("app.views.CommentStream", function(){
|
||||||
|
|
||||||
context("submission", function() {
|
context("submission", function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
this.view.$(".comment_box").val('a new comment');
|
this.view.$(".comment-box").val('a new comment');
|
||||||
this.view.createComment();
|
this.view.createComment();
|
||||||
|
|
||||||
this.request = jasmine.Ajax.requests.mostRecent();
|
this.request = jasmine.Ajax.requests.mostRecent();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue