<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/5/005
 * Time: 10:41
 */
?>
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
    <h4 class="modal-title">编辑内容</h4>
</div>
<form id="form1" class="form-horizontal">
    <input type="hidden" name="id" value="<?= $config['id'] ?>">
    <div class="modal-body">
        <textarea id="kindeditor" name="<?= $t ?>" type="text" class="form-control"><?= !empty($value) ? $value : '' ?></textarea>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
        <div onclick="s()" type="button" class="btn btn-primary">提交</div>
    </div>
</form>
<script type="text/javascript">

    var editor;
    KindEditor.ready(function(K) {
        editor=K.create('#kindeditor', {
            uploadJson: '/admin/kindeditor/upload',
            fileManagerJson: '/admin/kindeditor/file-manager',
            allowFileManager: true,
            urlType: 'domain',
            width : '100%',
            height: '200px',
            items: ['fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', '|', 'image','insertfile', 'link','source'],
        });
    });

    function s(){
        editor.sync();
        $.ajax({
            type: "POST",
            url: "/admin/config/update",
            data: $('#form1').serialize(),
            dataType: "json",
            beforeSend: function() {},
            success: function(data) {
                if(data.code){
                    $("#modal").modal("hide");
                }else{
                    toastr.error(data.message, "提示");
                }
            },
            complete: function(XMLHttpRequest, textStatus) {},
            error: function() {}
        });
    }


</script>
