1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #6333 from viown/remove-jquery-part-1

Remove jQuery
This commit is contained in:
viown 2025-01-14 01:12:37 +03:00 committed by GitHub
parent f1c49163c2
commit 3600426058
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 177 additions and 152 deletions

View file

@ -8,7 +8,6 @@ import escapeHtml from 'escape-html';
import loading from '../loading/loading';
import dialogHelper from '../dialogHelper/dialogHelper';
import dom from '../../scripts/dom';
import 'jquery';
import libraryoptionseditor from '../libraryoptionseditor/libraryoptionseditor';
import globalize from '../../lib/globalize';
import '../../elements/emby-button/emby-button';
@ -43,8 +42,8 @@ function onAddLibrary(e) {
isCreating = true;
loading.show();
const dlg = dom.parentWithClass(this, 'dlg-librarycreator');
const name = $('#txtValue', dlg).val();
let type = $('#selectCollectionType', dlg).val();
const name = dlg.querySelector('#txtValue').value;
let type = dlg.querySelector('#selectCollectionType').value;
if (type == 'mixed') {
type = null;
@ -72,9 +71,12 @@ function getCollectionTypeOptionsHtml(collectionTypeOptions) {
}
function initEditor(page, collectionTypeOptions) {
$('#selectCollectionType', page).html(getCollectionTypeOptionsHtml(collectionTypeOptions)).val('').on('change', function () {
const selectCollectionType = page.querySelector('#selectCollectionType');
selectCollectionType.innerHTML = getCollectionTypeOptionsHtml(collectionTypeOptions);
selectCollectionType.value = '';
selectCollectionType.addEventListener('change', function () {
const value = this.value;
const dlg = $(this).parents('.dialog')[0];
const dlg = dom.parentWithClass(this, 'dialog');
libraryoptionseditor.setContentType(dlg.querySelector('.libraryOptions'), value);
if (value) {
@ -90,12 +92,12 @@ function initEditor(page, collectionTypeOptions) {
const name = this.options[index].innerHTML
.replaceAll('*', '')
.replaceAll('&', '&');
$('#txtValue', dlg).val(name);
dlg.querySelector('#txtValue').value = name;
}
}
const folderOption = collectionTypeOptions.find(i => i.value === value);
$('.collectionTypeFieldDescription', dlg).html(folderOption?.message || '');
dlg.querySelector('.collectionTypeFieldDescription').innerHTML = folderOption?.message || '';
});
page.querySelector('.btnAddFolder').addEventListener('click', onAddButtonClick);
page.querySelector('.addLibraryForm').addEventListener('submit', onAddLibrary);
@ -184,7 +186,7 @@ function onDialogClosed() {
function initLibraryOptions(dlg) {
libraryoptionseditor.embed(dlg.querySelector('.libraryOptions')).then(() => {
$('#selectCollectionType', dlg).trigger('change');
dlg.querySelector('#selectCollectionType').dispatchEvent(new Event('change'));
});
}

View file

@ -57,7 +57,7 @@ export default function (page, providerId, options) {
return i.Id === providerId;
})[0] || {};
listingsId = info.ListingsId;
$('#selectListing', page).val(info.ListingsId || '');
page.querySelector('#selectListing').value = info.ListingsId || '';
page.querySelector('.txtUser').value = info.Username || '';
page.querySelector('.txtPass').value = '';
page.querySelector('.txtZipCode').value = info.ZipCode || '';
@ -114,7 +114,7 @@ export default function (page, providerId, options) {
$('#selectCountry', page).html(countryList.map(function (c) {
return '<option value="' + c.value + '">' + c.name + '</option>';
}).join('')).val(info.Country || '');
$(page.querySelector('.txtZipCode')).trigger('change');
page.querySelector('.txtZipCode').dispatchEvent(new Event('change'));
}, function () { // ApiClient.getJSON() error handler
Dashboard.alert({
message: globalize.translate('ErrorGettingTvLineups')
@ -157,7 +157,7 @@ export default function (page, providerId, options) {
}
function submitListingsForm() {
const selectedListingsId = $('#selectListing', page).val();
const selectedListingsId = page.querySelector('#selectListing').value;
if (!selectedListingsId) {
Dashboard.alert({
@ -173,7 +173,7 @@ export default function (page, providerId, options) {
return i.Id === id;
})[0];
info.ZipCode = page.querySelector('.txtZipCode').value;
info.Country = $('#selectCountry', page).val();
info.Country = page.querySelector('#selectCountry').value;
info.ListingsId = selectedListingsId;
info.EnableAllTuners = page.querySelector('.chkAllTuners').checked;
info.EnabledTuners = info.EnableAllTuners ? [] : $('.chkTuner', page).get().filter(function (i) {
@ -207,7 +207,7 @@ export default function (page, providerId, options) {
function refreshListings(value) {
if (!value) {
$('#selectListing', page).html('');
page.querySelector('#selectListing').innerHTML = '';
return;
}
@ -217,16 +217,16 @@ export default function (page, providerId, options) {
url: ApiClient.getUrl('LiveTv/ListingProviders/Lineups', {
Id: providerId,
Location: value,
Country: $('#selectCountry', page).val()
Country: page.querySelector('#selectCountry').value
}),
dataType: 'json'
}).then(function (result) {
$('#selectListing', page).html(result.map(function (o) {
page.querySelector('#selectListing').innerHTML = result.map(function (o) {
return '<option value="' + o.Id + '">' + o.Name + '</option>';
}));
}).join('');
if (listingsId) {
$('#selectListing', page).val(listingsId);
page.querySelector('#selectListing').value = listingsId;
}
loading.hide();
@ -257,15 +257,17 @@ export default function (page, providerId, options) {
const hideSubmitButton = options.showSubmitButton === false;
page.querySelector('.btnSubmitListings').classList.toggle('hide', hideSubmitButton);
$('.formLogin', page).on('submit', function () {
page.querySelector('.formLogin').addEventListener('submit', function (e) {
e.preventDefault();
submitLoginForm();
return false;
});
$('.formListings', page).on('submit', function () {
page.querySelector('.formListings').addEventListener('submit', function (e) {
e.preventDefault();
submitListingsForm();
return false;
});
$('.txtZipCode', page).on('change', function () {
page.querySelector('.txtZipCode').addEventListener('change', function () {
refreshListings(this.value);
});
page.querySelector('.chkAllTuners').addEventListener('change', function (e) {

View file

@ -7,6 +7,7 @@ import '../listview/listview.scss';
import '../../elements/emby-button/paper-icon-button-light';
import Dashboard from '../../utils/dashboard';
import Events from '../../utils/events.ts';
import dom from 'scripts/dom';
function getTunerName(providerId) {
switch (providerId.toLowerCase()) {
@ -46,7 +47,7 @@ function refreshTunerDevices(page, providerInfo, devices) {
}
function onSelectPathClick(e) {
const page = $(e.target).parents('.xmltvForm')[0];
const page = dom.parentWithClass(e.target, 'xmltvForm');
import('../directorybrowser/directorybrowser').then(({ default: DirectoryBrowser }) => {
const picker = new DirectoryBrowser();