mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 19:00:09 +00:00 
			
		
		
		
	reworked id management...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									1edd5decc4
								
							
						
					
					
						commit
						fa4c7737f9
					
				| @ -108,6 +108,8 @@ requirejs([ | |||||||
| 		make.group( | 		make.group( | ||||||
| 			make('a'), | 			make('a'), | ||||||
| 			'b') | 			'b') | ||||||
|  | 		// XXX Q: should we show only one if multiple lines are in sequence??? | ||||||
|  | 		make('---') | ||||||
| 		make('---') | 		make('---') | ||||||
| 		// XXX not yet visible... | 		// XXX not yet visible... | ||||||
| 		make('...') | 		make('...') | ||||||
|  | |||||||
| @ -223,7 +223,9 @@ var BaseBrowserClassPrototype = { | |||||||
| // XXX need a way to identify items...
 | // XXX need a way to identify items...
 | ||||||
| var BaseBrowserPrototype = { | var BaseBrowserPrototype = { | ||||||
| 	// XXX should we mix item/list options or separate them into sub-objects???
 | 	// XXX should we mix item/list options or separate them into sub-objects???
 | ||||||
| 	options: null, | 	options: { | ||||||
|  | 		noDuplicateValues: false, | ||||||
|  | 	}, | ||||||
| 
 | 
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// Format:
 | 	// Format:
 | ||||||
| @ -353,6 +355,9 @@ var BaseBrowserPrototype = { | |||||||
| 	//
 | 	//
 | ||||||
| 	// XXX revise options handling for .__list__(..)
 | 	// XXX revise options handling for .__list__(..)
 | ||||||
| 	make: function(options){ | 	make: function(options){ | ||||||
|  | 		// XXX
 | ||||||
|  | 		options = options || this.options || {} | ||||||
|  | 
 | ||||||
| 		var items = this.items = [] | 		var items = this.items = [] | ||||||
| 		var old_index = this.item_index || {} | 		var old_index = this.item_index || {} | ||||||
| 		var new_index = this.item_index = {}  | 		var new_index = this.item_index = {}  | ||||||
| @ -390,11 +395,18 @@ var BaseBrowserPrototype = { | |||||||
| 					&& Date.now()) | 					&& Date.now()) | ||||||
| 				|| JSON.stringify(value) | 				|| JSON.stringify(value) | ||||||
| 
 | 
 | ||||||
|  | 			var k = key | ||||||
|  | 			while(k in new_index){ | ||||||
| 				// no duplicate keys...
 | 				// no duplicate keys...
 | ||||||
| 			if(key in new_index){ | 				if(options.noDuplicateValues){ | ||||||
| 					throw new Error(`make(..): duplicate key "${key}": ` | 					throw new Error(`make(..): duplicate key "${key}": ` | ||||||
| 						+`can't create multiple items with the same key.`) } | 						+`can't create multiple items with the same key.`) } | ||||||
| 
 | 
 | ||||||
|  | 				// create a new key...
 | ||||||
|  | 				k = k +' '+ Date.now() | ||||||
|  | 			} | ||||||
|  | 			key = opts.id = k | ||||||
|  | 
 | ||||||
| 			// build the item...
 | 			// build the item...
 | ||||||
| 			var item = Object.assign({},  | 			var item = Object.assign({},  | ||||||
| 				// get the old item values...
 | 				// get the old item values...
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user