Revised to store the newly-constructed period chooser and month chooser in variables to prevent SonarQube from complaining.

This commit is contained in:
依瑪貓 2023-03-08 14:22:29 +08:00
parent b19f4fa939
commit 7c3b8c8f44

View File

@ -24,7 +24,7 @@
// Initializes the page JavaScript. // Initializes the page JavaScript.
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
new PeriodChooser(); PeriodChooser.initialize();
}); });
/** /**
@ -63,6 +63,20 @@ class PeriodChooser {
this.tabPlanes[tab.tabId()] = tab; this.tabPlanes[tab.tabId()] = tab;
} }
} }
/**
* The period chooser.
* @type {PeriodChooser}
*/
static #chooser;
/**
* Initializes the period chooser.
*
*/
static initialize() {
this.#chooser = new PeriodChooser();
}
} }
/** /**
@ -143,6 +157,12 @@ class TabPlane {
*/ */
class MonthTab extends TabPlane { class MonthTab extends TabPlane {
/**
* The month chooser.
* @type {tempusDominus.TempusDominus}
*/
#monthChooser
/** /**
* Constructs a tab plane. * Constructs a tab plane.
* *
@ -152,7 +172,7 @@ class MonthTab extends TabPlane {
super(chooser); super(chooser);
const monthChooser = document.getElementById(this.prefix + "-chooser"); const monthChooser = document.getElementById(this.prefix + "-chooser");
let start = monthChooser.dataset.start; let start = monthChooser.dataset.start;
new tempusDominus.TempusDominus(monthChooser, { this.#monthChooser = new tempusDominus.TempusDominus(monthChooser, {
restrictions: { restrictions: {
minDate: start, minDate: start,
}, },