<commit_before>/*jshint eqnull: true */
function Modal(element, config) {
	this.overlay = document.createElement("div");
	this.overlay.classList.add("modal-overlay");
	if (config == null) {
		this.config = { keyboard: true };
	} 
	
	else {
		this.config = config;
	}


	if (element instanceof HTMLElement) {
		this.element = element;
	} 
	
	else {
		this.element = document.querySelector(element);
		if (this.element == null) {
			throw new Error("element does not exist.");
		} 
		
		else if (!this.element.classList.contains("modal")) {
			throw new Error("element must have class modal");
		}
	}

	if (this.overlay.style.zIndex === undefined || this.overlay.style.zIndex === "") {
		this.overlay.style.zIndex = 0;
	}
	this.element.style.zIndex = this.overlay.style.zIndex + 1;
	buttonsEl = this.element.querySelector(".modal-buttons");

	if (buttonsEl != null) {
		buttons = Array.prototype.slice.call(buttonsEl.childNodes);
		var _this = this;
		document.addEventListener("keyup", function(event) {
			if (_this.config.keyboard) {
				if (event.keyCode == 27 && this.element.classList.contains("active")) {
					event.preventDefault();
					_this.hide();
				}
			}
		});
		buttons.forEach(function(button) {
			//Checks if the button is actually an element.
			if (button.nodeType == 1) {
				if (button.classList.contains("positive")) {
					document.addEventListener("keyup", function(event) {
						if (_this.config.keyboard) {
							if (event.keyCode == 13 && _this.element.classList.contains("active")) {
								//Enter
								event.preventDefault();
								button.click();
							}
						}
					});
				}

				button.addEventListener("click", function(event) {
					var mainEvent = null;
					var secondaryEvent = null;

					try {
						mainEvent = new Event("pressed", { cancelable: true });
					}
					//Legacy support for IE and the likes
					catch (e) {
						mainEvent = document.createEvent("event");
						mainEvent.initEvent("pressed", false, true);
					}

					mainEvent.el = this;

					if (this.classList.contains("positive")) {
						try {
							secondaryEvent = new Event("positive-pressed", { cancelable: true });
						}
						//Legacy support for IE and the likes
						catch (e) {
							mainEvent = document.createEvent("event");
							mainEvent.initEvent("positive-pressed", false, true);
						}
					} 
					
					else if (this.classList.contains("negative")) {
						secondaryEvent = new Event("negative-pressed", { cancelable: true });
						try {
							secondaryEvent = new Event("negative-pressed", { cancelable: true });
						}
						//Legacy support for IE and the likes
						catch (e) {
							mainEvent = document.createEvent("event");
							mainEvent.initEvent("nevative-pressed", false, true);
						}
					}

					_this.element.dispatchEvent(mainEvent);

					if (secondaryEvent !== null) {
						secondaryEvent.el = this;
						_this.element.dispatchEvent(secondaryEvent);
					}

					if (!(mainEvent.defaultPrevented || secondaryEvent != null && secondaryEvent.defaultPrevented)) {
						_this.hide();
					}
				});
			}
		});
	}
}

Modal.prototype.show = function() {
	var event = null;

	try {
		event = new Event("show", { cancelable: true });
	}

	catch (e) {
		//Legacy support for IE and the likes.
		event = document.createEvent("event");
		event.initEvent("show", false, true);
	}

	this.element.dispatchEvent(event);
	if (!event.defaultPrevented) {
		this.element.classList.add("active");
		document.body.appendChild(this.overlay);
		this.overlay.classList.add("active");
	}
};

Modal.prototype.hide = function() {
	var event = null;
	try {
		event = new Event("hide", { cancelable: true });
	}
	
	catch (e){
		event = document.createEvent("event");	
		event.initEvent("hide", false, true);
	}

	this.element.dispatchEvent(event);
	if (!event.defaultPrevented) {
		this.element.classList.remove("active");
		this.overlay.addEventListener("transitionend", function(event) {
			this.parentNode.removeChild(this);
		});
		this.overlay.classList.remove("active");
	}
};

Modal.prototype.toggle = function() {
	if (this.element.classList.contains("active")) {
		this.hide();
	}

	else {
		this.show();
	}
};

