<?php
require_once("../check.php");
?>
<!DOCTYPE HTML>
<html>
<head>
<title>内容发布</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="/editor/themes/default/default.css" />
<script src="../js/jquery-1.11.1.min.js"></script>
<script src="../../editor/kindeditor-min.js"></script>

<body>
<style>
body{
    margin:0;
    padding:0;
    text-align:left;
}

#button{
    margin-top:5px;
    width:700px;
    height:80px;
    line-height:80px;
    display: table;
    text-align:left;

}

#button input{
    margin-top:10px;
    margin-left:155px;
    height:35px;
    line-height:35px;
    width:150px;
    float:left;
    color: #FFFFFF;
    font-size:16px; 
    background-color:#08246B;
    border:1px solid #08246B;
    border-radius:5px;
    box-shadow:0px 0px 5px 5px #C2C2C2;   
}



#table{
    margin-top:5px;
    width:auto;
    max-width:1000px;
    min-height:30px;
    height:auto;
    display: table;
    line-height:30px;
    text-align:left;

}
#table label{
    clear:none;
    height:30px;
    line-height:30px;
    float:left;
    width:150px;
    text-align:right;
    color: #5F5F5F;
    font-size:16px;
    margin-right:5px;
}
#table input{
    border:1px solid #D8D8D8;
    border-radius:3px;
    line-height:30px;
    height:30px;
    float:left;
    font-size:14px; 
}
#table input.text{
    color: #5F5F5F;
    width:740px;  
}
#table input.xtext{
    color: #5F5F5F;
    width:100px; 
}
#table textarea.c{
    float:left;
    width:735px;
    height:350px;
    resize:none;
    border:1px solid #D8D8D8;
    border-radius:3px;
    color: #5F5F5F;
    font-size:16px;
    line-height:25px;
    letter-spacing: 1px;
}

#table input.form{
    margin-top:10px;
    margin-left:155px;
    height:35px;
    line-height:35px;
    width:150px;
    float:left;
    color: #FFFFFF;
    font-size:16px; 
    background-color:#08246B;
    border:1px solid #08246B;
    border-radius:5px;
    box-shadow:0px 0px 5px 5px #C2C2C2;   
}
#table select{

    color: #5F5F5F;
    font-size:14px;
    border:1px solid #D8D8D8;
    width: 100px;
}

.alert{
    display:none;
    left:0;
    width:200px;
    height:340px;
    position: absolute;
    background-color: #08246B;
    left:268px;
    margin-top:30px;
    z-index: 200;
    text-align:left;
    color:#FFFFFF;
    font-size:14px;
    box-shadow:0px 0px 5px 5px #C2C2C2;
}
.alert textarea{
    outline: none;
    text-align:left;
    clear:left;
    float:left;
    margin:0;
    padding:0;
    width:198px;
    height:280px;
    line-height:25px;
    font-size:16px;
    color: #6E6E6E;
    resize:none;
    overflow: hidden;
    
}
#loading{
    z-index: 800;
    display:none;
    margin:0;
    padding:0;
    position: fixed;
    width:190px;
    height:14px;
    top:220px;
    left:410px;
}
input.title{
    width:735px;
}
</style>
<script>
			KindEditor.ready(function(K) {
				var uploadbutton = K.uploadbutton({
					button : K('#uploadButton')[0],
					fieldName : 'imgFile',
					url : '../../editor/php/upload_json.php?dir=image',
					afterUpload : function(data) {
						if (data.error === 0) {
							var url = K.formatUrl(data.url, 'absolute');
							K('#img').val(url);
                            $.post("../../editor/php/dunling.php",{
                            url:url
                            },function(slta,sltb){
                            //****//
                            });
						} else {
							alert(data.message);
						}
					},
					afterError : function(str) {
						alert('自定义错误信息: ' + str);
					}
				});
				uploadbutton.fileBox.change(function(e) {
					uploadbutton.submit();
				});
			});
</script>
<script>
$(function(){

    $(document).ajaxStart(function(){
    $("#loading").show();
    });
    
    $(document).ajaxStop(function(){
    setTimeout(function(){
    $("#loading").hide();
    },1000);
    
    });
    

    
    setTimeout(function(){
    $("#fenlei").load('../core/article_fenlei_ajax.php');
    },500);
    
    $("#fenleiupdate").click(function(){
    $("#fenlei").load('../core/article_fenlei_ajax.php?id'+ Math.random());
    });

    
   $("#form").click(function(){
    editor.sync();
    var fenlei = $("#fenlei").val();
    var img = $("#img").val();
    var title = $("#title").val();
    var content = $("#content").val();
    if((title==false) || (content==false)){
        alert('请输入必填项!\n\n必填项包含:标题、内容!');
        return false;
    }
    $.post("../core/article_form.php",{
        title:title,
        content:content,
        fenlei:fenlei,
        img:img
    },function(fabuok,fabuzt){
        if(fabuok=="ok"){
              setTimeout(function(){
              alert('保存成功!');
              location.href='article_form.php';
              return false;
                },1500);
            
        }else{
            alert(fabuok);
            return false;
        }
    });
    
   });
   $("#guanlifenlei").click(function(){
    $(".alert").fadeToggle(300);
   });
   $("#fenleiclose").click(function(){
    $(".alert").fadeToggle(300);
   });
   $("#fenleishezhi").click(function(){
    var fenlei = $("#fenleizhi").val();
    $.post("../core/article_fenlei.php",{
        fenleizhi:fenlei
    },function(fa,fb){
        if(fa!="ok"){
            alert('您没有写入权限,无法保存!');
            return false;
        }
    });
   });  
});
</script>
<script>
			KindEditor.ready(function(K) {
				 window.editor = K.create('#content', {
                    pasteType:3,
                    resizeType:0,
                    urlType:'domain',
					filterMode: true,//是否开启过滤模式
                      width:'740px',
                    height:'360px'
				});
			});
</script>

<link rel="stylesheet" href="../../edirot/themes/default/default.css" />
<div id="table">
<label>标题:</label><input type="text" id="title" class="title"  />
</div>
<div id="table">

<label>选择分类:</label>
<select id="fenlei"></select>
</div>

<div id="table">
<label>显示图标:</label><input class="ke-input-text" style="width: 250px;" type="text" id="img" value="" readonly="readonly" /><input type="button" id="uploadButton" value="选择图片"/>
</div>

<div id="table">
<label>详细内容:</label><textarea id="content" class="c"></textarea>
</div>


<div id="button">
<input class="form" id="form" type="button" value="保存" />
</div>
<div id="loading"><img src="../images/png/dunling_loading.gif" /></div>
</body>