<{import file="index/top.html" title="相册管理"}> 
<link rel="stylesheet" type="text/css" href="<{$__APP__}>public/css/album.css">  
<div class="hd_bar">
	<div class="hd">
		<div class="logo"><a href="?m=shop"><img src="<{$__IMG__}><{$UQCMS.site_logo}>"/></a><span>图片管理</span></div>
		<div class="space">
			<span>使用容量 </span>
			<div class="capacity"><span style="width:<{$space.percent}>%"></span><i><{$space.size}>/<{$space.limit}></i></div> 
		</div> 
	</div> 
</div>
<div class="ab_bar">
	<div class="ab">
		<!--顶部分类-->
		<div class="lft">
			<div class="album_tree"></div> 
			<input type="hidden" id="atree_ck" value=""/>
			<div class="atree_box_right_click"></div>
		</div>	
		<!--右侧部分-->
		<div class="rit">
			<!--管理页面-->
			<div class="manage"> 
				<div class="mgbox"> 
					<div class="chose">
						<span><label><input type="checkbox" name="all_ck"/><i>全选</i></label></span> 
					</div> 
					<a href="javascript:;" onClick="type_set('设置分类', 'member.php?m=album&a=type_set&type=<{$smarty.get.type}>')">移动到分类</a> 
					<a href="javascript:;" class="del_all">删除</a> 
					
					<div class="file2"> 
						<input type="file" name="images[]" id="imgFile" class="album_upload_button" multiple="multiple"/>上传文件  
					</div>	
				</div> 
				<input type="hidden" id="ajax_album_menu_type" value="<{$smarty.get.type}>"/> 
			</div> 
			<!--相册列表-->
			<div class="albumcon ajax_album_img"></div>
			<!--分页-->
			<div class="page ajax_album_page"><{$page}></div>
		</div> 	
		
	</div>
