<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改文章模板')"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-articletemplate-edit" th:object="${cmsArticleTemplate}">
        <input name="templeId" th:field="*{templeId}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>模板名称：</label>
            <div class="col-sm-8">
                <input name="templeName" th:field="*{templeName}" class="form-control" type="text" required
                       maxlength="255">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label"><span style="color: red; ">*</span>模板内容：</label>
            <div class="col-sm-8">
                <script id="editor" name="templeContent" type="text/plain"></script>
                <textarea hidden="text" id="divdata" style="display: none;">[[*{templeContent}]]</textarea>

            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: ueditor"/>
<script type="text/javascript">
    var prefix = ctx + "bussiness_cms/articletemplate";
    $("#form-articletemplate-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            var c = getContentTxt();
            if (c == '' || c.length == 0) {
                $.modal.alertWarning("请输入模板内容！");
                return;
            }
            $.operate.save(prefix + "/edit", $('#form-articletemplate-edit').serialize());
        }
    }

    $(function () {
        $("#editor").css("height", "380px");
        //给UEeditor赋值
        var data = $("#divdata").text();
        var ue = UE.getEditor('editor');
        var proinfo = $("#divdata").text();
        ue.ready(function () {//编辑器初始化完成再赋值
            ue.setContent(data);  //赋值给UEditor
        });
    })

    function getContentTxt() {
        return UE.getEditor('editor').getContentTxt();
    }
</script>
</body>
</html>