
<style>
	html{_overflow-y:scroll}
	.swfupload {position: absolute;z-index: 1;}
	.mainnav_title {display:none;}
	</style>
	<link href="__ROOT__/Public/Js/swfupload/swfupload.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" href="/js/layui/css/layui.css">
    <script src="/js/layui/layui.js"></script>
	<script type="text/javascript" src="__ROOT__/Public/Js/swfupload/swfupload.js"></script>
	<script type="text/javascript" src="__ROOT__/Public/Js/swfupload/fileprogress.js"></script>
	<script type="text/javascript" src="__ROOT__/Public/Js/swfupload/handlers.js"></script>
	<script type="text/javascript">
			$.ajaxSetup ({ cache: false });
	
			var file_limit = {$file_limit};
			var swfu;
	function ajaxload(typeid,page,inputid,isadmin)
	{
		var data = '';
		var url =  "{:U('Attachment/filelist')}&typeid="+typeid+"&p="+page+"&inputid="+inputid+"&isadmin="+isadmin;
		$.ajax({
			 type: "POST",
			 url: url,
			 data: data,
			 success: function(msg){
				$('#'+inputid).html(msg);
				for(var i=0;i<ids.length;i++){
					$('#on_'+ids[i]).addClass("on");
				}
			 }
		});
	}
	
	</script>
	<div id="content">
	<div id="tabs">
		<div class="title"><ul><li class="on"><a href="javascript:void(0);">{:L('upload_file')}</a></li>
		<li><a href="javascript:void(0);">{:L('upload_url')}</a></li>
		<if condition="!empty($more)">
		<li><a href="javascript:void(0);" onclick="ajaxload(1,1,'filelist',<?php echo $isadmin;?>);">{:L('upload_list_file')}</a></li>
		<li><a href="javascript:void(0);"  onclick="ajaxload(0,1,'nouselist',<?php echo $isadmin;?>);">{:L('upload_unuse_file')}</a></li>
		</if>
		<if condition="!empty($no_use_files)">
		<li style="border:0;background:none;"><a href="{:U('Attachment/cleanfile?isadmin='.$isadmin)}" style="color:#FB0000;">{:L('no_use_files')}</a></li>
		</if>
		</ul></div>
	
		<div class="content_1">
			<div class="tabbox" style="display:block;">
					<div id="divMovieContainer">
						<!-- <div class="selectbut"><span id="spanButtonPlaceHolder"></span></div>
						<input type="button" value="{:L('start_upload')}" id="uploadbut" onclick="swfu.startUpload();"/> -->
						<div style="display: inline-block;float:left;">
							<button type="button" class="layui-btn layui-btn-sm" id="upload">
								<i class="layui-icon">&#xe67c;</i>上传图片
							</button>
						</div>
						<div style="color:#959595;line-height:24px;height:24px;background:url() no-repeat;padding-left:20px;"><input type="checkbox" id="addwater" name="addwater" value="1" onclick="addwater_enable();" <if condition="$watermark_enable==1"> checked</if>/> <font color="green">{:L('upload_add_water')}</font> , {:L('upload_say4')} <font color="red">{$file_types}</font> {:L('upload_say5')}</div><br>
						<div style="color:#454545;clear:both;line-height:24px;height:24px;"> {:L('upload_say1')} <font color="red">{$file_limit}</font> {:L('upload_say2')} <font color="red">{$file_size}</font>	{:L('upload_say3')}</div>
					</div>
	
	
					<!-- <div id="divStatus">{:L('upload_say6')}<span id="tdFilesQueued">0</span>{:L('upload_say7')}<span id="tdErrors">0</span> {:L('upload_say8')}<span id="tdFilesUploaded">0</span> {:L('upload_say9')}</div> -->
					<fieldset  id="swfupload-box">
						<legend>{:L('file_list')}</legend>
						<ul id="fsUploadProgress"></ul>
						<ul class="attachment-list"  id="thumbnails"></ul>
					</fieldset>
	
			</div>
			<div class="tabbox">
			 <br>
				{:L('upload_fileurl')}: <input type="text" id="fileurl" name="fileurl" class="input-text" value=""  style="width:350px;"  onblur="addfileurl(this)">
				<br><br><br>
	
			</div>
			<div class="tabbox">
				<div id="filelist"></div>
			</div>
			<div class="tabbox">
				<div id="nouselist"></div>
			</div>
		</div>
	</div>
	
	<div  id="myuploadform" style="display:none;" ></div>
	<script>
	new Tabs("#tabs",".title ul li",".content_1",".tabbox","on",1);
	function addfileurl(obj) {
		var strs = $(obj).val() ?  $(obj).val() : '';
	
		if(strs){
			var datas='<div id="uplist_1"><input type="hidden" id="aids" name="aids"  value="0"  /><input type="text"  id="filedata" name="filedata" value="'+strs+'"  /><input type="text"  id="namedata" name="namedata" value=""  /> &nbsp;<a href="javascript:remove_this(\'uplist_1\');">{:L('remove')}</a> </div>';
			$('#myuploadform').html(datas);
			$('#thumbnails   a ').removeClass("on");
			$('.img a ').removeClass("on");
		}else{
	
			$('#myuploadform').html('');
		}
	}
	
	var insert2Xheditor =  insert2Xheditor || function(){
			<if condition="$_GET[immediate]==1">var immediate='!';</if>
			var arrMsg=[],img = '',data = '',i=0;
			var num = $('#myuploadform > div').length;
			if(num){
					$('#myuploadform   div').each(function(){
						var status =  $(this).find('#status').val();
						var aid = $(this).find('#aids').val();
						var src = $(this).find('#filedata').val();
						var name = $(this).find('#namedata').val();
						if(status!=0) aid=0;
						arrMsg[i]= { "url":immediate+src,"localfile":name,"id":aid,"editorid":"{$_GET[editorid]}" };
						i++;
				   });
				  // $('#{$_GET[editorid]}_aid_box').append(data);
			}
			//arrMsg.push({"name":"","url":"!200906030521128703.gif","id":});
			callback(arrMsg);
	}

	layui.use('upload', function () {
		var upload = layui.upload;
		//执行实例
		var uploadInst = upload.render({
			elem: '#upload' //绑定元素
			, url: '{:U('Attachment/upload')}' //上传接口
			, data:{ "PHPSESSID": "<?php echo  $sessid;?>", "isadmin": "<?php echo $isadmin;?>", "userid": "<?php echo $userid?>", "swf_auth_key": "<?php echo $swf_auth_key;?>", "isthumb": "<?php echo $isthumb;?>", "moduleid": "<?php echo $moduleid?>", "addwater": "<?php echo intval($watermark_enable);?>", "lang": "<?php echo $lang;?>" }
			,multiple :true
			,number:file_limit
			, done: function (res) {
				if (res.status == 1) {
					file_limit--;
					if(file_limit <= 0){
						$('#divMovieContainer').hide();
					}
					add_uploadok(res.data);
				}
			}
			, error: function () {
			}
	    });
		$('#addwater').on('click', function () {
			if ($(this).attr('checked')) {
				uploadInst.config.data.addwater = "1"
			} else {
				uploadInst.config.data.addwater = ""
			}
		})
	})
	</script>
	<if condition="!empty($_GET[editorid])">
	<div id="bootline"></div>
	<div id="btnbox" class="btn" style="padding-left:450px;">
			<INPUT TYPE="submit" onclick="insert2Xheditor();" value="{:L(dosubmit)}" class="button " >
	<input TYPE="reset" onclick="unloadme();" value="{:L(cancel)}" class="button">
	</div>
	</if>
	