<include file="public@header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li ><a href="{:url('Gift/index')}">礼物列表</a></li>
			<li class="active"><a >{:lang('ADD')}</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('Gift/addPost')}">

            <div class="form-group">
				<label for="input-type" class="col-sm-2 control-label"><span class="form-required">*</span>类型</label>
				<div class="col-md-6 col-sm-10" id="type">
                    <volist name="type" id="v">
					<label class="radio-inline"><input type="radio" name="type" value="{$key}" <if condition="$i eq 1">checked</if>>{$v}</label>
                    </volist>
				</div>
			</div>
            
            <div class="form-group">
				<label for="input-mark" class="col-sm-2 control-label"><span class="form-required">*</span>标识</label>
				<div class="col-md-6 col-sm-10" id="mark" style="position: relative;">
                    <volist name="mark" id="v">
					<label class="radio-inline" for="mark_{$key}"><input type="radio" name="mark" value="{$key}" id="mark_{$key}" <if condition="$i eq 1">checked</if>>{$v}</label>
                    </volist>

				</div>
			</div>
            
            <div class="form-group">
				<label for="input-giftname" class="col-sm-2 control-label"><span class="form-required">*</span>名称</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-giftname" name="giftname" style="width:300px;">
				</div>
			</div>
            
            <div class="form-group">
				<label for="input-needcoin" class="col-sm-2 control-label"><span class="form-required">*</span>价格</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-needcoin" name="needcoin" style="width:300px;">
				</div>
			</div>
            
            <div class="form-group">
				<label for="input-user_login" class="col-sm-2 control-label"><span class="form-required">*</span>图片</label>
				<div class="col-md-6 col-sm-10">
					<input type="hidden" name="gifticon" id="thumbnail" value="">
                    <a href="javascript:uploadOneImage('图片上传','#thumbnail');">
                        <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                 id="thumbnail-preview"
                                 style="cursor: pointer;max-width:100px;max-height:100px;"/>
                    </a>
                    <input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片"> 
                    <p class="help-block">建议尺寸: 50 X 50 太大会造成加载图片加载慢等各种问题</p>
				</div>
			</div>
            
			<div id="swf_area" style="display: none;">
			
            <div class="form-group">
				<label for="input-swftype" class="col-sm-2 control-label"><span class="form-required">*</span>动画类型</label>
				<div class="col-md-6 col-sm-10" id="swftype">
                    <volist name="swftype" id="v">
					<label class="radio-inline"><input type="radio" name="swftype" value="{$key}" <if condition="$i eq 1">checked</if>>{$v}</label>
                    </volist>
				</div>
			</div>
            
            <div class="form-group" id="">
				<label for="input-gif" class="col-sm-2 control-label">GIF图片</label>
				<div class="col-md-6 col-sm-10">
                    <div id="swftype_bd_0">
                        <input type="hidden" name="gif" id="thumbnail2" value="">
                        <a href="javascript:uploadOneImage('图片上传','#thumbnail2');">
                            <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                     id="thumbnail2-preview"
                                     style="cursor: pointer;max-width:100px;max-height:100px;"/>
                        </a>
                        <input type="button" class="btn btn-sm btn-cancel-thumbnail2" value="取消图片"> 
                        <p class="help-block">建议尺寸: 200 X 200</p>
                    </div>
                    <div id="swftype_bd_1" style="display:none;">
                        <input class="form-control" id="js-file-input" type="text" name="svga" value="" style="width: 300px;display: inline-block;" title="文件名称">
                        <a href="javascript:uploadOne('文件上传','#js-file-input','file');">上传SVGA文件</a>
                    </div>
                    
				</div>
			</div>
            
            <div class="form-group">
				<label for="input-swftime" class="col-sm-2 control-label">动画时长</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-swftime" name="swftime" value="0" style="width:300px;">
                    <p class="help-block">秒 精度:小数点后两位</p>
				</div>
			</div>
			
			</div>
            
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
					<a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
				</div>
			</div>
            
		</form>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
    <script>
        (function(){
            $('.btn-cancel-thumbnail').click(function () {
                $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
                $('#thumbnail').val('');
            });
            
            $('.btn-cancel-thumbnail2').click(function () {
                $('#thumbnail2-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
                $('#thumbnail2').val('');
            });
            
            $("#type label input").on('click',function(){
                var v=$(this).val();
                if(v==0){
                    $("#mark_3").removeAttr('disabled')
                }else{
                    //if($("#mark_3").attr("checked")){
                    if($('#mark label input:checked').val()==3){
                        //$("#mark_0").removeAttr('checked');
                        $("#mark_0").attr('checked','checked');
                      
                    }
                    $("#mark_3").attr('disabled','disabled');
                }
				
				if(v==1){
                    $("#swf_area").show();
                }else{
                    $("#swf_area").hide();
                }
            })
            

            
            $("#swftype label").on('click',function(){
                var v=$("input",this).val();
                var b=$("#swftype_bd_"+v);
                b.siblings().hide();
                b.show();
            })
        })()
    </script>
</body>
</html>