<commit_before>/**
 * Manages form field dependencies.
 * 
 * @author	<NAME>
 * @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/Manager
 * @since	5.2
 */
define(['Dictionary', 'Dom/ChangeListener', 'EventHandler', 'List', 'Dom/Traverse', 'Dom/Util', 'ObjectMap'], function(Dictionary, DomChangeListener, EventHandler, List, DomTraverse, DomUtil, ObjectMap) {
	"use strict";
	
	/**
	 * is `true` if containters are currently checked for their availablility, otherwise `false`
	 * @type	{boolean}
	 * @private
	 */
	var _checkingContainers = false;
	
	/**
	 * is `true` if containter will be checked again after the current check for their availablility
	 * has finished, otherwise `false`
	 * @type	{boolean}
	 * @private
	 */
	var _checkContainersAgain = true;
	
	/**
	 * list of containers hidden due to their own dependencies
	 * @type	{List}
	 * @private
	 */
	var _dependencyHiddenNodes = new List();
	
	/**
	 * list of fields for which event listeners have been registered
	 * @type	{Dictionary}
	 * @private
	 */
	var _fields = new Dictionary();
	
	/**
	 * list of registered forms
	 * @type	{List}
	 * @private
	 */
	var _forms = new List();
	
	/**
	 * list of dependencies grouped by the dependent node they belong to
	 * @type	{Dictionary}
	 * @private
	 */
	var _nodeDependencies = new Dictionary();
	
	/**
	 * cache of validation-related properties of hidden form fields
	 * @type	{ObjectMap}
	 * @private
	 */
	var _validatedFieldProperties = new ObjectMap();
	
	return {
		/**
		 * Hides the given node because of its own dependencies.
		 * 
		 * @param	{HTMLElement}	node	hidden node
		 * @protected
		 */
		_hide: function(node) {
			elHide(node);
			_dependencyHiddenNodes.add(node);
			
			// also hide tab menu entry
			if (node.classList.contains('tabMenuContent')) {
				elBySelAll('li', DomTraverse.prevByClass(node, 'tabMenu'), function(tabLink) {
					if (elData(tabLink, 'name') === elData(node, 'name')) {
						elHide(tabLink);
					}
				});
			}
			
			elBySelAll('[max], [maxlength], [min], [required]', node, function(validatedField) {
				var properties = new Dictionary();
				
				var max = elAttr(validatedField, 'max');
				if (max) {
					properties.set('max', max);
					validatedField.removeAttribute('max');
				}
				
				var maxlength = elAttr(validatedField, 'maxlength');
				if (maxlength) {
					properties.set('maxlength', maxlength);
					validatedField.removeAttribute('maxlength');
				}
				
				var min = elAttr(validatedField, 'min');
				if (min) {
					properties.set('min', min);
					validatedField.removeAttribute('min');
				}
				
				if (validatedField.required) {
					properties.set('required', true);
					validatedField.removeAttribute('required');
				}
				
				_validatedFieldProperties.set(validatedField, properties);
			});
		},
		
		/**
		 * Shows the given node because of its own dependencies.
		 * 
		 * @param	{HTMLElement}	node	shown node
		 * @protected
		 */
		_show: function(node) {
			elShow(node);
			_dependencyHiddenNodes.delete(node);
			
			// also show tab menu entry
			if (node.classList.contains('tabMenuContent')) {
				elBySelAll('li', DomTraverse.prevByClass(node, 'tabMenu'), function(tabLink) {
					if (elData(tabLink, 'name') === elData(node, 'name')) {
						elShow(tabLink);
					}
				});
			}<commit_msg>Fix hiding/showing tab menu entries due to form builder dependencies<commit_after>/**
 * Manages form field dependencies.
 * 
 * @author	<NAME>
 * @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/Manager
 * @since	5.2
 */
define(['Dictionary', 'Dom/ChangeListener', 'EventHandler', 'List', 'Dom/Util', 'ObjectMap'], function(Dictionary, DomChangeListener, EventHandler, List, DomUtil, ObjectMap) {
	"use strict";
	
	/**
	 * is `true` if containters are currently checked for their availablility, otherwise `false`
	 * @type	{boolean}
	 * @private
	 */
	var _checkingContainers = false;
	
	/**
	 * is `true` if containter will be checked again after the current check for their availablility
	 * has finished, otherwise `false`
	 * @type	{boolean}
	 * @private
	 */
	var _checkContainersAgain = true;
	
	/**
	 * list of containers hidden due to their own dependencies
	 * @type	{List}
	 * @private
	 */
	var _dependencyHiddenNodes = new List();
	
	/**
	 * list of fields for which event listeners have been registered
	 * @type	{Dictionary}
	 * @private
	 */
	var _fields = new Dictionary();
	
	/**
	 * list of registered forms
	 * @type	{List}
	 * @private
	 */
	var _forms = new List();
	
	/**
	 * list of dependencies grouped by the dependent node they belong to
	 * @type	{Dictionary}
	 * @private
	 */
	var _nodeDependencies = new Dictionary();
	
	/**
	 * cache of validation-related properties of hidden form fields
	 * @type	{ObjectMap}
	 * @private
	 */
	var _validatedFieldProperties = new ObjectMap();
	
	return {
		/**
		 * Hides the given node because of its own dependencies.
		 * 
		 * @param	{HTMLElement}	node	hidden node
		 * @protected
		 */
		_hide: function(node) {
			elHide(node);
			_dependencyHiddenNodes.add(node);
			
			// also hide tab menu entry
			if (node.classList.contains('tabMenuContent')) {
				elBySelAll('li', node.parentNode.querySelector('.tabMenu'), function(tabLink) {
					if (elData(tabLink, 'name') === elData(node, 'name')) {
						elHide(tabLink);
					}
				});
			}
			
			elBySelAll('[max], [maxlength], [min], [required]', node, function(validatedField) {
				var properties = new Dictionary();
				
				var max = elAttr(validatedField, 'max');
				if (max) {
					properties.set('max', max);
					validatedField.removeAttribute('max');
				}
				
				var maxlength = elAttr(validatedField, 'maxlength');
				if (maxlength) {
					properties.set('maxlength', maxlength);
					validatedField.removeAttribute('maxlength');
				}
				
				var min = elAttr(validatedField, 'min');
				if (min) {
					properties.set('min', min);
					validatedField.removeAttribute('min');
				}
				
				if (validatedField.required) {
					properties.set('required', true);
					validatedField.removeAttribute('required');
				}
				
				_validatedFieldProperties.set(validatedField, properties);
			});
		},
		
		/**
		 * Shows the given node because of its own dependencies.
		 * 
		 * @param	{HTMLElement}	node	shown node
		 * @protected
		 */
		_show: function(node) {
			elShow(node);
			_dependencyHiddenNodes.delete(node);
			
			// also show tab menu entry
			if (node.classList.contains('tabMenuContent')) {
				elBySelAll('li', node.parentNode.querySelector('.tabMenu'), function(tabLink) {
					if (elData(tabLink, 'name') === elData(node, 'name')) {
						elShow(tabLink);
					}
				});
			}
{'fraction_non_alphanumeric': 0.1361271676300578, 'fraction_numerical': 0.002890173410404624, 'mean_word_length': 3.3364661654135337, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3320220', 'n_tokens_mistral': 2573, 'n_tokens_neox': 2065, 'n_words': 555}