<commit_before>/**
 * @class Grid
 */
Juxta.Grid = function(grid) {
	this.init(grid);
}

Juxta.Grid.prototype = {
	statistics: {
		item: 'item',
		items: 'items',
		all: 0,
		selected: 0
	},
	content: null,
	from: null,
	cache: {},
	init: function(grid) {
		this.$container = $(grid);
		this.$bodyContainer = this.$container.find('.body');
		this.$body = this.$bodyContainer.find('table');
		this.$notFound = this.$bodyContainer.find('.not-found')
		this.head = this.$container.find('.head');
		this.$actions = this.$container.find('.actions');
		this.$context = this.$container.find('.context');

		var that = this;

		this.$body.change(function(event) {
			// Select/deselect row
			if ($(event.target).is('[type=checkbox]')) {
				$('.context:visible').hide();

				var $row = $(event.target).parent().parent();
				if ($(event.target).is('[type=checkbox]:checked')) {
					that.select($row);
				} else{
					that.deselect($row);
				}
			}

			// Count all and selected items
			that.statistics.all = that.$body.find('tr:not(tr tr):not(.content)').find('[type=checkbox]').length;
			that.statistics.selected = that.$body.find('tr:not(tr tr):not(.content)').find('[type=checkbox]:checked').length;

			// Change all, nothing links states
			if (that.statistics.all > 0 && that.statistics.all == that.statistics.selected) {
				that.$actions.find('.all').addClass('active');
				that.$actions.find('.nothing').removeClass('active');
			} else if(that.statistics.selected == 0) {
				that.$actions.find('.all').removeClass('active');
				that.$actions.find('.nothing').addClass('active');
			} else{
				that.$actions.find('.all').removeClass('active');
				that.$actions.find('.nothing').removeClass('active');
			}

			// Disable group actions' buttons if nothing selected, enable else
			if (that.statistics.selected < 1) {
				that.$actions.find('input[type=button]').attr('disabled', true);
			} else{
				that.$actions.find('input[type=button]').attr('disabled', false);
			}
		});

		// Trigger event with type equals action name
		this.$actions.bind('click', function() {
			var $button = $(event.target);
			if ($button.is('span.like-a, input') && $button.attr('name')) {
				that.$actions.trigger($button.attr('name'));
				that.$body.trigger($button.attr('name'));
			}
		});

		this.$actions.bind('all', function() {
			that.select();
		});
		this.$actions.bind('nothing', function() {
			that.deselect();
		});

		if (this.$context.is('.context')) {
			this.contextMenu = new Juxta.ContextMenu(this.$body, this.$container.find('.context'));
		}

	},
	height: function(height) {
		if (height) {<commit_msg>Fixed bug in JuxtaGrid in Firefox 4<commit_after>/**
 * @class Grid
 */
Juxta.Grid = function(grid) {
	this.init(grid);
}

Juxta.Grid.prototype = {
	statistics: {
		item: 'item',
		items: 'items',
		all: 0,
		selected: 0
	},
	content: null,
	from: null,
	cache: {},
	init: function(grid) {
		this.$container = $(grid);
		this.$bodyContainer = this.$container.find('.body');
		this.$body = this.$bodyContainer.find('table');
		this.$notFound = this.$bodyContainer.find('.not-found')
		this.head = this.$container.find('.head');
		this.$actions = this.$container.find('.actions');
		this.$context = this.$container.find('.context');

		var that = this;

		this.$body.change(function(event) {
			// Select/deselect row
			if ($(event.target).is('[type=checkbox]')) {
				$('.context:visible').hide();

				var $row = $(event.target).parent().parent();
				if ($(event.target).is('[type=checkbox]:checked')) {
					that.select($row);
				} else{
					that.deselect($row);
				}
			}

			// Count all and selected items
			that.statistics.all = that.$body.find('tr:not(tr tr):not(.content)').find('[type=checkbox]').length;
			that.statistics.selected = that.$body.find('tr:not(tr tr):not(.content)').find('[type=checkbox]:checked').length;

			// Change all, nothing links states
			if (that.statistics.all > 0 && that.statistics.all == that.statistics.selected) {
				that.$actions.find('.all').addClass('active');
				that.$actions.find('.nothing').removeClass('active');
			} else if(that.statistics.selected == 0) {
				that.$actions.find('.all').removeClass('active');
				that.$actions.find('.nothing').addClass('active');
			} else{
				that.$actions.find('.all').removeClass('active');
				that.$actions.find('.nothing').removeClass('active');
			}

			// Disable group actions' buttons if nothing selected, enable else
			if (that.statistics.selected < 1) {
				that.$actions.find('input[type=button]').attr('disabled', true);
			} else{
				that.$actions.find('input[type=button]').attr('disabled', false);
			}
		});

		// Trigger event with type equals action name
		this.$actions.bind('click', function(event) {
			var $button = $(event.target);
			if ($button.is('span.like-a, input') && $button.attr('name')) {
				that.$actions.trigger($button.attr('name'));
				that.$body.trigger($button.attr('name'));
			}
		});

		this.$actions.bind('all', function() {
			that.select();
		});
		this.$actions.bind('nothing', function() {
			that.deselect();
		});

		if (this.$context.is('.context')) {
			this.contextMenu = new Juxta.ContextMenu(this.$body, this.$container.find('.context'));
		}

	},
	height: function(height) {
		if (height) {
{'fraction_non_alphanumeric': 0.21530282893487754, 'fraction_numerical': 0.0020884754129485475, 'mean_word_length': 3.8642659279778395, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5676173', 'n_tokens_mistral': 1972, 'n_tokens_neox': 1689, 'n_words': 278}