mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	some refactoring and cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									830e1f9cc5
								
							
						
					
					
						commit
						91b8d0bce0
					
				| @ -1135,8 +1135,8 @@ module.TagsEditActions = actions.Actions({ | |||||||
| 		{journal: true}, | 		{journal: true}, | ||||||
| 		function(tags, gids){ | 		function(tags, gids){ | ||||||
| 			gids = gids || this.current | 			gids = gids || this.current | ||||||
| 			gids = gids.constructor !== Array ? [gids] : gids | 			gids = gids instanceof Array ? gids : [gids] | ||||||
| 			tags = tags.constructor !== Array ? [tags] : tags | 			tags = tags instanceof Array ? tags : [tags] | ||||||
| 
 | 
 | ||||||
| 			var that = this | 			var that = this | ||||||
| 			gids = gids.map(function(gid){ return that.data.getImage(gid) }) | 			gids = gids.map(function(gid){ return that.data.getImage(gid) }) | ||||||
| @ -1165,8 +1165,8 @@ module.TagsEditActions = actions.Actions({ | |||||||
| 		{journal: true}, | 		{journal: true}, | ||||||
| 		function(tags, gids){ | 		function(tags, gids){ | ||||||
| 			gids = gids || this.current | 			gids = gids || this.current | ||||||
| 			gids = gids.constructor !== Array ? [gids] : gids | 			gids = gids instanceof Array ? gids : [gids] | ||||||
| 			tags = tags.constructor !== Array ? [tags] : tags | 			tags = tags instanceof Array ? tags : [tags] | ||||||
| 
 | 
 | ||||||
| 			// data...
 | 			// data...
 | ||||||
| 			this.data.untag(tags, gids) | 			this.data.untag(tags, gids) | ||||||
| @ -1258,13 +1258,13 @@ module.TagsEdit = core.ImageGridFeatures.Feature({ | |||||||
| 				var changes = [] | 				var changes = [] | ||||||
| 
 | 
 | ||||||
| 				gids = gids || [this.data.getImage()] | 				gids = gids || [this.data.getImage()] | ||||||
| 				gids = gids.constructor !== Array ?  | 				gids = gids instanceof Array ?  | ||||||
| 					[this.data.getImage(gids)]  | 					gids | ||||||
| 					: gids |  | ||||||
| 						.map(function(e){ return that.data.getImage(e) }) | 						.map(function(e){ return that.data.getImage(e) }) | ||||||
|  | 					: [this.data.getImage(gids)]  | ||||||
| 
 | 
 | ||||||
| 				tags = tags || [] | 				tags = tags || [] | ||||||
| 				tags = tags.constructor !== Array ? [tags] : tags | 				tags = tags instanceof Array ? tags : [tags] | ||||||
| 
 | 
 | ||||||
| 				// tags...
 | 				// tags...
 | ||||||
| 				if(tags.length > 0){ | 				if(tags.length > 0){ | ||||||
|  | |||||||
| @ -1025,6 +1025,15 @@ module.CollectionTags = core.ImageGridFeatures.Feature({ | |||||||
| // 		only???
 | // 		only???
 | ||||||
| // XXX do we need real tag queries???
 | // XXX do we need real tag queries???
 | ||||||
| var AutoTagCollectionsActions = actions.Actions({ | var AutoTagCollectionsActions = actions.Actions({ | ||||||
|  | 	config: { | ||||||
|  | 		// Can be:
 | ||||||
|  | 		// 	'ignore-local' (default)
 | ||||||
|  | 		// 	'main-collection-local'
 | ||||||
|  | 		//'auto-collection-tags-mode': 'ignore-local',
 | ||||||
|  | 		'auto-collection-tags-mode': 'main-collection-local', | ||||||
|  | 	}, | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 	collectionAutoTagsLoader: ['- Collections/', | 	collectionAutoTagsLoader: ['- Collections/', | ||||||
| 		core.doc` | 		core.doc` | ||||||
| 
 | 
 | ||||||
| @ -1034,16 +1043,17 @@ var AutoTagCollectionsActions = actions.Actions({ | |||||||
| 		{collectionFormat: 'tag_query'}, | 		{collectionFormat: 'tag_query'}, | ||||||
| 		function(title, state){  | 		function(title, state){  | ||||||
| 			return new Promise((function(resolve){ | 			return new Promise((function(resolve){ | ||||||
|  | 				var local_tags_mode = this.config['auto-collection-tags-mode'] || 'ignore-local' | ||||||
| 				var local_tag_names = this.config['collection-local-tags'] || [] | 				var local_tag_names = this.config['collection-local-tags'] || [] | ||||||
| 
 | 
 | ||||||
| 				var tags = (state.tag_query || []) | 				var tags = (state.tag_query || []) | ||||||
| 					// filter out local tags...
 | 					.filter(function(tag){  | ||||||
| 					.filter(function(tag){ return local_tag_names.indexOf(tag) < 0 }) | 						return local_tag_names.indexOf(tag) < 0 }) | ||||||
| 
 | 
 | ||||||
| 				// XXX should this be a real tag query???
 | 				// XXX should this be a real tag query???
 | ||||||
| 				var gids = this.data.getTaggedByAll(tags) | 				var gids = this.data.getTaggedByAll(tags) | ||||||
| 
 | 
 | ||||||
| 				// get unmatching...
 | 				// get items that topped matching the query...
 | ||||||
| 				var remove = state.data ? | 				var remove = state.data ? | ||||||
| 					state.data.order | 					state.data.order | ||||||
| 						.filter(function(gid){ return gids.indexOf(gid) < 0 }) | 						.filter(function(gid){ return gids.indexOf(gid) < 0 }) | ||||||
|  | |||||||
| @ -84,7 +84,7 @@ function(attr, states, a, b){ | |||||||
| 
 | 
 | ||||||
| 	return toggler.Toggler(null, | 	return toggler.Toggler(null, | ||||||
| 		function(_, action){ | 		function(_, action){ | ||||||
| 			var lst = states.constructor === Array ? states  | 			var lst = states instanceof Array ? states  | ||||||
| 				: states instanceof Function ? states.call(this) | 				: states instanceof Function ? states.call(this) | ||||||
| 				: states | 				: states | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -44,7 +44,7 @@ function makeTagTogglerAction(tag){ | |||||||
| 					? this.data.getImages(target) | 					? this.data.getImages(target) | ||||||
| 			: target == 'ribbon' ? this.data.getImages('current') | 			: target == 'ribbon' ? this.data.getImages('current') | ||||||
| 			: target | 			: target | ||||||
| 		return target.constructor !== Array ? [target] : target | 		return target instanceof Array ? target : [target] | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// the toggler...
 | 	// the toggler...
 | ||||||
|  | |||||||
| @ -506,7 +506,7 @@ actions.Actions({ | |||||||
| 	// tags...
 | 	// tags...
 | ||||||
| 	tag: [  | 	tag: [  | ||||||
| 		function(tags, gids){  | 		function(tags, gids){  | ||||||
| 			gids = gids != null && gids.constructor !== Array ? [gids] : gids | 			gids = (gids instanceof Array || gids == null) ? gids : [gids] | ||||||
| 			return function(){ | 			return function(){ | ||||||
| 				//this.ribbons.updateImage(gids) 
 | 				//this.ribbons.updateImage(gids) 
 | ||||||
| 				this.refresh(gids) | 				this.refresh(gids) | ||||||
| @ -514,7 +514,7 @@ actions.Actions({ | |||||||
| 		}], | 		}], | ||||||
| 	untag: [ | 	untag: [ | ||||||
| 		function(tags, gids){  | 		function(tags, gids){  | ||||||
| 			gids = gids != null && gids.constructor !== Array ? [gids] : gids | 			gids = (gids instanceof Array || gids == null) ? gids : [gids] | ||||||
| 			return function(){ | 			return function(){ | ||||||
| 				//this.ribbons.updateImage(gids) 
 | 				//this.ribbons.updateImage(gids) 
 | ||||||
| 				this.refresh(gids) | 				this.refresh(gids) | ||||||
| @ -780,7 +780,7 @@ module.ShiftAnimation = core.ImageGridFeatures.Feature({ | |||||||
| 		['shiftImageUp.pre shiftImageDown.pre', | 		['shiftImageUp.pre shiftImageDown.pre', | ||||||
| 			function(target){ | 			function(target){ | ||||||
| 				// XXX do not do target lists...
 | 				// XXX do not do target lists...
 | ||||||
| 				if(target != null && target.constructor === Array  | 				if(target != null && target instanceof Array  | ||||||
| 						// do not animate in single image mode...
 | 						// do not animate in single image mode...
 | ||||||
| 						&& this.toggleSingleImage('?') == 'on'){ | 						&& this.toggleSingleImage('?') == 'on'){ | ||||||
| 					return | 					return | ||||||
| @ -796,7 +796,7 @@ module.ShiftAnimation = core.ImageGridFeatures.Feature({ | |||||||
| 		['shiftImageLeft.pre shiftImageRight.pre',  | 		['shiftImageLeft.pre shiftImageRight.pre',  | ||||||
| 			function(target){ | 			function(target){ | ||||||
| 				// XXX do not do target lists...
 | 				// XXX do not do target lists...
 | ||||||
| 				if(target != null && target.constructor === Array | 				if(target != null && target instanceof Array | ||||||
| 						// do not animate in single image mode...
 | 						// do not animate in single image mode...
 | ||||||
| 						&& this.toggleSingleImage('?') == 'on'){ | 						&& this.toggleSingleImage('?') == 'on'){ | ||||||
| 					return | 					return | ||||||
|  | |||||||
| @ -694,7 +694,7 @@ module.StatusBar = core.ImageGridFeatures.Feature({ | |||||||
| 		], | 		], | ||||||
| 			function(res, tags, gids){ | 			function(res, tags, gids){ | ||||||
| 				// trigger only when current image is affected...
 | 				// trigger only when current image is affected...
 | ||||||
| 				if(gids.constructor === Array  | 				if(gids instanceof Array  | ||||||
| 						&& (gids.indexOf('current') >= 0  | 						&& (gids.indexOf('current') >= 0  | ||||||
| 							|| gids.indexOf(this.current) >= 0) | 							|| gids.indexOf(this.current) >= 0) | ||||||
| 						|| this.data.getImage(gids) == this.current){ | 						|| this.data.getImage(gids) == this.current){ | ||||||
|  | |||||||
| @ -811,7 +811,7 @@ var DataPrototype = { | |||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		// normalize target...
 | 		// normalize target...
 | ||||||
| 		if(target in this.ribbons || target.constructor === Array){ | 		if(target in this.ribbons || target instanceof Array){ | ||||||
| 			list = target | 			list = target | ||||||
| 			target = this.current | 			target = this.current | ||||||
| 		} else if(['before', 'after', 'next', 'prev'].indexOf(target) >= 0){ | 		} else if(['before', 'after', 'next', 'prev'].indexOf(target) >= 0){ | ||||||
| @ -829,7 +829,7 @@ var DataPrototype = { | |||||||
| 
 | 
 | ||||||
| 		// normalize mode...
 | 		// normalize mode...
 | ||||||
| 		if(mode != null  | 		if(mode != null  | ||||||
| 				&& mode.constructor === Array | 				&& mode instanceof Array | ||||||
| 				|| mode in this.ribbons){ | 				|| mode in this.ribbons){ | ||||||
| 			list = mode | 			list = mode | ||||||
| 			mode = null | 			mode = null | ||||||
| @ -864,7 +864,7 @@ var DataPrototype = { | |||||||
| 						|| this.getRibbon(this.getImage(target, 'after', this.getImages()))] | 						|| this.getRibbon(this.getImage(target, 'after', this.getImages()))] | ||||||
| 			: list == 'global' ? | 			: list == 'global' ? | ||||||
| 				this.order | 				this.order | ||||||
| 			: list.constructor === Array ?  | 			: list instanceof Array ?  | ||||||
| 				this.makeSparseImages(list) | 				this.makeSparseImages(list) | ||||||
| 			: this.ribbons[this.getRibbon(list)] | 			: this.ribbons[this.getRibbon(list)] | ||||||
| 
 | 
 | ||||||
| @ -1056,7 +1056,7 @@ var 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 === Array){ | 		} else if(target != null && target instanceof Array){ | ||||||
| 			var loaded = count == 'current' ? this.getImages('current') | 			var loaded = count == 'current' ? this.getImages('current') | ||||||
| 				: count in this.ribbons ? this.ribbons[count].compact() | 				: count in this.ribbons ? this.ribbons[count].compact() | ||||||
| 				: typeof(count) == typeof(123) ?  | 				: typeof(count) == typeof(123) ?  | ||||||
| @ -1455,7 +1455,7 @@ var DataPrototype = { | |||||||
| 			mode = from | 			mode = from | ||||||
| 			from = null | 			from = null | ||||||
| 		} | 		} | ||||||
| 		from = from != null && from.constructor !== Array ? [from] : from | 		from = from == null || from instanceof Array ? from : [from] | ||||||
| 
 | 
 | ||||||
| 		var r = this.getRibbon('current') | 		var r = this.getRibbon('current') | ||||||
| 
 | 
 | ||||||
| @ -1786,7 +1786,7 @@ var DataPrototype = { | |||||||
| 		if(from == null){ | 		if(from == null){ | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 		from = from.constructor !== Array ? [from] : from | 		from = from instanceof Array ? from : [from] | ||||||
| 
 | 
 | ||||||
| 		var place | 		var place | ||||||
| 
 | 
 | ||||||
| @ -1832,7 +1832,7 @@ var DataPrototype = { | |||||||
| 	// 		ribbon above or the top ribbon...
 | 	// 		ribbon above or the top ribbon...
 | ||||||
| 	shiftImageUp: function(gid){  | 	shiftImageUp: function(gid){  | ||||||
| 		gid = gid || this.current | 		gid = gid || this.current | ||||||
| 		var g = gid && gid.constructor === Array ? gid[0] : gid | 		var g = gid && gid instanceof 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){ | ||||||
| @ -1852,7 +1852,7 @@ var DataPrototype = { | |||||||
| 	}, | 	}, | ||||||
| 	shiftImageDown: function(gid){  | 	shiftImageDown: function(gid){  | ||||||
| 		gid = gid || this.current | 		gid = gid || this.current | ||||||
| 		var g = gid && gid.constructor === Array ? gid[0] : gid | 		var g = gid && gid instanceof 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){ | ||||||
| @ -2022,7 +2022,7 @@ var DataPrototype = { | |||||||
| 	// XXX test if generated gid is unique...
 | 	// XXX test if generated gid is unique...
 | ||||||
| 	group: function(gids, group){ | 	group: function(gids, group){ | ||||||
| 		gids = gids == null ? this.getImage() : gids | 		gids = gids == null ? this.getImage() : gids | ||||||
| 		gids = gids.constructor !== Array ? [gids] : gids | 		gids = gids instanceof Array ? gids : [gids] | ||||||
| 		// XXX not safe -- fast enough and one can generate two identical
 | 		// XXX not safe -- fast enough and one can generate two identical
 | ||||||
| 		// 		gids...
 | 		// 		gids...
 | ||||||
| 		group = group == null ? this.newGid('G' + Date.now()) : group | 		group = group == null ? this.newGid('G' + Date.now()) : group | ||||||
| @ -2107,7 +2107,7 @@ var DataPrototype = { | |||||||
| 		groups = groups == null ? this.getGroup() | 		groups = groups == null ? this.getGroup() | ||||||
| 			: groups == 'all' || groups == '*' ? Object.keys(this.groups) | 			: groups == 'all' || groups == '*' ? Object.keys(this.groups) | ||||||
| 			: groups | 			: groups | ||||||
| 		groups = groups.constructor !== Array ? [groups] : groups | 		groups = groups instanceof Array ? groups : [groups] | ||||||
| 
 | 
 | ||||||
| 		var that = this | 		var that = this | ||||||
| 		groups.forEach(function(group){ | 		groups.forEach(function(group){ | ||||||
| @ -2152,7 +2152,7 @@ var DataPrototype = { | |||||||
| 		groups = groups == null ? this.getGroup()  | 		groups = groups == null ? this.getGroup()  | ||||||
| 			: groups == 'all' || groups == '*' ? Object.keys(this.groups) | 			: groups == 'all' || groups == '*' ? Object.keys(this.groups) | ||||||
| 			: groups | 			: groups | ||||||
| 		groups = groups.constructor !== Array ? [groups] : groups | 		groups = groups instanceof Array ? groups : [groups] | ||||||
| 		safe = safe || false | 		safe = safe || false | ||||||
| 
 | 
 | ||||||
| 		var that = this | 		var that = this | ||||||
| @ -2284,12 +2284,10 @@ var DataPrototype = { | |||||||
| 	// 		.getImage(..)
 | 	// 		.getImage(..)
 | ||||||
| 	// NOTE: if no target is given this will assume the current image.
 | 	// NOTE: if no target is given this will assume the current image.
 | ||||||
| 	split: function(target){ | 	split: function(target){ | ||||||
| 		if(arguments.length > 1){ | 		target = argument.length > 1 ? [].slice.call(arguments) | ||||||
| 			target = Array.apply(null, arguments) | 			: target == null || target instanceof Array ? target | ||||||
| 		} else if(target == null  | 			: [target] | ||||||
| 				|| target.constructor !== Array){ | 
 | ||||||
| 			target = [ target ] |  | ||||||
| 		} |  | ||||||
| 		var res = [] | 		var res = [] | ||||||
| 		var tail = this.clone() | 		var tail = this.clone() | ||||||
| 		var that = this | 		var that = this | ||||||
| @ -2348,7 +2346,7 @@ var DataPrototype = { | |||||||
| 			args.shift()  | 			args.shift()  | ||||||
| 			: 'base' | 			: 'base' | ||||||
| 		align = align || 'base' | 		align = align || 'base' | ||||||
| 		args = args[0].constructor === Array ? args[0] : args | 		args = args[0] instanceof Array ? args[0] : args | ||||||
| 
 | 
 | ||||||
| 		var base = this | 		var base = this | ||||||
| 
 | 
 | ||||||
| @ -2991,10 +2989,10 @@ var DataWithTagsPrototype = { | |||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
| 	tag: function(tags, gids){ | 	tag: function(tags, gids){ | ||||||
| 		tags = tags.constructor !== Array ? [tags] : tags | 		tags = tags instanceof Array ? tags : [tags] | ||||||
| 
 | 
 | ||||||
| 		gids = gids == null || gids == 'current' ? this.getImage() : gids | 		gids = gids == null || gids == 'current' ? this.getImage() : gids | ||||||
| 		gids = gids.constructor !== Array ? [gids] : gids | 		gids = gids instanceof Array ? gids : [gids] | ||||||
| 
 | 
 | ||||||
| 		if(this.tags == null){ | 		if(this.tags == null){ | ||||||
| 			this.tags = {} | 			this.tags = {} | ||||||
| @ -3019,10 +3017,10 @@ var DataWithTagsPrototype = { | |||||||
| 		if(this.tags == null){ | 		if(this.tags == null){ | ||||||
| 			return this | 			return this | ||||||
| 		} | 		} | ||||||
| 		tags = tags.constructor !== Array ? [tags] : tags | 		tags = tags instanceof Array ? tags : [tags] | ||||||
| 
 | 
 | ||||||
| 		gids = gids == null || gids == 'current' ? this.getImage() : gids | 		gids = gids == null || gids == 'current' ? this.getImage() : gids | ||||||
| 		gids = gids.constructor !== Array ? [gids] : gids | 		gids = gids instanceof Array ? gids : [gids] | ||||||
| 
 | 
 | ||||||
| 		var that = this | 		var that = this | ||||||
| 		var tagset = this.tags | 		var tagset = this.tags | ||||||
| @ -3046,7 +3044,7 @@ var DataWithTagsPrototype = { | |||||||
| 	// NOTE: this does not support multiple tags at this point...
 | 	// NOTE: this does not support multiple tags at this point...
 | ||||||
| 	toggleTag: function(tag, gids, action){ | 	toggleTag: function(tag, gids, action){ | ||||||
| 		gids = gids == null || gids == 'current' ? this.getImage() : gids | 		gids = gids == null || gids == 'current' ? this.getImage() : gids | ||||||
| 		gids = gids.constructor !== Array ? [gids] : gids | 		gids = gids instanceof Array ? gids : [gids] | ||||||
| 
 | 
 | ||||||
| 		// tag all...
 | 		// tag all...
 | ||||||
| 		if(action == 'on'){ | 		if(action == 'on'){ | ||||||
| @ -3099,10 +3097,11 @@ var DataWithTagsPrototype = { | |||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
| 	getTags: function(gids){ | 	getTags: function(gids){ | ||||||
| 		gids = arguments.length > 1 ? [].slice.call(arguments) : gids | 		gids = arguments.length > 1 ? [].slice.call(arguments)  | ||||||
| 		gids = gids == null || gids == 'current' ? this.getImage() : gids | 			: gids == null || gids == 'current' ? this.getImage()  | ||||||
|  | 			: gids | ||||||
| 		gids = gids == null ? [] : gids | 		gids = gids == null ? [] : gids | ||||||
| 		gids = gids.constructor !== Array ? [gids] : gids | 		gids = gids instanceof Array ? gids : [gids] | ||||||
| 
 | 
 | ||||||
| 		if(this.tags == null){ | 		if(this.tags == null){ | ||||||
| 			return [] | 			return [] | ||||||
| @ -3125,7 +3124,7 @@ var DataWithTagsPrototype = { | |||||||
| 	// selectors...
 | 	// selectors...
 | ||||||
| 	getTaggedByAny: function(tags){ | 	getTaggedByAny: function(tags){ | ||||||
| 		tags = arguments.length > 1 ? [].slice.call(arguments) : tags | 		tags = arguments.length > 1 ? [].slice.call(arguments) : tags | ||||||
| 		tags = tags.constructor !== Array ? [tags] : tags | 		gids = gids instanceof Array ? gids : [gids] | ||||||
| 
 | 
 | ||||||
| 		var res = [] | 		var res = [] | ||||||
| 
 | 
 | ||||||
| @ -3145,7 +3144,7 @@ var DataWithTagsPrototype = { | |||||||
| 	}, | 	}, | ||||||
| 	getTaggedByAll: function(tags){ | 	getTaggedByAll: function(tags){ | ||||||
| 		tags = arguments.length > 1 ? [].slice.call(arguments) : tags | 		tags = arguments.length > 1 ? [].slice.call(arguments) : tags | ||||||
| 		tags = tags.constructor !== Array ? [tags] : tags | 		tags = tags instanceof Array ? tags : [tags] | ||||||
| 
 | 
 | ||||||
| 		if(this.tags == null){ | 		if(this.tags == null){ | ||||||
| 			return [] | 			return [] | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user