<commit_before>(function($) {
    // check browser support for placeholder
    $.support.placeholder = 'placeholder' in document.createElement('input');

    // plugin code
    $.fn.placeholder = function(opts) {
        opts = $.extend({
			blurClass: 'placeholderBlur',
			activeClass: 'placeholderFocus',
			overrideSupport: false
		}, opts);

		// we don't have to do anything if the browser supports placeholder
		if(!opts.overrideSupport && $.support.placeholder)
		    return this;

        return this.each(function() {
            var $el = $(this);

            // skip if we do not have the placeholder attribute
            if(!$el.is('[placeholder]'))
                return;

            // we cannot do password fields, but supported browsers can
            if($el.is(':password'))
                return;

            $el.focus(function(){
                var $el = $(this);
                if($el.val() == $el.attr('placeholder'))
                    $el.val('')
                       .removeClass(opts.blurClass)
                       .addClass(opts.activeClass);
            });
            $el.blur(function(){
                var $el = $(this);
                if($el.val() == '')
                  $el.val($el.attr('placeholder'))
                     .removeClass(opts.activeClass)
                     .addClass(opts.blurClass);
            });
            $el.triggerHandler('blur');
        });
    };
})(jQuery);<commit_msg>Fixed bug: If the value is actually set to the same as the placeholder, it's still considered a placeholder Fixed bug: Refresh in firefox pre fills the input field with the placeholder Fixed bug: Val() function returns the placeholder, not an empty string Fixed bug: Submitting a form would submit the placeholder value<commit_after>(function($) {
    // check browser support for placeholder
    $.support.placeholder = 'placeholder' in document.createElement('input');

    // plugin code
	$.fn.placeholder = function(opts) {
		opts = $.extend({
			focusClass: 'placeholderFocus',
			activeClass: 'placeholderActive',
			overrideSupport: false,
			preventRefreshIssues: true
		}, opts);

		// we don't have to do anything if the browser supports placeholder
		if(!opts.overrideSupport && $.support.placeholder)
		    return this;
		
		// Replace the val function to never return placeholders
		$.fn.plVal = $.fn.val;
		$.fn.val = function(value) {
			if(value != undefined)
				return $(this).plVal(value);
			

			if(this[0]) {
        		var el = $(this[0]);
        		if(el.hasClass(opts.activeClass) && el.plVal() == el.attr('placeholder')) {
           			return '';
       			} else {
           	 		return el.plVal();
        		}
    		}
    		return undefined;
		};
		
		// Clear placeholder values upon page reload
		$(window).bind('beforeunload.placeholder', function() {
			console.log('removing values');
			$('input.' + opts.placeholderBlur).val('').attr('autocomplete','off');
		});


        return this.each(function() {
            var $el = $(this);

            // skip if we do not have the placeholder attribute
            if(!$el.is('[placeholder]'))
                return;

            // we cannot do password fields, but supported browsers can
            if($el.is(':password'))
                return;
			
			// Prevent values from being reapplied on refresh
			if(opts.preventRefreshIssues):
				$el.attr('autocomplete','off');

            $el.bind('focus.placeholder', function(){
                var $el = $(this);
                if(this.value == $el.attr('placeholder') && $el.hasClass(opts.activeClass))
                    $el.val('')
                       .removeClass(opts.activeClass)
                       .addClass(opts.focusClass);
            });
            $el.bind('blur.placeholder', function(){
                var $el = $(this);
				
				$el.removeClass(opts.focusClass);

                if(this.value == '')
                  $el.val($el.attr('placeholder'))
                     .addClass(opts.activeClass);
            });

            $el.triggerHandler('blur');
			
			// Prevent incorrect form values being posted
			$el.parents('form').submit(function(){
				$el.triggerHandler('focus.placeholder');
			});

        });
    };
})(jQuery);
{'fraction_non_alphanumeric': 0.13872560545497295, 'fraction_numerical': 0.00047025628967787447, 'mean_word_length': 1.9706703910614525, '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': '6179827', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1081, 'n_words': 284}