<%@ Page Title="" Language="C#" MasterPageFile="~/whir_system/master/DialogMasterPage.master"
    AutoEventWireup="true" CodeFile="SiteFile_Iframe.aspx.cs" Inherits="Whir_System_Plugin_FileManage_SiteFile_Iframe" %>

<%@ Import Namespace="Whir.Language" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript" src="<%= SysPath %>res/script/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
    <script type="text/javascript" src="<%= SysPath %>res/script/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
    <link rel="stylesheet" type="text/css" href="<%= SysPath %>res/script/fancybox/jquery.fancybox-1.3.4.css"
        media="screen" />
        <style type="text/css">
           #tbdFileList td{ padding: 1px;}
        </style>
    <script type="text/javascript">
        $(function () {

            var isNew = '<%=IsNew %>'.toLowerCase() == 'true' ? true : false;
            var isBatchDelete = '<%=IsBatchDelete %>'.toLocaleLowerCase() == 'true' ? true : false;

            //是否具有新建文件夹功能 divDirectory
            if (isNew)
                $("#divDirectory").show();
            else
                $("#divDirectory").hide();

            //是否批量删除功能 lbnDelete
            if (isBatchDelete) {
                whir.control.getAllControlByNameToEnabled("a", "name", "lbnDel");
                $("#<%=lbnDelete.ClientID %>").css("display", "");
            }
            else {
                whir.control.getAllControlByNameToDisabled("a", "name", "lbnDel");
                $("#<%=lbnDelete.ClientID %>").css("display", "none");
            }
            //图片缩放
            if ($("a[rel^='fancybox']").fancybox) {
                $("a[rel^='fancybox']")
                    .fancybox({
                        'overlayShow': false,
                        'transitionIn': 'elastic',
                        'transitionOut': 'elastic'
                    });
            }
            //父页面iframe高度
            var ifm_height = $(".box_common").height();
            window.parent.iframeHeight(ifm_height + 50);
            window.parent.uploadReady("<%= Server.UrlEncode(CurrentPath) %>");
        });

        //点击选中文件列表中的多选框/单选框
        function select_file() {
            var selected = "";

            $("#tbdFileList input").each(function () {
                if ($(this).prop("checked")) {
                    selected += $(this).parent().parent("span").attr("realName") + "*";
                }
            });

            if (selected.length > 0)
                selected = selected.substring(0, selected.length - 1);

            $("#<%= hidSelected.ClientID %>").val(selected);
        }

        //批量选中删除
        function deleteAction() {
            if ($("#<%= hidSelected.ClientID %>").val() == '') {
                TipMessage('请选择');
                return false;
            }
            return true;
        }

        function editRealName(obj) {
            $(obj).next().show();
            $(obj).hide();
        }

        function editFile(path,ext, obj) {
            var newval = $(obj).prev().val();
            var val = $(obj).parent().prev().html();

            //path = 'E:\\word\\ezEIP v4.0.5\\WebSite\\cn\\template';

            $.ajax({
                type: "POST",
                url: "<%= SysPath %>ajax/extension/editFilesRealName.aspx?newfile=" + escape(newval+ext) + "&path=" + escape(path) + "&oldfile=" + escape(val),
                success: function (msg) {
                    if (msg == "true") {
                        $(obj).parent().prev().html(newval+ext);
                        $(obj).parent().hide();
                        $(obj).parent().prev().show();
                    } else {
                        alert(msg);
                    }
                }
            });
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <form id="Form1" runat="server">
    <div class="box_common">
        <h3 class="f_title">
            <%="文件".ToLang()%></h3>
        <div class="padding_10 td_pad_05">
            <table border="0" cellspacing="0" cellpadding="0" width="100%">
                <tr>
                    <td>
                        <table border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td valign="top" style="word-break: break-all;">
                                    <asp:Literal ID="litDirectory" runat="server"></asp:Literal>
                                </td>
                                <td valign="top">
                                    <whir:TextBox ID="txtFolder" runat="server" CssClass="text_common form-control" Width="160px"
                                        ValidationGroup="CreateFloder" ErrorCss="form_error" TipCss="form_tip" Required="true"
                                        MaxLength="32" ValidationExpression="[\w\u4e00-\u9fa5]*" ErrorMessage="不能输入敏感字符，如：“*”、“/”"
                                        Regular="Custom"></whir:TextBox>
                                </td>
                                <td valign="top">
                                    <asp:LinkButton name="aNew" ID="lbnCreateFolder" runat="server" CssClass="aAll_button btn btn-info"
                                        ValidationGroup="CreateFloder" OnCommand="Create_Command">
                            <b><%="新建文件夹".ToLang()%></b>
                                    </asp:LinkButton>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td valign="top" align="right">
                        <whir:TextBox ID="txtSearch" runat="server" CssClass="text_common form-control" Width="160px"
                            ValidationExpression="[\w\u4e00-\u9fa5|.]*" ErrorMessage="不能输入敏感字符，如：“*”、“/”"
                            Regular="Custom" MaxLength="32"></whir:TextBox>
                    </td>
                    <td valign="top" align="right" width="45">
                        <asp:LinkButton ID="lbtSearch" runat="server" CssClass="aAll_button btn btn-info" OnClick="lbtSave_Click">
                            <b> <%="搜索".ToLang()%></b>
                        </asp:LinkButton>
                    </td>
                </tr>
            </table>
        </div>
        <div class="All_list">
            <table width="100%" border="0" cellspacing="0" cellpadding="0"  class="controller table table-bordered table-noPadding">
                <tr>
                    <th class="th_center">
                        &nbsp;
                    </th>
                    <th class="th_center">
                        &nbsp;
                    </th>
                    <th>
                        <%="文件名称".ToLang()%>
                    </th>
                    <th>
                        <%="物理名称".ToLang() %>
                    </th>
                    <th>
                        <%="大小".ToLang() %>
                    </th>
                    <th width='<%= LanguageHelper.GetSplitValue("140px|140px|200px") %>' align="right">
                        <%="操作".ToLang()%>
                    </th>
                    <th>
                        &nbsp;
                    </th>
                </tr>
                <tr>
                    <td colspan="6">
                        <asp:LinkButton runat="server" ID="lbnUp" CssClass="btn btn-info" OnClick="lbnUp_Click">
                            <i class="glyphicon glyphicon-circle-arrow-up"></i>
                            <%="返回上级文件夹".ToLang()%>
                        </asp:LinkButton>
                    </td>
                </tr>
                <tbody id="tbdFileList">
                    <asp:Repeater ID="rptFileList" runat="server">
                        <ItemTemplate>
                            <tr>
                                <td align="center">
                                    <asp:Literal ID="litImg" runat="server"></asp:Literal>
                                </td>
                                <td class="center">
                                    <asp:Literal ID="litType" runat="server"></asp:Literal>
                                </td>
                                <td>
                                    <div class="linefeed">
                                        <asp:Literal ID="litName" runat="server"></asp:Literal></div>
                                </td>
                                <td>
                                    <div class="linefeed">
                                        <a href="javascript:void(0);" onclick="editRealName(this);">
                                            <asp:Literal ID="litRealName" runat="server"></asp:Literal></a>
                                        <div class="divEditRealName">
                                            <asp:TextBox runat="server" CssClass="text_common" ID="tbEditRealName"></asp:TextBox>
                                            <img src="<%= SysPath %>res/images/button_submit_icon_6.gif" onclick="editFile('<%# Eval("FullPath").ToStr().Replace("\\","\\\\") %>','<%# Eval("Ext") %>',this)" />
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    <%# Eval("Size") %>
                                </td>
                                <td align="right">
                                    <asp:Literal ID="litDownload" runat="server"></asp:Literal>
                                    <asp:Literal ID="litEdit" runat="server"></asp:Literal>
                                    <asp:LinkButton ID="lbnDel" name="lbnDel" CssClass="btn btn-danger" runat="server" OnCommand="Delete_Command"
                                        CommandArgument='<%# Eval("FullName") %>' CommandName="Delete" />
                                </td>
                                <td>
                                    <asp:CheckBox ID="cbxCheck" runat="server" Visible="false" />
                                    <asp:RadioButton ID="radCheck" runat="server" GroupName="radio" Visible="false" />
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </tbody>
            </table>
            <asp:HiddenField ID="hidSelected" runat="server" />
        </div>
        <div class="pages">
            <whir:WhirPager ID="AspNetPager1" runat="server" OnPageChanged="PageChanged" NumericButtonCount="5"
                UrlPaging="True" AlwaysShow="True" LayoutType="Table" PageSize="10" ShowCustomInfoSection="Left"
                CurrentPageButtonClass="" CustomInfoClass="Page_total" CustomInfoSectionWidth=""
                CustomInfoStyle="">
            </whir:WhirPager>
        </div>
        <div class="padding_10" align="right">
            <a class="aAll_button btn btn-primary" href="javascript:location.href = location.href">
                <%="刷新列表".ToLang()%>
            </a>
            <asp:LinkButton ID="lbnDelete" runat="server" CssClass="btn btn-danger" OnCommand="Delete_Command"
                CommandName="CheckDelete">
                <%="删除".ToLang()%>
            </asp:LinkButton>
        </div>
    </div>
    <script>
        $(".divEditRealName").hide();
    </script>
   </form>
</asp:Content>
