mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Forbid jQuery .css and refactor all usage (#29852)
				
					
				
			Tested all functionality. There is a [pre-existing bug](https://github.com/go-gitea/gitea/issues/29853) when moving a project panels which is not caused by this refactoring. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		@@ -2,11 +2,15 @@ import $ from 'jquery';
 | 
			
		||||
import {createColorPicker} from '../colorpicker.js';
 | 
			
		||||
 | 
			
		||||
export function initCompColorPicker() {
 | 
			
		||||
  createColorPicker($('.color-picker'));
 | 
			
		||||
  (async () => {
 | 
			
		||||
    await createColorPicker(document.querySelectorAll('.color-picker'));
 | 
			
		||||
 | 
			
		||||
  $('.precolors .color').on('click', function () {
 | 
			
		||||
    const color_hex = $(this).data('color-hex');
 | 
			
		||||
    $('.color-picker').val(color_hex);
 | 
			
		||||
    $('.minicolors-swatch-color').css('background-color', color_hex);
 | 
			
		||||
  });
 | 
			
		||||
    for (const el of document.querySelectorAll('.precolors .color')) {
 | 
			
		||||
      el.addEventListener('click', (e) => {
 | 
			
		||||
        const color = e.target.getAttribute('data-color-hex');
 | 
			
		||||
        const parent = e.target.closest('.color.picker');
 | 
			
		||||
        $(parent.querySelector('.color-picker')).minicolors('value', color);
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
  })();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -43,7 +43,6 @@ export function initCompLabelEdit(selector) {
 | 
			
		||||
 | 
			
		||||
  // Edit label
 | 
			
		||||
  $('.edit-label-button').on('click', function () {
 | 
			
		||||
    $('.edit-label .color-picker').minicolors('value', $(this).data('color'));
 | 
			
		||||
    $('#label-modal-id').val($(this).data('id'));
 | 
			
		||||
 | 
			
		||||
    const $nameInput = $('.edit-label .label-name-input');
 | 
			
		||||
@@ -60,9 +59,8 @@ export function initCompLabelEdit(selector) {
 | 
			
		||||
      (!this.hasAttribute('data-exclusive') || !isExclusiveScopeName($nameInput.val())));
 | 
			
		||||
    updateExclusiveLabelEdit('.edit-label');
 | 
			
		||||
 | 
			
		||||
    $('.edit-label .label-desc-input').val($(this).data('description'));
 | 
			
		||||
    $('.edit-label .color-picker').val($(this).data('color'));
 | 
			
		||||
    $('.edit-label .minicolors-swatch-color').css('background-color', $(this).data('color'));
 | 
			
		||||
    $('.edit-label .label-desc-input').val(this.getAttribute('data-description'));
 | 
			
		||||
    $('.edit-label .color-picker').minicolors('value', this.getAttribute('data-color'));
 | 
			
		||||
 | 
			
		||||
    $('.edit-label.modal').modal({
 | 
			
		||||
      onApprove() {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user