mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 19:30:07 +00:00 
			
		
		
		
	some refactoring and bugfixes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									c1575f69c4
								
							
						
					
					
						commit
						cbc22e98ad
					
				| @ -53,8 +53,8 @@ function getBookmarkedGIDBefore(gid){ | ||||
| 
 | ||||
| /*********************************************************************/ | ||||
| 
 | ||||
| function cropBookmarkedImages(cmp, keep_ribbons, no_cleanout_marks){ | ||||
| 	cropDataTo(BOOKMARKS.slice(), keep_ribbons, no_cleanout_marks) | ||||
| function cropBookmarkedImages(cmp, keep_ribbons, keep_unloaded_gids){ | ||||
| 	cropDataTo(BOOKMARKS.slice(), keep_ribbons, keep_unloaded_gids) | ||||
| 
 | ||||
| 	return DATA | ||||
| } | ||||
|  | ||||
| @ -251,9 +251,7 @@ if(window.CEF_dumpJSON != null){ | ||||
| 							// add the preview to the image object...
 | ||||
| 							img.preview[size+'px'] = './' + CACHE_DIR +'/'+ preview_path.split(CACHE_DIR).pop() | ||||
| 							// mark image dirty...
 | ||||
| 							if(IMAGES_UPDATED.indexOf(gid) < 0){ | ||||
| 								IMAGES_UPDATED.push(gid) | ||||
| 							} | ||||
| 							imageUpdated(gid) | ||||
| 						} | ||||
| 						//console.log('>>> Preview:', name, '('+size+'): Exists.')
 | ||||
| 						deferred.notify(gid, size, 'exists') | ||||
| @ -324,9 +322,7 @@ if(window.CEF_dumpJSON != null){ | ||||
| 								} | ||||
| 								img.preview[size+'px'] = './' + CACHE_DIR +'/'+ preview_path.split(CACHE_DIR).pop() | ||||
| 								// mark image dirty...
 | ||||
| 								if(IMAGES_UPDATED.indexOf(gid) < 0){ | ||||
| 									IMAGES_UPDATED.push(gid) | ||||
| 								} | ||||
| 								imageUpdated(gid) | ||||
| 								// we are done...
 | ||||
| 								deferred.resolve() | ||||
| 							} | ||||
|  | ||||
							
								
								
									
										10
									
								
								ui/data.js
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								ui/data.js
									
									
									
									
									
								
							| @ -695,6 +695,16 @@ function orientationExif2ImageGrid(orientation){ | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| // mark an image as updated...
 | ||||
| //
 | ||||
| function imageUpdated(gid){ | ||||
| 	gid = gid == null ? getImageGID(): gid | ||||
| 	if(IMAGES_UPDATED.indexOf(gid) == -1){ | ||||
| 		IMAGES_UPDATED.push(gid) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /********************************************************************** | ||||
| * Constructors and general data manipulation | ||||
|  | ||||
							
								
								
									
										11
									
								
								ui/files.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								ui/files.js
									
									
									
									
									
								
							| @ -753,9 +753,8 @@ function readImageOrientation(gid, no_update_loaded){ | ||||
| 			img.flipped = o.flipped | ||||
| 
 | ||||
| 			// mark image dirty...
 | ||||
| 			if((o_o != o.orientation || o_f != o.flipped )  | ||||
| 					&& IMAGES_UPDATED.indexOf(gid) < 0){ | ||||
| 				IMAGES_UPDATED.push(gid) | ||||
| 			if(o_o != o.orientation || o_f != o.flipped){ | ||||
| 				imageUpdated(gid) | ||||
| 			} | ||||
| 
 | ||||
| 			// update image if loaded...
 | ||||
| @ -811,7 +810,7 @@ function readImagesDates(images){ | ||||
| 	return $.when.apply(null, $.map(images, function(_, gid){ | ||||
| 		return readImageDate(gid, images) | ||||
| 			.done(function(){ | ||||
| 				IMAGES_UPDATED.push(gid) | ||||
| 				imageUpdated(gid) | ||||
| 			}) | ||||
| 	})) | ||||
| } | ||||
| @ -823,7 +822,7 @@ function readImagesDatesQ(images){ | ||||
| 	$.each(images, function(gid, img){ | ||||
| 		queue.enqueue(readImageDate, gid, images) | ||||
| 			.always(function(){  | ||||
| 				IMAGES_UPDATED.push(gid) | ||||
| 				imageUpdated(gid) | ||||
| 				queue.notify(gid, 'done')  | ||||
| 			}) | ||||
| 	}) | ||||
| @ -844,7 +843,7 @@ function updateImageGID(gid, images, data){ | ||||
| 			// images...
 | ||||
| 			images[gid] = images[key] | ||||
| 			delete images[key] | ||||
| 			IMAGES_UPDATED.push(gid) | ||||
| 			imageUpdated(gid) | ||||
| 
 | ||||
| 			// data...
 | ||||
| 			if(data != null){ | ||||
|  | ||||
| @ -144,12 +144,11 @@ var updateSelectedImageMark = makeMarkUpdater( | ||||
| // NOTE: MARKED may contain both gids that are not loaded and that do 
 | ||||
| // 		not exist, as there is no way to distinguish between the two 
 | ||||
| // 		situations the cleanup is optional...
 | ||||
| function cropMarkedImages(cmp, keep_ribbons, no_cleanout_marks){ | ||||
| function cropMarkedImages(cmp, keep_ribbons, keep_unloaded_gids){ | ||||
| 	cmp = cmp == null ? imageOrderCmp : cmp | ||||
| 	var cur = DATA.current | ||||
| 	var marked = MARKED.slice().sort(cmp) | ||||
| 
 | ||||
| 	cropDataTo(marked, keep_ribbons, no_cleanout_marks) | ||||
| 	cropDataTo(marked, keep_ribbons, keep_unloaded_gids) | ||||
| 
 | ||||
| 	return DATA | ||||
| } | ||||
|  | ||||
							
								
								
									
										12
									
								
								ui/setup.js
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								ui/setup.js
									
									
									
									
									
								
							| @ -290,9 +290,7 @@ function setupDataBindings(viewer){ | ||||
| 				// change the image orientation status and add to 
 | ||||
| 				// updated list...
 | ||||
| 				IMAGES[gid].orientation = orientation | ||||
| 				if(IMAGES_UPDATED.indexOf(gid) == -1){ | ||||
| 					IMAGES_UPDATED.push(gid) | ||||
| 				} | ||||
| 				imageUpdated(gid) | ||||
| 			}) | ||||
| 		}) | ||||
| 		.on('flippingVertical flippingHorizontal', function(evt, image){ | ||||
| @ -302,9 +300,7 @@ function setupDataBindings(viewer){ | ||||
| 				var flip = getImageFlipState(img) | ||||
| 
 | ||||
| 				IMAGES[gid].flipped = flip | ||||
| 				if(IMAGES_UPDATED.indexOf(gid) == -1){ | ||||
| 					IMAGES_UPDATED.push(gid) | ||||
| 				} | ||||
| 				imageUpdated(gid) | ||||
| 			}) | ||||
| 		}) | ||||
| 		.on('resetToOriginalImage', function(evt, image){ | ||||
| @ -315,9 +311,7 @@ function setupDataBindings(viewer){ | ||||
| 				IMAGES[gid].flipped = null | ||||
| 				IMAGES[gid].orientation = 0 | ||||
| 
 | ||||
| 				if(IMAGES_UPDATED.indexOf(gid) == -1){ | ||||
| 					IMAGES_UPDATED.push(gid) | ||||
| 				} | ||||
| 				imageUpdated(gid) | ||||
| 			}) | ||||
| 		}) | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										57
									
								
								ui/tags.js
									
									
									
									
									
								
							
							
						
						
									
										57
									
								
								ui/tags.js
									
									
									
									
									
								
							| @ -10,9 +10,7 @@ | ||||
| // 		...
 | ||||
| // 	}
 | ||||
| //
 | ||||
| TAGS = { | ||||
| 
 | ||||
| } | ||||
| var TAGS = {} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @ -72,8 +70,8 @@ function addTag(tags, gid, tagset, images){ | ||||
| 			set = [] | ||||
| 			tagset[tag] = set | ||||
| 		} | ||||
| 		if(set.indexOf(tag) < 0){ | ||||
| 			set.push(tag) | ||||
| 		if(set.indexOf(gid) < 0){ | ||||
| 			set.push(gid) | ||||
| 			set.sort() | ||||
| 		} | ||||
| 
 | ||||
| @ -84,8 +82,7 @@ function addTag(tags, gid, tagset, images){ | ||||
| 
 | ||||
| 	if(updated){ | ||||
| 		img.tags = img_tags | ||||
| 		// XXX hardcoded and not customizable...
 | ||||
| 		IMAGES_UPDATED.push(gid) | ||||
| 		imageUpdated(gid) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| @ -121,8 +118,7 @@ function removeTag(tags, gid, tagset, images){ | ||||
| 	} | ||||
| 
 | ||||
| 	if(updated){ | ||||
| 		// XXX hardcoded and not customizable...
 | ||||
| 		IMAGES_UPDATED.push(gid) | ||||
| 		imageUpdated(gid) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| @ -203,6 +199,49 @@ function getRelatedTags(){ | ||||
| } | ||||
| */ | ||||
| 
 | ||||
| /*********************************************************************/ | ||||
| 
 | ||||
| function tagMarked(tags){ | ||||
| 	MARKED.forEach(function(gid){ | ||||
| 		addTag(tags, gid) | ||||
| 	}) | ||||
| 	return MARKED | ||||
| } | ||||
| function untagMarked(tags){ | ||||
| 	MARKED.forEach(function(gid){ | ||||
| 		removeTag(tags, gid) | ||||
| 	}) | ||||
| 	return MARKED | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| function markTagged(tags){ | ||||
| 	MARKED = selectByTags(tags) | ||||
| 	updateImages() | ||||
| 	return MARKED | ||||
| } | ||||
| function unmarkTagged(tags){ | ||||
| 	var set = selectByTags(tags) | ||||
| 	set.forEach(function(gid){ | ||||
| 		var i = MARKED.indexOf(gid) | ||||
| 		if(i > -1){ | ||||
| 			MARKED.splice(i, 1) | ||||
| 		} | ||||
| 	}) | ||||
| 	updateImages() | ||||
| 	return set | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| function cropTagged(tags, cmp, keep_ribbons, keep_unloaded_gids){ | ||||
| 	cmp = cmp == null ? imageOrderCmp : cmp | ||||
| 	var set = selectByTags(tags).sort(cmp) | ||||
| 
 | ||||
| 	cropDataTo(set, keep_ribbons, keep_unloaded_gids) | ||||
| 
 | ||||
| 	return DATA | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /********************************************************************** | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user