mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 10:50:08 +00:00 
			
		
		
		
	refactoring and several bugfixes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									b420c007bc
								
							
						
					
					
						commit
						16dd6c92a6
					
				| @ -37,7 +37,7 @@ module.exitFullscreen = function() { | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| window.toggleFullscreenMode =  | window.toggleFullscreenMode =  | ||||||
| module.toggleFullscreenMode = makeCSSClassToggler( | module.toggleFullscreenMode = CSSClassToggler( | ||||||
| 		document.body,  | 		document.body,  | ||||||
| 		'.full-screen-mode', | 		'.full-screen-mode', | ||||||
| 		function(action){ | 		function(action){ | ||||||
|  | |||||||
| @ -9,6 +9,7 @@ | |||||||
| define(function(require){ var module = {} | define(function(require){ var module = {} | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| /*********************************************************************/ | /*********************************************************************/ | ||||||
| // Actions
 | // Actions
 | ||||||
| //
 | //
 | ||||||
| @ -157,9 +158,12 @@ if(typeof(args2array) != 'function'){ | |||||||
| // 	  registered from the current object and up to the base action set
 | // 	  registered from the current object and up to the base action set
 | ||||||
| // 	  will be fired.
 | // 	  will be fired.
 | ||||||
| //
 | //
 | ||||||
| // 	- an action will return the last deepest action's return, if that 
 | // 	- an action will return the deepest (root) action's return, if that 
 | ||||||
| // 	  return is null, then the action set is returned.
 | // 	  returns is undefined, then the action set is returned instead.
 | ||||||
| //
 | //
 | ||||||
|  | // NOTE: of the root handler is instance of Toggler (jli) and the action
 | ||||||
|  | // 		is called with '?' as argument, then the toggler will be called 
 | ||||||
|  | // 		with the argument and return the result bypassing the handlers.
 | ||||||
| // NOTE: actions once defined do not depend on the inheritance hierarchy, 
 | // NOTE: actions once defined do not depend on the inheritance hierarchy, 
 | ||||||
| // 		other than the .getHandlers(..) method. If this method is not 
 | // 		other than the .getHandlers(..) method. If this method is not 
 | ||||||
| // 		found in the inheritance chain (i.e. the link to MetaActions)
 | // 		found in the inheritance chain (i.e. the link to MetaActions)
 | ||||||
| @ -173,7 +177,6 @@ if(typeof(args2array) != 'function'){ | |||||||
| // NOTE: by default an action will return 'this', i.e. the action set
 | // NOTE: by default an action will return 'this', i.e. the action set
 | ||||||
| // 		object the action was called from.
 | // 		object the action was called from.
 | ||||||
| //
 | //
 | ||||||
| // XXX do we need to return something from an action ever?
 |  | ||||||
| // XXX add more metadata/docs:
 | // XXX add more metadata/docs:
 | ||||||
| // 		.section
 | // 		.section
 | ||||||
| // 		.category
 | // 		.category
 | ||||||
| @ -211,6 +214,18 @@ function Action(name, doc, ldoc, func){ | |||||||
| 		// 		method can be referenced more than once, both with the 
 | 		// 		method can be referenced more than once, both with the 
 | ||||||
| 		// 		same as well as under different names...
 | 		// 		same as well as under different names...
 | ||||||
| 		var handlers = getHandlers.call(this, name) | 		var handlers = getHandlers.call(this, name) | ||||||
|  | 		//	.map(function(h){ return h.apply(that, args) })
 | ||||||
|  | 
 | ||||||
|  | 		// special case: if the root handler is a toggler and we call 
 | ||||||
|  | 		// it with '?' then do not call the handlers...
 | ||||||
|  | 		// XXX might be good to make this modular/configurable...
 | ||||||
|  | 		if(handlers.slice(-1)[0] instanceof Toggler  | ||||||
|  | 				&& args.length == 1  | ||||||
|  | 				&& args[0] == '?'){ | ||||||
|  | 			return handlers.slice(-1)[0].apply(this, args) | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		handlers = handlers | ||||||
| 			.map(function(h){ return h.apply(that, args) }) | 			.map(function(h){ return h.apply(that, args) }) | ||||||
| 
 | 
 | ||||||
| 		// XXX use the last return as result...
 | 		// XXX use the last return as result...
 | ||||||
| @ -224,7 +239,7 @@ function Action(name, doc, ldoc, func){ | |||||||
| 		handlers.reverse().forEach(function(h, i){  | 		handlers.reverse().forEach(function(h, i){  | ||||||
| 			// function...
 | 			// function...
 | ||||||
| 			if(h instanceof Function){ | 			if(h instanceof Function){ | ||||||
| 				var r = h.call(that) | 				var r = h.apply(that, args) | ||||||
| 				res = i == 0 ? r : res | 				res = i == 0 ? r : res | ||||||
| 
 | 
 | ||||||
| 			// deferred...
 | 			// deferred...
 | ||||||
| @ -234,7 +249,8 @@ function Action(name, doc, ldoc, func){ | |||||||
| 			}  | 			}  | ||||||
| 		}) | 		}) | ||||||
| 
 | 
 | ||||||
| 		return res || this | 		// XXX is this the right way to go?
 | ||||||
|  | 		return res !== undefined ? res : this | ||||||
| 		//return this
 | 		//return this
 | ||||||
| 	} | 	} | ||||||
| 	meth.__proto__ = this.__proto__ | 	meth.__proto__ = this.__proto__ | ||||||
|  | |||||||
| @ -100,7 +100,7 @@ var USE_3D_TRANSFORM = true | |||||||
| // NOTE: if the pre-callback explicitly returns false, then the change will
 | // NOTE: if the pre-callback explicitly returns false, then the change will
 | ||||||
| // 		not be made.
 | // 		not be made.
 | ||||||
| //
 | //
 | ||||||
| // XXX revize/update this doc for makeToggler(..)
 | // XXX revize/update this doc for Toggler(..)
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // Make a generic toggler function/method...
 | // Make a generic toggler function/method...
 | ||||||
| @ -124,7 +124,7 @@ var USE_3D_TRANSFORM = true | |||||||
| // 		later is enough, but as strict mode is not stable enough (sometimes
 | // 		later is enough, but as strict mode is not stable enough (sometimes
 | ||||||
| // 		works and sometimes does not), we can not reliably pass the element
 | // 		works and sometimes does not), we can not reliably pass the element
 | ||||||
| // 		via 'this'.
 | // 		via 'this'.
 | ||||||
| function makeToggler(elem, state_accessor, states, callback_a, callback_b){ | function Toggler(elem, state_accessor, states, callback_a, callback_b){ | ||||||
| 	// normalize states...
 | 	// normalize states...
 | ||||||
| 	states = typeof(states) == typeof('str') ? ['none', states] : states | 	states = typeof(states) == typeof('str') ? ['none', states] : states | ||||||
| 	// normalize the callbacks...
 | 	// normalize the callbacks...
 | ||||||
| @ -246,13 +246,17 @@ function makeToggler(elem, state_accessor, states, callback_a, callback_b){ | |||||||
| 			'If "?" is given, this will return the current state.' | 			'If "?" is given, this will return the current state.' | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	func.__proto__ = Toggler.prototype | ||||||
|  | 	func.constructor = Toggler | ||||||
|  | 
 | ||||||
| 	return func | 	return func | ||||||
| } | } | ||||||
|  | Toggler.prototype.__proto__ = Function.prototype | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // XXX this should be drop-in compatible with createCSSClassToggler(..)
 | // XXX this should be drop-in compatible with createCSSClassToggler(..)
 | ||||||
| // 		test and replace...
 | // 		test and replace...
 | ||||||
| function makeCSSClassToggler(elem, classes, callback_a, callback_b){ | function CSSClassToggler(elem, classes, callback_a, callback_b){ | ||||||
| 	// normalize the states...
 | 	// normalize the states...
 | ||||||
| 	classes = typeof(classes) == typeof('str') ? ['none', classes] : classes | 	classes = typeof(classes) == typeof('str') ? ['none', classes] : classes | ||||||
| 	// remove the dot from class names...
 | 	// remove the dot from class names...
 | ||||||
| @ -268,7 +272,7 @@ function makeCSSClassToggler(elem, classes, callback_a, callback_b){ | |||||||
| 				}).join(' ') | 				}).join(' ') | ||||||
| 		}) | 		}) | ||||||
| 	 | 	 | ||||||
| 	return makeToggler( | 	var toggler = Toggler( | ||||||
| 		elem, | 		elem, | ||||||
| 		function(state){ | 		function(state){ | ||||||
| 			'use strict' | 			'use strict' | ||||||
| @ -298,8 +302,15 @@ function makeCSSClassToggler(elem, classes, callback_a, callback_b){ | |||||||
| 		classes,  | 		classes,  | ||||||
| 		callback_a,  | 		callback_a,  | ||||||
| 		callback_b) | 		callback_b) | ||||||
|  | 
 | ||||||
|  | 	toggler.__proto__ = CSSClassToggler.prototype | ||||||
|  | 	toggler.constructor = CSSClassToggler | ||||||
|  | 
 | ||||||
|  | 	return toggler | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | CSSClassToggler.prototype.__proto__ = Toggler.prototype | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /* | /* | ||||||
|  | |||||||
| @ -206,22 +206,21 @@ module.RibbonsPrototype = { | |||||||
| 		scale = scale || this.getScale() | 		scale = scale || this.getScale() | ||||||
| 		dim = dim == null ? 'width' : dim | 		dim = dim == null ? 'width' : dim | ||||||
| 		var img = this.viewer.find('.image') | 		var img = this.viewer.find('.image') | ||||||
| 		if(dim == 'height'){ | 
 | ||||||
| 			return img.outerHeight(true) * scale | 		return dim == 'height' ? img.outerHeight(true) * scale | ||||||
| 		} else if(dim == 'width'){ | 			: dim == 'width' ? img.outerWidth(true) * scale | ||||||
| 			return img.outerWidth(true) * scale | 			: dim == 'max' ? | ||||||
| 		} else if(dim == 'max'){ | 				Math.max(img.outerHeight(true), img.outerWidth(true)) * scale | ||||||
| 			return Math.max(img.outerHeight(true), img.outerWidth(true)) * scale | 			: dim == 'min' ? | ||||||
| 		} else if(dim == 'min'){ | 				Math.min(img.outerHeight(true), img.outerWidth(true)) * scale | ||||||
| 			return Math.min(img.outerHeight(true), img.outerWidth(true)) * scale | 			: null | ||||||
| 		} |  | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
| 	getScreenWidthImages: function(scale){ | 	getScreenWidthImages: function(scale, min){ | ||||||
| 		var scale = scale == null ? 1 : scale/this.getScale() | 		var scale = scale == null ? 1 : scale/this.getScale() | ||||||
| 
 | 
 | ||||||
| 		var W = this.viewer.width() | 		var W = this.viewer.width() | ||||||
| 		var w = this.getVisibleImageSize('width') * scale | 		var w = this.getVisibleImageSize(min ? 'min' : 'width') * scale | ||||||
| 
 | 
 | ||||||
| 		return W/w | 		return W/w | ||||||
| 	}, | 	}, | ||||||
| @ -1604,11 +1603,11 @@ module.RibbonsPrototype = { | |||||||
| 	// 		overflows either in height nor width.
 | 	// 		overflows either in height nor width.
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// XXX might be usefull to set origin before scaling...
 | 	// XXX might be usefull to set origin before scaling...
 | ||||||
| 	fitImage: function(n){ | 	fitImage: function(n, min){ | ||||||
| 		n = n || 1 | 		n = n || 1 | ||||||
| 
 | 
 | ||||||
| 		// NOTE: this is width oriented...
 | 		// NOTE: this is width oriented...
 | ||||||
| 		var scale = this.getScreenWidthImages(1) / n | 		var scale = this.getScreenWidthImages(1, min) / n | ||||||
| 
 | 
 | ||||||
| 		// check bounds...
 | 		// check bounds...
 | ||||||
| 		var H = this.viewer.height() | 		var H = this.viewer.height() | ||||||
|  | |||||||
| @ -189,6 +189,7 @@ $(function(){ | |||||||
| 	viewer.PartialRibbons.setup(a) | 	viewer.PartialRibbons.setup(a) | ||||||
| 	viewer.AlignRibbonsToImageOrder.setup(a) | 	viewer.AlignRibbonsToImageOrder.setup(a) | ||||||
| 	//viewer.AlignRibbonsToFirstImage.setup(a)
 | 	//viewer.AlignRibbonsToFirstImage.setup(a)
 | ||||||
|  | 	viewer.SingleImageView.setup(a) | ||||||
| 	viewer.ShiftAnimation.setup(a) | 	viewer.ShiftAnimation.setup(a) | ||||||
| 	viewer.BoundsIndicators.setup(a) | 	viewer.BoundsIndicators.setup(a) | ||||||
| 	viewer.CurrentImageIndicator.setup(a) | 	viewer.CurrentImageIndicator.setup(a) | ||||||
|  | |||||||
| @ -542,6 +542,9 @@ actions.Actions(Client, { | |||||||
| 	// 		updater if one is defined here as .updateRibbon(target)
 | 	// 		updater if one is defined here as .updateRibbon(target)
 | ||||||
| 	// XXX actions.updateRibbon(..) and ribbons.updateRibbon(..) are NOT
 | 	// XXX actions.updateRibbon(..) and ribbons.updateRibbon(..) are NOT
 | ||||||
| 	// 		signature compatible...
 | 	// 		signature compatible...
 | ||||||
|  | 	// 		...I'll fix this as/if I need to, right now there is no point to
 | ||||||
|  | 	// 		spend time and effort on unifying the interface when the common
 | ||||||
|  | 	// 		use-cases are not known + it seems quite logical as-is right now.
 | ||||||
| 	reload: ['Reload viewer', | 	reload: ['Reload viewer', | ||||||
| 		function(){ | 		function(){ | ||||||
| 			this.ribbons.preventTransitions() | 			this.ribbons.preventTransitions() | ||||||
| @ -577,11 +580,6 @@ actions.Actions(Client, { | |||||||
| 		function(){ | 		function(){ | ||||||
| 			toggleFullscreenMode()  | 			toggleFullscreenMode()  | ||||||
| 		}], | 		}], | ||||||
| 	toggleSingleImage: ['Toggle single image view',  |  | ||||||
| 		// XXX this is wrong!!!
 |  | ||||||
| 		makeCSSClassToggler( |  | ||||||
| 			function(){ return this.ribbons.viewer },  |  | ||||||
| 			'single-image-mode') ], |  | ||||||
| 	// XXX revise this...
 | 	// XXX revise this...
 | ||||||
| 	showDevTools: ['', | 	showDevTools: ['', | ||||||
| 		function(){ | 		function(){ | ||||||
| @ -591,7 +589,7 @@ actions.Actions(Client, { | |||||||
| 		}], | 		}], | ||||||
| 
 | 
 | ||||||
| 	toggleTheme: ['',  | 	toggleTheme: ['',  | ||||||
| 		makeCSSClassToggler( | 		CSSClassToggler( | ||||||
| 			function(){ return this.ribbons.viewer },  | 			function(){ return this.ribbons.viewer },  | ||||||
| 			[ | 			[ | ||||||
| 				'gray',  | 				'gray',  | ||||||
| @ -792,13 +790,12 @@ actions.Actions(Client, { | |||||||
| 		function(){ this.fitImage(this.config['max-screen-images']) }], | 		function(){ this.fitImage(this.config['max-screen-images']) }], | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	// XXX
 | 	// XXX the question with these is how to make these relatively 
 | ||||||
|  | 	// 		similar across platforms...
 | ||||||
| 	fitSmall: ['Show small image', | 	fitSmall: ['Show small image', | ||||||
| 		function(){  }], | 		function(){  }], | ||||||
| 	// XXX
 |  | ||||||
| 	fitNormal: ['Show normal image', | 	fitNormal: ['Show normal image', | ||||||
| 		function(){  }], | 		function(){  }], | ||||||
| 	// XXX
 |  | ||||||
| 	fitScreen: ['Fit image to screen', | 	fitScreen: ['Fit image to screen', | ||||||
| 		function(){  }], | 		function(){  }], | ||||||
| 
 | 
 | ||||||
| @ -947,36 +944,42 @@ actions.Actions({ | |||||||
| 
 | 
 | ||||||
| 			w = w || this.screenwidth | 			w = w || this.screenwidth | ||||||
| 
 | 
 | ||||||
| 			// get config data...
 | 			threshold = (threshold  | ||||||
| 			size = size  |  | ||||||
| 				|| this.config['ribbon-size-screens']  |  | ||||||
| 				|| 5 |  | ||||||
| 			threshold = threshold  |  | ||||||
| 				|| this.config['ribbon-resize-threshold']  | 				|| this.config['ribbon-resize-threshold']  | ||||||
| 				|| 1 | 				|| 1) * w | ||||||
| 
 |  | ||||||
| 			// normalize to image count...
 |  | ||||||
| 			var s = size * w |  | ||||||
| 			var t = threshold * w |  | ||||||
| 
 | 
 | ||||||
| 			// next/prev loaded... 
 | 			// next/prev loaded... 
 | ||||||
| 			var nl = this.ribbons.getImage(target).nextAll('.image').length | 			var nl = this.ribbons.getImage(target).nextAll('.image').length | ||||||
| 			var pl = this.ribbons.getImage(target).prevAll('.image').length | 			var pl = this.ribbons.getImage(target).prevAll('.image').length | ||||||
| 
 | 
 | ||||||
| 			// next/prev available...
 | 			// next/prev available...
 | ||||||
| 			var na = this.data.getImages(target, s/2, 'after').length - 1  | 			var na = this.data.getImages(target, size/2, 'after').length - 1  | ||||||
| 			var pa = this.data.getImages(target, s/2, 'before').length - 1  | 			var pa = this.data.getImages(target, size/2, 'before').length - 1  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 			// do the update...
 | 			// do the update...
 | ||||||
| 			// the target is not loaded...
 | 			// the target is not loaded...
 | ||||||
| 			if(this.ribbons.getImage(target).length == 0 | 			if(this.ribbons.getImage(target).length == 0 | ||||||
| 					// passed threshold on the right...
 | 					// passed threshold on the right...
 | ||||||
| 					|| (nl < t && na > nl)  | 					|| (nl < threshold && na > nl)  | ||||||
| 					// passed threshold on the left...
 | 					// passed threshold on the left...
 | ||||||
| 					|| (pl < t && pa > pl)  | 					|| (pl < threshold && pa > pl)  | ||||||
| 					// loaded more than we need by threshold...
 | 					// loaded more than we need by threshold...
 | ||||||
| 					|| nl + pl + 1 > s + t){ | 					|| nl + pl + 1 > size + threshold){ | ||||||
|  | 
 | ||||||
|  | 				// get config data and normalize...
 | ||||||
|  | 				size = (size  | ||||||
|  | 					|| this.config['ribbon-size-screens']  | ||||||
|  | 					|| 5) * w | ||||||
|  | 
 | ||||||
|  | 				this.resizeRibbon(target, size) | ||||||
|  | 			} | ||||||
|  | 		}], | ||||||
|  | 	resizeRibbon: ['Resize ribbon to n images', | ||||||
|  | 		function(target, size){ | ||||||
|  | 			size = size  | ||||||
|  | 				|| (this.config['ribbon-size-screens'] * this.screenwidth) | ||||||
|  | 				|| (5 * this.screenwidth) | ||||||
| 
 | 
 | ||||||
| 			// NOTE: we can't get ribbon via target directly here as
 | 			// NOTE: we can't get ribbon via target directly here as
 | ||||||
| 			// 		the target might not be loaded...
 | 			// 		the target might not be loaded...
 | ||||||
| @ -989,12 +992,11 @@ actions.Actions({ | |||||||
| 				this.ribbons | 				this.ribbons | ||||||
| 					.preventTransitions(r) | 					.preventTransitions(r) | ||||||
| 					.updateRibbon( | 					.updateRibbon( | ||||||
| 							this.data.getImages(target, s),  | 						this.data.getImages(target, size),  | ||||||
| 						r_gid, | 						r_gid, | ||||||
| 						target) | 						target) | ||||||
| 					.restoreTransitions(r, true) | 					.restoreTransitions(r, true) | ||||||
| 			} | 			} | ||||||
| 			} |  | ||||||
| 		}] | 		}] | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| @ -1012,17 +1014,24 @@ module.PartialRibbons = Feature({ | |||||||
| 	tag: 'ui-partial-ribbons', | 	tag: 'ui-partial-ribbons', | ||||||
| 
 | 
 | ||||||
| 	// number of screen widths to load...
 | 	// number of screen widths to load...
 | ||||||
| 	size: 5, | 	size: 7, | ||||||
| 
 | 
 | ||||||
| 	// number of screen widths to edge to trigger reload...
 | 	// number of screen widths to edge to trigger reload...
 | ||||||
| 	threshold: 1, | 	threshold: 1.5, | ||||||
| 
 | 
 | ||||||
| 	setup: function(actions){ | 	setup: function(actions){ | ||||||
| 		var feature = this | 		var feature = this | ||||||
| 
 | 
 | ||||||
| 		actions.mixin(PartialRibbonsActions) | 
 | ||||||
|  | 		if(!('ribbon-size-screens' in actions.config)){ | ||||||
|  | 			actions.config['ribbon-size-screens'] = this.size | ||||||
|  | 		} | ||||||
|  | 		if(!('ribbon-resize-threshold' in actions.config)){ | ||||||
|  | 			actions.config['ribbon-resize-threshold'] = this.threshold | ||||||
|  | 		} | ||||||
| 
 | 
 | ||||||
| 		return actions | 		return actions | ||||||
|  | 			.mixin(PartialRibbonsActions) | ||||||
| 			.on('focusImage.pre centerImage.pre', this.tag, function(target){ | 			.on('focusImage.pre centerImage.pre', this.tag, function(target){ | ||||||
| 				this.updateRibbon(target) | 				this.updateRibbon(target) | ||||||
| 			}) | 			}) | ||||||
| @ -1053,6 +1062,50 @@ module.PartialRibbons = Feature({ | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | //---------------------------------------------------------------------
 | ||||||
|  | var SingleImageActions = | ||||||
|  | module.SingleImageActions =  | ||||||
|  | actions.Actions({ | ||||||
|  | 	toggleSingleImage: ['Toggle single image view',  | ||||||
|  | 		// XXX this is wrong!!!
 | ||||||
|  | 		CSSClassToggler( | ||||||
|  | 			function(){ return this.ribbons.viewer },  | ||||||
|  | 			'single-image-mode') ], | ||||||
|  | }) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | var SingleImageView = | ||||||
|  | module.SingleImageView = Feature({ | ||||||
|  | 	tag: 'ui-single-image-view', | ||||||
|  | 
 | ||||||
|  | 	// XXX
 | ||||||
|  | 	setup: function(actions){ | ||||||
|  | 		return actions | ||||||
|  | 			.mixin(SingleImageActions) | ||||||
|  | 			.on('toggleSingleImage.post fitImgae.post', this.tag, function(){  | ||||||
|  | 				// XXX set image proportions...
 | ||||||
|  | 				if(this.toggleSingleImage('?') == 'on'){ | ||||||
|  | 					console.log('!!!! single image: on') | ||||||
|  | 					// XXX
 | ||||||
|  | 
 | ||||||
|  | 				// restore original image size...
 | ||||||
|  | 				} else { | ||||||
|  | 					console.log('!!!! single image: off') | ||||||
|  | 					this.ribbons.viewer.find('.image').css({ | ||||||
|  | 						width: '', | ||||||
|  | 						height: '' | ||||||
|  | 					}) | ||||||
|  | 				} | ||||||
|  | 			}) | ||||||
|  | 	}, | ||||||
|  | 	remove: function(actions){ | ||||||
|  | 		actions.mixout(SingleImageActions) | ||||||
|  | 		return actions.off('*', this.tag) | ||||||
|  | 	}, | ||||||
|  | }) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| //---------------------------------------------------------------------
 | //---------------------------------------------------------------------
 | ||||||
| // XXX this should also define up/down navigation behavior e.g. what to 
 | // XXX this should also define up/down navigation behavior e.g. what to 
 | ||||||
| // 		focus on next/prev ribbon...
 | // 		focus on next/prev ribbon...
 | ||||||
| @ -1062,12 +1115,8 @@ module.AlignRibbonsToImageOrder = Feature({ | |||||||
| 
 | 
 | ||||||
| 	setup: function(actions){ | 	setup: function(actions){ | ||||||
| 		return actions | 		return actions | ||||||
| 			// XXX this can be either pre or post...
 | 			.on('focusImage.post', this.tag,  | ||||||
| 			.on('focusImage.post', this.tag, function(target){ | 					function(){ this.alignByOrder() }) | ||||||
| 				this.alignByOrder(target) |  | ||||||
| 			}) |  | ||||||
| 			// normalize the initial state...
 |  | ||||||
| 			//.focusImage()
 |  | ||||||
| 	}, | 	}, | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| @ -1080,12 +1129,8 @@ module.AlignRibbonsToFirstImage = Feature({ | |||||||
| 
 | 
 | ||||||
| 	setup: function(actions){ | 	setup: function(actions){ | ||||||
| 		return actions | 		return actions | ||||||
| 			// XXX this can be either pre or post...
 | 			.on('focusImage.post', this.tag,  | ||||||
| 			.on('focusImage.post', this.tag, function(target){ | 					function(){ this.alignByFirst() }) | ||||||
| 				this.alignByFirst(target) |  | ||||||
| 			}) |  | ||||||
| 			// normalize the initial state...
 |  | ||||||
| 			//.focusImage()
 |  | ||||||
| 	}, | 	}, | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| @ -1237,7 +1282,7 @@ module.BoundsIndicators = Feature({ | |||||||
| 				}) | 				}) | ||||||
| 	}, | 	}, | ||||||
| 	remove: function(actions){ | 	remove: function(actions){ | ||||||
| 		actions.viewer.find('.' + this.tag).remove() | 		actions.ribbons.viewer.find('.' + this.tag).remove() | ||||||
| 		return actions.off('*', this.tag) | 		return actions.off('*', this.tag) | ||||||
| 	}, | 	}, | ||||||
| }) | }) | ||||||
| @ -1262,12 +1307,12 @@ module.CurrentImageIndicator = Feature({ | |||||||
| 	updateMarker: function(actions, target, update_border){ | 	updateMarker: function(actions, target, update_border){ | ||||||
| 		var scale = actions.ribbons.getScale() | 		var scale = actions.ribbons.getScale() | ||||||
| 		var cur = actions.ribbons.getImage(target) | 		var cur = actions.ribbons.getImage(target) | ||||||
| 		var ribbon = actions.ribbons.getRibbon() | 		var ribbon = actions.ribbons.getRibbon(target) | ||||||
| 		var ribbon_set = actions.ribbons.viewer.find('.ribbon-set') | 		var ribbon_set = actions.ribbons.viewer.find('.ribbon-set') | ||||||
| 
 | 
 | ||||||
| 		var marker = ribbon.find('.current-marker') | 		var marker = ribbon.find('.current-marker') | ||||||
| 
 | 
 | ||||||
| 		// no marker found...
 | 		// no marker found -- either in different ribbon or not created yet...
 | ||||||
| 		if(marker.length == 0){ | 		if(marker.length == 0){ | ||||||
| 			// get marker globally...
 | 			// get marker globally...
 | ||||||
| 			marker = actions.ribbons.viewer.find('.current-marker') | 			marker = actions.ribbons.viewer.find('.current-marker') | ||||||
| @ -1292,14 +1337,25 @@ module.CurrentImageIndicator = Feature({ | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | 		// NOTE: we will update only the attrs that need to be updated...
 | ||||||
|  | 		var css = {} | ||||||
|  | 
 | ||||||
| 		var w = cur.outerWidth(true) | 		var w = cur.outerWidth(true) | ||||||
| 		var h = cur.outerHeight(true) | 		var h = cur.outerHeight(true) | ||||||
| 
 | 
 | ||||||
|  | 		// keep size same as the image...
 | ||||||
|  | 		if(marker.outerWidth() != w || marker.outerHeight() != h){ | ||||||
|  | 			css.width = w | ||||||
|  | 			css.height = h | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		// update border...
 | ||||||
|  | 		if(update_border !== false){ | ||||||
| 			var border = Math.max(this.min_border, this.border / scale) | 			var border = Math.max(this.min_border, this.border / scale) | ||||||
| 
 | 
 | ||||||
| 			// set border right away...
 | 			// set border right away...
 | ||||||
| 			if(update_border == 'before'){ | 			if(update_border == 'before'){ | ||||||
| 			marker.css({ borderWidth: border })  | 				css.borderWidth = border | ||||||
| 
 | 
 | ||||||
| 			// set border with a delay...
 | 			// set border with a delay...
 | ||||||
| 			} else { | 			} else { | ||||||
| @ -1307,14 +1363,11 @@ module.CurrentImageIndicator = Feature({ | |||||||
| 					marker.css({ borderWidth: border })  | 					marker.css({ borderWidth: border })  | ||||||
| 				}, this.border_timeout) | 				}, this.border_timeout) | ||||||
| 			} | 			} | ||||||
|  | 		} | ||||||
| 
 | 
 | ||||||
| 		return marker.css({ | 		css.left = cur[0].offsetLeft | ||||||
| 			left: cur[0].offsetLeft, |  | ||||||
| 
 | 
 | ||||||
| 			// keep size same as the image...
 | 		return marker.css(css) | ||||||
| 			width: w, |  | ||||||
| 			height: h, |  | ||||||
| 		}) |  | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
| 	setup: function(actions){ | 	setup: function(actions){ | ||||||
| @ -1323,7 +1376,7 @@ module.CurrentImageIndicator = Feature({ | |||||||
| 		return actions | 		return actions | ||||||
| 			// move marker to current image...
 | 			// move marker to current image...
 | ||||||
| 			.on( 'focusImage.post', this.tag,  | 			.on( 'focusImage.post', this.tag,  | ||||||
| 					function(target){ that.updateMarker(this, target) }) | 					function(){ that.updateMarker(this) }) | ||||||
| 			// prevent animations when focusing ribbons...
 | 			// prevent animations when focusing ribbons...
 | ||||||
| 			.on('focusRibbon.pre', this.tag,  | 			.on('focusRibbon.pre', this.tag,  | ||||||
| 					function(){ | 					function(){ | ||||||
| @ -1333,6 +1386,17 @@ module.CurrentImageIndicator = Feature({ | |||||||
| 							this.ribbons.restoreTransitions(m) | 							this.ribbons.restoreTransitions(m) | ||||||
| 						} | 						} | ||||||
| 					}) | 					}) | ||||||
|  | 			// this is here to compensate for position change on ribbon 
 | ||||||
|  | 			// resize...
 | ||||||
|  | 			.on('resizeRibbon.post', this.tag,  | ||||||
|  | 					function(target, s){ | ||||||
|  | 						var m = this.ribbons.viewer.find('.current-marker') | ||||||
|  | 						if(m.length != 0){ | ||||||
|  | 							this.ribbons.preventTransitions(m) | ||||||
|  | 							that.updateMarker(this, target, false) | ||||||
|  | 							this.ribbons.restoreTransitions(m, true) | ||||||
|  | 						} | ||||||
|  | 					}) | ||||||
| 			// Change border size in the appropriate spot in the animation:
 | 			// Change border size in the appropriate spot in the animation:
 | ||||||
| 			// 	- before animation when scaling up
 | 			// 	- before animation when scaling up
 | ||||||
| 			// 	- after when scaling down
 | 			// 	- after when scaling down
 | ||||||
| @ -1364,7 +1428,7 @@ module.CurrentImageIndicator = Feature({ | |||||||
| 			//.focusImage()
 | 			//.focusImage()
 | ||||||
| 	}, | 	}, | ||||||
| 	remove: function(actions){ | 	remove: function(actions){ | ||||||
| 		actions.viewer.find('.' + this.tag).remove() | 		actions.ribbons.viewer.find('.' + this.tag).remove() | ||||||
| 		return actions.off('*', this.tag) | 		return actions.off('*', this.tag) | ||||||
| 	}, | 	}, | ||||||
| }) | }) | ||||||
| @ -1380,7 +1444,7 @@ module.ImageStateIndicator = Feature({ | |||||||
| 	setup: function(actions){ | 	setup: function(actions){ | ||||||
| 	}, | 	}, | ||||||
| 	remove: function(actions){ | 	remove: function(actions){ | ||||||
| 		actions.viewer.find('.' + this.tag).remove() | 		actions.ribbons.viewer.find('.' + this.tag).remove() | ||||||
| 		return actions.off('*', this.tag) | 		return actions.off('*', this.tag) | ||||||
| 	}, | 	}, | ||||||
| }) | }) | ||||||
| @ -1396,7 +1460,7 @@ module.GlobalStateIndicator = Feature({ | |||||||
| 	setup: function(actions){ | 	setup: function(actions){ | ||||||
| 	}, | 	}, | ||||||
| 	remove: function(actions){ | 	remove: function(actions){ | ||||||
| 		actions.viewer.find('.' + this.tag).remove() | 		actions.ribbons.viewer.find('.' + this.tag).remove() | ||||||
| 		return actions.off('*', this.tag) | 		return actions.off('*', this.tag) | ||||||
| 	}, | 	}, | ||||||
| }) | }) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user