{% extends 'obj_form.html' %}
{% block form_content %}

<script>

    $(document).ready(function () {
        var content = $("#id_content").val();
        $("#htmlEdit").html(content);

        var E = window.wangEditor
        var editor = new E('#htmlEdit')
        //editor.config.uploadImgServer = './ajax/SavePic.ashx'
        editor.config.uploadImgMaxLength = 99
        editor.config.uploadImgMaxSize = 0.5 * 1024 * 1024 // 512kb
        editor.config.uploadFileName = 'file'
        editor.create()


        $('.btn-save').click(function () {

            const editorData = editor.txt.html();
            $("#id_content").val(editorData);
            $.SubmitForm('#obj_form form', '{{request.path}}',function (){
                $('.alert').fadeIn();
                setTimeout(function (){
                    $('.alert').fadeOut();
                },3000)
            });
        });
    })
</script>

<div class="form-group ">
    <label class="col-sm-2 control-label ">标题</label>
    <div class="col-sm-8">{{ form.subtitle }}</div>
</div>
<div class="form-group">
    <label class="col-sm-2 control-label ">内容编辑</label>
    <div class="col-sm-8">
        <div id="htmlEdit"></div>
    </div>
</div>
<div class="form-group product_photo">
    <label class="col-sm-2 control-label ">结束时间</label>
    <div class="col-sm-8">{{ form.endtm }}</div>
</div>
<div class="form-group ">
    <label class="col-sm-2 control-label ">是否有效</label>
    <div class="col-sm-1">
        <div>
            {{ form.is_active }}
        </div>
    </div>
</div>
<div class="alert alert-success col-sm-10 col-sm-offset-2" role="alert" style="display: none">保存成功！</div>
<div>
    <a class="btn btn-primary btn-save" type="button" style="float:right;">保存</a>
</div>
<input type="hidden" id="id_content" name="content" value="{{ form.instance.content }}">
{% endblock %}