<%@ page language="C#" masterpagefile="~/HL_Admin/AdminIndexMaster.master" autoeventwireup="true" inherits="HL_Admin_Admin_LabelTemplate, HoWaveVGO" title="Untitled Page" enableEventValidation="false" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script src="Js/tabpane.js" type="text/javascript"></script>
<style type="text/css">
.label_square{width:100px;height:30px;line-height:30px;border:solid 1px #449AE8;background:#E0EEF5;text-align:center;margin:5px;float:left;cursor: pointer;}
.drag_lablestyle{width:100px;height:30px;line-height:30px;border:solid 1px #449AE8;background:#E0EEFE;text-align:center;margin:5px;float:left;}
.modalPopup {
	background-color:#FFFFFF;
	border-color:#FFFFFF;
    border:1px;
	width:800px;
	 position:absolute;
	top:0px ; left:0px;
	filter:progid:DXImageTransform.Microsoft.Gradient (startColorStr='#F7FCFF', endColorStr='#C7DEED', gradientType='0');
	}
.modalBackground {
	background-color:#C0C0C0;
	filter:alpha(opacity=70);
	opacity:0.7;
}
</style>

<script  type="text/javascript">

/* 拖放插入控制 */
var ie = (document.getElementById && document.all);
var presskey = 'none';
var dragspan;
var src;
var labeltype=0;

document.onkeyup = function(e) { 
    if(ie) e = event;
    presskey = 'none';
} 

document.onkeydown =function(e) { 
    if(ie) e = event;
    if(e.keyCode == 18)
    {
        presskey = 'alt';
    }
    else if(e.keyCode == 17)
    {
        presskey = 'ctrl';
    }
    else
    {
        presskey = 'none';
    }
} 

function dit(outype)
{
    window.drag = 1;
    window.event.returnValue = false;
    
    dragspan = document.createElement('div');
    dragspan.style.position = "absolute";
    switch (presskey)
    {
    case 'ctrl':
        dragspan.className = "dragspandiv_ctrl";
        break;
    case 'alt':
        dragspan.className = "dragspandiv_alt";
        break;
    default:
        dragspan.className = "drag_lablestyle";
        break;
    }     
    var mousePos = mouseCoords(window.event);
    dragspan.style.left = mousePos.x + 15;
    dragspan.style.top = mousePos.y + 11;
    dragspan.style.zIndex = 100 ;
    dragspan.appendChild(document.createTextNode(window.event.srcElement.innerText));
    txtproce(outype, window.event.srcElement);
    
    document.body.appendChild(dragspan);
}

function txtproce(outype, selectobj)
{
    switch (outype)
    {
     case 0:
        switch (presskey)
        {
        case 'ctrl':
            src = "<xsl:apply-templates select=\"" + selectobj.path + "/" + selectobj.tn + "\"/>";
            break;
        case 'alt':
            src = "<xsl:template match=\"" + selectobj.path  + "/" + selectobj.tn + "\">\n</xsl:template>";
            break;
        default:
            src = "<xsl:for-each select=\"" + selectobj.path  + "/" + selectobj.tn + "\">\n</xsl:for-each>";
            break;
        }
        break;
    case 1:
        switch (presskey)
        {
        case 'ctrl':
            src = "<xsl:value-of select=\"" + selectobj.path  + "/" + selectobj.tn + "\"/>";
            break;
        case 'alt':
            src = "{" + selectobj.path  + "/" + selectobj.tn + "}";
            break;
        default:
            src = "<xsl:value-of select=\"" + selectobj.tn + "\"/>";
            break;
        }
        break;
    case 2:
        switch (presskey)
        {
        case 'ctrl':
            src = "<xsl:value-of select=\"" + selectobj.path  + "$" + selectobj.tn + "\"/>";
            break;
        case 'alt':
            src = "{" + selectobj.path  + "/$" + selectobj.tn + "}";
            break;
        default:
            src = "<xsl:value-of select=\"$" + selectobj.tn + "\"/>";
            break;
        }
        break;
    case 3:
        switch (presskey)
        {
        case 'ctrl':
            src = "<xsl:param name=\"" + selectobj.innerText + "\" />";
            break;
        case 'alt':
            src = "$" + selectobj.innerText;
            break;
        default:
            src = "<xsl:value-of select=\"$" + selectobj.innerText + "\" />";
            break;
        }
        break;
    case 4:
        src = selectobj.value.replace(/&qout;/g, "\"");
        break;
    case 5:
        src = "HL:" + selectobj.value.replace(/&qout;/g, "'");
        break;
    case 6:
        src = "{HL.Config." + selectobj.value + "}";
        break;
    case 7:
        src = selectobj.value;
    }
    labeltype = outype;
}

function cit()
{
   var target = document.getElementById('ctl00_ContentPlaceHolder1_TemplateContent');
   target.focus();
   if(labeltype == 7 ){
        var link= "Admin_labelparameter.aspx?a=a&n=" + escape(src);
        var ret = showModalDialog(link,'','dialogWidth:500px; dialogHeight:350px; help: no; scroll: no; 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 + 15;
        dragspan.style.top = mousePos.y + 11;
    }
}

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(); 
    }
}

function SetParam(Obj){
    var mLabelName = document.getElementById('ctl00_ContentPlaceHolder1_LabelName');
    if(Obj.value!=""){
        if(mLabelName.value.indexOf(" "+Obj.name+"=\"")==-1){
            newstr = mLabelName.value.replace(" }","");
            mLabelName.value = newstr + " " + " "+Obj.name + "=\"" + Obj.value + "\" }";
        }else{
            a = mLabelName.value.split(" "+Obj.name+"=\"");
            b = a[1].split("\"");
            pvalue = b[0];
            oldparm = " "+Obj.name + "=\"" + pvalue + "\"";
            newparm = " "+Obj.name + "=\"" + Obj.value + "\"";
            mLabelName.value = mLabelName.value.replace(oldparm,newparm);
        }
        
    }else{
        if(mLabelName.value.indexOf(" "+Obj.name+"=\"")>0){
            a = mLabelName.value.split(" "+Obj.name+"=\"");
            b = a[1].split("\"");
            pvalue = b[0];
            prarmstr = " "+Obj.name + "=\"" + pvalue + "\"";
            mLabelName.value = mLabelName.value.replace(prarmstr,"");
        }
    }
}
    
function showhiddenparmlistDiv(){
    obj = document.getElementById("parmlistDiv");
    if(obj.style.display=="none"){
        obj.style.display="";
    }else{
        obj.style.display="none";
    }
}

</script>

<asp:ScriptManager runat="server" EnablePartialRendering="true"/>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server" 
            TargetControlID="ShowButton"
            PopupControlID="Panel1" 
            BackgroundCssClass="modalBackground"
            CancelControlID="closeB" 
             DropShadow="true"
             Drag="true"
             X="100"
             Y="20"
             PopupDragHandleControlID="bar" />
             
<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" style="display: none;" >
<div style="text-align:left; padding:2px; border:1px solid #C7DEED;">
 <div id="bar" runat="server" style="width:100%; text-align:center; border:1px inset #FFFFFF; background-color:#AEB4D5; line-height:20px;" onmousedown="location.href='#';"><div style="width:95%; float:left;"><b>标签预览区</b></div><div style="float:right;" id="closeBar" runat="server"><b></b></div></div>
<asp:UpdatePanel id="UpdatePanel1" runat="server">
  <ContentTemplate>
    <div style="text-align:left;">
    <div id="parmlistDiv">
    <asp:Literal ID="ParmList" runat="server"></asp:Literal>
    </div>
    
    <div style="width:100%; line-height:25px;"><div style="float:left; width:15%; text-align:right;">标签：</div><div style="float:left; text-align:left;">
     <asp:TextBox id="LabelName" runat="server" Width="500"></asp:TextBox> <a href="#" onclick="{return showhiddenparmlistDiv();}">↑↓</a></div></div>
   <div style="padding-left:20px;"><asp:Button ID="ShowButton2" OnClick="ShowButton_Click" runat="server" Text="预 览" /> 
      <asp:Button ID="ShowButton3" OnClick="ShowButton_Click2" runat="server" Text="源 码" />
   </div>
<div style="height:300px; margin-top:5px; background-color:White; overflow: auto; font:16px;">

    <asp:Literal ID="ShowPlace" runat="server"></asp:Literal>
     
</div>
   </div>
  </ContentTemplate>
</asp:UpdatePanel>
</div>

<div style="line-height:20px; padding:0 5px 5px 5px;" ><asp:Button ID="closeB" runat="server" Text="关 闭" /></div>
</asp:Panel>


<asp:Panel ID="Panel2" runat="server">
<table class="adminheading">                       
   <tr>
      <th>标签管理</th> 
      <td align="right"><div style="width:50px"><a href="Admin_Lable.aspx">返回</a></div></td>
      <td class="rtdw"></td>
   </tr>                        
</table> 

   <table class="nick" cellpadding="1" cellspacing="1" onmouseup="dragclear()" onmousemove="dragmove()">
        <tr><td class="nick" colspan="2">标签内容编辑(<font color="red"><%=Request["name"] %></font>)</td></tr>
        <tr>
          <td style="text-align: left; vertical-align: top; ">
              <asp:TextBox ID="TemplateContent" TextMode="MultiLine"  Height="450px" Width="99%"  runat="server" CssClass="TextBoxStyle"/>
          </td>
          <td style="width: 12px; cursor: hand; cursor: pointer"></td>
          <td style="text-align: left; vertical-align: top; width: 250px;" id="LabelTitle">
             <div class="tab-page" id="labeltempate_module">
                <script type="text/javascript">
                   var tabPane1 = new WebFXTabPane( document.getElementById( "labeltempate_module" ), 1 )
                </script>
                <div class="tab-page" id="label_parm">
                    <h2 class="tab">标准代码</h2>
                    <script type=text/javascript>
                       tabPane1.addTabPage( document.getElementById( "label_parm" ) );
                    </script>
                    <div style="overflow: auto; float: left; width: 100%; height: 390px; text-align: left">
                        <div value="xmlns:ms=&qout;urn:schemas-microsoft-com:xslt&qout;" onclick="cit()" onmousedown="dit(4)" class="label_square">
                                MS命名空间</div>
                            <div value="xmlns:js=&qout;urn:the-xml-files:xslt-js&qout;" onclick="cit()" onmousedown="dit(4)" class="label_square">
                                JS代码命名空间</div>
                            <div value="xmlns:vb=&qout;urn:the-xml-files:xslt-vb&qout;" onclick="cit()" onmousedown="dit(4)" class="label_square">
                                VB代码命名空间</div>
                            <div value="xmlns:csharp=&qout;urn:the-xml-files:xslt-csharp&qout;" onclick="cit()" onmousedown="dit(4)" class="label_square">
                                C#命名空间</div>
                            <div value="xmlns:pe=&qout;labelproc&qout;" onclick="cit()" onmousedown="dit(4)" class="label_square">
                                扩展函数命名空间</div>
                            <div value="disable-output-escaping=&qout;yes&qout;" onclick="cit()" onmousedown="dit(4)" class="label_square">
                                HTML编码输出</div>
                            <div value="<xsl:value-of select=&qout;&qout;/>" onclick="cit()" onmousedown="dit(4)" class="label_square" title="变量调用标签">
                                value-of</div>
                            <div value="<xsl:for-each select=&qout;&qout;></xsl:for-each>" onclick="cit()" onmousedown="dit(4)" class="label_square" title="变量循环">
                                for-each</div>
                            <div value="<xsl:param name=&qout;&qout;/>" onclick="cit()" onmousedown="dit(4)" class="label_square" title="变量引入">
                                Param</div>
                            <div value="<xsl:with-param name=&qout;&qout;/></xsl:with-param>" onclick="cit()" onmousedown="dit(4)" class="label_square" title="变量传递">
                                With-Param</div>
                            <div value="<xsl:variable name=&qout;&qout;/>" onclick="cit()" onmousedown="dit(4)" class="label_square" title="变量定义">
                                Variable</div>
                            <div value="<xsl:template match=&qout;&qout;></xsl:template>" onclick="cit()" onmousedown="dit(4)" class="label_square" title="循环模板定义">
                                Templates</div>
                            <div value="<xsl:apply-templates select=&qout;&qout;/>" onclick="cit()" onmousedown="dit(4)" class="label_square" title="循环引用标签">
                                Apply-templates</div>
                            <div value="<a> <xsl:attribute name=&qout;href&qout;></xsl:attribute> <xsl:attribute name=&qout;title&qout;></xsl:attribute></a>" onclick="cit()" onmousedown="dit(4)" class="label_square" title="超连接元素">
                                A</div>
                            <div value="<xsl:element name=&qout;img&qout;><xsl:attribute name=&qout;src&qout;></xsl:attribute><xsl:attribute name=&qout;border&qout;>0</xsl:attribute></xsl:element>" onclick="cit()" onmousedown="dit(4)" class="label_square" title="图象元素">
                                Img</div>
                            <div value="<xsl:text disable-output-escaping=&qout;yes&qout;></xsl:text>" onclick="cit()" onmousedown="dit(4)" class="label_square" title="格式化字符输出">
                                Text</div>
                            <div value="<xsl:if test=&qout;&qout;></xsl:if>" onclick="cit()" onmousedown="dit(4)" class="label_square" title="条件标签">
                                If</div>
                            <div value="<xsl:choose><xsl:when test=&qout;&qout;></xsl:when><xsl:otherwise></xsl:otherwise></xsl:choose>" onclick="cit()" onmousedown="dit(4)" class="label_square" title="条件循环">
                                When</div>
                    </div>
                </div>
                <div class="tab-page" id="label_function">
                   <h2 class="tab">内容标签</h2>
                   <script type="text/javascript">
                       tabPane1.addTabPage( document.getElementById( "label_function" ) );
                   </script>
                   <div>
                        <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="SysLabel" runat="server" />
                        </div>
                   </div>
                   
                </div>
                <div class="tab-page" id="label_label">
                   <h2 class="tab">参数标签</h2>
                   <script type="text/javascript">
                       tabPane1.addTabPage( document.getElementById( "label_label" ) );
                   </script> 
                    <div  style="overflow: auto; height:390px;">
                        <asp:Literal ID="ParmLabel" runat="server" />
                   </div>                  
                </div>
             </div>  
          </td>
      </tr>
   </table>  
   <div class="div_btm">
       <asp:Button ID="PreStepButton" Text=" 上 一 步 " runat="server"  OnClick="PreStepButton_Click"/>&nbsp;
       <asp:Button ID="FinishButton" runat="server"  Text="完 成" OnClick="FinishButton_Click" />&nbsp;
       <asp:Button ID="ShowButton" runat="server"  Text="预 览"  />&nbsp;
       <input id="BtnCancel" type="button" value="取　消" onclick="window.location.href='Admin_Lable.aspx'"  style="cursor: pointer; cursor: hand; width: 88px;" />
   </div>
</asp:Panel>
    
</asp:Content>

