<%@ Page Language="C#" AutoEventWireup="true" CodeFile="New.aspx.cs" Inherits="Board_One2one_New" ValidateRequest="false" meta:resourcekey="Page" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <title></title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../libs/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="../../libs/bootstrapValidator.min.css">
    <link rel="stylesheet" href="../../libs/fontawesome/css/all.min.css" >
    <script type="text/javascript" src="../../libs/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="../../libs/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="../../libs/bootstrapValidator.min.js"></script>
</head>
<body>
    <script type="text/javascript">
        $(document).ready(function () {
            Dialog.setMessage('<asp:Literal runat="server" Text="<%$ Resources:Dialog, Title%>" />', '<asp:Literal runat="server" Text="<%$ Resources:Dialog, OK%>" />', '<asp:Literal runat="server" Text="<%$ Resources:Dialog, Cancel%>" />');
            Dialog.setUseBrowserConfirm(<%=AppSetting.UseBrowserConfirm%>);

            $("#form1").bootstrapValidator().on('success.form.bv', function (e) {
                // 폼 서브미션 금지하고 __doPostBack 호출
                e.preventDefault();
                // 작성된 글을 게시하시겠습니까?
                Dialog.confirm({
                    content: '<asp:Literal runat="server" Text="<%$ Resources:, Msg01%>" />',
                    ok: function () {
                        __doPostBack("SaveButton", "");
                    },
                    cancel: function () {
                        // confirm 취소 시 서브밋 버튼 활성화
                        var $form = $(e.target);
                        $form.bootstrapValidator("disableSubmitButtons", false);
                    }
                });
            });
        });

        function AddFiles(e) {
            var url = "../../Mail/SelectFile.aspx?key=<%=_uploadKey%>";
            window.open(url, "AttachFileWindow");
            e.stopPropagation();
        }

        function OnCompletedUpload() {
            __doPostBack("AddAttachFileButton", "");
        }

        function RemoveFile(index) {
            $("#<%=RemoveAttachFileIndex.ClientID %>").val(index);
            __doPostBack("RemoveAttachFileButton", "");
        }

        function GotoBack() {
            history.back();
        }

        function ShowMessage(msg) {
            Dialog.alert(msg);
        }
    </script>

    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
            <CompositeScript>
                <Scripts>
                    <asp:ScriptReference Path="~/libs/tabs/common.js" />
                    <asp:ScriptReference Path="~/libs/tabs/dialog.js" />
                </Scripts>
            </CompositeScript>
        </asp:ScriptManager>

        <div class="container-fluid">
            <div class="row" id="toolBar" data-spy="affix">
                <div class="col-xs-12" style="padding-top:2px;padding-bottom:2px;">
                    <button type="submit" id="saveToolButton" class="btn btn-primary"><span class="fa-solid fa-download"></span> <asp:Localize ID="Localize1" runat="server" meta:resourcekey="L01">저장</asp:Localize></button>
                    <span>&nbsp;</span>
                    <button type="button" id="closeToolButton" class="btn btn-primary" onclick="GotoBack();"><span class="fa-solid fa-xmark"></span></button>
                </div>
            </div>
        </div>

        <div class="container-fluid" style="padding-top:40px">
            <div class="form-group">
                <label for="ToTextBox"><asp:Localize ID="Localize6" runat="server" meta:resourcekey="L06">제목</asp:Localize>:</label>
                <input type="text" runat="server" id="SubjectTextBox" name="SubjectTextBox" class="form-control" placeholder="<%$ Resources:, Msg03%>" autocomplete="off"
                    required data-bv-notempty-message="<%$ Resources:, Msg02%>" />
            </div>            
            <asp:UpdatePanel ID="attachPanel" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
                <ContentTemplate>
                    <div class="row" style="padding-bottom:0.5em">
                        <div class="col-xs-12" data-toggle="collapse" data-target="#attachList">
                            <strong><asp:Localize ID="Localize2" runat="server" meta:resourcekey="L02">첨부 파일</asp:Localize>:</strong> 
                            <asp:Label ID="AttachSummaryLabel" runat="server"></asp:Label>
                            <button type="button" id="addAttachButton" class="btn btn-default" onclick="AddFiles(event)"><span class="fa-solid fa-plus"></span></button>
                        </div>
                    </div>
                    <ul id="attachList" runat="server" class="list-group collapse">
                        <asp:Literal ID="AttachListTag" runat="server" />
                    </ul>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="AddAttachFileButton" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="RemoveAttachFileButton" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
            <div class="form-group">
                <label for="MsgTextBox"><asp:Localize ID="Localize3" runat="server" meta:resourcekey="L03">본문</asp:Localize>:</label> <span class="text-muted small"><asp:Localize ID="Localize4" runat="server" meta:resourcekey="L04">HTML 태그를 사용한 편집은 지원하지 않습니다.</asp:Localize></span>
                <textarea class="form-control" rows="10" id="MsgTextBox" runat="server"></textarea>
            </div>
            <div class="checkbox" id="fixedTopPanel" runat="server">
                <label><input type="checkbox" id="FixedTopCheckBox" runat="server"><asp:Localize ID="Localize5" runat="server" meta:resourcekey="L05">고정글로 게시합니다.</asp:Localize></label>
            </div>
            <div class="checkbox" id="anonymousPanel" runat="server">
                <label><input type="checkbox" id="AnonymousCheckBox" runat="server"><asp:Localize ID="Localize7" runat="server" meta:resourcekey="L07">익명으로 작성합니다.</asp:Localize></label>
            </div>
            
            <div id="SrcArticleView" runat="server" style="display:none;">
                <strong><asp:Localize ID="Localize8" runat="server" meta:resourcekey="L08">질문글</asp:Localize>:</strong> 
                <div><asp:PlaceHolder ID="MsgBodyHolder" runat="server" EnableViewState="false"></asp:PlaceHolder></div>
            </div>
            <div>&nbsp;</div> 
        </div>

        <div style="display:none">            
            <asp:LinkButton ID="SaveButton" runat="server" OnClick="SaveButton_Click" /> 
            <asp:LinkButton ID="AddAttachFileButton" runat="server" OnClick="AddAttachFileButton_Click" /> 
            <asp:LinkButton ID="RemoveAttachFileButton" runat="server" OnClick="RemoveAttachFileButton_Click" />
            <asp:HiddenField ID="RemoveAttachFileIndex" runat="server" />
        </div>
    </form>
</body>
</html>
