<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CommunityInfoListManage.aspx.cs" Inherits="M_Main.CommInfov2.CommunityInfoListManage" %>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

    <script src="../jscript/jquery.tool.js" type="text/javascript"></script>
    <script src="../jscript/Authority.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="../Jscript-Ui/jquery-easyui-1.4.4/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../Jscript-Ui/jquery-easyui-1.4.4/themes/icon.css" />
    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.4/jquery.min.js"></script>
    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.4/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.4/locale/easyui-lang-zh_CN.js"></script>
    <script src="../jscript/PersonDictionaryCanNull.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Jscript-Ui/JQForm/JQForm.js"></script>
    <script src="../jscript/Dialog.js" type="text/javascript"></script>
    <link href="../css/framesearch.css" type="text/css" rel="stylesheet" />

    <script src="../jscript/JSClient.js" type="text/javascript"></script>
    <script src="../jscript/jquery.tool.new.js" type="text/javascript"></script>
    <link href="../css/framedialog_Fourcol.css" type="text/css" rel="stylesheet" />
    <link href="../css/button.css" type="text/css" rel="stylesheet" />

    <script type="text/javascript" src="../jscript/DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" charset="utf-8" src="../Jscript-Ui/UEditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="../Jscript-Ui/UEditor/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="../Jscript-Ui/UEditor/lang/zh-cn/zh-cn.js"></script>
    <style>
        .div-container {
            margin-top: 10px;
            margin-right: 10px;
            float: left;
            position: relative;
            width: 120px;
            height: 120px;
        }

        .div-containner-border {
            border: 2px solid gray;
        }

        .abscenter {
            position: absolute;
            top: 50%;
            left: 50%;
            margin-left: -54px;
            margin-top: -15px;
        }

        .xximg {
            border: 1px solid #cccccc;
            width: 120px;
            height: 120px;
        }
    </style>
