{include file='public/meta'}
<link rel="stylesheet" href="__LIB__/layui/css/layui.css" media="all">
<body>
<article class="page-container">
	<form class="form form-horizontal" id="form-admin-add">
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>标题</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text"  placeholder="" id="title" name="title" value="<?php echo $row['title'];?>" >
		</div>
	</div>


	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">类别</label>
		<div class="formControls col-xs-8 col-sm-9">
			{:sirui_widget('widget/Categorylevel/index',['table'=>'topic_category','id'=>'topic_level_','default'=>$default])}
		</div>
	</div>

	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>封面(550x350)</label>
		<div class="formControls col-xs-8 col-sm-9">
			<button type="button" class="btn btn-primary size-S" id="btn_cover">上传</button>
			<div>
				<img class="layui-upload-img" id="demo_cover" width="100"  {notempty name="$row.cover"}src="{$row.cover|get_url}"{/notempty} >
			</div>
			<input type="hidden" name="cover" id='cover' value="<?php echo intval($row['cover']);?>"  />
		</div>
	</div>

	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">内容</label>
		<div class="formControls col-xs-8 col-sm-9">
			<script id="text" name="text" type="text/plain"><?php echo $row['text'];?></script>
		</div>
	</div>
	
	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">来源</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text" style='width:300px' placeholder="" id="from" name="from" value="<?php echo $row['from'];?>" >
		</div>
	</div>

	<div class="row cl">
		<label class="form-label col-xs-4 col-sm-3">浏览量</label>
		<div class="formControls col-xs-8 col-sm-9">
			<input type="text" class="input-text"  style='width:150px' onkeyup="checkInputInt(this)" id="readcount" name="readcount" value="<?php echo intval($row['readcount']);?>" >
		</div>
	</div>
	

	<input type="hidden" name="id" value="<?php echo intval($row['id']);?>">
	
	<div class="row cl">
		<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
			<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
		</div>
	</div>

	</form>
</article>

{include file='public/pfooter'}

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__LIB__/layui/layui.js"></script>
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$("#form-admin-add").validate({
		rules:{
			title:{
				required:true,
			},
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			$(form).ajaxSubmit({
				type: 'post',
				url: "<?php echo url('admin/news/publish');?>" ,
				success: function(data){
					layer.msg(data.msg,{icon:1,time:1000});
					if(0==data.error){
						setTimeout(function(){
							location.href="<?php echo url('admin/news/index');?>";
						},1000)
					}
				},
                error: function(XmlHttpRequest, textStatus, errorThrown){
					layer.msg('服务器端错误',{icon:1,time:1000});
				}
			});
		}
	});
});
</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>

<script>
//上传图片PC LOGO
layui.use('upload', function(){
  var upload = layui.upload;
  //执行实例
  var uploadInst = upload.render({
    elem: '#btn_cover' //绑定元素
    ,url: "{:url('common/upload',['atype'=>'topic_cover'])}" //上传接口
    ,done: function(res){
      //上传完毕回调
      if(0==res.error) {
        $('#demo_cover').attr('src',res.src);
        $('#cover').val(res.id);
      } else {
        layer.msg(data.msg,{icon:1,time:1000});
      }
    }
    ,error: function(){
    	layer.msg('接口异常');
    }
  });
});
</script>

<script type="text/javascript" src="__LIB__/ueditor/1.4.3/ueditor.config.js"></script> 
<script type="text/javascript" src="__LIB__/ueditor/1.4.3/ueditor.all.min.js"> </script> 
<script type="text/javascript" src="__LIB__/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('text',{
      initialFrameHeight:300
    });
</script>