<commit_before>/**
 * Generic handler for collapsible bbcode boxes.
 * 
 * @author	<NAME>
 * @copyright	2001-2016 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @module	WoltLabSuite/Core/Bbcode/Collapsible
 */
define([], function() {
	"use strict";
	
	var _containers = elByClass('jsCollapsibleBbcode');
	
	/**
	 * @exports	WoltLabSuite/Core/Bbcode/Collapsible
	 */
	return {
		observe: function() {
			var container, toggleButton;
			while (_containers.length) {
				container = _containers[0];
				container.classList.remove('jsCollapsibleBbcode');
				
				toggleButton = elBySel('.toggleButton', container);
				if (toggleButton === null) {
					continue;
				}
				
				(function(container, toggleButton) {
					var toggle = function(event) {
						if (container.classList.toggle('collapsed')) {
							toggleButton.textContent = elData(toggleButton, 'title-expand');
							
							if (event instanceof Event) {
								// negative top value means the upper boundary is not within the viewport
								var top = container.getBoundingClientRect().top;
								if (top < 0) {
									var y = window.pageYOffset + (top - 100);
									if (y < 0) y = 0;
									window.scrollTo(window.pageXOffset, y);
								}
							}
						}
						else {
							toggleButton.textContent = elData(toggleButton, 'title-collapse');
						}
					};
					
					toggleButton.addEventListener(WCF_CLICK_EVENT, toggle);
					
					// expand boxes that are initially scrolled
					if (container.scrollTop !== 0) {
						toggle();
					}
				})(container, toggleButton);
			}
		}
	};
});<commit_msg>Fixed nested collapsible bbcode<commit_after>/**
 * Generic handler for collapsible bbcode boxes.
 * 
 * @author	<NAME>
 * @copyright	2001-2016 WoltLab GmbH
 * @license	GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
 * @module	WoltLabSuite/Core/Bbcode/Collapsible
 */
define([], function() {
	"use strict";
	
	var _containers = elByClass('jsCollapsibleBbcode');
	
	/**
	 * @exports	WoltLabSuite/Core/Bbcode/Collapsible
	 */
	return {
		observe: function() {
			var container, toggleButton;
			while (_containers.length) {
				container = _containers[0];
				
				toggleButton = elBySelAll('.toggleButton', container)[0];
				if (toggleButton === undefined) {
					continue;
				}
				
				if (toggleButton.closest('.jsCollapsibleBbcode') === container) {
					(function (container, toggleButton) {
						var toggle = function (event) {
							if (container.classList.toggle('collapsed')) {
								toggleButton.textContent = elData(toggleButton, 'title-expand');
								
								if (event instanceof Event) {
									// negative top value means the upper boundary is not within the viewport
									var top = container.getBoundingClientRect().top;
									if (top < 0) {
										var y = window.pageYOffset + (top - 100);
										if (y < 0) y = 0;
										window.scrollTo(window.pageXOffset, y);
									}
								}
							}
							else {
								toggleButton.textContent = elData(toggleButton, 'title-collapse');
							}
						};
						
						toggleButton.addEventListener(WCF_CLICK_EVENT, toggle);
						
						// expand boxes that are initially scrolled
						if (container.scrollTop !== 0) {
							toggle();
						}
					})(container, toggleButton);
				}
				
				container.classList.remove('jsCollapsibleBbcode');
			}
		}
	};
});
{'fraction_non_alphanumeric': 0.12445351209559895, 'fraction_numerical': 0.009618187117458467, 'mean_word_length': 2.635593220338983, 'pattern_counts': {'":': 0, '<': 11, '<?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': '6541073', 'n_tokens_mistral': 1474, 'n_tokens_neox': 1015, 'n_words': 230}