<commit_before>/*!
 * VisualEditor UserInterface TextInputWidget class.
 *
 * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
 * @license The MIT License (MIT); see LICENSE.txt
 */

/**
 * Creates an ve.ui.TextInputWidget object.
 *
 * @class
 * @extends ve.ui.InputWidget
 *
 * @constructor
 * @param {Object} [config] Config options
 * @cfg {string} [placeholder] Placeholder text
 * @cfg {string} [icon] Symbolic name of icon
 */
ve.ui.TextInputWidget = function VeUiTextInputWidget( config ) {
	// Parent constructor
	ve.ui.InputWidget.call( this, config );

	// Properties
	this.pending = 0;

	// Initialization
	this.$.addClass( 've-ui-textInputWidget' );
	if ( config.icon ) {
		this.$.addClass( 've-ui-textInputWidget-decorated' );
		this.$.append(
			$( '<span>' )
				.addClass( 've-ui-textInputWidget-icon ve-ui-icon-' + config.icon )
				.mousedown( ve.bind( function () {
					this.$input.focus();
					return false;
				}, this ) )
		);
	}
	if ( config.placeholder ) {
		this.$input.attr( 'placeholder', config.placeholder );
	}
};

/* Inheritance */

ve.inheritClass( ve.ui.TextInputWidget, ve.ui.InputWidget );

/* Methods */

/**
 * Get input element.
 *
 * @method
 * @param {Object} [config] Config options
 * @return {jQuery} Input element
 */
ve.ui.TextInputWidget.prototype.getInputElement = function ( config ) {
	return config.multiline ? this.$$( '<textarea>' ) : this.$$( '<input>' ).attr( 'type', 'text' );
};

/* Methods */

/**
 * Checks if input is pending.
 *
 * @method
 * @returns {boolean} Input is pending
 */<commit_msg>Text input widget enter event<commit_after>/*!
 * VisualEditor UserInterface TextInputWidget class.
 *
 * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
 * @license The MIT License (MIT); see LICENSE.txt
 */

/**
 * Creates an ve.ui.TextInputWidget object.
 *
 * @class
 * @extends ve.ui.InputWidget
 *
 * @constructor
 * @param {Object} [config] Config options
 * @cfg {string} [placeholder] Placeholder text
 * @cfg {string} [icon] Symbolic name of icon
 * @cfg {boolean} [multiline=false] Allow multiple lines of text
 */
ve.ui.TextInputWidget = function VeUiTextInputWidget( config ) {
	// Parent constructor
	ve.ui.InputWidget.call( this, config );

	// Properties
	this.pending = 0;
	this.multiline = !!config.multiline;

	// Events
	this.$input.on( 'keypress', ve.bind( this.onKeyPress, this ) );

	// Initialization
	this.$.addClass( 've-ui-textInputWidget' );
	if ( config.icon ) {
		this.$.addClass( 've-ui-textInputWidget-decorated' );
		this.$.append(
			$( '<span>' )
				.addClass( 've-ui-textInputWidget-icon ve-ui-icon-' + config.icon )
				.mousedown( ve.bind( function () {
					this.$input.focus();
					return false;
				}, this ) )
		);
	}
	if ( config.placeholder ) {
		this.$input.attr( 'placeholder', config.placeholder );
	}
};

/* Inheritance */

ve.inheritClass( ve.ui.TextInputWidget, ve.ui.InputWidget );

/* Events */

/**
 * User presses enter inside the text box.
 *
 * Not called if input is multiline.
 *
 * @event enter
 */

/* Methods */

/**
 * Handles key press events.
 *
 * @param {jQuery.Event} e Key press event
 * @emits enter If enter key is pressed and input is not multiline
 */
ve.ui.TextInputWidget.prototype.onKeyPress = function ( e ) {
	if ( e.which === ve.Keys.ENTER && !this.multiline ) {
		this.emit( 'enter' );
	}
};

/**
 * Get input element.
 *
 * @method
 * @param {Object} [config] Config options
 * @return {jQuery} Input element
 */
ve.ui.TextInputWidget.prototype.getInputElement = function ( config ) {
	return config.multiline ? this.$$( '<textarea>' ) : this.$$( '<input>' ).attr( 'type', 'text' );
};

/* Methods */

/**
 * Checks if input is pending.
 *
 * @method
 * @returns {boolean} Input is pending
 */
{'fraction_non_alphanumeric': 0.16370390023879014, 'fraction_numerical': 0.004775802600159193, 'mean_word_length': 3.383720930232558, 'pattern_counts': {'":': 0, '<': 9, '<?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': '4661117', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1222, 'n_words': 315}