<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 selectedItems = this._getSelectedItems();
    
		if(selectedItems.length == 0){
		    this._fireCurrentItemChanged(null, false);
		}else if(selectedItems.length == 1){
		 this._currentItem = selectedItems[0];
		}
		
		var ci = this._currentItem;
    this._styleItem(ci != null && ci.item != null ? ci.item : null);
    
		
		this.element.trigger(<commit_msg>Fixes https://jira.duraspace.org/browse/DURACLOUD-910: Clicking on the checkbox next to a space causes the application to hang.<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;
	},
	
	_setCurrentItem: function(item){
    this._currentItem = {
                         item:item, 
                         data: this._getDataById($(item).attr("id")),
                       };
	},
	
	_fireCurrentItemChanged: function(item, notify){
		
		if(item != null){
		  this._setCurrentItem(item);
		}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 selectedItems = this._getSelectedItems();
    
		if(selectedItems.length == 0){
		    this._fireCurrentItemChanged(null, false);
		}else if(selectedItems.length == 1){
		 this._currentItem = this._setCurrentItem(selectedItems[0]);
		}
		
		var ci = this._currentItem;
    this._styleItem(ci != null && ci.item != null ? ci.item : null);
    
		
		this.element.trigger(
{'fraction_non_alphanumeric': 0.21722204920585486, 'fraction_numerical': 0.0020242914979757085, 'mean_word_length': 2.7715795654726954, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 1, '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': '1461862', 'n_tokens_mistral': 2256, 'n_tokens_neox': 1961, 'n_words': 324}