Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Update jquery-watermark.js #1

Open
wants to merge 7 commits into
from

Conversation

Projects
None yet
2 participants

coolj commented Aug 5, 2012

$.fn.watermark = function (params) {
//default values
var settings = $.extend({
'waterAttr' : 'data-water',
'waterCss': { color: 'Gray' },
'activeCss': { color: 'Black' },
'class': 'watermarked',
}, params);

$(this).parents('form').submit(function()
{
    $(this).find('['+settings.waterAttr+']').each(function() {
        if (($(this).val() == $(this).attr(settings.waterAttr)) || (jQuery.trim($(this).val()).length == 0)) {
            $(this).val("");
            $(this).css(settings.activeCss);
            $(this).removeClass(settings.class);
        }
    });
    return true;    
});
//loop
$(this).each(function () {
    if ($(this).val().length == 0) {
        $(this).css(settings.waterCss);
        $(this).addClass(settings.class);
        $(this).val($(this).attr(settings.waterAttr));
    }
    $(this).unbind("focus").focus(function () {
        if (($(this).val() == $(this).attr(settings.waterAttr)) || (jQuery.trim($(this).val()).length == 0)) {
            $(this).val("");
            $(this).css(settings.activeCss);
            $(this).removeClass(settings.class);
        }
    }).blur(function () {
        if (jQuery.trim($(this).val()).length == 0) {
            $(this).val($(this).attr(settings.waterAttr));
            $(this).css(settings.waterCss);
            $(this).addClass(settings.class);
        }
    });
});

}

coolj added some commits Aug 5, 2012

@coolj coolj Update jquery-watermark.js
var settings = $.extend({
    	'waterAttr' : 'data-water',
        'class':	'watermarked',
});  


$(this).parents('form').submit(function()
	{
		$(this).find('['+settings.waterAttr+']').each(function() {
			if (($(this).val() == $(this).attr(settings.waterAttr)) || (jQuery.trim($(this).val()).length == 0)) {
                $(this).val("");
                $(this).css(settings.activeCss);
				$(this).removeClass(settings.class);
            }
        });
		return true;	
	});
9cf54c2
@coolj coolj Update jquery-watermark.js 43a5667
@coolj coolj Update jquery-watermark.js b2dd5a5
@coolj coolj Update jquery-watermark.js 2424091
@coolj coolj Update README.md ecf8eb7
@coolj coolj Update README.md 7244407
@coolj coolj Update README.md 69057d5
Owner

sagivo commented Aug 7, 2012

@coolj - please provide explanation for this pull request. what did you want to change and why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment