mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-04 08:34:30 +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.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import {hideElem, showElem} from '../utils/dom.ts';
 | 
						|
import {initCompCropper} from './comp/Cropper.ts';
 | 
						|
 | 
						|
function initUserSettingsAvatarCropper() {
 | 
						|
  const fileInput = document.querySelector<HTMLInputElement>('#new-avatar');
 | 
						|
  const container = document.querySelector<HTMLElement>('.user.settings.profile .cropper-panel');
 | 
						|
  const imageSource = container.querySelector<HTMLImageElement>('.cropper-source');
 | 
						|
  initCompCropper({container, fileInput, imageSource});
 | 
						|
}
 | 
						|
 | 
						|
export function initUserSettings() {
 | 
						|
  if (!document.querySelector('.user.settings.profile')) return;
 | 
						|
 | 
						|
  initUserSettingsAvatarCropper();
 | 
						|
 | 
						|
  const usernameInput = document.querySelector<HTMLInputElement>('#username');
 | 
						|
  if (!usernameInput) return;
 | 
						|
  usernameInput.addEventListener('input', function () {
 | 
						|
    const prompt = document.querySelector('#name-change-prompt');
 | 
						|
    const promptRedirect = document.querySelector('#name-change-redirect-prompt');
 | 
						|
    if (this.value.toLowerCase() !== this.getAttribute('data-name').toLowerCase()) {
 | 
						|
      showElem(prompt);
 | 
						|
      showElem(promptRedirect);
 | 
						|
    } else {
 | 
						|
      hideElem(prompt);
 | 
						|
      hideElem(promptRedirect);
 | 
						|
    }
 | 
						|
  });
 | 
						|
}
 |