WebUI: migrate away from MooTools deprecated functions

https://mootools.net/core/docs/1.6.0/Core/Core#Deprecated-Functions
This commit is contained in:
Chocobo1 2024-04-21 15:32:36 +08:00
parent 4945ed576a
commit 1c7ecb7371
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
3 changed files with 10 additions and 15 deletions

View file

@ -130,8 +130,8 @@ let toggleFilterDisplay = function() {};
window.addEventListener("DOMContentLoaded", function() { window.addEventListener("DOMContentLoaded", function() {
const saveColumnSizes = function() { const saveColumnSizes = function() {
const filters_width = $('Filters').getSize().x; const filters_width = $('Filters').getSize().x;
const properties_height_rel = $('propertiesPanel').getSize().y / Window.getSize().y;
LocalPreferences.set('filters_width', filters_width); LocalPreferences.set('filters_width', filters_width);
const properties_height_rel = $('propertiesPanel').getSize().y / Window.getSize().y;
LocalPreferences.set('properties_height_rel', properties_height_rel); LocalPreferences.set('properties_height_rel', properties_height_rel);
}; };
@ -149,11 +149,7 @@ window.addEventListener("DOMContentLoaded", function() {
MochaUI.Desktop.initialize(); MochaUI.Desktop.initialize();
const buildTransfersTab = function() { const buildTransfersTab = function() {
let filt_w = LocalPreferences.get('filters_width'); const filt_w = Number(LocalPreferences.get('filters_width', 120));
if ($defined(filt_w))
filt_w = filt_w.toInt();
else
filt_w = 120;
new MochaUI.Column({ new MochaUI.Column({
id: 'filtersColumn', id: 'filtersColumn',
placement: 'left', placement: 'left',
@ -161,7 +157,6 @@ window.addEventListener("DOMContentLoaded", function() {
width: filt_w, width: filt_w,
resizeLimit: [1, 300] resizeLimit: [1, 300]
}); });
new MochaUI.Column({ new MochaUI.Column({
id: 'mainColumn', id: 'mainColumn',
placement: 'main' placement: 'main'
@ -1350,7 +1345,7 @@ window.addEventListener("DOMContentLoaded", function() {
height: null height: null
}); });
let prop_h = LocalPreferences.get('properties_height_rel'); let prop_h = LocalPreferences.get('properties_height_rel');
if ($defined(prop_h)) if (prop_h !== null)
prop_h = prop_h.toFloat() * Window.getSize().y; prop_h = prop_h.toFloat() * Window.getSize().y;
else else
prop_h = Window.getSize().y / 2.0; prop_h = Window.getSize().y / 2.0;

View file

@ -60,8 +60,8 @@ window.qBittorrent.PiecesBar = (() => {
'borderColor': 'var(--color-border-default)' 'borderColor': 'var(--color-border-default)'
}; };
if (parameters && ($type(parameters) === 'object')) if (parameters && (typeOf(parameters) === 'object'))
$extend(vals, parameters); Object.append(vals, parameters);
vals.height = Math.max(vals.height, 12); vals.height = Math.max(vals.height, 12);
const obj = new Element('div', { const obj = new Element('div', {
@ -73,7 +73,7 @@ window.qBittorrent.PiecesBar = (() => {
} }
}); });
obj.vals = vals; obj.vals = vals;
obj.vals.pieces = $pick(pieces, []); obj.vals.pieces = [pieces, []].pick();
obj.vals.canvas = new Element('canvas', { obj.vals.canvas = new Element('canvas', {
'id': vals.id + '_canvas', 'id': vals.id + '_canvas',

View file

@ -44,7 +44,7 @@ window.qBittorrent.ProgressBar = (function() {
initialize: function(value, parameters) { initialize: function(value, parameters) {
const vals = { const vals = {
'id': 'progressbar_' + (ProgressBars++), 'id': 'progressbar_' + (ProgressBars++),
'value': $pick(value, 0), 'value': [value, 0].pick(),
'width': 0, 'width': 0,
'height': 0, 'height': 0,
'darkbg': 'var(--color-background-blue)', 'darkbg': 'var(--color-background-blue)',
@ -52,8 +52,8 @@ window.qBittorrent.ProgressBar = (function() {
'lightbg': 'var(--color-background-default)', 'lightbg': 'var(--color-background-default)',
'lightfg': 'var(--color-text-default)' 'lightfg': 'var(--color-text-default)'
}; };
if (parameters && ($type(parameters) === 'object')) if (parameters && (typeOf(parameters) === 'object'))
$extend(vals, parameters); Object.append(vals, parameters);
if (vals.height < 12) if (vals.height < 12)
vals.height = 12; vals.height = 12;
const obj = new Element('div', { const obj = new Element('div', {
@ -68,7 +68,7 @@ window.qBittorrent.ProgressBar = (function() {
} }
}); });
obj.vals = vals; obj.vals = vals;
obj.vals.value = $pick(value, 0); // Fix by Chris obj.vals.value = [value, 0].pick();
obj.vals.dark = new Element('div', { obj.vals.dark = new Element('div', {
'id': vals.id + '_dark', 'id': vals.id + '_dark',
'class': 'progressbar_dark', 'class': 'progressbar_dark',