//分页
var page_card=new ots_page();
page_card.url='/file/card_list';
page_card.pagesBtn='[data-page]';
jQuery(document).on('click','.card_next',function () {
	scope.first=true;
    page_card.next();          
})
jQuery(document).on('click','.card_prev',function () {
	scope.first=true;
    page_card.prev();
})
jQuery(document).on('click','.card_list_show',function () {
	jQuery('.btn_card_del_more').html(jQuery('.btn_card_del_more').html().replace('...',''));
	jQuery('.btn_card_del_all').html(jQuery('.btn_card_del_all').html().replace('...',''));
	scope.first=true;
    var the=jQuery(this);
    var file_id=the.attr('data-file_id');
    scope.card_file_id=file_id;
    page_card.npks=[];
    page_card.spks=[];
    page_card.post={file_id:file_id};
    page_card.pageGroup=0;
	page_card.first();
	page_card.callback_pageshow=function (data) {
		scope.card_list=data.data;
		scope.card_pages=data.pages;
		scope.card_pageGroup=data.pageGroup;
		scope.card_npk=data.npk;
		scope.$apply();
		if (scope.first) {
			jQuery('[data-page]').eq(0).addClass('current');
		}
	};
	jQuery("#modal_card_list").modal();
})
jQuery("#modal_card_list").on('close.modal.amui',function () {
    folder();	
});
jQuery(document).on('click',page_card.pagesBtn,function () {
    scope.first=false;
    var the=jQuery(this);
    the.siblings('li').removeClass('current');
    the.addClass('current');
});
jQuery(document).on('click','.btn_card_del',function () {
    var the=jQuery(this);
    the.closest('tr').remove();
    jQuery.ajax({
    	url:"/file/card_del",
        data:{
        	card_id:the.attr('data-id')
        },
        dataType: "json",
        type: "post",
        timeout: 10000,
        success: function(data) {
        },
        error: function() {
        }
    });
})
jQuery(document).on('click','#card_select_all',function () {
	var the=jQuery(this);
	if (the.prop('checked')) {
		jQuery('.card_select').prop('checked',true);         
	}else{
		jQuery('.card_select').prop('checked',false);         
	}
})
jQuery(document).on('click','.btn_card_del_more',function () {
	var the=jQuery(this);
	if (the.html().indexOf('...')!=-1) {
		return false;
	}
	the.html(the.html()+'...');
	jQuery.ajax({
    	url:"/file/card_del",
        data:jQuery("form.card_list_from").serializeArray(),
        dataType: "json",
        type: "post",
        timeout: 10000,
        success: function(data) {
        	the.html(the.html().replace('...',''));
        	page_card.first();
        	jQuery("#card_select_all").prop('checked',false);
        },
        error: function() {
        }
    });          
})
jQuery(document).on('click','.btn_card_del_all',function () {
	var the=jQuery(this);
	if (the.html().indexOf('...')!=-1) {
		return false;
	}
	the.html(the.html()+'...');
	var file_id=the.attr('data-file_id');
	jQuery.ajax({
    	url:"/file/card_del_all",
        data:{
        	file_id:file_id
        },
        dataType: "json",
        type: "post",
        timeout: 10000,
        success: function(data) {
        	the.html(the.html().replace('...',''));
        	jQuery("#card_select_all").prop('checked',false);
        	jQuery("#modal_card_list").modal('close');
        },
        error: function() {
        }
    }); 
})
