<%@ Page Language="C#" MasterPageFile="~/Admin/MainPage.Master" AutoEventWireup="true" CodeBehind="MessageTemplateSet.aspx.cs" Inherits="PPFOR.Admin.Sys.WebConfig.Config.MessageTemplateSet" Title="编辑模板" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PPFOR_mainContent" runat="server">
<script src="/ckeditor/ckeditor.js" type="text/javascript" ></script>
<script type="text/javascript">
function $id(id){
    return (document.all ? document.all[id] : document.getElementById(id))||false;
}
function showLabelText()
{
    var objLabelList=$id('<%=PPFOR_labelList.ClientID %>');
    var v=objLabelList?objLabelList.value:'';
    var objLabelText=$id('labelText');
    if(objLabelText){
        objLabelText.value=v;
    }
}
function insertLabelToTitle(){
    var objLabelList=$id('<%=PPFOR_labelList.ClientID %>');
    var v=objLabelList?objLabelList.value:'';
    insertLabel('<%=PPFOR_templateTitle.ClientID %>',v);
}
function insertLabelToContent(){
    var objLabelList=$id('<%=PPFOR_labelList.ClientID %>');
    var v=objLabelList?objLabelList.value:'';
    appenData(v);
}
function insertLabel(id,label){                
    var objText = $id(id);
    if(objText){
        objText.focus();
        if (document.all){
            var r = document.selection.createRange();
            document.selection.empty();
            r.text = label;
            r.collapse();
            r.select();
        }
        else{
            var newstart = objText.selectionStart+label.length;
            objText.value=objText.value.substr(0,objText.selectionStart)+label+objText.value.substring(objText.selectionEnd);
            objText.selectionStart = newstart;
            objText.selectionEnd = newstart;
        }
    }
}    
</script>
<form id="form1" action="MessageTemplateSet.aspx" method="post" runat="server">
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="fortable">
<tr>
    <td style="width:15%" align="right">可用标签：</td>
    <td>
        <asp:DropDownList ID="PPFOR_labelList" runat="server"></asp:DropDownList>
        &nbsp;<input id="labelText" type="text" onfocus="this.select();" readonly="readonly" />
        &nbsp;<input type="button" class="blueinput" onclick="insertLabelToContent();" value="插入到内容" />
        &nbsp;<input type="button" class="blueinput" onclick="insertLabelToTitle();" value="插入到标题" />        
    </td>
</tr>
</table>
<br />
<asp:Label Enabled="false" Visible="false" ID="PPFOR_language" runat="server"></asp:Label>
<asp:Label Enabled="false" Visible="false" ID="PPFOR_when" runat="server"></asp:Label>
<asp:Label Enabled="false" Visible="false" ID="PPFOR_for" runat="server"></asp:Label>
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="fortable">
    <tr>
        <td style="width:15%" align="right">发送项目：</td>
        <td>
            <asp:Label ID="PPFOR_name" runat="server"></asp:Label>
        </td>
    </tr>
    <tr>
        <td align="right">是否启用：</td>
        <td>
            <asp:CheckBox ID="PPFOR_status" runat="server" Checked="true" Text="启用"></asp:CheckBox>
        </td>
    </tr>
    <tr>
        <td align="right">标题模板：</td>
        <td>
            <asp:TextBox ID="PPFOR_templateTitle" MaxLength="50" runat="server" Width="300px"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td align="right">内容模板：</td>
        <td align="center">
            <asp:TextBox ID="PPFOR_templateContent" runat="server" TextMode="MultiLine" Height="300px" Width="98%"></asp:TextBox>
            <script type="text/javascript">
            var isHtmlFile='<%=PPFOR_isNeedEditor.ToString() %>';
            var ckEditor=null;
            if (isHtmlFile.toLowerCase()=="true"){
                ckEditor=CKEDITOR.replace("<%=PPFOR_templateContent.ClientID%>", {
                     customConfig:'/ckeditor/email_config.js',
                     height:300
                 });
            }   
            function appenData(data)
            {          
                if (ckEditor!=null)
                {
                    if(ckEditor.mode=="source")
                    {
                        ckEditor.focus();
                        if(document.selection){
                            with(document.selection.createRange())
                            {
                                 text = data;
                                 collapse();
                            }
                        }                 
                    }else{
                        ckEditor.insertHtml(data);
                    }
                }else{
                    insertLabel('<%=PPFOR_templateContent.ClientID%>',data);
                }
            }                    
             </script>
        </td>
    </tr>
    <tr>
        <td colspan="2" align="center" style="height:30px; display:none">
            <asp:Button ID="PPFOR_templateSave" runat="server" CssClass="inputbutton" Text="保存设置" OnClick="PPFOR_templateSaveClick" />
            <input type="reset" id="reset1" value="重置" class="inputbutton" onmouseover="this.className='inputbutton_hover'" onmouseout="this.className='inputbutton'"/><br />
            <asp:Label ID="PPFOR_goBackToTemplateList" runat="server"></asp:Label>
            <script type="text/javascript">              
              addButtonArray("<%= PPFOR_templateSave.ClientID %>","reset1","goBack");
            </script> 
        </td>
    </tr> 
</table> 
</form>        
</asp:Content>