</div> 
<{include file="index/footer.html"}>
<script type="text/javascript" src="<{$__PUBLIC__}>plug/zclip/jquery.zclip.js"></script>
<script type="text/javascript" src="<{$__APP__}>public/js/uqcmsupload.js"></script> 
<script type="text/javascript"> 
function type_set(name, url){ 
	ajax_dialog(name, url, 440); 
}
function edit_floder(name, url){ 
	ajax_dialog(name, url, 380); 
}
$(function(){
	// 默认加载左侧的模块
	$.album_menu('0', function(html){
		h_html =  '<div class="atree_box">'+
				'	<div class="atree_box_one type_0 ptype_0">'+
				'		<a href="javascript:;" data-id="0" class="open ck"><i class="icon"></i><span>全部分类</span></a>'; 
		h_html +=		html +
				'	</div>'+
				'</div>'; 
		$(".album_tree").html(h_html);
	}); 
	// 右侧列表
	get_album_list('0');
	// 点击左侧右边的执行
	$(".album_tree").album_tree({
		conhtml: function(pid){
			$("#atree_ck").val(pid);
			get_album_list(pid);
		}
	}); 
	
	// 相册弹窗 分页操作
	$(document).on('click', ".ajax_album_page a", function(event){ 
		if(window.event){
			window.event.returnValue = false;
		}else{  
			event.preventDefault();	 //for firefox
		}
		var jump_url = $(this).attr('href');
		if(jump_url){
			pid = '0';	// 参数失效
			get_album_list(pid, jump_url);
		}
	});
	
	// 右侧目录
	$(document).on('contextmenu','.album_tree .atree_box_one a',function(e){
		$this = $(this);
		var X = $this.offset().top; 
		var Y = $this.offset().left;
		id = $(this).attr('data-id'); 
		html = '<div class="rit_click_box">'+
					'<a href="javascript:;" onClick="edit_floder(\'创建分类\', \'member.php?m=album&a=type_edit&pid='+id+'\')">创建分类</a>'+
					'<a href="javascript:;" onClick="edit_floder(\'重命名文件夹\', \'member.php?m=album&a=type_edit&id='+id+'\')">重命名</a>'+
					'<a href="javascript:;" class="floder_del" data-id="'+id+'">删除分类</a>'+
				'</div>'; 
		$(".atree_box_right_click").html(html); 
		$(".rit_click_box").css({top:X+22, left:Y+18});
		// 选中操作
		if(!$this.hasClass('open')){
			 $this.addClass('open');
			// 分类部分
			var pid = $this.attr('data-id'); 
			$.album_menu(pid, function(html){
				$this.after(html); 					 
			});
			// 内容回调
			$("#atree_ck").val(pid);
			get_album_list(pid);
		}
		$(".album_tree .atree_box_one a").removeClass('ck');	
		$this.addClass('ck');  
		return false;
	});
	// 删除目录
	$(document).on('click','.floder_del',function(e){
		id = $(this).attr('data-id');
		 $.get('member.php?m=album&a=type_del&id='+id, function(result){
			var data = jQuery.parseJSON(result); 
			if(data.error == '0'){
				$(".atree_box_one.type_"+id).remove();
			}else{
				$.alert(data.msg);
			} 
		 });
	}); 
	// atree弹出的 移除
	$(document).click(function(){
		$(".rit_click_box").remove();
	});
 	
	// ---------------------选中--------------------
	$(document).on('click','.abox .img a',function(e){
		$this = $(this);
		ck_status = $this.attr('data-ck');
		if(ck_status == 'ck'){
			$this.parents('.abox').removeClass('ck_img');
			$this.find('input').attr("checked",false);
			$this.attr('data-ck','');
		}else{
			$this.parents('.abox').addClass('ck_img');
			$this.find('input').attr("checked","checked");
			$this.attr('data-ck','ck'); 
		}
	});
	// 全选
	$("input[name='all_ck']").click(function(){ 
    	if(this.checked){ 
			$(".abox").each(function(){
				$(this).addClass('ck_img');
				$(this).find('input').attr("checked","checked");
				$('.img a',this).attr('data-ck','ck'); 
			});
    	}else{
			$(".abox").each(function(){
				$(this).removeClass('ck_img');
				$(this).find('input').attr("checked",false);
				$('.img a',this).attr('data-ck',''); 
			});
    	}   
 	}); 
	
	// 图片复制
	var cfg={
        path: "<{$__PUBLIC__}>plug/zclip/ZeroClipboard.swf",
        copy: function(){
      	  	return $(this).attr('data-url');
        },
        beforeCopy:function(){	/* 按住鼠标时的操作 */
            $(this).css("color","orange");
        },
        afterCopy:function(){	/* 复制成功后的操作 */ 
			$.alert('复制成功'); 
        }
    };
	$(document).on('mouseover', '.copy', function(e){
	   if(!$(this).data('init')){
			$(this).zclip(cfg);
			$(this).data('init',true);
		}
	});
	// 删除
	$(document).on('click','a.del',function(e){
		$this = $(this);
		id = $this.attr('data-id');
		$.post('?m=album&a=del', {id:id}, function(result){
			data = jQuery.parseJSON(result); 
			if(data.error == '0'){
				$.alert('删除成功');  
				type_id = $this.attr('data-type');
				get_album_list(type_id);
			}else{
				$.alert(data.msg); 
			} 
		}); 
	});
	$(document).on('click','a.del_all',function(e){
		if(!confirm("确定要删除吗？")) { 
			if(window.event){
				window.event.returnValue = false;
			}else{  
				event.preventDefault();	//for firefox
			}
		}else{
			var str=""; 
			$("input[name='ck_img']:checked").each(function(){ 
				str+=$(this).val()+','; 
			});
			ck_id = str.substring(0,str.length-1);
			if(str){ 
				$.post('member.php?m=album&a=ajax_del', {'ck_id':ck_id},function(result){
					data = jQuery.parseJSON(result); 
					if(data.error == '0'){
						$.alert('删除成功'); 
						now_type = $("#atree_ck").val(); 
						get_album_list(now_type);
					}else{
						$.alert(data.msg);
					}
				});
			}else{
				$.alert('没有选中图片');
			}	
		} 
	}); 
	
	
	
	
	
}); 


</script>