forked from forgejo/forgejo
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> (cherry picked from commit fa100618c4b644346bf5666f92d33dce0747d0a2)
This commit is contained in:
parent
272dffb0d6
commit
8c3d7c049a
7 changed files with 78 additions and 73 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue