mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	fixed a several of issues with focus/next/prev and disabled items...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									129c3fea8f
								
							
						
					
					
						commit
						1397d100f1
					
				| @ -831,6 +831,8 @@ var BaseBrowserPrototype = { | |||||||
| 	// 		// XXX not yet supported...
 | 	// 		// XXX not yet supported...
 | ||||||
| 	// 		skipInlined: <bool>,
 | 	// 		skipInlined: <bool>,
 | ||||||
| 	//
 | 	//
 | ||||||
|  | 	// 		skipDisabled: <bool>,
 | ||||||
|  | 	//
 | ||||||
| 	// 		// Reverse iteration order...
 | 	// 		// Reverse iteration order...
 | ||||||
| 	//		//
 | 	//		//
 | ||||||
| 	//		// modes:
 | 	//		// modes:
 | ||||||
| @ -922,6 +924,7 @@ var BaseBrowserPrototype = { | |||||||
| 		var iterateCollapsed = options.iterateAll || options.iterateCollapsed | 		var iterateCollapsed = options.iterateAll || options.iterateCollapsed | ||||||
| 		var skipNested = !options.iterateAll && options.skipNested | 		var skipNested = !options.iterateAll && options.skipNested | ||||||
| 		var skipInlined = !options.iterateAll && options.skipInlined | 		var skipInlined = !options.iterateAll && options.skipInlined | ||||||
|  | 		var skipDisabled = !options.iterateAll && options.skipDisabled | ||||||
| 		var reverse = options.reverse === true ? | 		var reverse = options.reverse === true ? | ||||||
| 			(options.defaultReverse || 'tree') | 			(options.defaultReverse || 'tree') | ||||||
| 			: options.reverse | 			: options.reverse | ||||||
| @ -945,6 +948,9 @@ var BaseBrowserPrototype = { | |||||||
| 				// skip non-iterable items...
 | 				// skip non-iterable items...
 | ||||||
| 				if(!iterateNonIterable && node.noniterable){ | 				if(!iterateNonIterable && node.noniterable){ | ||||||
| 					return state } | 					return state } | ||||||
|  | 				// skip disabled...
 | ||||||
|  | 				if(skipDisabled && node.disabled){ | ||||||
|  | 					return state } | ||||||
| 
 | 
 | ||||||
| 				var nested = false | 				var nested = false | ||||||
| 				var doNested = function(list){ | 				var doNested = function(list){ | ||||||
| @ -2183,11 +2189,11 @@ var BaseBrowserPrototype = { | |||||||
| 	// 	.focus(query[, ...])
 | 	// 	.focus(query[, ...])
 | ||||||
| 	// 		-> this
 | 	// 		-> this
 | ||||||
| 	//
 | 	//
 | ||||||
| 	// XXX BUG: .focus(-1) turns indexing around persistently -- after it
 | 	//
 | ||||||
| 	// 		.focus(0) will get the last element (a-la .focus(-1)) and 
 | 	// NOTE: this will ignore disabled items.
 | ||||||
| 	// 		.focus(1) will get the second to last element (a-la .focus(-2))
 | 	// NOTE: .focus('next') / .focus('prev') will not wrap around the 
 | ||||||
| 	// 		...are we leaking the multiplier somewhere???
 | 	// 		first last elements...
 | ||||||
| 	// 		this seems to be isolated to .focus(..)...
 | 	// 		XXX should it???
 | ||||||
| 	focus: makeItemEventMethod('focus',  | 	focus: makeItemEventMethod('focus',  | ||||||
| 		function(evt, items){ | 		function(evt, items){ | ||||||
| 			// blur .focused...
 | 			// blur .focused...
 | ||||||
| @ -2198,9 +2204,11 @@ var BaseBrowserPrototype = { | |||||||
| 			item != null | 			item != null | ||||||
| 				&& (item.focused = true) | 				&& (item.focused = true) | ||||||
| 		}, | 		}, | ||||||
| 		// default...
 |  | ||||||
| 		function(){ return this.get(0) }, | 		function(){ return this.get(0) }, | ||||||
| 		{ getMode: 'get' }), | 		{  | ||||||
|  | 			getMode: 'get',  | ||||||
|  | 			skipDisabled: true, | ||||||
|  | 		}), | ||||||
| 	blur: makeItemEventMethod('blur', function(evt, items){ | 	blur: makeItemEventMethod('blur', function(evt, items){ | ||||||
| 		items.forEach(function(item){ | 		items.forEach(function(item){ | ||||||
| 			delete item.focused }) }), | 			delete item.focused }) }), | ||||||
| @ -2209,8 +2217,14 @@ var BaseBrowserPrototype = { | |||||||
| 		'focus', 'blur',  | 		'focus', 'blur',  | ||||||
| 		function(){ return this.focused || 0 },  | 		function(){ return this.focused || 0 },  | ||||||
| 		false), | 		false), | ||||||
| 	next: function(){ return this.focus('next') }, | 	// NOTE: .next() / .prev() will wrap around the first/last elements...
 | ||||||
| 	prev: function(){ return this.focus('prev') }, | 	// 		XXX should wrapping be done here or in .focus(..)???
 | ||||||
|  | 	next: function(){  | ||||||
|  | 		this.focus('next').focused || this.focus('first')  | ||||||
|  | 		return this }, | ||||||
|  | 	prev: function(){  | ||||||
|  | 		this.focus('prev').focused || this.focus('last')  | ||||||
|  | 		return this }, | ||||||
| 
 | 
 | ||||||
| 	select: makeItemEventMethod('select',  | 	select: makeItemEventMethod('select',  | ||||||
| 		function(evt, items){ | 		function(evt, items){ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user