<commit_before>if (!tc) { var tc = {}; }

tc.carousel = makeClass();

tc.carousel.prototype.carousel = null;

tc.carousel.prototype.init = function(options) {
	tc.util.log("tc.carousel.init");
	
	this.options = tc.jQ.extend({
		element: null,
		scrollable: {
			items: ".items",
			speed: 300,
			circular: true
		},
		scrollPaneSelector: ".scrollable:first",
		pagination: false // { current: jQuery obj, total: jQuery obj }
	}, options);
	
	this.rendered = false;
	
	if (this.has_items() && this.options.element.is(":visible")) {
		this.render();
	} else {
		tc.util.log("postponing carousel rendering", "warn");
	}
};

tc.carousel.prototype.render = function() {
	var me, scrollpane, w, h;
	tc.util.log("tc.carousel.render");
	if (this.rendered === true) { 
		tc.util.log("carousel already rendered!!!", "warn");
		return;
	}
	me = this;
	w = this.options.element.width();
	h = 0;
	this.options.element.width(w);
	scrollpane = this.options.element.find(this.options.scrollPaneSelector);
	scrollpane.children(this.options.scrollable.items).children("li").each(function() {
		var item, item_height;
		item = tc.jQ(this);
		item.width(w);
		item_height = item.outerHeight();
		if (item_height > h) {
			h = item_height;
		}
	});
	scrollpane.height(h);
	this.carousel = scrollpane.scrollable(this.options.scrollable).data("scrollable");
	
	if (this.options.pagination) {
		this.carousel.onSeek(function(e, i) {
			me.update_pagination();
		});
		this.carousel.onAddItem(function(e, i) {
			me.update_pagination();
			// TODO (update "next" button if we've gone from have 1 item to having 2)
		});
	}
	
	this.options.element.find(".next, .prev").bind("click", function(e) {
		e.preventDefault();
	});
	
	this.rendered = true;
	this.update_pagination();
};

tc.carousel.prototype.update_pagination = function() {
	if (!this.rendered) { return; }
	tc.util.log("tc.carousel.update_pagination");
	if (this.options.pagination) {
		this.options.pagination.current.text( this.carousel.getIndex() + 1 );
		this.options.pagination.total.text( this.carousel.getSize() );
	}
};

tc.carousel.prototype.has_items = function() {<commit_msg>made next button hidden for goal carousels tha have only one goal (no. 492)<commit_after>if (!tc) { var tc = {}; }

tc.carousel = makeClass();

tc.carousel.prototype.carousel = null;

tc.carousel.prototype.init = function(options) {
	tc.util.log("tc.carousel.init");
	
	this.options = tc.jQ.extend({
		element: null,
		scrollable: {
			items: ".items",
			speed: 300,
			circular: true
		},
		scrollPaneSelector: ".scrollable:first",
		pagination: false // { current: jQuery obj, total: jQuery obj }
	}, options);
	
	this.rendered = false;
	
	if (this.has_items() && this.options.element.is(":visible")) {
		this.render();
	} else {
		tc.util.log("postponing carousel rendering", "warn");
	}
};

tc.carousel.prototype.render = function() {
	var me, scrollpane, w, h;
	tc.util.log("tc.carousel.render");
	if (this.rendered === true) { 
		tc.util.log("carousel already rendered!!!", "warn");
		return;
	}
	me = this;
	w = this.options.element.width();
	h = 0;
	this.options.element.width(w);
	scrollpane = this.options.element.find(this.options.scrollPaneSelector);
	scrollpane.children(this.options.scrollable.items).children("li").each(function() {
		var item, item_height;
		item = tc.jQ(this);
		item.width(w);
		item_height = item.outerHeight();
		if (item_height > h) {
			h = item_height;
		}
	});
	scrollpane.height(h);
	this.carousel = scrollpane.scrollable(this.options.scrollable).data("scrollable");
	
	this.carousel.onSeek(function(e, i) {
		me.update_pagination();
	});
	this.carousel.onAddItem(function(e, i) {
		me.update_navigation();
		me.update_pagination();
	});
	
	this.next_btn = this.options.element.find(".next");
	this.prev_btn = this.options.element.find(".prev");
	tc.jQ.each([this.next_btn, this.prev_btn], function() {
		if (this.length) {
			this.bind("click", function(e) {
				e.preventDefault();
			});
		}
	});
	
	this.rendered = true;
	this.update_navigation();
	this.update_pagination();
};

tc.carousel.prototype.update_navigation = function() {
	if (!this.rendered) { return; }
	tc.util.log("tc.carousel.update_navigation");
	if (this.carousel.getSize() < 2) {
		if (this.next_btn) { this.next_btn.hide(); }
		if (this.prev_btn) { this.prev_btn.hide(); }
	} else {
		if (this.next_btn) { this.next_btn.show(); }
		if (this.prev_btn) { this.prev_btn.show(); }
	}
};

tc.carousel.prototype.update_pagination = function() {
	if (!this.options.pagination || !this.rendered) { return; }
	tc.util.log("tc.carousel.update_pagination");
	if (this.options.pagination) {
		this.options.pagination.current.text( this.carousel.getIndex() + 1 );
		this.options.pagination.total.text( this.carousel.getSize() );
	}
};

tc.carousel.prototype.has_items = function() {
{'fraction_non_alphanumeric': 0.1797963001454999, 'fraction_numerical': 0.0033257119102057782, 'mean_word_length': 4.174193548387096, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 5, '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': '6941104', 'n_tokens_mistral': 1863, 'n_tokens_neox': 1740, 'n_words': 290}