mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-11-01 03:40:09 +00:00 
			
		
		
		
	added mark-based shifting up/down...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									e7ea183597
								
							
						
					
					
						commit
						c6257a335a
					
				
							
								
								
									
										77
									
								
								ui/data.js
									
									
									
									
									
								
							
							
						
						
									
										77
									
								
								ui/data.js
									
									
									
									
									
								
							| @ -1433,7 +1433,7 @@ function sortImagesByName(reverse){ | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // shifting images...
 | // Ordering images...
 | ||||||
| // NOTE: this a bit more complicated than simply shifting an image 
 | // NOTE: this a bit more complicated than simply shifting an image 
 | ||||||
| // 		left/right the DATA.order, we have to put it before or after
 | // 		left/right the DATA.order, we have to put it before or after
 | ||||||
| // 		the prev/next image...
 | // 		the prev/next image...
 | ||||||
| @ -1481,6 +1481,81 @@ function shiftImageRight(image){ | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | // XXX move to marks.js
 | ||||||
|  | 
 | ||||||
|  | // XXX need to account for empty ribbons...
 | ||||||
|  | function shiftMarkedImages(direction, mode, new_ribbon){ | ||||||
|  | 	mode = mode == null ? 'ribbon' : mode | ||||||
|  | 	var cur = getRibbonIndex() | ||||||
|  | 
 | ||||||
|  | 	// ribbon only...
 | ||||||
|  | 	if(mode == 'ribbon'){ | ||||||
|  | 		var ribbon = DATA.ribbons[cur] | ||||||
|  | 		// remove all the marked images form current ribbon...
 | ||||||
|  | 		var marked = $.map(MARKED, function(e){ | ||||||
|  | 			var i = ribbon.indexOf(e) | ||||||
|  | 			if(i >= 0){ | ||||||
|  | 				ribbon.splice(i, 1) | ||||||
|  | 				return e | ||||||
|  | 			} | ||||||
|  | 			return null | ||||||
|  | 		}) | ||||||
|  | 
 | ||||||
|  | 	// shift all marked images...
 | ||||||
|  | 	} else { | ||||||
|  | 		var marked = MARKED.slice() | ||||||
|  | 		// remove all the marked images form all the ribbons...
 | ||||||
|  | 		$.each(DATA.ribbons, function(ribbon){ | ||||||
|  | 			$.each(marked, function(e){ | ||||||
|  | 				var i = ribbon.indexOf(e) | ||||||
|  | 				i >= 0 ? ribbon.splice(i, 1) : null | ||||||
|  | 			}) | ||||||
|  | 		}) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	// if we are at the top or bottom ribbons we need to create a new 
 | ||||||
|  | 	// ribbon regardless...
 | ||||||
|  | 	if((cur == 0 && direction == 'prev')  | ||||||
|  | 			|| (cur == DATA.ribbons.length-1 && direction == 'next')){ | ||||||
|  | 		new_ribbon = true | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	// add marked to new ribbon...
 | ||||||
|  | 	if(new_ribbon){ | ||||||
|  | 		cur += direction == 'next' ? 1 : 0 | ||||||
|  | 		DATA.ribbons.splice(cur, 0, marked) | ||||||
|  | 	 | ||||||
|  | 	// add marked to existing ribbon...
 | ||||||
|  | 	} else { | ||||||
|  | 		cur += direction == 'next' ? 1 : -1 | ||||||
|  | 		DATA.ribbons[cur] = DATA.ribbons[cur].concat(marked).sort(cmp) | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	// remove empty ribbons...
 | ||||||
|  | 	DATA.ribbons = DATA.ribbons.filter(function(e){ return e.length > 0 ? true : false }) | ||||||
|  | 
 | ||||||
|  | 	updateRibbonOrder() | ||||||
|  | } | ||||||
|  | function shiftMarkedImagesUp(mode, new_ribbon){ | ||||||
|  | 	return shiftMarkedImages('prev', mode, new_ribbon) | ||||||
|  | } | ||||||
|  | function shiftMarkedImagesDown(mode, new_ribbon){ | ||||||
|  | 	return shiftMarkedImages('next', mode, new_ribbon) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | // XXX these are ribbon wise only (???)
 | ||||||
|  | // XXX this on first step this must pack all marked images
 | ||||||
|  | function horizontalShiftMarkedImages(direction){ | ||||||
|  | } | ||||||
|  | function shiftMarkedImagesLeft(){ | ||||||
|  | 	return shiftMarkedImages('prev') | ||||||
|  | } | ||||||
|  | function shiftMarkedImagesRight(){ | ||||||
|  | 	return shiftMarkedImages('next') | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| /********************************************************************** | /********************************************************************** | ||||||
| * vim:set ts=4 sw=4 spell :                                          */ | * vim:set ts=4 sw=4 spell :                                          */ | ||||||
|  | |||||||
| @ -305,11 +305,10 @@ var KEYBOARD_CONFIG = { | |||||||
| 						shiftImageUpNewRibbon(null, DIRECTION)  | 						shiftImageUpNewRibbon(null, DIRECTION)  | ||||||
| 						centerRibbons() | 						centerRibbons() | ||||||
| 					}), | 					}), | ||||||
| 
 |  | ||||||
| 				// XXX
 |  | ||||||
| 				alt: doc('Shift marked images up', | 				alt: doc('Shift marked images up', | ||||||
| 					function(){ | 					function(){ | ||||||
| 						// XXX
 | 						toggleMarkesView('on') | ||||||
|  | 						shiftMarkedImagesUp() | ||||||
| 					}), | 					}), | ||||||
| 				'alt+shift': doc('Shift marked images up to empty ribbon', | 				'alt+shift': doc('Shift marked images up to empty ribbon', | ||||||
| 					function(){ | 					function(){ | ||||||
| @ -335,11 +334,10 @@ var KEYBOARD_CONFIG = { | |||||||
| 						shiftImageDownNewRibbon(null, DIRECTION)  | 						shiftImageDownNewRibbon(null, DIRECTION)  | ||||||
| 						centerRibbons() | 						centerRibbons() | ||||||
| 					}), | 					}), | ||||||
| 
 |  | ||||||
| 				// XXX
 |  | ||||||
| 				alt: doc('Shift marked images down', | 				alt: doc('Shift marked images down', | ||||||
| 					function(){ | 					function(){ | ||||||
| 						// XXX
 | 						toggleMarkesView('on') | ||||||
|  | 						shiftMarkedImagesDown() | ||||||
| 					}), | 					}), | ||||||
| 				'alt+shift': doc('Shift marked images down to empty ribbon', | 				'alt+shift': doc('Shift marked images down to empty ribbon', | ||||||
| 					function(){ | 					function(){ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user