<?php
use common\assets\SwfUploadAsset;
use yii\helpers\Html;
use yii\helpers\Url;

/* @var $this \yii\web\View */
/* @var $content string */

$asset = SwfUploadAsset::register($this);
?>

<?php $this->beginPage() ?>
<!doctype html>
<html>
	<head>
		<meta charset="<?= Yii::$app->charset ?>">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<?= Html::csrfMetaTags() ?>
		<title>上传附件</title>
		<?php $this->head() ?>
		<style>
            html, body, div, dl, dt, dd, ul, p, th, td, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend {
                margin: 0;
                padding: 0;
            }
            body {
                color: #333;
                font-family: Arial;
                font-size: 12px;
                line-height: 1.5;
            }
            li {
                list-style: outside none none;
            }
            a {
                color: #266aae;
                text-decoration: none;
            }
			/*设置tab*/
			.pop_nav {
				padding:10px 15px 0;
				margin-bottom:10px;
			}
			.pop_nav ul{
				border-bottom:1px solid #e3e3e3;
				padding:0 5px;
				height:25px;
				clear:both;
			}
			.pop_nav ul li{
				float:left;
				margin-right:10px;
			}
			.pop_nav ul li a{
				float:left;
				display:block;
				padding:0 10px;
				height:25px;
				line-height:23px;
			}
			.pop_nav ul li.current a{
				border:1px solid #e3e3e3;
				border-bottom:0 none;
				color:#333;
				font-weight:700;
				background:#fff;
				position:relative;
				border-radius:2px;
				margin-bottom:-1px;
			}
			.pop_cont{
				padding:0 15px;
			}
			/*上传*/
			.edit_menu_cont {
				padding: 10px 15px;
			}
			.edit_uping {
				height: 30px;
				margin-bottom: 10px;
			}
			.edit_uping .num {
				color: #999999;
				float: right;
				margin-top: 5px;
			}
			.edit_uping .num em {
				color: #FF5500;
				font-style: normal;
			}
			.eidt_uphoto {
				border: 1px solid #CCCCCC;
			}
			.eidt_uphoto ul {
				height: 280px;
				overflow-y: scroll;
				padding-bottom: 10px;
				position: relative;
			}
			.eidt_uphoto li {
				display: inline;
				float: left;
				height: 100px;
				margin: 10px 0 0 10px;
				width: 87px;
			}
			.eidt_uphoto .invalid {
				background: none repeat scroll 0 0 #FBFBFB;
				border: 1px solid #CCCCCC;
				height: 98px;
				position: relative;
				width: 78px;
			}
			.eidt_uphoto .invalid .error {
				padding: 30px 1px;
				text-align: center;
			}
			.eidt_uphoto .no {
				background: url("<?= $asset->baseUrl ?>/images/upload_pic.jpg") no-repeat scroll center center #FBFBFB;
				border: 1px solid #CCCCCC;
				height: 98px;
				overflow: hidden;
				text-indent: -2000em;
			}
			.eidt_uphoto .nouplode {
				background: #FBFBFB;
				border: 1px solid #CCCCCC;
				height: 98px;
				overflow: hidden;
				text-align: center;
				padding: 0px 5px 0px 5px;
			}
			.eidt_uphoto .schedule {
				background: none repeat scroll 0 0 #FFFFFF;
				border: 1px solid #CCCCCC;
				height: 98px;
				line-height: 98px;
				position: relative;
				text-align: center;
			}
			.eidt_uphoto .schedule span {
				background: none repeat scroll 0 0 #F0F5F9;
				height: 98px;
				left: 0;
				position: absolute;
				top: 0;
			}
			.eidt_uphoto .schedule em {
				left: 0;
				position: absolute;
				text-align: center;
				top: 0;
				width: 78px;
				z-index: 1;
			}
			.eidt_uphoto .get{
				background:#ffffff;
				border:1px solid #cccccc;
				position:relative;
				overflow:hidden;
			}
			.eidt_uphoto .selected{
				border:2px solid #1D76B7;
			}
			.eidt_uphoto .get img{
				cursor:pointer;
			}
			.eidt_uphoto .del{
				position:absolute;
				width:15px;
				height:15px;
				background:url("<?= $asset->baseUrl ?>/images/upload_del.png") no-repeat;
				right:1px;
				top:1px;
				overflow:hidden;
				text-indent:-2000em;
				display:none;
			}
			.eidt_uphoto .del:hover{
				background-position:-20px 0;
			}
			.eidt_uphoto .get img{
				vertical-align:top;
				width:87px;
				height:75px;
				border-bottom:1px solid #ccc;
			}
			.eidt_uphoto .get input{
				border:0;
				outline:0 none;
				margin-left:3px;
			}
			.eidt_uphoto .get .edit{
				position:absolute;
				height:22px;
				line-height:22px;
				text-align:center;
				width:78px;
				bottom:0;
				left:0;
				background:#e5e5e5;
				color:#333;
				filter:alpha(opacity=70);
				-moz-opacity:0.7;
				opacity:0.7;
				display:none;
			}
			.eidt_uphoto li:hover .edit,
			.eidt_uphoto li:hover .del{
				/*text-decoration:none;
				display:block;*/
			}
			/*上传选择按钮*/
			#btupload,.addnew{
				background: url("<?= $asset->baseUrl ?>/js/swfupload/images/swfBnt.png") no-repeat; float:left; margin-right:10px;width:75px; height:28px; line-height:28px;font-weight:700; color:#fff;
			}
			#btupload{ 
				vertical-align:middle;border:none;cursor: hand;!important;cursor: pointer;
			}
			.addnew{
				background: url("<?= $asset->baseUrl ?>/js/swfupload/images/swfBnt.png") no-repeat; float:left; margin-right:10px;width:75px; height:28px; line-height:28px;font-weight:700; color:#fff;
			}
			.addnew{
				background-position: left bottom;
			}
			.hide{
				display:none;
			}
		</style>
		<script>

			//用于图库加载
			function set_iframe(id, src) {
				if ($("#" + id).attr("src") == "") {
					$("#" + id).attr("src", src);
				}
			}

			//网络地址
			function addonlinefile(obj) {
				var strs = $(obj).val() ? '|' + $(obj).val() : '';
				$('#att-status').html(strs);
			}

			var swfu_contents = '';
			$(document).ready(function() {
				swfu_contents = new SWFUpload({
					flash_url: "<?= $asset->baseUrl ?>/js/swfupload/swfupload.swf?" + Math.random(),
					upload_url: "<?= Url::to(['upload']) ?>",
					file_post_name: "Filedata",
					post_params: {
                        <?= session_name() ?>: "<?= session_id() ?>",
						_csrf: "<?= Yii::$app->request->getCsrfToken() ?>",
						route: "<?= $route ?>",
						//"swf_auth_key": "b1984e185e939308bc8f8382df92def4"
					},
					file_size_limit: "<?= $sys_upload_size ?>KB",
					file_types: "<?= $allow_ext ?>",
					file_types_description: "All Files",
					file_upload_limit: "<?= $upload_num ?>",
					custom_settings: {progressTarget: "fsUploadProgress", cancelButtonId: "btnCancel"},
					button_image_url: "",
					button_width: 75,
					button_height: 28,
					button_placeholder_id: "buttonPlaceHolder",
					button_text_style: "",
					button_text_top_padding: 3,
					button_text_left_padding: 12,
					button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
					button_cursor: SWFUpload.CURSOR.HAND,
					file_dialog_start_handler: fileDialogStart,
					file_queued_handler: fileQueued,
					file_queue_error_handler: fileQueueError,
					file_dialog_complete_handler: fileDialogComplete,
					upload_progress_handler: uploadProgress,
					upload_error_handler: uploadError,
					upload_success_handler: uploadSuccess,
					upload_complete_handler: uploadComplete
				});
				$('.tab_div').Tabs({
					event: 'click'
				});
			})



		</script>
	</head>
	<body class="body_none">
		<?php $this->beginBody() ?>
		<div class="wrap tab_div" style="padding:5px;">
			<div class="pop_nav ">
				<ul class="J_tabs_nav tab_menu">
					<li class="current"><a href="javascript:;">上传</a></li>
					<li class=""><a href="javascript:;" onClick="set_iframe('album_list', '<?= Url::to(['list', 'upload_num' => $upload_num]) ?>')">附件库</a></li>
				</ul>
			</div>
			<div class="J_tabs_contents tab_box">
				<div class="pop_cont">
					<div class="">
						<div class="edit_uping"> 
							<!--选择按钮-->
							<div class="addnew"><span  id="buttonPlaceHolder"></span></div>
							<span class="num">  单次最多上传<em> <?= $upload_num ?></em> 个附件,单文件最大 <em><?= $sys_upload_size ?> KB</em>，<em style="cursor: help;" title="可上传格式：<?= $allow_ext ?>">支持格式？</em></span>
						</div>
						<div class="eidt_uphoto">
							<ul id="fsUploadProgress" class="cc">
								<!--<li class="J_empty"><div class="no">暂无</div></li>-->
							</ul>
						</div>
					</div>
				</div>
				<div class="pop_cont hide" >
					<iframe name="album-list" src="" frameborder="false" scrolling="no" style="overflow-x:hidden;border:none" width="100%" height="350" allowtransparency="true" id="album_list"></iframe>
				</div>

			</div>
		</div>
		<div id="att-status" style="display:none"></div>
		<div id="att-status-del" style="display:none"></div>
		<div id="att-name" style="display:none"></div>
		<div id="att-id" style="display:none"></div>
		<script>
			$(function() {
				$("#att-status").html("");
				$("#att-status-del").html("");
				$("#att-name").html("");
			});
        </script>
        <?php $this->endBody() ?>
	</body>
</html>
<?php $this->endPage() ?>