Modal.prototype.addEventListener = function() {
	this.element.addEventListener.apply(this, arguments);
};
<commit_msg>Fix spacing in modal.js<commit_after>/*jshint eqnull: true */
function Modal(element, config) {
	this.overlay = document.createElement("div");
	this.overlay.classList.add("modal-overlay");
	if (config == null) {
		this.config = { keyboard: true };
	} 
	else {
		this.config = config;
	}


	if (element instanceof HTMLElement) {
		this.element = element;
	} 
	else {
		this.element = document.querySelector(element);
		if (this.element == null) {
			throw new Error("element does not exist.");
		} 
		else if (!this.element.classList.contains("modal")) {
			throw new Error("element must have class modal");
		}
	}

	if (this.overlay.style.zIndex === undefined || this.overlay.style.zIndex === "") {
		this.overlay.style.zIndex = 0;
	}
	this.element.style.zIndex = this.overlay.style.zIndex + 1;
	buttonsEl = this.element.querySelector(".modal-buttons");

	if (buttonsEl != null) {
		buttons = Array.prototype.slice.call(buttonsEl.childNodes);
		var _this = this;
		document.addEventListener("keyup", function(event) {
			if (_this.config.keyboard) {
				if (event.keyCode == 27 && this.element.classList.contains("active")) {
					event.preventDefault();
					_this.hide();
				}
			}
		});
		buttons.forEach(function(button) {
			//Checks if the button is actually an element.
			if (button.nodeType == 1) {
				if (button.classList.contains("positive")) {
					document.addEventListener("keyup", function(event) {
						if (_this.config.keyboard) {
							if (event.keyCode == 13 && _this.element.classList.contains("active")) {
								//Enter
								event.preventDefault();
								button.click();
							}
						}
					});
				}

				button.addEventListener("click", function(event) {
					var mainEvent = null;
					var secondaryEvent = null;

					try {
						mainEvent = new Event("pressed", { cancelable: true });
					}
					//Legacy support for IE and the likes
					catch (e) {
						mainEvent = document.createEvent("event");
						mainEvent.initEvent("pressed", false, true);
					}

					mainEvent.el = this;

					if (this.classList.contains("positive")) {
						try {
							secondaryEvent = new Event("positive-pressed", { cancelable: true });
						}
						//Legacy support for IE and the likes
						catch (e) {
							mainEvent = document.createEvent("event");
							mainEvent.initEvent("positive-pressed", false, true);
						}
					} 
					else if (this.classList.contains("negative")) {
						secondaryEvent = new Event("negative-pressed", { cancelable: true });
						try {
							secondaryEvent = new Event("negative-pressed", { cancelable: true });
						}
						//Legacy support for IE and the likes
						catch (e) {
							mainEvent = document.createEvent("event");
							mainEvent.initEvent("nevative-pressed", false, true);
						}
					}

					_this.element.dispatchEvent(mainEvent);

					if (secondaryEvent !== null) {
						secondaryEvent.el = this;
						_this.element.dispatchEvent(secondaryEvent);
					}

					if (!(mainEvent.defaultPrevented || secondaryEvent != null && secondaryEvent.defaultPrevented)) {
						_this.hide();
					}
				});
			}
		});
	}
}

Modal.prototype.show = function() {
	var event = null;

	try {
		event = new Event("show", { cancelable: true });
	}

	catch (e) {
		//Legacy support for IE and the likes.
		event = document.createEvent("event");
		event.initEvent("show", false, true);
	}

	this.element.dispatchEvent(event);
	if (!event.defaultPrevented) {
		this.element.classList.add("active");
		document.body.appendChild(this.overlay);
		this.overlay.classList.add("active");
	}
};

Modal.prototype.hide = function() {
	var event = null;
	try {
		event = new Event("hide", { cancelable: true });
	}
	
	catch (e){
		event = document.createEvent("event");	
		event.initEvent("hide", false, true);
	}

	this.element.dispatchEvent(event);
	if (!event.defaultPrevented) {
		this.element.classList.remove("active");
		this.overlay.addEventListener("transitionend", function(event) {
			this.parentNode.removeChild(this);
		});
		this.overlay.classList.remove("active");
	}
};

Modal.prototype.toggle = function() {
	if (this.element.classList.contains("active")) {
		this.hide();
	}
	else {
		this.show();
	}
};

Modal.prototype.addEventListener = function() {
	this.element.addEventListener.apply(this, arguments);
};

{'fraction_non_alphanumeric': 0.1541958041958042, 'fraction_numerical': 0.0016317016317016317, 'mean_word_length': 3.1434089811685175, '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': '1506709', 'n_tokens_mistral': 3291, 'n_tokens_neox': 2627, 'n_words': 525}