gbcollection.js 1.92 KB
$(function(){

	if($("#data-gbcollection-tmpl").length){

		var page_index = 0,
			offset = 10,
			start = 0,
			collection_usertagid=90601;
		
		$('#showmorecollection').click(function(e){
			$(this).val("加载中...");
			$('#showmoreloading').fadeIn();
			start = page_index * offset;
			
			$('.loading').removeClass('hidden');
							
			identityService.findAllPostByUserTagID({utid:collection_usertagid,start:start,offset:offset},{
				callback:function(gbresults){	
					var template = Handlebars.compile($("#data-gbcollection-tmpl").html()), 
					        	gbcollection = template(gbresults);
					        	
					$('#collectionlist').append(gbcollection);
					
			        page_index++;	
					
					if(gbresults.length===0){
						$('#showmorecollection').addClass('hidden');
					}		
					
					$('.loading').addClass('hidden');			
				}
			});	 
	        

			e.preventDefault();
		});
		
		$('#showmorecollection').trigger('click');

	}
	
	if($("#data-gbevents-tmpl").length){

		var page_index = 0,
			offset = 10,
			start = 0,
			collection_usertagid=151331;
		
		$('#showmorecollection').click(function(e){
			$(this).val("加载中...");
			$('#showmoreloading').fadeIn();
			start = page_index * offset;
			
			$('.loading').removeClass('hidden');
							
			identityService.findAllPostByUserTagID({utid:collection_usertagid,start:start,offset:offset},{
				callback:function(gbresults){	
					var template = Handlebars.compile($("#data-gbevents-tmpl").html()), 
					        	gbcollection = template(gbresults);
					        	
					$('#collectionlist').append(gbcollection);
					
			        page_index++;	
					
					if(gbresults.length===0){
						$('#showmorecollection').addClass('hidden');
					}		
					
					$('.loading').addClass('hidden');			
				}
			});	 
	        

			e.preventDefault();
		});
		
		$('#showmorecollection').trigger('click');

	}
	
});