{extend name="base" /}
{block name="css"}
<link href="__ADMIN__/js/ztree/css/zTreeStyle/zTreeStyle.css?v={$v}" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="__STATIC__/plugins/webuploader/webuploader.css?v={$v}" />
{/block}
{block name="js"}
<script src="__ADMIN__/js/ztree/jquery.ztree.all-3.5.js?v={$v}"></script>
<script src="__STATIC__/plugins/webuploader/webuploader.js?v={$v}" type="text/javascript" ></script>
<script src="__STATIC__/plugins//kindeditor/kindeditor.js?v={$v}" type="text/javascript" ></script>
<script src="__ADMIN__/trade_rule/trade_rule.js?v={$v}" type="text/javascript"></script>
<script>
$(function () {
	{if condition="$object['id']!=0 "}
	   WST.setValues({:json_encode($object)});
	{/if}
	$('#articleForm').validator({
	    fields: {
	    	title: {
	    		tip: "请输入标题",
	    		rule: '标题:required;length[~50];'
	    	},
		    content: {
	    		tip: "请输入内容",
	    		rule: '内容:required;'
	    	}
	    },
	    valid: function(form){
	    	var id = $('#id').val();
	    	toEdits(id);
	    }
	})
});
</script>
{/block}
{block name="main"}
<input type='hidden' id='id' value='{$object["id"]}'/>
<form id='articleForm' autocomplete="off">
<table class='wst-form wst-box-top '>
  <tr>
     <th width='150'>标题<font color='red'>*</font>:</th>
     <td><input type="text" id='title' name='title' maxLength='50' style='width:300px;' class='ipt'/></td>
  </tr>
   <tr>
       <th width='150'>内容<font color='red'>*</font>:</th>
       <td>
       	<textarea id='content' name='content' class="form-control ipt" style='width:80%;height:400px'></textarea>
       </td>
    </tr>  
     <tr>
       <td colspan='2' align='center'>
       	<button type="submit" class="btn btn-primary btn-mright" ><i class="fa fa-check"></i>保&nbsp;存</button> 
        <button type="button" class="btn" onclick="javascript:history.go(-1)"><i class="fa fa-angle-double-left"></i>返&nbsp;回</button>
       </td>
     </tr>
</table>
 </form>
  <script>
$(function(){
	//文件上传
	WST.upload({
  	  pick:'#coverImgPicker',
  	  formData: {dir:'articles',isThumb:1},
  	  accept: {extensions: 'gif,jpg,jpeg,png',mimeTypes: 'image/jpg,image/jpeg,image/png,image/gif'},
  	  callback:function(f){
  		  var json = WST.toAdminJson(f);
  		  if(json.status==1){
  			$('#coverImgMsg').empty().hide();
        	$('#preview').html('<img src="'+WST.conf.IMGURL+'/'+json.savePath+json.thumb+'" height="152" />');
        	$('#coverImg').val(json.savePath+json.name);
  		  }
	  },
	  progress:function(rate){
	      $('#coverImgMsg').show().html('已上传'+rate+"%");
	  }
    });
  //编辑器
    KindEditor.ready(function(K) {
		editor1 = K.create('textarea[name="content"]', {
			height:'350px',
      uploadJson : WST.conf.ROOT+'/admin/trade_rule/editorUpload',
			allowFileManager : false,
			allowImageUpload : true,
      allowMediaUpload : false,
			items:[
			        'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
			        'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
			        'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
			        'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
			        'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
			        'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|','image','media','table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
			        'anchor', 'link', 'unlink', '|', 'about'
			],
			afterBlur: function(){ this.sync(); }
		});
	});
});
</script>
{/block}