<@sys.site id=id>
    <#assign a=object/>
</@sys.site>
<@sys.site id=(a.parentId)!parentId><#assign parent=object/></@sys.site>
<script>
function siteDefaultConfig${id!}(type){
    var directory=$('input[name=directory]',navTab.getCurrentPanel()).val();
    if(directory) {
        directory += '/';
    } else {
        directory = ''
    }
    if('static'==type){
        if(!$('input[name=useStatic]',navTab.getCurrentPanel()).is(":checked")){
            $('input[name=useStatic]',navTab.getCurrentPanel()).trigger("click");
        }
        if($('input[name=useSsi]',navTab.getCurrentPanel()).is(":checked")){
            $('input[name=useSsi]',navTab.getCurrentPanel()).trigger("click");
        }
        $('input[name=sitePath]',navTab.getCurrentPanel()).val("//"+location.host+"${base}/webfile/"+directory);
        $('input[name=dynamicPath]',navTab.getCurrentPanel()).val("//"+location.host+"${base}/"+directory);
    }else{
        if($('input[name=useStatic]',navTab.getCurrentPanel()).is(":checked")){
            $('input[name=useStatic]',navTab.getCurrentPanel()).trigger("click");
        }
        $('input[name=sitePath]',navTab.getCurrentPanel()).val("//"+location.host+"${base}/webfile/"+directory);
        $('input[name=dynamicPath]',navTab.getCurrentPanel()).val("//"+location.host+"${base}/"+directory);
    }
    <#if !a?has_content>
        $('input[name=domain]',navTab.getCurrentPanel()).val(location.hostname);
    </#if>
    $('.info',navTab.getCurrentPanel()).show();
}
</script>
<form method="post" autocomplete="off" action="sysSite/save?callbackType=closeCurrent&navTabId=sysSite/list" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone);">
    <input name="id" type="hidden" value="${id!}"/>
    <input type="hidden" name="_csrf" value="<@tools.csrfToken admin=true/>"/>
    <input type="hidden" name="encoding" value="sha512"/>
    <div class="formBar card">
        <ul>
            <li><button type="submit" class="buttonActive" title="ctrl+s"><@t.page 'button.save'/></button></li>
            <li><button type="button" class="button close"><@t.page 'button.close'/></button></li>
        </ul>
    </div>
    <div class="card">
        <div class="pageFormContent" layoutH>
    <#if parent?has_content>
            <dl class="nowrap">
                <dt><@t.page 'site.parent'/>:</dt>
                <dd>
                    <input class="disabled" type="text" size="30" value="${(parent.name)!}"/>
                    <input name="parentId" type="hidden" value="${(parent.id)!}"/>
                    <span class="info"><@t.page 'site.parent.description'/></span>
                </dd>
            </dl>
            <#if parent.hasChild && parent.multiple>
                <dl class="nowrap">
                    <dt><@t.page 'directory'/>:</dt>
                    <dd>
                        <input name="directory" class="required" type="text" maxlength="50" size="30" value="${(a.directory)!}"/>
                    </dd>
                </dl>
            </#if>
    </#if>
            <dl>
                <dt><@t.page 'name'/>:</dt>
                <dd>
                    <input class="required" name="name" type="text" maxlength="255" size="30" value="${(a.name)!}"/>
                    <label><input name="useStatic" type="checkbox" class="form-check-input"<#if a?has_content&&a.useStatic> checked="checked"</#if>/><@t.page 'site.enable_static'/></label>
                    <#if !parent?has_content>
                        <label><input name="hasChild" type="checkbox" class="form-check-input"${(a?has_content&&a.hasChild)?then(' checked="checked"','')?no_esc}/><@t.page 'site.has_child'/></label>
                        <label class="hasChild <#if !(a?has_content&&a.hasChild)>hide</#if>"><input name="multiple" type="checkbox" class="form-check-input"${(a?has_content&&a.multiple)?then(' checked="checked"','')?no_esc}/><@t.page 'site.multiple'/></label>
                    </#if>
                    <span class="info hide"><@t.page 'site.config.description'/></span>
                </dd>
            </dl>
            <dl>
                <dt></dt>
                <dd>
                    <button type="button" class="button" onclick="siteDefaultConfig${id!}('static');return false;"><@t.page 'site.default_static_config'/></button>
                    <button type="button" class="button" onclick="siteDefaultConfig${id!}();return false;"><@t.page 'site.default_dynamic_config'/></button>
                </dd>
            </dl>
            <dl class="nowrap">
                <dt><@t.page 'site.dynamic_path'/>:</dt>
                <dd>
                    <input class="required" name="dynamicPath" type="text" maxlength="255" size="60" value="${(a.dynamicPath)!}"/>
                    <span class="info"><@t.page 'site.site_path.description'/></span>
                </dd>
            </dl>
            <dl class="nowrap">
                <dt><@t.page 'site.site_path'/>:</dt>
                <dd>
                    <input name="sitePath" type="text" maxlength="255" size="60" value="${(a.sitePath)!}"/>
                    <label><input name="useSsi" type="checkbox" class="form-check-input"<#if a?has_content&&a.useSsi> checked="checked"</#if>/><@t.page 'site.enable_ssi'/></label>
                    <span class="info"><@t.page 'site.dynamic_path.description'/></span>
                    <span class="info"><@t.page 'site.enable_ssi.description'/></span>
                </dd>
            </dl>
            <#if !a?has_content>
                <fieldset>
                    <legend><@t.page 'site.init'/></legend>
                    <dl class="nowrap">
                        <dt><@t.menu 'sitefile'/>:</dt>
                        <dd>
                            <input type="text" name="fileName" size="30" readonly="readonly"/>
                            <a class="btnLook" href="sysSite/lookupSitefile.html" lookupGroup="" width="1200" height="600"><@t.menu 'sitefile'/></a>
                        </dd>
                    </dl>
                <#if !(parent?has_content && parent.hasChild && parent.multiple)>
                    <dl class="nowrap">
                        <dt><@t.page 'domain'/>:</dt>
                        <dd>
                            <input class="required domain" remote="sysDomain/virify" name="domain" data-msg-remote="<@t.message 'verify.hasExist.domain'/>" type="text" maxlength="50" size="20"/>
                            <label><input name="wild" type="checkbox" class="form-check-input"/><@t.page 'domain.wild'/></label>
                            <span class="info"><@t.page 'domain.description'/></span>
                        </dd>
                    </dl>
                </#if>
                    <dl class="nowrap">
                        <dt><@t.page 'role'/>:</dt>
                        <dd>
                            <input class="required" name="roleName" type="text" maxlength="50" size="20" value="<@t.page 'site.default_role'/>"/>
                        </dd>
                    </dl>
                    <dl class="nowrap">
                        <dt><@t.page 'dept'/>:</dt>
                        <dd>
                            <input class="required" name="deptName" type="text" maxlength="50" size="20" value="<@t.page 'site.default_dept'/>"/>
                        </dd>
                    </dl>
                    <dl class="nowrap">
                        <dt><@t.page 'user.username'/>:</dt>
                        <dd>
                            <input class="required" name="userName" type="text" maxlength="45" size="20" value="admin"/>
                        </dd>
                    </dl>
                    <dl class="nowrap">
                        <dt><@t.page 'password'/>:</dt>
                        <dd>
                            <input class="required" name="password" type="password" escape="true" maxlength="255" size="20"/>
                        </dd>
                    </dl>
                </fieldset>
            </#if>
        </div>
    </div>
</form>
<script>
$('input[name=hasChild]',navTab.getCurrentPanel()).on("click", function(){
    if($(this).is(':checked')){
        $('.hasChild',navTab.getCurrentPanel()).show();
    } else {
        $('.hasChild',navTab.getCurrentPanel()).hide();
    }
});
</script>