* Default implementation for a container visibility handler due to the dependencies of its
* children that only considers the visibility of all of its children.
*
- * @author Matthias Schmidt
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module WoltLabSuite/Core/Form/Builder/Field/Dependency/Container/Default
- * @see module:WoltLabSuite/Core/Form/Builder/Field/Dependency/Abstract
- * @since 5.2
+ * @author Matthias Schmidt
+ * @copyright 2001-2020 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Form/Builder/Field/Dependency/Container/Default
+ * @see module:WoltLabSuite/Core/Form/Builder/Field/Dependency/Abstract
+ * @since 5.2
*/
-define(['./Abstract', 'Core', '../Manager'], function (Abstract, Core, DependencyManager) {
+define(["require", "exports", "tslib", "./Abstract", "../../../../../Core", "../Manager"], function (require, exports, tslib_1, Abstract_1, Core, Manager_1) {
"use strict";
- /**
- * @constructor
- */
- function Default(containerId) {
- this.init(containerId);
- }
- ;
- Core.inherit(Default, Abstract, {
- /**
- * @see WoltLabSuite/Core/Form/Builder/Field/Dependency/Container/Default#checkContainer
- */
- checkContainer: function () {
- if (elDataBool(this._container, 'ignore-dependencies')) {
+ Abstract_1 = tslib_1.__importDefault(Abstract_1);
+ Core = tslib_1.__importStar(Core);
+ Manager_1 = tslib_1.__importDefault(Manager_1);
+ class Default extends Abstract_1.default {
+ checkContainer() {
+ if (Core.stringToBool(this._container.dataset.ignoreDependencies || "")) {
return;
}
// only consider containers that have not been hidden by their own dependencies
- if (DependencyManager.isHiddenByDependencies(this._container)) {
+ if (Manager_1.default.isHiddenByDependencies(this._container)) {
return;
}
- var containerIsVisible = !elIsHidden(this._container);
- var containerShouldBeVisible = false;
- var children = this._container.children;
- var start = 0;
- // ignore container header for visibility considerations
- if (this._container.children.item(0).tagName === 'H2' || this._container.children.item(0).tagName === 'HEADER') {
- var start = 1;
- }
- for (var i = start, length = children.length; i < length; i++) {
- if (!elIsHidden(children.item(i))) {
- containerShouldBeVisible = true;
- break;
+ const containerIsVisible = this._container.style.display !== "none";
+ 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";
+ });
if (containerIsVisible !== containerShouldBeVisible) {
if (containerShouldBeVisible) {
- elShow(this._container);
+ this._container.style.display = "block";
}
else {
- elHide(this._container);
+ this._container.style.display = "none";
}
// check containers again to make sure parent containers can react to
// changing the visibility of this container
- DependencyManager.checkContainers();
+ Manager_1.default.checkContainers();
}
}
- });
+ }
+ Core.enableLegacyInheritance(Default);
return Default;
});
+++ /dev/null
-/**
- * Default implementation for a container visibility handler due to the dependencies of its
- * children that only considers the visibility of all of its children.
- *
- * @author Matthias Schmidt
- * @copyright 2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @module WoltLabSuite/Core/Form/Builder/Field/Dependency/Container/Default
- * @see module:WoltLabSuite/Core/Form/Builder/Field/Dependency/Abstract
- * @since 5.2
- */
-define(['./Abstract', 'Core', '../Manager'], function(Abstract, Core, DependencyManager) {
- "use strict";
-
- /**
- * @constructor
- */
- function Default(containerId) {
- this.init(containerId);
- };
- Core.inherit(Default, Abstract, {
- /**
- * @see WoltLabSuite/Core/Form/Builder/Field/Dependency/Container/Default#checkContainer
- */
- checkContainer: function() {
- if (elDataBool(this._container, 'ignore-dependencies')) {
- return;
- }
-
- // only consider containers that have not been hidden by their own dependencies
- if (DependencyManager.isHiddenByDependencies(this._container)) {
- return;
- }
-
- var containerIsVisible = !elIsHidden(this._container);
- var containerShouldBeVisible = false;
-
- var children = this._container.children;
- var start = 0;
- // ignore container header for visibility considerations
- if (this._container.children.item(0).tagName === 'H2' || this._container.children.item(0).tagName === 'HEADER') {
- var start = 1;
- }
-
- for (var i = start, length = children.length; i < length; i++) {
- if (!elIsHidden(children.item(i))) {
- containerShouldBeVisible = true;
- break;
- }
- }
-
- if (containerIsVisible !== containerShouldBeVisible) {
- if (containerShouldBeVisible) {
- elShow(this._container);
- }
- else {
- elHide(this._container);
- }
-
- // check containers again to make sure parent containers can react to
- // changing the visibility of this container
- DependencyManager.checkContainers();
- }
- }
- });
-
- return Default;
-});
--- /dev/null
+/**
+ * Default implementation for a container visibility handler due to the dependencies of its
+ * children that only considers the visibility of all of its children.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2020 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLabSuite/Core/Form/Builder/Field/Dependency/Container/Default
+ * @see module:WoltLabSuite/Core/Form/Builder/Field/Dependency/Abstract
+ * @since 5.2
+ */
+
+import Abstract from "./Abstract";
+import * as Core from "../../../../../Core";
+import DependencyManager from "../Manager";
+
+class Default extends Abstract {
+ public checkContainer(): void {
+ if (Core.stringToBool(this._container.dataset.ignoreDependencies || "")) {
+ return;
+ }
+
+ // only consider containers that have not been hidden by their own dependencies
+ if (DependencyManager.isHiddenByDependencies(this._container)) {
+ return;
+ }
+
+ const containerIsVisible = this._container.style.display !== "none";
+ 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";
+ });
+
+ if (containerIsVisible !== containerShouldBeVisible) {
+ if (containerShouldBeVisible) {
+ this._container.style.display = "block";
+ } else {
+ this._container.style.display = "none";
+ }
+
+ // check containers again to make sure parent containers can react to
+ // changing the visibility of this container
+ DependencyManager.checkContainers();
+ }
+ }
+}
+
+Core.enableLegacyInheritance(Default);
+
+export = Default;