<%@ page language="C#" masterpagefile="AdminIndexMaster.master" validaterequest="false" autoeventwireup="true" inherits="Admin_Admin_Template, mallz" title="编辑模板内容" enableEventValidation="false" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script src="Js/tabpane.js" type="text/javascript"></script>
<link href="css/tabpane.css" type="text/css" rel="stylesheet" />
<style type="text/css">
    .label_square{width:90px;height:25px;line-height:25px;border:solid 1px #449AE8;background:#E0EEF5;text-align:center;margin:5px;float:left;cursor: pointer;overflow:hidden;}
    .drag_lablestyle{width:90px;height:25px;line-height:25px;border:solid 1px #449AE8;background:#E0EEFE;text-align:center;margin:5px;float:left;overflow:hidden;}
</style>
<script id="pejs" type="text/javascript">
<!--
var dragspan;
var src;
var labeltype;

function dit(outype)
{
    window.drag = 1;
    window.event.returnValue = false;
    
    dragspan = document.createElement('div');
    dragspan.style.position = "absolute";
    dragspan.className = "drag_lablestyle";
    var mousePos = mouseCoords(window.event);
    dragspan.style.left = mousePos.x + 10;
    dragspan.style.top = mousePos.y + 8;
    dragspan.style.zIndex = 100;
    dragspan.appendChild(document.createTextNode(window.event.srcElement.innerHTML));
    if(outype == 0)
    {
        src = "{MZ.Config." + window.event.srcElement.getAttribute("value") + "}";
    }
    else if(outype == 1)
    {
        src = window.event.srcElement.getAttribute("value");
    }
    else if(outype == 2)
    {
        src = window.event.srcElement.getAttribute("value");
    }
    else if(outype == 3)
    {
        src = window.event.srcElement.getAttribute("value");
    }
    else
    {
        src = "<xsl:value-of select=\"$" + window.event.srcElement.getAttribute("value") + "\"/>";
    }
    labeltype = outype; 
    document.body.appendChild(dragspan);
}
    
function cit()
{
    var target =document.getElementById('ctl00_ContentPlaceHolder1_TemplateContent');
    target.focus();
    if(labeltype == 1 || labeltype == 2 || labeltype == 3)
    {
        var link;
        var ret;
        var rnd=Math.random();
        if (labeltype == 2){
            link= "admin_Pagelabelparameter.aspx?n=" + escape(src)+"&rnd="+rnd;
            ret = showModalDialog(link,window,'dialogWidth:500px; dialogHeight:350px; help: no; scroll: no; status: no; edge: sunken;');
        }else if(labeltype == 3){
            link= "admin_Csslabelparameter.aspx?n=" + escape(src)+"&rnd="+rnd;
            ret = showModalDialog(link,window,'dialogWidth:500px; dialogHeight:350px; help: no; scroll: no; status: no; edge: sunken;');
        }else{
            link= "Admin_labelparameter.aspx?n=" + escape(src)+"&rnd="+rnd;;
            ret = showModalDialog(link,'','dialogWidth:500px; dialogHeight:350px; help: no; scroll: auto; status: no; edge: sunken;');        
        }
        if (ret != null)
        {
            if (ret.replace(/^\s+|\s+$/g,"") == "")
            {
                alert("不能输入空值");
            }
            else
            {
                target.focus();
                var tarobj = document.selection.createRange();
                tarobj.text = ret;
            }
        }
    }
    else
    {
        var tarobj = document.selection.createRange();
        tarobj.text = src;
    }
    if(window.drag)
    {
        window.drag = 0;
        window.event.returnValue = true;
    }
}

function dragend()
{
    if(window.drag)
    {
        document.body.removeChild(dragspan);
        cit();
    }
    
}

function dragmove()
{
    if(window.drag)
    {
        var ev = ev || window.event;
        var mousePos = mouseCoords(ev);

        ev.returnValue = false;
                 
        dragspan.style.left = mousePos.x + 10;
        dragspan.style.top = mousePos.y + 8;
    }
}

function dragclear()
{
    if(window.drag)
    {
        document.body.removeChild(dragspan);
        window.drag = 0;
        window.event.returnValue = true;
    }
    
}
   
function mouseCoords(ev) {
    if(ev.pageX || ev.pageY) {
      return {x:ev.pageX, y:ev.pageY};
    }
    return {
      x:ev.clientX + document.documentElement.scrollLeft - document.body.clientLeft,
      y:ev.clientY + document.documentElement.scrollTop - document.body.clientTop
    };
}

function movePoint() 
{
    if(window.drag)
    {
        var rng = event.srcElement.createTextRange(); 
        rng.moveToPoint(event.x,event.y); 
        rng.select(); 
    }
}

var fpath = '/App_Themes/AdminDefaultTheme/';

function sizeChange(size){
    var obj=document.getElementById('ctl00_ContentPlaceHolder1_TemplateContent');
    var height = parseInt(obj.offsetHeight);
    if (height+size>=100){
        obj.style.height=height+size;
    }
}

function TemplateContent_dblclick()
{
    if(window.event.button==2){
        var obj=document.selection.createRange().duplicate().text;
        if(obj!=""){
            if(obj.indexOf("<MZ:")>=0){
                alert(obj);
            }
        }
    }
}
-->
</script>

<div style="width:98%;clear:both; margin:5px auto; height:20px;">
    <div style="float:left">
       <asp:literal runat="server" ID="TemplateTitle" Text="填写文件名：" />
       <asp:literal runat="server" ID="EditTemplateTitle" Text="编辑模板：" />&nbsp;&nbsp;
       <asp:Literal ID="TemPath" runat="server" />&nbsp;&nbsp;
       <asp:Literal ID="TemplateFileName" runat="server" />
       <asp:TextBox ID="TemplateName" runat="server" /> 
       <asp:Literal ID="TemNameMsg" Text=".html (不需要写后缀,默认后缀为“.html”)" runat="server" />
    </div>
    <div style="float:right"><a href="Admin_ManageTemplate.aspx">返回上一级</a></div>
</div>

<table class="nick" cellpadding="1" cellspacing="1" onmouseup="dragclear()" onmousemove="dragmove()" >
      <tr><td class="tit" colspan="3">模板内容编辑</td></tr>
      <tr>
          <td style="text-align:left; vertical-align:top;">
              <asp:TextBox ID="TemplateContent" TextMode="MultiLine" Wrap="true" Height="435px" Width="100%"  runat="server" CssClass="TextBoxStyle" onmousedown="return TemplateContent_dblclick()" />
          </td>
          <td style="cursor:hand; cursor:pointer; width:5px;"></td>
          <td style="text-align:left; vertical-align:top;padding-top:5px;" id="LabelTitle">
              
             <div class="tab-page" id="labeltempate_module" style="width:250px;">
                <script type="text/javascript">
                   var tabPane1 = new WebFXTabPane( document.getElementById( "labeltempate_module" ), 1 )
                </script>
                
                <div class="tab-page" id="label_label">
                   <h2 class="tab" style="height:16px;">内容标签</h2>
                   <script type="text/javascript">
                       tabPane1.addTabPage( document.getElementById( "label_label" ) );
                   </script>
                   <div>
                        <asp:DropDownList ID="LabelClassSelect" runat="server" AutoPostBack="true" OnSelectedIndexChanged="select_LabelClassSelect" AppendDataBoundItems="true">
                           <asp:ListItem Text="全部标签" Value="全部标签" />
                        </asp:DropDownList>
                        </div>
                        <div id="SysLabelDiv" style="overflow: auto; height:390px;">
                            <asp:Literal ID="LabelList" runat="server" />      
                        </div>           
                </div>
                
                <div class="tab-page" id="label_parm">
                   <h2 class="tab" style="height:18px;">分页标签</h2>
                   <script type="text/javascript">
                      tabPane1.addTabPage( document.getElementById( "label_parm" ) );
                   </script>
                   <div>
                       <asp:DropDownList ID="PageLabelClassSelect" runat="server" AutoPostBack="true" OnSelectedIndexChanged="BindPageLabel_Change" AppendDataBoundItems="true">
                           <asp:ListItem Text="全部分页标签" Value="全部分页标签" />
                        </asp:DropDownList>
                   </div>
                   <div style="overflow: auto; height:390px;">
                     <asp:Literal ID="PageLabelList" runat="server" />
                   </div>
                </div>
                
                <div class="tab-page" id="label_function">
                   <h2 class="tab" style="height:18px;">系统标签</h2>
                   <script type="text/javascript">
                       tabPane1.addTabPage( document.getElementById( "label_function" ) );
                   </script>
                   <asp:Literal ID="SysLabell" runat="server" />
                </div>
               
             </div>  
          </td>
      </tr>
   </table>  
   
   <div class="div_btm"> 
       <asp:RequiredFieldValidator ControlToValidate="TemplateName" ID="rfv1" runat="server" ErrorMessage="请填写模板名称" Display="Dynamic" />
       <asp:Button ID="ButViewModify" runat="server" Visible="false" Text=" 可视编辑 " OnClientClick="window.open('Editor/Admin_TemplateView.aspx?Dir={0}','view','');return false; " />&nbsp;
       <asp:Button ID="SaveTemplateButton" runat="server"  Text=" 保 存 " OnClick="SaveTemplateButton_Click" />&nbsp;
       <input id="BtnCancel" type="button" value=" 取 消 " onclick="javascript:history.go(-1)" />
   </div>
   
</asp:Content>

