<commit_before>// jQuery UI style "widget" for editing an iTop "dashlet"
$(function()
{
	// the widget definition, where "itop" is the namespace,
	// "dashlet" the widget name
	$.widget( "itop.dashlet",
	{
		// default options
		options:
		{
			dashlet_id: '',
			dashlet_class: ''
		},
	
		// the constructor
		_create: function()
		{
			var me = this; 

			this.element
			.addClass('itop-dashlet')
			.bind('click.itop-dashlet', function(event) { me._on_click(event); } );

			this._update();
		},
	
		// to call when the contents are changed
		_update: function()
		{
			var me = this; 

			this.closeBox = $('<div class="close-box"/>');
			this.closeBox
				.click(function() { me._remove_dashlet(); })
				.prependTo(this.element);
			if (this.element.hasClass('dashlet-selected'))
			{
				this.closeBox.show();
			}
			else
			{
				this.closeBox.hide();
			}

		},

		// called when created, and later when changing options
		_refresh: function()
		{
		},
		// events bound via _bind are removed automatically
		// revert other modifications here
		_destroy: function()
		{
			this.element
			.removeClass('itop-dashlet')
			.unbind('click.itop-dashlet');
			
			this.closeBox.remove();			
		},
		// _setOptions is called with a hash of all options that are changing
		_setOptions: function()
		{
			// in 1.9 would use _superApply
			this._superApply(arguments);
			this._update();
		},
		// _setOption is called for each individual option that is changing
		_setOption: function( key, value )
		{
			// in 1.9 would use _super
			this._superApply(arguments);
		},
		select: function()
		{
			this.element.addClass('dashlet-selected');
			this.closeBox.fadeIn(500);
			$('#event_bus').trigger('dashlet-selected', {'dashlet_id': this.options.dashlet_id, 'dashlet_class': this.options.dashlet_class});
		},
		deselect: function()
		{
			this.element.removeClass('dashlet-selected');
			this.closeBox.hide();
		},
		deselect_all: function()
		{
			$(':itop-dashlet').each(function(){
				var sId = $(this).attr('id');
				var oWidget = $(this).data('itopDashlet');
				if (oWidget)
				{
					oWidget.deselect();
				}
			});
		},
		_on_click: function(event)
		{
			this.deselect_all();
			this.select();
		},
		get_params: function()
		{
			var oParams = {};
			var oProperties = $('#dashlet_properties_'+this.options.dashlet_id);
            oProperties.find('.itop-property-field').each(function(){
                var oWidget = $(this).data('itopProperty_field');
                if (oWidget == undefined)
                {
                    oWidget = $(this).data('itopSelector_property_field');
                }
                if (oWidget && $(this).is(':visible'))
                {
                    var oVal = oWidget._get_committed_value();
                    oParams[oVal.name] = oVal.value;
                }
            });

			oParams.dashlet_id = this.options.dashlet_id;<commit_msg>N°1161 - Fix Dashlet Group By edition<commit_after>// jQuery UI style "widget" for editing an iTop "dashlet"
$(function()
{
	// the widget definition, where "itop" is the namespace,
	// "dashlet" the widget name
	$.widget( "itop.dashlet",
	{
		// default options
		options:
		{
			dashlet_id: '',
			dashlet_class: ''
		},
	
		// the constructor
		_create: function()
		{
			var me = this; 

			this.element
			.addClass('itop-dashlet')
			.bind('click.itop-dashlet', function(event) { me._on_click(event); } );

			this._update();
		},
	
		// to call when the contents are changed
		_update: function()
		{
			var me = this; 

			this.closeBox = $('<div class="close-box"/>');
			this.closeBox
				.click(function() { me._remove_dashlet(); })
				.prependTo(this.element);
			if (this.element.hasClass('dashlet-selected'))
			{
				this.closeBox.show();
			}
			else
			{
				this.closeBox.hide();
			}

		},

		// called when created, and later when changing options
		_refresh: function()
		{
		},
		// events bound via _bind are removed automatically
		// revert other modifications here
		_destroy: function()
		{
			this.element
			.removeClass('itop-dashlet')
			.unbind('click.itop-dashlet');
			
			this.closeBox.remove();			
		},
		// _setOptions is called with a hash of all options that are changing
		_setOptions: function()
		{
			// in 1.9 would use _superApply
			this._superApply(arguments);
			this._update();
		},
		// _setOption is called for each individual option that is changing
		_setOption: function( key, value )
		{
			// in 1.9 would use _super
			this._superApply(arguments);
		},
		select: function()
		{
			this.element.addClass('dashlet-selected');
			this.closeBox.fadeIn(500);
			$('#event_bus').trigger('dashlet-selected', {'dashlet_id': this.options.dashlet_id, 'dashlet_class': this.options.dashlet_class});
		},
		deselect: function()
		{
			this.element.removeClass('dashlet-selected');
			this.closeBox.hide();
		},
		deselect_all: function()
		{
			$(':itop-dashlet').each(function(){
				var sId = $(this).attr('id');
				var oWidget = $(this).data('itopDashlet');
				if (oWidget)
				{
					oWidget.deselect();
				}
			});
		},
		_on_click: function(event)
		{
			this.deselect_all();
			this.select();
		},
		get_params: function()
		{
			var oParams = {};
			var oProperties = $('#dashlet_properties_'+this.options.dashlet_id);
            oProperties.find('.itop-property-field').each(function(){
                var oWidget = $(this).data('itopProperty_field');
                if (oWidget == undefined)
                {
                    oWidget = $(this).data('itopSelector_property_field');
                }
				var oVal = oWidget._get_committed_value();
				oParams[oVal.name] = oVal.value;
            });

			oParams.dashlet_id = this.options.dashlet_id;
{'fraction_non_alphanumeric': 0.15208660729876025, 'fraction_numerical': 0.003143006809848088, 'mean_word_length': 2.6647472808701216, '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': '860365', 'n_tokens_mistral': 2214, 'n_tokens_neox': 1860, 'n_words': 381}