mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	more cleaning...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									8ffb7f49ea
								
							
						
					
					
						commit
						2c684e6640
					
				
							
								
								
									
										15
									
								
								ui/base.js
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								ui/base.js
									
									
									
									
									
								
							| @ -109,8 +109,11 @@ function getImageGID(image){ | |||||||
| 
 | 
 | ||||||
| // Calculate relative position between two elements
 | // Calculate relative position between two elements
 | ||||||
| //
 | //
 | ||||||
| // ...tried to make this as brain-dead-stupidly-simple as possible...
 | // NOTE: tried to make this as brain-dead-stupidly-simple as possible...
 | ||||||
| //		...looks spectacular comparing to either gen2 or gen1 ;)
 | //		...looks spectacular comparing to either gen2 or gen1 ;)
 | ||||||
|  | // NOTE: if used during an animation/transition this will give the 
 | ||||||
|  | // 		position at the exact frame of the animation, this might not be
 | ||||||
|  | // 		the desired "final" data...
 | ||||||
| function getRelativeVisualPosition(outer, inner){ | function getRelativeVisualPosition(outer, inner){ | ||||||
| 	outer = $(outer).offset() | 	outer = $(outer).offset() | ||||||
| 	inner = $(inner).offset() | 	inner = $(inner).offset() | ||||||
| @ -177,7 +180,7 @@ function shiftTo(image, ribbon){ | |||||||
| 	// if removing last image out of a ribbon, remove the ribbon....
 | 	// if removing last image out of a ribbon, remove the ribbon....
 | ||||||
| 	if(cur_ribbon.find('.image').length == 0){ | 	if(cur_ribbon.find('.image').length == 0){ | ||||||
| 		// XXX check if the ribbon outside the loaded area is empty...
 | 		// XXX check if the ribbon outside the loaded area is empty...
 | ||||||
| 		// 		...do we need this check? it might be interresting to
 | 		// 		...do we need this check? it might be interesting to
 | ||||||
| 		// 		"collapse" disjoint, empty areas...
 | 		// 		"collapse" disjoint, empty areas...
 | ||||||
| 		// 		......if so, will also need to do this in DATA...
 | 		// 		......if so, will also need to do this in DATA...
 | ||||||
| 		removeRibbon(cur_ribbon) | 		removeRibbon(cur_ribbon) | ||||||
| @ -188,12 +191,7 @@ function shiftTo(image, ribbon){ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| function shiftImage(direction, image, force_create_ribbon){ | function shiftImage(direction, image, force_create_ribbon){ | ||||||
| 	if(image == null){ | 	image = image == null ? $('.current.image') : $(image) | ||||||
| 		// XXX need to make this context specific...
 |  | ||||||
| 		image = $('.current.image') |  | ||||||
| 	} else { |  | ||||||
| 		image = $(image) |  | ||||||
| 	} |  | ||||||
| 	var old_ribbon = getRibbon(image) | 	var old_ribbon = getRibbon(image) | ||||||
| 	var ribbon = old_ribbon[direction]('.ribbon') | 	var ribbon = old_ribbon[direction]('.ribbon') | ||||||
| 
 | 
 | ||||||
| @ -222,6 +220,7 @@ function shiftImage(direction, image, force_create_ribbon){ | |||||||
| // NOTE: this will not attach the created images.
 | // NOTE: this will not attach the created images.
 | ||||||
| function createImage(n, force_create_new){ | function createImage(n, force_create_new){ | ||||||
| 	if(n == null){ | 	if(n == null){ | ||||||
|  | 		// XXX do we need this?
 | ||||||
| 		if(window._n == null){ | 		if(window._n == null){ | ||||||
| 			window._n = 0 | 			window._n = 0 | ||||||
| 		} | 		} | ||||||
|  | |||||||
							
								
								
									
										19
									
								
								ui/data.js
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								ui/data.js
									
									
									
									
									
								
							| @ -1,6 +1,7 @@ | |||||||
| /********************************************************************** | /********************************************************************** | ||||||
| *  | *  | ||||||
| * | * | ||||||
|  | * TODO move DATA to a more logical context avoiding the global vars... | ||||||
| * | * | ||||||
| **********************************************************************/ | **********************************************************************/ | ||||||
| 
 | 
 | ||||||
| @ -23,7 +24,6 @@ var STUB_IMAGE_DATA = { | |||||||
| 	classes: '', | 	classes: '', | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // XXX STUB
 |  | ||||||
| // Data format...
 | // Data format...
 | ||||||
| var DATA = { | var DATA = { | ||||||
| 	varsion: '2.0', | 	varsion: '2.0', | ||||||
| @ -207,7 +207,6 @@ function getImageGIDs(from, count, ribbon, inclusive){ | |||||||
| 		var start = ribbon.indexOf(from) + c | 		var start = ribbon.indexOf(from) + c | ||||||
| 		return ribbon.slice(start, start + count) | 		return ribbon.slice(start, start + count) | ||||||
| 	} else { | 	} else { | ||||||
| 		// XXX
 |  | ||||||
| 		var c = inclusive == null ? 0 : 1 | 		var c = inclusive == null ? 0 : 1 | ||||||
| 		var end = ribbon.indexOf(from) | 		var end = ribbon.indexOf(from) | ||||||
| 		return ribbon.slice((Math.abs(count) >= end ? 0 : end + count + c), end + c) | 		return ribbon.slice((Math.abs(count) >= end ? 0 : end + count + c), end + c) | ||||||
| @ -341,22 +340,18 @@ function loadImages(ref_gid, count, ribbon){ | |||||||
| 
 | 
 | ||||||
| 	var size = getVisibleImageSize() | 	var size = getVisibleImageSize() | ||||||
| 
 | 
 | ||||||
| 	// XXX the next section might need some simplification -- fells bulky...
 | 	// XXX the next section might need some simplification -- feels bulky...
 | ||||||
| 	// check if we have a common section at all / full reload...
 | 	// check if we have a common section at all / full reload...
 | ||||||
| 	if(head == 0 && tail == 0){ | 	if(head == 0 && tail == 0){ | ||||||
| 		if(gids.indexOf(old_gids[0]) == -1){ | 		if(gids.indexOf(old_gids[0]) == -1){ | ||||||
| 			window.DEBUG && console.log('>>> (ribbon:', ribbon_i, ') FULL RELOAD --', gids.length) | 			window.DEBUG && console.log('>>> (ribbon:', ribbon_i, ') FULL RELOAD --', gids.length) | ||||||
| 			// XXX do we need to think about alining here???
 |  | ||||||
| 			extendRibbon(0, gids.length - old_gids.length, ribbon) | 			extendRibbon(0, gids.length - old_gids.length, ribbon) | ||||||
| 
 |  | ||||||
| 			var images = ribbon | 			var images = ribbon | ||||||
| 				.find('.image') | 				.find('.image') | ||||||
| 					.each(function(i, e){ | 					.each(function(i, e){ | ||||||
| 						updateImage(e, gids[i], size) | 						updateImage(e, gids[i], size) | ||||||
| 					}) | 					}) | ||||||
| 
 |  | ||||||
| 			$('.viewer').trigger('reloadedRibbon', [ribbon]) | 			$('.viewer').trigger('reloadedRibbon', [ribbon]) | ||||||
| 
 |  | ||||||
| 			return images | 			return images | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -383,9 +378,7 @@ function loadImages(ref_gid, count, ribbon){ | |||||||
| 		res.right.each(function(i, e){ | 		res.right.each(function(i, e){ | ||||||
| 			updateImage(e, gids[i + gids.length - tail], size) | 			updateImage(e, gids[i + gids.length - tail], size) | ||||||
| 		}) | 		}) | ||||||
| 
 |  | ||||||
| 		$('.viewer').trigger('updatedRibbon', [ribbon]) | 		$('.viewer').trigger('updatedRibbon', [ribbon]) | ||||||
| 
 |  | ||||||
| 		return ribbon.find('.image') | 		return ribbon.find('.image') | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @ -520,6 +513,7 @@ function loadLocalStorage(attr){ | |||||||
| 	return loadData(JSON.parse(localStorage[attr])) | 	return loadData(JSON.parse(localStorage[attr])) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| function saveLocalStorage(attr){ | function saveLocalStorage(attr){ | ||||||
| 	attr = attr == null ? 'DATA' : attr | 	attr = attr == null ? 'DATA' : attr | ||||||
| 	localStorage[attr] = JSON.stringify(DATA) | 	localStorage[attr] = JSON.stringify(DATA) | ||||||
| @ -527,7 +521,6 @@ function saveLocalStorage(attr){ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| /********************************************************************** | /********************************************************************** | ||||||
| * Image caching... | * Image caching... | ||||||
| */ | */ | ||||||
| @ -556,6 +549,7 @@ function preCacheRibbonImages(ribbon){ | |||||||
| 	return cache | 	return cache | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| function preCacheAllRibbons(){ | function preCacheAllRibbons(){ | ||||||
| 	$('.ribbon').each(function(){ | 	$('.ribbon').each(function(){ | ||||||
| 		preCacheRibbonImages($(this)) | 		preCacheRibbonImages($(this)) | ||||||
| @ -565,7 +559,6 @@ function preCacheAllRibbons(){ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| /********************************************************************** | /********************************************************************** | ||||||
| * Setup | * Setup | ||||||
| */ | */ | ||||||
| @ -582,8 +575,6 @@ function preCacheAllRibbons(){ | |||||||
| // 		- shifting (expand/contract)
 | // 		- shifting (expand/contract)
 | ||||||
| // 		- zooming (expand/contract)
 | // 		- zooming (expand/contract)
 | ||||||
| //
 | //
 | ||||||
| //
 |  | ||||||
| // XXX this is causing lots of errors, rethink...
 |  | ||||||
| function setupDataBindings(viewer){ | function setupDataBindings(viewer){ | ||||||
| 	viewer = viewer == null ? $('.viewer') : viewer | 	viewer = viewer == null ? $('.viewer') : viewer | ||||||
| 	viewer | 	viewer | ||||||
| @ -619,8 +610,6 @@ function setupDataBindings(viewer){ | |||||||
| 
 | 
 | ||||||
| 			// NOTE: if this is greater than the number of images currently 
 | 			// NOTE: if this is greater than the number of images currently 
 | ||||||
| 			//		loaded, it might lead to odd effects...
 | 			//		loaded, it might lead to odd effects...
 | ||||||
| 			//		XXX need to load additional images and keep track of the 
 |  | ||||||
| 			//			loaded chunk size...
 |  | ||||||
| 			var frame_size = (screen_size * LOAD_SCREENS) / 2 | 			var frame_size = (screen_size * LOAD_SCREENS) / 2 | ||||||
| 			var threshold = screen_size * LOAD_THRESHOLD | 			var threshold = screen_size * LOAD_THRESHOLD | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user