mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 19:30:07 +00:00 
			
		
		
		
	more work on actions, basic editing and navigation now working...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									06eb2f2f1e
								
							
						
					
					
						commit
						f987acd5c5
					
				| @ -247,12 +247,9 @@ module.DataPrototype = { | |||||||
| 		prefix = prefix == null ? 'G' : prefix | 		prefix = prefix == null ? 'G' : prefix | ||||||
| 		var gid = prefix + Date.now() | 		var gid = prefix + Date.now() | ||||||
| 		while(this.ribbon_order.indexOf(gid) >= 0  | 		while(this.ribbon_order.indexOf(gid) >= 0  | ||||||
| 				|| this.order.indexOf(gid) >= 0 | 				|| this.order.indexOf(gid) >= 0){ | ||||||
| 				|| this._gid_cache.indexOf(gid) >= 0){ |  | ||||||
| 			gid = prefix + Date.now() | 			gid = prefix + Date.now() | ||||||
| 		} | 		} | ||||||
| 		// XXX not sure if this is a good idea...
 |  | ||||||
| 		this._gid_cache.push(gid) |  | ||||||
| 		return gid | 		return gid | ||||||
| 	}, | 	}, | ||||||
| 	 | 	 | ||||||
| @ -1019,28 +1016,42 @@ module.DataPrototype = { | |||||||
| 	//
 | 	//
 | ||||||
| 	// NOTE: shiftImageUp/shiftImageDown will create new ribbons when 
 | 	// NOTE: shiftImageUp/shiftImageDown will create new ribbons when 
 | ||||||
| 	// 		shifting from first/last ribbons respectively.
 | 	// 		shifting from first/last ribbons respectively.
 | ||||||
|  | 	// NOTE: shiftImageUp/shiftImageUp will remove an empty ribbon after
 | ||||||
|  | 	// 		shifting the last image out...
 | ||||||
| 	// NOTE: none of these change .current
 | 	// NOTE: none of these change .current
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// XXX should these be here??
 | 	// XXX should these be here??
 | ||||||
| 	shiftImageLeft: function(gid){ return this.shiftImage(gid, -1, 'offset') }, // Gen2
 | 	shiftImageLeft: function(gid){ return this.shiftImage(gid, -1, 'offset') }, // Gen2
 | ||||||
| 	shiftImageRight: function(gid){ return this.shiftImage(gid, 1, 'offset') }, // Gen2
 | 	shiftImageRight: function(gid){ return this.shiftImage(gid, 1, 'offset') }, // Gen2
 | ||||||
| 	// XXX test...
 |  | ||||||
| 	shiftImageUp: function(gid){  | 	shiftImageUp: function(gid){  | ||||||
| 		var g = gid.constructor.name == 'Array' ? gid[0] : gid | 		var g = gid.constructor.name == 'Array' ? gid[0] : gid | ||||||
|  | 		var r = this.getRibbonOrder(g) | ||||||
| 		// check if we need to create a ribbon here...
 | 		// check if we need to create a ribbon here...
 | ||||||
| 		if(this.getRibbonOrder(g) == 0){ | 		if(r == 0){ | ||||||
| 			this.newRibbon(g) | 			this.newRibbon(g) | ||||||
| 		} | 		} | ||||||
| 		return this.shiftImage(gid, this.getRibbonOrder(g)-1)  | 		var res = this.shiftImage(gid, r-1)  | ||||||
|  | 		// clear empty ribbon...
 | ||||||
|  | 		if(this.ribbons[this.ribbon_order[r]].len() == 0){ | ||||||
|  | 			r = this.ribbon_order.splice(r, 1)[0] | ||||||
|  | 			delete this.ribbons[r] | ||||||
|  | 		} | ||||||
|  | 		return res | ||||||
| 	}, | 	}, | ||||||
| 	// XXX test...
 |  | ||||||
| 	shiftImageDown: function(gid){  | 	shiftImageDown: function(gid){  | ||||||
| 		var g = gid.constructor.name == 'Array' ? gid[0] : gid | 		var g = gid.constructor.name == 'Array' ? gid[0] : gid | ||||||
|  | 		var r = this.getRibbonOrder(g) | ||||||
| 		// check if we need to create a ribbon here...
 | 		// check if we need to create a ribbon here...
 | ||||||
| 		if(this.getRibbonOrder(g) == this.ribbon_order.length-1){ | 		if(r == this.ribbon_order.length-1){ | ||||||
| 			this.newRibbon(g, 'below') | 			this.newRibbon(g, 'below') | ||||||
| 		} | 		} | ||||||
| 		return this.shiftImage(gid, this.getRibbonOrder(g)+1)  | 		var res = this.shiftImage(gid, r+1)  | ||||||
|  | 		// clear empty ribbon...
 | ||||||
|  | 		if(this.ribbons[this.ribbon_order[r]].len() == 0){ | ||||||
|  | 			r = this.ribbon_order.splice(r, 1)[0] | ||||||
|  | 			delete this.ribbons[r] | ||||||
|  | 		} | ||||||
|  | 		return res | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
| 	// Shift ribbon vertically...
 | 	// Shift ribbon vertically...
 | ||||||
| @ -1458,8 +1469,6 @@ module.DataPrototype = { | |||||||
| 		this.ribbon_order = []  | 		this.ribbon_order = []  | ||||||
| 		this.ribbons = {} | 		this.ribbons = {} | ||||||
| 
 | 
 | ||||||
| 		this._gid_cache = [] |  | ||||||
| 
 |  | ||||||
| 		return this | 		return this | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -448,7 +448,13 @@ module.RibbonsPrototype = { | |||||||
| 	//	.placeImage(target, image, 'after')
 | 	//	.placeImage(target, image, 'after')
 | ||||||
| 	//		-> image
 | 	//		-> image
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// NOTE: mode is defaults to 'before'.
 | 	// Place target at ribbon start/end:
 | ||||||
|  | 	//	.placeImage(target, ribbon)
 | ||||||
|  | 	//	.placeImage(target, ribbon, 'before')
 | ||||||
|  | 	//	.placeImage(target, ribbon, 'after')
 | ||||||
|  | 	//		-> image
 | ||||||
|  | 	//
 | ||||||
|  | 	// NOTE: mode defaults to 'before'.
 | ||||||
| 	// NOTE: if image gid does not exist it will be created.
 | 	// NOTE: if image gid does not exist it will be created.
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// XXX interaction animation...
 | 	// XXX interaction animation...
 | ||||||
| @ -458,6 +464,7 @@ module.RibbonsPrototype = { | |||||||
| 		mode = mode == null ? 'before' : mode | 		mode = mode == null ? 'before' : mode | ||||||
| 		var img = this.getImage(target) | 		var img = this.getImage(target) | ||||||
| 		img = img.length == 0 ? this.createImage(target) : img | 		img = img.length == 0 ? this.createImage(target) : img | ||||||
|  | 		var r = this.getRibbon(to) | ||||||
| 
 | 
 | ||||||
| 		// offset on same ribbon...
 | 		// offset on same ribbon...
 | ||||||
| 		if(typeof(to) == typeof(123)){ | 		if(typeof(to) == typeof(123)){ | ||||||
| @ -470,6 +477,19 @@ module.RibbonsPrototype = { | |||||||
| 			to = images.length > 0  | 			to = images.length > 0  | ||||||
| 				? images.eq(Math.min(Math.abs(i), images.length)-1)  | 				? images.eq(Math.min(Math.abs(i), images.length)-1)  | ||||||
| 				: img | 				: img | ||||||
|  | 			if(to === img){ | ||||||
|  | 				return to | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 		// append/prepend to ribbon...
 | ||||||
|  | 		} else if(r.length > 0 && r.hasClass('ribbon')){ | ||||||
|  | 			if(mode == 'before'){ | ||||||
|  | 				r.append(img) | ||||||
|  | 			} else { | ||||||
|  | 				r.prepend(img) | ||||||
|  | 			} | ||||||
|  | 			return this.updateImage(img) | ||||||
|  | 
 | ||||||
| 		// relative to image...
 | 		// relative to image...
 | ||||||
| 		} else { | 		} else { | ||||||
| 			var i = mode == 'before' ? -1 : 1 | 			var i = mode == 'before' ? -1 : 1 | ||||||
|  | |||||||
| @ -102,6 +102,21 @@ module.GLOBAL_KEYBOARD = { | |||||||
| 		F: { | 		F: { | ||||||
| 			ctrl: 'F11', | 			ctrl: 'F11', | ||||||
| 		}, | 		}, | ||||||
|  | 
 | ||||||
|  | 		// XXX testing...
 | ||||||
|  | 		Home: doc('', function(){ a.firstImage() }), | ||||||
|  | 		End: doc('', function(){ a.lastImage() }), | ||||||
|  | 		Left: doc('', function(){ a.prevImage() }), | ||||||
|  | 		Right: doc('', function(){ a.nextImage() }), | ||||||
|  | 		Up: { | ||||||
|  | 			default: doc('', function(){ a.prevRibbon() }), | ||||||
|  | 			shift: doc('', function(){ a.shiftImageUp() }), | ||||||
|  | 		}, | ||||||
|  | 		Down: { | ||||||
|  | 			default: doc('', function(){ a.nextRibbon() }), | ||||||
|  | 			shift: doc('', function(){ a.shiftImageDown() }), | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 	}, | 	}, | ||||||
| }	 | }	 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -165,13 +165,15 @@ actions.Actions({ | |||||||
| 	lastRibbon: ['Focus next ribbon', | 	lastRibbon: ['Focus next ribbon', | ||||||
| 		function(){ this.focusRibbon('last') }], | 		function(){ this.focusRibbon('last') }], | ||||||
| 
 | 
 | ||||||
|  | 	// XXX check that going up/down must be stable and not drift to 
 | ||||||
|  | 	// 		adjacent images...
 | ||||||
| 	prevRibbon: ['Focus previous ribbon', | 	prevRibbon: ['Focus previous ribbon', | ||||||
| 		function(){ this.focusRibbon('before') }], | 		function(){ this.focusRibbon('before') }], | ||||||
| 	nextRibbon: ['Focus next ribbon', | 	nextRibbon: ['Focus next ribbon', | ||||||
| 		function(){ this.focusRibbon('after') }], | 		function(){ this.focusRibbon('after') }], | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	// basic editing...
 | 	// basic ribbon editing...
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// NOTE: for all of these, current/ribbon image is a default...
 | 	// NOTE: for all of these, current/ribbon image is a default...
 | ||||||
| 	//
 | 	//
 | ||||||
| @ -187,6 +189,9 @@ actions.Actions({ | |||||||
| 
 | 
 | ||||||
| 				var cur = this.data.getImage() | 				var cur = this.data.getImage() | ||||||
| 				var next = this.data.getImage(direction) | 				var next = this.data.getImage(direction) | ||||||
|  | 				next = next == null  | ||||||
|  | 					? this.data.getImage(direction == 'next' ? 'prev' : 'next')  | ||||||
|  | 					: next | ||||||
| 
 | 
 | ||||||
| 				this.data.shiftImageUp(cur) | 				this.data.shiftImageUp(cur) | ||||||
| 				this.focusImage(next) | 				this.focusImage(next) | ||||||
| @ -207,6 +212,9 @@ actions.Actions({ | |||||||
| 
 | 
 | ||||||
| 				var cur = this.data.getImage() | 				var cur = this.data.getImage() | ||||||
| 				var next = this.data.getImage(direction) | 				var next = this.data.getImage(direction) | ||||||
|  | 				next = next == null  | ||||||
|  | 					? this.data.getImage(direction == 'next' ? 'prev' : 'next')  | ||||||
|  | 					: next | ||||||
| 
 | 
 | ||||||
| 				this.data.shiftImageDown(cur) | 				this.data.shiftImageDown(cur) | ||||||
| 				this.focusImage(next) | 				this.focusImage(next) | ||||||
| @ -216,49 +224,70 @@ actions.Actions({ | |||||||
| 				this.data.shiftImageDown(target) | 				this.data.shiftImageDown(target) | ||||||
| 			} | 			} | ||||||
| 		}], | 		}], | ||||||
| 	shiftImageUpNewRibbon: ['', | 	shiftImageUpNewRibbon: ['Shift image up to a new empty ribbon', | ||||||
| 		function(target){ | 		function(target){ | ||||||
| 			this.data.newRibbon(target) | 			this.data.newRibbon(target) | ||||||
| 			this.shiftImageUp(target) | 			this.shiftImageUp(target) | ||||||
| 		}], | 		}], | ||||||
| 	shiftImageDownNewRibbon: ['', | 	shiftImageDownNewRibbon: ['Shift image down to a new empty ribbon', | ||||||
| 		function(target){ | 		function(target){ | ||||||
| 			this.data.newRibbon(target, 'below') | 			this.data.newRibbon(target, 'below') | ||||||
| 			this.shiftImageUp(target) | 			this.shiftImageUp(target) | ||||||
| 		}], | 		}], | ||||||
| 	// XXX is tracking direction here correct???
 | 	// XXX is tracking direction here correct???
 | ||||||
| 	shiftImageLeft: ['', | 	shiftImageLeft: ['Shift image left', | ||||||
| 		function(target){  | 		function(target){  | ||||||
| 			if(target == null){ | 			if(target == null){ | ||||||
| 				this.direction = 'left' | 				this.direction = 'left' | ||||||
| 			} | 			} | ||||||
| 			this.data.shiftImageLeft(target)  | 			this.data.shiftImageLeft(target)  | ||||||
| 			// XXX is this the right way to go/???
 |  | ||||||
| 			this.focusImage() | 			this.focusImage() | ||||||
| 		}], | 		}], | ||||||
| 	// XXX is tracking direction here correct???
 | 	// XXX is tracking direction here correct???
 | ||||||
| 	shiftImageRight: ['', | 	shiftImageRight: ['Shift image right', | ||||||
| 		function(target){  | 		function(target){  | ||||||
| 			if(target == null){ | 			if(target == null){ | ||||||
| 				this.direction = 'right' | 				this.direction = 'right' | ||||||
| 			} | 			} | ||||||
| 			this.data.shiftImageLeft(target)  | 			this.data.shiftImageRight(target)  | ||||||
| 			// XXX is this the right way to go/???
 |  | ||||||
| 			this.focusImage() | 			this.focusImage() | ||||||
| 		}], | 		}], | ||||||
| 
 | 
 | ||||||
| 	shiftRibbonUp: ['', | 	shiftRibbonUp: ['Shift ribbon up', | ||||||
| 		function(target){  | 		function(target){  | ||||||
| 			this.data.shiftRibbonUp(target)  | 			this.data.shiftRibbonUp(target)  | ||||||
| 			// XXX is this the right way to go/???
 | 			// XXX is this the right way to go/???
 | ||||||
| 			this.focusImage() | 			this.focusImage() | ||||||
| 		}], | 		}], | ||||||
| 	shiftRibbonDown: ['', | 	shiftRibbonDown: ['Shift ribbon down', | ||||||
| 		function(target){  | 		function(target){  | ||||||
| 			this.data.shiftRibbonDown(target) | 			this.data.shiftRibbonDown(target) | ||||||
| 			// XXX is this the right way to go/???
 | 			// XXX is this the right way to go/???
 | ||||||
| 			this.focusImage() | 			this.focusImage() | ||||||
| 		}], | 		}], | ||||||
|  | 	 | ||||||
|  | 	// XXX
 | ||||||
|  | 	sortImages: [ | ||||||
|  | 		function(){  }], | ||||||
|  | 	// XXX
 | ||||||
|  | 	reverseImages: [ | ||||||
|  | 		function(){  }], | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	// basic image editing...
 | ||||||
|  | 	//
 | ||||||
|  | 	// XXX
 | ||||||
|  | 	rotateCW: [  | ||||||
|  | 		function(){  }], | ||||||
|  | 	rotateCCW: [  | ||||||
|  | 		function(){  }], | ||||||
|  | 	flipVertical: [  | ||||||
|  | 		function(){  }], | ||||||
|  | 	flipHorizontal: [ | ||||||
|  | 		function(){  }], | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	// crop...
 | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -355,12 +384,12 @@ actions.Actions(Client, { | |||||||
| 			this.ribbons.setBaseRibbon(r) | 			this.ribbons.setBaseRibbon(r) | ||||||
| 		}], | 		}], | ||||||
| 
 | 
 | ||||||
| 	// XXX
 | 	// XXX need screen width in images...
 | ||||||
| 	prevScreen: ['Focus previous image one screen width away', | 	prevScreen: ['Focus previous image one screen width away', | ||||||
| 		function(){ | 		function(){ | ||||||
| 			// XXX
 | 			// XXX
 | ||||||
| 		}], | 		}], | ||||||
| 	// XXX
 | 	// XXX need screen width in images...
 | ||||||
| 	nextScreen: ['Focus next image one screen width away', | 	nextScreen: ['Focus next image one screen width away', | ||||||
| 		function(){ | 		function(){ | ||||||
| 			// XXX
 | 			// XXX
 | ||||||
| @ -369,36 +398,44 @@ actions.Actions(Client, { | |||||||
| 
 | 
 | ||||||
| 	// XXX
 | 	// XXX
 | ||||||
| 	shiftImageUp: [ | 	shiftImageUp: [ | ||||||
| 		function(){ | 		function(target){ | ||||||
| 			// XXX
 | 			return function(){ | ||||||
|  | 				// XXX this is cheating...
 | ||||||
|  | 				this.ribbons.updateData(this.data) | ||||||
|  | 				this.focusImage() | ||||||
|  | 			} | ||||||
| 		}], | 		}], | ||||||
| 	shiftImageDown: [ | 	shiftImageDown: [ | ||||||
| 		function(){ | 		function(target){ | ||||||
| 			// XXX
 | 			return function(){ | ||||||
|  | 				// XXX this is cheating...
 | ||||||
|  | 				this.ribbons.updateData(this.data) | ||||||
|  | 				this.focusImage() | ||||||
|  | 			} | ||||||
| 		}], | 		}], | ||||||
| 	shiftImageUpNewRibbon: [ | 	shiftImageUpNewRibbon: [ | ||||||
| 		function(){ | 		function(target){ | ||||||
| 			// XXX
 | 			// XXX only create a new ribbon...
 | ||||||
| 		}], | 		}], | ||||||
| 	shiftImageDownNewRibbon: [ | 	shiftImageDownNewRibbon: [ | ||||||
| 		function(){ | 		function(target){ | ||||||
| 			// XXX
 | 			// XXX only create a new ribbon...
 | ||||||
| 		}], | 		}], | ||||||
| 	shiftImageLeft: [ | 	shiftImageLeft: [ | ||||||
| 		function(){ | 		function(target){ | ||||||
| 			// XXX
 | 			this.ribbons.placeImage(target, -1) | ||||||
| 		}], | 		}], | ||||||
| 	shiftImageRight: [ | 	shiftImageRight: [ | ||||||
| 		function(){ | 		function(target){ | ||||||
| 			// XXX
 | 			this.ribbons.placeImage(target, 1) | ||||||
| 		}], | 		}], | ||||||
| 
 | 
 | ||||||
| 	shiftRibbonUp: [ | 	shiftRibbonUp: [ | ||||||
| 		function(){ | 		function(target){ | ||||||
| 			// XXX
 | 			// XXX
 | ||||||
| 		}], | 		}], | ||||||
| 	shiftRibbonDown: [ | 	shiftRibbonDown: [ | ||||||
| 		function(){ | 		function(target){ | ||||||
| 			// XXX
 | 			// XXX
 | ||||||
| 		}], | 		}], | ||||||
| }) | }) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user