<commit_before>function SwatAccordion(id)
{
	this.id = id;
	this.current_page = null;
	this.semaphore = false;
	this.pageChangeEvent = new YAHOO.util.CustomEvent('pageChange');

	YAHOO.util.Event.onDOMReady(this.init, this, true);
}

SwatAccordion.resize_period = 0.25; // seconds

SwatAccordion.prototype.init = function()
{
	this.container = document.getElementById(this.id);
	this.pages = [];

	var page;
	var pages = YAHOO.util.Dom.getChildren(this.container);
	for (var i = 0; i < pages.length; i++) {

		page = new SwatAccordionPage(pages[i]);

		var status_icon = document.createElement('span');
		status_icon.className = 'swat-accordion-toggle-status';

		if (YAHOO.util.Dom.hasClass(page.element, 'selected')) {
			YAHOO.util.Dom.removeClass(page.element, 'selected');
			this.current_page = page;
			page.element.className += ' swat-accordion-page-opened';
		} else {
			page.animation.style.display = 'none';
			page.element.className += ' swat-accordion-page-closed';
		}

		page.toggle.insertBefore(status_icon, page.toggle.firstChild);

		var that = this;
		(function() {
			var the_page = page;
			YAHOO.util.Event.on(page.toggle, 'click', function (e) {
				YAHOO.util.Event.preventDefault(e);
				that.setPageWithAnimation(the_page);
			});
		})();

		this.pages.push(page);
	}

};

SwatAccordion.prototype.setPage = function(page)
{
	if (this.current_page === page) {
		return;
	}

	for (var i = 0; i < this.pages.length; i++) {
		if (this.pages[i] === page) {
			this.pages[i].animation.style.display = 'block';
			this.pages[i].setStatus('opened');
		} else {
			this.pages[i].animation.style.display = 'none';
			this.pages[i].setStatus('closed');
		}
	}

	this.pageChangeEvent.fire(page, this.current_page);

	this.current_page = page;
};

SwatAccordion.prototype.setPageWithAnimation = function(new_page)
{
	if (this.current_page === new_page || this.semaphore) {
		return;
	}

	this.semaphore = true;

	var old_page = this.current_page;

	var old_region = YAHOO.util.Dom.getRegion(old_page.animation);
	var old_from_height = old_region.height;
	var old_to_height = 0;
	old_page.animation.style.overflow = 'hidden';

	new_page.animation.style.overflow = 'hidden';
	if (new_page.animation.style.height == '' ||
		new_page.animation.style.height == 'auto') {
		new_page.animation.style.height = '0';
		new_from_height = 0;
	} else {
		new_from_height = parseInt(new_page.animation.style.height);
	}
	new_page.animation.style.display = 'block';

	var new_region = YAHOO.util.Dom.getRegion(new_page.content);
	var new_to_height = new_region.height;

	var anim = new YAHOO.util.Anim(
		new_page.animation, { opacity: { to: 2 } }, // TODO
		SwatAccordion.resize_period,
		YAHOO.util.Easing.easeBoth);

	anim.onTween.subscribe(function (name, data) {
		var new_height = Math.floor(
			anim.doMethod('height', new_from_height, new_to_height));

		var old_height = Math.ceil(
			anim.doMethod('height', old_from_height, old_to_height));

		old_page.animation.style.height = old_height + 'px';
		new_page.animation.style.height = new_height + 'px';
	}, this, true);

	anim.onComplete.subscribe(function () {
		new_page.animation.style.height = 'auto';
		this.semaphore = false;
	}, this, true);

	anim.animate();

	old_page.setStatus('closed');
	new_page.setStatus('opened');

	this.pageChangeEvent.fire(new_page, old_page);
<commit_msg>Use empty attributes instead of opacity.<commit_after>function SwatAccordion(id)
{
	this.id = id;
	this.current_page = null;
	this.semaphore = false;
	this.pageChangeEvent = new YAHOO.util.CustomEvent('pageChange');

	YAHOO.util.Event.onDOMReady(this.init, this, true);
}

SwatAccordion.resize_period = 0.25; // seconds

SwatAccordion.prototype.init = function()
{
	this.container = document.getElementById(this.id);
	this.pages = [];

	var page;
	var pages = YAHOO.util.Dom.getChildren(this.container);
	for (var i = 0; i < pages.length; i++) {

		page = new SwatAccordionPage(pages[i]);

		var status_icon = document.createElement('span');
		status_icon.className = 'swat-accordion-toggle-status';

		if (YAHOO.util.Dom.hasClass(page.element, 'selected')) {
			YAHOO.util.Dom.removeClass(page.element, 'selected');
			this.current_page = page;
			page.element.className += ' swat-accordion-page-opened';
		} else {
			page.animation.style.display = 'none';
			page.element.className += ' swat-accordion-page-closed';
		}

		page.toggle.insertBefore(status_icon, page.toggle.firstChild);

		var that = this;
		(function() {
			var the_page = page;
			YAHOO.util.Event.on(page.toggle, 'click', function (e) {
				YAHOO.util.Event.preventDefault(e);
				that.setPageWithAnimation(the_page);
			});
		})();

		this.pages.push(page);
	}

};

SwatAccordion.prototype.setPage = function(page)
{
	if (this.current_page === page) {
		return;
	}

	for (var i = 0; i < this.pages.length; i++) {
		if (this.pages[i] === page) {
			this.pages[i].animation.style.display = 'block';
			this.pages[i].setStatus('opened');
		} else {
			this.pages[i].animation.style.display = 'none';
			this.pages[i].setStatus('closed');
		}
	}

	this.pageChangeEvent.fire(page, this.current_page);

	this.current_page = page;
};

SwatAccordion.prototype.setPageWithAnimation = function(new_page)
{
	if (this.current_page === new_page || this.semaphore) {
		return;
	}

	this.semaphore = true;

	var old_page = this.current_page;

	var old_region = YAHOO.util.Dom.getRegion(old_page.animation);
	var old_from_height = old_region.height;
	var old_to_height = 0;
	old_page.animation.style.overflow = 'hidden';

	new_page.animation.style.overflow = 'hidden';
	if (new_page.animation.style.height == '' ||
		new_page.animation.style.height == 'auto') {
		new_page.animation.style.height = '0';
		new_from_height = 0;
	} else {
		new_from_height = parseInt(new_page.animation.style.height);
	}
	new_page.animation.style.display = 'block';

	var new_region = YAHOO.util.Dom.getRegion(new_page.content);
	var new_to_height = new_region.height;

	var anim = new YAHOO.util.Anim(
		new_page.animation, { },
		SwatAccordion.resize_period,
		YAHOO.util.Easing.easeBoth);

	anim.onTween.subscribe(function (name, data) {
		var new_height = Math.floor(
			anim.doMethod('height', new_from_height, new_to_height));

		var old_height = Math.ceil(
			anim.doMethod('height', old_from_height, old_to_height));

		old_page.animation.style.height = old_height + 'px';
		new_page.animation.style.height = new_height + 'px';
	}, this, true);

	anim.onComplete.subscribe(function () {
		new_page.animation.style.height = 'auto';
		this.semaphore = false;
	}, this, true);

	anim.animate();

	old_page.setStatus('closed');
	new_page.setStatus('opened');

	this.pageChangeEvent.fire(new_page, old_page);

{'fraction_non_alphanumeric': 0.15447761194029852, 'fraction_numerical': 0.002537313432835821, 'mean_word_length': 4.3608, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1861901', 'n_tokens_mistral': 2648, 'n_tokens_neox': 2428, 'n_words': 379}