<commit_before>"use strict";

var ProjectView = Backbone.View.extend({

	events: {

		'blur input.js-title': 'collectData',
		'keyup input.js-title': 'onInputKeyUp'
	},


	initialize: function (options) {

		this.$title = this.$el.find('input.js-title');
		this.$projection = this.$el.find('p.js-estimate');

		this.treeEventReciever = _.extend({}, Backbone.Events);

		this.applyModel();
		this.model.on('change', this.applyModel, this);

		// TODO: Does this cause leaks? Use this.listenTo(model, 'eventName', callback) instead?
		this.model.on('focus', function () { this.$title.focus(); }, this);
		this.model.on('close', this.remove, this);

		this.treeView = new ProjectTreeView({
			el: this.$('.tree-view'),
			model: this.model
		});
		this.model.once('sync', function (model) {

			model.calculateProjection();
		})
	},


	onInputKeyUp: function (event) {

		if (event.keyCode == 13) {

			this.collectData();
		}
	},


	onDragStart: function () {

		this.$el.toggleClass('dragging', true);
	},


	onDragStop: function () {

		this.$el.toggleClass('dragging', false);
	},


	applyModel: function () {

		this.$title.val(this.model.get('title'));

		var projection = this.model.get('projection');
		this.$projection.text(projection ? (
			'From ' + Duration.formatRounded(projection.min) +
			' to ' + Duration.formatRounded(projection.max)
		) : 'no projection');
	},


	collectData: function (){

		// Save data.
		this.model.save({<commit_msg>Hid projection when not available.<commit_after>"use strict";

var ProjectView = Backbone.View.extend({

	events: {

		'blur input.js-title': 'collectData',
		'keyup input.js-title': 'onInputKeyUp'
	},


	initialize: function (options) {

		this.$title = this.$el.find('input.js-title');
		this.$projection = this.$el.find('p.js-estimate');

		this.treeEventReciever = _.extend({}, Backbone.Events);

		this.applyModel();
		this.model.on('change', this.applyModel, this);

		// TODO: Does this cause leaks? Use this.listenTo(model, 'eventName', callback) instead?
		this.model.on('focus', function () { this.$title.focus(); }, this);
		this.model.on('close', this.remove, this);

		this.treeView = new ProjectTreeView({
			el: this.$('.tree-view'),
			model: this.model
		});
		this.model.once('sync', function (model) {

			model.calculateProjection();
		})
	},


	onInputKeyUp: function (event) {

		if (event.keyCode == 13) {

			this.collectData();
		}
	},


	onDragStart: function () {

		this.$el.toggleClass('dragging', true);
	},


	onDragStop: function () {

		this.$el.toggleClass('dragging', false);
	},


	applyModel: function () {

		this.$title.val(this.model.get('title'));

		var projection = this.model.get('projection');
		this.$projection
			.text(projection ? (
				'From ' + Duration.formatRounded(projection.min) +
				' to ' + Duration.formatRounded(projection.max)
			) : 'No projection')
			.toggle(!!projection);
	},


	collectData: function (){

		// Save data.
		this.model.save({
{'fraction_non_alphanumeric': 0.18562267971650354, 'fraction_numerical': 0.0013499831252109348, 'mean_word_length': 3.796116504854369, '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': '7286377', 'n_tokens_mistral': 1138, 'n_tokens_neox': 992, 'n_words': 179}