<commit_before>// --------------------------------------------------
// Used in generic autocompletes and designed to be
// extended by other views that need extended feature
// --------------------------------------------------
define(function (require) {
	
	// Dependencies
	var $ = require('jquery'),
		_ = require('underscore'),
		Backbone = require('backbone'),
		Autocomplete = require('decoy/views/autocomplete');
			
	// Public view module
	var Datalist = Autocomplete.extend({
		
		// Init
		initialize: function () {
			Autocomplete.prototype.initialize.call(this);
			
			// Cache selectors
			this.$status = this.$('button');
			this.$icon = this.$status.find('i');
			this.$hidden = this.$('input[type="hidden"]');
			
			// Add extra events
			this.events['click button'] = 'edit';
		},
		
		// Overide the match function to toggle the state of the match
		// icons and to set the hidden input field
		match: function() {
			Autocomplete.prototype.match.call(this);
			
			// Match found
			if (this.found) {
				this.$status.addClass('btn-info').prop('disabled', false).attr('href', this.route+'/'+this.id);
				this.$icon.removeClass().addClass('icon-pencil icon-white');
				this.$hidden.val(this.id);
			
			// Match cleared
			} else {
				this.$status.removeClass('btn-info').prop('disabled', true).removeAttr('href');
				this.$icon.removeClass().addClass('icon-ban-circle');
				this.$hidden.val('');
			}
		},
		
		// Visit the edit page
		edit: function(e) {
			e.preventDefault();
			location.href = this.route+'/'+this.$hidden.val();
		}
				
	});
	
	return Datalist;
});<commit_msg>Wiping datalist field if no match<commit_after>// --------------------------------------------------
// Used in generic autocompletes and designed to be
// extended by other views that need extended feature
// --------------------------------------------------
define(function (require) {
	
	// Dependencies
	var $ = require('jquery'),
		_ = require('underscore'),
		Backbone = require('backbone'),
		Autocomplete = require('decoy/views/autocomplete');
			
	// Public view module
	var Datalist = Autocomplete.extend({
		
		// Init
		initialize: function () {
			Autocomplete.prototype.initialize.call(this);
			
			// Cache selectors
			this.$status = this.$('button');
			this.$icon = this.$status.find('i');
			this.$hidden = this.$('input[type="hidden"]');
			
			// Add extra events
			this.events['click button'] = 'edit';
			this.events['blur input[type="text"]'] = 'blur';
		},
		
		// Overide the match function to toggle the state of the match
		// icons and to set the hidden input field
		match: function() {
			Autocomplete.prototype.match.call(this);
			
			// Match found
			if (this.found) {
				this.$status.addClass('btn-info').prop('disabled', false).attr('href', this.route+'/'+this.id);
				this.$icon.removeClass().addClass('icon-pencil icon-white');
				this.$hidden.val(this.id);
			
			// Match cleared
			} else {
				this.$status.removeClass('btn-info').prop('disabled', true).removeAttr('href');
				this.$icon.removeClass().addClass('icon-ban-circle');
				this.$hidden.val('');
			}
		},
		
		// Clear the field if there is no match on blur
		blur: function(e) {
			if (!this.found) this.$input.val('');
		},
		
		// Visit the edit page
		edit: function(e) {
			e.preventDefault();
			location.href = this.route+'/'+this.$hidden.val();
		}
				
	});
	
	return Datalist;
});
{'fraction_non_alphanumeric': 0.22163588390501318, 'fraction_numerical': 0.0, 'mean_word_length': 2.521155830753354, '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': '4010376', 'n_tokens_mistral': 1183, 'n_tokens_neox': 975, 'n_words': 225}