<{import file="index/header.html"}> 
<style type="text/css"> 
a.del{ padding:0; font-size:10px; background:none; border:0; border-radius:2px; color:#333; }
.content{ width:100%; float:left; } 
.imgbox{ width:120px; height:150px; margin:0 15px 15px 0; border:1px solid #efefef; float: left; }
.imgbox.ck{ border:1px solid #59AAF4; }
.imgbox .c0{ width:0; height:0; overflow:hidden; }
.imgbox .img{ width:120px; height:120px; line-height:117px; padding:0; margin:0; position:relative; text-align:center; float:left; }
.imgbox .img img{ max-width:120px; max-height:120px; margin:0; padding:0; }
.imgbox .img i.ck{ width:22px; height:22px; position:absolute; right:2px; top:2px; background:url(<{$__APP__}>public/svg/img_ck.svg?s);  z-index:10; float:right; }
.imgbox .act{ width:120px; border-top:1px solid #efefef; padding:5px 0 0 0; float:left; }
.imgbox .act input{ margin:1px 0 0 6px; float:left; }
.imgbox .act a{ margin:0 0 0 6px; float:left; } 
.btn{ margin:0 10px 0 0; float:left; }

</style>
<div class="nav"><span>相册管理</span></div>
<div class="filter" style=" width:100%; padding:8px 0; margin:0 0 10px 0; box-sizing: border-box; float:left;"> 
	<a class="button" id="del_all">删除</a>
	<div class="btn">
		<select name="type" class="select" id="album_type">
			<option value="" <{if $smarty.get.type == ''}>selected="selected"<{/if}>>全部图片</option> 
			<{foreach item=i key=k from=$type_arr}> 
				<option value="<{$k}>" <{if $smarty.get.type === $k}>selected="selected"<{/if}>><{$i}></option>
			<{/foreach}> 
		</select>
	</div>
	<div class="upload_button">
		<a id="file" class="file" href="javascript:;" style="height:20px; background:#1583F0; color:#fff; border:1px solid #1583F0">文件上传<input type="file" name="imgFile" class="img_file" id="imgFile"/></a>
	</div>
</div> 
<div class="main">
	<div class="content">
		<{if $data.list}>
			<{foreach item=i from=$data.list}>
				<div class="imgbox">
					<div class="c0"><input type="checkbox" class="checked_list" value="<{$i.id}>"/></div>
					<div class="img">
						<a href="javascript:;">
							<img src="<{$__IMG__}><{$i.url|img_size:120x120}>"><i></i>
						</a>
					</div>
					<div class="act">
						<a href="javascript:;" data-url="<{$i.url}>" class="copy">复制</a>
						<a href="<{$__IMG__}><{$i.url}>" target="_blank">查看</a>
						<a href="javascript::" data-id="<{$i.id}>" class="del">删除</a>
					</div>
				</div> 
			<{/foreach}>
		<{else}>
			<div class="nomsg">还没有数据，赶快添加吧！</div>
		<{/if}>
	</div> 
	<{if $data.page}><div class="page"><{$data.page}></div><{/if}>
</div>
<{import file="index/footer.html"}>
<script type="text/javascript">
_delete(ADMIN+'album/del', '#del_all');
// 选中图片
$(document).on('click', '.imgbox .img', function(){ 
	$this = $(this); 
	if($this.find('i').hasClass('ck')){
		$this.find('i').removeClass('ck');
		$this.parent().removeClass('ck');
		$this.parent().find('.c0 input').attr('checked', false);
	}else{
		$this.find('i').addClass('ck'); 
		$this.parent().addClass('ck');
		$this.parent().find('.c0 input').attr('checked', true);
	}
});

// 下拉菜单 
$(document).on('change', '#album_type', function(){ 
	type_id = $(this).children('option:selected').val();  
	location.href="<{$__ADMIN__}>album/index?type="+type_id;
});

upload('#imgFile', '<{$__ADMIN__}>album/upload?path=temp', function(data){ 
	if(data.error == '0'){
		parent.$.alert('上传成功');
		location.reload();
	}else{
		parent.$.alert(data.msg);
	} 
});

// 复制 
$(document).on('click', '.copy', function(e){
	data = $(this).attr('data-url');
	var flag = copyText(data); 
	$.alert(flag ? "复制成功！" : "复制失败！");
}); 
</script>
