xheditor

13 篇文章 0 订阅

<%@ 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}       
    );

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值