{layout name="public/layout_main"}
<link rel="stylesheet" href="/static/fileinput/css/fileinput.css">
<link rel="stylesheet" href="/static/bootstrap-select/css/bootstrap-select.min.css">
<style type="text/css">
.progress-bar{
    text-align: center;
}
.dropdown-menu{
    z-index: 100000;
}
</style>

<section class="wrapper">
    <h3 class="">
        <a href="<?php echo url('@admin/Post/index')?>">
            <i class="fa fa-angle-right"></i> <a href="{:url('admin/post/index')}">文章管理</a> <i class="fa fa-angle-right"></i> 发布文章
        </a>
    </h3>
    <hr>

    <?php if(isset($msg) && $msg):?>
    <div class="row margin-bottom">
        <div class="col-md-12">
            <div class="alert alert-danger alert-dismissible fade in" role="alert">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
                <?php echo $msg;?>
            </div>
        </div>
    </div>
    <?php endif;?>

    <div class="row margin-bottom">
        <div class="col-md-12">
            <form name="myFrom" class="form-horizontal" enctype="multipart/form-data" method="POST" action="<?php echo url("@admin/Post/create")?>" id="article-create-form">
                <div class="form-group">
                    <label for="title" class="col-sm-1 control-label text-right">文章标题</label>
                    <div class="col-lg-10">
                        <input type="text" class="form-control validate[required]" name="title" id="title" placeholder="文章标题 ">
                    </div>
                </div>
                <div class="form-group">
                    <label for="title" class="col-sm-1 control-label text-right" >文章封面</label>
                    <div class="col-lg-10">
                        <input id="input-b1" name="poster" type="file">
                    </div>
                </div>
                <div class="form-group">
                    <label for="title" class="col-sm-1 control-label text-right">文章标签</label>
                    <div class="col-lg-10">
                        <select class="selectpicker form-control" name="tags" multiple data-live-search="true">
                            {volist name="tag_list" name="tag_list" id="vo"}
                            <option value="{$vo.id}">{$vo.name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="title" class="col-sm-1 control-label text-right">文章类型</label>
                    <div class="col-lg-10">
                        <select class="form-control" name="type" id="post_type">
                            <option value="1">手动编写文章</option>
                            <option value="2">链接到网络文章</option>
                        </select>
                    </div>
                </div>
                <div class="form-group" id="href" style="display: none">
                    <label for="title" class="col-sm-1 control-label text-right">请输入url</label>
                    <div class="col-lg-10">
                        <input type="text" name="href" class="form-control">
                        <code>http:// + 网址 或 https:// + 网址</code>
                    </div>
                </div>
                <div class="form-group" id="content">
                    <label for="content" class="col-sm-1 control-label text-right">文章内容</label>
                    <div class="col-lg-10">
                        <!-- 加载编辑器的容器 -->
                        <script id="post_container" name="content" type="text/plain" style="width: 100%">
                        </script>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-1 col-sm-10">
                        <button type="submit" class="btn btn-default" id="btn-save">提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</section>
<!-- 文件上传和select插件 -->
<script type="text/javascript" src="/static/fileinput/js/fileinput.min.js"></script>
<script type="text/javascript" src="/static/fileinput/js/locales/zh.js"></script>
<script type="text/javascript" src="/static/bootstrap-select/js/bootstrap-select.min.js"></script>
<script type="text/javascript" src="/static/bootstrap-select/js/i18n/defaults-zh_CN.js"></script>


                        <!-- 配置文件 -->
<script type="text/javascript" src="/static/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="/static/ueditor/ueditor.all.js"></script>

<script type="text/javascript">
$(function(){
    // 即时显示封面图
    $('#poster').change(function(e){
        var file = e.target.files[0];
        preview(file, 0);
    });
});
$("#post_type").change(function(){
    var type = $(this).val();
    if(type == 1){
        $("#content").show();
        $("#href").hide();
    }else{
        $("#href").show();
        $("#content").hide();
    }
});
// 初始化文件上传
$("#input-b1").fileinput({
    language: 'zh',
    showUpload:false, //是否显示上传按钮
    allowedFileExtensions: ['bmp','jpg','png','tif','gif','pcx','tga','exif','fpx','svg','cdr','pcd','dxf','ufo','eps','raw','WMF','webp'],//接收的文件后缀
})
UE.getEditor('post_container', {
    //编辑区域大小
    'initialFrameHeight' : '350',
    'elementPathEnabled':false,
    'autoHeight': true,
    'autoHeightEnabled':true,
    'autoFloatEnabled': true,
    'iframeCssUrl': '/static/ueditor/themes/iframe.css',// 引入css
    //定制菜单
    'toolbars' : [
        [
            'fullscreen', 'source', 'undo', 'redo', '|',
            'fontsize',
            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'removeformat',
            'formatmatch', 'blockquote', 'pasteplain', '|',
            'forecolor', 'backcolor', '|',
            'lineheight', '|',
            'indent', '|', 'insertimage', '|',
            'justifyleft', //居左对齐
            'justifyright', //居右对齐
            'justifycenter', //居中对齐
            'justifyjustify', //两端对齐
        ],
    ]
});
</script>
