50e38c7e071122fb620ae7be5fce6eca2654568b.svn-base
3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/modules/cms/front/include/taglib.jsp"%>
<link href="${ctxStatic}/jquery-validation/1.11.1/jquery.validate.min.css" type="text/css" rel="stylesheet" />
<script src="${ctxStatic}/jquery-validation/1.11.1/jquery.validate.min.js" type="text/javascript"></script>
<script src="${ctxStatic}/jquery-validation/1.11.1/jquery.validate.method.min.js" type="text/javascript"></script>
<style type="text/css">.reply{border:1px solid #ddd;background:#fefefe;margin:10px;}</style>
<script type="text/javascript">
$(document).ready(function() {
comment(0);
});
function commentForm(form){
$(form).validate({
rules: {
validateCode: {remote: "${pageContext.request.contextPath}/servlet/validateCodeServlet"}
},
messages: {
content: {required: "请填写评论内容"},
validateCode: {remote: "验证码不正确", required: "请填写验证码"}
},
submitHandler: function(form){
$.post($(form).attr("action"), $(form).serialize(), function(data){
data = eval("("+data+")");
alert(data.message);
if (data.result==1){
page(1);
}
});
},
errorContainer: form + " .messageBox",
errorPlacement: function(error, element) {
if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
error.appendTo(element.parent().parent());
} else {
error.insertAfter(element);
}
}
});
}
function comment(id){
if ($("#commentForm"+id).html()==""){
$(".validateCodeRefresh").click();
$(".commentForm").hide(500,function(){$(this).html("");});
$("#commentForm"+id).html($("#commentFormTpl").html()).show(500);
$("#commentForm"+id+" input[name='replyId']").val(id);
commentForm("#commentForm"+id + " form");
}else{
$("#commentForm"+id).hide(500,function(){$(this).html("");});
}
}
</script>
<h5>评论列表</h5>
<ul>
<c:forEach items="${page.list}" var="comment">
<li>
<h6>姓名: ${comment.name} 时间:<fmt:formatDate value="${comment.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
<a href="javascript:comment('${comment.id}')">回复</a></h6>
<div>${comment.content}</div>
<div id="commentForm${comment.id}" class="commentForm hide"></div>
</li>
</c:forEach>
<c:if test="${fn:length(page.list) eq 0}">
<li>暂时还没有人评论!</li>
</c:if>
</ul>
<div class="pagination">${page}</div>
<h5>我要评论</h5>
<div id="commentForm0"></div>
<script id="commentFormTpl" type="text/javascript"><!--/*-->
<form:form action="${ctx}/comment" method="post" class="form-horizontal">
<input type="hidden" name="category.id" value="${comment.category.id}"/>
<input type="hidden" name="contentId" value="${comment.contentId}"/>
<input type="hidden" name="title" value="${comment.title}"/>
<input type="hidden" name="replyId"/>
<div class="control-group">
<label class="control-label">留言内容:</label>
<div class="controls">
<textarea name="content" rows="4" maxlength="200" class="txt required" style="width:400px;"></textarea>
</div>
</div>
<div class="control-group">
<label class="control-label">姓名:</label>
<div class="controls">
<input type="text" name="name" maxlength="11" class="txt required" style="width:100px;" value="匿名"/>
<label class="mid">验证码:</label><sys:validateCode name="validateCode" />
<input class="btn mid" type="submit" value="提 交"/>
</div>
</div>
<div class="alert alert-error messageBox" style="display:none">输入有误,请先更正。</div>
</form:form><!--*/-->
</script>