<%@ Page Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true"
    ValidateRequest="false" Inherits="PowerEasy.Module.General.WebSite.Admin.Template.LabelTemplate"
    Title="标签内容编辑" CodeBehind="LabelTemplate.aspx.cs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CphNavigation" runat="Server">
    <pe:ExtendedSiteMapPath ID="SmpNavigator" SiteMapProvider="AdminMapProvider" runat="server" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CphContent" runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
    <table style="width: 100%; margin: 0 auto;" cellpadding="2" cellspacing="0" class="border">
        <tr>
            <td class="spacingtitle" style="height: 22px;" colspan="5" align="center">
                <b>标签内容编辑</b>
            </td>
        </tr>
        <tr class="tdbg">
            <td style="text-align: center; vertical-align: top; width: 200px" id="ft">
                <pec:CodeSnippetPanel ID="CodeSnippetPanel1" runat="server" />
            </td>
            <td onclick="switchSysBar('sp','ft','left')" style="width: 12px; cursor: pointer">
                <img id="sp" src="<% =StyleSheetPath %>images/butClose.gif" alt="关闭" style="border: 0px;
                    width: 12px;" />
            </td>
            <td style="text-align: left; vertical-align: top">
                <div>
                    <input type="text" class="inputtext" value="" id="cbox" size="50" />
                    <input type="button" onclick="findText()" value="查找下一个并选择" />
                </div>
                <asp:TextBox ID="TxtTemplate" runat="server" Height="430px" Width="99%" TextMode="MultiLine"
                    Wrap="False" CssClass="txt_main inputtext"></asp:TextBox>
                <div style="text-align: center; vertical-align: top;">
                    <img alt="增加高度" src="../../Admin/Images/sizeplus.gif" onclick="sizeChange(50)" />
                    <img alt="减少高度" src="../../Admin/Images/sizeminus.gif" onclick="sizeChange(-50)" />
                </div>
            </td>
            <td onclick="switchSysBar('sp2','ft2', 'right')" style="width: 12px; cursor: pointer">
                <img id="sp2" src="<% =StyleSheetPath %>images/butOpen.gif" alt="关闭" style="border: 0px;
                    width: 12px;" />
            </td>
            <td style="text-align: left; vertical-align: top; width: 1px;" id="ft2">
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <div style="text-align: center; width: 200px">
                            <asp:Button ID="BtnShowSchema" OnClick="BtnShowSchema_Click" runat="server" Text="架构"
                                BackColor="Red"></asp:Button>
                            <asp:Button ID="BtnShowDetal" OnClick="BtnShowDetal_Click" runat="server" Text="全部">
                            </asp:Button></div>
                        <div id="xmltreediv" style="overflow: auto; float: left; width: 200px; height: 400px;
                            text-align: left">
                            <pe:ExtendedLabel HtmlEncode="false" ID="ShowXml" runat="server"></pe:ExtendedLabel>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </td>
        </tr>
        <tr class="tdbg">
            <td align="center" colspan="5">
                &nbsp;<asp:Button ID="BtnPrv" OnClick="BtnPrv_Click" runat="server" Text="上一步" Style="cursor: pointer;
                    cursor: hand; width: 88px;"></asp:Button>&nbsp;&nbsp;<asp:Button ID="BtnUse" OnClick="BtnUse_Click"
                        runat="server" Text="应用" Style="cursor: pointer; cursor: hand; width: 88px;">
                </asp:Button>&nbsp;&nbsp;<asp:Button ID="BtnFinal" OnClick="BtnFinal_Click" runat="server"
                    Text="完　成" Style="cursor: pointer; cursor: hand; width: 88px;"></asp:Button>&nbsp;&nbsp;<input
                        id="BtnCancel" type="button" class="inputbutton" value="取　消" onclick="Redirect('LabelManage.aspx?type=-3')"
                        style="cursor: pointer; cursor: hand; width: 88px;" />&nbsp; &nbsp;<pe:OneClickButton
                            IsOneClick="false" ID="OpenShowTemplate" runat="server" Text="查看效果" />
                &nbsp;&nbsp;<input id="BtnXmlShow" type="button" class="inputbutton" value="导出数据"
                    onclick="openxmlshow();" style="cursor: pointer; cursor: hand; width: 88px;" />
            </td>
        </tr>
    </table>
    <div id="prompt-note">
        <dl>
            <dt class="prompt-note-tit"><span>提示说明</span> <a>操作说明</a> <a>XSLT简介</a> <a>其他说明</a>
                <a>数据源标签说明</a> <span class="right-line"></span></dt>
            <dd class="prompt-note-con">
                <p>
                    左方列出的是XML节点列表，右方进行模板编辑。</p>
                <p>
                    请直接拖放节点到右方的模板编辑器中，系统会自动加上调用代码。</p>
                <p>
                    如需要输入全路径节点，请按住"CTRL"键再进行拖放。</p>
                <p>
                    如果您擅长使用Macromedia Dreamweaver 8，可以通过“导出数据”功能，将标签数据保存为XML文件，再使用DW8的XSLT编辑功能进行本地编辑。</p>
            </dd>
            <dd class="prompt-note-con" style="display: none;">
                <p>
                    XSLT，是最近伴随XML兴起的一种模板编辑语言，XSLT通过对XML数据的重新整理，生成符合需要的HTML或其他代码，而这个重新整理的规范，就成为XSLT模板。<br />
                    XSLT本身也是XML结构的文档模式，您在XSLT中定义的模板，也必须符合W3C对XML的各项规定。</p>
            </dd>
            <dd class="prompt-note-con" style="display: none;">
                <p>
                    XSLT要求使用的HTML代码必须有封闭符号，比如原来的&lt;br&gt;就必须写为&lt;br /&gt。</p>
            </dd>
            <dd class="prompt-note-con" style="display: none;">
                <p>
                    如需要使用可视化输入方式，请在节点定义的上下，使用标记，样式如下：<br />
                    <span style="color: Red;">&lt;!-- FieldTipsStart --&gt;</span><br />
                    你的数据源标签字段包括在此标记内.<br />
                    <span style="color: Red;">&lt;!-- FieldTipsEnd --&gt;</span></p>
            </dd>
            <div class="clearbox">
            </div>
        </dl>
    </div>
    <asp:Panel ID="Panel1" runat="server" Style="display: none" ScrollBars="Auto" CssClass="modalPopup">
        <asp:Panel ID="Panel3" runat="server" Style="cursor: move; background-color: #CCCCDD;
            border: solid 1px Gray; color: Black; text-align: center">
            <b>标签测试窗口</b>
        </asp:Panel>
        当前分页：<asp:TextBox ID="TxtTempPage" runat="server" Text="1" Width="30px"></asp:TextBox><br />
        测试页名：<asp:TextBox ID="TxtTempPageName" runat="server" Text="test.aspx?page={$pageid/}"
            Width="480px"></asp:TextBox><br />
        测试标签：<asp:TextBox ID="TxtTemplateTest" runat="server" Width="480px"></asp:TextBox>
        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate>
                &nbsp;<asp:Button ID="BtnShowTemplate" runat="server" OnClick="BtnShowTemplate_Click"
                    Text="刷新" Style="cursor: pointer; cursor: hand; width: 88px;" />
                &nbsp;&nbsp;<input id="tohtml" type="button" value="源码" onclick="sizeshowmode()"
                    style="cursor: pointer; cursor: hand; width: 88px;" />
                <div style="overflow: auto; width: 550px; height: 300px; background-color: #EEEEEE;
                    border: solid 1px Gray; color: Black;">
                    <pe:ExtendedLabel ID="LabShow" HtmlEncode="False" runat="server" Text="标签结果显示区"></pe:ExtendedLabel>
                    <textarea id="ShowHtml" cols="50" style="width: 540px; height: 380px; display: none"></textarea>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
        <pe:OneClickButton IsOneClick="false" ID="CloseButton" runat="server" Text="关闭" Style="cursor: pointer;
            cursor: hand" />
    </asp:Panel>
    <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server" TargetControlID="OpenShowTemplate"
        PopupControlID="Panel1" BackgroundCssClass="modalBackground" CancelControlID="CloseButton"
        DropShadow="true" PopupDragHandleControlID="Panel3" />
    <asp:HiddenField ID="HdnKeyword" Value="0" runat="server" />
    <pe:FloatDivDialog ID="FdvShowWindow" runat="server" EnableViewState="false" Width="800"
        Height="430" Enabled="true">
    </pe:FloatDivDialog>
    <script type="text/javascript">
        /* 导出XML数据 */
        function openxmlshow() {
            window.open('LabelXmlShow.aspx?name=' + encodeURI('<%= m_LabelName %>'), '_blank');
        }

        //弹出窗口函数
        function ShowWindow(url, title) {
            jQuery('.title').html(title);
            jQuery('#<%=FdvShowWindow.ClientID %>' + '__HdnLoadUrl').prop('value', url);
            jQuery('#<%=FdvShowWindow.ClientID %>' + '__LitID').click();
        }

        function sizeChange(size) {

            var obj = document.getElementById("<% = TxtTemplate.ClientID %>");
            var height = parseInt(obj.offsetHeight);
            if (height + size >= 100) {
                obj.style.height = height + size + 'px';
            }
        }

        function sizeshowmode() {
            var obj = $get("<% = LabShow.ClientID %>");
            if ($get("tohtml").value != "源码") {
                $get("tohtml").value = "源码";
                $get("ShowHtml").style.display = "none";
                obj.style.display = "";
            }
            else {
                $get("tohtml").value = "内容";
                $get("ShowHtml").style.display = "";
                $get("ShowHtml").value = obj.innerHTML;
                obj.style.display = "none";
            }
        }

        //边侧栏状态记忆，切换实现
        var fpath = '<% =StyleSheetPath %>';
        function switchSysBar(objname, target, dir) {
            var obj = $get(objname);
            if (obj.alt == "关闭") {
                obj.alt = "打开";
                if (dir == "right")
                    obj.src = fpath + "Images/butd.gif";
                else
                    obj.src = fpath + "Images/butc.gif";
                $get(target).style.display = "none";
            }
            else {
                obj.alt = "关闭";
                if (dir == "right")
                    obj.src = fpath + "Images/butc.gif";
                else
                    obj.src = fpath + "Images/butd.gif";
                $get(target).style.display = "";
            }
        }

        function sizeChange(size) {
            var obj = $get("<% = TxtTemplate.ClientID %>");
            var height = parseInt(obj.offsetHeight);
            if (height + size >= 100) {
                obj.style.height = height + size + 'px';
            }
        }

        function sizeshowmode() {
            var obj = $get("<% = LabShow.ClientID %>");
            if ($get("tohtml").value != "源码") {
                $get("tohtml").value = "源码";
                $get("ShowHtml").style.display = "none";
                obj.style.display = "";
            }
            else {
                $get("tohtml").value = "内容";
                $get("ShowHtml").style.display = "";
                $get("ShowHtml").value = obj.innerHTML;
                obj.style.display = "none";
            }
        }

        var isff = document.getElementById && !document.all;
        if (!isff) {
            var textRange = document.getElementById("<% = TxtTemplate.ClientID %>").createTextRange();
            var isSelect = false;
            var inputWord = "";
        }

        function findText() {
            if (!isff) {
                if (inputWord != document.getElementById('cbox').value) {
                    isSelect = false;
                }
                inputWord = document.getElementById('cbox').value;
                if (inputWord == "") {
                    alert("请输入要搜索的内容");
                    return;
                }
                var selectedWord = 0;
                if (document.selection) {
                    selectedWord = document.selection.createRange().text.length;
                }
                textRange.moveEnd("character", document.getElementById('<% = TxtTemplate.ClientID %>').value.length);
                textRange.moveStart("character", selectedWord);
                if (textRange.findText(inputWord)) {
                    textRange.select();
                    isSelect = true;
                }
                if (textRange.text != inputWord) {
                    if (isSelect) {
                        alert("已经搜索到内容末端！搜索将从头开始");
                        textRange = document.getElementById('<% = TxtTemplate.ClientID %>').createTextRange()

                    }
                    else {
                        alert("找不到" + inputWord);
                    }
                }
                else { return; }

            }
            else {
                alert("抱歉，搜索功能不能适应您的浏览器！");
            }
        }
    </script>
</asp:Content>
