<commit_before>var $ = require('jquery');
var instance = require('./instance');
var dom = require('./dom');
var events = require('./events');
var meta = require('./meta');

/**
 * @class
 *
 * @param {Element} element
 * @param {Object} options
 */
var Stylefileinput = module.exports = function ( element, options ) {

	this.element = element;
	this.options = $.extend(true, {}, this.defaults, options);

	instance.setup.call(this);
	dom.setup.call(this);
	events.setup.call(this);

	if ( this.$el.prop('disabled') ) {
		this.$el.trigger('disable' + this.ens);
	}

};

$.extend(Stylefileinput.prototype, {

	/**
	 * @param  {Boolean} state
	 * @param  {Object} e
	 */
	toggleDisabledState: function ( state, e ) {
		this.$el.prop('disabled', state);
	},

	handleFocus: function () {

		this.$el.data(meta.ns.dataAttr + '-val', this.$el.val());

	},

	handleCheckChange: function () {

		if ( this.$el.val() && this.$el.val() !== this.$el.data(meta.ns.dataAttr + '-val') ) {
			this.$el.trigger('change' + this.ens);
		}

	},

	handleChange: function () {

		var fileName = this.$el.val().split(/\\/).pop();

		this.$val
			.text(fileName);

		this.$button
			.text(this.options.labels.buttonChange);

	},

	/**
	 * For IE and Opera, make sure change fires after choosing a file, using an async callback
	 */
	handleClick: function () {

		this.$el.data(meta.ns.dataAttr + '-val', this.$el.val());

		setTimeout($.proxy(this.handleCheckChange, this), 100);

	},<commit_msg>Canceling dialog sets input field to empty value<commit_after>var $ = require('jquery');
var instance = require('./instance');
var dom = require('./dom');
var events = require('./events');
var meta = require('./meta');

/**
 * @class
 *
 * @param {Element} element
 * @param {Object} options
 */
var Stylefileinput = module.exports = function ( element, options ) {

	this.element = element;
	this.options = $.extend(true, {}, this.defaults, options);

	instance.setup.call(this);
	dom.setup.call(this);
	events.setup.call(this);

	if ( this.$el.prop('disabled') ) {
		this.$el.trigger('disable' + this.ens);
	}

};

$.extend(Stylefileinput.prototype, {

	/**
	 * @param  {Boolean} state
	 * @param  {Object} e
	 */
	toggleDisabledState: function ( state, e ) {
		this.$el.prop('disabled', state);
	},

	handleFocus: function () {

		this.$el.data(meta.ns.dataAttr + '-val', this.$el.val());

	},

	handleCheckChange: function () {

		if ( this.$el.val() && this.$el.val() !== this.$el.data(meta.ns.dataAttr + '-val') ) {
			this.$el.trigger('change' + this.ens);
		}

	},

	handleChange: function () {

		var fileName = this.$el.val().split(/\\/).pop();
		var inputFieldText = fileName;
		var buttonLabel = this.options.labels.buttonChange;

		if ( !fileName ) {
			inputFieldText = this.options.labels.val;
			buttonLabel = this.options.labels.buttonBrowse;
		}

		this.$val
			.text(inputFieldText);

		this.$button
			.text(buttonLabel);

	},

	/**
	 * For IE and Opera, make sure change fires after choosing a file, using an async callback
	 */
	handleClick: function () {

		this.$el.data(meta.ns.dataAttr + '-val', this.$el.val());

		setTimeout($.proxy(this.handleCheckChange, this), 100);

	},
{'fraction_non_alphanumeric': 0.19748031496062993, 'fraction_numerical': 0.001889763779527559, 'mean_word_length': 3.556671449067432, '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': '1025076', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1043, 'n_words': 219}