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

<!DOCTYPE html>
<html>
<head>
    <title>社区信息编辑器</title>
    <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" />
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    
    <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>
        .abscenter {
            position: absolute;
            top: 50%;
            left: 50%;
            margin-left: -53px;
            margin-top: -15px;
        }

        .xximg {
            border: 1px solid #cccccc;
            width: 120px;
            height: 120px;
            margin-right: 5px;
        }
    </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="InfoType" type="hidden" name="InfoType"  runat="server" />
        <input id="OpType" type="hidden" name="OpType" runat="server" />
        <input id="CommID" type="hidden" name="CommID" runat="server" />
        <input id="IsAudit" type="hidden" name="IsAudit" value="0" runat="server" />
        <table class="DialogTable" border="0">
            <tr>
                <td class="DialogTdTitle">标题</td>
                <td class="DialogTdContent_4Col" colspan="3">
                    <input id="Heading" runat="server" name="Heading" type="text" class="easyui-validatebox" style="width:97%;"/>
                </td>
            </tr>
            <tr>
                <td class="DialogTdTitle">发布时间</td>
                <td class="DialogTdContent_4Col">
                    <input id="IssueDate" runat="server" name="IssueDate" type="text" class="easyui-datetimebox" />
                </td>
                <td class="DialogTdTitle">过期时间</td>
                <td class="DialogTdContent_4Col">
                    <input id="ShowEndDate" runat="server" name="ShowEndDate" type="text" class="easyui-datetimebox" />
                </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">简介图
                </td>
                <td class="DialogTdContent_4Col" colspan="3">
                    <div style="float: left; position: relative">
                        <img id="xximg" class="xximg" src="../images/nopicture2.jpg" runat="server" />
                        <input id="add" type="button" class="button abscenter" value="添加" runat="server">
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="4" style="text-align: center; padding-top: 15px;">
                    <input type="button" class="button" value="保存" id="BtnSave" />
                </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">

            $("#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() {
                    });
            });

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

            $(document).ready(function () {
                var value = $('#InfoContent').val();
                value = document.getElementById('InfoContent').value;

                ue.ready(function () {
                    var h = $(window).height();
                    ue.setHeight(200);
                    ue.setContent(value);
                });
            }
            );

            $("#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]);

                $.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('上传失败啦,重新试试吧');
                            return;
                        }
                        else {
                            $("#ImageUrl").val(addr);
                            $("#xximg").attr("src", addr);
                            $("#add").val("更换");
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        $.tool.pageUnLoading();
                        HDialog.Info('上传失败啦,重新试试吧');
                    }
                });
            }
        </script>
    </form>
</body>
</html>
