#@layout()

#define script()
<script>

    $(".template-enable").on("click", function () {
        var templateId = $(this).attr("for-tid");
        ajaxGet("#(CPATH)/admin/template/doEnable?tid=" + templateId);
    })

    $(".template-uninstall").on("click", function () {
        if (confirm('确定要卸载该主题吗？卸载后不可恢复')) {
            var templateId = $(this).attr("for-tid");
            ajaxGet("#(CPATH)/admin/template/doUninstall?tid=" + templateId);
        }
    })


</script>
#end

#define css()
<style>
    .box-body img {
        width: 100%;
        height: 200px;
        border-top-left-radius: 2px;
        border-top-right-radius: 2px;
    }

    .box-footer .title {
        padding-top: 7px;
    }
</style>
#end

#define content()
<div class="content-wrapper">

    <section class="content-header">
        <h1>
            模板管理
            <small>Template Management</small>
        </h1>
    </section>

    <section class="content-header text-tap">
        <a href="">全部 (#(templateCount))</a> |
        <a href="">PC模板 (#(templateCount))</a> |
        <a href="">H5模板 (#(templateCount))</a> |
        <a href="">小程序 (#(templateCount))</a>
    </section>

    <section class="content">

        <div class="row">
            <div class="col-xs-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <form class="form-horizontal actionPanel" action="#(CPATH)/admin/template" method="get">
                            <div class="row">
                                <div class="form-group col-lg-4">
                                    <label class="col-sm-3 control-label">名称</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control" name="title" value="#para('title')">
                                    </div>
                                </div>

                                <div class="form-group col-lg-4">
                                    <div class="col-sm-12">
                                        <button type="submit" class="btn btn-primary ">查询</button>
                                        <button type="reset" class="btn btn-default">重置</button>
                                        <a href="#(CPATH)/admin/template/install" class="btn"> 安装新模板 </a>
                                    </div>
                                </div>
                            </div>
                            <!-- /.box-body -->
                        </form>


                    </div>
                    <!-- /.box-header -->
                    <div class="box-body ">

                        <div class="row">

                            #for(template : templates)
                            <div class="col-lg-4">
                                <!-- jQuery Knob -->
                                <div class="box box-dashboard">
                                    <!-- /.box-header -->
                                    <div class="box-body no-padding">
                                        <img src="#(CPATH)#(template.screenshot ??)"/>
                                        <!-- /.row -->
                                    </div>
                                    <!-- /.box-body -->
                                    <div class="box-footer">
                                        <label class="title">#(template.title ??)</label>
                                        #if(option('web_template') == template.id)
                                        <button type="button" class="btn btn-default disabled pull-right" disabled>
                                            <i class="fa fa-fw fa-check"></i>已启用
                                        </button>
                                        #else
                                        <div class="pull-right">
                                            <button type="button" class="btn btn-default template-uninstall"
                                                    for-tid="#(template.id)">卸载
                                            </button>
                                            <button type="button" class="btn btn-primary template-enable"
                                                    for-tid="#(template.id)">启用
                                            </button>
                                        </div>

                                        #end
                                    </div>
                                </div>
                                <!-- /.box -->
                            </div>
                            #end

                            <!-- /.col -->
                        </div>


                    </div>
                </div>
                <!-- /.box -->
            </div>
        </div>

    </section>


</div>
#end
