<commit_before>(function (Q, $, window, document, undefined) {

/**
 * Q Tools
 * @module Q-tools
 */

/**
 * Activates placeholder effect on any input and textarea elements contained within this jquery.
 * Attribute placeholder must be set for element
 * @class Q placeholders
 * @constructor
 * @param {Object} [options]
 */
Q.Tool.jQuery('Q/placeholders',

function () {
	
	return this.plugin('Q/placeholders', 'setup');
},

{
	// properties
},

{
	setup: function () {
		
		function manage(event) {
			var $this = $(this);
			var $placeholder = $this.data('Q-placeholder');
			if (!$placeholder) {
				return;
			}
			var p;
			if (p = $this.attr('placeholder')) {
				$placeholder.text(p);
				$this.removeAttr('placeholder');
			}
			if ($this.val()) { //  || event.type === 'keypress' || event.type === 'change'
				$placeholder.hide();
			} else {
				$placeholder.show();
			}
		}
		
		$('input', this)
		.add($(this))
		.not('input.Q_leave_alone')
		.not('input[type=file]')
		.not('input[type=hidden]')
		.not('input[type=submit]')
		.add('textarea', this).each(function () {
			var t = this.tagName.toLowerCase();
			if (t != 'input' && t != 'textarea') return;
		
			var $this = $(this);
		
			var plch = $this.attr('placeholder');
			$this.removeAttr('placeholder');
			if(!(plch)) {
				return;
			}

			if (!$this.is(':visible')) {
				return;
			}
			var dim = $this[0].cssDimensions();
			var display = $this.css('display');
			if (display === 'inline') {
				display = 'inline-block';
			}
			var span = $('<span />').css({
				position: 'relative',
				width: dim.width,
				height: dim.height,
				display: display
			}).addClass('Q_placeholders_container');
			var props = {};
			$this.hide(); // to get percentage values, if any, for margins & padding
			Q.each(['left', 'right', 'top', 'bottom'], function (i, pos) {
				props['padding-'+pos] = $this.css('padding-'+pos);
				props['margin-'+pos] = $this.css('margin-'+pos);
				span.css('margin-'+pos, props['margin-'+pos]);
			});
			$this.show();
			$this.wrap(span).css('margin', '0');
			span = $this.parent();
			span.on(Q.Pointer.fastclick, function() {
				$this.trigger('focus');
			});
			var $placeholder = $('<div />').text(plch).css({
				'position': 'absolute',
				'left': $this.position().left,
				'top': $this.position().top,
				'margin': 0,
				'padding-left': parseInt(props['padding-left'])+3+'px',
				'padding-right': props['padding-right'],
				'padding-top': props['padding-top'],
				'padding-bottom': props['padding-bottom'],
				'border-top': 'solid ' + $this.css('border-top-width') + ' transparent',
				'border-left': 'solid ' + $this.css('border-left-width') + ' transparent',
				'box-sizing': $this.css('box-sizing'),
				'font-size': $this.css('font-size'),
				'font-weight': $this.css('font-weight'),
				'line-height': $this.css('line-height'),
				'overflow': 'hidden',
				'width': '100%',
				'height': '100%',
				'text-align': $this.css('text-align'),<commit_msg>Fixed line-height issue in Q/placeholders<commit_after>(function (Q, $, window, document, undefined) {

/**
 * Q Tools
 * @module Q-tools
 */

/**
 * Activates placeholder effect on any input and textarea elements contained within this jquery.
 * Attribute placeholder must be set for element
 * @class Q placeholders
 * @constructor
 * @param {Object} [options]
 */
Q.Tool.jQuery('Q/placeholders',

function () {
	
	return this.plugin('Q/placeholders', 'setup');
},

{
	// properties
},

{
	setup: function () {
		
		function manage(event) {
			var $this = $(this);
			var $placeholder = $this.data('Q-placeholder');
			if (!$placeholder) {
				return;
			}
			var p;
			if (p = $this.attr('placeholder')) {
				$placeholder.text(p);
				$this.removeAttr('placeholder');
			}
			if ($this.val()) { //  || event.type === 'keypress' || event.type === 'change'
				$placeholder.hide();
			} else {
				$placeholder.show();
			}
		}
		
		$('input', this)
		.add($(this))
		.not('input.Q_leave_alone')
		.not('input[type=file]')
		.not('input[type=hidden]')
		.not('input[type=submit]')
		.add('textarea', this).each(function () {
			var t = this.tagName.toLowerCase();
			if (t != 'input' && t != 'textarea') return;
		
			var $this = $(this);
		
			var plch = $this.attr('placeholder');
			$this.removeAttr('placeholder');
			if(!(plch)) {
				return;
			}

			if (!$this.is(':visible')) {
				return;
			}
			var dim = $this[0].cssDimensions();
			var display = $this.css('display');
			if (display === 'inline') {
				display = 'inline-block';
			}
			var span = $('<span />').css({
				position: 'relative',
				width: dim.width,
				height: dim.height,
				display: display
			}).addClass('Q_placeholders_container');
			var props = {};
			$this.hide(); // to get percentage values, if any, for margins & padding
			Q.each(['left', 'right', 'top', 'bottom'], function (i, pos) {
				props['padding-'+pos] = $this.css('padding-'+pos);
				props['margin-'+pos] = $this.css('margin-'+pos);
				span.css('margin-'+pos, props['margin-'+pos]);
			});
			$this.show();
			$this.wrap(span).css('margin', '0');
			span = $this.parent();
			span.on(Q.Pointer.fastclick, function() {
				$this.trigger('focus');
			});
			var lineHeight = $this.css('line-height');
			if (lineHeight === 'normal') {
				lineHeight = $this.height();
			}
			var $placeholder = $('<div />').text(plch).css({
				'position': 'absolute',
				'left': $this.position().left,
				'top': $this.position().top,
				'margin': 0,
				'padding-left': parseInt(props['padding-left'])+3+'px',
				'padding-right': props['padding-right'],
				'padding-top': props['padding-top'],
				'padding-bottom': props['padding-bottom'],
				'border-top': 'solid ' + $this.css('border-top-width') + ' transparent',
				'border-left': 'solid ' + $this.css('border-left-width') + ' transparent',
				'box-sizing': $this.css('box-sizing'),
				'font-size': $this.css('font-size'),
				'font-weight': $this.css('font-weight'),
				'line-height': $this.css('line-height'),
				'overflow': 'hidden',
				'width': '100%',
				'height': '100%',
				'text-align': $this.css('text-align'),
{'fraction_non_alphanumeric': 0.22331368696791093, 'fraction_numerical': 0.0032743942370661427, 'mean_word_length': 3.3949640287769784, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4545289', 'n_tokens_mistral': 2476, 'n_tokens_neox': 2072, 'n_words': 415}