show_article.js
2.01 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
var comm_reply_userid = 0;
var comm_reply_username = '';
var ue;
$(document).ready(function(){
ue = UE.getEditor('editor',{
initialFrameHeight:100 //初始化编辑器高度,默认200
,compressSide:1
,imageScaleEnabled:false // 图片不允许拖拽
,autoHeightEnabled:true // 自动长高
, toolbars: [[
'source', '|',
'bold', 'italic', 'underline', 'strikethrough', 'insertorderedlist', 'insertunorderedlist', 'paragraph', '|',
'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',
'link', 'unlink', '|',
'simpleupload', 'insertimage', 'emotion' , 'insertcode'
]]
});
});
$(function() {
// 回复
$('#comment-btn').click(function(){
// var comment_content = $('[name="comment"]').val();
var comment_content = ue.getContent();
if(!ue.hasContents()){
Alert('请输入评论内容');
return false;
}
if(ue.getContentTxt().length > 5000){
Alert('评论('+ue.getContentTxt().length+'字)文字过长,请输入小于5000个字');
return false;
}
var create_id = $('[name="create_id"]').val();
var article_id = $('[name="article_id"]').val();
// 去除回复提示
if(comm_reply_username!='' && comment_content.indexOf(comm_reply_username) == 0){
comment_content = comment_content.substr(comm_reply_username.length);
}
// 空字符串处理
comment_content = comment_content || '';
comment_content = comment_content.replace(/(^\s*)|(\s*$)/g, "");
if(comment_content==''){
alert('发布内容不能为空!');
return;
} else if (comment_content.length > 5000) {
alert('发布内容长度不能大于5000!');
return;
}
comment.oper_save(comment_content,article_id,comm_reply_userid,create_id);
// 清空内容
ue.setContent("");
});
// 回复内容为空时清除to_user
$('[name="comment"]').change(function(){
if($(this).val()=='') {
comm_reply_userid = 0;
comm_reply_username = '';
}
});
});