mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 23:33:15 -05:00
Remove jQuery .attr
from the common global functions (#30023)
- Switched from jQuery `.attr` to plain javascript `getAttribute` - Tested the show/hide modal buttons, they work as before Signed-off-by: Yarden Shoham <git@yardenshoham.com> (cherry picked from commit 900dd79d8adaf2569df0f1346b6e6e91ed4b5ad3)
This commit is contained in:
parent
66feafb3de
commit
0dc6919e2d
1 changed files with 6 additions and 7 deletions
|
@ -301,8 +301,8 @@ export function initGlobalLinkActions() {
|
||||||
const $this = $(this);
|
const $this = $(this);
|
||||||
const dataArray = $this.data();
|
const dataArray = $this.data();
|
||||||
let filter = '';
|
let filter = '';
|
||||||
if ($this.attr('data-modal-id')) {
|
if (this.getAttribute('data-modal-id')) {
|
||||||
filter += `#${$this.attr('data-modal-id')}`;
|
filter += `#${this.getAttribute('data-modal-id')}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const $dialog = $(`.delete.modal${filter}`);
|
const $dialog = $(`.delete.modal${filter}`);
|
||||||
|
@ -352,8 +352,7 @@ function initGlobalShowModal() {
|
||||||
// If there is a ".{attr}" part like "data-modal-form.action", then the form's "action" attribute will be set.
|
// If there is a ".{attr}" part like "data-modal-form.action", then the form's "action" attribute will be set.
|
||||||
$('.show-modal').on('click', function (e) {
|
$('.show-modal').on('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const $el = $(this);
|
const modalSelector = this.getAttribute('data-modal');
|
||||||
const modalSelector = $el.attr('data-modal');
|
|
||||||
const $modal = $(modalSelector);
|
const $modal = $(modalSelector);
|
||||||
if (!$modal.length) {
|
if (!$modal.length) {
|
||||||
throw new Error('no modal for this action');
|
throw new Error('no modal for this action');
|
||||||
|
@ -406,7 +405,7 @@ export function initGlobalButtons() {
|
||||||
// a '.show-panel' element can show a panel, by `data-panel="selector"`
|
// a '.show-panel' element can show a panel, by `data-panel="selector"`
|
||||||
// if it has "toggle" class, it toggles the panel
|
// if it has "toggle" class, it toggles the panel
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const sel = $(this).attr('data-panel');
|
const sel = this.getAttribute('data-panel');
|
||||||
if (this.classList.contains('toggle')) {
|
if (this.classList.contains('toggle')) {
|
||||||
toggleElem(sel);
|
toggleElem(sel);
|
||||||
} else {
|
} else {
|
||||||
|
@ -417,12 +416,12 @@ export function initGlobalButtons() {
|
||||||
$('.hide-panel').on('click', function (e) {
|
$('.hide-panel').on('click', function (e) {
|
||||||
// a `.hide-panel` element can hide a panel, by `data-panel="selector"` or `data-panel-closest="selector"`
|
// a `.hide-panel` element can hide a panel, by `data-panel="selector"` or `data-panel-closest="selector"`
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let sel = $(this).attr('data-panel');
|
let sel = this.getAttribute('data-panel');
|
||||||
if (sel) {
|
if (sel) {
|
||||||
hideElem($(sel));
|
hideElem($(sel));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sel = $(this).attr('data-panel-closest');
|
sel = this.getAttribute('data-panel-closest');
|
||||||
if (sel) {
|
if (sel) {
|
||||||
hideElem($(this).closest(sel));
|
hideElem($(this).closest(sel));
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue