mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	some minor refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									b7a8f1a784
								
							
						
					
					
						commit
						c168b22e38
					
				| @ -3022,7 +3022,9 @@ var DataWithTagsPrototype = { | |||||||
| 		return this | 		return this | ||||||
| 	}, | 	}, | ||||||
| 	toggleTag: function(tag, gids, action){ | 	toggleTag: function(tag, gids, action){ | ||||||
| 		gids = gids == null || gids == 'current' ?  | 		var that = this | ||||||
|  | 		return this.tags.toggle(tag,  | ||||||
|  | 				gids == null || gids == 'current' ?  | ||||||
| 						this.current | 						this.current | ||||||
| 					: gids == 'ribbon' ? | 					: gids == 'ribbon' ? | ||||||
| 						this.getImages('current') | 						this.getImages('current') | ||||||
| @ -3030,19 +3032,12 @@ var DataWithTagsPrototype = { | |||||||
| 						this.getImages('loaded') | 						this.getImages('loaded') | ||||||
| 					: gids == 'all' ? | 					: gids == 'all' ? | ||||||
| 						this.getImages('all') | 						this.getImages('all') | ||||||
| 			: gids | 					: gids,  | ||||||
| 
 | 				action) | ||||||
| 		var res = this.tags.toggle(tag, gids, action) | 			.run(function(){ | ||||||
| 
 | 				return this === that.tags ? | ||||||
| 		return res === this.tags ?  | 					that | ||||||
| 				this  | 					: this }) }, | ||||||
| 			: res === true ?  |  | ||||||
| 				'on' |  | ||||||
| 			: res === false ?  |  | ||||||
| 				'off' |  | ||||||
| 			: res |  | ||||||
| 				.map(function(r){ return r ? 'on' : 'off' }) |  | ||||||
| 	}, |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	// XXX should these be .tags.query(..) ???
 | 	// XXX should these be .tags.query(..) ???
 | ||||||
|  | |||||||
| @ -1022,7 +1022,7 @@ var BaseTagsPrototype = { | |||||||
| 	//	Toggle tag for each values...
 | 	//	Toggle tag for each values...
 | ||||||
| 	//	.toggle(tag, value)
 | 	//	.toggle(tag, value)
 | ||||||
| 	//	.toggle(tag, values)
 | 	//	.toggle(tag, values)
 | ||||||
| 	//		-> [bool|null, ..]
 | 	//		-> ['on'|'off'|null, ..]
 | ||||||
| 	//		NOTE: if tag is a tag pattern (contains '*') this will toggle
 | 	//		NOTE: if tag is a tag pattern (contains '*') this will toggle
 | ||||||
| 	//			matching tags values off as expected but ignore toggling 
 | 	//			matching tags values off as expected but ignore toggling 
 | ||||||
| 	//			tags on in which case null will be  returned for the 
 | 	//			tags on in which case null will be  returned for the 
 | ||||||
| @ -1046,7 +1046,7 @@ var BaseTagsPrototype = { | |||||||
| 	//	Check if tag is set on value(s)...
 | 	//	Check if tag is set on value(s)...
 | ||||||
| 	//	.toggle(tag, value, '?')
 | 	//	.toggle(tag, value, '?')
 | ||||||
| 	//	.toggle(tag, values, '?')
 | 	//	.toggle(tag, values, '?')
 | ||||||
| 	//		-> [bool, ..]
 | 	//		-> ['on'|'off', ..]
 | ||||||
| 	//
 | 	//
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// NOTE: this supports tag patterns (see: ,match(..))
 | 	// NOTE: this supports tag patterns (see: ,match(..))
 | ||||||
| @ -1061,7 +1061,7 @@ var BaseTagsPrototype = { | |||||||
| 		var ntag = this.normalize(tag) | 		var ntag = this.normalize(tag) | ||||||
| 
 | 
 | ||||||
| 		// can't set pattern as tag...
 | 		// can't set pattern as tag...
 | ||||||
| 		if(pattern && action != 'on'){ | 		if(pattern && action == 'on'){ | ||||||
| 			throw new TypeError(`.toggle(..): will not toggle on "${tag}": pattern and not a tag.`) | 			throw new TypeError(`.toggle(..): will not toggle on "${tag}": pattern and not a tag.`) | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| @ -1072,19 +1072,19 @@ var BaseTagsPrototype = { | |||||||
| 			: action == '?' ? | 			: action == '?' ? | ||||||
| 				values | 				values | ||||||
| 					.map(function(v){  | 					.map(function(v){  | ||||||
| 						return pattern ?  | 						return (pattern ?  | ||||||
| 							// non-strict pattern search...
 | 							// non-strict pattern search...
 | ||||||
| 							that.tags(v, tag)  | 							that.tags(v, tag)  | ||||||
| 							// strict test...
 | 							// strict test...
 | ||||||
| 							: that.tags(v).indexOf(ntag) >= 0 }) | 							: that.tags(v).indexOf(ntag) >= 0) ? 'on' : 'off' }) | ||||||
| 			// toggle each...
 | 			// toggle each...
 | ||||||
| 			: values | 			: values | ||||||
| 				.map(function(v){  | 				.map(function(v){  | ||||||
| 					return that.tags(v, tag) ?  | 					return that.tags(v, tag) ?  | ||||||
| 						(that.untag(tag, v), false)  | 						(that.untag(tag, v), 'off')  | ||||||
| 						// NOTE: we set only if we are not a pattern...
 | 						// NOTE: we set only if we are not a pattern...
 | ||||||
| 						: (!pattern ?  | 						: (!pattern ?  | ||||||
| 							(that.tag(tag, v), true)  | 							(that.tag(tag, v), 'on')  | ||||||
| 							: null) }) }, | 							: null) }) }, | ||||||
| 
 | 
 | ||||||
| 	// Replace tags...
 | 	// Replace tags...
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user