mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 11:35:03 +01:00 
			
		
		
		
	- Enable https://www.typescriptlang.org/tsconfig/#noImplicitThis - Wrap Vue Template-Syntax SFCs in [`defineComponent`](https://vuejs.org/api/general#definecomponent) which makes type inference and linter work better - Move `createApp` calls outside the SFCs into separate files - Use [`PropType`](https://vuejs.org/api/utility-types#proptype-t) where appropriate - Some top-level component properties changed order as dictated by the linter - Fix all tsc and lint issues that popped up during these refactors
		
			
				
	
	
		
			30 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import $ from 'jquery';
 | |
| import type {FomanticInitFunction} from '../../types.ts';
 | |
| 
 | |
| const fomanticModalFn = $.fn.modal;
 | |
| 
 | |
| // use our own `$.fn.modal` to patch Fomantic's modal module
 | |
| export function initAriaModalPatch() {
 | |
|   if ($.fn.modal === ariaModalFn) throw new Error('initAriaModalPatch could only be called once');
 | |
|   $.fn.modal = ariaModalFn;
 | |
|   (ariaModalFn as FomanticInitFunction).settings = fomanticModalFn.settings;
 | |
| }
 | |
| 
 | |
| // the patched `$.fn.modal` modal function
 | |
| // * it does the one-time attaching on the first call
 | |
| function ariaModalFn(this: any, ...args: Parameters<FomanticInitFunction>) {
 | |
|   const ret = fomanticModalFn.apply(this, args);
 | |
|   if (args[0] === 'show' || args[0]?.autoShow) {
 | |
|     for (const el of this) {
 | |
|       // If there is a form in the modal, there might be a "cancel" button before "ok" button (all buttons are "type=submit" by default).
 | |
|       // In such case, the "Enter" key will trigger the "cancel" button instead of "ok" button, then the dialog will be closed.
 | |
|       // It breaks the user experience - the "Enter" key should confirm the dialog and submit the form.
 | |
|       // So, all "cancel" buttons without "[type]" must be marked as "type=button".
 | |
|       for (const button of el.querySelectorAll('form button.cancel:not([type])')) {
 | |
|         button.setAttribute('type', 'button');
 | |
|       }
 | |
|     }
 | |
|   }
 | |
|   return ret;
 | |
| }
 |