* @see module:WoltLabSuite/Core/Form/Builder/Field/Dependency/Abstract
* @since 5.2
*/
-define(["require", "exports", "tslib", "./Abstract", "../../../../../Core", "../Manager"], function (require, exports, tslib_1, Abstract_1, Core, DependencyManager) {
+define(["require", "exports", "tslib", "./Abstract", "../../../../../Core", "../Manager", "../../../../../Dom/Util"], function (require, exports, tslib_1, Abstract_1, Core, DependencyManager, Util_1) {
"use strict";
Abstract_1 = tslib_1.__importDefault(Abstract_1);
Core = tslib_1.__importStar(Core);
DependencyManager = tslib_1.__importStar(DependencyManager);
+ Util_1 = tslib_1.__importDefault(Util_1);
class Default extends Abstract_1.default {
checkContainer() {
if (Core.stringToBool(this._container.dataset.ignoreDependencies || "")) {
if (DependencyManager.isHiddenByDependencies(this._container)) {
return;
}
- const containerIsVisible = this._container.style.display !== "none";
+ const containerIsVisible = !Util_1.default.isHidden(this._container);
const containerShouldBeVisible = Array.from(this._container.children).some((child, index) => {
// ignore container header for visibility considerations
if (index === 0 && (child.tagName === "H2" || child.tagName === "HEADER")) {
return false;
}
- return child.style.display !== "none";
+ return !Util_1.default.isHidden(child);
});
if (containerIsVisible !== containerShouldBeVisible) {
if (containerShouldBeVisible) {
- this._container.style.display = "block";
+ Util_1.default.show(this._container);
}
else {
- this._container.style.display = "none";
+ Util_1.default.hide(this._container);
}
// check containers again to make sure parent containers can react to
// changing the visibility of this container
if (DependencyManager.isHiddenByDependencies(this._container)) {
return;
}
- const containerIsVisible = this._container.style.display !== "none";
- const containerShouldBeVisible = Array.from(this._container.children).some((child) => {
- return child.style.display !== "none";
- });
+ const containerIsVisible = !DomUtil.isHidden(this._container);
+ const containerShouldBeVisible = Array.from(this._container.children).some((child) => !DomUtil.isHidden(child));
if (containerIsVisible !== containerShouldBeVisible) {
const tabMenuListItem = this._container.parentNode.parentNode.querySelector("#" +
DomUtil.identify(this._container.parentNode) +
throw new Error("Cannot find tab menu entry for tab '" + this._container.id + "'.");
}
if (containerShouldBeVisible) {
- this._container.style.display = "block";
- tabMenuListItem.style.display = "block";
+ DomUtil.show(this._container);
+ DomUtil.show(tabMenuListItem);
}
else {
- this._container.style.display = "none";
- tabMenuListItem.style.display = "none";
+ DomUtil.hide(this._container);
+ DomUtil.hide(tabMenuListItem);
const tabMenu = UiTabMenu.getTabMenu(DomUtil.identify(tabMenuListItem.closest(".tabMenuContainer")));
// check if currently active tab will be hidden
if (tabMenu.getActiveTab() === tabMenuListItem) {
if (DependencyManager.isHiddenByDependencies(this._container)) {
return;
}
- const containerIsVisible = this._container.style.display !== "none";
+ const containerIsVisible = !DomUtil.isHidden(this._container);
const listItems = this._container.parentNode.querySelectorAll("#" + DomUtil.identify(this._container) + " > nav > ul > li");
- const containerShouldBeVisible = Array.from(listItems).some((child) => {
- return child.style.display !== "none";
- });
+ const containerShouldBeVisible = Array.from(listItems).some((child) => !DomUtil.isHidden(child));
if (containerIsVisible !== containerShouldBeVisible) {
if (containerShouldBeVisible) {
- this._container.style.display = "block";
+ DomUtil.show(this._container);
UiTabMenu.getTabMenu(DomUtil.identify(this._container)).selectFirstVisible();
}
else {
- this._container.style.display = "none";
+ DomUtil.hide(this._container);
}
// check containers again to make sure parent containers can react to
// changing the visibility of this container
* Hides the given node because of its own dependencies.
*/
function _hide(node) {
- node.style.display = "none";
+ Util_1.default.hide(node);
_dependencyHiddenNodes.add(node);
// also hide tab menu entry
if (node.classList.contains("tabMenuContent")) {
.querySelectorAll("li")
.forEach((tabLink) => {
if (tabLink.dataset.name === node.dataset.name) {
- tabLink.style.display = "none";
+ Util_1.default.hide(tabLink);
}
});
}
* Shows the given node because of its own dependencies.
*/
function _show(node) {
- node.style.display = "block";
+ Util_1.default.show(node);
_dependencyHiddenNodes.delete(node);
// also show tab menu entry
if (node.classList.contains("tabMenuContent")) {
.querySelectorAll("li")
.forEach((tabLink) => {
if (tabLink.dataset.name === node.dataset.name) {
- tabLink.style.display = "block";
+ Util_1.default.show(tabLink);
}
});
}
// if a container is shown, ignore all fields that
// have a hidden parent element within the container
let parentNode = validatedField.parentNode;
- while (parentNode !== node && parentNode.style.getPropertyValue("display") !== "none") {
+ while (parentNode !== node && !Util_1.default.isHidden(parentNode)) {
parentNode = parentNode.parentNode;
}
if (parentNode === node && _validatedFieldProperties.has(validatedField)) {
import Abstract from "./Abstract";
import * as Core from "../../../../../Core";
import * as DependencyManager from "../Manager";
+import DomUtil from "../../../../../Dom/Util";
class Default extends Abstract {
public checkContainer(): void {
return;
}
- const containerIsVisible = this._container.style.display !== "none";
+ const containerIsVisible = !DomUtil.isHidden(this._container);
const containerShouldBeVisible = Array.from(this._container.children).some((child: HTMLElement, index) => {
// ignore container header for visibility considerations
if (index === 0 && (child.tagName === "H2" || child.tagName === "HEADER")) {
return false;
}
- return child.style.display !== "none";
+ return !DomUtil.isHidden(child);
});
if (containerIsVisible !== containerShouldBeVisible) {
if (containerShouldBeVisible) {
- this._container.style.display = "block";
+ DomUtil.show(this._container);
} else {
- this._container.style.display = "none";
+ DomUtil.hide(this._container);
}
// check containers again to make sure parent containers can react to
return;
}
- const containerIsVisible = this._container.style.display !== "none";
- const containerShouldBeVisible = Array.from(this._container.children).some((child: HTMLElement) => {
- return child.style.display !== "none";
- });
+ const containerIsVisible = !DomUtil.isHidden(this._container);
+ const containerShouldBeVisible = Array.from(this._container.children).some(
+ (child: HTMLElement) => !DomUtil.isHidden(child),
+ );
if (containerIsVisible !== containerShouldBeVisible) {
const tabMenuListItem = this._container.parentNode!.parentNode!.querySelector(
}
if (containerShouldBeVisible) {
- this._container.style.display = "block";
- tabMenuListItem.style.display = "block";
+ DomUtil.show(this._container);
+ DomUtil.show(tabMenuListItem);
} else {
- this._container.style.display = "none";
- tabMenuListItem.style.display = "none";
+ DomUtil.hide(this._container);
+ DomUtil.hide(tabMenuListItem);
const tabMenu = UiTabMenu.getTabMenu(
DomUtil.identify(tabMenuListItem.closest(".tabMenuContainer") as HTMLElement),
return;
}
- const containerIsVisible = this._container.style.display !== "none";
+ const containerIsVisible = !DomUtil.isHidden(this._container);
const listItems = this._container.parentNode!.querySelectorAll(
"#" + DomUtil.identify(this._container) + " > nav > ul > li",
);
- const containerShouldBeVisible = Array.from(listItems).some((child: HTMLElement) => {
- return child.style.display !== "none";
- });
+ const containerShouldBeVisible = Array.from(listItems).some((child: HTMLElement) => !DomUtil.isHidden(child));
if (containerIsVisible !== containerShouldBeVisible) {
if (containerShouldBeVisible) {
- this._container.style.display = "block";
+ DomUtil.show(this._container);
UiTabMenu.getTabMenu(DomUtil.identify(this._container))!.selectFirstVisible();
} else {
- this._container.style.display = "none";
+ DomUtil.hide(this._container);
}
// check containers again to make sure parent containers can react to
* Hides the given node because of its own dependencies.
*/
function _hide(node: HTMLElement): void {
- node.style.display = "none";
+ DomUtil.hide(node);
_dependencyHiddenNodes.add(node);
// also hide tab menu entry
.querySelectorAll("li")
.forEach((tabLink) => {
if (tabLink.dataset.name === node.dataset.name) {
- tabLink.style.display = "none";
+ DomUtil.hide(tabLink);
}
});
}
* Shows the given node because of its own dependencies.
*/
function _show(node: HTMLElement): void {
- node.style.display = "block";
+ DomUtil.show(node);
_dependencyHiddenNodes.delete(node);
// also show tab menu entry
.querySelectorAll("li")
.forEach((tabLink) => {
if (tabLink.dataset.name === node.dataset.name) {
- tabLink.style.display = "block";
+ DomUtil.show(tabLink);
}
});
}
// if a container is shown, ignore all fields that
// have a hidden parent element within the container
let parentNode = validatedField.parentNode! as HTMLElement;
- while (parentNode !== node && parentNode.style.getPropertyValue("display") !== "none") {
+ while (parentNode !== node && !DomUtil.isHidden(parentNode)) {
parentNode = parentNode.parentNode! as HTMLElement;
}