<commit_before>define([
	'jquery',
	'underscore',
	'backbone',
	'd3',

	'appconfig',
	'backendServiceM',
	'WaterfallChartV',
	'LocatingChartV',
	'DistributionChartV',
	'hbs!templates/chartsTabs'
	],
	function ($, _, Backbone, d3, appconfig, backendServiceM, WaterfallChartV, LocatingChartV, DistributionChartV,
		chartsTabsT) {

		var AppV = Backbone.View.extend({
			events: {},
			el: '#chart-wrapper',
			fragmentByChartName: {
				'distribution': 'répartition',
				'locating': 'se-situer',
				'waterfall': 'cascade'
			},
			width: null,
			height: null,
			initialize: function () {
				$(window).on('resize', $.proxy(this.updateDimensions, this));
				this.updateDimensions();
				this.$el
					.html(chartsTabsT({enableLocatingChart: appconfig.enabledModules.locatingChart}))
					.find('a[data-toggle="tab"]').on('shown.bs.tab', function(evt) {
						var href = $(evt.target).attr('href');
						window.location.hash = href;
					});
				this.$overlay = $('<div class="alert alert-info overlay">Simulation en cours…</div>')
					.hide()
					.appendTo(this.$el);
				this.listenTo(backendServiceM, 'change:simulationInProgress', this.updateOverlay);
			},
			render: function (chartName) {
				if (_.isUndefined(chartName)) {
					chartName = appconfig.enabledModules.locatingChart ? 'locating' : 'waterfall';
				}
				/* Switch menu */
				if(this.$el.find('.active').length === 0) {
					this.$el.find('.nav a[href="#' + this.fragmentByChartName[chartName] + '"]')
						.parent('li').addClass('active');
				}

				if(!_.isUndefined(this.chart)) this.outTransition();

				switch(chartName) {
					case 'waterfall':
						this.chart = new WaterfallChartV(this);
						break;
					case 'locating':
						if (appconfig.enabledModules.locatingChart) {
							this.chart = new LocatingChartV(this);
						}
						break;
					case 'distribution':
						this.chart = new DistributionChartV(this);
						break;
//					default:
//						console.error('_Error : No chart selected when called AppV.render');
				}
				return this;
			},
			outTransition: function () {
	            this.chart._remove();

	            $('svg').remove();
				this.chart.model.destroy();
			},
			updateDimensions: function() {
				this.width = Math.min(this.$el.width(), 1000);
				this.height = this.width * 0.66;
				this.$el.find('svg')
					.attr('width', this.width)
					.attr('height', this.height);
			},
			updateOverlay: function() {
				var simulationInProgress = backendServiceM.get('simulationInProgress');
				var $svg = this.$el.find('svg');
				if (simulationInProgress) {
					$svg.css('opacity', 0.1);
					this.$overlay.show();
				} else {
					$svg.css('opacity', 1);
					this.$overlay.hide();
				}
			}
		});

		var appV = new AppV();
		return appV;

	}
);
<commit_msg>Update overlay on init.<commit_after>define([
	'jquery',
	'underscore',
	'backbone',
	'd3',

	'appconfig',
	'backendServiceM',
	'WaterfallChartV',
	'LocatingChartV',
	'DistributionChartV',
	'hbs!templates/chartsTabs'
	],
	function ($, _, Backbone, d3, appconfig, backendServiceM, WaterfallChartV, LocatingChartV, DistributionChartV,
		chartsTabsT) {

		var AppV = Backbone.View.extend({
			events: {},
			el: '#chart-wrapper',
			fragmentByChartName: {
				'distribution': 'répartition',
				'locating': 'se-situer',
				'waterfall': 'cascade'
			},
			width: null,
			height: null,
			initialize: function () {
				$(window).on('resize', $.proxy(this.updateDimensions, this));
				this.updateDimensions();
				this.$el
					.html(chartsTabsT({enableLocatingChart: appconfig.enabledModules.locatingChart}))
					.find('a[data-toggle="tab"]').on('shown.bs.tab', function(evt) {
						var href = $(evt.target).attr('href');
						window.location.hash = href;
					});
				this.$overlay = $('<div class="alert alert-info overlay">Simulation en cours…</div>')
					.hide()
					.appendTo(this.$el);
				this.listenTo(backendServiceM, 'change:simulationInProgress', this.updateOverlay);
				this.updateOverlay();
			},
			render: function (chartName) {
				if (_.isUndefined(chartName)) {
					chartName = appconfig.enabledModules.locatingChart ? 'locating' : 'waterfall';
				}
				/* Switch menu */
				if(this.$el.find('.active').length === 0) {
					this.$el.find('.nav a[href="#' + this.fragmentByChartName[chartName] + '"]')
						.parent('li').addClass('active');
				}

				if(!_.isUndefined(this.chart)) this.outTransition();

				switch(chartName) {
					case 'waterfall':
						this.chart = new WaterfallChartV(this);
						break;
					case 'locating':
						if (appconfig.enabledModules.locatingChart) {
							this.chart = new LocatingChartV(this);
						}
						break;
					case 'distribution':
						this.chart = new DistributionChartV(this);
						break;
//					default:
//						console.error('_Error : No chart selected when called AppV.render');
				}
				return this;
			},
			outTransition: function () {
	            this.chart._remove();

	            $('svg').remove();
				this.chart.model.destroy();
			},
			updateDimensions: function() {
				this.width = Math.min(this.$el.width(), 1000);
				this.height = this.width * 0.66;
				this.$el.find('svg')
					.attr('width', this.width)
					.attr('height', this.height);
			},
			updateOverlay: function() {
				var simulationInProgress = backendServiceM.get('simulationInProgress');
				var $svg = this.$el.find('svg');
				if (simulationInProgress) {
					$svg.css('opacity', 0.1);
					this.$overlay.show();
				} else {
					$svg.css('opacity', 1);
					this.$overlay.hide();
				}
			}
		});

		var appV = new AppV();
		return appV;

	}
);

{'fraction_non_alphanumeric': 0.1736409155937053, 'fraction_numerical': 0.004649499284692418, 'mean_word_length': 3.146034099332839, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '359309', 'n_tokens_mistral': 2361, 'n_tokens_neox': 1833, 'n_words': 316}