<commit_before>/**
 * 
 * created by <NAME>
 */

/////////////////////////////////////////////////////////////////////////////////////
///selectable list widget
///
/////////////////////////////////////////////////////////////////////////////////////
(function(){
/**
 * Selectable list widget
 */
$.widget("ui.selectablelist",{
	
	/**
	 * Default values go here
	 */
	options: {
	
			itemClass: "dc-item"
		,   selectable: true
		,   clickable: true
		,   itemActionClass: "dc-action-panel"
			
	},
	
	_currentItem: null,
	_footer: null,
	dataMap: new Array(),
	
	_restyleSiblings: function(siblings){
		siblings.removeClass("dc-selected-list-item dc-checked-selected-list-item dc-checked-list-item");
		siblings.find("input[type='checkbox']:checked").closest("." +this.options.itemClass).addClass("dc-checked-list-item");
	},
	
	_styleItem:  function(target){
		if(target != undefined && target != null){
			var item = $(target).nearestOfClass(this.options.itemClass);
			$(item).removeClass("dc-checked-selected-list-item dc-checked-list-item dc-selected-list-item");
			var checked = $(item).find("input[type='checkbox']:checked").size() > 0;
			$(item).addClass(checked ? "dc-checked-selected-list-item" : "dc-selected-list-item");
			this._restyleSiblings(item.siblings());
		}else{
			this._restyleSiblings(this.element.children("."+this.options.itemClass));
		}
		
	},

	_getSelectedItems: function(){
		var array =  new Array();
		var items = this.element.find("."+this.options.itemClass).toArray();
		$.each(items, function(i, e){
			if($(e).find("input[type='checkbox']:checked").size() > 0){
				array.push(e);
			}
		});

		return array;
	},
	
	getSelectedData: function(){
		var that = this;
		var selected = this._getSelectedItems();
		var selectedData = new Array();
		$.each(selected, function(i,selectedItem){
			selectedData.push(that._getDataById($(selectedItem).attr("id")));
		});
		
		return selectedData;
	},
	
	_fireCurrentItemChanged: function(item, notify){
		
		if(item != null){
			this._currentItem = {
					item:item, 
					data: this._getDataById($(item).attr("id")),
				};
		}else{
			this._currentItem = null;
		}
		
		
		$("input[type='checkbox']:checked",this.element).removeAttr("checked");
		this._styleItem(item);
		if(item){
		    $(item).find("input[type='checkbox']")
		           .not("[disabled]")
		           .attr("checked",true);
		}

        var selectedItems = this._getSelectedItems();
		
		var fire = (notify == undefined || notify == null || notify == true);
		if(fire){
			this.element.trigger(
				"currentItemChanged",
				{	
					currentItem:this._currentItem, 
					selectedItems: selectedItems
				}
			);
		}
	},
	
	_fireSelectionChanged: function(){
		var ci = this._currentItem;
		this._styleItem(ci != null && ci.item != null ? ci.item : null);
		var selectedItems = this._getSelectedItems();
		
		if(selectedItems.length == 0){
		    this._fireCurrentItemChanged(null, false);
		}
		
		this.element.trigger(
			"selectionChanged", 
			{
				selectedItems: this._getSelectedItems(), 
				currentItem: this._currentItem,
			}
		);
	},

	_fireItemRemoved: function(item, data){
		this.element.trigger(
		  "itemRemoved", 
		  {
		      item: item,
		      data: data,
		  }
	    );
	},



	_itemSelectionStateChanged: function(target){
		var item = $(target).closest("."+this.options.itemClass);
		this._fireSelectionChanged(item);
	},
	
	clear: function(notify){
		this._currentItem = null;
		this.element.children("."+this.options.itemClass).remove();	
        this.element.children("."+this.options.itemClass + "-divider").remove(); 
		this.dataMap = new Array();
		this._fireCurrentItemChanged(null,notify);
		$(this._footer).html('');
	},
	
	/**
	 * Initialization 
	 */
	_init: function(){
		var that = this;
		this.clear();

		this._footer = $.fn.create("div").addClass("dc-selectablelist-footer").html("");
		$(that.element).append(that._footer);
		
		//add item classes to all direct children
		$(that.element).children("."+this.options.itemClass).each(function(i,c){
			that._initItem(c);
		});
		
		that.element.bind("selectionChanged", function(evt, state){
			var selectionChanged = that.options.selectionChanged;
			if(selectionChanged){
				selectionChanged(evt,state);
			}
		});
		
	},
	
	addItem: function(item, data, selected, /*optional boolean*/disabled){
		this.setFooter('');
		this._footer.before(item);
		this._initItem(item,data, disabled);
		
		if(selected && this.options.selectable){
			$("input[type=checkbox]",item).attr("checked", true);
		}
		
		return item;
	},
	
    addDivider: function(label){
        this.setFooter('');
        
        var divider = $.fn.create("div").addClass(this.options.itemClass+"-divider");
        divider.html(label);
        this._footer.before(divider);
    },<commit_msg>removes notification on selectablelist _init method.<commit_after>/**
 * 
 * created by <NAME>
 */

/////////////////////////////////////////////////////////////////////////////////////
///selectable list widget
///
/////////////////////////////////////////////////////////////////////////////////////
(function(){
/**
 * Selectable list widget
 */
$.widget("ui.selectablelist",{
	
	/**
	 * Default values go here
	 */
	options: {
	
			itemClass: "dc-item"
		,   selectable: true
		,   clickable: true
		,   itemActionClass: "dc-action-panel"
			
	},
	
	_currentItem: null,
	_footer: null,
	dataMap: new Array(),
	
	_restyleSiblings: function(siblings){
		siblings.removeClass("dc-selected-list-item dc-checked-selected-list-item dc-checked-list-item");
		siblings.find("input[type='checkbox']:checked").closest("." +this.options.itemClass).addClass("dc-checked-list-item");
	},
	
	_styleItem:  function(target){
		if(target != undefined && target != null){
			var item = $(target).nearestOfClass(this.options.itemClass);
			$(item).removeClass("dc-checked-selected-list-item dc-checked-list-item dc-selected-list-item");
			var checked = $(item).find("input[type='checkbox']:checked").size() > 0;
			$(item).addClass(checked ? "dc-checked-selected-list-item" : "dc-selected-list-item");
			this._restyleSiblings(item.siblings());
		}else{
			this._restyleSiblings(this.element.children("."+this.options.itemClass));
		}
		
	},

	_getSelectedItems: function(){
		var array =  new Array();
		var items = this.element.find("."+this.options.itemClass).toArray();
		$.each(items, function(i, e){
			if($(e).find("input[type='checkbox']:checked").size() > 0){
				array.push(e);
			}
		});

		return array;
	},
	
	getSelectedData: function(){
		var that = this;
		var selected = this._getSelectedItems();
		var selectedData = new Array();
		$.each(selected, function(i,selectedItem){
			selectedData.push(that._getDataById($(selectedItem).attr("id")));
		});
		
		return selectedData;
	},
	
	_fireCurrentItemChanged: function(item, notify){
		
		if(item != null){
			this._currentItem = {
					item:item, 
					data: this._getDataById($(item).attr("id")),
				};
		}else{
			this._currentItem = null;
		}
		
		
		$("input[type='checkbox']:checked",this.element).removeAttr("checked");
		this._styleItem(item);
		if(item){
		    $(item).find("input[type='checkbox']")
		           .not("[disabled]")
		           .attr("checked",true);
		}

        var selectedItems = this._getSelectedItems();
		
		var fire = (notify == undefined || notify == null || notify == true);
		if(fire){
			this.element.trigger(
				"currentItemChanged",
				{	
					currentItem:this._currentItem, 
					selectedItems: selectedItems
				}
			);
		}
	},
	
	_fireSelectionChanged: function(){
		var ci = this._currentItem;
		this._styleItem(ci != null && ci.item != null ? ci.item : null);
		var selectedItems = this._getSelectedItems();
		
		if(selectedItems.length == 0){
		    this._fireCurrentItemChanged(null, false);
		}
		
		this.element.trigger(
			"selectionChanged", 
			{
				selectedItems: this._getSelectedItems(), 
				currentItem: this._currentItem,
			}
		);
	},

	_fireItemRemoved: function(item, data){
		this.element.trigger(
		  "itemRemoved", 
		  {
		      item: item,
		      data: data,
		  }
	    );
	},



	_itemSelectionStateChanged: function(target){
		var item = $(target).closest("."+this.options.itemClass);
		this._fireSelectionChanged(item);
	},
	
	clear: function(notify){
		this._currentItem = null;
		this.element.children("."+this.options.itemClass).remove();	
        this.element.children("."+this.options.itemClass + "-divider").remove(); 
		this.dataMap = new Array();
		this._fireCurrentItemChanged(null,notify);
		$(this._footer).html('');
	},
	
	/**
	 * Initialization 
	 */
	_init: function(){
		var that = this;
		this.clear(false);

		this._footer = $.fn.create("div").addClass("dc-selectablelist-footer").html("");
		$(that.element).append(that._footer);
		
		//add item classes to all direct children
		$(that.element).children("."+this.options.itemClass).each(function(i,c){
			that._initItem(c);
		});
		
		that.element.unbind().bind("selectionChanged", function(evt, state){
			var selectionChanged = that.options.selectionChanged;
			if(selectionChanged){
				selectionChanged(evt,state);
			}
		});
		
	},
	
	addItem: function(item, data, selected, /*optional boolean*/disabled){
		this.setFooter('');
		this._footer.before(item);
		this._initItem(item,data, disabled);
		
		if(selected && this.options.selectable){
			$("input[type=checkbox]",item).attr("checked", true);
		}
		
		return item;
	},
	
    addDivider: function(label){
        this.setFooter('');
        
        var divider = $.fn.create("div").addClass(this.options.itemClass+"-divider");
        divider.html(label);
        this._footer.before(divider);
    },
{'fraction_non_alphanumeric': 0.20611082340756084, 'fraction_numerical': 0.0006214396685655101, 'mean_word_length': 3.063973063973064, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '6719259', 'n_tokens_mistral': 3465, 'n_tokens_neox': 2998, 'n_words': 469}