<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="iframe.aspx.cs" Inherits="Kcms.UI.Inc.iframe" %>
<%@ Register assembly="PageNavigator" namespace="KcNavigator" tagprefix="Kc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="style.css" rel="stylesheet" type="text/css" />
    <script src="/inc/swfupload/swfupload.js" type="text/javascript"></script>
    <script src="/inc/swfupload/js/swfupload.queue.js" type="text/javascript"></script>
    <script src="/inc/swfupload/js/fileprogress.js" type="text/javascript"></script>
    <script src="/inc/swfupload/js/handlers.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="/inc/swfupload/progress/css.css" />
    <script type="text/javascript">
        function refreshThis() {
            <%=ClientScript.GetPostBackEventReference(UpdatePanel1, "refresh") %>;
        }

        function insertUpload(id, type) {
            var input = '<%=input %>';
            var win = art.dialog.parent;
            switch (type) {
                case 0:
                    html = "<img src=\"/uploads/?" + id + ".jpg\" alt=\"\" />";
                    try {
                        win.KE.util.focus(input);
                        win.KE.util.selection(input);
                        win.KE.util.insertHtml(input, html);
                    }
                    catch (e) {
                        parent.document.frames("workArea").KE.util.focus(input);
                        parent.document.frames("workArea").KE.util.selection(input);
                        parent.document.frames("workArea").KE.util.insertHtml(input, html);
                    }
                    break;
                case 1:
                    try {
                        win.document.getElementById(input).value = id;
                    }
                    catch (e) {
                        parent.document.frames("workArea").document.getElementById(input).value = id;
                    }
                    break;
                case 2:
                    var vin = input + "_v";
                    try {
                        win.document.getElementById(input).innerHTML = "<img src=\"/uploads/?" + id + ",110,110.jpg\" alt=\"\" />";
                        win.document.getElementById(vin).value = id;
                    }
                    catch (e) {
                        parent.document.frames("workArea").document.getElementById(input).innerHTML = "<img src=\"/uploads/?" + id + ",110,110.jpg\" alt=\"\" />";
                        parent.document.frames("workArea").document.getElementById(vin).value = id;
                    }
                    break;
            }
            art.dialog.close();
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
<div class="iframe">
    <div class="upswf clearfix">
        <div><span id="upfile"></span></div>
        <div class="txt">[如果已经上传，可直接从下面列表中选择！]</div>
    </div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div id="divprogress" class="clearfix"></div>
            <div class="clearfix">
            <ul>
                <asp:Repeater ID="rptList" runat="server">
                <ItemTemplate>
                    <li><a href="javascript:insertUpload(<%#Eval("id") %>,<%=type %>)" title="<%#Eval("filename") %>"><img src="/uploads/?<%#Eval("id") %>,60,60.jpg" alt="" width="60" height="60" border="0" /></a></li>
                </ItemTemplate>
                </asp:Repeater>
            </ul>
            </div>
            <Kc:PageNavigator ID="PageNavigator1" runat="server" CssClass="pager" onchangepageclick="PageNavigator1_ChangePageClick" />
        </ContentTemplate>
        </asp:UpdatePanel>
</div>
    </form>
</body>
<script type="text/javascript">
    initUpload();
    
    var swfu;
    function initUpload() {
        var settings = {
            flash_url: "/inc/swfupload/swfupload.swf",
            upload_url: "/inc/upload.ashx?w=<%=w %>",
            file_size_limit: "5MB",
            file_types: "*.jpg;*.gif;*.png;*.bmp",
            file_types_description: "允许*.jpg;*.gif;*.png;*.bmp",
            file_upload_limit: 0, //上传数不限，系统计算
            file_queue_limit: 5, //排队数
            custom_settings: {
                progressTarget: "divprogress",
                container_css: "progress clearfix",
                icoNormal_css: "IcoNormal",
                icoWaiting_css: "IcoWaiting",
                icoUpload_css: "IcoUpload",
                state_div_css: "statebarDiv",
                state_bar_css: "statebar",
                br_div_css: "brdiv"
            },

            debug: false,

            // Button settings
            button_image_url: '/inc/swfupload/progress/images/upload_photo.png',
            button_placeholder_id: 'upfile',
            button_width: 100,
            button_height: 35,
            button_text: '<span class="theFont"></span>',
            button_text_style: '.theFont { text-indent: 22px;}',
            button_text_left_padding: -1,
            button_text_top_padding: -1,
            button_cursor: SWFUpload.CURSOR.HAND,
            button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,

            file_queued_handler: fileQueued,
            file_queue_error_handler: fileQueueError,
            upload_start_handler: uploadStart,
            upload_progress_handler: uploadProgress,
            upload_error_handler: uploadError,
            upload_success_handler: uploadSuccess,
            upload_complete_handler: uploadComplete,
            file_dialog_complete_handler: fileDialogComplete,
            queue_complete_handler: queueComplete
        };

        if (swfu) {
            var movie = swfu.getMovieElement();
            var placeHolder = document.createElement("div");
            placeHolder.id = settings.button_placeholder_id;
            movie.parentNode.replaceChild(placeHolder, movie);
        }

        if (!$D(settings.button_placeholder_id) || !$D(settings.custom_settings.progressTarget)) {
            alert('缺少容器' + settings.button_placeholder_id + '或' + settings.custom_settings.progressTarget + '');
            return;
        }

        swfu = new SWFUpload(settings);
    }
    function $D(b) { return typeof b == "string" ? document.getElementById(b) : b }
</script>
</html>
