mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 19:00:09 +00:00 
			
		
		
		
	refactoring (not done yet)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									1d5745f0f1
								
							
						
					
					
						commit
						bb244a53af
					
				| @ -41,14 +41,38 @@ Items.dialog = null | |||||||
| Items.items = null | Items.items = null | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | // Last item created...
 | ||||||
|  | // XXX not sure about this...
 | ||||||
|  | // XXX should this be a prop???
 | ||||||
|  | Items.last = function(){ | ||||||
|  | 	return (this.items || [])[this.items.length - 1] } | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| // Focus last created item...
 | // Focus last created item...
 | ||||||
| // XXX also would be nice to set the last created items to .last or 
 | // XXX also would be nice to set the last created items to .last or 
 | ||||||
| // 		similar in the context...
 | // 		similar in the context...
 | ||||||
| Items.focus = function(){ | Items.focus = function(){ | ||||||
|  | 	this.last.current = true | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | // helper...
 | ||||||
|  | var normalizeItems = function(context, items){ | ||||||
|  | 	var made = items | ||||||
|  | 		.filter(function(e){ | ||||||
|  | 			return e === context }) | ||||||
|  | 	var l = context.items.length - items.length | ||||||
|  | 	// constructed item list...
 | ||||||
|  | 	made = context.items.slice(l) | ||||||
|  | 	// get the actual item values...
 | ||||||
|  | 	return items | ||||||
|  | 		.map(function(e){ | ||||||
|  | 			return e === context ? | ||||||
|  | 				made.shift() | ||||||
|  | 				: e }) } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| //
 | //
 | ||||||
| //	.group(make(..), ..)
 | //	.group(make(..), ..)
 | ||||||
| //		-> make
 | //		-> make
 | ||||||
| @ -68,18 +92,12 @@ Items.focus = function(){ | |||||||
| // 		and prevent allot of specific errors...
 | // 		and prevent allot of specific errors...
 | ||||||
| Items.group = function(...items){ | Items.group = function(...items){ | ||||||
| 	var that = this | 	var that = this | ||||||
| 	var made = items | 	// XXX ???
 | ||||||
| 		.filter(function(e){ | 	items = items.length == 1 && items[0] instanceof Array ? | ||||||
| 			return e === that }) | 		items[0] | ||||||
|  | 		: items | ||||||
| 	var l = this.items.length - items.length | 	var l = this.items.length - items.length | ||||||
| 	// constructed item list...
 | 	items = normalizeItems(this, items)  | ||||||
| 	made = this.items.slice(l) |  | ||||||
| 	// get the actual item values...
 |  | ||||||
| 	items = items |  | ||||||
| 		.map(function(e){ |  | ||||||
| 			return e === that ? |  | ||||||
| 				made.shift() |  | ||||||
| 				: e }) |  | ||||||
| 
 | 
 | ||||||
| 	// replace the items with the group...
 | 	// replace the items with the group...
 | ||||||
| 	this.items.splice(l, items.length, items) | 	this.items.splice(l, items.length, items) | ||||||
| @ -90,7 +108,9 @@ Items.group = function(...items){ | |||||||
| // XXX add support for lists of items (a-la .group(..))
 | // XXX add support for lists of items (a-la .group(..))
 | ||||||
| Items.nest = function(item, list, options){ | Items.nest = function(item, list, options){ | ||||||
| 	options = options || {} | 	options = options || {} | ||||||
| 	options.sublist = list | 	options.sublist = list instanceof Array ? | ||||||
|  | 		normalizeItems(this, list) | ||||||
|  | 		: list | ||||||
| 	return this(item, options) | 	return this(item, options) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -235,6 +255,13 @@ var BaseBrowserPrototype = { | |||||||
| 	make: function(options){ | 	make: function(options){ | ||||||
| 		var items = this.items = [] | 		var items = this.items = [] | ||||||
| 
 | 
 | ||||||
|  | 		// XXX change this to:
 | ||||||
|  | 		// 		- return a new instance/function for each call
 | ||||||
|  | 		// 		- each new instance/function references:
 | ||||||
|  | 		// 			- the item created
 | ||||||
|  | 		// 			- next instance/function
 | ||||||
|  | 		// XXX might also be a good idea to move this out of the method
 | ||||||
|  | 		// 		and into the module scope for clarity...
 | ||||||
| 		var make_called = false | 		var make_called = false | ||||||
| 		var make = function(value, opts){ | 		var make = function(value, opts){ | ||||||
| 			make_called = true | 			make_called = true | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user