mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 11:20:09 +00:00 
			
		
		
		
	potentially fixed section focus issues...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									bf5fc8202e
								
							
						
					
					
						commit
						cde9596299
					
				| @ -643,6 +643,16 @@ function(item, event, evt, ...args){ | |||||||
| // 		-> bool
 | // 		-> bool
 | ||||||
| //
 | //
 | ||||||
| //
 | //
 | ||||||
|  | // options format:
 | ||||||
|  | // 	{
 | ||||||
|  | // 		// if true unresolved items will not trigger the event unless the
 | ||||||
|  | // 		// input was null/undefined...
 | ||||||
|  | // 		skipUnresolved: <bool>,
 | ||||||
|  | //
 | ||||||
|  | // 		...
 | ||||||
|  | // 	}
 | ||||||
|  | //
 | ||||||
|  | //
 | ||||||
| // NOTE: item is compatible to .search(item, ..) spec, see that for more 
 | // NOTE: item is compatible to .search(item, ..) spec, see that for more 
 | ||||||
| // 		details...
 | // 		details...
 | ||||||
| // NOTE: triggering an event that matches several items will handle each 
 | // NOTE: triggering an event that matches several items will handle each 
 | ||||||
| @ -710,7 +720,8 @@ function(event, {handler, action, default_item, filter, options={}, getter='sear | |||||||
| 			var opts = options instanceof Function ? | 			var opts = options instanceof Function ? | ||||||
| 				makeOptions.call(this) | 				makeOptions.call(this) | ||||||
| 				: options | 				: options | ||||||
| 			return base.call(this,  | 			var skipUnresolved = opts.skipUnresolved | ||||||
|  | 			var resolved =  | ||||||
| 				// event handler...
 | 				// event handler...
 | ||||||
| 				item instanceof Function ? | 				item instanceof Function ? | ||||||
| 					item | 					item | ||||||
| @ -728,7 +739,14 @@ function(event, {handler, action, default_item, filter, options={}, getter='sear | |||||||
| 				: item !== null && default_item instanceof Function ? | 				: item !== null && default_item instanceof Function ? | ||||||
| 					[default_item.call(that) || []].flat() | 					[default_item.call(that) || []].flat() | ||||||
| 				// item is null (explicitly) or other...
 | 				// item is null (explicitly) or other...
 | ||||||
| 				: [], | 				: [] | ||||||
|  | 			return (skipUnresolved  | ||||||
|  | 					&& resolved.length == 0  | ||||||
|  | 					&& item != null) ? | ||||||
|  | 				// skip unresolved...
 | ||||||
|  | 				this | ||||||
|  | 				: base.call(this,  | ||||||
|  | 					resolved, | ||||||
| 					...args) }, | 					...args) }, | ||||||
| 			// get base method attributes -- keep the event method format...
 | 			// get base method attributes -- keep the event method format...
 | ||||||
|    			base) } |    			base) } | ||||||
| @ -3162,22 +3180,9 @@ var BaseBrowserPrototype = { | |||||||
| 	// 		first last elements...
 | 	// 		first last elements...
 | ||||||
| 	// NOTE: if focus does not change this will trigger any handlers...
 | 	// NOTE: if focus does not change this will trigger any handlers...
 | ||||||
| 	// NOTE: this will reveal the focused item...
 | 	// NOTE: this will reveal the focused item...
 | ||||||
| 	// XXX SECTION_FOCUS
 |  | ||||||
| 	focus: makeItemEventMethod('focus', { | 	focus: makeItemEventMethod('focus', { | ||||||
| 		handler: function(evt, items){ | 		handler: function(evt, items){ | ||||||
| 			var item = items.shift() | 			var item = items.shift() | ||||||
| 			// do not change focus if item is not in the main section...
 |  | ||||||
| 			// NOTE: we will still trigger item focus handlers...
 |  | ||||||
| 			if(item != null  |  | ||||||
| 					&& this.get(item) == null  |  | ||||||
| 					&& !(this.options || {}).allowSecondaySectionFocus){ |  | ||||||
| 				// XXX SECTION_FOCUS
 |  | ||||||
| 				// XXX this fixes the .__focus__(..) falling into recursion 
 |  | ||||||
| 				// 		problem but prevent non-main-section item handlers 
 |  | ||||||
| 				// 		from triggering...
 |  | ||||||
| 				evt.stopPropagation() |  | ||||||
| 				return  |  | ||||||
| 			} |  | ||||||
| 			// blur .focused...
 | 			// blur .focused...
 | ||||||
| 			this.focused | 			this.focused | ||||||
| 				&& this.blur(this.focused) | 				&& this.blur(this.focused) | ||||||
| @ -3188,10 +3193,7 @@ var BaseBrowserPrototype = { | |||||||
| 		default_item: function(){ return this.get(0) }, | 		default_item: function(){ return this.get(0) }, | ||||||
| 		options: function(){ | 		options: function(){ | ||||||
| 			return { | 			return { | ||||||
| 				// XXX this messes up focusing by index, e.g. .focus(0) 
 | 				skipUnresolved: true, | ||||||
| 				// 		if a header is available...
 |  | ||||||
| 				// XXX SECTION_FOCUS
 |  | ||||||
| 				section: '*', |  | ||||||
| 				skipDisabled: !(this.options || {}).focusDisabledItems, | 				skipDisabled: !(this.options || {}).focusDisabledItems, | ||||||
| 			} }, | 			} }, | ||||||
| 		getter: 'get' }), | 		getter: 'get' }), | ||||||
| @ -4677,7 +4679,6 @@ var HTMLBrowserPrototype = { | |||||||
| 		}, {skipDisabled: false}) | 		}, {skipDisabled: false}) | ||||||
| 	}, | 	}, | ||||||
| 	// NOTE: element alignment is done via the browser focus mechanics...
 | 	// NOTE: element alignment is done via the browser focus mechanics...
 | ||||||
| 	// XXX SECTION_FOCUS
 |  | ||||||
| 	__focus__: function(evt, elem){ | 	__focus__: function(evt, elem){ | ||||||
| 		var that = this | 		var that = this | ||||||
| 		elem | 		elem | ||||||
| @ -4694,7 +4695,6 @@ var HTMLBrowserPrototype = { | |||||||
| 					}) | 					}) | ||||||
| 				}) | 				}) | ||||||
| 				// set focus...
 | 				// set focus...
 | ||||||
| 				// XXX SECTION_FOCUS breaks int recursion on non main section items...
 |  | ||||||
| 				.focus() }, | 				.focus() }, | ||||||
| 	__blur__: function(evt, elem){ | 	__blur__: function(evt, elem){ | ||||||
| 		var that = this | 		var that = this | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user