mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 19:30:07 +00:00 
			
		
		
		
	more tweaking of the crop api in connection with saving and loading data...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									af69c5489d
								
							
						
					
					
						commit
						5e7fafd9c5
					
				
							
								
								
									
										23
									
								
								ui/data.js
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								ui/data.js
									
									
									
									
									
								
							| @ -1157,7 +1157,7 @@ function getPrevLocation(){ | ||||
| /******************************************************* Crop Data ***/ | ||||
| 
 | ||||
| function isViewCropped(){ | ||||
| 	return !(CROP_STACK.length == 0) | ||||
| 	return CROP_STACK.length != 0 | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| @ -1170,10 +1170,9 @@ function getAllData(){ | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| // XXX make keep_ribbons option work...
 | ||||
| // NOTE: this will not update .current state...
 | ||||
| // XXX should this set the .current to anything but null or the first elem???
 | ||||
| function makeCroppedData(gids, keep_ribbons){ | ||||
| 	var cur = DATA.current | ||||
| 	var old_data = DATA | ||||
| 	var res = { | ||||
| 		varsion: '2.0', | ||||
| 		current: null, | ||||
| @ -1196,20 +1195,21 @@ function makeCroppedData(gids, keep_ribbons){ | ||||
| 		}) | ||||
| 	} | ||||
| 
 | ||||
| 	cur = getGIDBefore(cur, 0) | ||||
| 	cur = cur == null ? gids[0] : cur | ||||
| 	res.current = cur  | ||||
| 
 | ||||
| 	return res | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| function cropDataTo(gids, keep_ribbons){ | ||||
| 	var prev_state = DATA | ||||
| 	var cur = DATA.current | ||||
| 
 | ||||
| 	CROP_STACK.push(prev_state) | ||||
| 	DATA = makeCroppedData(gids, keep_ribbons) | ||||
| 
 | ||||
| 	cur = getGIDBefore(cur) | ||||
| 	cur = cur == null ? gids[0] : cur | ||||
| 	DATA.current = cur  | ||||
| 
 | ||||
| 	reloadViewer() | ||||
| 	updateImages() | ||||
| 
 | ||||
| @ -1242,10 +1242,17 @@ function uncropData(){ | ||||
| 
 | ||||
| function showAllData(){ | ||||
| 	var prev_state = DATA | ||||
| 	var cur = DATA.current | ||||
| 
 | ||||
| 	DATA = getAllData() | ||||
| 	CROP_STACK = [] | ||||
| 
 | ||||
| 	// XXX do we need to check if this exists???
 | ||||
| 	// 		...in theory, as long as there are no global destructive 
 | ||||
| 	// 		operations, no.
 | ||||
| 	// keep the current position...
 | ||||
| 	DATA.current = cur | ||||
| 
 | ||||
| 	reloadViewer() | ||||
| 	updateImages() | ||||
| 
 | ||||
|  | ||||
| @ -438,7 +438,10 @@ function saveFileState(name, no_normalize_path){ | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	dumpJSON(name + '-data.json', getAllData()) | ||||
| 	var data = getAllData() | ||||
| 	data.current = DATA.current | ||||
| 
 | ||||
| 	dumpJSON(name + '-data.json', data) | ||||
| 	// XXX do we need to do this???
 | ||||
| 	saveFileMarks(name) | ||||
| 
 | ||||
|  | ||||
| @ -48,7 +48,11 @@ function loadLocalStorageData(attr){ | ||||
| } | ||||
| function saveLocalStorageData(attr){ | ||||
| 	attr = attr == null ? DATA_ATTR : attr | ||||
| 	localStorage[attr] = JSON.stringify(getAllData()) | ||||
| 
 | ||||
| 	var data = getAllData() | ||||
| 	data.current = DATA.current | ||||
| 
 | ||||
| 	localStorage[attr] = JSON.stringify(data) | ||||
| 	saveLocalStorageBaseURL(attr) | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user