Skip to content
Browse files

Merge branch 'master' of github.com:srir/tau

  • Loading branch information...
2 parents c3e84e8 + d5e0e25 commit a507dbcd56448b96ec115ceec7a5780948382e35 @dsyang dsyang committed
Showing with 98 additions and 25 deletions.
  1. +64 −13 public/css/style.css
  2. +29 −6 public/js/views/review.js
  3. +5 −6 views/review.html
View
77 public/css/style.css
@@ -37,7 +37,7 @@ ul {
}
textarea {
- border: 1px solid #999;
+ border: 1px solid #aaa;
display: block;
font-family: 'Helvetica', 'Arial', sans-serif;
font-size: 13px;
@@ -48,6 +48,16 @@ textarea {
display: none !important;
}
+.clearfix:after {
+ clear: both;
+ content: ".";
+ display: block;
+ font-size: 0;
+ height: 0;
+ line-height: 0;
+ visibility: hidden;
+}
+
.container {
margin: 0 auto;
width: 960px;
@@ -88,7 +98,8 @@ textarea {
text-decoration: none;
}
-.nav .logoutLink:hover {
+.nav .logoutLink:hover,
+#code .addComment .cancel:hover {
background-color: #ff5757;
color: #fff;
}
@@ -178,11 +189,15 @@ textarea {
background: #fff;
}
-#code dd.code.selected,
-#code dd.code.highlight {
+#code dd.code.highlight,
+#code dd.code.selected.highlight {
background: #fff;
}
+#code dd.code.selected {
+ background: #f7fa97;
+}
+
#code dd.hasCollapsedComment {
border-bottom: 1px solid #dc9917;
}
@@ -221,17 +236,53 @@ textarea {
}
#code dd.addComment {
- background: #d6f773;
- border-color: #858900;
- border-right: 1px solid #858900;
+ /*background: #d6f773;*/
+ /*border-color: #858900;*/
+ /*border-right: 1px solid #858900;*/
+ background: #f7fa97;
+ border-color: #999;
+ border-bottom: 1px solid #dc9917;
padding: 10px;
}
-#code textarea {
+#code .addComment textarea {
+ float: left;
height: 60px;
- padding: 5px;
+ padding: 2px;
resize: none;
- width: 628px;
+ width: 548px;
+}
+
+#code .addComment .actions {
+ margin-left: 554px;
+ width: 85px;
+}
+
+#code .addComment .actions a {
+ color: #333;
+ display: block;
+ padding: 8px 16px;
+ text-align: center;
+ width: 53px;
+}
+
+#code .addComment .submit {
+ background: #aaa;
+ border-radius: 0 2px 0 0;
+}
+
+#code .addComment .cancel {
+ background: #ccc;
+ border-radius: 0 0 2px;
+}
+
+#code .addComment .actions a:hover {
+ text-decoration: none;
+}
+
+#code .addComment .actions .submit:hover {
+ background: #8ec104;
+ color: #fff;
}
#code .addCommentOptions {
@@ -244,12 +295,12 @@ textarea {
background: #f7fa97;
border-color: #dc9917;
border-right: 1px solid #dc9917;
- padding: 0 5px 5px;
- width: 650px;
+ padding: 0 0 2px;
+ width: 660px;
}
#code dd.comment.first {
- padding-top: 5px;
+ padding-top: 2px;
}
.commentContainer {
View
35 public/js/views/review.js
@@ -58,7 +58,7 @@ $(function() {
},
commentCollapse: function(event) {
var comment = $(event.target).closest('dd.comment');
- comment.nextUntil('dt').slideUp(200);
+ comment.nextUntil('dt', 'dd.comment').slideUp(200);
$(comment).slideUp(200, function() {
$(this).prev().addClass('hasCollapsedComment');
});
@@ -88,6 +88,7 @@ $(function() {
codeLines: $('dd.code').get(),
selectedLines: [],
startLine: null,
+ commentFormTemplate: _.template($('#add-comment-template').html()),
commenting: false,
events: {
'mousedown dd.code' : 'onMouseDown',
@@ -166,8 +167,7 @@ $(function() {
var on_target =
$(event.target).closest('dd.code, dd.comment').get(0);
if (this.startLine && on_target) {
- // TODO(vsiao)
- // beginCommenting(selectedLines);
+ this.beginComment(this.selectedLines);
} else {
//form.slideUp(200).remove();
$(this.selectedLines).removeClass('selected');
@@ -175,11 +175,34 @@ $(function() {
}
this.startLine = null;
},
- cancelComment: function() {
-
+ beginComment: function(lines) {
+ this.commenting = true;
+ _.each(lines, function(line) {
+ var next = $(line.nextElementSibling);
+ if (next.hasClass('comment')) {
+ next.find('.commentCollapse').click();
+ }
+ });
+ var last_line = lines[lines.length-1];
+ var old_comments = $(last_line).nextUntil('dt').get();
+ var form = $(this.commentFormTemplate());
+ if (old_comments.length) {
+ form.insertAfter(old_comments[old_comments.length-1]).slideDown(200);
+ } else {
+ form.insertAfter(last_line).slideDown(200);;
+ }
+ },
+ cancelComment: function(event) {
+ $(event.target).closest('.addComment').slideUp(200, _.bind(function() {
+ $(this.selectedLines).removeClass('selected');
+ this.selectedLines = [];
+ this.commenting = false;
+ $(this).remove();
+ }, this));
+ return false;
},
submitComment: function() {
-
+
}
});
View
11 views/review.html
@@ -24,12 +24,11 @@
<a href="#" class="commentCollapse">-</a>
</script>
<script type="text/template" id="add-comment-template">
- <dd class="addComment">
- <textarea>Wow, you used the bang operator!</textarea>
- <ul class="addCommentOptions">
- <li><a href="#">:)</a></li>
- <li><a href="#">:|</a></li>
- <li><a href="#">:(</a></li>
+ <dd class="addComment clearfix" style="display:none;">
+ <textarea></textarea>
+ <ul class="actions">
+ <li><a href="#" class="submit">Submit</a></li>
+ <li><a href="#" class="cancel">Cancel</a></li>
</ul>
</dd>
</script>

0 comments on commit a507dbc

Please sign in to comment.
Something went wrong with that request. Please try again.