<commit_before>jsio('from common.javascript import Singleton, bind');

jsio('import browser.dimensions as dimensions');
jsio('import browser.dom as dom');
jsio('import browser.css as css');
jsio('import browser.events as events');

jsio('import browser.resizeManager');

jsio('import browser.UIComponent');

css.loadStyles(jsio.__path);

exports = Singleton(browser.UIComponent, function(supr) {
	
	this.init = function() {
		supr(this, 'init');
		this._resizeCallback = bind(this, 'onWindowResize');
	}
	
	this.createContent = function() {
		this.addClassName('Overlay');
		this._underlay = dom.create({ parent: this._element, className: 'underlay' });
		this._content = dom.create({ parent: this._element, className: 'content' });
	}
	
	this.show = function(content, notDismissable) {
		document.body.appendChild(this.getElement());
		this._content.innerHTML = '';
		this._content.appendChild(content);
		browser.resizeManager.onWindowResize(this._resizeCallback);
	}
	
	this.hide = function() {
		dom.remove(this._element);
		browser.resizeManager.cancelWindowResize(this._resizeCallback);
		events.remove(this._underlay, 'click', this._clickHandler);
	}
	
	this.onWindowResize = function(size) {
		dom.setStyle(this._underlay, size);
		var contentSize = dimensions.getSize(this._content.firstChild);
		dom.setStyle(this._content, { left: (size.width / 2) - (contentSize.width / 2),
			top: (size.height / 2) - (contentSize.height / 2) });
	}
})<commit_msg>If the overlay is not dismissable, you should not be able to remove it by clicking it<commit_after>jsio('from common.javascript import Singleton, bind');

jsio('import browser.dimensions as dimensions');
jsio('import browser.dom as dom');
jsio('import browser.css as css');
jsio('import browser.events as events');

jsio('import browser.resizeManager');

jsio('import browser.UIComponent');

css.loadStyles(jsio.__path);

exports = Singleton(browser.UIComponent, function(supr) {
	
	this.init = function() {
		supr(this, 'init');
		this._resizeCallback = bind(this, 'onWindowResize');
	}
	
	this.createContent = function() {
		this.addClassName('Overlay');
		this._underlay = dom.create({ parent: this._element, className: 'underlay' });
		this._content = dom.create({ parent: this._element, className: 'content' });
	}
	
	this.show = function(content, notDismissable) {
		document.body.appendChild(this.getElement());
		this._content.innerHTML = '';
		this._content.appendChild(content);
		browser.resizeManager.onWindowResize(this._resizeCallback);
		if (!notDismissable) {
			this._clickHandler = events.add(this._underlay, 'click', bind(this, 'hide'));
		}
	}
	
	this.hide = function() {
		dom.remove(this._element);
		browser.resizeManager.cancelWindowResize(this._resizeCallback);
		events.remove(this._underlay, 'click', this._clickHandler);
	}
	
	this.onWindowResize = function(size) {
		dom.setStyle(this._underlay, size);
		var contentSize = dimensions.getSize(this._content.firstChild);
		dom.setStyle(this._content, { left: (size.width / 2) - (contentSize.width / 2),
			top: (size.height / 2) - (contentSize.height / 2) });
	}
})
{'fraction_non_alphanumeric': 0.15344938749194068, 'fraction_numerical': 0.0025789813023855577, 'mean_word_length': 5.193612774451098, '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': '1962743', 'n_tokens_mistral': 1023, 'n_tokens_neox': 971, 'n_words': 189}