mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	some refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									2e43544625
								
							
						
					
					
						commit
						edea39a2de
					
				| @ -390,7 +390,7 @@ module.DataPrototype = { | |||||||
| 
 | 
 | ||||||
| 		// normalize mode...
 | 		// normalize mode...
 | ||||||
| 		if(mode != null  | 		if(mode != null  | ||||||
| 				&& mode.constructor.name == 'Array'  | 				&& mode.constructor === Array | ||||||
| 				|| mode in this.ribbons){ | 				|| mode in this.ribbons){ | ||||||
| 			list = mode | 			list = mode | ||||||
| 			mode = null | 			mode = null | ||||||
| @ -568,7 +568,7 @@ module.DataPrototype = { | |||||||
| 			target = null  | 			target = null  | ||||||
| 
 | 
 | ||||||
| 		// filter out the unloaded gids from given list...
 | 		// filter out the unloaded gids from given list...
 | ||||||
| 		} else if(target != null && target.constructor.name == 'Array'){ | 		} else if(target != null && target.constructor === Array){ | ||||||
| 			var loaded = this.getImages('loaded') | 			var loaded = this.getImages('loaded') | ||||||
| 			list = target.filter(function(e){ | 			list = target.filter(function(e){ | ||||||
| 				return loaded.indexOf(e) >= 0 | 				return loaded.indexOf(e) >= 0 | ||||||
| @ -943,7 +943,7 @@ module.DataPrototype = { | |||||||
| 	shiftImage: function(from, target, mode){ | 	shiftImage: function(from, target, mode){ | ||||||
| 		from = from == null ? this.current : from | 		from = from == null ? this.current : from | ||||||
| 		from = from == 'current' ? this.current : from | 		from = from == 'current' ? this.current : from | ||||||
| 		from = from.constructor.name != 'Array' ? [from] : from | 		from = from.constructor !== Array ? [from] : from | ||||||
| 		mode = mode == null ? 'after' : mode | 		mode = mode == null ? 'after' : mode | ||||||
| 		var ribbons = this.ribbons | 		var ribbons = this.ribbons | ||||||
| 		var order = this.order | 		var order = this.order | ||||||
| @ -1060,7 +1060,7 @@ module.DataPrototype = { | |||||||
| 	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
 | ||||||
| 	shiftImageUp: function(gid){  | 	shiftImageUp: function(gid){  | ||||||
| 		var g = gid.constructor.name == 'Array' ? gid[0] : gid | 		var g = gid.constructor === Array ? gid[0] : gid | ||||||
| 		var r = this.getRibbonOrder(g) | 		var r = this.getRibbonOrder(g) | ||||||
| 		// check if we need to create a ribbon here...
 | 		// check if we need to create a ribbon here...
 | ||||||
| 		if(r == 0){ | 		if(r == 0){ | ||||||
| @ -1075,7 +1075,7 @@ module.DataPrototype = { | |||||||
| 		return res | 		return res | ||||||
| 	}, | 	}, | ||||||
| 	shiftImageDown: function(gid){  | 	shiftImageDown: function(gid){  | ||||||
| 		var g = gid.constructor.name == 'Array' ? gid[0] : gid | 		var g = gid.constructor === Array ? gid[0] : gid | ||||||
| 		var r = this.getRibbonOrder(g) | 		var r = this.getRibbonOrder(g) | ||||||
| 		// check if we need to create a ribbon here...
 | 		// check if we need to create a ribbon here...
 | ||||||
| 		if(r == this.ribbon_order.length-1){ | 		if(r == this.ribbon_order.length-1){ | ||||||
| @ -1174,7 +1174,7 @@ module.DataPrototype = { | |||||||
| 		if(arguments.length > 1){ | 		if(arguments.length > 1){ | ||||||
| 			target = Array.apply(null, arguments) | 			target = Array.apply(null, arguments) | ||||||
| 		} else if(target == null  | 		} else if(target == null  | ||||||
| 				|| target.constructor.name != 'Array'){ | 				|| target.constructor !== Array){ | ||||||
| 			target = [ target ] | 			target = [ target ] | ||||||
| 		} | 		} | ||||||
| 		var res = [] | 		var res = [] | ||||||
| @ -1230,7 +1230,7 @@ module.DataPrototype = { | |||||||
| 	join: function(){ | 	join: function(){ | ||||||
| 		var args = Array.apply(null, arguments) | 		var args = Array.apply(null, arguments) | ||||||
| 		var align = typeof(args[0]) == typeof('str') ? args.splice(0, 1)[0] : 'base' | 		var align = typeof(args[0]) == typeof('str') ? args.splice(0, 1)[0] : 'base' | ||||||
| 		args = args[0].constructor.name == 'Array' ? args[0] : args | 		args = args[0].constructor === Array ? args[0] : args | ||||||
| 
 | 
 | ||||||
| 		var base = this | 		var base = this | ||||||
| 
 | 
 | ||||||
| @ -1605,7 +1605,7 @@ var Data = | |||||||
| module.Data = | module.Data = | ||||||
| function Data(json){ | function Data(json){ | ||||||
| 	// in case this is called as a function (without new)...
 | 	// in case this is called as a function (without new)...
 | ||||||
| 	if(this.constructor.name != 'Data'){ | 	if(this.constructor !== Data){ | ||||||
| 		return new Data(json) | 		return new Data(json) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -286,7 +286,7 @@ module.ImagesPrototype = { | |||||||
| 	// XXX test out the attr list functionality...
 | 	// XXX test out the attr list functionality...
 | ||||||
| 	makeIndex: function(attr){ | 	makeIndex: function(attr){ | ||||||
| 		var res = {} | 		var res = {} | ||||||
| 		attr = attr.constructor.name != 'Array' ? [attr] : attr | 		attr = attr.constructor !== Array ? [attr] : attr | ||||||
| 
 | 
 | ||||||
| 		// buld the index...
 | 		// buld the index...
 | ||||||
| 		var that = this | 		var that = this | ||||||
| @ -360,7 +360,7 @@ module.ImagesPrototype = { | |||||||
| 		gids = gids == null ? Object.keys(this) : gids | 		gids = gids == null ? Object.keys(this) : gids | ||||||
| 
 | 
 | ||||||
| 		cmp = cmp == null ? module.makeImageDateCmp(this) : cmp | 		cmp = cmp == null ? module.makeImageDateCmp(this) : cmp | ||||||
| 		cmp = cmp.constructor.name == 'Array' ? chainCmp(cmp) : cmp | 		cmp = cmp.constructor === Array ? chainCmp(cmp) : cmp | ||||||
| 
 | 
 | ||||||
| 		gids = gids.sort(cmp) | 		gids = gids.sort(cmp) | ||||||
| 		gids = reverse ? gids.reverse() : gids | 		gids = reverse ? gids.reverse() : gids | ||||||
| @ -408,7 +408,7 @@ module.ImagesPrototype = { | |||||||
| 	//
 | 	//
 | ||||||
| 	// NOTE: target can be a gid or a list of gids...
 | 	// NOTE: target can be a gid or a list of gids...
 | ||||||
| 	rotateImage: function(gids, direction){ | 	rotateImage: function(gids, direction){ | ||||||
| 		gids = gids.constructor.name != 'Array' ? [gids] : gids | 		gids = gids.constructor !== Array ? [gids] : gids | ||||||
| 		// validate direction...
 | 		// validate direction...
 | ||||||
| 		if(module.calcRelativeRotation(direction) == null){ | 		if(module.calcRelativeRotation(direction) == null){ | ||||||
| 			return this | 			return this | ||||||
| @ -441,7 +441,7 @@ module.ImagesPrototype = { | |||||||
| 	//		-> images
 | 	//		-> images
 | ||||||
| 	//
 | 	//
 | ||||||
| 	flipImage: function(gids, direction){ | 	flipImage: function(gids, direction){ | ||||||
| 		gids = gids.constructor.name != 'Array' ? [gids] : gids | 		gids = gids.constructor !== Array ? [gids] : gids | ||||||
| 		var that = this | 		var that = this | ||||||
| 		gids.forEach(function(key){ | 		gids.forEach(function(key){ | ||||||
| 			var img = that[key] | 			var img = that[key] | ||||||
| @ -492,7 +492,7 @@ var Images = | |||||||
| module.Images = | module.Images = | ||||||
| function Images(json){ | function Images(json){ | ||||||
| 	// in case this is called as a function (without new)...
 | 	// in case this is called as a function (without new)...
 | ||||||
| 	if(this.constructor.name != 'Images'){ | 	if(this.constructor !== Images){ | ||||||
| 		return new Images(json) | 		return new Images(json) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -151,7 +151,7 @@ function doc(text, func){ | |||||||
| var normalizeModifiers = | var normalizeModifiers = | ||||||
| module.normalizeModifiers = | module.normalizeModifiers = | ||||||
| function normalizeModifiers(c, a, s){ | function normalizeModifiers(c, a, s){ | ||||||
| 		if(c != null && c.constructor.name == 'Array'){ | 		if(c != null && c.constructor === Array){ | ||||||
| 			a = c[1] | 			a = c[1] | ||||||
| 			s = c[2] | 			s = c[2] | ||||||
| 			c = c[0] | 			c = c[0] | ||||||
| @ -331,12 +331,7 @@ function getKeyHandlers(key, modifiers, keybindings, modes, shifted_keys, action | |||||||
| 
 | 
 | ||||||
| 		// alias...
 | 		// alias...
 | ||||||
| 		// XXX should this be before after or combined with ignore handling...
 | 		// XXX should this be before after or combined with ignore handling...
 | ||||||
| 		while( handler != null  | 		while( handler != null && typeof(handler) != 'function'){ | ||||||
| 				&& typeof(handler) != 'function'){ |  | ||||||
| 				//&& (typeof(handler) == typeof(123) 
 |  | ||||||
| 				//	|| typeof(handler) == typeof('str')
 |  | ||||||
| 				//	|| typeof(handler) == typeof({}) 
 |  | ||||||
| 				//		&& handler.constructor.name == 'Object') ){
 |  | ||||||
| 
 | 
 | ||||||
| 			// do the complex handler aliases...
 | 			// do the complex handler aliases...
 | ||||||
| 			if(handler != null && handler.constructor == Object){ | 			if(handler != null && handler.constructor == Object){ | ||||||
| @ -688,7 +683,7 @@ function buildKeybindingsHelp(keybindings, shifted_keys, actions){ | |||||||
| 
 | 
 | ||||||
| 				var handler = getKeyHandlers(key, mod, keybindings, 'all', null, actions)[pattern] | 				var handler = getKeyHandlers(key, mod, keybindings, 'all', null, actions)[pattern] | ||||||
| 
 | 
 | ||||||
| 				if(handler.constructor.name == 'Array' && handler[1] == 'IGNORE NEXT'){ | 				if(handler.constructor === Array && handler[1] == 'IGNORE NEXT'){ | ||||||
| 					handler = handler[0] | 					handler = handler[0] | ||||||
| 				} | 				} | ||||||
| 
 | 
 | ||||||
| @ -697,7 +692,7 @@ function buildKeybindingsHelp(keybindings, shifted_keys, actions){ | |||||||
| 					var doc = handler.doc | 					var doc = handler.doc | ||||||
| 
 | 
 | ||||||
| 				// lisp style...
 | 				// lisp style...
 | ||||||
| 				} else if(handler.constructor.name == 'Array'){ | 				} else if(handler.constructor === Array){ | ||||||
| 					var doc = handler[1] | 					var doc = handler[1] | ||||||
| 
 | 
 | ||||||
| 				// no doc...
 | 				// no doc...
 | ||||||
|  | |||||||
| @ -23,49 +23,6 @@ var IMAGE_UPDATERS = | |||||||
| module.IMAGE_UPDATERS = [] | module.IMAGE_UPDATERS = [] | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /*********************************************************************/ |  | ||||||
| 
 |  | ||||||
| // XXX add inheritance...
 |  | ||||||
| var makeObject = |  | ||||||
| module.makeObject = |  | ||||||
| function makeObject(name, cls, obj){ |  | ||||||
| 	// NOTE: we are using eval here to name the function correctly as
 |  | ||||||
| 	// 		simply assigning .name does not work...
 |  | ||||||
| 	// 		XXX think of a cleaner way...
 |  | ||||||
| 	var O = function OBJECT(){ |  | ||||||
| 		if(this.constructor.name != name){ |  | ||||||
| 			return new (Function.prototype.bind.apply( |  | ||||||
| 				OBJECT, |  | ||||||
| 				arguments.length == 1 ? [null, arguments[0]] |  | ||||||
| 					: [null].concat(Array.apply(null, arguments)))) |  | ||||||
| 		} |  | ||||||
| 	 |  | ||||||
| 		if(this.__init__ != null){ |  | ||||||
| 			this.__init__.apply(this, arguments) |  | ||||||
| 		} |  | ||||||
| 	 |  | ||||||
| 		return this |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	if(name != null){ |  | ||||||
| 		O = eval(O |  | ||||||
| 			.toString() |  | ||||||
| 			.replace(/OBJRCT/g, name)) |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	if(cls != null){ |  | ||||||
| 		O.__proto__ = cls |  | ||||||
| 	} |  | ||||||
| 	if(obj != null){ |  | ||||||
| 		O.prototype = obj |  | ||||||
| 	} |  | ||||||
| 	O.prototype.constructor = O |  | ||||||
| 
 |  | ||||||
| 	return O |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| /*********************************************************************/ | /*********************************************************************/ | ||||||
| //
 | //
 | ||||||
| // This expects the following HTML structure...
 | // This expects the following HTML structure...
 | ||||||
| @ -1165,7 +1122,7 @@ module.RibbonsPrototype = { | |||||||
| 
 | 
 | ||||||
| 		// clear one or more gids...
 | 		// clear one or more gids...
 | ||||||
| 		} else { | 		} else { | ||||||
| 			gids = gids.constructor.name != 'Array' ? [gids] : gids | 			gids = gids.constructor !== Array ? [gids] : gids | ||||||
| 			var that = this | 			var that = this | ||||||
| 			gids.forEach(function(g){ | 			gids.forEach(function(g){ | ||||||
| 				that.viewer.find('[gid='+JSON.stringify(g)+']').remove() | 				that.viewer.find('[gid='+JSON.stringify(g)+']').remove() | ||||||
| @ -1255,7 +1212,7 @@ module.RibbonsPrototype = { | |||||||
| 			image = null | 			image = null | ||||||
| 		} | 		} | ||||||
| 		image = this.getImage(image)  | 		image = this.getImage(image)  | ||||||
| 		cls = cls.constructor.name != 'Array' ? [cls] : cls | 		cls = cls.constructor !== Array ? [cls] : cls | ||||||
| 		action = action == null ? 'toggle' : action | 		action = action == null ? 'toggle' : action | ||||||
| 
 | 
 | ||||||
| 		// no image is loaded...
 | 		// no image is loaded...
 | ||||||
| @ -1361,7 +1318,7 @@ module.RibbonsPrototype = { | |||||||
| 	// 		loaded images vertically.
 | 	// 		loaded images vertically.
 | ||||||
| 	flipImage: function(target, direction){ | 	flipImage: function(target, direction){ | ||||||
| 		target = this.getImage(target) | 		target = this.getImage(target) | ||||||
| 		var set_state = direction.constructor.name == 'Array' ? direction : null | 		var set_state = direction.constructor === Array ? direction : null | ||||||
| 		target.each(function(i, e){ | 		target.each(function(i, e){ | ||||||
| 			var img = $(this) | 			var img = $(this) | ||||||
| 
 | 
 | ||||||
| @ -1566,7 +1523,7 @@ var Ribbons = | |||||||
| module.Ribbons = | module.Ribbons = | ||||||
| function Ribbons(viewer, images){ | function Ribbons(viewer, images){ | ||||||
| 	// in case this is called as a function (without new)...
 | 	// in case this is called as a function (without new)...
 | ||||||
| 	if(this.constructor.name != 'Ribbons'){ | 	if(this.constructor !== Ribbons){ | ||||||
| 		return new Ribbons(viewer, images) | 		return new Ribbons(viewer, images) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -83,10 +83,7 @@ module.GLOBAL_KEYBOARD = { | |||||||
| 
 | 
 | ||||||
| 		// NOTE: this is handled by the wrapper at this point, so we do 
 | 		// NOTE: this is handled by the wrapper at this point, so we do 
 | ||||||
| 		// 		not have to do anything here...
 | 		// 		not have to do anything here...
 | ||||||
| 		F11: doc('Toggle full screen view', function(){  | 		F11: 'toggleFullScreen',  | ||||||
| 				toggleFullscreenMode()  |  | ||||||
| 				return false |  | ||||||
| 			}), |  | ||||||
| 		F: { | 		F: { | ||||||
| 			ctrl: 'F11', | 			ctrl: 'F11', | ||||||
| 		}, | 		}, | ||||||
| @ -155,7 +152,7 @@ $(function(){ | |||||||
| 
 | 
 | ||||||
| 	window.a = testing.setupActions() | 	window.a = testing.setupActions() | ||||||
| 
 | 
 | ||||||
| 	viewer.Animation.setup(a) | 	viewer.ShiftAnimation.setup(a) | ||||||
| 	viewer.BoundsIndicators.setup(a) | 	viewer.BoundsIndicators.setup(a) | ||||||
| 
 | 
 | ||||||
| 	// this publishes all the actions...
 | 	// this publishes all the actions...
 | ||||||
|  | |||||||
| @ -395,6 +395,29 @@ actions.Actions({ | |||||||
| 		function(){ | 		function(){ | ||||||
| 			// XXX
 | 			// XXX
 | ||||||
| 		}], | 		}], | ||||||
|  | 
 | ||||||
|  | 	cropRibbon: ['Crop current ribbon', | ||||||
|  | 		function(ribbon, flatten){ | ||||||
|  | 			ribbon = ribbon || 'current' | ||||||
|  | 			this.crop(this.data.getImages(ribbon), flatten) | ||||||
|  | 		}], | ||||||
|  | 	cropRibbonAndAbove: ['Crop current and above ribbons', | ||||||
|  | 		function(ribbon, flatten){ | ||||||
|  | 			ribbon = ribbon || this.data.getRibbon() | ||||||
|  | 
 | ||||||
|  | 			var data = this.data | ||||||
|  | 			var that = this | ||||||
|  | 
 | ||||||
|  | 			var i = data.ribbon_order.indexOf(ribbon) | ||||||
|  | 			var ribbons = data.ribbon_order.slice(0, i) | ||||||
|  | 			var images = ribbons | ||||||
|  | 				.reduce(function(a, b){  | ||||||
|  | 						return data.getImages(a).concat(data.getImages(b))  | ||||||
|  | 					}, data.getImages(ribbon)) | ||||||
|  | 				.compact() | ||||||
|  | 
 | ||||||
|  | 			this.crop(data.getImages(images), flatten) | ||||||
|  | 		}], | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -609,10 +632,6 @@ actions.Actions(Client, { | |||||||
| 	shiftImageUp: [ reloadAfter() ], | 	shiftImageUp: [ reloadAfter() ], | ||||||
| 	shiftImageDown: [ reloadAfter() ], | 	shiftImageDown: [ reloadAfter() ], | ||||||
| 
 | 
 | ||||||
| 	// NOTE: .shiftImageDownNewRibbon(..) and .shiftImageUpNewRibbon(..)
 |  | ||||||
| 	// 		are not needed here when doing a reload on vertical 
 |  | ||||||
| 	// 		shifting...
 |  | ||||||
| 
 |  | ||||||
| 	shiftImageLeft: [ | 	shiftImageLeft: [ | ||||||
| 		function(target){ | 		function(target){ | ||||||
| 			this.ribbons.placeImage(target, -1) | 			this.ribbons.placeImage(target, -1) | ||||||
| @ -659,30 +678,6 @@ actions.Actions(Client, { | |||||||
| 
 | 
 | ||||||
| 	crop: [ reloadAfter() ], | 	crop: [ reloadAfter() ], | ||||||
| 	uncrop: [ reloadAfter() ], | 	uncrop: [ reloadAfter() ], | ||||||
| 
 |  | ||||||
| 	// XXX need flat version of these...
 |  | ||||||
| 	cropRibbon: ['Crop current ribbon', |  | ||||||
| 		function(ribbon, flatten){ |  | ||||||
| 			ribbon = ribbon || 'current' |  | ||||||
| 			this.crop(this.data.getImages(ribbon), flatten) |  | ||||||
| 		}], |  | ||||||
| 	cropRibbonAndAbove: ['', |  | ||||||
| 		function(ribbon, flatten){ |  | ||||||
| 			ribbon = ribbon || this.data.getRibbon() |  | ||||||
| 
 |  | ||||||
| 			var data = this.data |  | ||||||
| 			var that = this |  | ||||||
| 
 |  | ||||||
| 			var i = data.ribbon_order.indexOf(ribbon) |  | ||||||
| 			var ribbons = data.ribbon_order.slice(0, i) |  | ||||||
| 			var images = ribbons |  | ||||||
| 				.reduce(function(a, b){  |  | ||||||
| 						return data.getImages(a).concat(data.getImages(b))  |  | ||||||
| 					}, data.getImages(ribbon)) |  | ||||||
| 				.compact() |  | ||||||
| 
 |  | ||||||
| 			this.crop(data.getImages(images), flatten) |  | ||||||
| 		}], |  | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -692,8 +687,8 @@ actions.Actions(Client, { | |||||||
| // 		...need something like:
 | // 		...need something like:
 | ||||||
| // 			Features(['feature_a', 'feature_b'], action).setup()
 | // 			Features(['feature_a', 'feature_b'], action).setup()
 | ||||||
| 
 | 
 | ||||||
| var Animation = | var ShiftAnimation = | ||||||
| module.Animation = { | module.ShiftAnimation = { | ||||||
| 	tag: 'ui-animation', | 	tag: 'ui-animation', | ||||||
| 
 | 
 | ||||||
| 	setup: function(actions){ | 	setup: function(actions){ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user