<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>xhEditor初始化代码生成向导 for xhEditor 1.1.4</title>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-1.3.2.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/xheditor/clearHtml.js"></script>
<script type="text/javascript">
var maxLength = 0;
$(document).ready(function (){
//forcePtag:false,upBtnText:'浏览',
var hid = 8;
var upImgUrl = '${pageContext.request.contextPath}/hometopic/uploadTopicImage.do?hid='+hid;
var editor = $('#editorId').xheditor(
{tools:'Emot',skin:'o2007silver',hoverExecDelay:100,layerShadow:0,upImgUrl:upImgUrl,upImgCallback:upImgCallback,upImgExt:'jpg,jpeg,gif,png',html5Upload:false,
onkeyup:countWords,shortcuts:{'ctrl+enter':submitEditor}}
);
//初始化最大输入字数
maxLength = 140;
$("#maxLength").html(maxLength);
$("#nextLength").html(maxLength);
});
function submitEditor(){
//提交时自定义验证编辑框字数是否超出范围,可自己重写,如下只是参考
var charRange = $.trim($("#nextLength").html());
if(charRange<0){
$("#errorInput").html("<font color='red'>您的字数已经超出最大范围!</font>");
return ;
}
var data = $("#editorId").val();
//清除html
data = clearHtml(data);
//这里放在一个隐藏域中,是因为直接提交可能会自动产生一些html代码,当然也可以在后台处理
$("#preview").val(data);
data = clearImgHtml(data);
if(data.length>maxLength) {
$("#normalInput").hide();
$("#errorInput").html("<font color='red'>您的字数已经超出最大范围!</font>");
return ;
}
//最后提交
$('#editorForm').submit();
}
function countWords(){
checkMaxLength(maxLength);
}
function upImgCallback(text){
if(text=="typeerror"){
$("#imgInfo").html("提示:请上传合法文件");
return false;
}else if(text=="sizeerror"){
$("#imgInfo").html("提示:图片大小小于120KB");
return false;
}else{
var domain=$("#domain").val(); //域
text = domain+text;
return text;
}
}
</script>
</head>
<body>
<input type="hidden" value="${fzdnaDomain}" id="domain"/>
<form action="${pageContext.request.contextPath}/pub/testExheditor.do" id="editorForm" method="post">
<h2>1: 预览编辑器A</h2>
<div class="section">
<input type="hidden" name="preview" id="preview"/>
<textarea id="editorId" name="test" rows="15" cols="90"></textarea></div>
<div id="normalInput">最多<span id="maxLength"></span>个字,你还可以输入<span id="nextLength"> </span>字</div>
<div id="errorInput"></div>
<input type="button" value="提交" οnclick="submitEditor()"/>
</form>
<br/>
<br/>
<s:include value="/common/foot/foot.jsp"/>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/xheditor/xheditor-zh-cn.min.js?v=1.1.4"></script>
</body>
</html>
$('#editorId).xheditor(
{tools:'Bold,FontColor,Emot',height:'110',width:'585',hoverExecDelay:-1,layerShadow:5}
);