<commit_before>/*! Input Fit Plugin - v0.0.1 - 2015-07-08
 * https://github.com/Papacidero/inputfit
 *
 * Copyright (c) 2015 <NAME> <<EMAIL>>;
 * Licensed under the MIT license */

(function ($) {

    $.fn.inputFit = function (options) {

        var defaults = {
            'maxFontSize': 40,
            'minFontSize': 5
        };

        var options = $.extend({}, defaults, options);


        var originalFontSize = $(this).css('font-size');
        var originalFontFamily = $(this).css('font-family');
        var originalFontAlignment = $(this).css('text-align');
        var originalFontWeight = $(this).css('font-weight');
        var originalTextTransform = $(this).css('text-transform');
        var maxWidth = $(this).width() - 5;
        var maxHeight = $(this).height();

        $(this).addClass('inputFit');
        //$(this).after('<div id="temp" style="width:' + maxWidth + 'px;height:' + maxHeight + 'px;border: 1px solid red; float: left;"><span class="inputFit" style="display:block; border: 1px solid red; float: left;"></span></div>');
		
		$(this).after('<span class="inputFit" style="display:none; border: 1px solid red; float: left;"></span>');

        $('span.inputFit').css({
            'font-size': originalFontSize,
            'font-family': originalFontFamily,
            'text-align': originalFontAlignment,
            'font-weight': originalFontWeight,
            'text-transform': originalTextTransform
        });


        var actualWidth = '';
        var actualHeight = '';
        var actualFontSize = '';

        function actualSizes() {
            actualWidth = $('span.inputFit').width() + 5;
            actualHeight = $('span.inputFit').height();
            actualFontSize = parseInt($('span.inputFit').css('font-size'));
        }

        function resize() {

            fontSize = actualFontSize * maxWidth / actualWidth * 0.9;
            if (maxWidth < actualWidth) {
                $('.inputFit').css('font-size', fontSize);
            } else if (maxWidth > actualWidth) {
                fontSize = actualFontSize * maxWidth / actualWidth * 0.9;
                if (fontSize <= parseInt(originalFontSize)) {
                    $('.inputFit').css('font-size', fontSize);
                }
            }
        }

        $(this).keydown(function (event) {

            //Using toUpperCase
            $('span.inputFit').text($(this).val().toUpperCase());
            actualSizes();
            resize();
        });

        $(this).keyup(function () {
            //Using toUpperCase
            $('span.inputFit').text($(this).val().toUpperCase());
            actualSizes();

		if($(this).val() == ''){
			$(this).css('font-size',originalFontSize);
			}

        });

    };

})(jQuery);<commit_msg>Some Adjustments on input widht and height<commit_after>/*! Input Fit Plugin - v0.0.1 - 2015-07-08
 * https://github.com/Papacidero/inputfit
 *
 * Copyright (c) 2015 <NAME> <<EMAIL>>;
 * Licensed under the MIT license */

(function ($) {

    $.fn.inputFit = function (options) {

        var defaults = {
            'maxFontSize': 40,
            'minFontSize': 5
        };

        var options = $.extend({}, defaults, options);


        var originalFontSize = $(this).css('font-size');
        var originalFontFamily = $(this).css('font-family');
        var originalFontAlignment = $(this).css('text-align');
        var originalFontWeight = $(this).css('font-weight');
        var originalTextTransform = $(this).css('text-transform');
        var maxWidth = $(this).width();
        var maxHeight = $(this).height();

        $(this).addClass('inputFit');
        
        $(this).after('<span class="inputFit" style="position: absolute; bottom: 0; left: 0; border: 1px solid gray; float: left;"></span>');

        $('span.inputFit').css({
            'font-size': originalFontSize,
            'font-family': originalFontFamily,
            'text-align': originalFontAlignment,
            'font-weight': originalFontWeight,
            'text-transform': originalTextTransform
        });


        var actualWidth = '';
        var actualHeight = '';
        var actualFontSize = '';

        function actualSizes() {
            actualWidth = $('span.inputFit').width();
            actualHeight = $('span.inputFit').height();
            actualFontSize = parseInt($('span.inputFit').css('font-size'));
        }

        function resize() {

            fontSize = actualFontSize * maxWidth / actualWidth * 0.9;
            if (maxWidth < actualWidth) {
                $('input.inputFit').css({'font-size': fontSize, 'height' : maxHeight, 'width' : maxWidth});
            } else if (maxWidth > actualWidth) {
                fontSize = actualFontSize * maxWidth / actualWidth * 0.9;
                if (fontSize <= parseInt(originalFontSize)) {
                    $('input.inputFit').css({'font-size': fontSize, 'height' : maxHeight, 'width' : maxWidth});
                }
            }
        }

        $(this).keydown(function (event) {            

            $('span.inputFit').text($(this).val());
            actualSizes();
            resize();
        });

        $(this).keyup(function () {

            $('span.inputFit').text($(this).val());
            actualSizes();

		if($(this).val() == ''){
			$(this).css('font-size',originalFontSize);
			}

        });

    };

})(jQuery);

$('input').inputFit();
{'fraction_non_alphanumeric': 0.1734467455621302, 'fraction_numerical': 0.009615384615384616, 'mean_word_length': 2.1265895953757226, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, 'https://': 2, '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': '5539248', 'n_tokens_mistral': 1611, 'n_tokens_neox': 1481, 'n_words': 295}