| 
									
										
										
										
											2014-07-20 03:02:18 +04:00
										 |  |  | /********************************************************************** | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | **********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-29 19:09:05 +04:00
										 |  |  | define(function(require){ var module = {} | 
					
						
							|  |  |  | console.log('>>> viewer') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-20 03:02:18 +04:00
										 |  |  | //var DEBUG = DEBUG != null ? DEBUG : true
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | var actions = require('lib/actions') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var data = require('data') | 
					
						
							|  |  |  | var ribbons = require('ribbons') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-20 03:02:18 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*********************************************************************/ | 
					
						
							| 
									
										
										
										
											2014-10-08 04:52:41 +04:00
										 |  |  | //
 | 
					
						
							|  |  |  | // XXX Tasks to accomplish here:
 | 
					
						
							|  |  |  | // 	- life-cycle actions/events
 | 
					
						
							|  |  |  | // 		- setup
 | 
					
						
							|  |  |  | // 		- reset
 | 
					
						
							|  |  |  | // 	- "features" and the mechanism to turn them on or off (action-sets)
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | var Client =  | 
					
						
							|  |  |  | module.Client =  | 
					
						
							|  |  |  | actions.Actions({ | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:18:33 +04:00
										 |  |  | 	// XXX should this be here???
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 	config: { | 
					
						
							|  |  |  | 		'steps-to-change-direction': 3, | 
					
						
							| 
									
										
										
										
											2014-10-18 17:32:41 +04:00
										 |  |  | 		'max-screen-images': 30, | 
					
						
							|  |  |  | 		'zoom-step': 1.2, | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:18:33 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 	// basic state...
 | 
					
						
							|  |  |  | 	// NOTE: the setters in the following use the appropriate actions
 | 
					
						
							|  |  |  | 	// 		so to avoid recursion do not use these in the specific 
 | 
					
						
							|  |  |  | 	// 		actions...
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:18:33 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Base ribbon...
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 	get base(){ | 
					
						
							|  |  |  | 		return this.data == null ? null : this.data.base | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	set base(value){ | 
					
						
							|  |  |  | 		this.setBaseRibbon(value) | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:18:33 +04:00
										 |  |  | 	// Current image...
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 	get current(){ | 
					
						
							|  |  |  | 		return this.data == null ? null : this.data.current | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	set current(value){ | 
					
						
							|  |  |  | 		this.focusImage(value) | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:18:33 +04:00
										 |  |  | 	// Current ribbon...
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 	get currentRibbon(){ | 
					
						
							|  |  |  | 		return this.data == null ? null : this.data.getRibbon() | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	set currentRibbon(value){ | 
					
						
							|  |  |  | 		this.focusRibbon(value) | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:18:33 +04:00
										 |  |  | 	// Default direction...
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// This can be 'left' or 'right', other values are ignored.
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// The system has inertial direction change, after >N steps of 
 | 
					
						
							|  |  |  | 	// movement in one direction it takes N steps to reverse the default
 | 
					
						
							|  |  |  | 	// direction.
 | 
					
						
							|  |  |  | 	// The number of steps (N) is set in:
 | 
					
						
							|  |  |  | 	// 		.config['steps-to-change-direction']
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 	//
 | 
					
						
							|  |  |  | 	// NOTE: to force direction change append a '!' to the direction.
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:18:33 +04:00
										 |  |  | 	// 		e.g. X.direction = 'left!'
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 	get direction(){ | 
					
						
							|  |  |  | 		return this._direction >= 0 ? 'right' | 
					
						
							|  |  |  | 			: this._direction < 0 ? 'left' | 
					
						
							|  |  |  | 			: 'right' | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	set direction(value){ | 
					
						
							|  |  |  | 		// force direction change...
 | 
					
						
							|  |  |  | 		if(value.slice(-1) == '!'){ | 
					
						
							|  |  |  | 			this._direction = value == 'left!' ? -1 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:18:33 +04:00
										 |  |  | 				: value == 'right!' ? 0 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 				: this._direction | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// 'update' direction...
 | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			value = value == 'left' ? -1  | 
					
						
							| 
									
										
										
										
											2014-10-11 17:18:33 +04:00
										 |  |  | 				: value == 'right' ? 1 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 				: 0 | 
					
						
							|  |  |  | 			var d = (this._direction || 0) + value | 
					
						
							|  |  |  | 			var s = this.config['steps-to-change-direction'] | 
					
						
							|  |  |  | 			s = s < 1 ? 1 : s | 
					
						
							|  |  |  | 			// cap the direction value between -s and s-1...
 | 
					
						
							|  |  |  | 			// NOTE: we use s-1 instead of s as 0/null is a positive 
 | 
					
						
							|  |  |  | 			// 		direction...
 | 
					
						
							|  |  |  | 			d = d >= s ? s-1 : d | 
					
						
							|  |  |  | 			d = d < -s ? -s : d | 
					
						
							|  |  |  | 			this._direction = d | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-10-11 17:18:33 +04:00
										 |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 	// basic life-cycle actions...
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:18:33 +04:00
										 |  |  | 	//
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 	ready: [ | 
					
						
							|  |  |  | 		function(){ | 
					
						
							|  |  |  | 			// XXX setup empty state...
 | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 	load: [ | 
					
						
							|  |  |  | 		function(d){ | 
					
						
							|  |  |  | 			this.data = data.Data(d.data) | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 	clear: [ | 
					
						
							|  |  |  | 		function(){ | 
					
						
							|  |  |  | 			delete this.data | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 	// basic navigation...
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:18:33 +04:00
										 |  |  | 	//
 | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 	focusImage: ['Focus image', | 
					
						
							| 
									
										
										
										
											2014-10-19 22:32:33 +04:00
										 |  |  | 		function(img, list){ | 
					
						
							|  |  |  | 			this.data.focusImage(img, list) | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 		}], | 
					
						
							|  |  |  | 	focusRibbon: ['Focus Ribbon', | 
					
						
							|  |  |  | 		function(target){ | 
					
						
							|  |  |  | 			var data = this.data | 
					
						
							|  |  |  | 			var r = data.getRibbon(target) | 
					
						
							| 
									
										
										
										
											2014-10-13 00:18:26 +04:00
										 |  |  | 			if(r == null){ | 
					
						
							|  |  |  | 				return | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			var c = data.getRibbonOrder() | 
					
						
							|  |  |  | 			var i = data.getRibbonOrder(r) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// NOTE: we are not changing the direction here based on 
 | 
					
						
							|  |  |  | 			// 		this.direction as swap will confuse the user...
 | 
					
						
							|  |  |  | 			var direction = c < i ? 'before' : 'after' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var t = data.getImage(r, direction) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// if there are no images in the requied direction, try the 
 | 
					
						
							|  |  |  | 			// other way...
 | 
					
						
							|  |  |  | 			t = t == null ? data.getImage(r, direction == 'before' ? 'after' : 'before') : t | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			this.focusImage(t, r) | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-19 22:32:33 +04:00
										 |  |  | 	setBaseRibbon: ['Set base ribbon', | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		function(target){ this.data.setBase(target) }], | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// shorthands for .focusImage(..) and .focusRibbon(..)...
 | 
					
						
							|  |  |  | 	firstImage: ['Focus first image in current ribbon', | 
					
						
							|  |  |  | 		function(){ this.focusImage('first') }], | 
					
						
							|  |  |  | 	lastImage: ['Focus last image in current ribbon', | 
					
						
							|  |  |  | 		function(){ this.focusImage('last') }], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	prevImage: ['Focus previous image', | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		function(){  | 
					
						
							|  |  |  | 			// keep track of traverse direction...
 | 
					
						
							|  |  |  | 			this.direction = 'left' | 
					
						
							|  |  |  | 			this.focusImage('prev')  | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 	nextImage: ['Focus next image', | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		function(){  | 
					
						
							|  |  |  | 			// keep track of traverse direction...
 | 
					
						
							|  |  |  | 			this.direction = 'right' | 
					
						
							|  |  |  | 			this.focusImage('next')  | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-19 22:32:33 +04:00
										 |  |  | 	prevImageInOrder: ['Focus previous image in order', | 
					
						
							|  |  |  | 		function(){  | 
					
						
							|  |  |  | 			// keep track of traverse direction...
 | 
					
						
							|  |  |  | 			this.direction = 'left' | 
					
						
							|  |  |  | 			this.focusImage('prev', this.data.order)  | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 	nextImageInOrder: ['Focus next image in order', | 
					
						
							|  |  |  | 		function(){  | 
					
						
							|  |  |  | 			// keep track of traverse direction...
 | 
					
						
							|  |  |  | 			this.direction = 'right' | 
					
						
							|  |  |  | 			this.focusImage('next', this.data.order)  | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 	firstRibbon: ['Focus previous ribbon', | 
					
						
							|  |  |  | 		function(){ this.focusRibbon('fisrt') }], | 
					
						
							|  |  |  | 	lastRibbon: ['Focus next ribbon', | 
					
						
							|  |  |  | 		function(){ this.focusRibbon('last') }], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 	// XXX check that going up/down must be stable and not drift to 
 | 
					
						
							|  |  |  | 	// 		adjacent images...
 | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 	prevRibbon: ['Focus previous ribbon', | 
					
						
							|  |  |  | 		function(){ this.focusRibbon('before') }], | 
					
						
							|  |  |  | 	nextRibbon: ['Focus next ribbon', | 
					
						
							|  |  |  | 		function(){ this.focusRibbon('after') }], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 	// basic ribbon editing...
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 	//
 | 
					
						
							|  |  |  | 	// NOTE: for all of these, current/ribbon image is a default...
 | 
					
						
							| 
									
										
										
										
											2014-10-19 00:41:50 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// XXX to be used for things like mark/place and dragging...
 | 
					
						
							|  |  |  | 	shiftImageTo: ['', | 
					
						
							|  |  |  | 		function(target, to){ | 
					
						
							|  |  |  | 			// XXX
 | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-18 17:32:41 +04:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 	shiftImageUp: ['Shift image up', | 
					
						
							|  |  |  | 		'If implicitly shifting current image (i.e. no arguments), focus ' | 
					
						
							|  |  |  | 			+'will shift to the next or previous image in the current ' | 
					
						
							|  |  |  | 			+'ribbon depending on current direction.', | 
					
						
							|  |  |  | 		function(target){  | 
					
						
							| 
									
										
										
										
											2014-10-19 00:41:50 +04:00
										 |  |  | 			// by default we need to focus another image in the same ribbon...
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 			if(target == null){ | 
					
						
							|  |  |  | 				var direction = this.direction == 'right' ? 'next' : 'prev' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				var cur = this.data.getImage() | 
					
						
							|  |  |  | 				var next = this.data.getImage(direction) | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 				next = next == null  | 
					
						
							|  |  |  | 					? this.data.getImage(direction == 'next' ? 'prev' : 'next')  | 
					
						
							|  |  |  | 					: next | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				this.data.shiftImageUp(cur) | 
					
						
							|  |  |  | 				this.focusImage(next) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// if a specific target is given, just shift it...
 | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				this.data.shiftImageUp(target) | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 	shiftImageDown: ['Shift image down', | 
					
						
							| 
									
										
										
										
											2014-10-11 17:18:33 +04:00
										 |  |  | 		'If implicitly shifting current image (i.e. no arguments), focus ' | 
					
						
							|  |  |  | 			+'will shift to the next or previous image in the current ' | 
					
						
							|  |  |  | 			+'ribbon depending on current direction.', | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		function(target){  | 
					
						
							| 
									
										
										
										
											2014-10-19 00:41:50 +04:00
										 |  |  | 			// by default we need to focus another image in the same ribbon...
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 			if(target == null){ | 
					
						
							|  |  |  | 				var direction = this.direction == 'right' ? 'next' : 'prev' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				var cur = this.data.getImage() | 
					
						
							|  |  |  | 				var next = this.data.getImage(direction) | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 				next = next == null  | 
					
						
							|  |  |  | 					? this.data.getImage(direction == 'next' ? 'prev' : 'next')  | 
					
						
							|  |  |  | 					: next | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				this.data.shiftImageDown(cur) | 
					
						
							|  |  |  | 				this.focusImage(next) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// if a specific target is given, just shift it...
 | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				this.data.shiftImageDown(target) | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 	shiftImageUpNewRibbon: ['Shift image up to a new empty ribbon', | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		function(target){ | 
					
						
							|  |  |  | 			this.data.newRibbon(target) | 
					
						
							|  |  |  | 			this.shiftImageUp(target) | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 	shiftImageDownNewRibbon: ['Shift image down to a new empty ribbon', | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		function(target){ | 
					
						
							|  |  |  | 			this.data.newRibbon(target, 'below') | 
					
						
							| 
									
										
										
										
											2014-10-12 04:52:44 +04:00
										 |  |  | 			this.shiftImageDown(target) | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 	shiftImageLeft: ['Shift image left', | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		function(target){  | 
					
						
							|  |  |  | 			if(target == null){ | 
					
						
							|  |  |  | 				this.direction = 'left' | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			this.data.shiftImageLeft(target)  | 
					
						
							|  |  |  | 			this.focusImage() | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 	shiftImageRight: ['Shift image right', | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		function(target){  | 
					
						
							|  |  |  | 			if(target == null){ | 
					
						
							|  |  |  | 				this.direction = 'right' | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 			this.data.shiftImageRight(target)  | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 			this.focusImage() | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 	shiftRibbonUp: ['Shift ribbon up', | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		function(target){  | 
					
						
							|  |  |  | 			this.data.shiftRibbonUp(target)  | 
					
						
							|  |  |  | 			// XXX is this the right way to go/???
 | 
					
						
							|  |  |  | 			this.focusImage() | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 	shiftRibbonDown: ['Shift ribbon down', | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		function(target){  | 
					
						
							|  |  |  | 			this.data.shiftRibbonDown(target) | 
					
						
							|  |  |  | 			// XXX is this the right way to go/???
 | 
					
						
							|  |  |  | 			this.focusImage() | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2014-10-18 04:36:47 +04:00
										 |  |  | 	reverseImages: ['Reverse image order', | 
					
						
							| 
									
										
										
										
											2014-10-13 00:18:26 +04:00
										 |  |  | 		function(){ this.data.reverseImages() }], | 
					
						
							| 
									
										
										
										
											2014-10-18 04:36:47 +04:00
										 |  |  | 	reverseRibbons: ['Reverse ribbon order', | 
					
						
							|  |  |  | 		function(){ this.data.reverseRibbons() }], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-18 04:26:52 +04:00
										 |  |  | 	// XXX this also requires images...
 | 
					
						
							|  |  |  | 	sortImages: [ | 
					
						
							|  |  |  | 		function(){  }], | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// basic image editing...
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							| 
									
										
										
										
											2014-10-18 04:26:52 +04:00
										 |  |  | 	// XXX these are not data stuff... should this be split into a 
 | 
					
						
							|  |  |  | 	// 		separate images block???
 | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 	rotateCW: [  | 
					
						
							|  |  |  | 		function(){  }], | 
					
						
							|  |  |  | 	rotateCCW: [  | 
					
						
							|  |  |  | 		function(){  }], | 
					
						
							|  |  |  | 	flipVertical: [  | 
					
						
							|  |  |  | 		function(){  }], | 
					
						
							|  |  |  | 	flipHorizontal: [ | 
					
						
							|  |  |  | 		function(){  }], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// crop...
 | 
					
						
							| 
									
										
										
										
											2014-10-13 00:18:26 +04:00
										 |  |  | 	//
 | 
					
						
							|  |  |  | 	// XXX
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | // XXX do partial loading...
 | 
					
						
							|  |  |  | var Viewer =  | 
					
						
							|  |  |  | module.Viewer =  | 
					
						
							|  |  |  | actions.Actions(Client, { | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	ready: [ | 
					
						
							|  |  |  | 		function(){ | 
					
						
							|  |  |  | 			// XXX setup empty state...
 | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 	load: [ | 
					
						
							|  |  |  | 		function(data){ | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 			// recycle the viewer if one is not given specifically...
 | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 			var viewer = data.viewer | 
					
						
							|  |  |  | 			viewer = viewer == null && this.ribbons != null  | 
					
						
							|  |  |  | 				? this.ribbons.viewer  | 
					
						
							|  |  |  | 				: viewer | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 			// XXX do we need to recycle the images???
 | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			this.ribbons = ribbons.Ribbons(viewer, data.images) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			return function(){ | 
					
						
							|  |  |  | 				// XXX do a partial load...
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 				// XXX
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 				this.ribbons.updateData(this.data) | 
					
						
							|  |  |  | 				this.focusImage() | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-12 04:52:44 +04:00
										 |  |  | 	reload: [ | 
					
						
							|  |  |  | 		function(){ | 
					
						
							|  |  |  | 			this.ribbons.updateData(this.data) | 
					
						
							|  |  |  | 			this.focusImage() | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 	clear: [ | 
					
						
							|  |  |  | 		// XXX do we need to delete the ribbons???
 | 
					
						
							|  |  |  | 		function(){ | 
					
						
							|  |  |  | 			this.ribbons.clear() | 
					
						
							|  |  |  | 			delete this.ribbons | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	focusImage: [ | 
					
						
							|  |  |  | 		// XXX skip invisible ribbons (???)
 | 
					
						
							|  |  |  | 		// XXX load data chunks...
 | 
					
						
							| 
									
										
										
										
											2014-10-19 22:32:33 +04:00
										 |  |  | 		function(target, list){ | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 			var ribbons = this.ribbons | 
					
						
							|  |  |  | 			var data = this.data | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-19 22:32:33 +04:00
										 |  |  | 			if(data == null){ | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 				target = ribbons.focusImage(target) | 
					
						
							|  |  |  | 				var gid = ribbons.getElemGID(target) | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-19 22:32:33 +04:00
										 |  |  | 			return function(){ | 
					
						
							|  |  |  | 				if(data != null){ | 
					
						
							|  |  |  | 					// use the data for all the heavy lifting...
 | 
					
						
							|  |  |  | 					// NOTE: this will prevent sync errors...
 | 
					
						
							|  |  |  | 					var gid = data.getImage() | 
					
						
							|  |  |  | 					target = ribbons.focusImage(gid) | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-19 22:32:33 +04:00
										 |  |  | 					// XXX see if we need to do some loading...
 | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 					// XXX
 | 
					
						
							| 
									
										
										
										
											2014-10-19 22:32:33 +04:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-19 22:32:33 +04:00
										 |  |  | 				// align current ribbon...
 | 
					
						
							|  |  |  | 				ribbons | 
					
						
							|  |  |  | 					.centerRibbon(target) | 
					
						
							|  |  |  | 					.centerImage(target) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// align other ribbons...
 | 
					
						
							|  |  |  | 				if(data != null){ | 
					
						
							|  |  |  | 					var ribbon = data.getRibbon(gid) | 
					
						
							|  |  |  | 					for(var r in data.ribbons){ | 
					
						
							|  |  |  | 						// skip the current ribbon...
 | 
					
						
							|  |  |  | 						if(r == ribbon){ | 
					
						
							| 
									
										
										
										
											2014-10-17 03:54:29 +04:00
										 |  |  | 							continue | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2014-10-19 22:32:33 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 						// XXX skip off-screen ribbons...
 | 
					
						
							|  |  |  | 						// XXX
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 						// center...
 | 
					
						
							|  |  |  | 						// XXX is there a 'last' special case here???
 | 
					
						
							|  |  |  | 						var t = data.getImage(gid, r) | 
					
						
							|  |  |  | 						if(t == null){ | 
					
						
							|  |  |  | 							var f = data.getImage('first', r) | 
					
						
							|  |  |  | 							// nothing found -- empty ribbon?
 | 
					
						
							|  |  |  | 							if(f == null){ | 
					
						
							|  |  |  | 								continue | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 							ribbons.centerImage(data.getImage('first', r), 'before') | 
					
						
							|  |  |  | 						} else { | 
					
						
							|  |  |  | 							ribbons.centerImage(t, 'after') | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-19 22:32:33 +04:00
										 |  |  | 	setBaseRibbon: [ | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		function(target){ | 
					
						
							|  |  |  | 			var r = this.data.getRibbon(target) | 
					
						
							|  |  |  | 			r =  r == null ? this.ribbons.getRibbon(target) : r | 
					
						
							|  |  |  | 			this.ribbons.setBaseRibbon(r) | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-08 04:52:41 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 	prevScreen: ['Focus previous image one screen width away', | 
					
						
							|  |  |  | 		function(){ | 
					
						
							| 
									
										
										
										
											2014-10-18 04:26:52 +04:00
										 |  |  | 			var s = Math.ceil(this.ribbons.getScreenWidthImages()) | 
					
						
							|  |  |  | 			this.focusImage(this.data.getImage('current', -s) | 
					
						
							|  |  |  | 					// go to the first image if it's closer than s...
 | 
					
						
							|  |  |  | 					|| this.data.getImage('first')) | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 		}], | 
					
						
							|  |  |  | 	nextScreen: ['Focus next image one screen width away', | 
					
						
							|  |  |  | 		function(){ | 
					
						
							| 
									
										
										
										
											2014-10-18 04:26:52 +04:00
										 |  |  | 			var s = Math.ceil(this.ribbons.getScreenWidthImages()) | 
					
						
							|  |  |  | 			this.focusImage(this.data.getImage('current', s) | 
					
						
							|  |  |  | 					// go to the last image if it's closer than s...
 | 
					
						
							|  |  |  | 					|| this.data.getImage('last')) | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		}], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-13 00:18:26 +04:00
										 |  |  | 	// zooming...
 | 
					
						
							| 
									
										
										
										
											2014-10-18 17:32:41 +04:00
										 |  |  | 	//
 | 
					
						
							|  |  |  | 	// Zooming is done by multiplying the current scale by config['zoom-step']
 | 
					
						
							|  |  |  | 	// and rounding to nearest discrete number of images to fit on screen.
 | 
					
						
							| 
									
										
										
										
											2014-10-13 00:18:26 +04:00
										 |  |  | 	zoomIn: ['Zoom in', | 
					
						
							| 
									
										
										
										
											2014-10-18 17:32:41 +04:00
										 |  |  | 		function(){  | 
					
						
							|  |  |  | 			this.ribbons.setOrigin() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			//var n = Math.round(this.ribbons.getScreenWidthImages())-1
 | 
					
						
							|  |  |  | 			var d = this.config['zoom-step'] | 
					
						
							|  |  |  | 			var s = a.ribbons.getScale() * d | 
					
						
							|  |  |  | 			var n = Math.floor(this.ribbons.getScreenWidthImages(s)) | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 			this.fitImage(n <= 0 ? 1 : n) | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-13 00:18:26 +04:00
										 |  |  | 	zoomOut: ['Zoom out', | 
					
						
							| 
									
										
										
										
											2014-10-18 17:32:41 +04:00
										 |  |  | 		function(){  | 
					
						
							|  |  |  | 			this.ribbons.setOrigin() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			//var n = Math.round(this.ribbons.getScreenWidthImages())+1
 | 
					
						
							|  |  |  | 			var d = this.config['zoom-step'] | 
					
						
							|  |  |  | 			var s = a.ribbons.getScale() / d | 
					
						
							|  |  |  | 			var n = Math.ceil(this.ribbons.getScreenWidthImages(s)) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var max = this.config['max-screen-images'] | 
					
						
							|  |  |  | 			this.fitImage(n > max ? max : n) | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-13 00:18:26 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	fitOrig: ['Fit to original scale', | 
					
						
							| 
									
										
										
										
											2014-10-13 06:33:22 +04:00
										 |  |  | 		function(){  | 
					
						
							|  |  |  | 			this.ribbons.setScale(1)  | 
					
						
							|  |  |  | 			this.ribbons.updateImage('*') | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-13 00:18:26 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// NOTE: if this gets a count argument it will fit count images, 
 | 
					
						
							|  |  |  | 	// 		default is one.
 | 
					
						
							|  |  |  | 	fitImage: ['Fit image', | 
					
						
							|  |  |  | 		function(count){ | 
					
						
							|  |  |  | 			this.ribbons.fitImage(count) | 
					
						
							|  |  |  | 			this.ribbons.updateImage('*') | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	fitTwo: ['Fit two images', function(){ this.fitImage(2) }], | 
					
						
							|  |  |  | 	fitThree: ['Fit three images', function(){ this.fitImage(3) }], | 
					
						
							|  |  |  | 	fitFour: ['Fit four images', function(){ this.fitImage(4) }], | 
					
						
							|  |  |  | 	fitFive: ['Fit five images', function(){ this.fitImage(5) }], | 
					
						
							|  |  |  | 	fitSix: ['Fit six images', function(){ this.fitImage(6) }], | 
					
						
							|  |  |  | 	fitSeven: ['Fit seven images', function(){ this.fitImage(7) }], | 
					
						
							|  |  |  | 	fitEight: ['Fit eight images', function(){ this.fitImage(8) }], | 
					
						
							|  |  |  | 	fitNine: ['Fit nine images', function(){ this.fitImage(9) }], | 
					
						
							| 
									
										
										
										
											2014-10-18 04:44:03 +04:00
										 |  |  | 	fitTen: ['Fit ten images', function(){ this.fitImage(10) }], | 
					
						
							|  |  |  | 	fitEleven: ['Fit eleven images', function(){ this.fitImage(11) }], | 
					
						
							|  |  |  | 	fitTwelve: ['Fit twelve images', function(){ this.fitImage(12) }], | 
					
						
							| 
									
										
										
										
											2014-10-13 00:18:26 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	fitMax: ['Fit the maximum number of images', | 
					
						
							| 
									
										
										
										
											2014-10-18 17:32:41 +04:00
										 |  |  | 		function(){ this.fitImage(this.config['max-screen-images']) }], | 
					
						
							| 
									
										
										
										
											2014-10-13 00:18:26 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// XXX
 | 
					
						
							|  |  |  | 	fitSmall: ['Show small image', | 
					
						
							|  |  |  | 		function(){  }], | 
					
						
							|  |  |  | 	// XXX
 | 
					
						
							|  |  |  | 	fitNormal: ['Show normal image', | 
					
						
							|  |  |  | 		function(){  }], | 
					
						
							|  |  |  | 	// XXX
 | 
					
						
							|  |  |  | 	fitScreen: ['Fit image to screen', | 
					
						
							|  |  |  | 		function(){  }], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-19 00:41:50 +04:00
										 |  |  | 	// XXX are these cheating???
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 	shiftImageUp: [ | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 		function(target){ | 
					
						
							| 
									
										
										
										
											2014-10-19 00:41:50 +04:00
										 |  |  | 			// prevent animations form adding/removing ribbons...
 | 
					
						
							| 
									
										
										
										
											2014-10-18 17:32:41 +04:00
										 |  |  | 			this.ribbons.preventTransitions() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 			return function(){ | 
					
						
							| 
									
										
										
										
											2014-10-19 00:41:50 +04:00
										 |  |  | 				// NOTE: this may seem like cheating, but .reload() should
 | 
					
						
							|  |  |  | 				// 		be very efficient, reusing all of the items loaded...
 | 
					
						
							| 
									
										
										
										
											2014-10-12 04:52:44 +04:00
										 |  |  | 				this.reload() | 
					
						
							| 
									
										
										
										
											2014-10-19 05:01:22 +04:00
										 |  |  | 				this.ribbons.restoreTransitions() | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		}], | 
					
						
							|  |  |  | 	shiftImageDown: [ | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 		function(target){ | 
					
						
							| 
									
										
										
										
											2014-10-19 00:41:50 +04:00
										 |  |  | 			// prevent animations form adding/removing ribbons...
 | 
					
						
							| 
									
										
										
										
											2014-10-18 17:32:41 +04:00
										 |  |  | 			this.ribbons.preventTransitions() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 			return function(){ | 
					
						
							| 
									
										
										
										
											2014-10-19 00:41:50 +04:00
										 |  |  | 				// NOTE: this may seem like cheating, but .reload() should
 | 
					
						
							|  |  |  | 				// 		be very efficient, reusing all of the items loaded...
 | 
					
						
							| 
									
										
										
										
											2014-10-12 04:52:44 +04:00
										 |  |  | 				this.reload() | 
					
						
							| 
									
										
										
										
											2014-10-19 05:01:22 +04:00
										 |  |  | 				this.ribbons.restoreTransitions() | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-13 00:18:26 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// NOTE: .shiftImageDownNewRibbon(..) and .shiftImageUpNewRibbon(..)
 | 
					
						
							|  |  |  | 	// 		are not needed here when doing a reload on vertical 
 | 
					
						
							|  |  |  | 	// 		shifting...
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 	shiftImageLeft: [ | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 		function(target){ | 
					
						
							|  |  |  | 			this.ribbons.placeImage(target, -1) | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		}], | 
					
						
							|  |  |  | 	shiftImageRight: [ | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 		function(target){ | 
					
						
							|  |  |  | 			this.ribbons.placeImage(target, 1) | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		}], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	shiftRibbonUp: [ | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 		function(target){ | 
					
						
							| 
									
										
										
										
											2014-10-18 04:26:52 +04:00
										 |  |  | 			target = this.ribbons.getRibbon(target) | 
					
						
							|  |  |  | 			var i = this.ribbons.getRibbonOrder(target) | 
					
						
							|  |  |  | 			if(i > 0){ | 
					
						
							|  |  |  | 				this.ribbons.placeRibbon(target, i-1) | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-10-11 17:08:17 +04:00
										 |  |  | 		}], | 
					
						
							|  |  |  | 	shiftRibbonDown: [ | 
					
						
							| 
									
										
										
										
											2014-10-12 03:14:29 +04:00
										 |  |  | 		function(target){ | 
					
						
							| 
									
										
										
										
											2014-10-18 04:26:52 +04:00
										 |  |  | 			target = this.ribbons.getRibbon(target) | 
					
						
							|  |  |  | 			var i = this.ribbons.getRibbonOrder(target) | 
					
						
							|  |  |  | 			if(i < this.data.ribbon_order.length-1){ | 
					
						
							|  |  |  | 				this.ribbons.placeRibbon(target, i+1) | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-13 00:18:26 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	reverseImages: [ | 
					
						
							|  |  |  | 		function(){  | 
					
						
							|  |  |  | 			this.ribbons.preventTransitions() | 
					
						
							| 
									
										
										
										
											2014-10-19 05:01:22 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-13 00:18:26 +04:00
										 |  |  | 			return function(){  | 
					
						
							|  |  |  | 				this.reload()  | 
					
						
							|  |  |  | 				this.ribbons.restoreTransitions() | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-18 04:36:47 +04:00
										 |  |  | 	reverseRibbons: [ | 
					
						
							|  |  |  | 		function(target){ | 
					
						
							|  |  |  | 			return function(){ | 
					
						
							|  |  |  | 				// XXX this is cheating...
 | 
					
						
							|  |  |  | 				this.reload() | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2014-10-13 00:18:26 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-13 06:33:22 +04:00
										 |  |  | 	// basic image editing...
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							| 
									
										
										
										
											2014-10-18 17:32:41 +04:00
										 |  |  | 	// XXX should these call .images.* or should it be done by data...
 | 
					
						
							|  |  |  | 	// 		...I think that data is a better candidate as it should be
 | 
					
						
							|  |  |  | 	// 		standalone...
 | 
					
						
							| 
									
										
										
										
											2014-10-13 06:33:22 +04:00
										 |  |  | 	rotateCW: [  | 
					
						
							| 
									
										
										
										
											2014-10-18 04:26:52 +04:00
										 |  |  | 		function(target){ this.ribbons.rotateCW(target) }], | 
					
						
							| 
									
										
										
										
											2014-10-13 06:33:22 +04:00
										 |  |  | 	rotateCCW: [  | 
					
						
							| 
									
										
										
										
											2014-10-18 04:26:52 +04:00
										 |  |  | 		function(target){ this.ribbons.rotateCCW(target) }], | 
					
						
							| 
									
										
										
										
											2014-10-13 06:33:22 +04:00
										 |  |  | 	flipVertical: [  | 
					
						
							| 
									
										
										
										
											2014-10-18 04:26:52 +04:00
										 |  |  | 		function(target){ this.ribbons.flipVertical(target) }], | 
					
						
							| 
									
										
										
										
											2014-10-13 06:33:22 +04:00
										 |  |  | 	flipHorizontal: [ | 
					
						
							| 
									
										
										
										
											2014-10-18 04:26:52 +04:00
										 |  |  | 		function(target){ this.ribbons.flipHorizontal(target) }], | 
					
						
							| 
									
										
										
										
											2014-10-13 06:33:22 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-11 06:33:49 +04:00
										 |  |  | }) | 
					
						
							| 
									
										
										
										
											2014-07-20 03:02:18 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-13 17:32:19 +04:00
										 |  |  | /*********************************************************************/ | 
					
						
							|  |  |  | // XXX do a simple feature framework...
 | 
					
						
							|  |  |  | // 		...need something like:
 | 
					
						
							|  |  |  | // 			Features(['feature_a', 'feature_b'], action).setup()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var Animation = | 
					
						
							|  |  |  | module.Animation = { | 
					
						
							|  |  |  | 	tag: 'animation_handler', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	setup: function(actions){ | 
					
						
							|  |  |  | 		var animate = function(target){ | 
					
						
							|  |  |  | 				var s = this.ribbons.makeShadow(target, true) | 
					
						
							|  |  |  | 				return function(){ s() } | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		var noanimate = function(target){ | 
					
						
							|  |  |  | 				var s = this.ribbons.makeShadow(target) | 
					
						
							|  |  |  | 				return function(){ s() } | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		var tag = this.tag | 
					
						
							|  |  |  | 		return actions | 
					
						
							|  |  |  | 			.on('shiftImageUp.pre', tag, animate) | 
					
						
							|  |  |  | 			.on('shiftImageDown.pre', tag, animate) | 
					
						
							|  |  |  | 			.on('shiftImageLeft.pre', tag, noanimate) | 
					
						
							|  |  |  | 			.on('shiftImageRight.pre', tag, noanimate) | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	remove: function(actions){ | 
					
						
							|  |  |  | 		return actions.off('*', this.tag) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-10-13 06:33:22 +04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-13 17:32:19 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-20 03:02:18 +04:00
										 |  |  | /********************************************************************** | 
					
						
							|  |  |  | * vim:set ts=4 sw=4 :                                                */ | 
					
						
							| 
									
										
										
										
											2014-07-29 19:09:05 +04:00
										 |  |  | return module }) |