Skip to content

Commit

Permalink
Implement cancel button comment edit (forem#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
JSSaini07 authored and maestromac committed Nov 5, 2018
1 parent ca63689 commit 908e82c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/assets/stylesheets/comments.scss
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ a.header-link{
appearance: none;
}

.comment-action-cancel {
background: $red;
display:none;
}

.comment-action-preview {
background: $dark-gray;
z-index: 10;
Expand Down
10 changes: 10 additions & 0 deletions app/views/comments/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
</div>
<% end %>
<div class="actions" id="submit-wrapper">
<a href="<%=commentable.path%>">
<button id="cancel-button" class="comment-action-button comment-action-cancel">CANCEL</button>
</a>
<button id="preview-button" class="comment-action-button comment-action-preview">PREVIEW</button>
<%= f.submit "SUBMIT", id: "submit-button", onclick:"validateField(event)", class:"comment-action-button" %>
</div>
Expand All @@ -72,3 +75,10 @@
}
}
</script>

<script async>
var formElement = document.getElementById("edit_comment_<%= @comment.id if @comment %>");
if (formElement) {
formElement.getElementsByClassName("comment-action-cancel")[0].style.display = "inline-block";
}
</script>

0 comments on commit 908e82c

Please sign in to comment.