
<div class="main">
    <div class="alert alert-warning alert-dismissible" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <i class="fa fa-info-circle"></i>站点的提交和修改会导致网站进程重启，建议在访客少时候进行操作。
    </div>
    <form class=" form ui-formBind" method="post" id="_form" data-source="@Model">
        <div class="form-group">
            <label class="control-label">站点名称</label>
            <div class="controls">
                <input type="text" value="" class="form-control" maxlength="50" id="Name" name="Name" data-validate="dataType:'*',nullMsg:'请填写站点名称!',checkUrl:'@Url.Action("CheckExists",new { id = Request.QueryString["id"],area="admin" })',checkError:'站点名称已存在，请重新设置'" />
                <span class="help-block"></span>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label">备注</label>
            <div class="controls">
                <input type="text" value="" class="form-control" id="Remark" name="Remark" />
                <span class="help-block"></span>
            </div>
        </div>


        <div class="form-group">
            <label class="control-label">网站访问目录</label>
            <div class="controls">
                <input type="text" id="Directory" name="Directory" class="form-control" data-validate="dataType:'string',nullMsg:'请填写站点目录！',checkUrl:'@Url.Action("CheckExists",new { id = Request.QueryString["id"],area="admin" })',checkError:'目录已存在，请重新设置'" maxlength="20" />
                <input type="hidden" id="old_directory" name="old_directory" />
                <span class="help-block">如果网站未绑定域名，则用主域名+访问目录形式访问。</span>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label">网站绑定域名</label>
            <div class="controls">
                <input name="Domain" id="Domain" type="text" class="form-control" />
                <span class="help-block">如：http://www.domain.cn，留空则用主域名+目录访问网站,如有采用非80端口，必须带上端口。</span>
            </div>
        </div>


        <div class="form-group">
            <label class="control-label">选择模板目录</label>
            <div class="controls form-inline">

                <input name="TemplateDirectory" id="TemplateDirectory" type="text" maxlength="50" class="form-control form-control-sm form-com" data-validate="dataType:'*',nullMsg:'请选择网站模板目录！'" />

                <button class="btn btn-default ui-dialog" type="button" data-custom-params="title:'选择模板目录',url:'@Url.ActionUrl("SelectTemplate","TemplateManager")?objname=#TemplateDirectory',width:'500px',height:'90%',target:'_self'">选择目录</button>

                <span class="help-block">模板目录在/Templates目录下，填写或修改时请确认目录是否存在</span>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label">Gzip压缩</label>
            <div class="controls">
                <select name="Compression" id="Compression" class="form-control form-control-sm">
                    <option value="1">开启</option>
                    <option value="0">关闭</option>
                </select>
                <span class="help-block">压缩可减少带宽消耗和提升访问速度，如果服务器的IIS中已开启了Gzip压缩，网站中就不需要再开启。</span>
            </div>
        </div>




        @*<div class="form-group">
                <label class="control-label" for="xuhao">序号</label>
                <div class="controls">
                    <input type="text" name="xuhao" id="xuhao" maxlength="3" value="1" class="form-control form-control-xs" data-validate="dataType:'num">
                    <span class="help-block"></span>
                </div>
            </div>*@
        <div class="form-group">
            <label class="control-label"></label>
            <div class="controls">
                @Html.AntiForgeryToken()
                <input type="hidden" id="Id" name="Id" />
                <input type="hidden" id="isDefault" name="isDefault" />
                <button type="button" class="btn btn-sm btn-primary ui-pagePost" data-custom-params="url:'@Url.ActionUrl()',callBack:'CallBack',beforeExecute:'BeforeExecute'" id="bt_submit">提交</button>
                <button type="button" class="btn btn-sm btn-default ui-closeDialog">关闭</button>
                <span class="help-block"></span>
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">

    function BeforeExecute() {
        var $domain = $("#Domain")
        var domainVal = $domain.val();
        $domain.val(domainVal.toLocaleLowerCase());
        return true;
    }

    function CallBack()
    {
        RestartApplication();
        PostRefreshBack();
    }


    function RestartApplication() {
        var url = "@Url.ActionUrl("RestartApplication","Default")";
        var Data = Ajax({ type: "post", async: false, url: url });
    }
</script>
