Permalink
Browse files

post#show finished

  • Loading branch information...
1 parent b5a3cb2 commit 616757952dffdfce3ca51887d0c36a1b8a1d7339 @liudangyi liudangyi committed Oct 28, 2012
@@ -14,6 +14,12 @@
@import "bootstrap/bootstrap.less";
+small.author {
+ line-height: 20px;
+ font-size: 14px;
+ color: #333;
+ font-weight: bold;
+}
small.time {
color: #999;
font-size: 12px;
@@ -1,5 +1,6 @@
class Comment
include Mongoid::Document
+ include Mongoid::Timestamps::Created
field :content, type: String
belongs_to :news
@@ -11,8 +11,8 @@ h1 留言板
li.msg-li {
clear: both;
- padding: 10px;
- min-height: 60px;
+ padding: 10px 0;
+ min-height: 50px;
border-top: 1px #AAA solid;
position: relative;
.delete-alert {
@@ -25,21 +25,22 @@ h1 留言板
}
}
.msg-form {
- padding: 10px;
+ padding: 10px 0;
form {
margin-left: 60px;
margin-bottom: 0px;
position: relative;
textarea {
height: 40px;
- width: 516px;
- max-width: 516px;
+ width: 536px;
+ max-width: 536px;
+ margin-bottom: 5px;
.transition(all 0.5s ease);
}
button.btn {
position: absolute;
right: 0px;
- bottom: 15px;
+ bottom: 10px;
display: none;
}
}
@@ -56,10 +57,9 @@ ul.unstyled
li.msg-li
= message.author ? image_tag(message.author.avatar, width: '50', height: '50', class: 'pull-left') : ''
div style="margin-left: 60px;"
- h5
- = message.author ? message.author.name : "匿名用户"
- |   
- small.time = beautify_time(message.created_at) if message.created_at
+ small.author = message.author ? message.author.name : "匿名用户"
+ |   
+ small.time = beautify_time(message.created_at) if message.created_at
= link_to message, :method => :delete, :remote => true, class: "delete-alert pull-right" do
i.icon-remove.pull-right
div
@@ -78,14 +78,14 @@ br
return false;
})
$('.msg-form textarea').focus(function(){
- $(this).css('height','70px').css('width','450px').css('max-width','450px');
+ $(this).css('height','70px').css('width','470px').css('max-width','470px');
$(this).siblings('button').delay(200).fadeIn('slow');
}).blur(function(){
if ($(this).val() == '') {
$(this).siblings('button').fadeOut('slow');
var textarea = this;
setTimeout(function(){
- $(textarea).css('height','40px').css('width','516px').css('max-width','516px');
+ $(textarea).css('height','40px').css('width','536px').css('max-width','536px');
},250);
}
})
@@ -1,44 +1,109 @@
- content_for :style do
less:
+ .transition(@transition) {
+ -webkit-transition: @transition;
+ -moz-transition: @transition;
+ -o-transition: @transition;
+ transition: @transition;
+ }
.post {
-
+ padding: 0px 0px 10px 0px;
}
- .comment {
-
+ ul.comments {
+ li.comment {
+ position: relative;
+ .delete-alert {
+ position: absolute;
+ top: 8px;
+ right: 0px;
+ }
+ .floor {
+ font-family: 'Courier New', Times, serif;
+ font-size: 16px;
+ font-weight: bold;
+ position: absolute;
+ top: 10px;
+ right: 25px;
+ }
+ padding: 10px 0;
+ border-top: 1px #AAA solid;
+ min-height: 50px;
+ p {
+ margin-bottom: 0px;
+ }
+ }
+ .cmt-form {
+ form {
+ margin-left: 60px;
+ margin-bottom: 0px;
+ position: relative;
+ textarea {
+ height: 40px;
+ width: 536px;
+ max-width: 536px;
+ margin-bottom: 5px;
+ .transition(all 0.5s ease);
+ }
+ button.btn {
+ position: absolute;
+ right: 0px;
+ bottom: 10px;
+ display: none;
+ }
+ }
+ }
}
-
-p#notice = notice
-
-p
- strong Title:
- = @post.title
-p
- strong Content:
- == @post.content
-
-ul
- - @post.comments.each do |comment|
- li
- = comment.content
-
-
-= link_to 'Edit', edit_post_path(@post)
-'|
-= link_to 'Back', posts_path
-
-= form_for @comment, url: comment_post_path do |f|
- = f.text_field :content
- = f.submit "回复"
-
+- if notice
+ p.alert#notice = notice
.post
- = image_tag @post.author.avatar, width: '80', height: '80'
+ = image_tag @post.author.avatar, width: '80', height: '80', class: 'pull-left'
div style="margin-left: 90px;"
- h5
-
-ul.comments
- li.comment
-
+ h4 style="margin-top: 0px;" = @post.title
+ p
+ small.author = @post.author.name
+ |   
+ small.time = beautify_time(@post.created_at)
+ == @post.content
+ul.comments.unstyled
+ - @post.comments.each_with_index do |comment, index|
+ li.comment
+ .floor = '#' + (index + 1).to_s
+ = link_to delete_comment_post_path(comment_id: comment.id), :remote => true, class: "delete-alert" do
+ i.icon-remove
+ = image_tag comment.author.avatar, width: '50', height: '50', class: 'pull-left' if comment.author
+ div style="margin-left: 60px;"
+ p
+ small.author = comment.author.name
+ |   
+ small.time = beautify_time(comment.created_at) if comment.created_at
+ == comment.content
+ li.comment.cmt-form
+ = image_tag(current_user.avatar, width: '50', height: '50', class: 'pull-left')
+ = form_for @comment, url: comment_post_path do |f|
+ = f.text_area :content, rows: 3, placeholder: '回复'
+ button type="submit" class="btn btn-primar-0-y" 回复
+= content_for :script do
+ javascript:
+ $('.delete-alert').click(function(){
+ if (confirm('确认删除吗?')) {
+ $(this).parent().css('min-height','0').slideUp('slow');
+ return true;
+ }
+ return false;
+ })
+ $('.cmt-form textarea').focus(function(){
+ $(this).css('height','70px').css('width','470px').css('max-width','470px');
+ $(this).siblings('button').delay(200).fadeIn('slow');
+ }).blur(function(){
+ if ($(this).val() == '') {
+ $(this).siblings('button').fadeOut('slow');
+ var textarea = this;
+ setTimeout(function(){
+ $(textarea).css('height','40px').css('width','536px').css('max-width','536px');
+ },250);
+ }
+ })

0 comments on commit 6167579

Please sign in to comment.