<commit_before>"use strict";

/*global module, require*/

var d3 = require("d3");

var makeToggleFunction = function(el, button) {
    return function() {
	var wasVisible = (el.style("visibility") === "visible");
	
	button.classed("element-visible", wasVisible ? false : true);
	el.style("visiblity", wasVisible ? "hidden" : "visible");
    };
};

/*
 Provides some functions which can be applied to an HTML element.
 */
module.exports = {
    drag: d3.behavior.drag()
	.origin(function(d){
	    var el = d3.select(this);
	    return {
		"x" : parseInt(el.style("left")),
		"y" : parseInt(el.style("top"))
	    };
	})
	.on("drag", function(d){
	    d3.select(this)
		.style("top", d3.event.y + "px")
		.style("left", d3.event.x + "px");
	}),

    open: function(el, button) {
	button
	    .classed("open-button", true)
	    .on("click", makeToggleFunction(el, button));
    },

    close: function(el, openButton) {
	var closeButton = el.append("span")
		.classed("close-button", true)
		.style("font-size", "large")
		.style("position", "absolute")
		.style("top", "5px")
		.style("right", "5px")
		.style("opacity", "0.6")
		.style("cursor", "pointer")
		.html("❌");

	if (openButton) {
	    closeButton.on("click", makeToggleFunction(el, openButton));
	    
	} else {
	    closeButton.on(
		"click", 
		function(d, i){
		    el.style("visibility", "hidden");
		}
	    );
	}
    },

    resize: function(el) {
	var dragHandle = d3.behavior.drag()
		.origin(function(d){
		    return {
			"x" : parseInt(el.style("width")),
			"y" : parseInt(el.style("height"))
		    };
		})
		.on("dragstart", function(d){
		    d3.event.sourceEvent.stopPropagation();
		})
		.on("drag", function(d){
		    el.style("height", d3.event.y + "px");
		    el.style("width", d3.event.x + "px");
		});

	el.append("span")
	    .style("font-size", "large")
	    .style("position", "absolute")
	    .style("bottom", "5px")
	    .style("right", "5px")
	    .style("opacity", "0.6")
	    .html("⇲")
	    .call(dragHandle);
    }
};<commit_msg>Fixed visibility toggle.<commit_after>"use strict";

/*global module, require*/

var d3 = require("d3");

var makeToggleFunction = function(el, button) {
    return function() {
	var wasVisible = (el.style("visibility") === "visible");
	
	button.classed("element-visible", wasVisible ? false : true);
	el.style("visibility", wasVisible ? "hidden" : "visible");
    };
};

/*
 Provides some functions which can be applied to an HTML element.
 */
module.exports = {
    drag: d3.behavior.drag()
	.origin(function(d){
	    var el = d3.select(this);
	    return {
		"x" : parseInt(el.style("left")),
		"y" : parseInt(el.style("top"))
	    };
	})
	.on("drag", function(d){
	    d3.select(this)
		.style("top", d3.event.y + "px")
		.style("left", d3.event.x + "px");
	}),

    open: function(el, button) {
	button
	    .classed("open-button", true)
	    .on("click", makeToggleFunction(el, button));
    },

    close: function(el, openButton) {
	var closeButton = el.append("span")
		.classed("close-button", true)
		.style("font-size", "large")
		.style("position", "absolute")
		.style("top", "5px")
		.style("right", "5px")
		.style("opacity", "0.6")
		.style("cursor", "pointer")
		.html("❌");

	if (openButton) {
	    closeButton.on("click", makeToggleFunction(el, openButton));
	    
	} else {
	    closeButton.on(
		"click", 
		function(d, i){
		    el.style("visibility", "hidden");
		}
	    );
	}
    },

    resize: function(el) {
	var dragHandle = d3.behavior.drag()
		.origin(function(d){
		    return {
			"x" : parseInt(el.style("width")),
			"y" : parseInt(el.style("height"))
		    };
		})
		.on("dragstart", function(d){
		    d3.event.sourceEvent.stopPropagation();
		})
		.on("drag", function(d){
		    el.style("height", d3.event.y + "px");
		    el.style("width", d3.event.x + "px");
		});

	el.append("span")
	    .style("font-size", "large")
	    .style("position", "absolute")
	    .style("bottom", "5px")
	    .style("right", "5px")
	    .style("opacity", "0.6")
	    .html("⇲")
	    .call(dragHandle);
    }
};
{'fraction_non_alphanumeric': 0.21802469135802469, 'fraction_numerical': 0.009382716049382716, 'mean_word_length': 3.1591375770020536, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4478594', 'n_tokens_mistral': 1591, 'n_tokens_neox': 1469, 'n_words': 272}