</head>
<body style="overflow-y:auto;">
    <form id="frmForm" runat="server" style="overflow:auto">
        <input id="InfoID" type="hidden" name="InfoID" runat="server" />
        <input id="OpType" type="hidden" name="OpType" runat="server" />
        <input id="CommID" type="hidden" name="CommID" runat="server" />
         <input id="InfoType" type="hidden" value="sqwh" name="CommID" runat="server" />

        <table class="DialogTable" style="margin-top:5px;border:0;">
           <%-- <tr id="InfoTypeV">
                <td class="DialogTdTitle">资讯类型</td>
                <td>
                    <label>
                        <input type="radio" name="InfoType" value="qqts" runat="server" style="margin-left: -1px;" checked="true"/>亲情提示</label>
                    <label>
                        <input type="radio" name="InfoType" value="dtzx" runat="server" style="margin-left: 20px;" />社区资讯</label>
                </td>
            </tr>--%>
            <tr>
                <td class="DialogTdTitle">标题</td>
                <td class="DialogTdContent_4Col" colspan="3">
                    <input id="Heading" runat="server" name="Heading" type="text" class="easyui-validatebox" data-options="required:true" style="width:87%"/>
                </td>
            </tr>
            <tr>
                <td class="DialogTdTitle">发布时间</td>
                <td class="DialogTdContent_4Col" colspan="3">
                    <input id="IssueDate" runat="server" style="width:200px;" name="IssueDate" type="text" class="easyui-datetimebox" data-options="required:true" />
                </td>
               <%-- <td class="DialogTdTitle">资讯来源</td>
                <td class="DialogTdContent_4Col">
                    <input id="InfoSource" runat="server" name="InfoSource" type="text" class="easyui-validatebox" data-options="required:false" />
                </td>--%>
            </tr>
           <%-- <tr>
                <td class="DialogTdTitle">过期时间</td>
                <td class="DialogTdContent_4Col">
                    <input id="ShowEndDate" runat="server" name="ShowEndDate" type="text" class="easyui-datetimebox" data-options="required:false" />
                </td>
            </tr>--%>
            <tr>
                <td class="DialogTdTitle">信息内容</td>
                <td class="DialogTdContent_4Col" colspan="3">
                    <script id="editor" type="text/plain" style="width: 97%;"></script>
                    <input id="InfoContent" type="hidden" name="InfoContent" runat="server">
                </td>
            </tr>
            <tr>
                <td class="DialogTdTitle" style="width: 80px;">附图
                </td>
                <td class="DialogTdContent_4Col" colspan="3" id="imageContainer" runat="server">
                    <div class="div-container div-containner-border" style="float: left; position: relative">
                        <input id="add" type="button" class="button abscenter" value="添加">
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="4" style="height:28px;"></td>
            </tr>
            <tr style=" bottom: 0; position: fixed; width: 540px; height: 35px; line-height: 35px; background-color: #f5f5f5; margin-left: -2px;padding-left: 354px;padding-bottom:5px;">
                <td colspan="4" style="text-align: center;">
                    <input type="button" class="button" value="保存" id="BtnSave" />
                    &nbsp;&nbsp;&nbsp;&nbsp;
                <input type="button" class="button" value="关闭" id="BtnReturn" />
                </td>
            </tr>
        </table>
        <input type="hidden" id="ImageUrl" name="ImageUrl" runat="server" />
        <input id="UpFile" type="file" runat="server" name="UpFile" style="width: 1px; visibility: hidden" accept="image/*" />
        <script src="../jscript/CloseAjaxCache.js" type="text/javascript"></script>
        <script type="text/javascript">
            $("#add").click(function (e) {
                if ($("#imageContainer").children(".div-container").length == 6) {
                    HDialog.Info("最多只能上传5张图片，请删除多余的图片后再试");
                    return;
                }
                $("#UpFile").click();
            });

            $("#BtnSave").click(function () {
                var InfoContent = UE.getEditor('editor').getContent();
                $("#InfoContent").val(InfoContent);

                $.tool.DataPostChk('frmForm', 'CommInfo', 'Save', $('#frmForm').serialize(),
                    function Init() {
                    },
                    function callback(_Data) {
                        if (_Data.substring(0, 5) == "false") {
                            HDialog.Info(_Data.substring(6));
                        }
                        else {
                            HDialog.Close('1');
                        }
                    },
                    function completeCallback() {
                    },
                    function errorCallback() {
                    });
            });

            $("#BtnReturn").click(function () {
                HDialog.Close('');
            });

            var ue = UE.getEditor('editor');

            $(document).ready(function () {
                var content = $('#InfoContent').val();
                ue.ready(function () {
                    var h = $(window).height();
                    ue.setHeight(200);
                    ue.setContent(content);
                });
            });

            $("#add").click(function (e) {
                $("#UpFile").click();
            });

            $("#UpFile").change(function (e) {
                UpLoadFile();
            });
            function getFileName(o) {
                var pos = o.lastIndexOf("\\");
                return o.substring(pos + 1);
            }
            function UpLoadFile() {
                var file = $("#UpFile").val();
                var fileName = getFileName(file);

                var fd = new FormData();
				fd.append("UpFileData", $("#UpFile")[0].files[0]);
				fd.append("file", fileName);

                $.tool.pageLoadInfo("上传中，请等待");
                $.ajax({
                    url: "../UpLoad/UpFile.aspx",
                    type: "POST",
                    processData: false,
                    contentType: false,
                    data: fd,
                    success: function (addr) {
                        $.tool.pageUnLoading();

                        if (addr.length > 200) {
                            HDialog.Info('上传失败啦,重新试试吧');
                        } else {
                            insertImage(addr);
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        $.tool.pageUnLoading();
                        HDialog.Info('上传失败啦,重新试试吧');
                    }
                });
            }

            function insertImage(addr) {
                var imageUrl = $("#ImageUrl").val();
                if (imageUrl != "") {
                    imageUrl = imageUrl + "," + addr;
                } else {
                    imageUrl = addr;
                }
                $("#ImageUrl").val(imageUrl);

                var html = "<div class=\"div-container\"><img class=\"xximg\" src=\"" + addr + "\">"
                html += "<input onclick=\"delImage(this)\" type=\"button\" class=\"button abscenter\" value=\"删除\"></div>";
                $("#imageContainer").prepend(html);
            }

            function delImage(obj) {
                $(obj).parent().remove();
                var $imgs = $("#imageContainer").find("img");
                var imageUrlArr = [];
                for (var i = 0; i < $imgs.length; i++) {
                    imageUrlArr.push($imgs.eq(i).attr("src"));
                }
                $("#ImageUrl").val(imageUrlArr.join(","));
            }
        </script>
    </form>
</body>
</html>

