mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-11-04 05:10:07 +00:00 
			
		
		
		
	some more cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									5788cb1b9b
								
							
						
					
					
						commit
						53066cb8be
					
				
							
								
								
									
										113
									
								
								ui/data.js
									
									
									
									
									
								
							
							
						
						
									
										113
									
								
								ui/data.js
									
									
									
									
									
								
							@ -1470,119 +1470,6 @@ function loadImagesAround(count, gid, ribbon, data){
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
// Load count images around a given image/gid into the given ribbon.
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// NOTE: this will reload the current image elements...
 | 
					 | 
				
			||||||
// NOTE: this is similar to extendRibbon(...) but different in interface...
 | 
					 | 
				
			||||||
// NOTE: load only what is needed instead of reloading everything...
 | 
					 | 
				
			||||||
// NOTE: this will not change alignment if the current image is within 
 | 
					 | 
				
			||||||
// 		the target range...
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// XXX for some magical (unknown) reason this returns BEFORE all the 
 | 
					 | 
				
			||||||
// 		elements this creates actually exist (async)...
 | 
					 | 
				
			||||||
// 		...this causes race conditions...
 | 
					 | 
				
			||||||
function loadImages(ref_gid, count, ribbon){
 | 
					 | 
				
			||||||
	ribbon = $(ribbon)
 | 
					 | 
				
			||||||
	var images = ribbon.find('.image')
 | 
					 | 
				
			||||||
	var ribbon_i = getRibbonIndex(ribbon)
 | 
					 | 
				
			||||||
	var gid = getGIDBefore(ref_gid, ribbon_i)
 | 
					 | 
				
			||||||
	gid = gid == null ? DATA.ribbons[ribbon_i][0] : gid
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// start/end points...
 | 
					 | 
				
			||||||
	var l = DATA.ribbons[ribbon_i].length
 | 
					 | 
				
			||||||
	if(l <= count){
 | 
					 | 
				
			||||||
		var from_i = 0
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		var from_i = DATA.ribbons[ribbon_i].indexOf(gid) - Math.floor(count/2)
 | 
					 | 
				
			||||||
		// special case: head...
 | 
					 | 
				
			||||||
		from_i = from_i < 0 ? 0 : from_i
 | 
					 | 
				
			||||||
		// special case: tail...
 | 
					 | 
				
			||||||
		from_i = l - from_i < count ? l - count : from_i
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	var from_gid = DATA.ribbons[ribbon_i][from_i]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	var old_gids = getImageGIDs(getImageGID(images.first()), images.length, ribbon_i, true)
 | 
					 | 
				
			||||||
	var gids = getImageGIDs(from_gid, count, ribbon_i, true)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// check if heads have a common gid and get the diff length...
 | 
					 | 
				
			||||||
	var i = gids.indexOf(old_gids[0])
 | 
					 | 
				
			||||||
	var j = old_gids.indexOf(gids[0])
 | 
					 | 
				
			||||||
	var head = i != -1 ? i 
 | 
					 | 
				
			||||||
		// check if we need to truncate...
 | 
					 | 
				
			||||||
		: j != -1 ? -j
 | 
					 | 
				
			||||||
		// XXX why is the default zero???
 | 
					 | 
				
			||||||
		: 0
 | 
					 | 
				
			||||||
	// check if tails have a common gid and get the diff length...
 | 
					 | 
				
			||||||
	i = gids.indexOf(old_gids[old_gids.length-1])
 | 
					 | 
				
			||||||
	j = old_gids.indexOf(gids[gids.length-1])
 | 
					 | 
				
			||||||
	var tail = i > 0 ? gids.length - i - 1
 | 
					 | 
				
			||||||
		// check if we need to truncate...
 | 
					 | 
				
			||||||
		: j > 0 ? -(old_gids.length - j - 1)
 | 
					 | 
				
			||||||
		// XXX why is the default zero???
 | 
					 | 
				
			||||||
		: 0
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	var size = getVisibleImageSize('max')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// XXX the next section might need some simplification -- feels bulky...
 | 
					 | 
				
			||||||
	// check if we have a common section at all / full reload...
 | 
					 | 
				
			||||||
	if(head == 0 && tail == 0){
 | 
					 | 
				
			||||||
		if(gids.indexOf(old_gids[0]) == -1){
 | 
					 | 
				
			||||||
			window.DEBUG && console.log('>>> (ribbon:', ribbon_i, ') FULL RELOAD --', gids.length)
 | 
					 | 
				
			||||||
			extendRibbon(0, gids.length - old_gids.length, ribbon)
 | 
					 | 
				
			||||||
			var images = ribbon
 | 
					 | 
				
			||||||
				.find('.image')
 | 
					 | 
				
			||||||
					.each(function(i, e){
 | 
					 | 
				
			||||||
						updateImage(e, gids[i], size)
 | 
					 | 
				
			||||||
					})
 | 
					 | 
				
			||||||
			$('.viewer').trigger('reloadedRibbon', [ribbon])
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// do nothing...
 | 
					 | 
				
			||||||
		// ...the requested section is the same as the one already loaded...
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			window.DEBUG && console.log('>>> (ribbon:', ribbon_i, ') NOTHING TO DO.')
 | 
					 | 
				
			||||||
			return images
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// do a partial reload...
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		window.DEBUG && console.log('>>> (ribbon:', ribbon_i, ')', head, '+-('+ (old_gids.length) +')-+', tail)
 | 
					 | 
				
			||||||
		// NOTE: we do not need to do anything about alignment as 
 | 
					 | 
				
			||||||
		// 		extendRibbon will get the correct head and tail so as to
 | 
					 | 
				
			||||||
		// 		align everything by itself...
 | 
					 | 
				
			||||||
		var res = extendRibbon(head, tail, ribbon)
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		// NOTE: if there was no extension (i.e. head/tail <= 0) then 
 | 
					 | 
				
			||||||
		// 		these will do nothing...
 | 
					 | 
				
			||||||
		res.left.each(function(i, e){
 | 
					 | 
				
			||||||
			updateImage(e, gids[i], size)
 | 
					 | 
				
			||||||
		})
 | 
					 | 
				
			||||||
		res.right.each(function(i, e){
 | 
					 | 
				
			||||||
			updateImage(e, gids[i + gids.length - tail], size)
 | 
					 | 
				
			||||||
		})
 | 
					 | 
				
			||||||
		$('.viewer').trigger('updatedRibbon', [ribbon])
 | 
					 | 
				
			||||||
		images = ribbon.find('.image')
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// XXX is this the right place for this?
 | 
					 | 
				
			||||||
	// XXX this might be too global, do only the images loaded...
 | 
					 | 
				
			||||||
	correctImageProportionsForRotation(images)
 | 
					 | 
				
			||||||
	return images
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
// NOTE: this is here for testing...
 | 
					 | 
				
			||||||
function loadImagesAround(ref_gid, count, ribbon){
 | 
					 | 
				
			||||||
	var ribbon_i = getRibbonIndex(ribbon)
 | 
					 | 
				
			||||||
	var gid = getGIDBefore(ref_gid, ribbon_i)
 | 
					 | 
				
			||||||
	return loadImages(ref_gid, count, ribbon).filter('[gid="'+JSON.stringify(gid)+'"]').click()
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Roll ribbon and load new images in the updated section.
 | 
					// Roll ribbon and load new images in the updated section.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
// NOTE: this is signature-compatible with rollRibbon...
 | 
					// NOTE: this is signature-compatible with rollRibbon...
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user