<commit_before>function setTouchMenu(origin) {
	var touchMenuElements = {
		root 				: 'touch-menu',
		button 				: 'touch-menu-button',
		dropdown 			: 'touch-menu-dropdown',
		drawer 				: 'touch-menu-drawer',
		helper 				: 'touch-menu-document-helper',
		helperWrapper 		: 'touch-menu-document-helper-wrapper'
	};

	var touchMenuStates = {
		ready 	: '__touch-menu--ready',
		active	: '__touch-menu--active'
	};

	var touchMenu = $('.' + touchMenuElements.root).not('.' + touchMenuStates.ready);
	if(touchMenu.length > 0) {
		var updateEvent;
		$(window).on({
			resize : function() {
				clearTimeout(updateEvent);
				updateEvent = setTimeout(function() {
					touchMenu.trigger('tipi.touchMenu.RESIZE', [touchMenu]);
				}, 100);
			}
		});

		touchMenu.each(function() {
			var touchMenu = $(this);
			var touchMenuButton = getTouchMenuElement('button', touchMenu, touchMenuElements);
			var touchMenuDropdown = getTouchMenuElement('dropdown', touchMenu, touchMenuElements);
			var touchMenuDrawer = getTouchMenuElement('drawer', touchMenu, touchMenuElements);

			if(touchMenuDropdown.length > 0 || touchMenuDrawer.length > 0) {
				touchMenu.addClass(touchMenuStates.ready);

				touchMenu.on({
					'tipi.touchMenu.TOGGLE' : function(event, touchMenu) {
						toggleTouchMenu(touchMenu, touchMenuElements, touchMenuStates);
					},
					'tipi.touchMenu.RESIZE' : function(event, touchMenu) {
						sizeTouchMenuDrawer(touchMenu, touchMenuElements);
					}
				});

				touchMenuButton.on({
					click : function(event) {
						event.preventDefault();

						var touchMenu = getTouchMenuElement('root', $(this), touchMenuElements);
						touchMenu.trigger('tipi.touchMenu.TOGGLE', [touchMenu]);
					}
				});

				//Trigger tipi.UPDATE so we can UPDATE OTHER components except this one.
				touchMenu.trigger('tipi.touchMenu.RESIZE', [touchMenu]);
			}
		});
	}
}

function getTouchMenuElement(type, origin, elements) {
	if(typeof type != 'undefined' && typeof origin != 'undefined') {
		var element;

		switch(type) {
			case 'root':
				element = origin.parents('.' + elements.root).first();
			break;
			case 'button':
				element = origin.find('.' + elements.button).first();
			break;
			case 'dropdown':
				element = origin.find('.' + elements.dropdown).first();
			break;
			case 'drawer':
				element = origin.find('.' + elements.drawer).first();
			break;
			default:
				element = undefined;
		}

		return element;
	}
}

function toggleTouchMenu(touchMenu, touchMenuElements, touchMenuStates) {
	touchMenu.toggleClass(touchMenuStates.active);
}

function sizeTouchMenuDrawer(touchMenu, touchMenuElements) {
	var touchMenuDrawer = getTouchMenuElement('drawer', touchMenu, touchMenuElements);

	touchMenuDrawer.css({
		'min-height' : $(window).outerHeight()
	});
}<commit_msg>Task: Only update height on window height chang<commit_after>function setTouchMenu(origin) {
	var touchMenuElements = {
		root 				: 'touch-menu',
		button 				: 'touch-menu-button',
		dropdown 			: 'touch-menu-dropdown',
		drawer 				: 'touch-menu-drawer',
		helper 				: 'touch-menu-document-helper',
		helperWrapper 		: 'touch-menu-document-helper-wrapper'
	};

	var touchMenuStates = {
		ready 	: '__touch-menu--ready',
		active	: '__touch-menu--active'
	};

	var touchMenu = $('.' + touchMenuElements.root).not('.' + touchMenuStates.ready);
	if(touchMenu.length > 0) {
		var documentWidth = $(document).width();
		var updateEvent;
		$(window).on({
			resize : function() {
				clearTimeout(updateEvent);
				updateEvent = setTimeout(function() {
					if(documentWidth != $(document).width()) {
						touchMenu.trigger('tipi.touchMenu.RESIZE', [touchMenu]);
					}
					documentWidth = $(document).width();
				}, 100);
			}
		});

		touchMenu.each(function() {
			var touchMenu = $(this);
			var touchMenuButton = getTouchMenuElement('button', touchMenu, touchMenuElements);
			var touchMenuDropdown = getTouchMenuElement('dropdown', touchMenu, touchMenuElements);
			var touchMenuDrawer = getTouchMenuElement('drawer', touchMenu, touchMenuElements);

			if(touchMenuDropdown.length > 0 || touchMenuDrawer.length > 0) {
				touchMenu.addClass(touchMenuStates.ready);

				touchMenu.on({
					'tipi.touchMenu.TOGGLE' : function(event, touchMenu) {
						toggleTouchMenu(touchMenu, touchMenuElements, touchMenuStates);
					},
					'tipi.touchMenu.RESIZE' : function(event, touchMenu) {
						sizeTouchMenuDrawer(touchMenu, touchMenuElements);
					}
				});

				touchMenuButton.on({
					click : function(event) {
						event.preventDefault();

						var touchMenu = getTouchMenuElement('root', $(this), touchMenuElements);
						touchMenu.trigger('tipi.touchMenu.TOGGLE', [touchMenu]);
					}
				});

				//Trigger tipi.UPDATE so we can UPDATE OTHER components except this one.
				touchMenu.trigger('tipi.touchMenu.RESIZE', [touchMenu]);
			}
		});
	}
}

function getTouchMenuElement(type, origin, elements) {
	if(typeof type != 'undefined' && typeof origin != 'undefined') {
		var element;

		switch(type) {
			case 'root':
				element = origin.parents('.' + elements.root).first();
			break;
			case 'button':
				element = origin.find('.' + elements.button).first();
			break;
			case 'dropdown':
				element = origin.find('.' + elements.dropdown).first();
			break;
			case 'drawer':
				element = origin.find('.' + elements.drawer).first();
			break;
			default:
				element = undefined;
		}

		return element;
	}
}

function toggleTouchMenu(touchMenu, touchMenuElements, touchMenuStates) {
	touchMenu.toggleClass(touchMenuStates.active);
}

function sizeTouchMenuDrawer(touchMenu, touchMenuElements) {
	var touchMenuDrawer = getTouchMenuElement('drawer', touchMenu, touchMenuElements);

	touchMenuDrawer.css({
		'min-height' : $(window).outerHeight()
	});
}
{'fraction_non_alphanumeric': 0.14513611929946246, 'fraction_numerical': 0.0020808045777700713, 'mean_word_length': 3.9005947323704335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1050417', 'n_tokens_mistral': 2158, 'n_tokens_neox': 1788, 'n_words': 328}