<?= view('layout/header')->send(); ?>

<form id="cv-form" method="post" class="cv-mt-15">
    <div class="cv-normal-input-box">
        <input value="<?= $category['title']; ?>" class="easyui-textbox" name="cv[title]" label="栏目名称" prompt="<?= lang('请输入栏目名称'); ?>" missingMessage="<?= lang('栏目名称为必填项'); ?>" required style="width: 100%;"  />
    </div>
    <div class="cv-normal-input-box">
        <label class="textbox-label textbox-label-before">是否显示</label>
        <span class="easyui-fluid">
            <input type="radio" name="cv[is_show]" value="1" <?php if ($category['is_show']):?>checked<?php endif;?> />&nbsp;是&nbsp;&nbsp;
            <input type="radio" name="cv[is_show]" value="0" <?php if (intval($category['is_show'])===0):?>checked<?php endif;?> />&nbsp;否
        </span>
    </div>
    <div class="cv-normal-input-box">
        <input value="<?= $category['mark']; ?>" class="easyui-textbox" name="cv[mark]" label="标识" prompt="<?= lang('可为该栏目指定特殊标识'); ?>" style="width: 100%;"  />
    </div>
    <div class="cv-normal-input-box">
        <input value="<?= $category['keywords']; ?>" class="easyui-textbox" name="cv[keywords]" label="关键词" prompt="<?= lang('请输入栏目关键词'); ?>" style="width: 100%;"  />
    </div>
    <div class="cv-normal-input-box">
        <input value="<?= $category['view']; ?>" class="easyui-textbox" name="cv[view]" label="模板" prompt="<?= lang('仅需输入模板文件名，不含后缀'); ?>" style="width: 100%;"  />
    </div>
    <div class="cv-normal-input-box">
        <input value="<?= $category['logo']; ?>" buttonText="选取" id="cv_logo" class="easyui-textbox" name="cv[logo]" label="Logo" style="width: 100%;" />
    </div>
    <div class="cv-normal-input-box">
        <input value="<?= $category['description']; ?>" class="easyui-textbox" name="cv[description]" label="栏目描述" prompt="<?= lang('请描述该栏目'); ?>" style="width: 100%;" multiline="true"  />
    </div>
</form>

<div class="cv-submit">
    <a href="javascript:void(0)" class="easyui-linkbutton c8" onclick="saveForm()" style="width:80px">确定</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="closeSelf()" style="width:80px">取消</a>
</div>
<?= view('layout/footer')->send(); ?>

<script type="text/javascript">
    function saveForm(){
        $("#cv-form").form('submit',{
            onSubmit: function(){
                return $(this).form('validate');
            },
            success: function(result){
                var response = JSON.parse(result);
                parent.message(response.message);
                if (response.success){
                    parent.reloadCategoryListData();
                    closeSelf();
                }
            }
        });
    }

    function closeSelf() {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }

    $(function () {
        $('#cv_logo').textbox({
            onClickButton: function () {
                parent.openDialog("媒体上传","<?= url('dash/media/new'); ?>?cl=toCategoryLogoReceiver(response.f_url);|closeSelf();",'750px','520px');
            }
        });
    });

    function categoryLogoReceiver(response) {
        $('#cv_logo').textbox('setValue',response);
    }
</script>
