<%@ Page Title="" Language="C#" MasterPageFile="~/Dialog/DialogMaster.Master" AutoEventWireup="true"
    CodeBehind="SMSTemplateEdit.aspx.cs" Inherits="OAWeb.SMSEmail.SMSTemplateEdit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <style>
        .field_tags
        {
            text-decoration: underline;
        }
    </style>
    <div class="form" style="width: 600px; padding: 10px;">
        <table cellpadding="0" cellspacing="0" border="0" class="table_form">
            <tr>
                <td>
                    模板简称：<asp:TextBox ID="txtTempTitle" CssClass="text width200" runat="server"></asp:TextBox>
                    &nbsp;<asp:DropDownList ID="ddlTempType" runat="server">
                        <asp:ListItem Value="0">选择类型</asp:ListItem>
                    </asp:DropDownList>
                    <asp:CheckBox ID="chkEnabled" runat="server" Text="启用" Checked="True" />
                </td>
            </tr>
            <tr>
                <td>
                    可插入使用标签:<span class="sms_tag"></span>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="txtContent" runat="server" TextMode="MultiLine" Height="200px" CssClass="text ctl_content"
                        Width="100%"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    短信输入建议不超过65个字，超过则会拆分后发送，当前已输入 <span class="green" id="content_num">0</span>/65 个字
                </td>
            </tr>
            <tr>
                <td style="text-align: center">
                    <input id="btnSave" type="button" value=" 保 存 " class="btn_77px" />
                    <input id="btnClose" type="button" value=" 返 回 " onclick="art.dialog.close();return false;"
                        class="btn_77px" />
                </td>
            </tr>
        </table>
    </div>
    <script type="text/javascript">
        function changeNum() {
            $("#content_num").html($(".ctl_content").val().length);
            if ($(".ctl_content").val().length > 65) {
                $("#content_num").removeClass("green");
                $("#content_num").addClass("red");
            } else {
                $("#content_num").removeClass("red");
                $("#content_num").addClass("green");
            }
        }
        $(document).ready(function () {
            var jsonTag = eval('(<%=LoadTagData() %>)');
            $("#<%=ddlTempType.ClientID %>").change(function () {
                var type = $(this).val();
                $(".sms_tag").html("");
                $.each(jsonTag, function (n, value) {
                    if (n == type) {
                        $.each(value[0], function (name, field) {
                            $(".sms_tag").append("<a href=\"javascript:void(0)\" class=\"field_tags\"><{" + name + "}></a> ");
                        })
                    }
                })
            });
            $("#<%=ddlTempType.ClientID %>").change();
            $(".field_tags").live("click", function () {
                var txt = $("#<%=txtContent.ClientID %>");
                insertAtCursor(txt, $(this).text());
                changeNum();
            })
            $("#btnSave").click(function () { return FormPostAjax("/SMSEmail/SMSTemplateEdit.aspx?op=Save&Id=<%=Id %>", "ok", CloseReload); });
            $(".ctl_content").keyup(changeNum);
            changeNum();
        });

    </script>
</asp:Content>
