<commit_before>// Make sure the document is loaded and jQuery is available.
$(document).ready(function() {
	// Disable the margin and the padding of the "UL" class that displays the tabs.
	OfficeUICore.DisableMargin($("#OfficeUI .ribbon .tabs > ul"));
	OfficeUICore.DisablePadding($("#OfficeUI .ribbon .tabs > ul"));

	// Make the first tab the application tab.
	$("#OfficeUI .ribbon .tabs > ul li[role=tab]:first-child").addClass("application");
	OfficeUICore.DisableMargin($("#OfficeUI .ribbon .tabs > ul li[role=tab]:first-child"));

	// Set the first tab as the active one.
	OfficeUICore.MakeActive($("#OfficeUI .ribbon .tabs > ul li[role=tab]:not(.application)").first());

	// When clicked on a tab, make sure it"s being activated.
	$("#OfficeUI .ribbon .tabs > ul li[role=tab]:not(.application)").click(function() {
		// Loop over all the tabs and deactivate them.
		$("#OfficeUI .ribbon .tabs > ul li[role=tab]").each(function(index) {
			OfficeUICore.MakeInactive(this);
		});

		// Activate the selected tab.
		OfficeUICore.MakeActive(this);
	});

	// See if an item is marked as a menuitem.
	// If that"s the case, auto add a down arrow to indicate that this is a menuitem.
	$("#OfficeUI .ribbon .tabs > ul li[role=tab] .contents .group .icongroup .icon").children().each(function(index) {
		if ($(this).hasClass("menu")) {

			var element = $(this);

			$('<i class="fa fa-sort-asc arrow"></i>').appendTo($(this).prev());

			// Add a click event to the element that contains a menu.
			$(this).parent().click(function(e) {
                e.stopPropagation();

                // Check toggle state
                if(!$(this).data("state") || $(this).data("state") == 0) {
                    // If menu is closed, show it
                    $(element).show().parent().addClass("active");
                    
                    // Update state
                    $(this).data("state", 1);
                    
                } else if ($(this).data("state") == 1) {
                    // If menu is already open, close it
                    $(element).hide().parent().removeClass("active");
                    
                    // Update state
                    $(this).data("state", 0);
                }
                
			});
		}
	});
    
    $(document).click(function() {
        $(".menu").each(function() {
            $(this).hide().parent().data("state", 0).removeClass("active");
        });
    });
});<commit_msg>Make jQuery code more readable and forsee some comments.<commit_after>// Make sure the document is loaded and jQuery is available.
$(document).ready(function() {
	// Disable the margin and the padding of the "UL" class that displays the tabs.
	OfficeUICore.DisableMargin($("#OfficeUI .ribbon .tabs > ul"));
	OfficeUICore.DisablePadding($("#OfficeUI .ribbon .tabs > ul"));

	// Make the first tab the application tab and disable the margins.
	OfficeUICore.DisableMargin($("#OfficeUI .ribbon .tabs > ul li[role=tab]:first-child").addClass("application"));

	// Mark the first tab (not the application tab) as the active one.
	OfficeUICore.MakeActive($("#OfficeUI .ribbon .tabs > ul li[role=tab]:not(.application)").first());

	// Check if an item is marked as a "MenuItem". This indicates that there is an invisible dropdown which will be showed when you click on it.
	$("#OfficeUI .ribbon .tabs > ul li[role=tab] .contents .group .icongroup .icon").children().each(function(index) {
		if ($(this).hasClass("menu")) {

			// Gets the current element.
			var element = $(this);

			// Add the down arrow to indicate that there are some icons underneath it.
			$('<i class="fa fa-sort-asc arrow"></i>').appendTo($(this).prev());

			// Add a click event on the element which should show the dropdown.
			$(this).parent().click(function(e) {
                e.stopPropagation();

                // Check the "toggle" state.
                if(!$(this).data("state") || $(this).data("state") == 0) { // Menu is closed, so we should show it.
                    $(element).show().parent().addClass("active");
                    
                    // Update the current state.
                    $(this).data("state", 1);
                } else if ($(this).data("state") == 1) { // Menu is visible, so let's close it.
                    $(element).hide().parent().removeClass("active");
                    
                    // Update the state.
                    $(this).data("state", 0);
                }
                
			});
		}
	});
	


	// Event handlers for the Ribbon are placed here.

		// When you click on a tab (not the application tab), make sure that the correct contents are showed.
		$("#OfficeUI .ribbon .tabs > ul li[role=tab]:not(.application)").click(function() {
			
			// Deactivate all the tabs.
			$("#OfficeUI .ribbon .tabs > ul li[role=tab]").each(function(index) {
				OfficeUICore.MakeInactive(this);
			});

			// Activate the tab which is selected.
			OfficeUICore.MakeActive(this);
		});
    	
    	// When you click somewhere on the document, execute the following code.
	    $(document).click(function() {
	    	// Make sure that all dropdowns are closed and that the toggle state is updated.
	        $(".menu").each(function() {
	            $(this).hide().parent().data("state", 0).removeClass("active");
	        });
	    });
});
{'fraction_non_alphanumeric': 0.16090874953060458, 'fraction_numerical': 0.001877581674802854, 'mean_word_length': 2.3566477630749842, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 22, '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': '231077', 'n_tokens_mistral': 1615, 'n_tokens_neox': 1452, 'n_words': 457}